hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -N TrackerReconDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TrackerReconDriver.java 19 Jan 2012 01:03:18 -0000 1.1
@@ -0,0 +1,187 @@
+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.seedtracker.SeedStrategy;
+import org.lcsim.recon.tracking.seedtracker.SeedTracker;
+import org.lcsim.recon.tracking.seedtracker.StrategyXMLUtils;
+import org.lcsim.util.Driver;
+
+public final class TrackerReconDriver extends Driver
+{
+ // FIXME: Hard-coded B-field value.
+ // Can we get this from the Detector object's BoxDipole 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 Seedtracker's output collection.
+ private final String trackCollectionName = "MatchedTracks";
+
+ // Name of Seedtracker's HelicalTrackHit input collection.
+ private final String stInputCollectionName = "RotatedHelicalTrackHits";
+
+ // Name of HelicalTrackHitDriver's output hit collection.
+ private final String hthOutputCollectionName = "HelicalTrackHits";
+
+ // Name of strip hits collection.
+ // FIXME: Hard-coded collection name depends on name of strip clusterer in another Driver.
+ private final String stripHitsCollectionName = "StripClusterer_SiTrackerHitStrip1D";
+
+ public TrackerReconDriver()
+ {}
+
+ /**
+ * 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 at start of data.
+ */
+ public void startOfData()
+ {
+ super.startOfData();
+ }
+
+ /**
+ * Setup all the child Drivers necessary for track reconstruction.
+ */
+ private void setup()
+ {
+ //
+ // 1) 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 Driver.
+ HPSHelicalTrackHitDriver hthdriver = new HPSHelicalTrackHitDriver();
+ hthdriver.addCollection(stripHitsCollectionName);
+ hthdriver.OutputCollection(hthOutputCollectionName);
+ hthdriver.HitRelationName("HelicalTrackHitRelations"); // parameter
+ hthdriver.MCRelationName("HelicalTrackMCRelations"); // parameter
+ for (int[] pair : pairs)
+ {
+ hthdriver.setStereoPair("Tracker", pair[0], pair[1]);
+ }
+ hthdriver.setMaxSeperation(10.01);
+ hthdriver.setTolerance(0.01);
+ hthdriver.setTransformToTracking(true);
+ add(hthdriver);
+
+ //
+ // 2) 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);
+
+ //
+ // 3) 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 run the reconstruction and print debug information.
+ */
+ public void process(EventHeader event)
+ {
+ // This runs 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