lcsim-contrib/src/main/java/org/lcsim/contrib/Partridge/TrackingTest
diff -u -r1.3 -r1.4
--- FindableTrack.java 6 Mar 2009 01:52:59 -0000 1.3
+++ FindableTrack.java 9 Sep 2009 04:27:43 -0000 1.4
@@ -22,6 +22,7 @@
import org.lcsim.event.RelationalTable;
import org.lcsim.event.SimTrackerHit;
import org.lcsim.event.base.BaseRelationalTable;
+import org.lcsim.fit.helicaltrack.HelicalTrackHit;
import org.lcsim.fit.helicaltrack.HelixParamCalculator;
import org.lcsim.fit.helicaltrack.HitIdentifier;
import org.lcsim.recon.tracking.seedtracker.SeedLayer;
@@ -42,27 +43,50 @@
private double _bfield;
private RelationalTable _hittomc;
private HitIdentifier _ID;
+ private boolean _digihits;
/** Creates a new instance of FindableTrack */
public FindableTrack(EventHeader event) {
+ this(event, null);
+ }
+
+ public FindableTrack(EventHeader event, String hitcol) {
// Get the magnetic field
Hep3Vector IP = new BasicHep3Vector(0., 0., 1.);
_bfield = event.getDetector().getFieldMap().getField(IP).z();
+ // Save the flag indicating whether we are using digitized TrackerHits or GEANT SimTrackerHits
+ _digihits = hitcol != null;
+
// Instantiate the hit identifier class
_ID = new HitIdentifier();
// Create a relational table that maps SimTrackerHits to MCParticles
_hittomc = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED);
- // Get the collections of SimTrackerHits
- List<List<SimTrackerHit>> simcols = event.get(SimTrackerHit.class);
+ if (_digihits) {
+
+ // Get the collection of HelicalTrackHits
+ List<HelicalTrackHit> digicol = event.get(HelicalTrackHit.class, hitcol);
- // Loop over the SimTrackerHits and fill in the relational table
- for (List<SimTrackerHit> simlist : simcols) {
- for (SimTrackerHit simhit : simlist) {
- _hittomc.add(simhit, simhit.getMCParticle());
+ // Loop over the HelicalTrackHits and fill in the relational table
+ for (HelicalTrackHit hit : digicol) {
+ for (MCParticle mcp : hit.getMCParticles()) {
+ _hittomc.add(hit, mcp);
+ }
+ }
+
+ } else {
+
+ // Get the collections of SimTrackerHits
+ List<List<SimTrackerHit>> simcols = event.get(SimTrackerHit.class);
+
+ // Loop over the SimTrackerHits and fill in the relational table
+ for (List<SimTrackerHit> simlist : simcols) {
+ for (SimTrackerHit simhit : simlist) {
+ _hittomc.add(simhit, simhit.getMCParticle());
+ }
}
}
}
@@ -119,16 +143,28 @@
public int LayersHit(MCParticle mcp) {
- // Get the list of hits associated with the MCParticle
- Set<SimTrackerHit> hitlist = _hittomc.allTo(mcp);
-
// Create a set of the identifiers for the hit layers
Set<String> idset = new HashSet<String>();
- // Create the set of identifiers
- for (SimTrackerHit simhit : hitlist) {
- String identifier = _ID.Identifier(getDetectorElement(simhit));
- if (!idset.contains(identifier)) idset.add(identifier);
+ if (_digihits) {
+
+ // Get the list of digi hits associated with the MCParticle
+ Set<HelicalTrackHit> hitlist = _hittomc.allTo(mcp);
+
+ // Create the set of identifiers
+ for (HelicalTrackHit hit : hitlist) {
+ idset.add(hit.getLayerIdentifier());
+ }
+
+ } else {
+
+ // Get the list of hits associated with the MCParticle
+ Set<SimTrackerHit> hitlist = _hittomc.allTo(mcp);
+
+ // Create the set of identifiers
+ for (SimTrackerHit simhit : hitlist) {
+ idset.add(_ID.Identifier(getDetectorElement(simhit)));
+ }
}
return idset.size();
@@ -184,26 +220,51 @@
private int HitCount(MCParticle mcp, List<SeedLayer> lyrlist) {
- // Get the list of hits associated with the MCParticle
- Set<SimTrackerHit> hitlist = _hittomc.allTo(mcp);
-
- // Count the number of layers with hits in them
+ // Initialize the count of layers with hits from this mcp
int hitcount = 0;
- for (SeedLayer lyr : lyrlist) {
- // Loop over the hits for this MCParticle
- for (SimTrackerHit simhit : hitlist) {
+ if (_digihits) {
+
+ // Get the list of digi hits associated with the MCParticle
+ Set<HelicalTrackHit> hitlist = _hittomc.allTo(mcp);
+
+ // Loop over the layers to check
+ for (SeedLayer lyr : lyrlist) {
+
+ // Loop over the hits for this MCParticle
+ for (HelicalTrackHit hit : hitlist) {
+
+ // See if this hit is on the layer we are checking
+ if (!lyr.getDetName().equals(hit.Detector())) continue;
+ if (lyr.getLayer() != hit.Layer()) continue;
+ if (!lyr.getBarrelEndcapFlag().equals(hit.BarrelEndcapFlag())) continue;
+ hitcount++;
+ break;
+ }
+ }
+
+ } else {
+
+ // Get the list of hits associated with the MCParticle
+ Set<SimTrackerHit> hitlist = _hittomc.allTo(mcp);
+
+ // Loop over the layers to check
+ for (SeedLayer lyr : lyrlist) {
- // Get the detector element for this hit
- IDetectorElement de = getDetectorElement(simhit);
+ // Loop over the hits for this MCParticle
+ for (SimTrackerHit simhit : hitlist) {
- // See if this hit is on the layer we are checking
- if (!lyr.getDetName().equals(_ID.getName(de))) continue;
- if (lyr.getLayer() != _ID.getLayer(de)) continue;
- if (!lyr.getBarrelEndcapFlag().equals(_ID.getBarrelEndcapFlag(de)))
- continue;
- hitcount++;
- break;
+ // Get the detector element for this hit
+ IDetectorElement de = getDetectorElement(simhit);
+
+ // See if this hit is on the layer we are checking
+ if (!lyr.getDetName().equals(_ID.getName(de))) continue;
+ if (lyr.getLayer() != _ID.getLayer(de)) continue;
+ if (!lyr.getBarrelEndcapFlag().equals(_ID.getBarrelEndcapFlag(de)))
+ continue;
+ hitcount++;
+ break;
+ }
}
}