diff --git a/detector-model/dependency-reduced-pom.xml b/detector-model/dependency-reduced-pom.xml new file mode 100644 index 000000000..a57ace5df --- /dev/null +++ b/detector-model/dependency-reduced-pom.xml @@ -0,0 +1,64 @@ + + + + hps-java + org.hps + 5.2.2-SNAPSHOT + + 4.0.0 + hps-detector-model + detector-model + detector modeling code based on lcsim framework + + + + maven-shade-plugin + + + package + + shade + + + true + bin + + + + org.hps.detector.DetectorConverter + + + + + hep.testdata.aida:* + + + + + + + + maven-surefire-plugin + + + **/*Test.java + + + + + + + + junit + junit + 4.13.1 + test + + + hamcrest-core + org.hamcrest + + + + + diff --git a/recon/src/main/java/org/hps/recon/filtering/UnbiasedTriggerFilterDriver.java b/recon/src/main/java/org/hps/recon/filtering/UnbiasedTriggerFilterDriver.java new file mode 100644 index 000000000..2511ec681 --- /dev/null +++ b/recon/src/main/java/org/hps/recon/filtering/UnbiasedTriggerFilterDriver.java @@ -0,0 +1,42 @@ +package org.hps.recon.filtering; + +import org.lcsim.event.EventHeader; +import org.lcsim.event.GenericObject; +import org.lcsim.util.Driver; +import org.hps.record.epics.EpicsData; +import org.hps.record.scalers.ScalerData; +import org.hps.record.triggerbank.AbstractIntData; +import org.hps.record.triggerbank.TSData2019; + +/** + * Keep pulser triggered events. Also keep EPICS events, and Scaler events. Drop all other events. + */ +public class UnbiasedTriggerFilterDriver extends Driver { + + public void process(EventHeader event) { + + // 1. keep all events with EPICS data (could also use event tag = 31): + if (EpicsData.read(event) != null) + return; + + // 2. keep all events with Scaler data: + if (ScalerData.read(event) != null) + return; + + // 3. drop event if it doesn't have a TriggerBank + if (!event.hasCollection(GenericObject.class, "TSBank")) + throw new Driver.NextEventException(); + + // 4. keep event if it was from a Pulser trigger: + for (GenericObject gob : event.get(GenericObject.class, "TSBank")) { + if (!(AbstractIntData.getTag(gob) == TSData2019.BANK_TAG)) + continue; + TSData2019 tsd = new TSData2019(gob); + if (tsd.isPulserTrigger() || tsd.isFaradayCupTrigger()) + return; + } + + // 5. Else, drop event: + throw new Driver.NextEventException(); + } +} diff --git a/steering-files/src/main/resources/org/hps/steering/analysis/PhysicsRun2019SVTHitEffKalman.lcsim b/steering-files/src/main/resources/org/hps/steering/analysis/PhysicsRun2019SVTHitEffKalman.lcsim new file mode 100644 index 000000000..8c1453290 --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/analysis/PhysicsRun2019SVTHitEffKalman.lcsim @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CONFIG + + + + + + + + + WARNING + EcalClusters + + + EcalClusters + EcalClustersCorr + + + + + SVTRawTrackerHits + + + + Pileup + false + true + false + false + true + true + false + false + + + + 8.0 + true + 200 + false + + + + false + 40.0 + 400.0 + 20.0 + false + + + + false + + 0.05 + false + 9 + + + + EcalClustersCorr + KalmanFullTracks + KalmanFullTracks + TrackClusterMatcherMinDistance + UnconstrainedV0Candidates_KF + UnconstrainedV0Vertices_KF + BeamspotConstrainedV0Candidates_KF + BeamspotConstrainedV0Vertices_KF + TargetConstrainedV0Candidates_KF + TargetConstrainedV0Vertices_KF + FinalStateParticles_KF + true + false + false + 0.180 + 0.05 + 0.04 + 0.020 + -7.5 + 10.0 + 7.0 + 0.0 + 40.0 + 40 + 40 + false + true + true + false + false + + + + + + ${outputFile}.slcio + + + ${outputFile}.root + + + + + diff --git a/steering-files/src/main/resources/org/hps/steering/analysis/PhysicsRun2021SVTHitEffKalman.lcsim b/steering-files/src/main/resources/org/hps/steering/analysis/PhysicsRun2021SVTHitEffKalman.lcsim new file mode 100644 index 000000000..827558729 --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/analysis/PhysicsRun2021SVTHitEffKalman.lcsim @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CONFIG + + + + + + + + + WARNING + EcalClusters + + + EcalClusters + EcalClustersCorr + + + + + SVTRawTrackerHits + + + + .5 + 1 + Pileup + Migrad + false + true + false + false + true + true + false + false + + + + 8.0 + true + 200 + false + + + + false + 40.0 + 400.0 + 20.0 + false + + + + false + + 0.05 + false + 9 + + + + EcalClustersCorr + KalmanFullTracks + KalmanFullTracks + TrackClusterMatcherMinDistance + UnconstrainedV0Candidates_KF + UnconstrainedV0Vertices_KF + BeamspotConstrainedV0Candidates_KF + BeamspotConstrainedV0Vertices_KF + TargetConstrainedV0Candidates_KF + TargetConstrainedV0Vertices_KF + FinalStateParticles_KF + true + false + false + 0.180 + 0.05 + 0.04 + 0.020 + -7.5 + 10.0 + 7.0 + 0.0 + 40.0 + 40 + 40 + false + true + true + false + false + + + + + + cake.slcio + + + cake_svtEfficiency.root + + + + diff --git a/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_pass0_recon_evio_optimized.lcsim b/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_pass0_recon_evio_optimized.lcsim new file mode 100644 index 000000000..d3cb1db9d --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_pass0_recon_evio_optimized.lcsim @@ -0,0 +1,405 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EcalCalHits EcalClusters EcalClustersCorr FinalStateParticles UnconstrainedMollerCandidates UnconstrainedMollerVertices UnconstrainedV0Candidates UnconstrainedV0Vertices TargetConstrainedMollerCandidates TargetConstrainedMollerVertices TargetConstrainedV0Candidates TargetConstrainedV0Vertices BeamspotConstrainedMollerCandidates BeamspotConstrainedMollerVertices BeamspotConstrainedV0Candidates BeamspotConstrainedV0Vertices GBLKinkData GBLKinkDataRelations MatchedToGBLTrackRelations HelicalTrackHits HelicalTrackHitRelations MatchedTracks GBLTracks MatchedToGBLTrackRelations PartialTracks RotatedHelicalTrackHits RotatedHelicalTrackHitRelations SVTFittedRawTrackerHits SVTShapeFitParameters StripClusterer_SiTrackerHitStrip1D TrackData TrackDataRelations TrackResiduals TrackResidualsRelations + + + 1000 + + + svt_readout_overlap_good + + + + + + + + + CONFIG + + + + + + + + + WARNING + EcalClusters + + + EcalClusters + EcalClustersCorr + + + + SVTRawTrackerHits + + + .5 + 1 + Pileup + Migrad + false + true + false + false + true + true + false + true + false + + + 24.0 + 3.0 + false + 400 + 4.0 + 1.0 + 3.0 + 3.0 + true + true + false + + + false + 40.0 + 400.0 + 20.0 + false + + + + + + + + Tracks_s123_c4_e56 + HPS_s123_c4_e56_4hit.xml + false + 1000.0 + 250 + + + Tracks_s123_c5_e46 + HPS_s123_c5_e46_4hit.xml + false + 1000.0 + 250 + + + Tracks_s567_c4_e123 + HPS_s567_c4_e123.xml + false + + 20.0 + 250 + + + Tracks_s456_c3_e127 + HPS_s456_c3_e127.xml + false + + 20.0 + 250 + + + Tracks_s356_c7_e124 + HPS_s356_c7_e124.xml + false + + 20.0 + 250 + + + Tracks_s235_c6_e147 + HPS_s235_c6_e147.xml + false + + 20.0 + 250 + + + Tracks_s234_c6_e157 + HPS_s234_c6_e157.xml + false + + 20.0 + 250 + + + Tracks_s345_c2_e16 + HPS_s345_c2_e16.xml + false + 8.0 + 250 + + + Tracks_s345_c6_e7 + HPS_s345_c6_e7_2019.xml + false + 20.0 + 250 + + + Tracks_s345_c7_e6 + HPS_s345_c7_e6_2019.xml + false + 20.0 + 250 + + + Tracks_s346_c7_e5 + HPS_s346_c7_e5_2019.xml + false + 20.0 + 250 + + + Tracks_s346_c5_e7 + HPS_s346_c5_e7_2019.xml + false + 20.0 + 250 + + + Tracks_s456_c3_e7 + HPS_s456_c3_e7_2019.xml + false + 20.0 + 250 + + + Tracks_s456_c7_e3 + HPS_s456_c7_e3_2019.xml + false + 20.0 + 250 + + + Tracks_s457_c3_e6 + HPS_s457_c3_e6_2019.xml + false + 20.0 + 250 + + + Tracks_s457_c6_e3 + HPS_s457_c6_e3_2019.xml + false + 20.0 + 250 + + + Tracks_s567_c3_e4 + HPS_s567_c3_e4_2019.xml + false + 20.0 + 250 + + + Tracks_s567_c4_e3 + HPS_s567_c4_e3_2019.xml + false + 20.0 + 250 + + + + + + + true + 5 + false + false + ${outputFile}_millepede.bin + + + + + + + 0.05 + false + + + ${outputFile}_gblplots.root + GBLTracks + + + + + EcalClustersCorr + GBLTracks + GBLTracks + TrackClusterMatcherMinDistance + true + false + false + 0.180 + 0.05 + 0.04 + 0.020 + -7.5 + 7.0 + 7.0 + 0.0 + 40.0 + 40 + 40 + false + false + true + false + false + + + EcalClustersCorr + KalmanFullTracks + KalmanFullTracks + TrackClusterMatcherMinDistance + UnconstrainedV0Candidates_KF + UnconstrainedV0Vertices_KF + BeamspotConstrainedV0Candidates_KF + BeamspotConstrainedV0Vertices_KF + TargetConstrainedV0Candidates_KF + TargetConstrainedV0Vertices_KF + FinalStateParticles_KF + true + false + false + 0.180 + 0.05 + 0.04 + 0.020 + -7.5 + 7.0 + 7.0 + 0.0 + 40.0 + 40 + 40 + false + true + true + false + true + UnconstrainedMollerCandidates_KF + UnconstrainedMollerVertices_KF + BeamspotConstrainedMollerCandidates_KF + BeamspotConstrainedMollerVertices_KF + TargetConstrainedMollerCandidates_KF + TargetConstrainedMollerVertices_KF + + + + ${outputFile}.slcio + + + ${outputFile}.root + + + ${outputFile}.root + + + + all + + + all + true + + + all + EcalClustersCorr + false + + + all + + + all + GBLTracks + + + all + + + all + true + + + all + true + + + all + true + + + + all + + + + diff --git a/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java b/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java index 60703937c..9e58d9954 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java @@ -30,9 +30,13 @@ public class DataTrackerHitDriver extends Driver { private double meanTime = 0.0; private double timeWindow = 72.0; private double neighborDeltaT = 24.0; + private double neighborDeltaTSigma = 3.0; + private double doTimeError = 0.0; private int clusterMaxSize = 10; private int clusterCentralStripAveragingThreshold = 4; - + private boolean doDeadFix = false; + private boolean doVSplit = false; + // Clustering errors by number of TrackerHits. private static final double clusterErrorMultiplier = 1.0; private double oneClusterErr = clusterErrorMultiplier / Math.sqrt(12.); @@ -74,6 +78,10 @@ public void setClusterSeedThreshold(double clusterSeedThreshold) { this.clusterSeedThreshold = clusterSeedThreshold; } + public void setDoTimeError(double doTimeError) { + this.doTimeError = doTimeError; + } + public void setClusterNeighborThreshold(double clusterNeighborThreshold) { this.clusterNeighborThreshold = clusterNeighborThreshold; } @@ -82,6 +90,14 @@ public void setClusterThreshold(double clusterThreshold) { this.clusterThreshold = clusterThreshold; } + public void setDoDeadFix(boolean doDeadFix) { + this.doDeadFix = doDeadFix; + } + + public void setDoVSplit(boolean doVSplit) { + this.doVSplit = doVSplit; + } + public void setMeanTime(double meanTime) { this.meanTime = meanTime; } @@ -94,6 +110,11 @@ public void setNeighborDeltaT(double neighborDeltaT) { this.neighborDeltaT = neighborDeltaT; } + public void setNeighborDeltaTSigma(double neighborDeltaTSigma) { + this.neighborDeltaTSigma = neighborDeltaTSigma; + } + + public void setClusterMaxSize(int clusterMaxSize) { this.clusterMaxSize = clusterMaxSize; } @@ -160,11 +181,16 @@ public void detectorChanged(Detector detector) { stripClusteringAlgo.setMeanTime(meanTime); stripClusteringAlgo.setTimeWindow(timeWindow); stripClusteringAlgo.setNeighborDeltaT(neighborDeltaT); + stripClusteringAlgo.setNeighborDeltaTSigma(neighborDeltaTSigma); + stripClusteringAlgo.setDoTimeError(doTimeError); + stripClusteringAlgo.setDoDeadFix(doDeadFix); + stripClusteringAlgo.setDoVSplit(doVSplit); stripClusterer = new StripMaker(stripSim, stripClusteringAlgo); stripClusterer.setMaxClusterSize(clusterMaxSize); stripClusterer.setCentralStripAveragingThreshold(clusterCentralStripAveragingThreshold); stripClusterer.setDebug(debug); + stripClusterer.setDoTimeError(doTimeError); // Set the cluster errors. DefaultSiliconResolutionModel model = new DefaultSiliconResolutionModel(); diff --git a/tracking/src/main/java/org/hps/recon/tracking/FittedRawTrackerHit.java b/tracking/src/main/java/org/hps/recon/tracking/FittedRawTrackerHit.java index c8318d9f9..cf3fc3e6f 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/FittedRawTrackerHit.java +++ b/tracking/src/main/java/org/hps/recon/tracking/FittedRawTrackerHit.java @@ -26,6 +26,9 @@ public double getT0() { public double getAmp() { return getShapeFitParameters().getAmp(); } + public double getT0Err() { + return getShapeFitParameters().getT0Err(); + } public static RawTrackerHit getRawTrackerHit(LCRelation rel) { return (RawTrackerHit) rel.getFrom(); @@ -42,6 +45,9 @@ public static double getT0(LCRelation rel) { public static double getAmp(LCRelation rel) { return ShapeFitParameters.getAmp(getShapeFitParameters(rel)); } + public static double getT0Err(LCRelation rel) { + return ShapeFitParameters.getT0Err(getShapeFitParameters(rel)); + } /** * Get the fit chi2 probability. diff --git a/tracking/src/main/java/org/hps/recon/tracking/NearestNeighborRMSClusterer.java b/tracking/src/main/java/org/hps/recon/tracking/NearestNeighborRMSClusterer.java index 865199fcd..cfee9dd5c 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/NearestNeighborRMSClusterer.java +++ b/tracking/src/main/java/org/hps/recon/tracking/NearestNeighborRMSClusterer.java @@ -8,6 +8,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.ArrayList; +import java.util.Collections; import org.apache.commons.math3.special.Gamma; @@ -25,9 +27,13 @@ public class NearestNeighborRMSClusterer implements ClusteringAlgorithm { private double _neighbor_threshold; private double _cluster_threshold; private double _meanTime = 24; - private double _timeWindow = 48; + private double _timeWindow = 48; private double _neighborDeltaT = Double.POSITIVE_INFINITY; + private double _neighborDeltaTSigma = Double.POSITIVE_INFINITY; private final double _minChiProb = Gamma.regularizedGammaQ(4, 20); + private double _doTimeError = 0.0; + private boolean _doDeadFix = false; + private boolean _doVSplit = false; /** * Instantiate NearestNeighborRMS with specified thresholds. Seed threshold @@ -58,6 +64,15 @@ public void setNeighborDeltaT(double _neighborDeltaT) { this._neighborDeltaT = _neighborDeltaT; } + public void setNeighborDeltaTSigma(double _neighborDeltaTSigma) { + this._neighborDeltaTSigma = _neighborDeltaTSigma; + } + + public void setDoDeadFix(boolean _doDeadFix){ + this._doDeadFix = _doDeadFix; + } + + /** * Instantiate NearestNeighborRMS with default thresholds: * @@ -77,6 +92,10 @@ public void setSeedThreshold(double seed_threshold) { _seed_threshold = seed_threshold; } + public void setDoTimeError(double doTimeError) { + _doTimeError = doTimeError; + } + /** * Set the neighbor threshold. Units are RMS noise. * @@ -95,6 +114,10 @@ public void setClusterThreshold(double cluster_threshold) { _cluster_threshold = cluster_threshold; } + public void setDoVSplit(boolean doVSplit){ + _doVSplit = doVSplit; + } + /** * Use a nearest neighbor algorithm to create clusters. * @@ -115,6 +138,7 @@ public List> findClusters(List fittedHits) { int mapsize = 2 * fittedHits.size(); Set clusterableSet = new HashSet(mapsize); + Map channel_to_hit = new HashMap(mapsize); // Create list of channel numbers to be used as cluster seeds @@ -126,12 +150,17 @@ public List> findClusters(List fittedHits) { for (LCRelation fittedHit : fittedHits) { RawTrackerHit rawHit = FittedRawTrackerHit.getRawTrackerHit(fittedHit); - + + // get the channel number for this hit SiTrackerIdentifierHelper sid_helper = (SiTrackerIdentifierHelper) rawHit.getIdentifierHelper(); IIdentifier id = rawHit.getIdentifier(); int channel_number = sid_helper.getElectrodeValue(id); + if(_doDeadFix){ + if(((HpsSiSensor) rawHit.getDetectorElement()).isBadChannel(channel_number)){continue;} + } + // Check for duplicate RawTrackerHits or channel numbers if (channel_to_hit.containsKey(channel_number)) { //TODO: be smarter about this @@ -146,17 +175,15 @@ public List> findClusters(List fittedHits) { // Get the signal from the readout chip double signal = FittedRawTrackerHit.getAmp(fittedHit); - double noiseRMS = 0; + double noiseRMS = 0; for(int sampleN = 0; sampleN < HPSSVTConstants.TOTAL_NUMBER_OF_SAMPLES; sampleN++){ noiseRMS += ((HpsSiSensor) rawHit.getDetectorElement()).getNoise(channel_number, sampleN); } noiseRMS = noiseRMS/HPSSVTConstants.TOTAL_NUMBER_OF_SAMPLES; - // Mark this hit as available for clustering if it is above the neighbor threshold if (signal / noiseRMS >= _neighbor_threshold && passChisqCut(fittedHit)) { clusterableSet.add(channel_number); } - // Add this hit to the list of seeds if it is above the seed threshold if (signal / noiseRMS >= _seed_threshold && passTimingCut(fittedHit) && passChisqCut(fittedHit)) { cluster_seeds.add(channel_number); @@ -177,6 +204,7 @@ public List> findClusters(List fittedHits) { // Create a new cluster List cluster = new ArrayList(); double cluster_signal = 0.; + double time_signal = 0.; double cluster_noise_squared = 0.; double cluster_weighted_time = 0.; @@ -195,16 +223,30 @@ public List> findClusters(List fittedHits) { cluster.add(channel_to_hit.get(clustered_cell)); LCRelation hit = channel_to_hit.get(clustered_cell); cluster_signal += FittedRawTrackerHit.getAmp(hit); + + time_signal += 1.0/FittedRawTrackerHit.getT0Err(hit); + double strip_noise = 0; for(int sampleN = 0; sampleN < HPSSVTConstants.TOTAL_NUMBER_OF_SAMPLES; sampleN++){ strip_noise += ((HpsSiSensor) FittedRawTrackerHit.getRawTrackerHit(hit).getDetectorElement()).getNoise(clustered_cell, sampleN); } strip_noise = strip_noise/HPSSVTConstants.TOTAL_NUMBER_OF_SAMPLES; cluster_noise_squared += Math.pow(strip_noise, 2); - cluster_weighted_time += FittedRawTrackerHit.getT0(hit) * FittedRawTrackerHit.getAmp(hit); - Collection neighbor_channels = getNearestNeighborCells(clustered_cell); + if(_doTimeError==1.0){ + cluster_weighted_time += FittedRawTrackerHit.getT0(hit)/FittedRawTrackerHit.getT0Err(hit); + }else{ + cluster_weighted_time += FittedRawTrackerHit.getT0(hit)*FittedRawTrackerHit.getAmp(hit); + } + boolean left=((HpsSiSensor) FittedRawTrackerHit.getRawTrackerHit(hit).getDetectorElement()).isBadChannel(clustered_cell-1); + boolean right=((HpsSiSensor) FittedRawTrackerHit.getRawTrackerHit(hit).getDetectorElement()).isBadChannel(clustered_cell+1); + + left=(left)&&(_doDeadFix); + right=(right)&&(_doDeadFix); - // Now loop over the neighbors and see if we can add them to the cluster + Collection neighbor_channels = getNearestNeighborCells(clustered_cell,left,right); + + + // Now loop over the neighbors and see if we can add them to the cluster for (int channel : neighbor_channels) { // Check if this neighbor channel is still available for clustering @@ -213,13 +255,18 @@ public List> findClusters(List fittedHits) { } LCRelation neighbor_hit = channel_to_hit.get(channel); - if (Math.abs(FittedRawTrackerHit.getT0(neighbor_hit) - cluster_weighted_time / cluster_signal) > _neighborDeltaT) { - continue; + if(_doTimeError==1.0){ + if (Math.abs(FittedRawTrackerHit.getT0(neighbor_hit) - cluster_weighted_time / time_signal)/FittedRawTrackerHit.getT0Err(neighbor_hit) > _neighborDeltaTSigma) { + continue; + } + }else{ + if (Math.abs(FittedRawTrackerHit.getT0(neighbor_hit) - cluster_weighted_time / cluster_signal) > _neighborDeltaT) { + continue; + } } - // Add channel to the list of unchecked clustered channels - // and mark it unavailable for clustering - unchecked.addLast(channel); + // and mark it unavailable for clustering + unchecked.addLast(channel); clusterableSet.remove(channel); } // end of loop over neighbor cells @@ -228,7 +275,15 @@ public List> findClusters(List fittedHits) { // Finished with this cluster, check cluster threshold and add it to the list of // clusters if (cluster.size() > 0 && cluster_signal / Math.sqrt(cluster_noise_squared) > _cluster_threshold) { - cluster_list.add(cluster); + if(!(_doVSplit)||cluster.size()<=2){cluster_list.add(cluster);} + else{ + ArrayList> vloc = hasV(cluster); + for(int i=0;i> findClusters(List fittedHits) { // Finished finding clusters return cluster_list; } + //WILL RETURN THE LIST OF SPLIT CLUSTERS, THOUGH NOT CHECKED BY SIGNIFICANCE + private ArrayList> hasV(List cluster){ + ArrayList vloc = new ArrayList(); + int minChan=1000000; + int maxChan=-1; + //CHANNELS AREN'T ORDERED PROPERLY, SO YOU HAVE TO ORDER THEM + for(int I=0;ImaxChan){ + maxChan = channel_number; + } + } + //Now that you have the min and max channel, you can do a scan of the triplets + vloc.add(minChan); + for(int I=minChan;I<=maxChan-2;I++){ + double amp1=-10000.0; + double amp2=1000000.0; + double amp3=-10000.0; + int chan2=-1; + int index2=-1; + for(int II=0;IIamp2)&&(amp3>amp2)){ + vloc.add(chan2); + ShapeFitParameters param = (ShapeFitParameters)(FittedRawTrackerHit.getShapeFitParameters(cluster.get(index2))); + param.setAmp(FittedRawTrackerHit.getAmp(cluster.get(index2))/2.0); + } + } + vloc.add(maxChan); + ArrayList> clusters = new ArrayList>(); + //System.out.println("Start of New Clustering"); + for(int I=0;I clusterS = new ArrayList(); + for(int II=vloc.get(I);II<=vloc.get(I+1);II++){ + for(int III=0;III cluster){ + double cluster_signal = 0; + double cluster_noise_squared = 0; + for(int I=0;I _cluster_threshold); + } private boolean passTimingCut(LCRelation fittedHit) { double time = FittedRawTrackerHit.getT0(fittedHit); @@ -246,15 +394,39 @@ private boolean passChisqCut(LCRelation fittedHit) { return FittedRawTrackerHit.getChi2Prob(fittedHit) > _minChiProb; } - public Collection getNearestNeighborCells(int cell) { - Collection neighbors = new ArrayList(2); - for (int ineigh = -1; ineigh <= 1; ineigh = ineigh + 2) { - int neighbor_cell = cell + ineigh; + public Collection getNearestNeighborCells(int cell,boolean left,boolean right) { + if(left){ + Collection neighbors = new ArrayList(3); + int neighbor_cell = cell + 1; if (isValidCell(neighbor_cell)) { + neighbors.add(neighbor_cell); + } + neighbor_cell = cell - 2; + if (isValidCell(neighbor_cell)) { neighbors.add(neighbor_cell); + } + return neighbors; + }else if(right){ + Collection neighbors = new ArrayList(3); + int neighbor_cell = cell - 1; + if (isValidCell(neighbor_cell)) { + neighbors.add(neighbor_cell); + } + neighbor_cell = cell + 2; + if (isValidCell(neighbor_cell)) { + neighbors.add(neighbor_cell); + } + return neighbors; + }else{ + Collection neighbors = new ArrayList(2); + for (int ineigh = -1; ineigh <= 1; ineigh = ineigh + 2) { + int neighbor_cell = cell + ineigh; + if (isValidCell(neighbor_cell)) { + neighbors.add(neighbor_cell); + } } + return neighbors; } - return neighbors; } public boolean isValidCell(int cell) { diff --git a/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java b/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java index bfbff22b2..2d03af98f 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java @@ -60,6 +60,9 @@ public class RawTrackerHitFitterDriver extends Driver { private double trigTimeScale = 43.0;// the mean time of the trigger...changes with run period!!! 43.0 is for 2015 Eng. Run private double trigTimeOffset = 14.0; private double tsCorrectionScale = 240; + private double chiSqrThresh = .5; + + private int doOldDT = 1; private boolean isFirstEvent=true; @@ -70,6 +73,14 @@ public class RawTrackerHitFitterDriver extends Driver { * * @param useTruthTime */ + public void setChiSqrThresh(double chiSqrThresh){ + this.chiSqrThresh = chiSqrThresh; + } + + public void setDoOldDT(int doOldDT){ + this.doOldDT = doOldDT; + } + public void setUseTruthTime(boolean useTruthTime) { this.useTruthTime = useTruthTime; } @@ -132,9 +143,9 @@ public void setFitAlgorithm(String fitAlgorithm) { else if (fitAlgorithm.equals("Linear")) fitter = new ShaperLinearFitAlgorithm(1); else if (fitAlgorithm.equals("PileupAlways")) - fitter = new ShaperPileupFitAlgorithm(1.0); + fitter = new ShaperPileupFitAlgorithm(1.0,this.doOldDT); else if (fitAlgorithm.equals("Pileup")) - fitter = new ShaperPileupFitAlgorithm(); + fitter = new ShaperPileupFitAlgorithm(this.chiSqrThresh,this.doOldDT); else throw new RuntimeException("Unrecognized fitAlgorithm: " + fitAlgorithm); } diff --git a/tracking/src/main/java/org/hps/recon/tracking/ShaperPileupFitAlgorithm.java b/tracking/src/main/java/org/hps/recon/tracking/ShaperPileupFitAlgorithm.java index 6384165ef..ce8a05eca 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/ShaperPileupFitAlgorithm.java +++ b/tracking/src/main/java/org/hps/recon/tracking/ShaperPileupFitAlgorithm.java @@ -9,16 +9,18 @@ public class ShaperPileupFitAlgorithm implements ShaperFitAlgorithm { ShaperLinearFitAlgorithm twoPulseFitter = new ShaperLinearFitAlgorithm(2); private String fitTimeMinimizer = "Simplex"; private boolean debug = false; - private double refitThreshold = 0.5; + private double refitThreshold = .75; private int totalFits = 0; private int refitAttempts = 0; private int refitsAccepted = 0; - + private int doOldDT = 1; + public ShaperPileupFitAlgorithm() { } - public ShaperPileupFitAlgorithm(double threshold) { + public ShaperPileupFitAlgorithm(double threshold,int DT) { refitThreshold = threshold; + doOldDT = DT; } @Override @@ -29,18 +31,21 @@ public void setFitTimeMinimizer(String fitTimeMinimizer) { //===> public Collection fitShape(RawTrackerHit rth, HPSSVTCalibrationConstants.ChannelConstants constants) { public Collection fitShape(RawTrackerHit rth, PulseShape shape) { - //===> Collection fittedPulses = onePulseFitter.fitShape(rth, constants); Collection fittedPulses = onePulseFitter.fitShape(rth, shape); double singlePulseChiProb = fittedPulses.iterator().next().getChiProb(); totalFits++; if (singlePulseChiProb < refitThreshold) { refitAttempts++; - //===> Collection doublePulse = twoPulseFitter.fitShape(rth, constants); Collection doublePulse = twoPulseFitter.fitShape(rth, shape); - double doublePulseChiProb = doublePulse.iterator().next().getChiProb(); + ShapeFitParameters doubleParam = doublePulse.iterator().next(); + double doublePulseChiProb = doubleParam.getChiProb(); + double time1 = doubleParam.getT0(); + double time2 = fittedPulses.iterator().next().getT0(); if (doublePulseChiProb > singlePulseChiProb) { - refitsAccepted++; - fittedPulses = doublePulse; + if(((time2-time1)*(time2-time1)>40.0)||(doOldDT==1)){ + refitsAccepted++; + fittedPulses = doublePulse; + } } } if (debug && totalFits % 10000 == 0) { diff --git a/tracking/src/main/java/org/hps/recon/tracking/StripMaker.java b/tracking/src/main/java/org/hps/recon/tracking/StripMaker.java index e6d7152e0..a1791d0ce 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/StripMaker.java +++ b/tracking/src/main/java/org/hps/recon/tracking/StripMaker.java @@ -46,6 +46,8 @@ public class StripMaker { //Map _strip_map = new HashMap(); Map< LCRelation, Integer > stripMap_ = new HashMap< LCRelation, Integer >(); + double _doTimeError = 0.0; + boolean _debug = false; private SiliconResolutionModel _res_model = new DefaultSiliconResolutionModel(); @@ -66,6 +68,10 @@ public StripMaker(SiSensorSim simulation, ClusteringAlgorithm algo) { _simulation = simulation; } + public void setDoTimeError(double doTimeError){ + _doTimeError = doTimeError; + } + public String getName() { return _NAME; } @@ -176,8 +182,7 @@ public List makeHits(SiSensor sensor, SiSensorElectrodes electrode List hits = new ArrayList(); // Make a pixel hit from this cluster - for (List cluster : cluster_list) - + for (List cluster : cluster_list){ // Make a TrackerHit from the cluster if it meets max cluster size requirement if (cluster.size() <= _max_cluster_nstrips) { SiTrackerHitStrip1D hit = makeTrackerHit(cluster, electrodes); @@ -186,6 +191,7 @@ public List makeHits(SiSensor sensor, SiSensorElectrodes electrode hits.add(hit); sensor.getReadout().addHit(hit); } + } if (_debug) System.out.println(this.getClass().getSimpleName() + "::makeHits : Returning " + hits.size() + " hits "); return hits; @@ -211,8 +217,14 @@ private SiTrackerHitStrip1D makeTrackerHit(List cluster, SiSensorEle double energy = getEnergy(cluster); TrackerHitType type = new TrackerHitType(TrackerHitType.CoordinateSystem.GLOBAL, TrackerHitType.MeasurementType.STRIP_1D); List rth_cluster = new ArrayList(); - for (LCRelation bth : cluster) + for (LCRelation bth : cluster){ rth_cluster.add(FittedRawTrackerHit.getRawTrackerHit(bth)); + RawTrackerHit rawHit = FittedRawTrackerHit.getRawTrackerHit(bth); + SiTrackerIdentifierHelper sid_helper = (SiTrackerIdentifierHelper) rawHit.getIdentifierHelper(); + IIdentifier id = rawHit.getIdentifier(); + int channel_number = sid_helper.getElectrodeValue(id); + double amp1=FittedRawTrackerHit.getAmp(bth); + } SiTrackerHitStrip1D hit = new SiTrackerHitStrip1D(position, covariance, energy, time, rth_cluster, type); if (_debug) System.out.println(this.getClass().getSimpleName() + " SiTrackerHitStrip1D created at " + position + "(" + hit.getPositionAsVector().toString() + ")" + " E " + energy + " time " + time); @@ -294,10 +306,14 @@ private double getTime(List cluster) { double signal = FittedRawTrackerHit.getAmp(hit); double time = FittedRawTrackerHit.getT0(hit); - - time_sum += time * signal * signal; - signal_sum += signal * signal; - + double tErr = FittedRawTrackerHit.getT0Err(hit); + if(_doTimeError==1.0){ + time_sum += time/tErr; + signal_sum += 1.0/tErr; + }else{ + time_sum += time * signal * signal; + signal_sum += signal * signal; + } } return time_sum / signal_sum; }