Author: [log in to unmask] Date: Wed Sep 9 15:49:35 2015 New Revision: 3570 Log: identify and split out partial tracks Modified: java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconMC_Pass2.lcsim java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon_Pass2.lcsim java/trunk/tracking/src/main/java/org/hps/recon/tracking/MergeTrackCollections.java Modified: java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java ============================================================================= --- java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java (original) +++ java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java Wed Sep 9 15:49:35 2015 @@ -36,6 +36,8 @@ /** Utility used to determine if a track and cluster are matched */ TrackClusterMatcher matcher = new TrackClusterMatcher(); + String[] trackCollectionNames = null; + /** * Sets the name of the LCIO collection for beam spot constrained V0 * candidate particles. @@ -152,6 +154,15 @@ */ public void setUnconstrainedV0VerticesColName(String unconstrainedV0VerticesColName) { this.unconstrainedV0VerticesColName = unconstrainedV0VerticesColName; + } + + /** + * Set the names of the LCIO track collections used as input. + * + * @param trackCollectionNames Array of collection names. If not set, use all Track collections in the event. + */ + public void setTrackCollectionNames(String[] trackCollectionNames) { + this.trackCollectionNames = trackCollectionNames; } /** @@ -365,12 +376,19 @@ // collection and add it to the list of collections. This is // needed in order to create final state particles from the the // Ecal clusters in the event. - List<List<Track>> trackCollections; - if (event.hasCollection(Track.class)) { - trackCollections = event.get(Track.class); + List<List<Track>> trackCollections = new ArrayList<List<Track>>(); + if (trackCollectionNames != null) { + for (String collectionName : trackCollectionNames) { + if (event.hasCollection(Track.class, collectionName)) { + trackCollections.add(event.get(Track.class, collectionName)); + } + } } else { - trackCollections = new ArrayList<List<Track>>(0); - trackCollections.add(new ArrayList<Track>(0)); + if (event.hasCollection(Track.class)) { + trackCollections = event.get(Track.class); + } else { + trackCollections.add(new ArrayList<Track>(0)); + } } // Instantiate new lists to store reconstructed particles and Modified: java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconMC_Pass2.lcsim ============================================================================= --- java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconMC_Pass2.lcsim (original) +++ java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconMC_Pass2.lcsim Wed Sep 9 15:49:35 2015 @@ -123,32 +123,12 @@ <driver name="GBLRefitterDriver" type="org.hps.recon.tracking.gbl.HpsGblRefitter"/> <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> <ecalCollectionName>EcalCalHits</ecalCollectionName> - <use2014Gain>false</use2014Gain> - <useTimestamps>false</useTimestamps> - <useTruthTime>false</useTruthTime> - <useRunningPedestal>false</useRunningPedestal> - <useTimeWalkCorrection>false</useTimeWalkCorrection> - <emulateFirmware>true</emulateFirmware> - <emulateMode7>true</emulateMode7> - <leadingEdgeThreshold>12</leadingEdgeThreshold> - <nsa>100</nsa> - <nsb>20</nsb> - <nPeak>3</nPeak> - <useFit>true</useFit> <fixShapeParameter>true</fixShapeParameter> <globalFixedPulseWidth>2.4</globalFixedPulseWidth> - <!--<debug>true</debug>--> </driver> <driver name="ReconClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> <logLevel>WARNING</logLevel> <outputClusterCollectionName>EcalClusters</outputClusterCollectionName> - <hitEnergyThreshold>0.0075</hitEnergyThreshold> - <seedEnergyThreshold>0.050</seedEnergyThreshold> - <clusterEnergyThreshold>0.100</clusterEnergyThreshold> - <minTime>0.0</minTime> - <timeWindow>25.0</timeWindow> - <useTimeCut>true</useTimeCut> - <writeRejectedHitCollection>false</writeRejectedHitCollection> </driver> <driver name="GTPOnlineClusterer" type="org.hps.recon.ecal.cluster.ClusterDriver"> <logLevel>WARNING</logLevel> @@ -160,10 +140,10 @@ <driver name="CopyCluster" type="org.hps.recon.ecal.cluster.CopyClusterCollectionDriver"> <inputCollectionName>EcalClusters</inputCollectionName> <outputCollectionName>EcalClustersCorr</outputCollectionName> - <storeHits>true</storeHits> </driver> <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"> <ecalClusterCollectionName>EcalClustersCorr</ecalClusterCollectionName> + <trackCollectionNames>MatchedTracks GBLTracks</trackCollectionNames> </driver> <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" /> <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver"> Modified: java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon_Pass2.lcsim ============================================================================= --- java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon_Pass2.lcsim (original) +++ java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon_Pass2.lcsim Wed Sep 9 15:49:35 2015 @@ -132,6 +132,7 @@ <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" /> <driver name="ReconParticleDriver" type="org.hps.recon.particle.HpsReconParticleDriver" > <ecalClusterCollectionName>EcalClustersCorr</ecalClusterCollectionName> + <trackCollectionNames>MatchedTracks GBLTracks</trackCollectionNames> </driver> <driver name="GBLOutputDriver" type="org.hps.recon.tracking.gbl.GBLOutputDriver"/> <driver name="GBLRefitterDriver" type="org.hps.recon.tracking.gbl.HpsGblRefitter"/> Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/MergeTrackCollections.java ============================================================================= --- java/trunk/tracking/src/main/java/org/hps/recon/tracking/MergeTrackCollections.java (original) +++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/MergeTrackCollections.java Wed Sep 9 15:49:35 2015 @@ -25,14 +25,45 @@ public class MergeTrackCollections extends Driver { private String outputCollectionName = "MatchedTracks"; + private String partialTrackCollectionName = "PartialTracks"; private boolean removeCollections = true; + private double badHitChisq = 10.0; + /** + * Name of the LCIO collection containing all good tracks. + * + * @param outputCollectionName Defaults to MatchedTracks. + */ public void setOutputCollectionName(String outputCollectionName) { this.outputCollectionName = outputCollectionName; } + /** + * Name of the LCIO collection containing partial tracks (tracks whose hit + * content is a strict subset of another track). + * + * @param partialTrackCollectionName Defaults to PartialTracks. + */ + public void setPartialTrackCollectionName(String partialTrackCollectionName) { + this.partialTrackCollectionName = partialTrackCollectionName; + } + + /** + * Remove existing track collections after merging them. + * + * @param removeCollections Default to true. + */ public void setRemoveCollections(boolean removeCollections) { this.removeCollections = removeCollections; + } + + /** + * Set chisq threshold for partial tracks. + * + * @param badHitChisq Chisq threshold, default 10. + */ + public void setBadHitChisq(double badHitChisq) { + this.badHitChisq = badHitChisq; } @Override @@ -57,9 +88,11 @@ } List<Track> deduplicatedTracks = new ArrayList<Track>(); + Map<Track, Set<TrackerHit>> trackToHitsMap = new HashMap<Track, Set<TrackerHit>>(); - for (List<Track> matchingTracks : hitsToTracksMap.values()) { - Track trk = matchingTracks.get(0);// pick lowest-chisq track (this probably doesn't matter) + for (Map.Entry<Set<TrackerHit>, List<Track>> mapEntry : hitsToTracksMap.entrySet()) { + List<Track> matchingTracks = mapEntry.getValue(); + Track trk = matchingTracks.get(0);// pick lowest-chisq track for (Track matchingTrack : matchingTracks) { if (matchingTrack.getChi2() < trk.getChi2()) { trk = matchingTrack; @@ -83,7 +116,22 @@ ((SeedTrack) trk).setTrackType(trackType); deduplicatedTracks.add(trk); + trackToHitsMap.put(trk, mapEntry.getKey()); } + + List<Track> partialTracks = new ArrayList<Track>(); + for (Track track : deduplicatedTracks) { + Set<TrackerHit> trackHits = trackToHitsMap.get(track); + for (Track otherTrack : deduplicatedTracks) { + Set<TrackerHit> otherTrackHits = trackToHitsMap.get(otherTrack); + if (otherTrackHits.size() > trackHits.size() && otherTrackHits.containsAll(trackHits) && otherTrack.getChi2() < track.getChi2() + badHitChisq) { +// System.out.format("%f %d %f %d\n", track.getChi2(), trackHits.size(), otherTrack.getChi2(), otherTrackHits.size()); + partialTracks.add(track); + break; + } + } + } + deduplicatedTracks.removeAll(partialTracks); if (removeCollections) { for (List<Track> tracklist : trackCollections) { @@ -93,5 +141,6 @@ int flag = 1 << LCIOConstants.TRBIT_HITS; event.put(outputCollectionName, deduplicatedTracks, Track.class, flag); + event.put(partialTrackCollectionName, partialTracks, Track.class, flag); } }