Commit in hps-java/src/main on MAIN
java/org/lcsim/hps/monitoring/svt/SVTEventInfo.java+2-31.5 -> 1.6
                                 /SVTHitReconstructionPlots.java+79-171.14 -> 1.15
                                 /SVTHitPulsePlots.java+11.15 -> 1.16
                                 /TrackingReconstructionPlots.java+264-2111.7 -> 1.8
java/org/lcsim/hps/recon/vertexing/StraightLineTrack.java+41.2 -> 1.3
resources/org/lcsim/hps/recon/tracking/strategies/HPS-Test-4pt1.xml+1-11.4 -> 1.5
resources/org/lcsim/hps/steering/OfflineTrackingAxial.lcsim+97added 1.1
                                /OnlineTracking.lcsim+25-111.11 -> 1.12
java/org/lcsim/hps/recon/tracking/AxialTrackReconDriver.java+433added 1.1
                                 /TrackerReconDriver.java+1-11.19 -> 1.20
java/org/lcsim/hps/users/mgraham/MyLCIOWriterDriver.java+89added 1.1
+996-244
3 added + 8 modified, total 11 files
Many fairly minor changes.  Mostly to plotting.

hps-java/src/main/java/org/lcsim/hps/monitoring/svt
SVTEventInfo.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- SVTEventInfo.java	8 May 2012 16:01:33 -0000	1.5
+++ SVTEventInfo.java	24 May 2012 14:33:59 -0000	1.6
@@ -14,6 +14,7 @@
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.geometry.Detector;
 import org.lcsim.hps.monitoring.Resettable;
+import org.lcsim.hps.recon.tracking.HPSSVTDAQMaps;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
 
@@ -168,9 +169,7 @@
 
         ChargeCarrier carrier = ChargeCarrier.getCarrier(_sid_helper.getSideValue(id));
         SiSensorElectrodes electrodes = ((SiSensor) hit.getDetectorElement()).getReadoutElectrodes(carrier);
-
-//        if (((SiStrips) electrodes).getStripCenter(55).y() > 0)
-        if (sensor.getName().contains("reflected"))
+        if(!HPSSVTDAQMaps.sensorToTopLayer.containsKey(sensor))
             return false;
         return true;
     }

hps-java/src/main/java/org/lcsim/hps/monitoring/svt
SVTHitReconstructionPlots.java 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- SVTHitReconstructionPlots.java	18 May 2012 07:41:49 -0000	1.14
+++ SVTHitReconstructionPlots.java	24 May 2012 14:33:59 -0000	1.15
@@ -9,13 +9,17 @@
 import java.util.logging.Logger;
 import org.lcsim.detector.identifier.IIdentifier;
 import org.lcsim.detector.identifier.IIdentifierHelper;
+import org.lcsim.detector.tracker.silicon.ChargeCarrier;
 import org.lcsim.detector.tracker.silicon.SiSensor;
+import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
+import org.lcsim.detector.tracker.silicon.SiTrackerIdentifierHelper;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.geometry.Detector;
 import org.lcsim.hps.monitoring.AIDAFrame;
 import org.lcsim.hps.monitoring.Resettable;
 import org.lcsim.hps.recon.tracking.HPSFittedRawTrackerHit;
+import org.lcsim.hps.recon.tracking.HPSSVTDAQMaps;
 import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
@@ -23,7 +27,8 @@
 /**
  *
  * @author mgraham
- * @version $Id: SVTHitReconstructionPlots.java,v 1.14 2012/05/18 07:41:49 meeg Exp $
+ * @version $Id: SVTHitReconstructionPlots.java,v 1.14 2012/05/18 07:41:49 meeg
+ * Exp $
  */
 public class SVTHitReconstructionPlots extends Driver implements Resettable {
 
@@ -39,9 +44,11 @@
     IPlotter plotter2;
     IPlotter plotter3;
     IPlotter plotter4;
+    IPlotter plotter44;
     IPlotter plotter5;
     IPlotter plotter6;
     IPlotter plotter7;
+    IPlotter plotter8;
     private Map<String, Integer> sensorRegionMap;
     private String outputPlots = null;
 
@@ -101,22 +108,43 @@
         style4.dataStyle().errorBarStyle().setVisible(false);
         plotter5.createRegions(5, 4);
 
+
+        plotter44 = fac.createPlotterFactory().create("HPS SVT Cluster Hit Plots");
+        plotter44.setTitle("Clusters");
+        plotterFrame.addPlotter(plotter44);
+        IPlotterStyle style44 = plotter44.style();
+        style44.dataStyle().fillStyle().setColor("yellow");
+        style44.dataStyle().errorBarStyle().setVisible(false);
+        plotter44.createRegions(5, 4);
+
         plotter6 = fac.createPlotterFactory().create("HPS SVT Cluster Size Plots");
         plotter6.setTitle("Cluster Size");
         plotterFrame.addPlotter(plotter6);
-        IPlotterStyle style5 = plotter6.style();
-        style5.dataStyle().fillStyle().setColor("green");
-        style5.dataStyle().errorBarStyle().setVisible(false);
+        IPlotterStyle style6 = plotter6.style();
+        style6.dataStyle().fillStyle().setColor("green");
+        style6.dataStyle().errorBarStyle().setVisible(false);
         plotter6.createRegions(5, 4);
 
+
         plotter7 = fac.createPlotterFactory().create("HPS SVT Cluster Amp Plots");
-        plotter7.setTitle("Cluster Amp");
+        plotter7.setTitle("Cluster Amplitude");
         plotterFrame.addPlotter(plotter7);
-        IPlotterStyle style6 = plotter7.style();
-        style6.dataStyle().fillStyle().setColor("green");
-        style6.dataStyle().errorBarStyle().setVisible(false);
+        IPlotterStyle style7 = plotter7.style();
+        style7.dataStyle().fillStyle().setColor("green");
+        style7.dataStyle().errorBarStyle().setVisible(false);
         plotter7.createRegions(5, 4);
 
+        plotter8 = fac.createPlotterFactory().create("HPS SVT Cluster Position Vs Channel");
+        plotter8.setTitle("Cluster Position (y)");
+        plotterFrame.addPlotter(plotter8);
+        IPlotterStyle style8 = plotter8.style();
+        style8.dataStyle().fillStyle().setColor("green");
+        style8.dataStyle().errorBarStyle().setVisible(false);
+        style8.statisticsBoxStyle().setVisible(false);
+        plotter8.style().setParameter("hist2DStyle", "colorMap");
+        style8.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        style8.zAxisStyle().setParameter("scale", "log");
+        plotter8.createRegions(5, 4);
 
         for (SiSensor sensor : sensors) {
             IHistogram1D timingPlot = aida.histogram1D(sensor.getName() + "_timing", 50, -100, 100.0);
@@ -124,18 +152,24 @@
             IHistogram1D chisqPlot = aida.histogram1D(sensor.getName() + "_chisq", 100, 0, 10.0);
             IHistogram1D nrawPlot = aida.histogram1D(sensor.getName() + "_raw_hits", 10, 0, 9.0);
             IHistogram1D nrecoPlot = aida.histogram1D(sensor.getName() + "_reco_hits", 10, 0, 9.0);
+            IHistogram1D nclustPlot = aida.histogram1D(sensor.getName() + "_cluster_hits", 10, 0, 9.0);
             IHistogram1D clusterSizePlot = aida.histogram1D(sensor.getName() + "_cluster_size", 9, 1, 9.0);
             IHistogram1D clusterAmpPlot = aida.histogram1D(sensor.getName() + "_cluster_amp", 50, 0, 2000.0);
+            IHistogram2D clposVsStrip = aida.histogram2D(sensor.getName() + "_cluster_vs_strip", 128, 0, 639, 100, -50, 50);
             int region = sensorRegionMap.get(sensor.getName());
             plotter.region(region).plot(timingPlot);
             plotter2.region(region).plot(amplitudePlot);
             plotter3.region(region).plot(chisqPlot);
             plotter4.region(region).plot(nrawPlot);
             plotter5.region(region).plot(nrecoPlot);
+            plotter44.region(region).plot(nclustPlot);
             plotter6.region(region).plot(clusterSizePlot);
             plotter7.region(region).plot(clusterAmpPlot);
-        }
+            plotter8.region(region).plot(clposVsStrip);
 
+        }
+        IProfile1D hitsPerLayerTop = aida.profile1D("Number of Fitted Hits per layer in Top Half", 10, 1, 11);
+        IProfile1D hitsPerLayerBot = aida.profile1D("Number of Fitted Hits per layer in Bottom Half", 10, 1, 11);
         plotterFrame.pack();
         plotterFrame.setVisible(true);
     }
@@ -166,6 +200,7 @@
             for (int i = 0; i < ns; i++) {
                 aida.histogram1D(sensors.get(i).getName() + "_raw_hits").fill(0);
                 aida.histogram1D(sensors.get(i).getName() + "_reco_hits").fill(0);
+                aida.histogram1D(sensors.get(i).getName() + "_cluster_hits").fill(0);
             }
 
             return;
@@ -186,29 +221,56 @@
         List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName);
         List<HPSFittedRawTrackerHit> fittedrawHits = event.get(HPSFittedRawTrackerHit.class, fittedTrackerHitCollectionName);
         List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, trackerHitCollectionName);
+        int[] layersTop = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        int[] layersBot = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
         for (HPSFittedRawTrackerHit hrth : fittedrawHits) {
+            SiSensor sensor = (SiSensor) hrth.getRawTrackerHit().getDetectorElement();
+            int layer = hrth.getRawTrackerHit().getLayerNumber();
+            if (!HPSSVTDAQMaps.sensorToTopLayer.containsKey(sensor))
+                layersBot[layer - 1]++;
+            else
+                layersTop[layer - 1]++;
             double fittedAmp = hrth.getAmp();
             double fittedT0 = hrth.getT0();
-            String sensorName = hrth.getRawTrackerHit().getDetectorElement().getName();
+            String sensorName = sensor.getName();
             aida.histogram1D(sensorName + "_timing").fill(fittedT0);
             aida.histogram1D(sensorName + "_amplitude").fill(fittedAmp);
             aida.histogram1D(sensorName + "_chisq").fill(hrth.getShapeFitParameters().getChiSq());
         }
