Commit in hps-java/src/main/java/org/lcsim/hps/recon/tracking on MAIN
TestProposalJlabCoordTrackReconSteering.java+208added 1.1
first shot at writing a top level tracking Driver for new jlab coord detector that allows some XML config

hps-java/src/main/java/org/lcsim/hps/recon/tracking
TestProposalJlabCoordTrackReconSteering.java added at 1.1
diff -N TestProposalJlabCoordTrackReconSteering.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TestProposalJlabCoordTrackReconSteering.java	28 Jul 2011 23:34:24 -0000	1.1
@@ -0,0 +1,208 @@
+package org.lcsim.hps.recon.tracking;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackerHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.hps.event.HPSTransformations;
+import org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver;
+import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver;
+import org.lcsim.recon.tracking.seedtracker.SeedStrategy;
+import org.lcsim.recon.tracking.seedtracker.SeedTracker;
+import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils;
+import org.lcsim.util.Driver;
+
+/**
+ * Driver for track reconstruction and analysis of HPS Test Proposal detector
+ * in the JLAB coordinate system.  It starts with a collection of SimTrackerHits
+ * and produces Tracks, as well as intermediate collections of hit objects.
+ * 
+ * This class is basically a stripped down and refactored version of Matt Graham's 
+ * {@link org.lcsim.hps.users.mgraham.jlabrotation.HeavyPhotonLLDriver}.
+ * 
+ * It should work on the detector <b>HPS-Test-JLAB-v2pt1</b> from hps-detectors.
+ *
+ * @author jeremym
+ * @author mgraham - original Driver skeleton
+ */
+public final class TestProposalJlabCoordTrackReconSteering extends Driver 
+{
+    // FIXME: Hard-coded B-field value.  Can get this from Detector object instead???
+    private final double bfield = 0.5;
+    
+    // Default name of SimTrackerHit input collection.
+    private String simTrackerHitCollectionName = "TrackerHits";
+    
+    // Default tracking strategy path. 
+    private String strategyResource = "HPS-Test-1pt3.xml";
+        
+    // Name of output Track collection from Seedtracker.
+    private final String trackCollectionName = "MatchedTracks";
+    
+    // Name of HelicalTrackHit input collection to Seedtracker.
+    private final String stInputCollectionName = "RotatedHelicalTrackHits";
+    
+    // Name of the output collection from HelicalTrackHit Driver.
+    private final String hthOutputCollectionName = "HelicalTrackHits";
+    
+    /**
+     * Empty no-arg ctor for XML config.  
+     * All config is performed in {@link #detectorChanged(Detector)}
+     * via a call to {@link #setup()}.
+     */
+    public TestProposalJlabCoordTrackReconSteering()
+    {}
+        
+    /**
+     * Set the tracking strategy resource.
+     * @param strategyResource The absolute path to the strategy resource.
+     */        
+    public void setStrategyResource(String strategyResource)
+    {
+        this.strategyResource = strategyResource;
+    }
+    
+    /**
+     * Set the SimTrackerHit collection to be used for tracking.
+     * @param simTrackerHitCollectionName The name of the SimTrackerHit collection in the event.
+     */
+    public void setSimTrackerHitCollectionName(String simTrackerHitCollectionName)
+    {
+        this.simTrackerHitCollectionName = simTrackerHitCollectionName;
+    }
+    
+    /**
+     * This is used to setup the Drivers after XML config.
+     */
+    public void detectorChanged(Detector detector)
+    {
+        setup();
+        super.detectorChanged(detector);        
+    }
+    
+    /**
+     * Call super for child processing.
+     */
+    public void startOfData()
+    {
+        super.startOfData();
+    }    
+    
+    /** 
+     * Setup all the Drivers necessary for track reconstruction.
+     */
+    private void setup()
+    {        
+        // 1) Detector setup Driver.
+        add(new SiTrackerSpectrometerSensorSetup("Tracker"));
+
+        // 2) Readout Driver to link sensors and hits.
+        List<String> tkrColl = new ArrayList<String>();
+        tkrColl.add(simTrackerHitCollectionName);
+        add(new SimTrackerHitReadoutDriver(tkrColl));
+        
+        // 3) Digitization wrapper.
+        HPSTrackerHitDriver thd = new HPSTrackerHitDriver();        
+        add(thd);
+
+        // 4) Driver to create HelicalTrackHits expected by Seedtracker.
+        
+        // Setup adjacent layer pairings.
+        List<int[]> pairs = new ArrayList();
+        int[] p1 = {1, 2};
+        int[] p2 = {3, 4};
+        int[] p3 = {5, 6};
+        int[] p4 = {7, 8};
+        int[] p5 = {9, 10};
+        pairs.add(p1);
+        pairs.add(p2);
+        pairs.add(p3);
+        pairs.add(p4);
+        pairs.add(p5);
+
+        // Setup the hit Driver.
+        HPSHelicalTrackHitDriver hthdriver = new HPSHelicalTrackHitDriver();
+        hthdriver.addCollection(thd.getStripHits1DName());
+        hthdriver.OutputCollection(hthOutputCollectionName);
+        hthdriver.HitRelationName("HelicalTrackHitRelations");
+        hthdriver.MCRelationName("HelicalTrackMCRelations");        
+        for (int[] pair : pairs)
+        {
+            hthdriver.setStereoPair("Tracker", pair[0], pair[1]);
+        }       
+        hthdriver.setMaxSeperation(10.01);  
+        hthdriver.setTolerance(0.01); 
+        hthdriver.setTransformToTracking(true);
+        add(hthdriver);
+        
+        // 5) Driver to run Seedtracker.
+        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);
+        
+        // 6) Cleanup the readouts for next event.
+        List<String> readoutCleanup = new ArrayList<String>();
+        readoutCleanup.add(this.simTrackerHitCollectionName);
+        add(new ReadoutCleanupDriver(readoutCleanup));
+    }   
+    
+    /**
+     * This method is used to print debug information about collections after the Tracks are created
+     * by the child Drivers.
+     */
+    public void process(EventHeader event)
+    {
+        // This call will run the track reconstruction.
+        super.process(event);
+        
+        // Check for digi hits.
+        List<TrackerHit> digi = event.get(TrackerHit.class, "TrackerHits");
+        if (digi.size() == 0)
+        {
+            System.out.println("WARNING: The sisim TrackerHit collection is empty!");
+        }
+        else
+        {
+            System.out.println("The sisim TrackerHit collection has " + digi.size() + " hits.");
+        }
+        
+        // Check for HelicalTrackHits.
+        List<TrackerHit> hth = event.get(TrackerHit.class, hthOutputCollectionName);
+        if (hth.size() == 0)
+        {
+            System.out.println("WARNING: The HelicalTrackHit collection " + hthOutputCollectionName + " is empty!");
+        }
+        else
+        {
+            System.out.println("The HelicalTrackHit collection " + hthOutputCollectionName + " has " + hth.size() + " hits.");
+        }       
+        
+        // Check for Tracks.
+        List<Track> tracks = event.get(Track.class, trackCollectionName);        
+        if (tracks.size() == 0)
+        {
+            System.out.println("WARNING: The Track collection " + trackCollectionName + " is empty!");
+        }
+        else
+        {
+            System.out.println("The Track collection " + trackCollectionName + " has " + tracks.size() + " tracks.");
+        }        
+        // Print out track info.
+        for (Track track : tracks)
+        {
+            System.out.println(track.toString());
+        }
+    }   
+}
\ No newline at end of file
CVSspam 0.2.8