Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
FindableTrack.java+63-371.2 -> 1.3
Allow use of SimTrackerHit collection directly;  Added ability to check if an MC particle passes a user specified number of layers

hps-java/src/main/java/org/lcsim/hps/recon/tracking
FindableTrack.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- FindableTrack.java	29 Aug 2012 15:40:46 -0000	1.2
+++ FindableTrack.java	25 Sep 2012 01:57:19 -0000	1.3
@@ -32,63 +32,59 @@
 /**
  *
  * @author Richard Partridge
- * @version 1.0
+ * @version $Id: FindableTrack.java,v 1.3 2012/09/25 01:57:19 omoreno Exp $
  */
 public class FindableTrack {
 
     public enum Ignore {
-
         NoPTCut, NoDCACut, NoZ0Cut, NoSeedCheck, NoConfirmCheck, NoMinHitCut
     };
+    
     private double _bfield;
-    private RelationalTable _hittomc;
+    private RelationalTable<SimTrackerHit, MCParticle> _hittomc;
     private HitIdentifier _ID;
     private int _nlayersTot=10;
-    /** Creates a new instance of FindableTrack */
-    public FindableTrack(EventHeader event) {
-        //  Get the magnetic field
+    
+    public FindableTrack(EventHeader event, List<SimTrackerHit> simTrackerHits){
+        
+        // Get the magnetic field
         Hep3Vector IP = new BasicHep3Vector(0., 0., 1.);
         _bfield = event.getDetector().getFieldMap().getField(IP).z();
-
+        
         //  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);
-
+        _hittomc = new BaseRelationalTable<SimTrackerHit, MCParticle>(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED);
+        
+        List<List<SimTrackerHit>> simTrackerHitCollections = new ArrayList<List<SimTrackerHit>>();
+        
+        // If the collection of SimTrackerHits is not specified get the collection from the event.
+        // Otherwise, add the collection to the list of collections to be processed.
+        if(simTrackerHits == null) simTrackerHitCollections.addAll(event.get(SimTrackerHit.class));
+        else simTrackerHitCollections.add(simTrackerHits);
+        
         //  Loop over the SimTrackerHits and fill in the relational table
-        for (List<SimTrackerHit> simlist : simcols)
+        for (List<SimTrackerHit> simlist : simTrackerHitCollections){
             for (SimTrackerHit simhit : simlist)
                 if (simhit.getMCParticle() != null)
                     _hittomc.add(simhit, simhit.getMCParticle());
+        }
     }
-
-
-      public FindableTrack(EventHeader event, int ntot) {
-        _nlayersTot=ntot;
-        //  Get the magnetic field
-        Hep3Vector IP = new BasicHep3Vector(0., 0., 1.);
-         _bfield = event.getDetector().getFieldMap().getField(IP).y();
-
-        //  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);
-
-        //  Loop over the SimTrackerHits and fill in the relational table
-        for (List<SimTrackerHit> simlist : simcols)
-            for (SimTrackerHit simhit : simlist)
-                if (simhit.getMCParticle() != null)
-                    _hittomc.add(simhit, simhit.getMCParticle());
+    
+    public FindableTrack(EventHeader event, List<SimTrackerHit> simTrackerHits, int nLayersTot){
+        this(event, simTrackerHits);
+        this._nlayersTot = nLayersTot;
+    }
+    
+    public FindableTrack(EventHeader event){
+        this(event, null);
     }
 
+    public FindableTrack(EventHeader event, int nLayersTot){
+        this(event, null, nLayersTot);
+    }
+    
     public boolean isFindable(MCParticle mcp, List<SeedStrategy> slist, Ignore ignore) {
         List<Ignore> ignores = new ArrayList<Ignore>();
         ignores.add(ignore);
@@ -165,7 +161,37 @@
 
         return idset.size();
     }
-
+    
+    public boolean isTrackFindable(MCParticle mcParticle, int nLayers){
+        
+        if(nLayers%2 == 1) throw new RuntimeException(this.getClass().getSimpleName() + ": The required number of layers hit must be even");
+        
+        // A neutral particle can't be found
+        if(mcParticle.getCharge() == 0) return false;
+        
+        // Get the list of SimTrackerHits associated with the MC particle
+        Set<SimTrackerHit> simHits = _hittomc.allTo(mcParticle);
+        
+        // Find the layers hit
+        boolean[] layerHit = new boolean[_nlayersTot];
+        for(SimTrackerHit simHit : simHits){
+            layerHit[simHit.getLayer()-1] = true;
+        }
+        
+        int nLayersHit = 0;
+        // Check how many pairs of layers were hit
+        for(int index = 0; index < _nlayersTot; index += 2){
+            System.out.println(this.getClass().getSimpleName() + ": {" + layerHit[index] + ", " + layerHit[index+1] + "}");
+            if(layerHit[index] && layerHit[index+1]) nLayersHit += 2; 
+        }
+        
+        return nLayersHit >= nLayers;
+    }
+    
+    public Set<SimTrackerHit> getSimTrackerHits(MCParticle mcParticle){
+        return _hittomc.allTo(mcParticle);
+    }
+    
     public boolean InnerTrackerIsFindable(MCParticle mcp, int nlayers, boolean printout) {
         Set<SimTrackerHit> hitlist = _hittomc.allTo(mcp);
         boolean[] layerHit={false,false,false,false,false,false,false,false,false,false,false,false};
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1