-        for (SiSensor sensor : sensors) {
-            String sensorName = sensor.getName();
-            int nraw = sensor.getReadout().getHits(RawTrackerHit.class).size();
-            int nreco = sensor.getReadout().getHits(HPSFittedRawTrackerHit.class).size();
-            aida.histogram1D(sensorName + "_raw_hits").fill(nraw);
-            aida.histogram1D(sensorName + "_reco_hits").fill(nreco);
+
+        for (int i = 0; i < 10; i++) {
+            aida.profile1D("Number of Fitted Hits per layer in Top Half").fill(i + 1, layersTop[i]);
+            aida.profile1D("Number of Fitted Hits per layer in Bottom Half").fill(i + 1, layersBot[i]);
         }
+        Map<SiSensor, Integer> clustMap = new HashMap<SiSensor, Integer>();
         for (SiTrackerHitStrip1D cluster : stripHits) {
             SiSensor sensor = cluster.getSensor();
+            if (clustMap.containsKey(sensor))
+                clustMap.put(sensor, clustMap.get(sensor) + 1);
+            else
+                clustMap.put(sensor, 1);
             String sensorName = sensor.getName();
             int clusterSize = cluster.getRawHits().size();
             aida.histogram1D(sensorName + "_cluster_size").fill(clusterSize);
-            //double cluAmp = getCluAmp(cluster,fittedrawHits);
             double cluAmp = cluster.getdEdx();
             aida.histogram1D(sensorName + "_cluster_amp").fill(cluAmp);
+            double clpos = cluster.getPositionAsVector().y();
+            RawTrackerHit raw = (RawTrackerHit) cluster.getRawHits().get(0);
+            SiTrackerIdentifierHelper _sid_helper = (SiTrackerIdentifierHelper) raw.getDetectorElement().getIdentifierHelper();
+            IIdentifier id = raw.getIdentifier();
+            int stripNum = _sid_helper.getElectrodeValue(id);
+            aida.histogram2D(sensorName + "_cluster_vs_strip").fill(stripNum, clpos);
+        }
+
+
+        for (SiSensor sensor : sensors) {
+            String sensorName = sensor.getName();
+            int nraw = sensor.getReadout().getHits(RawTrackerHit.class).size();
+            int nreco = sensor.getReadout().getHits(HPSFittedRawTrackerHit.class).size();
+            aida.histogram1D(sensorName + "_raw_hits").fill(nraw);
+            aida.histogram1D(sensorName + "_reco_hits").fill(nreco);
+            if (clustMap.containsKey(sensor))
+                aida.histogram1D(sensorName + "_cluster_hits").fill(clustMap.get(sensor));
         }
     }
 

hps-java/src/main/java/org/lcsim/hps/monitoring/svt
SVTHitPulsePlots.java 1.15 -> 1.16
diff -u -r1.15 -r1.16
--- SVTHitPulsePlots.java	24 May 2012 00:30:57 -0000	1.15
+++ SVTHitPulsePlots.java	24 May 2012 14:33:59 -0000	1.16
@@ -81,6 +81,7 @@
         style3.statisticsBoxStyle().setVisibileStatistics("Entries");
         style2.dataStyle().fillStyle().setColor("black");
         style2.dataStyle().errorBarStyle().setVisible(false);
