Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
TrackerDigiDriver.java+113-1431.7 -> 1.8
TrackerReconDriver.java+153-1621.12 -> 1.13
+266-305
2 modified files
make debug setting accessible from lcsim xml

hps-java/src/main/java/org/lcsim/hps/recon/tracking
TrackerDigiDriver.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- TrackerDigiDriver.java	14 Mar 2012 01:25:41 -0000	1.7
+++ TrackerDigiDriver.java	19 Mar 2012 21:59:24 -0000	1.8
@@ -25,29 +25,29 @@
 import org.lcsim.util.lcio.LCIOUtil;
 
 /**
- * This Driver runs the tracker digitization to create raw hits and strip hits from simulated data.
- * The output can be used by a track reconstruction algorithm like Seed Tracker.
+ * This Driver runs the tracker digitization to create raw hits and strip hits
+ * from simulated data. The output can be used by a track reconstruction
+ * algorithm like Seed Tracker.
  * 
  * @author jeremym
- * @version $Id: TrackerDigiDriver.java,v 1.7 2012/03/14 01:25:41 jeremy Exp $
+ * @version $Id: TrackerDigiDriver.java,v 1.8 2012/03/19 21:59:24 jeremy Exp $
  */
-public class TrackerDigiDriver extends Driver 
-{
-    // Debug switch for development.  
-    private static final boolean DEBUG = false; 
-        
+public class TrackerDigiDriver extends Driver {
+    // Debug switch for development.
+    private boolean debug = false;
+
     // Collection name.
     private String readoutCollectionName = "TrackerHits";
-    
+
     // Subdetector name.
     private String subdetectorName = "Tracker";
-    
+
     // Name of RawTrackerHit output collection.
     private String rawTrackerHitOutputCollectionName = "RawTrackerHitMaker_RawTrackerHits";
-    
+
     // Name of StripHit1D output collection.
     private String stripHitOutputCollectionName = "StripClusterer_SiTrackerHitStrip1D";
-    
+
     // Readout parameters.
     private double readoutNoiseIntercept = 270.0;
     private double readoutNoiseSlope = 36.0;
@@ -55,14 +55,14 @@
     private double readoutNeighborThreshold = 4.0;
     private int readoutNBits = 10;
     private int readoutDynamicRange = 40;
-    
+
     // Clustering parameters.
     private double clusterSeedThreshold = 4.0;
     private double clusterNeighborThreshold = 3.0;
     private double clusterThreshold = 4.0;
     private int clusterMaxSize = 10;
     private int clusterCentralStripAveragingThreshold = 4;
-    
+
     // Clustering errors by number of TrackerHits.
     private static final double clusterErrorMultiplier = 1.0;
     private double oneClusterErr = clusterErrorMultiplier / Math.sqrt(12.);
@@ -70,127 +70,109 @@
     private double threeClusterErr = clusterErrorMultiplier / 3.0;
     private double fourClusterErr = clusterErrorMultiplier / 2.0;
     private double fiveClusterErr = clusterErrorMultiplier / 1.0;
-    
-    // Various data lists required by digitization.   
+
+    // Various data lists required by digitization.
     private List<String> readouts = new ArrayList<String>();
     private List<String> processPaths = new ArrayList<String>();
-    private List<IDetectorElement> processDEs = new ArrayList<IDetectorElement>();    
+    private List<IDetectorElement> processDEs = new ArrayList<IDetectorElement>();
     private Set<SiSensor> processSensors = new HashSet<SiSensor>();
     private Set<SiTrackerModule> processModules = new HashSet<SiTrackerModule>();
-    
+
     // Digi class objects.
     private SiDigitizer stripDigitizer;
     private StripHitMaker stripClusterer;
-    
-    public void setReadoutCollectionName(String readoutCollectionName)
-    {
+
+    public void setDebug(boolean debug) {
+        this.debug = true;
+    }
+
+    public void setReadoutCollectionName(String readoutCollectionName) {
         this.readoutCollectionName = readoutCollectionName;
     }
-    
-    public void setSubdetectorName(String subdetectorName)
-    {
+
+    public void setSubdetectorName(String subdetectorName) {
         this.subdetectorName = subdetectorName;
     }
-    
-    public void setRawTrackerHitOutputCollectionName(String rawTrackerHitOutputCollectionName)
-    {
-    	this.rawTrackerHitOutputCollectionName = rawTrackerHitOutputCollectionName;
-    }
-    
-    public void setStripHitOutputCollectionName(String stripHitOutputCollectionName)
-    {
-    	this.stripHitOutputCollectionName = stripHitOutputCollectionName;
-    }
-    
-    public void setReadoutNoiseIntercept(double readoutNoiseIntercept)
-    {
+
+    public void setRawTrackerHitOutputCollectionName(String rawTrackerHitOutputCollectionName) {
+        this.rawTrackerHitOutputCollectionName = rawTrackerHitOutputCollectionName;
+    }
+
+    public void setStripHitOutputCollectionName(String stripHitOutputCollectionName) {
+        this.stripHitOutputCollectionName = stripHitOutputCollectionName;
+    }
+
+    public void setReadoutNoiseIntercept(double readoutNoiseIntercept) {
         this.readoutNoiseIntercept = readoutNoiseIntercept;
     }
-    
-    public void setReadoutNoiseSlope(double readoutNoiseSlope)
-    {
+
+    public void setReadoutNoiseSlope(double readoutNoiseSlope) {
         this.readoutNoiseSlope = readoutNoiseSlope;
     }
-    
-    public void setReadoutNeighborThreshold(double readoutNeighborThreshold)
-    {
+
+    public void setReadoutNeighborThreshold(double readoutNeighborThreshold) {
         this.readoutNeighborThreshold = readoutNeighborThreshold;
     }
-    
-    public void setReadoutNBits(int readoutNBits)
-    {
+
+    public void setReadoutNBits(int readoutNBits) {
         this.readoutNBits = readoutNBits;
     }
-    
-    public void setReadoutDynamicRange(int readoutDynamicRange)
-    {
+
+    public void setReadoutDynamicRange(int readoutDynamicRange) {
         this.readoutDynamicRange = readoutDynamicRange;
     }
-    
-    public void setClusterSeedThreshold(double clusterSeedThreshold)
-    {
+
+    public void setClusterSeedThreshold(double clusterSeedThreshold) {
         this.clusterSeedThreshold = clusterSeedThreshold;
     }
-    
-    public void setClusterNeighborThreshold(double clusterNeighborThreshold)
-    {
+
+    public void setClusterNeighborThreshold(double clusterNeighborThreshold) {
         this.clusterNeighborThreshold = clusterNeighborThreshold;
     }
-    
-    public void setClusterThreshold(double clusterThreshold)
-    {
+
+    public void setClusterThreshold(double clusterThreshold) {
         this.clusterThreshold = clusterThreshold;
     }
-    
-    public void setClusterMaxSize(int clusterMaxSize)
-    {
+
+    public void setClusterMaxSize(int clusterMaxSize) {
         this.clusterMaxSize = clusterMaxSize;
     }
-    
-    public void setClusterCentralStripAveragingThreshold(int clusterCentralStripAveragingThreshold)
-    {
+
+    public void setClusterCentralStripAveragingThreshold(int clusterCentralStripAveragingThreshold) {
         this.clusterCentralStripAveragingThreshold = clusterCentralStripAveragingThreshold;
     }
-    
-    public void setOneClusterErr(double oneClusterErr)
-    {
+
+    public void setOneClusterErr(double oneClusterErr) {
         this.oneClusterErr = oneClusterErr;
     }
-    
-    public void setTwoClusterErr(double twoClusterErr)
-    {
+
+    public void setTwoClusterErr(double twoClusterErr) {
         this.twoClusterErr = twoClusterErr;
     }
-    
-    public void setThreeClusterErr(double threeClusterErr)
-    {
+
+    public void setThreeClusterErr(double threeClusterErr) {
         this.threeClusterErr = threeClusterErr;
     }
-    
-    public void setFourClusterErr(double fourClusterErr)
-    {
+
+    public void setFourClusterErr(double fourClusterErr) {
         this.fourClusterErr = fourClusterErr;
     }
-    
-    public void setFiveClusterErr(double fiveClusterErr)
-    {
+
+    public void setFiveClusterErr(double fiveClusterErr) {
         this.fiveClusterErr = fiveClusterErr;
     }
-    
+
     /**
      * Creates a new instance of TrackerHitDriver.
      */
-    public TrackerDigiDriver() 
-    {}
+    public TrackerDigiDriver() {
+    }
 
-    /** 
+    /**
      * Initializes this Driver's objects with the job parameters.
      */
-	private void initialize() 
-	{
-		if (DEBUG)
-			System.out.println(this.getClass() + " - initialize");
-		        
+    private void initialize() {
+
         // Create the sensor simulation.
         CDFSiSensorSim stripSim = new CDFSiSensorSim();
 
@@ -202,12 +184,12 @@
         stripReadout.setNeighborThreshold(readoutNeighborThreshold);
         stripReadout.setNbits(readoutNBits);
         stripReadout.setDynamicRange(readoutDynamicRange);
-        
+
         // Create the digitizer that produces the raw hits
         stripDigitizer = new RawTrackerHitMaker(stripSim, stripReadout);
 
         // Create Strip clustering algorithm.
-        NearestNeighborRMS stripClusteringAlgo = new NearestNeighborRMS(); 
+        NearestNeighborRMS stripClusteringAlgo = new NearestNeighborRMS();
         stripClusteringAlgo.setSeedThreshold(clusterSeedThreshold);
         stripClusteringAlgo.setNeighborThreshold(clusterNeighborThreshold);
         stripClusteringAlgo.setClusterThreshold(clusterThreshold);
@@ -216,7 +198,7 @@
         stripClusterer = new StripHitMaker(stripSim, stripReadout, stripClusteringAlgo);
         stripClusterer.setMaxClusterSize(clusterMaxSize);
         stripClusterer.setCentralStripAveragingThreshold(clusterCentralStripAveragingThreshold);
-        
+
         // Set the cluster errors.
         stripClusterer.SetOneClusterErr(oneClusterErr);
         stripClusterer.SetTwoClusterErr(twoClusterErr);
@@ -229,22 +211,19 @@
 
         // Set the detector to process.
         processPaths.add(subdetectorName);
-	}
-	
-	/**
-	 * This is executed before detectorChanged and initialization of digitization objects is done here.
-	 */
-    public void startOfData() 
-    {
-    	if (DEBUG)
-    		System.out.println(this.getClass().getSimpleName() + ".startOfData");
-    	
-    	// At start of job, setup digitization objects needed by this Driver.
-    	initialize();
-    	    	    	
+    }
+
+    /**
+     * This is executed before detectorChanged and initialization of
+     * digitization objects is done here.
+     */
+    public void startOfData() {
+
+        // At start of job, setup digitization objects needed by this Driver.
+        initialize();
+
         // If readouts not already set, set them up.
-        if (readouts.size() != 0) 
-        {
+        if (readouts.size() != 0) {
             System.out.println("Adding SimTrackerHitIdentifierReadoutDriver with readouts: " + readouts);
             super.add(new SimTrackerHitReadoutDriver(readouts));
         }
@@ -255,74 +234,65 @@
     /**
      * Do initialization once we get a Detector.
      */
-    public void detectorChanged(Detector detector) 
-    {
-    	if (DEBUG)
-    		System.out.println(this.getClass().getSimpleName() + ".detectorChanged");
-    	
-    	// Call sub-Driver's detectorChanged methods.
+    public void detectorChanged(Detector detector) {
+
+        // Call sub-Driver's detectorChanged methods.
         super.detectorChanged(detector);
-        
-        // Process detectors specified by path, otherwise process entire detector
+
+        // Process detectors specified by path, otherwise process entire
+        // detector
         IDetectorElement deDetector = detector.getDetectorElement();
-        
-        for (String path : processPaths) 
-        {
+
+        for (String path : processPaths) {
             processDEs.add(deDetector.findDetectorElement(path));
         }
 
-        if (processDEs.size() == 0) 
-        {
+        if (processDEs.size() == 0) {
             processDEs.add(deDetector);
         }
 
-        for (IDetectorElement detectorElement : processDEs) 
-        {
+        for (IDetectorElement detectorElement : processDEs) {
             processSensors.addAll(detectorElement.findDescendants(SiSensor.class));
-            if (DEBUG)
-                System.out.println("added " + processSensors.size() + " sensors");
+            //if (debug)
+            //    System.out.println("added " + processSensors.size() + " sensors");
             processModules.addAll(detectorElement.findDescendants(SiTrackerModule.class));
-            if (DEBUG)
-                System.out.println("added " + processModules.size() + " modules");
+            //if (debug)
+            //    System.out.println("added " + processModules.size() + " modules");
         }
     }
 
     /**
      * Perform the digitization.
      */
-    public void process(EventHeader event) 
-    {    	
-    	// Call sub-Driver processing.
+    public void process(EventHeader event) {
+        // Call sub-Driver processing.
         super.process(event);
 
         // Make new lists for output.
-        List<RawTrackerHit> rawHits = new ArrayList<RawTrackerHit>();                       
+        List<RawTrackerHit> rawHits = new ArrayList<RawTrackerHit>();
         List<SiTrackerHit> stripHits1D = new ArrayList<SiTrackerHit>();
 
         // Make raw hits.
-        for (SiSensor sensor : processSensors) 
-        {
+        for (SiSensor sensor : processSensors) {
             rawHits.addAll(stripDigitizer.makeHits(sensor));
         }
-                 
+
         // Make strip hits.
-        for (SiSensor sensor : processSensors) 
-        {
+        for (SiSensor sensor : processSensors) {
             stripHits1D.addAll(stripClusterer.makeHits(sensor));
-        }        
-        
+        }
+
         // Debug prints.
-        if (DEBUG)
-        {
-    		List<SimTrackerHit> simHits = event.get(SimTrackerHit.class, this.readoutCollectionName);
-    		System.out.println("SimTrackerHit collection " + this.readoutCollectionName + " has " + simHits.size() + " hits.");
-    		System.out.println("RawTrackerHit collection " + this.rawTrackerHitOutputCollectionName + " has " + rawHits.size() + " hits.");
+        if (debug) {
+            List<SimTrackerHit> simHits = event.get(SimTrackerHit.class, this.readoutCollectionName);
+            System.out.println("SimTrackerHit collection " + this.readoutCollectionName + " has " + simHits.size() + " hits.");
+            System.out.println("RawTrackerHit collection " + this.rawTrackerHitOutputCollectionName + " has " + rawHits.size() + " hits.");
             System.out.println("TrackerHit collection " + this.stripHitOutputCollectionName + " has " + stripHits1D.size() + " hits.");
         }
-             
+
         // Put output hits into collection.
         int flag = LCIOUtil.bitSet(0, 31, true); // Turn on 64-bit cell ID.
-        event.put(this.rawTrackerHitOutputCollectionName, rawHits, RawTrackerHit.class, flag, toString()); 
+        event.put(this.rawTrackerHitOutputCollectionName, rawHits, RawTrackerHit.class, flag, toString());
         event.put(this.stripHitOutputCollectionName, stripHits1D, SiTrackerHitStrip1D.class, 0, toString());
     }
 }
\ No newline at end of file

hps-java/src/main/java/org/lcsim/hps/recon/tracking
TrackerReconDriver.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- TrackerReconDriver.java	16 Mar 2012 19:11:47 -0000	1.12
+++ TrackerReconDriver.java	19 Mar 2012 21:59:24 -0000	1.13
@@ -19,16 +19,17 @@
 
 /**
  * This class runs the Track Reconstruction for the HPS Test Proposal detector.
- * The tracker digitization must be run in front of it.
- * It is intended to work with the {@link TrackerDigiDriver} digitization Driver.
+ * The tracker digitization must be run in front of it. It is intended to work
+ * with the {@link TrackerDigiDriver} digitization Driver.
  * 
  * @author jeremym
- * @version $Id: TrackerReconDriver.java,v 1.12 2012/03/16 19:11:47 jeremy Exp $
+ * @version $Id: TrackerReconDriver.java,v 1.13 2012/03/19 21:59:24 jeremy Exp $
  */
-public final class TrackerReconDriver extends Driver 
-{
+public final class TrackerReconDriver extends Driver {
+    
     // Debug flag.
-    private final static boolean DEBUG = false;
+    //private final static boolean DEBUG = false;
+    private boolean debug = false;
 
     // Tracks found across all events.
     int ntracks = 0;
@@ -48,7 +49,7 @@
     // SimTrackerHit input collection for readout cleanup.
     private String simTrackerHitCollectionName = "TrackerHits";
 
-    // Tracking strategies resource path. 
+    // Tracking strategies resource path.
     private String strategyResource = "HPS-Test-1pt3.xml";
 
     // Output track collection.
@@ -70,209 +71,199 @@
     private String helicalTrackMCRelationsCollectionName = "HelicalTrackMCRelations";
 
     // Max strip separation when making HelicalTrackHits.
-    private double stripMaxSeparation = 10.01;	
+    private double stripMaxSeparation = 10.01;
 
     // Tolerance factor when making HelicalTrackHits.
     private double stripTolerance = 0.01;
 
-    public TrackerReconDriver()
-    {}
+    public TrackerReconDriver() {
+    }
+    
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+    }
 
-    public void setSubdetectorName(String subdetectorName)
-    {
-	this.subdetectorName = subdetectorName;
+    public void setSubdetectorName(String subdetectorName) {
+        this.subdetectorName = subdetectorName;
     }
 
     /**
      * Set the tracking strategy resource.
-     * @param strategyResource The absolute path to the strategy resource in the hps-java jar.
-     */        
-    public void setStrategyResource(String strategyResource)
-    {
-	this.strategyResource = strategyResource;
+     * 
+     * @param strategyResource
+     *            The absolute path to the strategy resource in the hps-java
+     *            jar.
+     */
+    public void setStrategyResource(String strategyResource) {
+        this.strategyResource = strategyResource;
     }
 
-    public void setHelicalTrackHitRelationsCollectionName(String helicalTrackHitRelationsCollectionName)
-    {
-	this.helicalTrackHitRelationsCollectionName = helicalTrackHitRelationsCollectionName;				
+    public void setHelicalTrackHitRelationsCollectionName(String helicalTrackHitRelationsCollectionName) {
+        this.helicalTrackHitRelationsCollectionName = helicalTrackHitRelationsCollectionName;
     }
 
-    public void setHelicalTrackMCRelationsCollectionName(String helicalTrackMCRelationsCollectionName)
-    {
-	this.helicalTrackMCRelationsCollectionName = helicalTrackMCRelationsCollectionName;
+    public void setHelicalTrackMCRelationsCollectionName(String helicalTrackMCRelationsCollectionName) {
+        this.helicalTrackMCRelationsCollectionName = helicalTrackMCRelationsCollectionName;
     }
 
-    public void setInputHitCollectionName(String inputHitCollectionName)
-    {
-	this.stInputCollectionName = inputHitCollectionName;
+    public void setInputHitCollectionName(String inputHitCollectionName) {
+        this.stInputCollectionName = inputHitCollectionName;
     }
 
-    public void setOutputHitCollectionName(String outputHitCollectionName)
-    {
-	this.hthOutputCollectionName = outputHitCollectionName;
+    public void setOutputHitCollectionName(String outputHitCollectionName) {
+        this.hthOutputCollectionName = outputHitCollectionName;
     }
 
-    public void setStripHitsCollectionName(String stripHitsCollectionName)
-    {
-	this.stripHitsCollectionName = stripHitsCollectionName;
+    public void setStripHitsCollectionName(String stripHitsCollectionName) {
+        this.stripHitsCollectionName = stripHitsCollectionName;
     }
 
-    public void setTrackCollectionName(String trackCollectionName)
-    {
-	this.trackCollectionName = trackCollectionName;
+    public void setTrackCollectionName(String trackCollectionName) {
+        this.trackCollectionName = trackCollectionName;
     }
 
-    public void setStripMaxSeparation(double stripMaxSeparation)
-    {
-	this.stripMaxSeparation = stripMaxSeparation;
+    public void setStripMaxSeparation(double stripMaxSeparation) {
+        this.stripMaxSeparation = stripMaxSeparation;
     }
 
-    public void setStripTolerance(double stripTolerance)
-    {
-	this.stripTolerance = stripTolerance;
+    public void setStripTolerance(double stripTolerance) {
+        this.stripTolerance = stripTolerance;
     }
 
     /**
      * Set the SimTrackerHit collection to be used for tracking.
-     * @param simTrackerHitCollectionName The name of the SimTrackerHit collection in the event.
+     * 
+     * @param simTrackerHitCollectionName
+     *            The name of the SimTrackerHit collection in the event.
      */
-    public void setSimTrackerHitCollectionName(String simTrackerHitCollectionName)
-    {
-	this.simTrackerHitCollectionName = simTrackerHitCollectionName;
+    public void setSimTrackerHitCollectionName(String simTrackerHitCollectionName) {
+        this.simTrackerHitCollectionName = simTrackerHitCollectionName;
     }
 
     /**
      * This is used to setup the Drivers after XML config.
      */
-    public void detectorChanged(Detector detector)
-    {    	
-	// Cache Detector object.
-	this.detector = detector;
-
-	// Get B-field Y with no sign.  Seed Tracker doesn't like signed B-field components.
-	// FIXME Is this always right?
-	this.bfield = Math.abs((detector.getFieldMap().getField(new BasicHep3Vector(0,0,0)).y()));       	
-	if (DEBUG)
-	    System.out.println("Set B-field to " + this.bfield);
+    public void detectorChanged(Detector detector) {
+        // Cache Detector object.
+        this.detector = detector;
+
+        // Get B-field Y with no sign. Seed Tracker doesn't like signed B-field
+        // components.
+        // FIXME Is this always right?
+        this.bfield = Math.abs((detector.getFieldMap().getField(new BasicHep3Vector(0, 0, 0)).y()));
+        if (debug)
+            System.out.println("Set B-field to " + this.bfield);
 
-	initialize();
+        initialize();
 
-	super.detectorChanged(detector);
+        super.detectorChanged(detector);
     }
 
-    /** 
+    /**
      * Setup all the child Drivers necessary for track reconstruction.
      */
-    private void initialize()
-    {                
-	//
-	// 1) Driver to create HelicalTrackHits expected by Seedtracker.
-	//
-	// TODO Make this step its own separate Driver??? (Matt)
-
-	// Setup default stereo pairings, which should work for even number of modules.
-	List<SiTrackerModule> modules = detector.getSubdetector(subdetectorName).getDetectorElement().findDescendants(SiTrackerModule.class);
-	if (modules.size() == 0)
-	    throw new RuntimeException("No SiTrackerModules found in detector.");
-	int nmodules = modules.size();
-	if (nmodules % 2 != 0)
-	    throw new RuntimeException("Don't know how to do stereo pairing for odd number of modules.");        
-	List<int[]> pairs = new ArrayList<int[]>();
-	for (int i=1; i<=(nmodules/2)-1; i+=2)
-	{
-	    int[] pair = {i, i+1};
-	    if (DEBUG)
-		System.out.println("Adding stereo pair: " + pair[0] + ", " + pair[1]);
-	    pairs.add(pair);
-	}
-
-	// Create the Driver.
-	HPSHelicalTrackHitDriver hthdriver = new HPSHelicalTrackHitDriver();
-	hthdriver.addCollection(stripHitsCollectionName);
-	hthdriver.OutputCollection(hthOutputCollectionName);
-	hthdriver.HitRelationName(helicalTrackHitRelationsCollectionName);
-	hthdriver.MCRelationName(helicalTrackMCRelationsCollectionName);
-	for (int[] pair : pairs)
-	{
-	    hthdriver.setStereoPair(subdetectorName, pair[0], pair[1]);
-	}       
-	hthdriver.setMaxSeperation(stripMaxSeparation);
-	hthdriver.setTolerance(stripTolerance); // user parameter?        
-	hthdriver.setTransformToTracking(true);
-	add(hthdriver);
-
-	//
-	// 2) Driver to run Seed Tracker.
-	//
-
-	if (!strategyResource.startsWith("/"))
-	    strategyResource = "/" + strategyResource; 
-	List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromInputStream(
-		this.getClass().getResourceAsStream(strategyResource));
-	SeedTracker stFinal = new SeedTracker(sFinallist);
-	HPSTransformations hpstrans = new HPSTransformations();
-	stFinal.setMaterialManagerTransform(hpstrans.getTransform());
-	stFinal.setInputCollectionName(stInputCollectionName);
-	stFinal.setTrkCollectionName(trackCollectionName);
-	stFinal.setBField(bfield);
-	stFinal.setSectorParams(false);
-	add(stFinal);
-
-	//
-	// 3) Cleanup the readouts for next event.
-	//               
-	List<String> readoutCleanup = new ArrayList<String>();
-	readoutCleanup.add(this.simTrackerHitCollectionName);
-	add(new ReadoutCleanupDriver(readoutCleanup));
-    }   
+    private void initialize() {
+        //
+        // 1) Driver to create HelicalTrackHits expected by Seedtracker.
+        //
+        // TODO Make this step its own separate Driver??? (Matt)
+
+        // Setup default stereo pairings, which should work for even number of
+        // modules.
+        List<SiTrackerModule> modules = detector.getSubdetector(subdetectorName).getDetectorElement().findDescendants(SiTrackerModule.class);
+        if (modules.size() == 0)
+            throw new RuntimeException("No SiTrackerModules found in detector.");
+        int nmodules = modules.size();
+        if (nmodules % 2 != 0)
+            throw new RuntimeException("Don't know how to do stereo pairing for odd number of modules.");
+        List<int[]> pairs = new ArrayList<int[]>();
+        for (int i = 1; i <= (nmodules / 2) - 1; i += 2) {
+            int[] pair = { i, i + 1 };
+            if (debug)
+                System.out.println("Adding stereo pair: " + pair[0] + ", " + pair[1]);
+            pairs.add(pair);
+        }
+
+        // Create the Driver.
+        HPSHelicalTrackHitDriver hthdriver = new HPSHelicalTrackHitDriver();
+        hthdriver.addCollection(stripHitsCollectionName);
+        hthdriver.OutputCollection(hthOutputCollectionName);
+        hthdriver.HitRelationName(helicalTrackHitRelationsCollectionName);
+        hthdriver.MCRelationName(helicalTrackMCRelationsCollectionName);
+        for (int[] pair : pairs) {
+            hthdriver.setStereoPair(subdetectorName, pair[0], pair[1]);
+        }
+        hthdriver.setMaxSeperation(stripMaxSeparation);
+        hthdriver.setTolerance(stripTolerance); // user parameter?
+        hthdriver.setTransformToTracking(true);
+        add(hthdriver);
+
+        //
+        // 2) Driver to run Seed Tracker.
+        //
+
+        if (!strategyResource.startsWith("/"))
+            strategyResource = "/" + strategyResource;
+        List<SeedStrategy> sFinallist = StrategyXMLUtils.getStrategyListFromInputStream(this.getClass().getResourceAsStream(strategyResource));
+        SeedTracker stFinal = new SeedTracker(sFinallist);
+        HPSTransformations hpstrans = new HPSTransformations();
+        stFinal.setMaterialManagerTransform(hpstrans.getTransform());
+        stFinal.setInputCollectionName(stInputCollectionName);
+        stFinal.setTrkCollectionName(trackCollectionName);
+        stFinal.setBField(bfield);
+        stFinal.setSectorParams(false);
+        add(stFinal);
+
+        //
+        // 3) Cleanup the readouts for next event.
+        //
+        List<String> readoutCleanup = new ArrayList<String>();
+        readoutCleanup.add(this.simTrackerHitCollectionName);
+        add(new ReadoutCleanupDriver(readoutCleanup));
+    }
 
     /**
      * Call super for child processing at start of data.
      */
-    public void startOfData()
-    {
-	super.startOfData();
-    }    
+    public void startOfData() {
+        super.startOfData();
+    }
 
-    /**    
-     * This method is used to run the reconstruction and print debug information.
+    /**
+     * This method is used to run the reconstruction and print debug
+     * information.
      */
-    public void process(EventHeader event)
-    {    	
-	// This call runs the track reconstruction using the sub-Drivers.
-	super.process(event);
-
-	// Debug printouts.
-	if (DEBUG)
-	{
-	    // Check for HelicalTrackHits.
-	    List<TrackerHit> hth = event.get(TrackerHit.class, hthOutputCollectionName);
-	    System.out.println("The HelicalTrackHit collection " + hthOutputCollectionName + " has " + hth.size() + " hits.");
-
-	    // Check for Tracks.
-	    List<Track> tracks = event.get(Track.class, trackCollectionName);
-	    System.out.println("The Track collection " + trackCollectionName + " has " + tracks.size() + " tracks.");
-
-	    // Print out track info.
-	    for (Track track : tracks)
-	    {
-		System.out.println(track.toString());
-	    }
-	}
-
-	// Increment number of events.
-	++nevents;
-
-	// Add to tracks found.
-	ntracks += event.get(Track.class, trackCollectionName).size();
-    }   
-
-    public void endOfData()
-    {
-        if (DEBUG)
-        {
+    public void process(EventHeader event) {
+        // This call runs the track reconstruction using the sub-Drivers.
+        super.process(event);
+
+        // Debug printouts.
+        if (debug) {
+            // Check for HelicalTrackHits.
+            List<TrackerHit> hth = event.get(TrackerHit.class, hthOutputCollectionName);
+            System.out.println("The HelicalTrackHit collection " + hthOutputCollectionName + " has " + hth.size() + " hits.");
+
+            // Check for Tracks.
+            List<Track> tracks = event.get(Track.class, trackCollectionName);
+            System.out.println("The Track collection " + trackCollectionName + " has " + tracks.size() + " tracks.");
+
+            // Print out track info.
+            for (Track track : tracks) {
+                System.out.println(track.toString());
+            }
+        }
+
+        // Increment number of events.
+        ++nevents;
+
+        // Add to tracks found.
+        ntracks += event.get(Track.class, trackCollectionName).size();
+    }
+
+    public void endOfData() {
+        if (debug) {
             System.out.println("-------------------------------------------");
-            System.out.println(this.getName() + " found " + ntracks + " tracks in " + nevents + " events which is " + ((double)ntracks/(double)nevents) + " tracks per event.");
+            System.out.println(this.getName() + " found " + ntracks + " tracks in " + nevents + " events which is " + ((double) ntracks / (double) nevents) + " tracks per event.");
         }
     }
 }
\ No newline at end of file
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