+        style3.dataStyle().errorBarStyle().setVisible(false);
         style2.dataStyle().markerStyle().setColor("blue");
         plotter2.createRegions(5, 4);
         for (SiSensor sensor : sensors) {

hps-java/src/main/java/org/lcsim/hps/monitoring/svt
TrackingReconstructionPlots.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- TrackingReconstructionPlots.java	14 May 2012 22:51:35 -0000	1.7
+++ TrackingReconstructionPlots.java	24 May 2012 14:33:59 -0000	1.8
@@ -48,6 +48,7 @@
     private String fittedTrackerHitCollectionName = "SVTFittedRawTrackerHits";
     private String trackerHitCollectionName = "StripClusterer_SiTrackerHitStrip1D";
     private String helicalTrackHitCollectionName = "HelicalTrackHits";
+    private String rotatedTrackHitCollectionName = "RotatedHelicalTrackHits";
     private String helicalTrackHitRelationsCollectionName = "HelicalTrackHitRelations";
     private String trackCollectionName = "MatchedTracks";
     private String trackerName = "Tracker";
@@ -68,16 +69,16 @@
     IPlotter plotter3_2;
     IPlotter plotter4;
     IPlotter plotter5;
+    IPlotter plotter5_1;
+    IPlotter plotter55;
     IPlotter plotter6;
     double zEcal = 1500;
     double zAtDownStrPairSpec = 914.0; //mm
     double zAtColl = -1500;
     IHistogram1D trkPx;
     IHistogram1D nTracks;
-    
     HPSShaperFitAlgorithm _shaper = new DumbShaperFit();
-    
-    
+
     protected void detectorChanged(Detector detector) {
         this.detector = detector;
         aida.tree().cd("/");
@@ -96,7 +97,7 @@
         plotterFrame.addPlotter(plotter);
 
         trkPx = aida.histogram1D("Track Momentum (Px)", 25, -0.25, 0.25);
-        IHistogram1D trkPy = aida.histogram1D("Track Momentum (Py)", 25, -0.25, 0.25);
+        IHistogram1D trkPy = aida.histogram1D("Track Momentum (Py)", 25, -0.1, 0.1);
         IHistogram1D trkPz = aida.histogram1D("Track Momentum (Pz)", 25, 0, 3.5);
         IHistogram1D trkChi2 = aida.histogram1D("Track Chi2", 25, 0, 25.0);
 
@@ -105,11 +106,11 @@
         plotter.region(2).plot(trkPz);
         plotter.region(3).plot(trkChi2);
 
-        
+
         IHistogram1D trkd0 = aida.histogram1D("d0 ", 25, -100.0, 100.0);
-        IHistogram1D trkphi = aida.histogram1D("phi ", 25, -2.0*Math.PI, 2.0*Math.PI);
-        IHistogram1D trkomega = aida.histogram1D("omega ", 25, -0.01, 0.01);
-        IHistogram1D trklam = aida.histogram1D("tan(lambda) ", 25, -0.3,0.3);
+        IHistogram1D trkphi = aida.histogram1D("sinphi ", 25, -0.2, 0.2);
+        IHistogram1D trkomega = aida.histogram1D("omega ", 25, -0.0025, 0.0025);
+        IHistogram1D trklam = aida.histogram1D("tan(lambda) ", 25, -0.1, 0.1);
         IHistogram1D trkz0 = aida.histogram1D("z0 ", 25, -100.0, 100.0);
 
         plotter22 = fac.createPlotterFactory().create("HPS Track Params");
@@ -124,8 +125,8 @@
         plotter22.region(2).plot(trkomega);
         plotter22.region(3).plot(trklam);
         plotter22.region(4).plot(trkz0);
-        
-        
+
+
         plotter2 = fac.createPlotterFactory().create("HPS Tracking Plots");
         plotter2.setTitle("Track extrapolation");
         plotterFrame.addPlotter(plotter2);
@@ -133,15 +134,15 @@
         style2.dataStyle().fillStyle().setColor("yellow");
         style2.dataStyle().errorBarStyle().setVisible(false);
         plotter2.createRegions(2, 4);
-        IHistogram1D xAtConverter = aida.histogram1D("X (mm) @ Z=-60cm", 25, -50, 50);
-        IHistogram1D yAtConverter = aida.histogram1D("Y (mm) @ Z=-60cm", 50, -50, 100);
+        IHistogram1D xAtConverter = aida.histogram1D("X (mm) @ Z=-60cm", 25, -100, 100);
+        IHistogram1D yAtConverter = aida.histogram1D("Y (mm) @ Z=-60cm", 50, -50, 50);
         IHistogram1D xAtColl = aida.histogram1D("X (mm) @ Z=-150cm", 50, -200, 200);
         IHistogram1D yAtColl = aida.histogram1D("Y (mm) @ Z=-150cm", 50, -200, 200);
         IHistogram1D xAtEcal = aida.histogram1D("X (mm) @ Z=150cm", 50, -700, 700);
         IHistogram1D yAtEcal = aida.histogram1D("Y (mm) @ Z=150cm", 50, -50, 150);
         IHistogram1D xAtEcal2 = aida.histogram1D("X (mm) @ Z=150cm (Pz>1)", 50, -50, 50);
         IHistogram1D yAtEcal2 = aida.histogram1D("Y (mm) @ Z=150cm (Pz>1)", 50, -50, 150);
-        
+
         plotter2.region(0).plot(xAtConverter);
         plotter2.region(4).plot(yAtConverter);
         plotter2.region(1).plot(xAtColl);
@@ -150,7 +151,7 @@
         plotter2.region(6).plot(yAtEcal);
         plotter2.region(3).plot(xAtEcal2);
         plotter2.region(7).plot(yAtEcal2);
-        
+
         plotter222 = fac.createPlotterFactory().create("HPS Tracking Plots");
         plotter222.setTitle("Other");
         plotterFrame.addPlotter(plotter222);
@@ -158,14 +159,14 @@
         style222.dataStyle().fillStyle().setColor("yellow");
         style222.dataStyle().errorBarStyle().setVisible(false);
         plotter222.createRegions(2, 3);
-        
+
         IHistogram1D nHits = aida.histogram1D("Hits per Track", 2, 4, 6);
         IHistogram1D amp = aida.histogram1D("Amp (HitOnTrack)", 50, 0, 5000);
         IHistogram1D ampcl = aida.histogram1D("Amp (CluOnTrack)", 50, 0, 5000);
         IHistogram1D amp2 = aida.histogram1D("Amp Pz>1000 (HitOnTrack)", 50, 0, 5000);
         IHistogram1D ampcl2 = aida.histogram1D("Amp Pz>1000 (CluOnTrack)", 50, 0, 5000);
         nTracks = aida.histogram1D("Tracks per Event", 3, 0, 3);
-        
+
         plotter222.region(0).plot(nHits);
         plotter222.region(3).plot(nTracks);
         plotter222.region(1).plot(amp);
@@ -182,11 +183,11 @@
         style3.dataStyle().errorBarStyle().setVisible(false);
         plotter3.createRegions(5, 2);
 
-        double minResidY = -5;
-        double maxResidY = 5;
+        double minResidY = -1.5;
+        double maxResidY = 1.5;
 
-        double minResidX = -50;
-        double maxResidX = 50;
+        double minResidX = -5;
+        double maxResidX = 5;
 
         IHistogram1D mod1ResX = aida.histogram1D("Module 1 Residual X(mm)", 25, minResidX, maxResidX);
         IHistogram1D mod1ResY = aida.histogram1D("Module 1 Residual Y(mm)", 25, minResidY, maxResidY);
@@ -215,80 +216,80 @@
         plotter3.region(7).plot(mod4ResY);
         plotter3.region(9).plot(mod5ResY);
 
-        
+
         plotter3_1 = fac.createPlotterFactory().create("HPS Residual Plots (Single hit per layer)");
-        plotter3_1.setTitle("Residuals (1hpl)");
+        plotter3_1.setTitle("Residuals (Top)");
         plotterFrame.addPlotter(plotter3_1);
         IPlotterStyle style3_1 = plotter3_1.style();
         style3_1.dataStyle().fillStyle().setColor("yellow");
         style3_1.dataStyle().errorBarStyle().setVisible(false);
         plotter3_1.createRegions(5, 2);
 
-        IHistogram1D mod1ResX_1hpl = aida.histogram1D("Module 1 Residual X(mm) 1hpl", 25, minResidX, maxResidX);
-        IHistogram1D mod1ResY_1hpl = aida.histogram1D("Module 1 Residual Y(mm) 1hpl", 25, minResidY, maxResidY);
+        IHistogram1D mod1ResX_Top = aida.histogram1D("Module 1 Residual X(mm) Top", 25, minResidX, maxResidX);
+        IHistogram1D mod1ResY_Top = aida.histogram1D("Module 1 Residual Y(mm) Top", 25, minResidY, maxResidY);
+
+        IHistogram1D mod2ResX_Top = aida.histogram1D("Module 2 Residual X(mm) Top", 25, minResidX, maxResidX);
+        IHistogram1D mod2ResY_Top = aida.histogram1D("Module 2 Residual Y(mm) Top", 25, minResidY, maxResidY);
 
-        IHistogram1D mod2ResX_1hpl = aida.histogram1D("Module 2 Residual X(mm) 1hpl", 25, minResidX, maxResidX);
-        IHistogram1D mod2ResY_1hpl = aida.histogram1D("Module 2 Residual Y(mm) 1hpl", 25, minResidY, maxResidY);
+        IHistogram1D mod3ResX_Top = aida.histogram1D("Module 3 Residual X(mm) Top", 25, minResidX, maxResidX);
+        IHistogram1D mod3ResY_Top = aida.histogram1D("Module 3 Residual Y(mm) Top", 25, minResidY, maxResidY);
 
-        IHistogram1D mod3ResX_1hpl = aida.histogram1D("Module 3 Residual X(mm) 1hpl", 25, minResidX, maxResidX);
-        IHistogram1D mod3ResY_1hpl = aida.histogram1D("Module 3 Residual Y(mm) 1hpl", 25, minResidY, maxResidY);
+        IHistogram1D mod4ResX_Top = aida.histogram1D("Module 4 Residual X(mm) Top", 25, minResidX, maxResidX);
+        IHistogram1D mod4ResY_Top = aida.histogram1D("Module 4 Residual Y(mm) Top", 25, minResidY, maxResidY);
+
+        IHistogram1D mod5ResX_Top = aida.histogram1D("Module 5 Residual X(mm) Top", 25, minResidX, maxResidX);
+        IHistogram1D mod5ResY_Top = aida.histogram1D("Module 5 Residual Y(mm) Top", 25, minResidY, maxResidY);
+
+        plotter3_1.region(0).plot(mod1ResX_Top);
+        plotter3_1.region(2).plot(mod2ResX_Top);
+        plotter3_1.region(4).plot(mod3ResX_Top);
+        plotter3_1.region(6).plot(mod4ResX_Top);
+        plotter3_1.region(8).plot(mod5ResX_Top);
+
+        plotter3_1.region(1).plot(mod1ResY_Top);
+        plotter3_1.region(3).plot(mod2ResY_Top);
+        plotter3_1.region(5).plot(mod3ResY_Top);
+        plotter3_1.region(7).plot(mod4ResY_Top);
+        plotter3_1.region(9).plot(mod5ResY_Top);
 
-        IHistogram1D mod4ResX_1hpl = aida.histogram1D("Module 4 Residual X(mm) 1hpl", 25, minResidX, maxResidX);
-        IHistogram1D mod4ResY_1hpl = aida.histogram1D("Module 4 Residual Y(mm) 1hpl", 25, minResidY, maxResidY);
-
-        IHistogram1D mod5ResX_1hpl = aida.histogram1D("Module 5 Residual X(mm) 1hpl", 25, minResidX, maxResidX);
-        IHistogram1D mod5ResY_1hpl = aida.histogram1D("Module 5 Residual Y(mm) 1hpl", 25, minResidY, maxResidY);
-
-        plotter3_1.region(0).plot(mod1ResX_1hpl);
-        plotter3_1.region(2).plot(mod2ResX_1hpl);
-        plotter3_1.region(4).plot(mod3ResX_1hpl);
-        plotter3_1.region(6).plot(mod4ResX_1hpl);
-        plotter3_1.region(8).plot(mod5ResX_1hpl);
-
-        plotter3_1.region(1).plot(mod1ResY_1hpl);
-        plotter3_1.region(3).plot(mod2ResY_1hpl);
-        plotter3_1.region(5).plot(mod3ResY_1hpl);
-        plotter3_1.region(7).plot(mod4ResY_1hpl);
-        plotter3_1.region(9).plot(mod5ResY_1hpl);
 
-        
         plotter3_2 = fac.createPlotterFactory().create("HPS Residual Plots (Single strip cluster per layer)");
-        plotter3_2.setTitle("Residuals (1clpl)");
+        plotter3_2.setTitle("Residuals (Bottom)");
         plotterFrame.addPlotter(plotter3_2);
         IPlotterStyle style3_2 = plotter3_2.style();
         style3_2.dataStyle().fillStyle().setColor("yellow");
         style3_2.dataStyle().errorBarStyle().setVisible(false);
         plotter3_2.createRegions(5, 2);
 
-        IHistogram1D mod1ResX_1clpl = aida.histogram1D("Module 1 Residual X(mm) 1clpl", 25, minResidX, maxResidX);
-        IHistogram1D mod1ResY_1clpl = aida.histogram1D("Module 1 Residual Y(mm) 1clpl", 25, minResidY, maxResidY);
+        IHistogram1D mod1ResX_Bottom = aida.histogram1D("Module 1 Residual X(mm) Bottom", 25, minResidX, maxResidX);
+        IHistogram1D mod1ResY_Bottom = aida.histogram1D("Module 1 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
+
+        IHistogram1D mod2ResX_Bottom = aida.histogram1D("Module 2 Residual X(mm) Bottom", 25, minResidX, maxResidX);
+        IHistogram1D mod2ResY_Bottom = aida.histogram1D("Module 2 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
+
+        IHistogram1D mod3ResX_Bottom = aida.histogram1D("Module 3 Residual X(mm) Bottom", 25, minResidX, maxResidX);
+        IHistogram1D mod3ResY_Bottom = aida.histogram1D("Module 3 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
+
+        IHistogram1D mod4ResX_Bottom = aida.histogram1D("Module 4 Residual X(mm) Bottom", 25, minResidX, maxResidX);
+        IHistogram1D mod4ResY_Bottom = aida.histogram1D("Module 4 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
+
+        IHistogram1D mod5ResX_Bottom = aida.histogram1D("Module 5 Residual X(mm) Bottom", 25, minResidX, maxResidX);
+        IHistogram1D mod5ResY_Bottom = aida.histogram1D("Module 5 Residual Y(mm) Bottom", 25, minResidY, maxResidY);
+
+        plotter3_2.region(0).plot(mod1ResX_Bottom);
+        plotter3_2.region(2).plot(mod2ResX_Bottom);
+        plotter3_2.region(4).plot(mod3ResX_Bottom);
+        plotter3_2.region(6).plot(mod4ResX_Bottom);
+        plotter3_2.region(8).plot(mod5ResX_Bottom);
+
+        plotter3_2.region(1).plot(mod1ResY_Bottom);
+        plotter3_2.region(3).plot(mod2ResY_Bottom);
+        plotter3_2.region(5).plot(mod3ResY_Bottom);
+        plotter3_2.region(7).plot(mod4ResY_Bottom);
+        plotter3_2.region(9).plot(mod5ResY_Bottom);
 
-        IHistogram1D mod2ResX_1clpl = aida.histogram1D("Module 2 Residual X(mm) 1clpl", 25, minResidX, maxResidX);
-        IHistogram1D mod2ResY_1clpl = aida.histogram1D("Module 2 Residual Y(mm) 1clpl", 25, minResidY, maxResidY);
 
-        IHistogram1D mod3ResX_1clpl = aida.histogram1D("Module 3 Residual X(mm) 1clpl", 25, minResidX, maxResidX);
-        IHistogram1D mod3ResY_1clpl = aida.histogram1D("Module 3 Residual Y(mm) 1clpl", 25, minResidY, maxResidY);
 
-        IHistogram1D mod4ResX_1clpl = aida.histogram1D("Module 4 Residual X(mm) 1clpl", 25, minResidX, maxResidX);
-        IHistogram1D mod4ResY_1clpl = aida.histogram1D("Module 4 Residual Y(mm) 1clpl", 25, minResidY, maxResidY);
-
-        IHistogram1D mod5ResX_1clpl = aida.histogram1D("Module 5 Residual X(mm) 1clpl", 25, minResidX, maxResidX);
-        IHistogram1D mod5ResY_1clpl = aida.histogram1D("Module 5 Residual Y(mm) 1clpl", 25, minResidY, maxResidY);
-
-        plotter3_2.region(0).plot(mod1ResX_1clpl);
-        plotter3_2.region(2).plot(mod2ResX_1clpl);
-        plotter3_2.region(4).plot(mod3ResX_1clpl);
-        plotter3_2.region(6).plot(mod4ResX_1clpl);
-        plotter3_2.region(8).plot(mod5ResX_1clpl);
-
-        plotter3_2.region(1).plot(mod1ResY_1clpl);
-        plotter3_2.region(3).plot(mod2ResY_1clpl);
-        plotter3_2.region(5).plot(mod3ResY_1clpl);
-        plotter3_2.region(7).plot(mod4ResY_1clpl);
-        plotter3_2.region(9).plot(mod5ResY_1clpl);
-        
-        
-        
 
         plotter4 = fac.createPlotterFactory().create("HPS Track and ECal Plots");
         plotter4.setTitle("Track and ECal Correlations");
@@ -308,7 +309,7 @@
 
         IHistogram1D distX2 = aida.histogram1D("deltaX (Pz>1)", 50, -400, 400);
         IHistogram1D distY2 = aida.histogram1D("deltaY (Pz>1)", 50, -100, 100);
-        
+
         plotter4.region(0).plot(eVsP);
         plotter4.region(3).plot(eOverP);
         plotter4.region(1).plot(distX);
@@ -319,7 +320,7 @@
 
 
         plotter5 = fac.createPlotterFactory().create("HPS Hit Positions");
-        plotter5.setTitle("Hit Positions");
+        plotter5.setTitle("Hit Positions:  Top");
         plotterFrame.addPlotter(plotter5);
         IPlotterStyle style5 = plotter5.style();
         style5.setParameter("hist2DStyle", "colorMap");
@@ -330,12 +331,43 @@
 
         IHistogram1D charge = aida.histogram1D("Charge", 3, -1, 1);
 
-        IHistogram2D l1Pos = aida.histogram2D("Layer 1 HTH Position", 50, -55, 55, 55, -25, 25);
-        IHistogram2D l7Pos = aida.histogram2D("Layer 7 HTH Position", 50, -55, 55, 55, -25, 25);
+        IHistogram2D l1Pos = aida.histogram2D("Layer 1 HTH Position:  Top", 50, -55, 55, 55, -25, 25);
+        IHistogram2D l7Pos = aida.histogram2D("Layer 7 HTH Position:  Top", 50, -55, 55, 55, -25, 25);
 
         plotter5.region(0).plot(l1Pos);
         plotter5.region(1).plot(l7Pos);
 
+        plotter5_1 = fac.createPlotterFactory().create("HPS Hit Positions");
+        plotter5_1.setTitle("Hit Positions:  Bottom");
+        plotterFrame.addPlotter(plotter5_1);
+        IPlotterStyle style5_1 = plotter5_1.style();
+        style5_1.setParameter("hist2DStyle", "colorMap");
+        style5_1.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        style5_1.dataStyle().fillStyle().setColor("yellow");
+        style5_1.dataStyle().errorBarStyle().setVisible(false);
+        plotter5_1.createRegions(1, 2);
+
+        IHistogram2D l1PosBot = aida.histogram2D("Layer 1 HTH Position:  Bottom", 50, -55, 55, 55, -25, 25);
+        IHistogram2D l7PosBot = aida.histogram2D("Layer 7 HTH Position:  Bottom", 50, -55, 55, 55, -25, 25);
+        plotter5_1.region(0).plot(l1PosBot);
+        plotter5_1.region(1).plot(l7PosBot);
+
+        plotter55 = fac.createPlotterFactory().create("HPS Hit Positions");
+        plotter55.setTitle("Helical Track Hits");
+        plotterFrame.addPlotter(plotter55);
+        IPlotterStyle style55 = plotter55.style();
+        style55.dataStyle().fillStyle().setColor("Green");
+        style55.dataStyle().errorBarStyle().setVisible(false);
+        style55.dataStyle().markerStyle().setSize(20);
+        plotter55.createRegions(1, 2);
+
+        IProfile avgLayersTopPlot = aida.profile1D("Number of Stereo Hits per layer in Top Half", 5, 1, 11);
+        IProfile avgLayersBottomPlot = aida.profile1D("Number of Stereo Hits per layer in Bottom Half", 5, 1, 11);
+
+
+        plotter55.region(0).plot(avgLayersTopPlot);
+        plotter55.region(1).plot(avgLayersBottomPlot);
+
 
         plotter6 = fac.createPlotterFactory().create("HPS ECAL Hit Positions");
         plotter6.setTitle("ECAL Positions");
@@ -356,7 +388,7 @@
         IHistogram2D botECal2 = aida.histogram2D("Bottom ECal Cluster Position (E>100,>0 tracks)", 50, -400, 400, 10, -100, 0);
         IHistogram2D topECal3 = aida.histogram2D("Top ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, 0, 100);
         IHistogram2D botECal3 = aida.histogram2D("Bottom ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, -100, 0);
-         
+
 
         plotter6.region(0).plot(topECal);
         plotter6.region(1).plot(botECal);
@@ -410,28 +442,50 @@
             return;
         }
 
-
+         List<HelicalTrackHit> rotList = event.get(HelicalTrackHit.class, rotatedTrackHitCollectionName);
+        for (HelicalTrackHit hth : rotList) {
+            HelicalTrackCross htc = (HelicalTrackCross) hth;
+//            System.out.println("TrackingReconstructionPlots::original helical track position = "+hth.getPosition()[0]+","+hth.getPosition()[1]+","+hth.getPosition()[2]);
+//            System.out.println("TrackingReconstructionPlots::corrected helical track position = "+htc.getCorrectedPosition().toString());
+        }
         List<HelicalTrackHit> hthList = event.get(HelicalTrackHit.class, helicalTrackHitCollectionName);
+        int[] layersTop = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        int[] layersBot = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
         for (HelicalTrackHit hth : hthList) {
             HelicalTrackCross htc = (HelicalTrackCross) hth;
+//            System.out.println("TrackingReconstructionPlots::original helical track position = "+hth.getPosition()[0]+","+hth.getPosition()[1]+","+hth.getPosition()[2]);
+//            System.out.println("TrackingReconstructionPlots::corrected helical track position = "+htc.getCorrectedPosition().toString());
             //These Helical Track Hits are in the JLAB frame
             htc.resetTrackDirection();
             double x = htc.getPosition()[0];
             double y = htc.getPosition()[1];
             SiSensor sensor = ((SiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement());
             if (HPSSVTDAQMaps.sensorToTopLayer.containsKey(sensor)) {
+                layersTop[htc.Layer() - 1]++;
                 Hep3Vector sensorPos = ((SiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()).getGeometry().getPosition();
                 if (htc.Layer() == 1) {
 //                    System.out.println(sensorPos.toString());
 //                    System.out.println("Hit X = " + x + "; Hit Y = " + y);
-
-                    aida.histogram2D("Layer 1 HTH Position").fill(x - sensorPos.x(), y - sensorPos.y());
+                    aida.histogram2D("Layer 1 HTH Position:  Top").fill(x - sensorPos.x(), y - sensorPos.y());
+                }
+                if (htc.Layer() == 7)
+                    aida.histogram2D("Layer 7 HTH Position:  Top").fill(x - sensorPos.x(), y - sensorPos.y());
+            } else {
+                layersBot[htc.Layer() - 1]++;
+                  Hep3Vector sensorPos = ((SiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()).getGeometry().getPosition();
+                if (htc.Layer() == 1) {
+//                    System.out.println(sensorPos.toString());
+//                    System.out.println("Hit X = " + x + "; Hit Y = " + y);
+                    aida.histogram2D("Layer 1 HTH Position:  Bottom").fill(x - sensorPos.x(), y - sensorPos.y());
                 }
                 if (htc.Layer() == 7)
-                    aida.histogram2D("Layer 7 HTH Position").fill(x - sensorPos.x(), y - sensorPos.y());
+                    aida.histogram2D("Layer 7 HTH Position:  Bottom").fill(x - sensorPos.x(), y - sensorPos.y());
             }
         }
-
+        for (int i = 0; i < 10; i++) {
+            aida.profile1D("Number of Stereo Hits per layer in Top Half").fill(i + 1, layersTop[i]);
+            aida.profile1D("Number of Stereo Hits per layer in Bottom Half").fill(i + 1, layersBot[i]);
+        }
         if (!event.hasCollection(Track.class, trackCollectionName)) {
 //            System.out.println(trackCollectionName + " does not exist; skipping event");
             aida.histogram1D("Number Tracks/Event").fill(0);
@@ -450,13 +504,13 @@
                     aida.histogram2D("Top ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
                 if (cluster.getPosition()[1] < 0)
                     aida.histogram2D("Bottom ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
-             
-                if ( tracks.size() > 0) {
+
+                if (tracks.size() > 0) {
                     if (cluster.getPosition()[1] > 0)
                         aida.histogram2D("Top ECal Cluster Position (>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
                     if (cluster.getPosition()[1] < 0)
                         aida.histogram2D("Bottom ECal Cluster Position (>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
-             
+
                     if (cluster.getEnergy() > 100) {
                         if (cluster.getPosition()[1] > 0) {
                             aida.histogram2D("Top ECal Cluster Position (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
@@ -468,23 +522,23 @@
                         }
                     }
                 }
-                
-                
-                
+
+
+
             }
         }
 
-        
+
         List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, "StripClusterer_SiTrackerHitStrip1D");
-        int stripClustersPerLayerTop[] = getStripClustersPerLayer(stripHits,"up");
+        int stripClustersPerLayerTop[] = getStripClustersPerLayer(stripHits, "up");
         //int stripClustersPerLayerBottom[] = getStripClustersPerLayer(stripHits,"down");
-        
-        boolean hasSingleStripClusterPerLayer = singleStripClusterPerLayer( stripClustersPerLayerTop );
-        
+
+        boolean hasSingleStripClusterPerLayer = singleStripClusterPerLayer(stripClustersPerLayerTop);
+
         for (Track trk : tracks) {
-            
-            boolean isSingleHitPerLayerTrack =  singleTrackHitPerLayer(trk);
-            
+
+            boolean isSingleHitPerLayerTrack = singleTrackHitPerLayer(trk);
+
             aida.histogram1D("Track Momentum (Px)").fill(trk.getPY());
             aida.histogram1D("Track Momentum (Py)").fill(trk.getPZ());
             aida.histogram1D("Track Momentum (Pz)").fill(trk.getPX());
@@ -497,40 +551,41 @@
             HelixConverter converter = new HelixConverter(0);
             StraightLineTrack slt = converter.Convert(ht);
 
-            aida.histogram1D("X (mm) @ Z=-60cm").fill(slt.getYZAtX(zAtConverter)[1]);  //remember the tracker-->jlab 
-            aida.histogram1D("Y (mm) @ Z=-60cm").fill(slt.getYZAtX(zAtConverter)[0]);  //coordinate swap...
+            aida.histogram1D("X (mm) @ Z=-60cm").fill(slt.getYZAtX(zAtConverter)[0]);  //this is y in the tracker frame
+            aida.histogram1D("Y (mm) @ Z=-60cm").fill(slt.getYZAtX(zAtConverter)[1]);  //this is z in the tracker frame
             //double sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0);
-            aida.histogram1D("X (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[1]);
-            aida.histogram1D("Y (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[0]);
-            
-            
+            aida.histogram1D("X (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[0]);
+            aida.histogram1D("Y (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[1]);
+
+
             //Straight line after field-region???
             //HelixConverter converterEcal = new HelixConverter(zAtDownStrPairSpec);
             //StraightLineTrack sltEcal = converterEcal.Convert(ht);
             double sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0);
             Hep3Vector posonhelix = HelixUtils.PointOnHelix(ht, sECAL);//position in tracker coordinates!
-            
+
             aida.histogram1D("X (mm) @ Z=150cm").fill(posonhelix.y());
             aida.histogram1D("Y (mm) @ Z=150cm").fill(posonhelix.z());
-            if(trk.getPX()>1.0) {
-                aida.histogram1D("X (mm) @ Z=150cm (Pz>1)").fill(slt.getYZAtX(zAtColl)[1]);
-                aida.histogram1D("Y (mm) @ Z=150cm (Pz>1)").fill(slt.getYZAtX(zAtColl)[0]);
+            if (trk.getPX() > 1.0) {
+                aida.histogram1D("X (mm) @ Z=150cm (Pz>1)").fill(slt.getYZAtX(zAtColl)[0]);
+                aida.histogram1D("Y (mm) @ Z=150cm (Pz>1)").fill(slt.getYZAtX(zAtColl)[1]);
             }
             aida.histogram1D("d0 ").fill(trk.getTrackParameter(ParameterName.d0.ordinal()));
-            aida.histogram1D("phi ").fill(trk.getTrackParameter(ParameterName.phi0.ordinal()));
+            aida.histogram1D("sinphi ").fill(Math.sin(trk.getTrackParameter(ParameterName.phi0.ordinal())));
             aida.histogram1D("omega ").fill(trk.getTrackParameter(ParameterName.omega.ordinal()));
             aida.histogram1D("tan(lambda) ").fill(trk.getTrackParameter(ParameterName.tanLambda.ordinal()));
             aida.histogram1D("z0 ").fill(trk.getTrackParameter(ParameterName.z0.ordinal()));
 
-            
-            
-            
+
+
+
             List<TrackerHit> hitsOnTrack = trk.getTrackerHits();
             for (TrackerHit hit : hitsOnTrack) {
                 HelicalTrackHit htc = (HelicalTrackHit) hit;
+                HelicalTrackCross htcross=(HelicalTrackCross) htc;
                 double sHit = ht.PathMap().get(htc);
                 posonhelix = HelixUtils.PointOnHelix(ht, sHit);
-                
+
                 double yTr = posonhelix.y();
                 double zTr = posonhelix.z();
                 int layer = htc.Layer();
@@ -546,161 +601,159 @@
                 if (layer == 9)
                     modNum = "Module 5 ";
                 SymmetricMatrix cov = htc.getCorrectedCovMatrix();
-//                System.out.println("errX = " + Math.sqrt(cov.e(1, 1)) + "; errY = " + Math.sqrt(cov.e(2, 2)));
-//                System.out.println("Measured X " + hit.getPosition()[1] + "; Track X = " + yTr);
-//                System.out.println("Measured Y " + hit.getPosition()[2] + "; Track Y = " + zTr);
-//                System.out.println(htc.getCorrectedCovMatrix().toString());
-               
-                
-                
-                aida.histogram1D(modNum + "Residual X(mm)").fill(hit.getPosition()[1] - yTr);//these hits should be rotated track hits already
-                aida.histogram1D(modNum + "Residual Y(mm)").fill(hit.getPosition()[2] - zTr);//these hits should be rotated track hits already
-                
-                if (isSingleHitPerLayerTrack) {
-                    aida.histogram1D(modNum + "Residual X(mm) 1hpl").fill(hit.getPosition()[1] - yTr);//these hits should be rotated track hits already
-                    aida.histogram1D(modNum + "Residual Y(mm) 1hpl").fill(hit.getPosition()[2] - zTr);//these hits should be rotated track hits already
-                  
+
+                aida.histogram1D(modNum + "Residual X(mm)").fill( htcross.getCorrectedPosition().y()- yTr);//these hits should be rotated track hits already
+                aida.histogram1D(modNum + "Residual Y(mm)").fill( htcross.getCorrectedPosition().z() - zTr);//these hits should be rotated track hits already
+                if (hit.getPosition()[2]>0) {
+                    aida.histogram1D(modNum + "Residual X(mm) Top").fill(htcross.getCorrectedPosition().y() - yTr);//these hits should be rotated track hits already
+                    aida.histogram1D(modNum + "Residual Y(mm) Top").fill(htcross.getCorrectedPosition().z() - zTr);//these hits should be rotated track hits already
+
                 }
-                if ( hasSingleStripClusterPerLayer ) {
-                    aida.histogram1D(modNum + "Residual X(mm) 1clpl").fill(hit.getPosition()[1] - yTr);//these hits should be rotated track hits already
-                    aida.histogram1D(modNum + "Residual Y(mm) 1clpl").fill(hit.getPosition()[2] - zTr);//these hits should be rotated track hits already
-                  
+                if (hit.getPosition()[2]<0) {
+                    aida.histogram1D(modNum + "Residual X(mm) Bottom").fill(htcross.getCorrectedPosition().y() - yTr);//these hits should be rotated track hits already
+                    aida.histogram1D(modNum + "Residual Y(mm) Bottom").fill(htcross.getCorrectedPosition().z() - zTr);//these hits should be rotated track hits already
+
                 }
-                
+
                 List<RawTrackerHit> rawHits = hit.getRawHits();
-                for(RawTrackerHit rawHit : rawHits){
-                        
+                for (RawTrackerHit rawHit : rawHits) {
+
                     ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) rawHit.getDetectorElement(), rawHit.getIdentifierFieldValue("strip"));
                     HPSShapeFitParameters fit = _shaper.fitShape(rawHit, constants);
                     double amp = fit.getAmp();
                     aida.histogram1D("Amp (HitOnTrack)").fill(amp);
-                    if(trk.getPX()>1) aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
+                    if (trk.getPX() > 1)
+                        aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
                 }
 
                 //Fill the cluster energy directly
                 //This should return energyin GeV but without gain I should get 
                 // sum(ADC)*[energy of hole pair]
-                aida.histogram1D("Amp (CluOnTrack)").fill(hit.getdEdx()/DopedSilicon.ENERGY_EHPAIR);
-                if(trk.getPX()>1) aida.histogram1D("Amp Pz>1000 (CluOnTrack)").fill(hit.getdEdx()/DopedSilicon.ENERGY_EHPAIR);
-                
-                
-                
-                
-                
+                aida.histogram1D("Amp (CluOnTrack)").fill(hit.getdEdx() / DopedSilicon.ENERGY_EHPAIR);
+                if (trk.getPX() > 1)
+                    aida.histogram1D("Amp Pz>1000 (CluOnTrack)").fill(hit.getdEdx() / DopedSilicon.ENERGY_EHPAIR);
+
+
+
+
+
             }
             List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, ecalCollectionName);
 //            System.out.println("Number of ECAL clusters=" + clusters.size());
 //            sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0);
             posonhelix = HelixUtils.PointOnHelix(ht, sECAL);//position in tracker coordinates!
             HPSEcalCluster clust = findClosestCluster(posonhelix, clusters);
+ /*
             if (clust != null) {
                 aida.histogram2D("Energy Vs Momentum").fill(clust.getEnergy(), trk.getPX() * 1000.0);
                 aida.histogram1D("Energy Over Momentum").fill(clust.getEnergy() / (trk.getPX() * 1000.0));
                 aida.histogram1D("deltaX").fill(clust.getPosition()[0] - posonhelix.y());
                 aida.histogram1D("deltaY").fill(clust.getPosition()[1] - posonhelix.z());
-                if(trk.getPX()>1.0) {
+                if (trk.getPX() > 1.0) {
                     aida.histogram1D("deltaX (Pz>1)").fill(clust.getPosition()[0] - posonhelix.y());
                     aida.histogram1D("deltaY (Pz>1)").fill(clust.getPosition()[1] - posonhelix.z());
-                    
                 }
-                
-            }
+            }             
+            */
         }
     }
 
-    public int[] getTrackHitsPerLayer( Track trk ) {
-        int n[] = {0,0,0,0,0};
+    public int[] getTrackHitsPerLayer(Track trk) {
+        int n[] = {0, 0, 0, 0, 0};
         List<TrackerHit> hitsOnTrack = trk.getTrackerHits();
         int layer;
         for (TrackerHit hit : hitsOnTrack) {
-            HelicalTrackHit htc = (HelicalTrackHit)hit;
-            layer = htc.Layer();
-            layer = (layer-1)/2;
-            n[layer] = n[layer] + 1;
+            HelicalTrackHit htc = (HelicalTrackHit) hit;
+//            if (htc.getPosition()[2] < 0) {
+                layer = htc.Layer();
+                layer = (layer - 1) / 2;
+                n[layer] = n[layer] + 1;
+//            }
         }
-        
+
         return n;
     }
-    
-    public boolean singleTrackHitPerLayer( Track track) {
+
+    public boolean singleTrackHitPerLayer(Track track) {
         int hitsPerLayer[] = getTrackHitsPerLayer(track);
-        for (int i=0;i<5;++i) {
-            if (hitsPerLayer[i]!=1) {
+        for (int i = 0; i < 5; ++i) {
+            if (hitsPerLayer[i] != 1) {
                 return false;
             }
         }
         return true;
     }
-    
-     
-     public boolean singleStripClusterPerLayer( int hitsPerLayer[]) {
+
+    public boolean singleStripClusterPerLayer(int hitsPerLayer[]) {
         //This includes both axial and stereo separately 
         // so for a hit in each double layer we need 10 hits
-        for (int i=0;i<10;++i) {
-            if (hitsPerLayer[i]!=1) {
+        for (int i = 0; i < 10; ++i) {
+            if (hitsPerLayer[i] != 1) {
                 return false;
             }
         }
         return true;
     }
-    
+
     public int[] getStripClustersPerLayer(List<SiTrackerHitStrip1D> trackerHits, String side) {
         String si_side;
         String name;
         int l;
         int i;
-        int n[] = {0,0,0,0,0,0,0,0,0,0};
+        int n[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
         boolean ddd = false;
-        
+
         if (ddd) {
-            System.out.println("Get # hits per layer on side \"" + side +"\"");
-        } 
-        
-        for ( SiTrackerHitStrip1D stripCluster : trackerHits ) {
+            System.out.println("Get # hits per layer on side \"" + side + "\"");
+        }
+
+        for (SiTrackerHitStrip1D stripCluster : trackerHits) {
 
             if (ddd) {
                 System.out.println("Processing stripCluster " + stripCluster.toString());
-            } 
+            }
+
 
-            
-            if (side!="") {
+            if (side != "") {
                 String s;
-                if (stripCluster.getPosition()[1]>=0.0) s = "up";
-                else s = "down";
-                if (s != side) continue;
+                if (stripCluster.getPosition()[1] >= 0.0)
+                    s = "up";
+                else
+                    s = "down";
+                if (s != side)
+                    continue;
             }
 
             name = stripCluster.getSensor().getName();
-            if ( name.length() < 14) {
-            System.err.println("This name is too short!!");
-            throw new RuntimeException("SiSensor name " + name + " is invalid?");
+            if (name.length() < 14) {
+                System.err.println("This name is too short!!");
+                throw new RuntimeException("SiSensor name " + name + " is invalid?");
             }
-            
+
             if (ddd) {
-                System.out.println("sensor name  " + name );
+                System.out.println("sensor name  " + name);
             }
 
             //String str_l = name.substring(13);
-            String str_l = name.substring(name.indexOf("layer")+5, name.indexOf("_module"));
+            String str_l = name.substring(name.indexOf("layer") + 5, name.indexOf("_module"));
             l = Integer.parseInt(str_l);
-            
+
             if (ddd) {
                 System.out.println("sensor name  " + name + " --> layer " + l);
             }
 
-            if ( l < 1 || l > 10 ) {
+            if (l < 1 || l > 10) {
                 System.out.println("This layer doesn't exist?");
                 throw new RuntimeException("SiSensor name " + name + " is invalid?");
             }
 
-            n[l-1] = n[l-1] + 1;
-            
+            n[l - 1] = n[l - 1] + 1;
+
         }
-                          
+
         return n;
-    }   
-    
-    
+    }
+
     public void endOfData() {
         if (outputPlots != null)
             try {
@@ -751,36 +804,36 @@
         aida.histogram1D("Module 4 Residual Y(mm)").reset();
         aida.histogram1D("Module 5 Residual X(mm)").reset();
         aida.histogram1D("Module 5 Residual Y(mm)").reset();
-        aida.histogram1D("Module 1 Residual X(mm) 1hpl").reset();
-        aida.histogram1D("Module 1 Residual Y(mm) 1hpl").reset();
-        aida.histogram1D("Module 2 Residual X(mm) 1hpl").reset();
-        aida.histogram1D("Module 2 Residual Y(mm) 1hpl").reset();
-        aida.histogram1D("Module 3 Residual X(mm) 1hpl").reset();
-        aida.histogram1D("Module 3 Residual Y(mm) 1hpl").reset();
-        aida.histogram1D("Module 4 Residual X(mm) 1hpl").reset();
-        aida.histogram1D("Module 4 Residual Y(mm) 1hpl").reset();
-        aida.histogram1D("Module 5 Residual X(mm) 1hpl").reset();
-        aida.histogram1D("Module 5 Residual Y(mm) 1hpl").reset();
-        aida.histogram1D("Module 1 Residual X(mm) 1clpl").reset();
-        aida.histogram1D("Module 1 Residual Y(mm) 1clpl").reset();
-        aida.histogram1D("Module 2 Residual X(mm) 1clpl").reset();
-        aida.histogram1D("Module 2 Residual Y(mm) 1clpl").reset();
-        aida.histogram1D("Module 3 Residual X(mm) 1clpl").reset();
-        aida.histogram1D("Module 3 Residual Y(mm) 1clpl").reset();
-        aida.histogram1D("Module 4 Residual X(mm) 1clpl").reset();
-        aida.histogram1D("Module 4 Residual Y(mm) 1clpl").reset();
-        aida.histogram1D("Module 5 Residual X(mm) 1clpl").reset();
-        aida.histogram1D("Module 5 Residual Y(mm) 1clpl").reset();
+        aida.histogram1D("Module 1 Residual X(mm) Top").reset();
+        aida.histogram1D("Module 1 Residual Y(mm) Top").reset();
+        aida.histogram1D("Module 2 Residual X(mm) Top").reset();
+        aida.histogram1D("Module 2 Residual Y(mm) Top").reset();
+        aida.histogram1D("Module 3 Residual X(mm) Top").reset();
+        aida.histogram1D("Module 3 Residual Y(mm) Top").reset();
+        aida.histogram1D("Module 4 Residual X(mm) Top").reset();
+        aida.histogram1D("Module 4 Residual Y(mm) Top").reset();
+        aida.histogram1D("Module 5 Residual X(mm) Top").reset();
+        aida.histogram1D("Module 5 Residual Y(mm) Top").reset();
+        aida.histogram1D("Module 1 Residual X(mm) Bottom").reset();
+        aida.histogram1D("Module 1 Residual Y(mm) Bottom").reset();
+        aida.histogram1D("Module 2 Residual X(mm) Bottom").reset();
+        aida.histogram1D("Module 2 Residual Y(mm) Bottom").reset();
+        aida.histogram1D("Module 3 Residual X(mm) Bottom").reset();
+        aida.histogram1D("Module 3 Residual Y(mm) Bottom").reset();
+        aida.histogram1D("Module 4 Residual X(mm) Bottom").reset();
+        aida.histogram1D("Module 4 Residual Y(mm) Bottom").reset();
+        aida.histogram1D("Module 5 Residual X(mm) Bottom").reset();
+        aida.histogram1D("Module 5 Residual Y(mm) Bottom").reset();
 
         aida.histogram2D("Energy Vs Momentum").reset();
         aida.histogram1D("Energy Over Momentum").reset();
         aida.histogram1D("deltaX").reset();
         aida.histogram1D("deltaY").reset();
-        
+
         aida.histogram1D("Amp (HitOnTrack)").reset();
-        
+
         aida.histogram1D("d0 ").reset();
-        aida.histogram1D("phi ").reset();
+        aida.histogram1D("sinphi ").reset();
         aida.histogram1D("omega ").reset();
         aida.histogram1D("tan(lambda) ").reset();
         aida.histogram1D("z0 ").reset();

hps-java/src/main/java/org/lcsim/hps/recon/vertexing
StraightLineTrack.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- StraightLineTrack.java	8 May 2012 16:01:33 -0000	1.2
+++ StraightLineTrack.java	24 May 2012 14:33:59 -0000	1.3
@@ -178,4 +178,8 @@
         yzAtX[1] = _z0 + (xVal-_x0) * _dzdx;
         return yzAtX;
     }
+    
+        public double calculateXAtZEquals0() {       
+        return _x0-_z0/_dzdx;
+    }
 }

hps-java/src/main/resources/org/lcsim/hps/recon/tracking/strategies
HPS-Test-4pt1.xml 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- HPS-Test-4pt1.xml	8 May 2012 16:01:33 -0000	1.4
+++ HPS-Test-4pt1.xml	24 May 2012 14:33:59 -0000	1.5
@@ -5,7 +5,7 @@
         
         <!--Cutoffs-->
         
-        <MinPT>0.050</MinPT>
+        <MinPT>0.250</MinPT>
         <MinHits>4</MinHits>
         <MinConfirm>1</MinConfirm>
         

hps-java/src/main/resources/org/lcsim/hps/steering
OfflineTrackingAxial.lcsim added at 1.1
diff -N OfflineTrackingAxial.lcsim
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ OfflineTrackingAxial.lcsim	24 May 2012 14:33:59 -0000	1.1
@@ -0,0 +1,97 @@
+<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" 
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
+    <execute>
+        <driver name="EventMarkerDriver"/>
+        <driver name="SVTSetupDriver"/>
+        <driver name="HPSSVTDAQMaps"/>
+         <driver name="EcalRawConverter"/>
+        <driver name="EcalClusterer"/>
+        <driver name="RawTrackerHitMaker"/>
+<!--        <driver name="SVTEventPlots"/>    -->
+<!--       <driver name="SVTPulsePlots"/>  -->
+        <driver name="RawTrackerHitFitterDriver"/>    
+       <driver name="TrackerHitDriver"/>           
+<!--       <driver name="SVTHitRecoPlots"/>   -->
+        <driver name="TrackerReconDriver"/>
+        <driver name="TrackingReconstructionPlots"/>        
+         <driver name="LCIOWriter"/>
+        <driver name="CleanupDriver"/>
+    </execute>    
+    <drivers>
+          <driver name="EcalRawConverter" 
+                type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver">
+			<ecalCollectionName>EcalCalHits</ecalCollectionName>
+	</driver>
+        <driver name="EcalClusterer"
+                type="org.lcsim.hps.recon.ecal.HPSEcalClusterer">
+			<ecalName>Ecal</ecalName>
+			<ecalCollectionName>EcalCalHits</ecalCollectionName>
+	</driver>
+
+          <driver name="RawTrackerHitFitterDriver"
+                type="org.lcsim.hps.recon.tracking.HPSRawTrackerHitFitterDriver">
+           <rawHitCollectionName>SVTRawTrackerHits</rawHitCollectionName>  
+          <fittedHitCollectionName>SVTFittedRawTrackerHits</fittedHitCollectionName> 
+           <fitAlgorithm>Analytic</fitAlgorithm>  
+        </driver>
+
+        <driver name="TrackerHitDriver"
+                type="org.lcsim.hps.users.mgraham.DataTrackerHitDriver"/>
+
+         <driver name="SVTEventPlots"
+                type="org.lcsim.hps.monitoring.svt.SVTEventInfo">
+                 <outputPlots>svtEventInfoPlots.aida</outputPlots>
+        </driver>
+
+        <driver name="SVTHitRecoPlots"
+                type="org.lcsim.hps.monitoring.svt.SVTHitReconstructionPlots">
+             <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>   
+             <fittedTrackerHitCollectionName>SVTFittedRawTrackerHits</fittedTrackerHitCollectionName>   
+             <outputPlots>svtHitRecoPlots.aida</outputPlots>
+        </driver>
+
+        <driver name="SVTPulsePlots"
+                type="org.lcsim.hps.monitoring.svt.SVTHitPulsePlots">
+        <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>  
+             <outputPlots>svtPulsePlots.aida</outputPlots> 
+        </driver>    
+
+
+        <driver name="SVTSetupDriver"
+                type="org.lcsim.hps.recon.tracking.HPSSVTSensorSetup">
+        </driver>        
+        <driver name="EventMarkerDriver"
+                type="org.lcsim.job.EventMarkerDriver">
+            <eventInterval>1</eventInterval>
+        </driver>
+        <driver name="HPSSVTDAQMaps" type="org.lcsim.hps.recon.tracking.HPSSVTDAQMaps"/>   
+
+        <driver name="TrackerReconDriver"
+                type="org.lcsim.hps.recon.tracking.AxialTrackReconDriver">
+            <debug>true</debug>
+            <strategyResource>/org/lcsim/hps/recon/tracking/strategies/HPS-Test-4pt1.xml</strategyResource>
+            <stripMaxSeparation>20.0</stripMaxSeparation>
+            <stripTolerance>1.0</stripTolerance>
+        </driver>        
+
+       	<driver name="RawTrackerHitMaker" type="org.lcsim.hps.recon.tracking.SVTDataToRawTrackerHitDriver">
+            <rawTrackerHitOutputCollectionName>SVTRawTrackerHits</rawTrackerHitOutputCollectionName>
+        </driver>
+        
+     	<driver name="TrackingReconstructionPlots" type="org.lcsim.hps.monitoring.svt.TrackingReconstructionPlots">
+                <outputPlots>trackingPlots.aida</outputPlots>
+        </driver>
+
+
+          <driver name="LCIOWriter"
+                type="org.lcsim.util.loop.LCIODriver">
+            <outputFilePath>/Users/mgraham/HPS/HPSData/hps_000820_trackRecon.slcio</outputFilePath>
+        </driver>
+
+       <driver name="CleanupDriver" 
+                type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver">
+                <collectionNames>TrackerHits SVTRawTrackerHits  SVTFittedRawTrackerHits</collectionNames>
+        </driver>
+
+    </drivers>   
+</lcsim>
\ No newline at end of file

hps-java/src/main/resources/org/lcsim/hps/steering
OnlineTracking.lcsim 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- OnlineTracking.lcsim	11 May 2012 00:34:28 -0000	1.11
+++ OnlineTracking.lcsim	24 May 2012 14:33:59 -0000	1.12
@@ -12,16 +12,16 @@
          <driver name="EcalRawConverter"/>
         <driver name="EcalClusterer"/>
         <driver name="RawTrackerHitMaker"/>
-        <driver name="SVTEventPlots"/>    
+         <driver name="SVTOccupancyPlots"/>
+        <driver name="SVTEventPlots"/>   
        <driver name="SVTPulsePlots"/> 
         <driver name="RawTrackerHitFitterDriver"/>    
        <driver name="TrackerHitDriver"/>           
-       <driver name="SVTHitRecoPlots"/>   
+       <driver name="SVTHitRecoPlots"/>  
        <driver name="TrackerReconDriver"/>
-
        <driver name="TrackingReconstructionPlots"/>        
-       <driver name="SVTHitCorrPlots"/>   
-       <driver name="LCIOWriter"/>
+<!--       <driver name="SVTHitCorrPlots"/>  --> 
+<!--       <driver name="LCIOWriter"/>  -->  
        <driver name="CleanupDriver"/>
     </execute>    
     <drivers>
@@ -43,7 +43,11 @@
         </driver>
 
         <driver name="TrackerHitDriver"
-                type="org.lcsim.hps.users.mgraham.DataTrackerHitDriver"/>
+                type="org.lcsim.hps.users.mgraham.DataTrackerHitDriver">
+                <clusterSeedThreshold>3.0</clusterSeedThreshold>
+                <clusterNeighborThreshold>3.0</clusterNeighborThreshold>
+                <clusterThreshold>3.0</clusterThreshold>
+        </driver>
 
          <driver name="SVTEventPlots"
                 type="org.lcsim.hps.monitoring.svt.SVTEventInfo">
@@ -69,6 +73,10 @@
         <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>  
              <outputPlots>svtPulsePlots.aida</outputPlots> 
         </driver>    
+        <driver name="SVTOccupancyPlots" type="org.lcsim.hps.monitoring.svt.SensorOccupancyPlotsDriver">
+            <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>
+            <eventRefreshRate>100</eventRefreshRate>
+        </driver>
 
         <driver name="SVTEventDisplay"
                 type="org.lcsim.hps.monitoring.svt.SVTEventDisplay">
@@ -85,7 +93,7 @@
 
         <driver name="TrackerReconDriver"
                 type="org.lcsim.hps.recon.tracking.TrackerReconDriver">
-            <debug>false</debug>
+            <debug>false</debug>           
             <strategyResource>/org/lcsim/hps/recon/tracking/strategies/HPS-Test-4pt1.xml</strategyResource>
             <stripMaxSeparation>20.0</stripMaxSeparation>
             <stripTolerance>1.0</stripTolerance>
@@ -101,14 +109,20 @@
 
 
           <driver name="LCIOWriter"
-                type="org.lcsim.util.loop.LCIODriver">
-            <outputFilePath>/Users/phansson/work/HPS/software/reco/run/hps_000820_trackRecon.slcio</outputFilePath>
+                type="org.lcsim.hps.users.mgraham.MyLCIOWriterDriver">
+            <outputFilePath>/Users/mgraham/HPS/trackRecon.slcio</outputFilePath>
         </driver>
 
+<!--
+          <driver name="LCIOWriter"
+                type="org.lcsim.util.loop.LCIODriver">
+            <outputFilePath>/Users/mgraham/HPS/trackRecon.slcio</outputFilePath>
+        </driver>
+-->
        <driver name="CleanupDriver" 
                 type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver">
-                <collectionNames>TrackerHits SVTRawTrackerHits  SVTFittedRawTrackerHits</collectionNames>
+                <collectionNames>TrackerHits SVTRawTrackerHits  SVTFittedRawTrackerHits StripClusterer_SiTrackerHitStrip1D</collectionNames>
         </driver>
 
     </drivers>   
-</lcsim>
\ No newline at end of file
+</lcsim>

hps-java/src/main/java/org/lcsim/hps/recon/tracking
AxialTrackReconDriver.java added at 1.1
diff -N AxialTrackReconDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ AxialTrackReconDriver.java	24 May 2012 14:34:00 -0000	1.1
@@ -0,0 +1,433 @@
+package org.lcsim.hps.recon.tracking;
+
+import hep.physics.matrix.SymmetricMatrix;
+import hep.physics.vec.BasicHep3Vector;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.lcsim.detector.tracker.silicon.SiTrackerModule;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackerHit;
+import org.lcsim.fit.helicaltrack.*;
+import org.lcsim.fit.helicaltrack.HelicalTrackFitter.FitStatus;
+import org.lcsim.fit.line.SlopeInterceptLineFit;
+import org.lcsim.fit.line.SlopeInterceptLineFitter;
+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.*;
+import org.lcsim.recon.tracking.seedtracker.diagnostic.SeedTrackerDiagnostics;
+import org.lcsim.util.Driver;
+import org.lcsim.util.lcio.LCIOConstants;
+
+/**
+ * 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.
+ *
+ * @author jeremym
+ * @version $Id: TrackerReconDriver.java,v 1.18 2012/05/03 20:50:29 mgraham Exp
+ * $
+ */
+public final class AxialTrackReconDriver extends Driver {
+
+    // Debug flag.
+    //private final static boolean DEBUG = false;
+    private boolean debug = false;
+    // Tracks found across all events.
+    int ntracks = 0;
+    // Number of events processed.
+    int nevents = 0;
+    // Cache detector object.
+    Detector detector = null;
+    // Default B-field value.
+    private double bfield = 0.5;
+    // Name of the SVT subdetector.
+    private String subdetectorName = "Tracker";
+    // SimTrackerHit input collection for readout cleanup.
+    private String simTrackerHitCollectionName = "TrackerHits";
+    // Tracking strategies resource path.
+    private String strategyResource = "HPS-Test-1pt3.xml";
+    // Output track collection.
+    private String trackCollectionName = "MatchedTracks";
+    // HelicalTrackHit input collection.
+    private String stInputCollectionName = "RotatedHelicalTrackHits";
+    // Output hit collection for HelicalTrackHits.
+    private String hthOutputCollectionName = "HelicalTrackHits";
+    // Input strip hits collection from digi.
+    private String stripHitsCollectionName = "StripClusterer_SiTrackerHitStrip1D";
+    // Hit relations output collection.
+    private String helicalTrackHitRelationsCollectionName = "HelicalTrackHitRelations";
+    // Track to MC relations output collection.
+    private String helicalTrackMCRelationsCollectionName = "HelicalTrackMCRelations";
+    // Max strip separation when making HelicalTrackHits.
+    private double stripMaxSeparation = 10.01;
+    // Tolerance factor when making HelicalTrackHits.
+    private double stripTolerance = 0.01;
+    private List<SeedStrategy> sFinallist;
+
+    public AxialTrackReconDriver() {
+    }
+
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+    }
+
+    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;
+    }
+
+    public void setHelicalTrackHitRelationsCollectionName(String helicalTrackHitRelationsCollectionName) {
+        this.helicalTrackHitRelationsCollectionName = helicalTrackHitRelationsCollectionName;
+    }
+
+    public void setHelicalTrackMCRelationsCollectionName(String helicalTrackMCRelationsCollectionName) {
+        this.helicalTrackMCRelationsCollectionName = helicalTrackMCRelationsCollectionName;
+    }
+
+    public void setInputHitCollectionName(String inputHitCollectionName) {
+        this.stInputCollectionName = inputHitCollectionName;
+    }
+
+    public void setOutputHitCollectionName(String outputHitCollectionName) {
+        this.hthOutputCollectionName = outputHitCollectionName;
+    }
+
+    public void setStripHitsCollectionName(String stripHitsCollectionName) {
+        this.stripHitsCollectionName = stripHitsCollectionName;
+    }
+
+    public void setTrackCollectionName(String trackCollectionName) {
+        this.trackCollectionName = trackCollectionName;
+    }
+
+    public void setStripMaxSeparation(double stripMaxSeparation) {
+        this.stripMaxSeparation = stripMaxSeparation;
+    }
+
+    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.
+     */
+    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);
+        }
+
+        initialize();
+
+        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.");
+        }
+
+
+        // Create the Driver.
+        HPSHelicalTrackHitDriver hthdriver = new HPSHelicalTrackHitDriver();
+        hthdriver.addCollection(stripHitsCollectionName);
+        hthdriver.setOutputCollectionName(hthOutputCollectionName);
+//        hthdriver.setHitRelationName(helicalTrackHitRelationsCollectionName);
+//        hthdriver.setMCRelationName(helicalTrackMCRelationsCollectionName);
+
+  //      hthdriver.setStripMaxSeparation(stripMaxSeparation);
+  //      hthdriver.setStripTolerance(stripTolerance); // user parameter?
+        hthdriver.setTransformToTracking(true);
+        hthdriver.setDebug(true);
+        add(hthdriver);
+
+        //
+        // 2) Driver to run Seed Tracker.
+        //
+        sFinallist = StrategyXMLUtils.getStrategyListFromInputStream(this.getClass().getResourceAsStream(strategyResource));
+        // 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();
+    }
+
+    /**
+     * 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);
+        double maxChi2 = 250;
+        List<HelicalTrackHit> hth = event.get(HelicalTrackHit.class, stInputCollectionName);
+
+
+        System.out.println("The HelicalTrackHit collection " + hthOutputCollectionName + " has " + hth.size() + " hits.");
+        List<HelicalTrackHit> hitsLayer1 = getLayerHits(hth, 1);
+        List<HelicalTrackHit> hitsLayer3 = getLayerHits(hth, 3);
+        List<HelicalTrackHit> hitsLayer5 = getLayerHits(hth, 5);
+        List<HelicalTrackHit> hitsLayer7 = getLayerHits(hth, 7);
+        List<HelicalTrackHit> hitsLayer9 = getLayerHits(hth, 9);
+
+        List<SeedCandidate> seedtracks = new ArrayList<SeedCandidate>();
+        for (HelicalTrackHit h1 : hitsLayer1) {
+            for (HelicalTrackHit h3 : hitsLayer3) {
+                for (HelicalTrackHit h5 : hitsLayer5) {
+                    for (HelicalTrackHit h7 : hitsLayer7) {
+//                        for (HelicalTrackHit h9 : hitsLayer9) {
+
+                            SeedCandidate seed = new SeedCandidate(sFinallist.get(0), bfield);
+                            seed.addHit(h1);
+                            seed.addHit(h3);
+                            seed.addHit(h5);
+                            seed.addHit(h7);
+//                            seed.addHit(h9);
+
+                            HelicalTrackFit fitRes = fit(seed);
+                            if (fitRes != null) {
+                                seed.setHelix(fitRes);
+                                if (fitRes.chisq()[1] > maxChi2)
+                                    continue;
+
+                                seedtracks.add(seed);
+//                       System.out.println(fitRes.toString());
+                            }
+//                        }
+                    }
+                }
+            }
+        }
+
+        addTracksToEvent(event, seedtracks, bfield);
+        // Debug printouts.
+        if (debug) {
+            // Check for HelicalTrackHits.
+
+            // 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());
+                System.out.println("chi2 = " + track.getChi2());
+            }
+        }
+
+        // Increment number of events.
+        ++nevents;
+
+        // Add to tracks found.
+        ntracks += event.get(Track.class, trackCollectionName).size();
+    }
+
+    public HelicalTrackFit fit(SeedCandidate seed) {
+        List<HelicalTrackHit> hitcol = seed.getHits();
+        Map<HelicalTrackHit, MultipleScatter> msmap = new HashMap<HelicalTrackHit, MultipleScatter>();
+        SlopeInterceptLineFitter _lfitter = new SlopeInterceptLineFitter();
+        SlopeInterceptLineFit _lfit;
+        boolean success = false;
+        //  Check if we have enough pixel hits to do a straight-line fit of s vs z
+        int npix = hitcol.size();
+        //  Calculate the arc lengths from the DCA to each hit and check for backwards hits
+        Map<HelicalTrackHit, Double> smap = getPathLengths(hitcol);
+        //  Create the objects that will hold the fit output
+        double[] chisq = new double[2];
+        int[] ndof = new int[2];
+        ndof[0] = 0;
+        chisq[0] = 0;
+        double[] par = new double[5];
+        SymmetricMatrix cov = new SymmetricMatrix(5);
+
+
+        //  Setup for the line fit
+        double[] s = new double[npix];
+        double[] z = new double[npix];
+        double[] dz = new double[npix];
+
+        //  Store the coordinates and errors for the line fit
+        for (int i = 0; i < npix; i++) {
+            HelicalTrackHit hit = hitcol.get(i);
+            z[i] = hit.z();
+            System.out.println(hit.getCorrectedCovMatrix().toString());
+            dz[i] = Math.sqrt(hit.getCorrectedCovMatrix().e(2, 2));
+            s[i] = smap.get(hit);
+            System.out.println(z[i] + " " + dz[i] + " " + s[i]);
+        }
+
+        //  Call the line fitter and check for success
+        success = _lfitter.fit(s, z, dz, npix);
+        if (!success) {
+            return null;
+        }
+
+        //  Save the line fit, chi^2, and DOF
+        _lfit = _lfitter.getFit();
+        chisq[1] = _lfit.chisquared();
+        ndof[1] = npix - 2;
+
+        //  Save the line fit parameters
+        par[HelicalTrackFit.z0Index] = _lfit.intercept();
+        par[HelicalTrackFit.slopeIndex] = _lfit.slope();
+        par[HelicalTrackFit.curvatureIndex] = 0.0001;
+        par[HelicalTrackFit.dcaIndex] = 0.0001;
+        par[HelicalTrackFit.phi0Index] = 0.000;
+
+
+        //  Save the line fit covariance matrix elements
+        cov.setElement(HelicalTrackFit.z0Index, HelicalTrackFit.z0Index, Math.pow(_lfit.interceptUncertainty(), 2));
+        cov.setElement(HelicalTrackFit.z0Index, HelicalTrackFit.slopeIndex, _lfit.covariance());
+        cov.setElement(HelicalTrackFit.slopeIndex, HelicalTrackFit.slopeIndex, Math.pow(_lfit.slopeUncertainty(), 2));
+        cov.setElement(HelicalTrackFit.curvatureIndex, HelicalTrackFit.curvatureIndex, 0);
+        cov.setElement(HelicalTrackFit.curvatureIndex, HelicalTrackFit.phi0Index, 0);
+        cov.setElement(HelicalTrackFit.phi0Index, HelicalTrackFit.phi0Index, 0);
+        cov.setElement(HelicalTrackFit.curvatureIndex, HelicalTrackFit.dcaIndex, 0);  // fix d0 sign convention
+        cov.setElement(HelicalTrackFit.phi0Index, HelicalTrackFit.dcaIndex, 0);  // fix d0 sign convention
+        cov.setElement(HelicalTrackFit.dcaIndex, HelicalTrackFit.dcaIndex, 0);
+
+
+        //  Create the HelicalTrackFit for this helix
+        return new HelicalTrackFit(par, cov, chisq, ndof, smap, msmap);
+
+    }
+
+    private Map<HelicalTrackHit, Double> getPathLengths(List<HelicalTrackHit> hits) {
+
+        //  Create a map to store the arc lengths
+        Map<HelicalTrackHit, Double> smap = new HashMap<HelicalTrackHit, Double>();
+
+        //  Initialize looper tracking and iterate over ordered list of hits
+        double slast = 0.;
+        int ilast = -1;
+        double s;
+        for (int i = 0; i < hits.size(); i++) {
+
+            // Retrieve the next hit ordered by z coordinate and check hit type
+            HelicalTrackHit hit = hits.get(i);
+            if (hit instanceof HelicalTrack2DHit) {
+
+                //  Axial hit - measure from the DCA (can't handle loopers)
+//                s = HelixUtils.PathLength(_cfit, hit);
+                s = hit.getPosition()[0];
+                //  Save the arc length for this hit
+                smap.put(hit, s);
+            }
+        }
+        return smap;
+    }
+
+    private List<HelicalTrackHit> getLayerHits(List<HelicalTrackHit> hth, int layer) {
+        List<HelicalTrackHit> layerHits = new ArrayList<HelicalTrackHit>();
+
+        for (HelicalTrackHit hit : hth) {
+            if (hit.Layer() == layer)
+                layerHits.add(hit);
+        }
+        return layerHits;
+    }
+
+    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.");
+        }
+    }
+
+    private void addTracksToEvent(EventHeader event, List<SeedCandidate> seedlist, double bfield) {
+        //  Create a the track list
+        List<Track> tracks = new ArrayList<Track>();
+
+        //  Initialize the reference point to the origin
+        double[] ref = new double[3];
+        ref[0] = 0.;
+        ref[1] = 0.;
+        ref[2] = 0.;
+        //  Loop over the SeedCandidates that have survived
+        for (SeedCandidate trackseed : seedlist) {
+
+            //  Create a new SeedTrack (SeedTrack extends BaseTrack)
+            SeedTrack trk = new SeedTrack();
+
+            //  Add the hits to the track
+            for (HelicalTrackHit hit : trackseed.getHits()) {
+                trk.addHit((TrackerHit) hit);
+            }
+
+            //  Retrieve the helix and save the relevant bits of helix info
+            HelicalTrackFit helix = trackseed.getHelix();
+            trk.setTrackParameters(helix.parameters(), bfield);
+            trk.setCovarianceMatrix(helix.covariance());
+            trk.setChisq(helix.chisqtot());
+            trk.setNDF(helix.ndf()[0] + helix.ndf()[1]);
+
+            //  Flag that the fit was successful and set the reference point
+            trk.setFitSuccess(true);
+            trk.setReferencePoint(ref);
+            trk.setRefPointIsDCA(true);
+
+            //  Set the strategy used to find this track
+            trk.setStratetgy(trackseed.getSeedStrategy());
+
+            //  Set the SeedCandidate this track is based on
+            trk.setSeedCandidate(trackseed);
+
+
+            //  Add the track to the list of tracks
+            tracks.add((Track) trk);
+        }
+
+        // Put the tracks back into the event and exit
+        int flag = 1 << LCIOConstants.TRBIT_HITS;
+        event.put(trackCollectionName, tracks, Track.class, flag);
+    }
+}

hps-java/src/main/java/org/lcsim/hps/recon/tracking
TrackerReconDriver.java 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- TrackerReconDriver.java	13 May 2012 21:38:20 -0000	1.19
+++ TrackerReconDriver.java	24 May 2012 14:34:00 -0000	1.20
@@ -37,7 +37,7 @@
     // Cache detector object.
     Detector detector = null;
     // Default B-field value.
-    private double bfield = 0.8;
+    private double bfield = 0.5;
     // SimTrackerHit input collection for readout cleanup.
     private String simTrackerHitCollectionName = "TrackerHits";
     // Tracking strategies resource path.

hps-java/src/main/java/org/lcsim/hps/users/mgraham
MyLCIOWriterDriver.java added at 1.1
diff -N MyLCIOWriterDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MyLCIOWriterDriver.java	24 May 2012 14:34:00 -0000	1.1
@@ -0,0 +1,89 @@
+package org.lcsim.hps.users.mgraham;
+
+import java.io.IOException;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.Track;
+import org.lcsim.util.Driver;
+import org.lcsim.util.lcio.LCIOWriter;
+
+/**
+ *
+ * @author mgraham Created 5/17/2012 really the same as
+ * org.lcsim.util.LCIODriver but only write events that pass some condition
+ * (e.g. has a reconstructed track)
+ */
+public class MyLCIOWriterDriver extends Driver {
+
+    private String outputFile;
+    private LCIOWriter writer;
+    private String trackCollectionName = "MatchedTracks";
+
+    public MyLCIOWriterDriver() {
+    }
+
+    public void setOutputFilePath(String output) {
+        this.outputFile = output;
+    }
+    
+      public void setTrackCollectionNamePath(String trackCollection) {
+        this.trackCollectionName = trackCollection;
+    }
+
+    private void setupWriter() {
+        // Cleanup existing writer.
+        if (writer != null) {
+            try {
+                writer.flush();
+                writer.close();
+                writer = null;
+            } catch (IOException x) {
+                System.err.println(x.getMessage());
+            }
+        }
+
+        // Setup new writer.
+        try {
+            writer = new LCIOWriter(outputFile);
+        } catch (IOException x) {
+            throw new RuntimeException("Error creating writer", x);
+        }
+
+
+        try {
+            writer.reOpen();
+        } catch (IOException x) {
+            throw new RuntimeException("Error rewinding LCIO file", x);
+        }
+    }
+
+    protected void startOfData() {
+        setupWriter();
+    }
+
+    protected void endOfData() {
+        try {
+            writer.close();
+        } catch (IOException x) {
+            throw new RuntimeException("Error rewinding LCIO file", x);
+        }
+    }
+
+    protected void process(EventHeader event) {
+
+        if (event.get(Track.class, trackCollectionName).size()>0) {
+            try {
+                writer.write(event);
+            } catch (IOException x) {
+                throw new RuntimeException("Error writing LCIO file", x);
+            }
+        }
+    }
+
+    protected void suspend() {
+        try {
+            writer.flush();
+        } catch (IOException x) {
+            throw new RuntimeException("Error flushing LCIO file", x);
+        }
+    }
+}
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