Print

Print


Author: [log in to unmask]
Date: Thu Jan 22 15:22:11 2015
New Revision: 1969

Log:
replace TriggerData with TestRunTriggerData/SSPData where appropriate

Modified:
    java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalClusterPlots.java
    java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TestRunTriggerDriver.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerDriver.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TIData.java
    java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TestRunTriggerData.java
    java/trunk/evio/src/main/java/org/hps/evio/TriggerDataWriter.java
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/TrackTimePlots.java
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java
    java/trunk/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java
    java/trunk/users/src/main/java/org/hps/users/phansson/ROOTFlatTupleDriver.java
    java/trunk/users/src/main/java/org/hps/users/phansson/TriggerTurnOnAnalysis.java

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalClusterPlots.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalClusterPlots.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalClusterPlots.java	Thu Jan 22 15:22:11 2015
@@ -7,7 +7,6 @@
 import java.util.List;
 
 import org.apache.commons.math.stat.StatUtils;
-import org.hps.readout.ecal.TriggerData;
 import org.hps.recon.ecal.ECalUtils;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.Cluster;
@@ -116,19 +115,6 @@
 
     @Override
     public void process(EventHeader event) {
-        int orTrig = 0;
-        int topTrig = 0;
-        int botTrig = 0;
-        if (event.hasCollection(TriggerData.class, "TriggerBank")) {
-            List<TriggerData> triggerList = event.get(TriggerData.class, "TriggerBank");
-            if (!triggerList.isEmpty()) {
-                TriggerData triggerData = triggerList.get(0);
-
-                orTrig = triggerData.getOrTrig();
-                topTrig = triggerData.getTopTrig();
-                botTrig = triggerData.getBotTrig();
-            }
-        }
         if (event.hasCollection(Cluster.class, inputCollection)) {
             List<Cluster> clusters = event.get(Cluster.class, inputCollection);
             clusterCountPlot.fill(clusters.size());

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java	Thu Jan 22 15:22:11 2015
@@ -7,7 +7,8 @@
 
 import java.util.List;
 
-import org.hps.readout.ecal.TriggerData;
+import org.hps.readout.ecal.triggerbank.AbstractIntData;
+import org.hps.readout.ecal.triggerbank.TestRunTriggerData;
 import org.hps.recon.ecal.ECalUtils;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.EventHeader;
@@ -52,7 +53,6 @@
 
         //plotterFrame = new AIDAFrame();
         //plotterFrame.setTitle("HPS ECal Hit Plots");
-
         aida.tree().cd("/");
         IPlotterFactory plotterFactory = aida.analysisFactory().createPlotterFactory("Ecal Hit Plots");
 
@@ -70,7 +70,6 @@
         plotter.createRegions(1, 2);
         plotter.region(0).plot(hitCountPlot);
         plotter.region(1).plot(hitTimePlot);
-
 
         // Setup the plotter.
         plotter2 = plotterFactory.create("Hit Energies");
@@ -151,40 +150,44 @@
         int orTrigTime = -1;
         int topTrigTime = -1;
         int botTrigTime = -1;
+
         if (event.hasCollection(GenericObject.class, "TriggerBank")) {
             List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
-            if (!triggerList.isEmpty()) {
-                GenericObject triggerData = triggerList.get(0);
-
-                int orTrig = TriggerData.getOrTrig(triggerData);
-                if (orTrig != 0) {
-                    for (int i = 0; i < 32; i++) {
-                        if ((1 << (31 - i) & orTrig) != 0) {
-                            orTrigTime = i;
-                            orTrigTimePlot.fill(i);
-                            break;
-                        }
-                    }
-                }
-                int topTrig = TriggerData.getTopTrig(triggerData);
-                if (topTrig != 0) {
-                    for (int i = 0; i < 32; i++) {
-                        if ((1 << (31 - i) & topTrig) != 0) {
-                            topTrigTime = i;
-                            topTrigTimePlot.fill(i);
-                            break;
-                        }
-                    }
-                }
-                int botTrig = TriggerData.getBotTrig(triggerData);
-                if (botTrig != 0) {
-                    for (int i = 0; i < 32; i++) {
-                        if ((1 << (31 - i) & botTrig) != 0) {
-                            botTrigTime = i;
-                            botTrigTimePlot.fill(i);
-                            break;
-                        }
-                    }
+            for (GenericObject data : triggerList) {
+                if (AbstractIntData.getTag(data) == TestRunTriggerData.BANK_TAG) {
+                    TestRunTriggerData triggerData = new TestRunTriggerData(data);
+
+                    int orTrig = triggerData.getOrTrig();
+                    if (orTrig != 0) {
+                        for (int i = 0; i < 32; i++) {
+                            if ((1 << (31 - i) & orTrig) != 0) {
+                                orTrigTime = i;
+                                orTrigTimePlot.fill(i);
+                                break;
+                            }
+                        }
+                    }
+                    int topTrig = triggerData.getTopTrig();
+                    if (topTrig != 0) {
+                        for (int i = 0; i < 32; i++) {
+                            if ((1 << (31 - i) & topTrig) != 0) {
+                                topTrigTime = i;
+                                topTrigTimePlot.fill(i);
+                                break;
+                            }
+                        }
+                    }
+                    int botTrig = triggerData.getBotTrig();
+                    if (botTrig != 0) {
+                        for (int i = 0; i < 32; i++) {
+                            if ((1 << (31 - i) & botTrig) != 0) {
+                                botTrigTime = i;
+                                botTrigTimePlot.fill(i);
+                                break;
+                            }
+                        }
+                    }
+                    break;
                 }
             }
         }

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TestRunTriggerDriver.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TestRunTriggerDriver.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TestRunTriggerDriver.java	Thu Jan 22 15:22:11 2015
@@ -2,7 +2,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
-
+import org.hps.readout.ecal.triggerbank.TestRunTriggerData;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
 
@@ -29,14 +29,14 @@
     @Override
     protected void makeTriggerData(EventHeader event, String collectionName) {
         int[] trigArray = new int[8];
-        trigArray[TriggerData.TOP_TRIG] = topBits;
-        trigArray[TriggerData.BOT_TRIG] = botBits;
-        trigArray[TriggerData.AND_TRIG] = topBits & botBits;
-        trigArray[TriggerData.OR_TRIG] = topBits | botBits;
-        TriggerData tData = new TriggerData(trigArray);
-        List<TriggerData> triggerList = new ArrayList<TriggerData>();
+        trigArray[TestRunTriggerData.TOP_TRIG] = topBits;
+        trigArray[TestRunTriggerData.BOT_TRIG] = botBits;
+        trigArray[TestRunTriggerData.AND_TRIG] = topBits & botBits;
+        trigArray[TestRunTriggerData.OR_TRIG] = topBits | botBits;
+        TestRunTriggerData tData = new TestRunTriggerData(trigArray);
+        List<TestRunTriggerData> triggerList = new ArrayList<TestRunTriggerData>();
         triggerList.add(tData);
-        event.put(collectionName, triggerList, TriggerData.class, 0);
+        event.put(collectionName, triggerList, TestRunTriggerData.class, 0);
     }
 
     public void setClusterCollectionName(String clusterCollectionName) {

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerDriver.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerDriver.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerDriver.java	Thu Jan 22 15:22:11 2015
@@ -8,6 +8,7 @@
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.hps.readout.ecal.triggerbank.TestRunTriggerData;
 
 import org.lcsim.event.EventHeader;
 import org.lcsim.lcio.LCIOWriter;
@@ -156,10 +157,10 @@
      * Make a dummy TriggerData
      */
     protected void makeTriggerData(EventHeader event, String collectionName) {
-        TriggerData tData = new TriggerData(new int[8]);
-        List<TriggerData> triggerList = new ArrayList<TriggerData>();
+        TestRunTriggerData tData = new TestRunTriggerData(new int[8]);
+        List<TestRunTriggerData> triggerList = new ArrayList<TestRunTriggerData>();
         triggerList.add(tData);
-        event.put(collectionName, triggerList, TriggerData.class, 0);
+        event.put(collectionName, triggerList, TestRunTriggerData.class, 0);
     }
 
     @Override

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TIData.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TIData.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TIData.java	Thu Jan 22 15:22:11 2015
@@ -44,14 +44,8 @@
         calib = ((bank[0] >> 28) & 1) == 1;
         pulser = ((bank[0] >> 29) & 1) == 1;
 
-        long w1 = bank[2];
-        long w2 = bank[3];
-        if (w1 < 0) {
-            w1 += 2 * (long) Integer.MAX_VALUE + 2;
-        }
-        if (w2 < 0) {
-            w2 += 2 * (long) Integer.MAX_VALUE + 2;
-        }
+        long w1 = bank[2] & 0xffffffffL;
+        long w2 = bank[3] & 0xffffffffL;
 
         final long timelo = w1;
         final long timehi = (w2 & 0xffff) << 32;

Modified: java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TestRunTriggerData.java
 =============================================================================
--- java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TestRunTriggerData.java	(original)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/triggerbank/TestRunTriggerData.java	Thu Jan 22 15:22:11 2015
@@ -24,9 +24,11 @@
 //    }
     public TestRunTriggerData(int[] bank) {
         super(bank);
-        if (this.bank.length != BANK_SIZE) {
-            throw new RuntimeException();
-        }
+        decodeData();
+    }
+
+    public TestRunTriggerData(GenericObject data) {
+        super(data, BANK_TAG);
         decodeData();
     }
 

Modified: java/trunk/evio/src/main/java/org/hps/evio/TriggerDataWriter.java
 =============================================================================
--- java/trunk/evio/src/main/java/org/hps/evio/TriggerDataWriter.java	(original)
+++ java/trunk/evio/src/main/java/org/hps/evio/TriggerDataWriter.java	Thu Jan 22 15:22:11 2015
@@ -1,8 +1,8 @@
 package org.hps.evio;
 
 import java.util.List;
-
-import org.hps.readout.ecal.TriggerData;
+import org.hps.readout.ecal.triggerbank.AbstractIntData;
+import org.hps.readout.ecal.triggerbank.TestRunTriggerData;
 import org.jlab.coda.jevio.BaseStructure;
 import org.jlab.coda.jevio.DataType;
 import org.jlab.coda.jevio.EventBuilder;
@@ -19,7 +19,7 @@
 
     @Override
     public boolean hasData(EventHeader event) {
-        return event.hasCollection(TriggerData.class, TriggerData.TRIG_COLLECTION);
+        return event.hasCollection(TestRunTriggerData.class, TestRunTriggerData.TRIG_COLLECTION);
     }
 
     @Override
@@ -44,7 +44,7 @@
         }
 
 
-        List<TriggerData> triggerList = event.get(TriggerData.class, TriggerData.TRIG_COLLECTION);
+        List<AbstractIntData> triggerList = event.get(AbstractIntData.class, TestRunTriggerData.TRIG_COLLECTION);
         EvioBank triggerBank = new EvioBank(EventConstants.TRIGGER_BANK_TAG, DataType.UINT32, EventConstants.TRIGGER_BANK_NUMBER);
         try {
             triggerBank.appendIntData(triggerList.get(0).getBank());
@@ -56,6 +56,6 @@
 
     @Override
     public void writeData(EventHeader event, EventHeader toEvent) {
-        toEvent.put(TriggerData.TRIG_COLLECTION, event.get(TriggerData.class, TriggerData.TRIG_COLLECTION));
+        toEvent.put(TestRunTriggerData.TRIG_COLLECTION, event.get(AbstractIntData.class, TestRunTriggerData.TRIG_COLLECTION));
     }
 }

Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/TrackTimePlots.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/TrackTimePlots.java	(original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/TrackTimePlots.java	Thu Jan 22 15:22:11 2015
@@ -6,13 +6,13 @@
 import hep.aida.IPlotterFactory;
 import hep.aida.IPlotterStyle;
 import hep.aida.ref.plotter.PlotterRegion;
-
 import java.util.List;
-
-import org.hps.readout.ecal.TriggerData;
+import org.hps.readout.ecal.triggerbank.AbstractIntData;
+import org.hps.readout.ecal.triggerbank.TestRunTriggerData;
 import org.lcsim.detector.tracker.silicon.DopedSilicon;
 import org.lcsim.detector.tracker.silicon.HpsSiSensor;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.Track;
 import org.lcsim.event.TrackerHit;
 import org.lcsim.fit.helicaltrack.HelicalTrackCross;
@@ -28,7 +28,7 @@
  */
 public class TrackTimePlots extends Driver {
 
-	//private AIDAFrame plotterFrame;
+    //private AIDAFrame plotterFrame;
     private AIDA aida = AIDA.defaultInstance();
     private String hitCollection = "StripClusterer_SiTrackerHitStrip1D";
     private String trackCollection = "MatchedTracks";
@@ -47,7 +47,7 @@
 
     @Override
     protected void detectorChanged(Detector detector) {
-    	//plotterFrame = new AIDAFrame();
+        //plotterFrame = new AIDAFrame();
         //plotterFrame.setTitle("HPS SVT Track Time Plots");
 
         aida.tree().cd("/");
@@ -118,12 +118,11 @@
         style.dataStyle().errorBarStyle().setVisible(false);
         plotter7.createRegions(2, 2);
 
-        
-        for(HpsSiSensor sensor : sensors){
-        	int module = sensor.getModuleNumber();
-        	int layer = sensor.getLayerNumber(); 
+        for (HpsSiSensor sensor : sensors) {
+            int module = sensor.getModuleNumber();
+            int layer = sensor.getLayerNumber();
             int region = computePlotterRegion(layer + 1, module);
-        
+
             t0[module][layer] = aida.histogram1D(sensor.getName() + "_timing", 75, -50, 100.0);
             plotter.region(region).plot(t0[module][layer]);
             ((PlotterRegion) plotter.region(region)).getPlot().getXAxis().setLabel("Hit time [ns]");
@@ -142,16 +141,16 @@
             ((PlotterRegion) plotter6.region(region)).getPlot().getXAxis().setLabel("Hit position [mm]");
             ((PlotterRegion) plotter6.region(region)).getPlot().getYAxis().setLabel("Hit time residual [ns]");
         }
-        	
+
         for (int module = 0; module < 2; module++) {
-        
+
             trackT0[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Time", 75, -50, 100.0);
             plotter2.region(module).plot(trackT0[module]);
             ((PlotterRegion) plotter2.region(module)).getPlot().getXAxis().setLabel("Track time [ns]");
             trackTrigTime[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " Track Time vs. Trig Time", 75, -50, 100.0, 33, -1, 32);
             plotter2.region(module + 2).plot(trackTrigTime[module]);
-            ((PlotterRegion) plotter2.region(module+2)).getPlot().getXAxis().setLabel("Track time [ns]");
-            ((PlotterRegion) plotter2.region(module+2)).getPlot().getYAxis().setLabel("Trigger time [clocks]");
+            ((PlotterRegion) plotter2.region(module + 2)).getPlot().getXAxis().setLabel("Track time [ns]");
+            ((PlotterRegion) plotter2.region(module + 2)).getPlot().getYAxis().setLabel("Trigger time [clocks]");
             style = plotter2.region(module + 2).style();
             style.setParameter("hist2DStyle", "colorMap");
             style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
@@ -162,63 +161,62 @@
             ((PlotterRegion) plotter7.region(module)).getPlot().getXAxis().setLabel("Track time range [ns]");
             trackTimeMinMax[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " First and Last Track Hit Times", 75, -50, 100.0, 75, -50, 100.0);
             plotter7.region(module + 2).plot(trackTimeMinMax[module]);
-            ((PlotterRegion) plotter7.region(module+2)).getPlot().getXAxis().setLabel("First track hit time [ns]");
-            ((PlotterRegion) plotter7.region(module+2)).getPlot().getYAxis().setLabel("Last track hit time [ns]");
+            ((PlotterRegion) plotter7.region(module + 2)).getPlot().getXAxis().setLabel("First track hit time [ns]");
+            ((PlotterRegion) plotter7.region(module + 2)).getPlot().getYAxis().setLabel("Last track hit time [ns]");
             style = plotter7.region(module + 2).style();
             style.setParameter("hist2DStyle", "colorMap");
             style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
             style.zAxisStyle().setParameter("scale", "log");
         }
-        	
-       /* ===> for (int module = 0; module < 2; module++) {
-            for (int layer = 0; layer < 10; layer++) {
-                SiSensor sensor = SvtUtils.getInstance().getSensor(module, layer);
-                int region = computePlotterRegion(layer + 1, module);
-                t0[module][layer] = aida.histogram1D(sensor.getName() + "_timing", 75, -50, 100.0);
-                plotter.region(region).plot(t0[module][layer]);
-                ((PlotterRegion) plotter.region(region)).getPlot().getXAxis().setLabel("Hit time [ns]");
-                trackHitT0[module][layer] = aida.histogram1D(sensor.getName() + "_trackHit_timing", 75, -50, 4000.0);
-                plotter3.region(region).plot(trackHitT0[module][layer]);
-                ((PlotterRegion) plotter3.region(region)).getPlot().getXAxis().setLabel("Hit time [ns]");
-                trackHitDt[module][layer] = aida.histogram1D(sensor.getName() + "_trackHit_dt", 50, -20, 20.0);
-                plotter4.region(region).plot(trackHitDt[module][layer]);
-                ((PlotterRegion) plotter4.region(region)).getPlot().getXAxis().setLabel("Hit time residual [ns]");
-                trackHit2D[module][layer] = aida.histogram2D(sensor.getName() + "_trackHit_dt_2D", 75, -50, 100.0, 50, -20, 20.0);
-                plotter5.region(region).plot(trackHit2D[module][layer]);
-                ((PlotterRegion) plotter5.region(region)).getPlot().getXAxis().setLabel("Track time [ns]");
-                ((PlotterRegion) plotter5.region(region)).getPlot().getYAxis().setLabel("Hit time [ns]");
-                trackHitDtChan[module][layer] = aida.histogram2D(sensor.getName() + "_trackHit_dt_chan", 200, -20, 20, 50, -20, 20.0);
-                plotter6.region(region).plot(trackHitDtChan[module][layer]);
-                ((PlotterRegion) plotter6.region(region)).getPlot().getXAxis().setLabel("Hit position [mm]");
-                ((PlotterRegion) plotter6.region(region)).getPlot().getYAxis().setLabel("Hit time residual [ns]");
-            }
-            trackT0[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Time", 75, -50, 100.0);
-            plotter2.region(module).plot(trackT0[module]);
-            ((PlotterRegion) plotter2.region(module)).getPlot().getXAxis().setLabel("Track time [ns]");
-            trackTrigTime[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " Track Time vs. Trig Time", 75, -50, 100.0, 33, -1, 32);
-            plotter2.region(module + 2).plot(trackTrigTime[module]);
-            ((PlotterRegion) plotter2.region(module+2)).getPlot().getXAxis().setLabel("Track time [ns]");
-            ((PlotterRegion) plotter2.region(module+2)).getPlot().getYAxis().setLabel("Trigger time [clocks]");
-            style = plotter2.region(module + 2).style();
-            style.setParameter("hist2DStyle", "colorMap");
-            style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-            style.zAxisStyle().setParameter("scale", "log");
-
-            trackTimeRange[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Hit Time Range", 75, 0, 30.0);
-            plotter7.region(module).plot(trackTimeRange[module]);
-            ((PlotterRegion) plotter7.region(module)).getPlot().getXAxis().setLabel("Track time range [ns]");
-            trackTimeMinMax[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " First and Last Track Hit Times", 75, -50, 100.0, 75, -50, 100.0);
-            plotter7.region(module + 2).plot(trackTimeMinMax[module]);
-            ((PlotterRegion) plotter7.region(module+2)).getPlot().getXAxis().setLabel("First track hit time [ns]");
-            ((PlotterRegion) plotter7.region(module+2)).getPlot().getYAxis().setLabel("Last track hit time [ns]");
-            style = plotter7.region(module + 2).style();
-            style.setParameter("hist2DStyle", "colorMap");
-            style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-            style.zAxisStyle().setParameter("scale", "log");
-        } ===> */
+
+        /* ===> for (int module = 0; module < 2; module++) {
+         for (int layer = 0; layer < 10; layer++) {
+         SiSensor sensor = SvtUtils.getInstance().getSensor(module, layer);
+         int region = computePlotterRegion(layer + 1, module);
+         t0[module][layer] = aida.histogram1D(sensor.getName() + "_timing", 75, -50, 100.0);
+         plotter.region(region).plot(t0[module][layer]);
+         ((PlotterRegion) plotter.region(region)).getPlot().getXAxis().setLabel("Hit time [ns]");
+         trackHitT0[module][layer] = aida.histogram1D(sensor.getName() + "_trackHit_timing", 75, -50, 4000.0);
+         plotter3.region(region).plot(trackHitT0[module][layer]);
+         ((PlotterRegion) plotter3.region(region)).getPlot().getXAxis().setLabel("Hit time [ns]");
+         trackHitDt[module][layer] = aida.histogram1D(sensor.getName() + "_trackHit_dt", 50, -20, 20.0);
+         plotter4.region(region).plot(trackHitDt[module][layer]);
+         ((PlotterRegion) plotter4.region(region)).getPlot().getXAxis().setLabel("Hit time residual [ns]");
+         trackHit2D[module][layer] = aida.histogram2D(sensor.getName() + "_trackHit_dt_2D", 75, -50, 100.0, 50, -20, 20.0);
+         plotter5.region(region).plot(trackHit2D[module][layer]);
+         ((PlotterRegion) plotter5.region(region)).getPlot().getXAxis().setLabel("Track time [ns]");
+         ((PlotterRegion) plotter5.region(region)).getPlot().getYAxis().setLabel("Hit time [ns]");
+         trackHitDtChan[module][layer] = aida.histogram2D(sensor.getName() + "_trackHit_dt_chan", 200, -20, 20, 50, -20, 20.0);
+         plotter6.region(region).plot(trackHitDtChan[module][layer]);
+         ((PlotterRegion) plotter6.region(region)).getPlot().getXAxis().setLabel("Hit position [mm]");
+         ((PlotterRegion) plotter6.region(region)).getPlot().getYAxis().setLabel("Hit time residual [ns]");
+         }
+         trackT0[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Time", 75, -50, 100.0);
+         plotter2.region(module).plot(trackT0[module]);
+         ((PlotterRegion) plotter2.region(module)).getPlot().getXAxis().setLabel("Track time [ns]");
+         trackTrigTime[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " Track Time vs. Trig Time", 75, -50, 100.0, 33, -1, 32);
+         plotter2.region(module + 2).plot(trackTrigTime[module]);
+         ((PlotterRegion) plotter2.region(module+2)).getPlot().getXAxis().setLabel("Track time [ns]");
+         ((PlotterRegion) plotter2.region(module+2)).getPlot().getYAxis().setLabel("Trigger time [clocks]");
+         style = plotter2.region(module + 2).style();
+         style.setParameter("hist2DStyle", "colorMap");
+         style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+         style.zAxisStyle().setParameter("scale", "log");
+
+         trackTimeRange[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Hit Time Range", 75, 0, 30.0);
+         plotter7.region(module).plot(trackTimeRange[module]);
+         ((PlotterRegion) plotter7.region(module)).getPlot().getXAxis().setLabel("Track time range [ns]");
+         trackTimeMinMax[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " First and Last Track Hit Times", 75, -50, 100.0, 75, -50, 100.0);
+         plotter7.region(module + 2).plot(trackTimeMinMax[module]);
+         ((PlotterRegion) plotter7.region(module+2)).getPlot().getXAxis().setLabel("First track hit time [ns]");
+         ((PlotterRegion) plotter7.region(module+2)).getPlot().getYAxis().setLabel("Last track hit time [ns]");
+         style = plotter7.region(module + 2).style();
+         style.setParameter("hist2DStyle", "colorMap");
+         style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+         style.zAxisStyle().setParameter("scale", "log");
+         } ===> */
 //        shape = aida.histogram2D("Shape", 200, -1, 3, 200, -0.5, 2);
 //        plotter5.region(0).plot(shape);
-
         //plotterFrame.pack();
         //plotterFrame.setVisible(true);
     }
@@ -240,37 +238,40 @@
         int orTrigTime = -1;
         int topTrigTime = -1;
         int botTrigTime = -1;
-        if (event.hasCollection(TriggerData.class, "TriggerBank")) {
-            List<TriggerData> triggerList = event.get(TriggerData.class, "TriggerBank");
-            if (!triggerList.isEmpty()) {
-                TriggerData triggerData = triggerList.get(0);
-
-                orTrig = triggerData.getOrTrig();
-                if (orTrig != 0) {
-                    for (int i = 0; i < 32; i++) {
-                        if ((1 << (31 - i) & orTrig) != 0) {
-                            orTrigTime = i;
-                            break;
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
+            for (GenericObject data : triggerList) {
+                if (AbstractIntData.getTag(data) == TestRunTriggerData.BANK_TAG) {
+                    TestRunTriggerData triggerData = new TestRunTriggerData(data);
+
+                    orTrig = triggerData.getOrTrig();
+                    if (orTrig != 0) {
+                        for (int i = 0; i < 32; i++) {
+                            if ((1 << (31 - i) & orTrig) != 0) {
+                                orTrigTime = i;
+                                break;
+                            }
                         }
                     }
-                }
-                topTrig = triggerData.getTopTrig();
-                if (topTrig != 0) {
-                    for (int i = 0; i < 32; i++) {
-                        if ((1 << (31 - i) & topTrig) != 0) {
-                            topTrigTime = i;
-                            break;
+                    topTrig = triggerData.getTopTrig();
+                    if (topTrig != 0) {
+                        for (int i = 0; i < 32; i++) {
+                            if ((1 << (31 - i) & topTrig) != 0) {
+                                topTrigTime = i;
+                                break;
+                            }
                         }
                     }
-                }
-                botTrig = triggerData.getBotTrig();
-                if (botTrig != 0) {
-                    for (int i = 0; i < 32; i++) {
-                        if ((1 << (31 - i) & botTrig) != 0) {
-                            botTrigTime = i;
-                            break;
+                    botTrig = triggerData.getBotTrig();
+                    if (botTrig != 0) {
+                        for (int i = 0; i < 32; i++) {
+                            if ((1 << (31 - i) & botTrig) != 0) {
+                                botTrigTime = i;
+                                break;
+                            }
                         }
                     }
+                    break;
                 }
             }
         }
@@ -280,8 +281,8 @@
         for (SiTrackerHitStrip1D hit : hits) {
             //===> IIdentifier id = hit.getSensor().getIdentifier();
             //===> int layer = helper.getValue(id, "layer");
-             int layer = ((HpsSiSensor) hit.getSensor()).getLayerNumber(); 
-             int module = ((HpsSiSensor) hit.getSensor()).getModuleNumber(); 
+            int layer = ((HpsSiSensor) hit.getSensor()).getLayerNumber();
+            int module = ((HpsSiSensor) hit.getSensor()).getModuleNumber();
             //===> int module = helper.getValue(id, "module");
 //            System.out.format("%d, %d, %d\n",hit.getCellID(),layer,module);
             t0[module][layer - 1].fill(hit.getTime());
@@ -336,7 +337,7 @@
 
     @Override
     public void endOfData() {
-    	//plotterFrame.dispose();
+        //plotterFrame.dispose();
     }
 
     private int computePlotterRegion(int layer, int module) {

Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java	(original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java	Thu Jan 22 15:22:11 2015
@@ -8,8 +8,6 @@
 
 import java.util.List;
 
-import org.hps.readout.ecal.TriggerData;
-import org.hps.readout.ecal.SSPData;
 import org.hps.recon.ecal.ECalUtils;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.EventHeader;

Modified: java/trunk/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java	Thu Jan 22 15:22:11 2015
@@ -7,8 +7,8 @@
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
 
-import org.hps.readout.ecal.TriggerData;
-import org.hps.readout.ecal.SSPData;
+import org.hps.readout.ecal.triggerbank.SSPData;
+import org.hps.readout.ecal.triggerbank.AbstractIntData;
 import org.hps.recon.ecal.ECalUtils;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.EventHeader;
@@ -48,7 +48,7 @@
             	botTrigTime =((SSPData)triggerData).getBotTrig();      
             	System.out.println(orTrigTime+" "+topTrigTime+" "+botTrigTime);
             }         
-            else{
+            else if (AbstractIntData.getTag(triggerData)==SSPData.BANK_TAG){
             	SSPData mData=new SSPData(triggerData);
             	orTrigTime=(mData).getOrTrig();
             	topTrigTime=(mData).getTopTrig();

Modified: java/trunk/users/src/main/java/org/hps/users/phansson/ROOTFlatTupleDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/phansson/ROOTFlatTupleDriver.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/phansson/ROOTFlatTupleDriver.java	Thu Jan 22 15:22:11 2015
@@ -7,7 +7,6 @@
 import hep.physics.vec.BasicHep3Vector;
 import hep.physics.vec.Hep3Vector;
 import hep.physics.vec.VecOp;
-
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -19,10 +18,9 @@
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
 import org.hps.analysis.ecal.HPSMCParticlePlotsDriver;
-//===> import org.hps.conditions.deprecated.SvtUtils;
-import org.hps.readout.ecal.TriggerData;
+import org.hps.readout.ecal.triggerbank.AbstractIntData;
+import org.hps.readout.ecal.triggerbank.TestRunTriggerData;
 import org.hps.recon.tracking.BeamlineConstants;
 import org.hps.recon.tracking.EventQuality;
 import org.hps.recon.tracking.HPSTrack;
@@ -58,6 +56,7 @@
 
 /**
  * Analysis class which makes a text file compatible with ROOT Tree.
+ *
  * @author phansson <[log in to unmask]>
  * @version $id: $
  */
@@ -69,11 +68,11 @@
     private String trackCollectionName = "MatchedTracks";
     private boolean doPrintBranchInfoLine = true; //firs tline in text file
     private AIDA aida = AIDA.defaultInstance();
-    private int totalEvents=0;
-    private int totalTwoTrackEvents=0;
-    private int totalMCEvents=0;
-    private int totalTwoTrackMCEvents=0;
-	private int nEventsWithGoodRegionCluster=0;
+    private int totalEvents = 0;
+    private int totalTwoTrackEvents = 0;
+    private int totalMCEvents = 0;
+    private int totalTwoTrackMCEvents = 0;
+    private int nEventsWithGoodRegionCluster = 0;
     private boolean hideFrame = false;
     private String outputPlotFileName;
     private String ecalClusterCollectionName = "EcalClusters";
@@ -87,7 +86,7 @@
     private TwoTrackVertexer vertexer = new TwoTrackVertexer();
     private TwoTrackFringeVertexer fringeVertexer = new TwoTrackFringeVertexer();
     private TwoParticleVertexer particleVertexer = new TwoParticleVertexer();
-	private boolean _keepAllTracks = true;
+    private boolean _keepAllTracks = true;
     private EventQuality.Quality trk_quality_def = EventQuality.Quality.MEDIUM;
     private IPlotter _plotterParticleVertex;
     private IPlotter _plotterTrackVertex;
@@ -138,289 +137,290 @@
     private IHistogram1D _trkmatch_bot_plus_dx;
     private IHistogram1D _trkmatch_top_minus_dx;
     private IHistogram1D _trkmatch_bot_minus_dx;
-    
-	    
+
     private class CmpTrack implements Comparable<CmpTrack> {
+
         private Track _track;
+
         public CmpTrack(Track track) {
             _track = track;
         }
+
         @Override
         public int compareTo(CmpTrack t) {
-                int v = ((Double)(t._track.getTrackStates().get(0).getMomentum()[0]*100000 - _track.getTrackStates().get(0).getMomentum()[0]*100000)).intValue();
-                //System.out.printf("%s: _track = %f _t = %f  => %d \n",this.getClass().getSimpleName(),_track.getTrackStates().get(0).getMomentum()[0],t._track.getTrackStates().get(0).getMomentum()[0],v);
-                return v;
-        }
-    }
-    
-    
+            int v = ((Double) (t._track.getTrackStates().get(0).getMomentum()[0] * 100000 - _track.getTrackStates().get(0).getMomentum()[0] * 100000)).intValue();
+            //System.out.printf("%s: _track = %f _t = %f  => %d \n",this.getClass().getSimpleName(),_track.getTrackStates().get(0).getMomentum()[0],t._track.getTrackStates().get(0).getMomentum()[0],v);
+            return v;
+        }
+    }
+
     public void setDebug(boolean v) {
         this._debug = v;
     }
+
     public void setOutputPlotFileName(String filename) {
         outputPlotFileName = filename;
     }
+
     public void setOutputNameTextTuple(String filename) {
         this.outputNameTextTuple = filename;
     }
-    
+
     public void setHideFrame(boolean hide) {
         hideFrame = hide;
     }
-    
+
     public void setTrackCollectionName(String name) {
         trackCollectionName = name;
     }
-    
+
     public void setTargetPosition(double pos) {
         targetPosition = pos;
     }
-    
-
-    
+
     public ROOTFlatTupleDriver() {
     }
 
-    
     @Override
     public void detectorChanged(Detector detector) {
 
         createWriter();
 
-        if(printWriter==null)
+        if (printWriter == null) {
             System.out.println("printWriter is null");
-            
+        }
+
         fillTextTupleBranches();
 
         makePlots();
-       
+
         printEcalInfo(detector);
 
     }
-    
-    
+
     @Override
     public void process(EventHeader event) {
 
-        if(this._debug) 
+        if (this._debug) {
             System.out.println(this.getClass().getSimpleName() + ": processing event " + totalEvents + " which has event nr " + event.getEventNumber());
-            
-        
-        
+        }
+
         totalEvents++;
-        
+
         this.vertexer.clear();
         this.fringeVertexer.clear();
         this.particleVertexer.clear();
-        
-        
+
         List<Track> tracklist = null;
-        if(event.hasCollection(Track.class,trackCollectionName)) {        
+        if (event.hasCollection(Track.class, trackCollectionName)) {
             tracklist = event.get(Track.class, trackCollectionName);
-            if(_debug) System.out.println(this.getClass().getSimpleName() + ": Number of Tracks = " + tracklist.size() + " in event " + event.getEventNumber());
+            if (_debug) {
+                System.out.println(this.getClass().getSimpleName() + ": Number of Tracks = " + tracklist.size() + " in event " + event.getEventNumber());
+            }
         } else {
-             if(_debug)  System.out.println(this.getClass().getSimpleName() + ": No track collection in event " + event.getEventNumber());
-             return;
-        }
-        
-        
+            if (_debug) {
+                System.out.println(this.getClass().getSimpleName() + ": No track collection in event " + event.getEventNumber());
+            }
+            return;
+        }
+
         //if(tracklist.size()<2) {
-            //if(_debug) 
+        //if(_debug) 
         //        System.out.printf("%s: event %d has only %d tracks \n",this.getClass().getSimpleName(),event.getEventNumber(),tracklist.size());  
         //    System.exit(1);
         //    return;
         //}
-        
         ArrayList<CmpTrack> tracks = new ArrayList<CmpTrack>();
-        for(int i=0;i<tracklist.size();++i) {
+        for (int i = 0; i < tracklist.size(); ++i) {
             Track trk = tracklist.get(i);
-			if( _keepAllTracks) {
+            if (_keepAllTracks) {
                 tracks.add(new CmpTrack(trk));
-			}
-            else if(TrackUtils.isGoodTrack(trk, tracklist, trk_quality_def)) {
+            } else if (TrackUtils.isGoodTrack(trk, tracklist, trk_quality_def)) {
                 //System.out.printf("%s: trk momentum (%.3f,%.3f,%.3f) chi2=%.3f\n",this.getClass().getSimpleName(),trk.getTrackStates().get(0).getMomentum()[0],trk.getTrackStates().get(0).getMomentum()[1],trk.getTrackStates().get(0).getMomentum()[2],trk.getChi2());
-                if(_debug) {
+                if (_debug) {
                     int cuts = TrackUtils.passTrackSelections(trk, tracklist, trk_quality_def);
-                    System.out.printf("%s: track cuts: \n%s\n",this.getClass().getSimpleName(),EventQuality.instance().print(cuts));
-                    System.out.printf("%s: trk momentum (%.3f,%.3f,%.3f) chi2=%.3f\n",this.getClass().getSimpleName(),trk.getTrackStates().get(0).getMomentum()[0],trk.getTrackStates().get(0).getMomentum()[1],trk.getTrackStates().get(0).getMomentum()[2],trk.getChi2());
-                }
-                if(trk.getChi2()>10. && _debug) {
-                    System.out.printf("%s: trk momentum (%.3f,%.3f,%.3f) chi2=%.3f\n",this.getClass().getSimpleName(),trk.getTrackStates().get(0).getMomentum()[0],trk.getTrackStates().get(0).getMomentum()[1],trk.getTrackStates().get(0).getMomentum()[2],trk.getChi2());
+                    System.out.printf("%s: track cuts: \n%s\n", this.getClass().getSimpleName(), EventQuality.instance().print(cuts));
+                    System.out.printf("%s: trk momentum (%.3f,%.3f,%.3f) chi2=%.3f\n", this.getClass().getSimpleName(), trk.getTrackStates().get(0).getMomentum()[0], trk.getTrackStates().get(0).getMomentum()[1], trk.getTrackStates().get(0).getMomentum()[2], trk.getChi2());
+                }
+                if (trk.getChi2() > 10. && _debug) {
+                    System.out.printf("%s: trk momentum (%.3f,%.3f,%.3f) chi2=%.3f\n", this.getClass().getSimpleName(), trk.getTrackStates().get(0).getMomentum()[0], trk.getTrackStates().get(0).getMomentum()[1], trk.getTrackStates().get(0).getMomentum()[2], trk.getChi2());
                     int cuts = TrackUtils.passTrackSelections(trk, tracklist, trk_quality_def);
-                    System.out.printf("%s: track cuts: \n%s\n",this.getClass().getSimpleName(),EventQuality.instance().print(cuts));
+                    System.out.printf("%s: track cuts: \n%s\n", this.getClass().getSimpleName(), EventQuality.instance().print(cuts));
                     //System.exit(0);
                 }
-                tracks.add(new CmpTrack(trk));            
-			} else {
-               if(_debug) System.out.println(this.getClass().getSimpleName() + ": trk failed track selections (event nr " + event.getEventNumber() + ")\n" + trk.toString());
-            }
-        }
-        
+                tracks.add(new CmpTrack(trk));
+            } else {
+                if (_debug) {
+                    System.out.println(this.getClass().getSimpleName() + ": trk failed track selections (event nr " + event.getEventNumber() + ")\n" + trk.toString());
+                }
+            }
+        }
+
         Collections.sort(tracks);
-        
+
         Hep3Vector vtxPos = null;
         Hep3Vector vtxPosFringe = null;
         Hep3Vector vtxPosNonBend = null;
-        
-        if(tracks.size()>1) {
+
+        if (tracks.size() > 1) {
             Track trk1 = tracks.get(0)._track;
             Track trk2 = tracks.get(1)._track;
-            
+
             vertexer.setTracks(trk1, trk2);
-            vertexer.fitVertex();            
-			Vertex vtx = vertexer.getFittedVertex();
-			if (vtx != null) {
-				vtxPos = vertexer.getFittedVertex().getPosition();
-				fringeVertexer.setTracks(trk1, trk2);
-				fringeVertexer.fitVertex();
-				vtxPosFringe = fringeVertexer.getFittedVertex().getPosition();
-				
-				if(this._debug) {
-					System.out.printf("%s: vtxPos=%s\n", this.getClass().getSimpleName(),vtxPos.toString());
-					System.out.printf("%s: vtxPosFringe=%s\n", this.getClass().getSimpleName(),vtxPosFringe.toString());
-				}
-				
-				if(vtxPos.x() != vtxPos.x()) {
-					System.out.printf("%s: vtxPos is NaN -> Skip\n",this.getClass().getSimpleName());
-					vtxPos = null;
-				}
-				if(vtxPosFringe.x() != vtxPosFringe.x()) {
-					System.out.printf("%s: vtxPosFringe is NaN -> Skip\n",this.getClass().getSimpleName());
-					vtxPos = null;
-				}
-				
-				this._vtxpos_x.fill(vtxPos.x());
-				this._vtxpos_y.fill(vtxPos.y());
-				this._vtxpos_z.fill(vtxPos.z());            
-				
-				if(vtxPosFringe!=null) {
-					this._vtxposfr_x.fill(vtxPosFringe.x());
-					this._vtxposfr_y.fill(vtxPosFringe.y());
-					this._vtxposfr_z.fill(vtxPosFringe.z());            
-				}
-			}				
-            
+            vertexer.fitVertex();
+            Vertex vtx = vertexer.getFittedVertex();
+            if (vtx != null) {
+                vtxPos = vertexer.getFittedVertex().getPosition();
+                fringeVertexer.setTracks(trk1, trk2);
+                fringeVertexer.fitVertex();
+                vtxPosFringe = fringeVertexer.getFittedVertex().getPosition();
+
+                if (this._debug) {
+                    System.out.printf("%s: vtxPos=%s\n", this.getClass().getSimpleName(), vtxPos.toString());
+                    System.out.printf("%s: vtxPosFringe=%s\n", this.getClass().getSimpleName(), vtxPosFringe.toString());
+                }
+
+                if (vtxPos.x() != vtxPos.x()) {
+                    System.out.printf("%s: vtxPos is NaN -> Skip\n", this.getClass().getSimpleName());
+                    vtxPos = null;
+                }
+                if (vtxPosFringe.x() != vtxPosFringe.x()) {
+                    System.out.printf("%s: vtxPosFringe is NaN -> Skip\n", this.getClass().getSimpleName());
+                    vtxPos = null;
+                }
+
+                this._vtxpos_x.fill(vtxPos.x());
+                this._vtxpos_y.fill(vtxPos.y());
+                this._vtxpos_z.fill(vtxPos.z());
+
+                if (vtxPosFringe != null) {
+                    this._vtxposfr_x.fill(vtxPosFringe.x());
+                    this._vtxposfr_y.fill(vtxPosFringe.y());
+                    this._vtxposfr_z.fill(vtxPosFringe.z());
+                }
+            }
+
             boolean useFringe = false;
             StraightLineTrack[] slts = this.getSLTs(trk1, trk2, useFringe);
             double zAtCross = this.getCrossingS(trk1, trk2);
             double[] xyAtZ1 = slts[0].calculateXYAtZ(zAtCross);
             double[] xyAtZ2 = slts[1].calculateXYAtZ(zAtCross);
 
-            Hep3Vector[] vtxNonBend = {new BasicHep3Vector(xyAtZ1[0],xyAtZ1[1],zAtCross),new BasicHep3Vector(xyAtZ2[0],xyAtZ2[1],zAtCross)};
+            Hep3Vector[] vtxNonBend = {new BasicHep3Vector(xyAtZ1[0], xyAtZ1[1], zAtCross), new BasicHep3Vector(xyAtZ2[0], xyAtZ2[1], zAtCross)};
             //System.out.printf("%s: vtxNonBend=%s\n", this.getClass().getSimpleName(),vtxNonBend.toString());
-            
+
             this._vtxposnonb_x.fill(vtxNonBend[0].x());
             this._vtxposnonb_y.fill(vtxNonBend[0].y());
             this._vtxposnonb_y.fill(vtxNonBend[1].y());
-            this._vtxposnonb_dy.fill(vtxNonBend[0].y()-vtxNonBend[1].y());
+            this._vtxposnonb_dy.fill(vtxNonBend[0].y() - vtxNonBend[1].y());
             this._vtxposnonb_z.fill(vtxNonBend[0].z());
 
             this._vtxposnonb_xAtZ0.fill(slts[0].calculateXYAtZ(0.)[0]);
             this._vtxposnonb_zAtTarget.fill(slts[0].getYZAtX(this.targetPosition)[1]);
             this._vtxposnonb_angle1.fill(Math.atan(slts[0].dzdx()));
             this._vtxposnonb_angle2.fill(Math.atan(slts[1].dzdx()));
-            
+
             vtxPosNonBend = vtxNonBend[0];
 
         }
-        
-        
+
         List<Cluster> clusters = new ArrayList<Cluster>();
 
-        if(!event.hasCollection(Cluster.class, ecalClusterCollectionName)) {
-            if(_debug) {
+        if (!event.hasCollection(Cluster.class, ecalClusterCollectionName)) {
+            if (_debug) {
                 System.out.println(this.getClass().getSimpleName() + ": event doesn't have a ecal cluster collection ");
             }
         } else {
-            clusters = event.get(Cluster.class, ecalClusterCollectionName); 
-        
-            if(_debug) {
+            clusters = event.get(Cluster.class, ecalClusterCollectionName);
+
+            if (_debug) {
                 System.out.println(this.getClass().getSimpleName() + ": found " + clusters.size() + " ecal clusters " + event.getEventNumber());
             }
 
-			boolean goodRegion = false;
-			for(Cluster c : clusters) {
+            boolean goodRegion = false;
+            for (Cluster c : clusters) {
                 int iy = c.getCalorimeterHits().get(0).getIdentifierFieldValue("iy");
                 int ix = c.getCalorimeterHits().get(0).getIdentifierFieldValue("ix");
                 double E = c.getEnergy();
-				int evtnr = event.getEventNumber();
+                int evtnr = event.getEventNumber();
                 int clsize = c.getSize();
-				if( iy>0 && ix>0 && E>0.6) {
-					//printWriter.format("%d %5.5f %5d %5d %5d ",evtnr,E,ix,iy,clsize);
-					goodRegion = true;
-				}
-			}
-			if( goodRegion ) nEventsWithGoodRegionCluster++;
-
-        }
-        
+                if (iy > 0 && ix > 0 && E > 0.6) {
+                    //printWriter.format("%d %5.5f %5d %5d %5d ",evtnr,E,ix,iy,clsize);
+                    goodRegion = true;
+                }
+            }
+            if (goodRegion) {
+                nEventsWithGoodRegionCluster++;
+            }
+
+        }
+
         Hep3Vector vtxPosMC = null;
-        MCParticle electron=null;
-        MCParticle positron=null;
-        if(event.hasCollection(MCParticle.class,this.MCParticleCollectionName)) {
+        MCParticle electron = null;
+        MCParticle positron = null;
+        if (event.hasCollection(MCParticle.class, this.MCParticleCollectionName)) {
             totalMCEvents++;
-            List<MCParticle> mcparticles = event.get(MCParticle.class,this.MCParticleCollectionName);
+            List<MCParticle> mcparticles = event.get(MCParticle.class, this.MCParticleCollectionName);
             List<MCParticle> fsParticles = HPSMCParticlePlotsDriver.makeGenFSParticleList(mcparticles);
-                 
-            for(MCParticle part : fsParticles) {
-                if(ParticleTypeClassifier.isElectron(part.getPDGID())) {
-                    if(electron==null) {
+
+            for (MCParticle part : fsParticles) {
+                if (ParticleTypeClassifier.isElectron(part.getPDGID())) {
+                    if (electron == null) {
                         electron = part;
                     } else {
-                        if(part.getEnergy()>electron.getEnergy()) {
+                        if (part.getEnergy() > electron.getEnergy()) {
                             electron = part;
                         }
                     }
                 }
-                if(ParticleTypeClassifier.isPositron(part.getPDGID())) {
-                    if(positron==null) {
+                if (ParticleTypeClassifier.isPositron(part.getPDGID())) {
+                    if (positron == null) {
                         positron = part;
                     } else {
-                        if(part.getEnergy()>positron.getEnergy()) {
+                        if (part.getEnergy() > positron.getEnergy()) {
                             positron = part;
                         }
                     }
                 }
             }
 
-            if(electron!=null && positron!=null) {
+            if (electron != null && positron != null) {
                 particleVertexer.setParticle(electron, positron);
                 particleVertexer.fitVertex();
                 vtxPosMC = particleVertexer.getFittedVertex().getPosition();
-                if(this._debug) System.out.printf("%s: vtxPosMC=%s org1 %s org2 %s\n", this.getClass().getSimpleName(),vtxPosMC.toString(),electron.getOrigin().toString(),positron.getOrigin().toString());
+                if (this._debug) {
+                    System.out.printf("%s: vtxPosMC=%s org1 %s org2 %s\n", this.getClass().getSimpleName(), vtxPosMC.toString(), electron.getOrigin().toString(), positron.getOrigin().toString());
+                }
                 this._partvtxpos_x.fill(vtxPosMC.x());
                 this._partvtxpos_y.fill(vtxPosMC.y());
                 this._partvtxpos_z.fill(vtxPosMC.z());
                 totalTwoTrackMCEvents++;
             }
         }
-        
-
-        
+
         totalTwoTrackEvents++;
         try {
             this.fillTextTuple(electron, positron, tracks, vtxPosMC, vtxPos, vtxPosFringe, vtxPosNonBend, clusters, event);
         } catch (IOException ex) {
             Logger.getLogger(ROOTFlatTupleDriver.class.getName()).log(Level.SEVERE, null, ex);
         }
-        
-        if(this._debug) System.out.println(this.getClass().getSimpleName() + ": # two track events so far = "+totalTwoTrackEvents);
+
+        if (this._debug) {
+            System.out.println(this.getClass().getSimpleName() + ": # two track events so far = " + totalTwoTrackEvents);
+        }
         //System.exit(0);
-        
-    }
-
-    
-    
+
+    }
+
     @Override
     public void endOfData() {
-        
-        System.out.println(this.getClass().getSimpleName() + ": Total Number of Events = "+this.totalEvents);
-        System.out.println(this.getClass().getSimpleName() + ": Total Number of Events filling tuple = "+this.totalTwoTrackEvents);
-        System.out.println(this.getClass().getSimpleName() + ": Total Number of events with MC collection = "+this.totalMCEvents);
-        System.out.println(this.getClass().getSimpleName() + ": Total Number of events with e+e- ID'd = "+this.totalTwoTrackMCEvents);
-        System.out.println(this.getClass().getSimpleName() + ": Total Number of events with cl in good region = "+this.nEventsWithGoodRegionCluster);
-		
-        
+
+        System.out.println(this.getClass().getSimpleName() + ": Total Number of Events = " + this.totalEvents);
+        System.out.println(this.getClass().getSimpleName() + ": Total Number of Events filling tuple = " + this.totalTwoTrackEvents);
+        System.out.println(this.getClass().getSimpleName() + ": Total Number of events with MC collection = " + this.totalMCEvents);
+        System.out.println(this.getClass().getSimpleName() + ": Total Number of events with e+e- ID'd = " + this.totalTwoTrackMCEvents);
+        System.out.println(this.getClass().getSimpleName() + ": Total Number of events with cl in good region = " + this.nEventsWithGoodRegionCluster);
+
         if (!"".equals(outputPlotFileName)) {
             try {
                 aida.saveAs(outputPlotFileName);
@@ -428,87 +428,93 @@
                 Logger.getLogger(TrigRateDriver.class.getName()).log(Level.SEVERE, "Couldn't save aida plots to file " + outputPlotFileName, ex);
             }
         }
-        
-        if(printWriter==null) {
+
+        if (printWriter == null) {
             //Fill branches to text file (this is because detectorChanged() is called only if there are events to process
             createWriter();
             fillTextTupleBranches();
         }
-            
-        
-        System.out.printf("%s: printWriter close \n",this.getClass().getSimpleName());
+
+        System.out.printf("%s: printWriter close \n", this.getClass().getSimpleName());
         printWriter.close();
         try {
             fileWriter.close();
         } catch (IOException ex) {
             Logger.getLogger(ROOTFlatTupleDriver.class.getName()).log(Level.SEVERE, null, ex);
         }
-        
-                
-    }
-    
-    
-  
-    
+
+    }
+
     private boolean isFileEmpty(String fileName) {
         File f = new File(fileName);
         return f.length() == 0; //return zero also in case file doesn't exist
     }
-    
-    
+
     private void fillTextTupleBranches() {
-        
-        if(!doPrintBranchInfoLine) {
+
+        if (!doPrintBranchInfoLine) {
             throw new RuntimeException("Trying to fill tuple branches with flag being set to false?!");
         }
-        
-        String br_line = "";                 
-        br_line+="evtnr/I:";
-        br_line+="ntrks_top/I:ntrks_bot/I:ntrks100_top/I:ntrks100_bot/I:ntrks200_top/I:ntrks200_bot/I:ntrks300_top/I:ntrks300_bot/I:ntrks400_top/I:ntrks400_bot/I:ntrks500_top/I:ntrks500_bot/I:";
-        br_line+="e_px/F:e_py/F:e_pz/F:p_px/F:p_py/F:p_pz/F:";
-        
-        for(int itrk=1;itrk<=4;++itrk) {
+
+        String br_line = "";
+        br_line += "evtnr/I:";
+        br_line += "ntrks_top/I:ntrks_bot/I:ntrks100_top/I:ntrks100_bot/I:ntrks200_top/I:ntrks200_bot/I:ntrks300_top/I:ntrks300_bot/I:ntrks400_top/I:ntrks400_bot/I:ntrks500_top/I:ntrks500_bot/I:";
+        br_line += "e_px/F:e_py/F:e_pz/F:p_px/F:p_py/F:p_pz/F:";
+
+        for (int itrk = 1; itrk <= 4; ++itrk) {
             String trk_str = String.format("trk%d", itrk);
 
-            br_line+=""+trk_str+"_d0/F:"+trk_str+"_phi0/F:"+trk_str+"_R/F:"+trk_str+"_z0/F:"+trk_str+"_slope/F:";
-            br_line+=""+trk_str+"_q/I:"+trk_str+"_chi2/F:"+trk_str+"_px/F:"+trk_str+"_py/F:"+trk_str+"_pz/F:"+trk_str+"_nhits/I:";
-            for(int iLayer=1;iLayer<=5;++iLayer) br_line+=""+trk_str+"_hit"+iLayer+"_x/F:"+""+trk_str+"_hit"+iLayer+"_y/F:"+""+trk_str+"_hit"+iLayer+"_z/F:";
-            for(int iLayer=1;iLayer<=5;++iLayer) {
-                br_line+=""+trk_str+"_res"+iLayer+"_y/F:"+""+trk_str+"_res"+iLayer+"_z/F:";
-                br_line+=""+trk_str+"_eres"+iLayer+"_y/F:"+""+trk_str+"_eres"+iLayer+"_z/F:";
-                br_line+=""+trk_str+"_drdphi"+iLayer+"/F:"+""+trk_str+"_msdrphi"+iLayer+"/F:";
-                br_line+=""+trk_str+"_dz"+iLayer+"/F:"+""+trk_str+"_msdz"+iLayer+"/F:";
+            br_line += "" + trk_str + "_d0/F:" + trk_str + "_phi0/F:" + trk_str + "_R/F:" + trk_str + "_z0/F:" + trk_str + "_slope/F:";
+            br_line += "" + trk_str + "_q/I:" + trk_str + "_chi2/F:" + trk_str + "_px/F:" + trk_str + "_py/F:" + trk_str + "_pz/F:" + trk_str + "_nhits/I:";
+            for (int iLayer = 1; iLayer <= 5; ++iLayer) {
+                br_line += "" + trk_str + "_hit" + iLayer + "_x/F:" + "" + trk_str + "_hit" + iLayer + "_y/F:" + "" + trk_str + "_hit" + iLayer + "_z/F:";
+            }
+            for (int iLayer = 1; iLayer <= 5; ++iLayer) {
+                br_line += "" + trk_str + "_res" + iLayer + "_y/F:" + "" + trk_str + "_res" + iLayer + "_z/F:";
+                br_line += "" + trk_str + "_eres" + iLayer + "_y/F:" + "" + trk_str + "_eres" + iLayer + "_z/F:";
+                br_line += "" + trk_str + "_drdphi" + iLayer + "/F:" + "" + trk_str + "_msdrphi" + iLayer + "/F:";
+                br_line += "" + trk_str + "_dz" + iLayer + "/F:" + "" + trk_str + "_msdz" + iLayer + "/F:";
                 //br_line+=""+trk_str+"_ures"+iLayer+"/F:"+""+trk_str+"_ureserr"+iLayer+"/F:";
             }
-            for(int iLayer=1;iLayer<=10;++iLayer) br_line+=""+trk_str+"_strip"+iLayer+"_u/F:"+""+trk_str+"_strip"+iLayer+"_time/F:"+""+trk_str+"_strip"+iLayer+"_E/F:";
-            
-            br_line+=""+trk_str+"_conv_y/F:"+trk_str+"_conv_z/F:";
-            br_line+=""+trk_str+"_fr_conv_x/F:"+trk_str+"_fr_conv_y/F:"+trk_str+"_fr_conv_z/F:";
-            br_line+=""+trk_str+"_target_y/F:"+trk_str+"_target_z/F:";
-            br_line+=""+trk_str+"_fr_target_x/F:"+trk_str+"_fr_target_y/F:"+trk_str+"_fr_target_z/F:";
+            for (int iLayer = 1; iLayer <= 10; ++iLayer) {
+                br_line += "" + trk_str + "_strip" + iLayer + "_u/F:" + "" + trk_str + "_strip" + iLayer + "_time/F:" + "" + trk_str + "_strip" + iLayer + "_E/F:";
+            }
+
+            br_line += "" + trk_str + "_conv_y/F:" + trk_str + "_conv_z/F:";
+            br_line += "" + trk_str + "_fr_conv_x/F:" + trk_str + "_fr_conv_y/F:" + trk_str + "_fr_conv_z/F:";
+            br_line += "" + trk_str + "_target_y/F:" + trk_str + "_target_z/F:";
+            br_line += "" + trk_str + "_fr_target_x/F:" + trk_str + "_fr_target_y/F:" + trk_str + "_fr_target_z/F:";
             //br_line+=""+trk_str+"_ecal_y/F:"+trk_str+"_ecal_z/F:";
-            br_line+=""+trk_str+"_ecal_y/F:"+trk_str+"_ecal_z/F:"+trk_str+"_fr_ecal_x/F:"+trk_str+"_fr_ecal_y/F:"+trk_str+"_fr_ecal_z/F:";
-            br_line+=""+trk_str+"_ecal_sm_y/F:"+trk_str+"_ecal_sm_z/F:"+trk_str+"_fr_ecal_sm_x/F:"+trk_str+"_fr_ecal_sm_y/F:"+trk_str+"_fr_ecal_sm_z/F:";
+            br_line += "" + trk_str + "_ecal_y/F:" + trk_str + "_ecal_z/F:" + trk_str + "_fr_ecal_x/F:" + trk_str + "_fr_ecal_y/F:" + trk_str + "_fr_ecal_z/F:";
+            br_line += "" + trk_str + "_ecal_sm_y/F:" + trk_str + "_ecal_sm_z/F:" + trk_str + "_fr_ecal_sm_x/F:" + trk_str + "_fr_ecal_sm_y/F:" + trk_str + "_fr_ecal_sm_z/F:";
             //br_line+=""+trk_str+"_fr_ecal_x/F:"+trk_str+"_fr_ecal_y/F:"+trk_str+"_fr_ecal_z/F:";
             //br_line+=""+trk_str+"_fr_ecal_x/F:";
-            
+
         }
         //
-        for(int iLayer=1;iLayer<=10;++iLayer) br_line+="top_strip"+iLayer+"_n/F:";
-        for(int iLayer=1;iLayer<=10;++iLayer) br_line+="bot_strip"+iLayer+"_n/F:";
-        for(int iLayer=1;iLayer<=10;iLayer+=2) br_line+="top_stereo"+iLayer+"_n/F:";
-        for(int iLayer=1;iLayer<=10;iLayer+=2) br_line+="bot_stereo"+iLayer+"_n/F:";
-        br_line+="vtx_truth_x/F:vtx_truth_y/F:vtx_truth_z/F:";
-        br_line+="vtx_x/F:vtx_y/F:vtx_z/F:";
-        br_line+="vtx_fr_x/F:vtx_fr_y/F:vtx_fr_z/F:";
-        br_line+="vtx_nonbend_x/F:vtx_nonbend_y/F:vtx_nonbend_z/F:";
-        br_line+="cl1_E/F:cl1_ix/I:cl1_iy/I:cl1_x/F:cl1_y/F:cl1_z/F:cl1_n/I:";
-        br_line+="cl2_E/F:cl2_ix/I:cl2_iy/I:cl2_x/F:cl2_y/F:cl2_z/F:cl2_n/I:";
-        br_line+="cl3_E/F:cl3_ix/I:cl3_iy/I:cl3_x/F:cl3_y/F:cl3_z/F:cl3_n/I:";
-        br_line+="ncl_top/I:ncl_bot/I:";
-        br_line+="trig_top/I:trig_bot/I";
-        
-        if(printWriter==null) {
+        for (int iLayer = 1; iLayer <= 10; ++iLayer) {
+            br_line += "top_strip" + iLayer + "_n/F:";
+        }
+        for (int iLayer = 1; iLayer <= 10; ++iLayer) {
+            br_line += "bot_strip" + iLayer + "_n/F:";
+        }
+        for (int iLayer = 1; iLayer <= 10; iLayer += 2) {
+            br_line += "top_stereo" + iLayer + "_n/F:";
+        }
+        for (int iLayer = 1; iLayer <= 10; iLayer += 2) {
+            br_line += "bot_stereo" + iLayer + "_n/F:";
+        }
+        br_line += "vtx_truth_x/F:vtx_truth_y/F:vtx_truth_z/F:";
+        br_line += "vtx_x/F:vtx_y/F:vtx_z/F:";
+        br_line += "vtx_fr_x/F:vtx_fr_y/F:vtx_fr_z/F:";
+        br_line += "vtx_nonbend_x/F:vtx_nonbend_y/F:vtx_nonbend_z/F:";
+        br_line += "cl1_E/F:cl1_ix/I:cl1_iy/I:cl1_x/F:cl1_y/F:cl1_z/F:cl1_n/I:";
+        br_line += "cl2_E/F:cl2_ix/I:cl2_iy/I:cl2_x/F:cl2_y/F:cl2_z/F:cl2_n/I:";
+        br_line += "cl3_E/F:cl3_ix/I:cl3_iy/I:cl3_x/F:cl3_y/F:cl3_z/F:cl3_n/I:";
+        br_line += "ncl_top/I:ncl_bot/I:";
+        br_line += "trig_top/I:trig_bot/I";
+
+        if (printWriter == null) {
             System.out.println("hmm 1");
         }
         printWriter.println(br_line);
@@ -516,178 +522,196 @@
         doPrintBranchInfoLine = false;
 
     }
-    
-    
+
     /**
      * Find the closest ECal cluster in deltaR. Return null if no match
+     *
      * @param trk
      * @param clusters
      * @return clostest cluster.
      */
-
     private Cluster findEcalCluster(Track trk, List<Cluster> clusters) {
-    	Cluster matched_cluster = null;
-    	double drMin = 9999999.9;
-    	double drMax = 9999999.9;
-    	double dr;
-    	Hep3Vector pos_cl,pos_trk;
-    	for(Cluster cluster : clusters) {
-    		pos_cl = new BasicHep3Vector(cluster.getPosition());
-    		pos_trk = TrackUtils.extrapolateTrack(trk,pos_cl.z());
-    		dr = VecOp.sub(pos_cl, pos_trk).magnitude();
-    		if( dr < drMax) {
-    			if( dr < drMin ) {
-    				matched_cluster = cluster;
-    				drMin = dr;
-    			}
-    		}
-    	}
-    	return matched_cluster;
-    }
-    
+        Cluster matched_cluster = null;
+        double drMin = 9999999.9;
+        double drMax = 9999999.9;
+        double dr;
+        Hep3Vector pos_cl, pos_trk;
+        for (Cluster cluster : clusters) {
+            pos_cl = new BasicHep3Vector(cluster.getPosition());
+            pos_trk = TrackUtils.extrapolateTrack(trk, pos_cl.z());
+            dr = VecOp.sub(pos_cl, pos_trk).magnitude();
+            if (dr < drMax) {
+                if (dr < drMin) {
+                    matched_cluster = cluster;
+                    drMin = dr;
+                }
+            }
+        }
+        return matched_cluster;
+    }
+
     private void fillTextTuple(MCParticle e, MCParticle p, List<CmpTrack> tracks, Hep3Vector vtxPosParticle, Hep3Vector vtxPos, Hep3Vector vtxPosFr, Hep3Vector vtxPosNonBend, List<Cluster> clusters, EventHeader event) throws IOException {
-        if(doPrintBranchInfoLine) {
+        if (doPrintBranchInfoLine) {
             throw new RuntimeException("Need to fill tuple branches first!?");
         }
-        
+
         //Event info
-        printWriter.format("%5d ",event.getEventNumber());
-        if(tracks.size()>0) {
-        for(int icut=0;icut<=5;++icut) {
-            int ntrks[] = getNtracks(tracks,icut*0.1);
-            printWriter.format("%5d %5d ",ntrks[0],ntrks[1]);
-            this._ntrks_px.fill(0.1*icut, ntrks[0]+ntrks[1]);
-        }
+        printWriter.format("%5d ", event.getEventNumber());
+        if (tracks.size() > 0) {
+            for (int icut = 0; icut <= 5; ++icut) {
+                int ntrks[] = getNtracks(tracks, icut * 0.1);
+                printWriter.format("%5d %5d ", ntrks[0], ntrks[1]);
+                this._ntrks_px.fill(0.1 * icut, ntrks[0] + ntrks[1]);
+            }
         } else {
-            printWriter.format("%5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d ", -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999 );
-        }
-        
+            printWriter.format("%5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d ", -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999, -9999999);
+        }
+
         //Truth
-        if(e!=null && p!=null) printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f %5.5f ", e.getPX(),e.getPY(),e.getPZ(), p.getPX(),p.getPY(),p.getPZ() );
-        else printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999., -9999999., -9999999., -9999999. );
-        
-        
-        for (int itrk=0;itrk<4;itrk++) {
+        if (e != null && p != null) {
+            printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f %5.5f ", e.getPX(), e.getPY(), e.getPZ(), p.getPX(), p.getPY(), p.getPZ());
+        } else {
+            printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999., -9999999., -9999999., -9999999.);
+        }
+
+        for (int itrk = 0; itrk < 4; itrk++) {
             Track trk1 = null;
-            if(tracks.size()>itrk) trk1 = tracks.get(itrk)._track;
-           
-            if(trk1!=null) {
+            if (tracks.size() > itrk) {
+                trk1 = tracks.get(itrk)._track;
+            }
+
+            if (trk1 != null) {
                 SeedTrack st1 = (SeedTrack) trk1;
-                HelicalTrackFit helix1 = st1.getSeedCandidate().getHelix();     
+                HelicalTrackFit helix1 = st1.getSeedCandidate().getHelix();
                 List<TrackerHit> hitsOnTrack1 = trk1.getTrackerHits();
-                HashMap<Integer,HelicalTrackHit> hits1 = getHitMap(hitsOnTrack1,helix1);
-
-                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",helix1.dca(),helix1.phi0(),helix1.R(),helix1.z0(),helix1.slope());
-                printWriter.format("%5d %5.5f %5.5f %5.5f %5.5f %5d ",trk1.getCharge(),trk1.getChi2(), trk1.getTrackStates().get(0).getMomentum()[0],trk1.getTrackStates().get(0).getMomentum()[1],trk1.getTrackStates().get(0).getMomentum()[2],hitsOnTrack1.size());
+                HashMap<Integer, HelicalTrackHit> hits1 = getHitMap(hitsOnTrack1, helix1);
+
+                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", helix1.dca(), helix1.phi0(), helix1.R(), helix1.z0(), helix1.slope());
+                printWriter.format("%5d %5.5f %5.5f %5.5f %5.5f %5d ", trk1.getCharge(), trk1.getChi2(), trk1.getTrackStates().get(0).getMomentum()[0], trk1.getTrackStates().get(0).getMomentum()[1], trk1.getTrackStates().get(0).getMomentum()[2], hitsOnTrack1.size());
                 // stupid but I want to keep one line per event so default in case there is not hits in all layers
-                for(int iLayer=0;iLayer<5;++iLayer) {
-                    HelicalTrackHit hitOnLayer = hits1.get(iLayer*2+1);// = this.getHitOnLayer(iLayer, hitsOnTrack);
-                    if (hitOnLayer != null) printWriter.format("%5.5f %5.5f %5.5f ", hitOnLayer.getPosition()[0],hitOnLayer.getPosition()[1],hitOnLayer.getPosition()[2]);
-                    else printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9);
+                for (int iLayer = 0; iLayer < 5; ++iLayer) {
+                    HelicalTrackHit hitOnLayer = hits1.get(iLayer * 2 + 1);// = this.getHitOnLayer(iLayer, hitsOnTrack);
+                    if (hitOnLayer != null) {
+                        printWriter.format("%5.5f %5.5f %5.5f ", hitOnLayer.getPosition()[0], hitOnLayer.getPosition()[1], hitOnLayer.getPosition()[2]);
+                    } else {
+                        printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9);
+                    }
                 }
 
                 //Get the helix for residual calculation
-                for(int iLayer=0;iLayer<5;++iLayer) {
-                    HelicalTrackHit hitOnLayer = hits1.get(iLayer*2+1);// = this.getHitOnLayer(iLayer, hitsOnTrack);
+                for (int iLayer = 0; iLayer < 5; ++iLayer) {
+                    HelicalTrackHit hitOnLayer = hits1.get(iLayer * 2 + 1);// = this.getHitOnLayer(iLayer, hitsOnTrack);
                     if (hitOnLayer != null) {
                         //printWriter.format("\n%s\n","X11");
-                        Map<String,Double> res = TrackUtils.calculateTrackHitResidual(hitOnLayer, helix1, true);
-                        if( !res.isEmpty() ) {
-                        	printWriter.format("%5.5f %5.5f ",res.get("resy"),res.get("resz"));
-                        	printWriter.format("%5.5f %5.5f ",res.get("erry"),res.get("errz"));
-                        	printWriter.format("%5.5f %5.5f ", res.get("drphi"),res.get("msdrphi"));
-                        	printWriter.format("%5.5f %5.5f ", res.get("dz_res"),res.get("msdz"));
+                        Map<String, Double> res = TrackUtils.calculateTrackHitResidual(hitOnLayer, helix1, true);
+                        if (!res.isEmpty()) {
+                            printWriter.format("%5.5f %5.5f ", res.get("resy"), res.get("resz"));
+                            printWriter.format("%5.5f %5.5f ", res.get("erry"), res.get("errz"));
+                            printWriter.format("%5.5f %5.5f ", res.get("drphi"), res.get("msdrphi"));
+                            printWriter.format("%5.5f %5.5f ", res.get("dz_res"), res.get("msdz"));
                         } else {
                             printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
                             printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
                             printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
-                            printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);                        	
+                            printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
                         }
-                    }
-                    else {
+                    } else {
                         printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
                         printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
                         printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
                         printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
                     }
                 }
-                
-                HashMap<Integer,List<HelicalTrackStrip>> striphits1 = this.getStripHitsMap(hitsOnTrack1);        
-                for(int iLayer=1;iLayer<=10;++iLayer) {
-                    HelicalTrackStrip strip=null;
-                    if(striphits1.containsKey(iLayer)) strip = striphits1.get(iLayer).get(0);
-                    if(strip!=null) {
-                        printWriter.format("%5.5f %5.5f %5.5f ", strip.umeas(),strip.time(),strip.dEdx()/DopedSilicon.ENERGY_EHPAIR);
+
+                HashMap<Integer, List<HelicalTrackStrip>> striphits1 = this.getStripHitsMap(hitsOnTrack1);
+                for (int iLayer = 1; iLayer <= 10; ++iLayer) {
+                    HelicalTrackStrip strip = null;
+                    if (striphits1.containsKey(iLayer)) {
+                        strip = striphits1.get(iLayer).get(0);
                     }
-                    else {
+                    if (strip != null) {
+                        printWriter.format("%5.5f %5.5f %5.5f ", strip.umeas(), strip.time(), strip.dEdx() / DopedSilicon.ENERGY_EHPAIR);
+                    } else {
                         printWriter.format("%5.5f %5.5f %5.5f ", -99999999.9, -99999999.9, -99999999.9);
                     }
                 }
 
                 //Track at converter
-                Hep3Vector posAtConverter = TrackUtils.extrapolateTrack(trk1,BeamlineConstants.HARP_POSITION_TESTRUN);
-                if(beamlinePosOk(posAtConverter))  printWriter.format("%5.5f %5.5f ", posAtConverter.x(),posAtConverter.y()); //note rotation from JLab->tracking
-                else printWriter.format("%5.5f %5.5f ", -9999999.9,-9999999.9);
+                Hep3Vector posAtConverter = TrackUtils.extrapolateTrack(trk1, BeamlineConstants.HARP_POSITION_TESTRUN);
+                if (beamlinePosOk(posAtConverter)) {
+                    printWriter.format("%5.5f %5.5f ", posAtConverter.x(), posAtConverter.y()); //note rotation from JLab->tracking
+                } else {
+                    printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
+                }
                 HPSTrack hpstrk1 = new HPSTrack(helix1);
                 Hep3Vector posAtConverterFringe1 = hpstrk1.getPositionAtZMap(100., BeamlineConstants.HARP_POSITION_TESTRUN, 5.0)[0];
-                if (beamlinePosOk(posAtConverterFringe1)) printWriter.format("%5.5f %5.5f %5.5f ", posAtConverterFringe1.z(),posAtConverterFringe1.x(),posAtConverterFringe1.y()); //note rotation from JLab->tracking
-                else printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9,-9999999.9,-9999999.9);
-                
-                Hep3Vector posAtNomTarget1 = TrackUtils.extrapolateTrack(trk1,0);
-                if(beamlinePosOk(posAtNomTarget1)) printWriter.format("%5.5f %5.5f ", posAtNomTarget1.x(),posAtNomTarget1.y()); //note rotation from JLab->tracking
-                else printWriter.format("%5.5f %5.5f ", -9999999.9,-9999999.9);
+                if (beamlinePosOk(posAtConverterFringe1)) {
+                    printWriter.format("%5.5f %5.5f %5.5f ", posAtConverterFringe1.z(), posAtConverterFringe1.x(), posAtConverterFringe1.y()); //note rotation from JLab->tracking
+                } else {
+                    printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9);
+                }
+
+                Hep3Vector posAtNomTarget1 = TrackUtils.extrapolateTrack(trk1, 0);
+                if (beamlinePosOk(posAtNomTarget1)) {
+                    printWriter.format("%5.5f %5.5f ", posAtNomTarget1.x(), posAtNomTarget1.y()); //note rotation from JLab->tracking
+                } else {
+                    printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
+                }
 
                 Hep3Vector posAtNomTargetFringe1 = hpstrk1.getPositionAtZMap(100., 0.0, 5.0)[0];
-                if (beamlinePosOk(posAtNomTargetFringe1)) printWriter.format("%5.5f %5.5f %5.5f ", posAtNomTargetFringe1.z(),posAtNomTargetFringe1.x(),posAtNomTargetFringe1.y()); //note rotation from JLab->tracking
-                else printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9,-9999999.9,-9999999.9);
-
-                Hep3Vector posAtECal = TrackUtils.extrapolateTrack(trk1,BeamlineConstants.ECAL_FACE_TESTRUN);  
+                if (beamlinePosOk(posAtNomTargetFringe1)) {
+                    printWriter.format("%5.5f %5.5f %5.5f ", posAtNomTargetFringe1.z(), posAtNomTargetFringe1.x(), posAtNomTargetFringe1.y()); //note rotation from JLab->tracking
+                } else {
+                    printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9);
+                }
+
+                Hep3Vector posAtECal = TrackUtils.extrapolateTrack(trk1, BeamlineConstants.ECAL_FACE_TESTRUN);
                 Hep3Vector posAtECalFringe1 = hpstrk1.getPositionAtZMap(BeamlineConstants.DIPOLE_EDGE_TESTRUN - 100, BeamlineConstants.ECAL_FACE_TESTRUN, 5.0, false)[0];
-                if(beamlinePosOk(posAtECal)) {
-                	//printWriter.format("%5.5f %5.5f ",posAtECal.x(),posAtECal.y()); //note rotation from JLab->tracking
-                	printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",posAtECal.x(),posAtECal.y(),posAtECalFringe1.z(),posAtECalFringe1.x(),posAtECalFringe1.y()); //note rotation from JLab->tracking
-                } 
-                else printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9,-9999999.9,-9999999.9);
-                
+                if (beamlinePosOk(posAtECal)) {
+                    //printWriter.format("%5.5f %5.5f ",posAtECal.x(),posAtECal.y()); //note rotation from JLab->tracking
+                    printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", posAtECal.x(), posAtECal.y(), posAtECalFringe1.z(), posAtECalFringe1.x(), posAtECalFringe1.y()); //note rotation from JLab->tracking
+                } else {
+                    printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9, -9999999.9, -9999999.9);
+                }
+
                 Cluster matched_cluster = findEcalCluster(trk1, clusters);
-                if(matched_cluster !=null) {
-                	double[] pos_cluster = matched_cluster.getPosition();
-                	posAtECal = TrackUtils.extrapolateTrack(trk1,pos_cluster[2]);
-                	if(beamlinePosOk(posAtECal)) {
-                		posAtECalFringe1 = hpstrk1.getPositionAtZMap(BeamlineConstants.DIPOLE_EDGE_TESTRUN - 100, pos_cluster[2], 5.0, false)[0];
-                		printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",posAtECal.x(),posAtECal.y(),posAtECalFringe1.z(),posAtECalFringe1.x(),posAtECalFringe1.y()); //note rotation from JLab->tracking
-						if(_debug) {
-							System.out.printf("clpos:%5.5f %5.5f %5.5f  trk: %5.5f %5.5f %5.5f %5.5f %5.5f \n",pos_cluster[0],pos_cluster[1],pos_cluster[2],posAtECal.x(),posAtECal.y(),posAtECalFringe1.z(),posAtECalFringe1.x(),posAtECalFringe1.y()); //note rotation from JLab->tracking
-
-							if(clusters.size()==1) {
-								if(pos_cluster[1] >0) {
-									_trkmatch_top_dy.fill(pos_cluster[1] - posAtECal.y());
-									if(trk1.getCharge()>0) {
-										_trkmatch_top_plus_dx.fill(pos_cluster[0] - posAtECal.x());
-									} else {
-										_trkmatch_top_minus_dx.fill(pos_cluster[0] - posAtECal.x());
-									}
-								} else {
-									_trkmatch_bot_dy.fill(pos_cluster[1] - posAtECal.y());
-									if(trk1.getCharge()>0) {
-										_trkmatch_bot_plus_dx.fill(pos_cluster[0] - posAtECal.x());
-									} else {
-										_trkmatch_bot_minus_dx.fill(pos_cluster[0] - posAtECal.x());
-									}
-								}
-							}
-						}
-                	} 
-                	else printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9,-9999999.9,-9999999.9);
-                } 
-                else printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9,-9999999.9,-9999999.9);
-                
-                
-
-                
-                if(beamlinePosOk(posAtConverter)) {
-                    if(TrackUtils.isTopTrack(trk1, 4)) {
-                        if(trk1.getCharge()>0) {
+                if (matched_cluster != null) {
+                    double[] pos_cluster = matched_cluster.getPosition();
+                    posAtECal = TrackUtils.extrapolateTrack(trk1, pos_cluster[2]);
+                    if (beamlinePosOk(posAtECal)) {
+                        posAtECalFringe1 = hpstrk1.getPositionAtZMap(BeamlineConstants.DIPOLE_EDGE_TESTRUN - 100, pos_cluster[2], 5.0, false)[0];
+                        printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", posAtECal.x(), posAtECal.y(), posAtECalFringe1.z(), posAtECalFringe1.x(), posAtECalFringe1.y()); //note rotation from JLab->tracking
+                        if (_debug) {
+                            System.out.printf("clpos:%5.5f %5.5f %5.5f  trk: %5.5f %5.5f %5.5f %5.5f %5.5f \n", pos_cluster[0], pos_cluster[1], pos_cluster[2], posAtECal.x(), posAtECal.y(), posAtECalFringe1.z(), posAtECalFringe1.x(), posAtECalFringe1.y()); //note rotation from JLab->tracking
+
+                            if (clusters.size() == 1) {
+                                if (pos_cluster[1] > 0) {
+                                    _trkmatch_top_dy.fill(pos_cluster[1] - posAtECal.y());
+                                    if (trk1.getCharge() > 0) {
+                                        _trkmatch_top_plus_dx.fill(pos_cluster[0] - posAtECal.x());
+                                    } else {
+                                        _trkmatch_top_minus_dx.fill(pos_cluster[0] - posAtECal.x());
+                                    }
+                                } else {
+                                    _trkmatch_bot_dy.fill(pos_cluster[1] - posAtECal.y());
+                                    if (trk1.getCharge() > 0) {
+                                        _trkmatch_bot_plus_dx.fill(pos_cluster[0] - posAtECal.x());
+                                    } else {
+                                        _trkmatch_bot_minus_dx.fill(pos_cluster[0] - posAtECal.x());
+                                    }
+                                }
+                            }
+                        }
+                    } else {
+                        printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9, -9999999.9, -9999999.9);
+                    }
+                } else {
+                    printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9, -9999999.9, -9999999.9);
+                }
+
+                if (beamlinePosOk(posAtConverter)) {
+                    if (TrackUtils.isTopTrack(trk1, 4)) {
+                        if (trk1.getCharge() > 0) {
                             this._trk_y_at_conv_top_pos.fill(posAtConverter.x());
                             this._trk_z_at_conv_top_pos.fill(posAtConverter.y());
                         } else {
@@ -695,7 +719,7 @@
                             this._trk_z_at_conv_top_neg.fill(posAtConverter.y());
                         }
                     } else {
-                        if(trk1.getCharge()>0) {
+                        if (trk1.getCharge() > 0) {
                             this._trk_y_at_conv_bot_pos.fill(posAtConverter.x());
                             this._trk_z_at_conv_bot_pos.fill(posAtConverter.y());
                         } else {
@@ -704,9 +728,9 @@
                         }
                     }
                 }
-                if(beamlinePosOk(posAtConverterFringe1)) {
-                    if(TrackUtils.isTopTrack(trk1, 4)) {
-                        if(trk1.getCharge()>0) {
+                if (beamlinePosOk(posAtConverterFringe1)) {
+                    if (TrackUtils.isTopTrack(trk1, 4)) {
+                        if (trk1.getCharge() > 0) {
                             this._trk_y_at_conv_top_pos_fr.fill(posAtConverterFringe1.x());
                             this._trk_z_at_conv_top_pos_fr.fill(posAtConverterFringe1.y());
                         } else {
@@ -714,7 +738,7 @@
                             this._trk_z_at_conv_top_neg_fr.fill(posAtConverterFringe1.y());
                         }
                     } else {
-                        if(trk1.getCharge()>0) {
+                        if (trk1.getCharge() > 0) {
                             this._trk_y_at_conv_bot_pos_fr.fill(posAtConverterFringe1.x());
                             this._trk_z_at_conv_bot_pos_fr.fill(posAtConverterFringe1.y());
                         } else {
@@ -723,98 +747,108 @@
                         }
                     }
                 }
-                
-                
-                
-            }
-            else {
-
-                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9,-9999999.9,-9999999.9);
-                printWriter.format("%5d %5.5f %5.5f %5.5f %5.5f %5d ",-9999999,-9999999.9, -9999999.9,-9999999.9,-9999999.9,-9999999);
-                for(int iLayer=0;iLayer<5;++iLayer) {
+
+            } else {
+
+                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9, -9999999.9, -9999999.9);
+                printWriter.format("%5d %5.5f %5.5f %5.5f %5.5f %5d ", -9999999, -9999999.9, -9999999.9, -9999999.9, -9999999.9, -9999999);
+                for (int iLayer = 0; iLayer < 5; ++iLayer) {
                     printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9);
                 }
-                for(int iLayer=0;iLayer<5;++iLayer) {
-                        printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
-                        printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
-                        printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
-                        printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
-                }
-                for(int iLayer=1;iLayer<=10;++iLayer) {
+                for (int iLayer = 0; iLayer < 5; ++iLayer) {
+                    printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
+                    printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
+                    printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
+                    printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9);
+                }
+                for (int iLayer = 1; iLayer <= 10; ++iLayer) {
                     printWriter.format("%5.5f %5.5f %5.5f ", -99999999.9, -99999999.9, -99999999.9);
                 }
-                
-                printWriter.format("%5.5f %5.5f ",-9999999.9,-9999999.9); //note rotation from JLab->tracking
-                printWriter.format("%5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9); //note rotation from JLab->tracking
-                printWriter.format("%5.5f %5.5f ",-9999999.9,-9999999.9); //note rotation from JLab->tracking
-                printWriter.format("%5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9); //note rotation from JLab->tracking
-                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9,-9999999.9,-9999999.9); //note rotation from JLab->tracking
-                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ",-9999999.9,-9999999.9,-9999999.9,-9999999.9,-9999999.9); //note rotation from JLab->tracking
-                
+
+                printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9); //note rotation from JLab->tracking
+                printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9); //note rotation from JLab->tracking
+                printWriter.format("%5.5f %5.5f ", -9999999.9, -9999999.9); //note rotation from JLab->tracking
+                printWriter.format("%5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9); //note rotation from JLab->tracking
+                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9, -9999999.9, -9999999.9); //note rotation from JLab->tracking
+                printWriter.format("%5.5f %5.5f %5.5f %5.5f %5.5f ", -9999999.9, -9999999.9, -9999999.9, -9999999.9, -9999999.9); //note rotation from JLab->tracking
+
             }
         }
         //printWriter.format("\n%s\n","X1");
 
-
-
         //printWriter.format("\n%s\n","X2");
-
-
-        
-
-        HashMap<Integer,List<SiTrackerHitStrip1D>> allstriphits = this.getAllStripHitsMap(event,true);
+        HashMap<Integer, List<SiTrackerHitStrip1D>> allstriphits = this.getAllStripHitsMap(event, true);
         //System.out.printf("%s: %d strip hits in event\n",this.getClass().getSimpleName(),allstriphits.size());
-        for(int iLayer=1;iLayer<=10;++iLayer) {
-            if(allstriphits.containsKey(iLayer)) {
+        for (int iLayer = 1; iLayer <= 10; ++iLayer) {
+            if (allstriphits.containsKey(iLayer)) {
                 printWriter.format("%5d ", allstriphits.get(iLayer).size());
                 //System.out.printf("%s: layer %d has %d strip hits\n",this.getClass().getSimpleName(),iLayer,allstriphits.get(iLayer).size());
-            }
-            else {
+            } else {
                 printWriter.format("%5d ", -99999999);
                 //System.out.printf("%s: layer %d has 0 strip hits\n",this.getClass().getSimpleName(),iLayer);
             }
         }
-        allstriphits = this.getAllStripHitsMap(event,false);
-        for(int iLayer=1;iLayer<=10;++iLayer) {
-            if(allstriphits.containsKey(iLayer)) printWriter.format("%5d ", allstriphits.get(iLayer).size());
-            else printWriter.format("%5d ", -99999999);
+        allstriphits = this.getAllStripHitsMap(event, false);
+        for (int iLayer = 1; iLayer <= 10; ++iLayer) {
+            if (allstriphits.containsKey(iLayer)) {
+                printWriter.format("%5d ", allstriphits.get(iLayer).size());
+            } else {
+                printWriter.format("%5d ", -99999999);
+            }
         }
 
         List<HelicalTrackHit> stereoHits = new ArrayList<HelicalTrackHit>();
-        if(event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)) {
+        if (event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)) {
             stereoHits = event.get(HelicalTrackHit.class, stereoHitCollectionName);
-        } 
-
-       
-        HashMap<Integer,List<HelicalTrackHit>> allstereohits = getAllStereoHitsMap(stereoHits,true);
-        for(int iLayer=1;iLayer<=10;iLayer+=2) {
-            if(allstereohits.containsKey(iLayer)) printWriter.format("%5d ", allstereohits.get(iLayer).size());
-            else printWriter.format("%5d ", -99999999);
-        }
-        allstereohits = getAllStereoHitsMap(stereoHits,false);
-        for(int iLayer=1;iLayer<=10;iLayer+=2) {
-            if(allstereohits.containsKey(iLayer)) printWriter.format("%5d ", allstereohits.get(iLayer).size());
-            else printWriter.format("%5d ", -99999999);
+        }
+
+        HashMap<Integer, List<HelicalTrackHit>> allstereohits = getAllStereoHitsMap(stereoHits, true);
+        for (int iLayer = 1; iLayer <= 10; iLayer += 2) {
+            if (allstereohits.containsKey(iLayer)) {
+                printWriter.format("%5d ", allstereohits.get(iLayer).size());
+            } else {
+                printWriter.format("%5d ", -99999999);
+            }
+        }
+        allstereohits = getAllStereoHitsMap(stereoHits, false);
+        for (int iLayer = 1; iLayer <= 10; iLayer += 2) {
+            if (allstereohits.containsKey(iLayer)) {
+                printWriter.format("%5d ", allstereohits.get(iLayer).size());
+            } else {
+                printWriter.format("%5d ", -99999999);
+            }
         }
         //printWriter.format("\n%s\n","X4");
-        
+
         //Particle vtx
-        if(vtxPosParticle!=null) printWriter.format("%5.5f %5.5f %5.5f ", vtxPosParticle.x(),vtxPosParticle.y(),vtxPosParticle.z() );
-        else printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999. );
+        if (vtxPosParticle != null) {
+            printWriter.format("%5.5f %5.5f %5.5f ", vtxPosParticle.x(), vtxPosParticle.y(), vtxPosParticle.z());
+        } else {
+            printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999.);
+        }
         //Track vtx
-        if(vtxPos!=null) printWriter.format("%5.5f %5.5f %5.5f ", vtxPos.x(),vtxPos.y(),vtxPos.z() );
-        else printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999. );
-        if(vtxPosFr!=null) printWriter.format("%5.5f %5.5f %5.5f ", vtxPosFr.x(),vtxPosFr.y(),vtxPosFr.z() );
-        else printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999. );
-        if(vtxPosNonBend!=null) printWriter.format("%5.5f %5.5f %5.5f ", vtxPosNonBend.x(),vtxPosNonBend.y(),vtxPosNonBend.z() );
-        else printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999. );
-        int ncl_t=0; int ncl_b=0;
-        for(int i=0;i<3;++i) {
-            if(clusters==null) {
-                printWriter.format("%5.5f %5d %5d %5.5f %5.5f %5.5f %5d ",-999999.9,-999999,-999999,-999999.,-999999.,-999999.,-999999);
-            }
-            else if(clusters.size()<=i) {
-                printWriter.format("%5.5f %5d %5d %5.5f %5.5f %5.5f %5d ",-999999.9,-999999,-999999,-999999.,-999999.,-999999.,-999999);
+        if (vtxPos != null) {
+            printWriter.format("%5.5f %5.5f %5.5f ", vtxPos.x(), vtxPos.y(), vtxPos.z());
+        } else {
+            printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999.);
+        }
+        if (vtxPosFr != null) {
+            printWriter.format("%5.5f %5.5f %5.5f ", vtxPosFr.x(), vtxPosFr.y(), vtxPosFr.z());
+        } else {
+            printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999.);
+        }
+        if (vtxPosNonBend != null) {
+            printWriter.format("%5.5f %5.5f %5.5f ", vtxPosNonBend.x(), vtxPosNonBend.y(), vtxPosNonBend.z());
+        } else {
+            printWriter.format("%5.5f %5.5f %5.5f ", -9999999., -9999999., -9999999.);
+        }
+        int ncl_t = 0;
+        int ncl_b = 0;
+        for (int i = 0; i < 3; ++i) {
+            if (clusters == null) {
+                printWriter.format("%5.5f %5d %5d %5.5f %5.5f %5.5f %5d ", -999999.9, -999999, -999999, -999999., -999999., -999999., -999999);
+            } else if (clusters.size() <= i) {
+                printWriter.format("%5.5f %5d %5d %5.5f %5.5f %5.5f %5d ", -999999.9, -999999, -999999, -999999., -999999., -999999., -999999);
             } else {
                 //for(Cluster cl : clusters) {
                 int iy = clusters.get(i).getCalorimeterHits().get(0).getIdentifierFieldValue("iy");
@@ -822,166 +856,187 @@
                 double pos[] = clusters.get(i).getPosition();
                 double E = clusters.get(i).getEnergy();
                 int clsize = clusters.get(i).getSize();
-                printWriter.format("%5.5f %5d %5d %5.5f %5.5f %5.5f %5d ",E,ix,iy,pos[0],pos[1],pos[2],clsize);
-                if( iy > 0) ncl_t++;
-                else ncl_b++;
-            }
-        }
-        printWriter.format("%5d %5d ",ncl_t,ncl_b);
-        
-        GenericObject triggerData = getTriggerInfo(event);
-        if(triggerData==null) {
-        	printWriter.format("%5d %5d",0,0);
-        }
-        else {
-        	printWriter.format("%5d %5d",TriggerData.getTopTrig(triggerData),TriggerData.getBotTrig(triggerData));
-        	if(_debug) {
-        		System.out.printf("trigger top %d  bot %d  OR %d AND %d\n", TriggerData.getTopTrig(triggerData), TriggerData.getBotTrig(triggerData),TriggerData.getOrTrig(triggerData),TriggerData.getAndTrig(triggerData));
-        	}
+                printWriter.format("%5.5f %5d %5d %5.5f %5.5f %5.5f %5d ", E, ix, iy, pos[0], pos[1], pos[2], clsize);
+                if (iy > 0) {
+                    ncl_t++;
+                } else {
+                    ncl_b++;
+                }
+            }
+        }
+        printWriter.format("%5d %5d ", ncl_t, ncl_b);
+
+        TestRunTriggerData triggerData = getTriggerInfo(event);
+        if (triggerData == null) {
+            printWriter.format("%5d %5d", 0, 0);
+        } else {
+            printWriter.format("%5d %5d", triggerData.getTopTrig(), triggerData.getBotTrig());
+            if (_debug) {
+                System.out.printf("trigger top %d  bot %d  OR %d AND %d\n", triggerData.getTopTrig(), triggerData.getBotTrig(), triggerData.getOrTrig(), triggerData.getAndTrig());
+            }
         }
         printWriter.println();
-        
-    }
-    
-    
+
+    }
+
     /**
      * Check that object is not null or undefined
+     *
      * @param pos to check
      * @return
      */
     private boolean beamlinePosOk(Hep3Vector pos) {
-		if( pos == null) {
-			return false;
-		} else if ( Double.isNaN(pos.x()) || Double.isNaN(pos.y()) || Double.isNaN(pos.z()) ) {
-			return false;
-		} else {
-			return true;
-		}
-	}
-
-    private GenericObject getTriggerInfo(EventHeader event) {
-        if(event.hasCollection(TriggerData.class, triggerDecisionCollectionName)) {
-           
-            List<TriggerData> triggerDataList = event.get(TriggerData.class, "TriggerBank");
-            if(triggerDataList.isEmpty()) {
-                if(_debug) 
-                    System.out.println( "Event has trigger bank exists but is empty");
-                return null;
-            } else {
-                if(_debug) 
-                    System.out.println( "Event has trigger bank");
-                return triggerDataList.get(0);
-            }
-        }
-        else if (event.hasCollection(GenericObject.class, triggerDecisionCollectionName)) {
-        	List<GenericObject> triggerList = event.get(GenericObject.class, triggerDecisionCollectionName);
-            if (!triggerList.isEmpty()) {
-            	if(_debug) 
-                    System.out.println( "Event has trigger generic bank");
-                GenericObject triggerData = triggerList.get(0);
-                return triggerData;
-            } 
-            else {
-            	if(_debug) 
-                    System.out.println( "Event has trigger generic bank exists but is empty");
-            	return null;
-            }
-        }
-        else {
-        	if(_debug) { 
-        		System.out.printf( "%s: Event %d has NO trigger bank\n",this.getClass().getSimpleName(),event.getEventNumber());
-        	}
-        	return null;
-        }
-        
-    }
-                
-
-    private HashMap<Integer,HelicalTrackHit> getHitMap(List<TrackerHit> hits,HelicalTrackFit helix) {
-        HashMap<Integer,HelicalTrackHit> map = new HashMap<Integer,HelicalTrackHit>();
-        for(TrackerHit hit : hits) {
+        if (pos == null) {
+            return false;
+        } else if (Double.isNaN(pos.x()) || Double.isNaN(pos.y()) || Double.isNaN(pos.z())) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private TestRunTriggerData getTriggerInfo(EventHeader event) {
+        if (event.hasCollection(AbstractIntData.class, triggerDecisionCollectionName)) {
+
+            List<AbstractIntData> triggerDataList = event.get(AbstractIntData.class, "TriggerBank");
+            for (AbstractIntData data : triggerDataList) {
+                if (data instanceof TestRunTriggerData) {
+                    if (_debug) {
+                        System.out.println("Event has trigger bank");
+                    }
+                    return (TestRunTriggerData) data;
+                }
+            }
+            if (_debug) {
+                System.out.println("Event has trigger bank exists but is empty");
+            }
+            return null;
+        } else if (event.hasCollection(GenericObject.class, triggerDecisionCollectionName)) {
+            List<GenericObject> triggerList = event.get(GenericObject.class, triggerDecisionCollectionName);
+            for (GenericObject data : triggerList) {
+                if (AbstractIntData.getTag(data) == TestRunTriggerData.BANK_TAG) {
+                    if (_debug) {
+                        System.out.println("Event has trigger generic bank");
+                    }
+                    return new TestRunTriggerData(data);
+                }
+            }
+            if (_debug) {
+                System.out.println("Event has trigger generic bank exists but is empty");
+            }
+            return null;
+        } else {
+            if (_debug) {
+                System.out.printf("%s: Event %d has NO trigger bank\n", this.getClass().getSimpleName(), event.getEventNumber());
+            }
+            return null;
+        }
+
+    }
+
+    private HashMap<Integer, HelicalTrackHit> getHitMap(List<TrackerHit> hits, HelicalTrackFit helix) {
+        HashMap<Integer, HelicalTrackHit> map = new HashMap<Integer, HelicalTrackHit>();
+        for (TrackerHit hit : hits) {
             HelicalTrackHit hth = (HelicalTrackHit) hit;
             map.put(hth.Layer(), hth);
         }
         return map;
     }
-    
-
-    private HashMap<Integer,List<HelicalTrackStrip>> getStripHitsMap(List<TrackerHit> hits) {
-        HashMap<Integer,List<HelicalTrackStrip>> map = new HashMap<Integer,List<HelicalTrackStrip>>();
-        for(TrackerHit hit : hits) {
+
+    private HashMap<Integer, List<HelicalTrackStrip>> getStripHitsMap(List<TrackerHit> hits) {
+        HashMap<Integer, List<HelicalTrackStrip>> map = new HashMap<Integer, List<HelicalTrackStrip>>();
+        for (TrackerHit hit : hits) {
             HelicalTrackHit hth = (HelicalTrackHit) hit;
             HelicalTrackCross htc = (HelicalTrackCross) hth;
             HelicalTrackStrip s1 = htc.getStrips().get(0);
             HelicalTrackStrip s2 = htc.getStrips().get(1);
-            if(!map.containsKey(s1.layer())) map.put(s1.layer(), new ArrayList<HelicalTrackStrip>());
-            if(!map.containsKey(s2.layer())) map.put(s2.layer(), new ArrayList<HelicalTrackStrip>());
+            if (!map.containsKey(s1.layer())) {
+                map.put(s1.layer(), new ArrayList<HelicalTrackStrip>());
+            }
+            if (!map.containsKey(s2.layer())) {
+                map.put(s2.layer(), new ArrayList<HelicalTrackStrip>());
+            }
             map.get(s1.layer()).add(s1);
             map.get(s2.layer()).add(s2);
         }
         return map;
     }
-    
-    private HashMap<Integer,List<SiTrackerHitStrip1D>> getAllStripHitsMap(EventHeader event, boolean top) {
-        HashMap<Integer,List<SiTrackerHitStrip1D>> map = new HashMap<Integer,List<SiTrackerHitStrip1D>>();
-        if(!event.hasCollection(SiTrackerHitStrip1D.class, this._stripClusterCollectionName)) {
+
+    private HashMap<Integer, List<SiTrackerHitStrip1D>> getAllStripHitsMap(EventHeader event, boolean top) {
+        HashMap<Integer, List<SiTrackerHitStrip1D>> map = new HashMap<Integer, List<SiTrackerHitStrip1D>>();
+        if (!event.hasCollection(SiTrackerHitStrip1D.class, this._stripClusterCollectionName)) {
             return map;
         }
         List<SiTrackerHitStrip1D> strips = event.get(SiTrackerHitStrip1D.class, this._stripClusterCollectionName);
-        if(this._debug) System.out.printf("%s: found %d strips in clollection, asking strips in the %s\n", this.getClass().getSimpleName(),strips.size(),(top?"top":"bottom"));
-        for(SiTrackerHitStrip1D strip : strips) {
+        if (this._debug) {
+            System.out.printf("%s: found %d strips in clollection, asking strips in the %s\n", this.getClass().getSimpleName(), strips.size(), (top ? "top" : "bottom"));
+        }
+        for (SiTrackerHitStrip1D strip : strips) {
             IDetectorElement de = strip.getSensor();
             HpsSiSensor sensor = (HpsSiSensor) de;
             int lyr = _ID.getLayer(de);
             //===> if(!top && SvtUtils.getInstance().isTopLayer(sensor)) continue;
-            if(!top && sensor.isTopLayer()) continue;
-            //else if (top && !SvtUtils.getInstance().isTopLayer(sensor)) continue;
-            else if (top && !sensor.isTopLayer()) continue;
-            if(this._debug) System.out.printf("%s: strip \"%s\" at %s is selected\n", this.getClass().getSimpleName(),_ID.getName(de),strip.getPositionAsVector().toString());
-            if(!map.containsKey(lyr)) {
+            if (!top && sensor.isTopLayer()) {
+                continue;
+            } //else if (top && !SvtUtils.getInstance().isTopLayer(sensor)) continue;
+            else if (top && !sensor.isTopLayer()) {
+                continue;
+            }
+            if (this._debug) {
+                System.out.printf("%s: strip \"%s\" at %s is selected\n", this.getClass().getSimpleName(), _ID.getName(de), strip.getPositionAsVector().toString());
+            }
+            if (!map.containsKey(lyr)) {
                 map.put(lyr, new ArrayList<SiTrackerHitStrip1D>());
             }
             map.get(lyr).add(strip);
         }
-        
+
         return map;
     }
-    
-    private HashMap<Integer,List<HelicalTrackHit>> getAllStereoHitsMap(List<HelicalTrackHit> stereoHits, boolean top) {
-        HashMap<Integer,List<HelicalTrackHit>> map = new HashMap<Integer,List<HelicalTrackHit>>();
-        if(stereoHits==null) {
+
+    private HashMap<Integer, List<HelicalTrackHit>> getAllStereoHitsMap(List<HelicalTrackHit> stereoHits, boolean top) {
+        HashMap<Integer, List<HelicalTrackHit>> map = new HashMap<Integer, List<HelicalTrackHit>>();
+        if (stereoHits == null) {
             return map;
         }
-        if(this._debug) System.out.printf("%s: asking for stereo hits in the %s\n", this.getClass().getSimpleName(),(top?"top":"bottom"));
-        for(HelicalTrackHit hit : stereoHits) {
-            if(top && hit.z()<0) continue;
-            if(!top && hit.z()>0) continue;
-            if(this._debug) System.out.printf("%s: hit at xyz=%.3f,%.3f,%.3f is selected\n", this.getClass().getSimpleName(),hit.x(),hit.y(),hit.z());
-            if(!map.containsKey(hit.Layer())) {
+        if (this._debug) {
+            System.out.printf("%s: asking for stereo hits in the %s\n", this.getClass().getSimpleName(), (top ? "top" : "bottom"));
+        }
+        for (HelicalTrackHit hit : stereoHits) {
+            if (top && hit.z() < 0) {
+                continue;
+            }
+            if (!top && hit.z() > 0) {
+                continue;
+            }
+            if (this._debug) {
+                System.out.printf("%s: hit at xyz=%.3f,%.3f,%.3f is selected\n", this.getClass().getSimpleName(), hit.x(), hit.y(), hit.z());
+            }
+            if (!map.containsKey(hit.Layer())) {
                 map.put(hit.Layer(), new ArrayList<HelicalTrackHit>());
             }
             map.get(hit.Layer()).add(hit);
         }
         return map;
     }
-    
+
     private int[] getNtracks(List<CmpTrack> tracks, double min_px) {
         //System.out.printf("%s: getNtracks for %d tracks with min_px=%.3f \n",this.getClass().getSimpleName(),tracks.size(),min_px);
-        int n[] = {0,0};
-        for(CmpTrack track : tracks) {
-            if(track._track.getTrackStates().get(0).getMomentum()[0]<min_px) {
+        int n[] = {0, 0};
+        for (CmpTrack track : tracks) {
+            if (track._track.getTrackStates().get(0).getMomentum()[0] < min_px) {
                 continue;
             }
             //System.out.printf("%s: track had enough px=%f\n",this.getClass().getSimpleName(),track._track.getTrackStates().get(0).getMomentum()[0]);
-            
+
             List<TrackerHit> hitsOnTrack = track._track.getTrackerHits();
-            for(TrackerHit hit : hitsOnTrack) {
+            for (TrackerHit hit : hitsOnTrack) {
                 double y = hit.getPosition()[1];
-                if(y>0) {
+                if (y > 0) {
                     //System.out.printf("%s: this track (chi2=%f) is a top track\n",this.getClass().getSimpleName(),track._track.getChi2());
                     n[0]++;
                     break;
-                } else if(y<0) {
+                } else if (y < 0) {
                     //System.out.printf("%s: this track (chi2=%f) is a bot track\n",this.getClass().getSimpleName(),track._track.getChi2());
                     n[1]++;
                     break;
@@ -993,9 +1048,7 @@
         return n;
     }
 
-    
-    
-      private void makePlots() {
+    private void makePlots() {
         _vtxpos_x = aida.histogram1D("Vertex position X", 100, -800, -500);
         _vtxpos_y = aida.histogram1D("Vertex position Y", 100, 0, 40);
         _vtxpos_z = aida.histogram1D("Vertex position Z", 100, -4, 4);
@@ -1014,51 +1067,48 @@
         _vtxposnonb_angle1 = aida.histogram1D("SLT thetay non-bend (trk1)", 100, -0.05, 0.05);
         _vtxposnonb_angle2 = aida.histogram1D("SLT thetay non-bend (trk2)", 100, -0.05, 0.05);
 
-        _ntrks_px = aida.histogram2D("Track multiplicity vs px cut", 6, 0, 0.6,8,0,8);
-        
-        _trk_y_at_conv_top_pos = aida.histogram1D("Track y @ converter top +", 100, -30,60);
-        _trk_z_at_conv_top_pos = aida.histogram1D("Track z @ converter top +", 100, -20,20);
+        _ntrks_px = aida.histogram2D("Track multiplicity vs px cut", 6, 0, 0.6, 8, 0, 8);
+
+        _trk_y_at_conv_top_pos = aida.histogram1D("Track y @ converter top +", 100, -30, 60);
+        _trk_z_at_conv_top_pos = aida.histogram1D("Track z @ converter top +", 100, -20, 20);
         _trk_y_at_conv_top_pos_fr = aida.histogram1D("Track y @ converter top + (fr)", 100, -30, 60);
         _trk_z_at_conv_top_pos_fr = aida.histogram1D("Track z @ converter top + (fr)", 100, -20, 20);
-        _trk_y_at_conv_bot_pos = aida.histogram1D("Track y @ converter bot +", 100, -30,60);
-        _trk_z_at_conv_bot_pos = aida.histogram1D("Track z @ converter bot +", 100, -20,20);
+        _trk_y_at_conv_bot_pos = aida.histogram1D("Track y @ converter bot +", 100, -30, 60);
+        _trk_z_at_conv_bot_pos = aida.histogram1D("Track z @ converter bot +", 100, -20, 20);
         _trk_y_at_conv_bot_pos_fr = aida.histogram1D("Track y @ converter bot + (fr)", 100, -30, 60);
         _trk_z_at_conv_bot_pos_fr = aida.histogram1D("Track z @ converter bot + (fr)", 100, -20, 20);
 
-        _trk_y_at_conv_top_neg = aida.histogram1D("Track y @ converter top -", 100, -30,60);
-        _trk_z_at_conv_top_neg = aida.histogram1D("Track z @ converter top -", 100, -20,20);
+        _trk_y_at_conv_top_neg = aida.histogram1D("Track y @ converter top -", 100, -30, 60);
+        _trk_z_at_conv_top_neg = aida.histogram1D("Track z @ converter top -", 100, -20, 20);
         _trk_y_at_conv_top_neg_fr = aida.histogram1D("Track y @ converter top - (fr)", 100, -30, 60);
         _trk_z_at_conv_top_neg_fr = aida.histogram1D("Track z @ converter top - (fr)", 100, -20, 20);
-        _trk_y_at_conv_bot_neg = aida.histogram1D("Track y @ converter bot -", 100, -30,60);
-        _trk_z_at_conv_bot_neg = aida.histogram1D("Track z @ converter bot -", 100, -20,20);
+        _trk_y_at_conv_bot_neg = aida.histogram1D("Track y @ converter bot -", 100, -30, 60);
+        _trk_z_at_conv_bot_neg = aida.histogram1D("Track z @ converter bot -", 100, -20, 20);
         _trk_y_at_conv_bot_neg_fr = aida.histogram1D("Track y @ converter bot - (fr)", 100, -30, 60);
         _trk_z_at_conv_bot_neg_fr = aida.histogram1D("Track z @ converter bot - (fr)", 100, -20, 20);
 
-        
-        _trkmatch_top_dy = aida.histogram1D("dy(cl,track) top", 50, -60,60);
-        _trkmatch_top_dx = aida.histogram1D("dx(cl,track) top", 50, -60,60);
-        _trkmatch_bot_dy = aida.histogram1D("dy(cl,track) bot", 50, -60,60);
-        _trkmatch_bot_dx = aida.histogram1D("dx(cl,track) bot", 50, -60,60);
-
-        _trkmatch_top_plus_dx = aida.histogram1D("dx(cl,track) top plus", 50, -60,60);
-        _trkmatch_bot_plus_dx = aida.histogram1D("dx(cl,track) bot plus", 50, -60,60);
-        _trkmatch_top_minus_dx = aida.histogram1D("dx(cl,track) top minus", 50, -60,60);
-        _trkmatch_bot_minus_dx = aida.histogram1D("dx(cl,track) bot minus", 50, -60,60);
-       
-        
-        
+        _trkmatch_top_dy = aida.histogram1D("dy(cl,track) top", 50, -60, 60);
+        _trkmatch_top_dx = aida.histogram1D("dx(cl,track) top", 50, -60, 60);
+        _trkmatch_bot_dy = aida.histogram1D("dy(cl,track) bot", 50, -60, 60);
+        _trkmatch_bot_dx = aida.histogram1D("dx(cl,track) bot", 50, -60, 60);
+
+        _trkmatch_top_plus_dx = aida.histogram1D("dx(cl,track) top plus", 50, -60, 60);
+        _trkmatch_bot_plus_dx = aida.histogram1D("dx(cl,track) bot plus", 50, -60, 60);
+        _trkmatch_top_minus_dx = aida.histogram1D("dx(cl,track) top minus", 50, -60, 60);
+        _trkmatch_bot_minus_dx = aida.histogram1D("dx(cl,track) bot minus", 50, -60, 60);
+
         _plotterTrackVertex = aida.analysisFactory().createPlotterFactory().create();
-        _plotterTrackVertex.createRegions(2,2);
+        _plotterTrackVertex.createRegions(2, 2);
         _plotterTrackVertex.region(0).plot(_vtxpos_x);
         _plotterTrackVertex.region(1).plot(_vtxpos_y);
         _plotterTrackVertex.region(2).plot(_vtxpos_z);
         _plotterTrackVertexFr = aida.analysisFactory().createPlotterFactory().create();
-        _plotterTrackVertexFr.createRegions(2,2);
+        _plotterTrackVertexFr.createRegions(2, 2);
         _plotterTrackVertexFr.region(0).plot(_vtxposfr_x);
         _plotterTrackVertexFr.region(1).plot(_vtxposfr_y);
         _plotterTrackVertexFr.region(2).plot(_vtxposfr_z);
         _plotterTrackVertexNonBend = aida.analysisFactory().createPlotterFactory().create();
-        _plotterTrackVertexNonBend.createRegions(2,4);
+        _plotterTrackVertexNonBend.createRegions(2, 4);
         _plotterTrackVertexNonBend.region(0).plot(_vtxposnonb_x);
         _plotterTrackVertexNonBend.region(1).plot(_vtxposnonb_y);
         _plotterTrackVertexNonBend.region(2).plot(_vtxposnonb_z);
@@ -1068,15 +1118,15 @@
         _plotterTrackVertexNonBend.region(6).plot(_vtxposnonb_angle1);
         _plotterTrackVertexNonBend.region(7).plot(_vtxposnonb_angle2);
         _plotterParticleVertex = aida.analysisFactory().createPlotterFactory().create();
-        _plotterParticleVertex.createRegions(2,2);
+        _plotterParticleVertex.createRegions(2, 2);
         _plotterParticleVertex.region(0).plot(_partvtxpos_x);
         _plotterParticleVertex.region(1).plot(_partvtxpos_y);
         _plotterParticleVertex.region(2).plot(_partvtxpos_z);
         _plotterTrackMult = aida.analysisFactory().createPlotterFactory().create();
-        _plotterTrackMult.createRegions(1,1);
+        _plotterTrackMult.createRegions(1, 1);
         _plotterTrackMult.region(0).plot(_ntrks_px);
         _plotterTrackAtConv = aida.analysisFactory().createPlotterFactory().create();
-        _plotterTrackAtConv.createRegions(4,4);
+        _plotterTrackAtConv.createRegions(4, 4);
         _plotterTrackAtConv.region(0).plot(_trk_y_at_conv_top_pos);
         _plotterTrackAtConv.region(4).plot(_trk_z_at_conv_top_pos);
         _plotterTrackAtConv.region(8).plot(_trk_y_at_conv_top_pos_fr);
@@ -1094,7 +1144,7 @@
         _plotterTrackAtConv.region(11).plot(_trk_y_at_conv_bot_neg_fr);
         _plotterTrackAtConv.region(15).plot(_trk_z_at_conv_bot_neg_fr);
         _plotterTrackMatch = aida.analysisFactory().createPlotterFactory().create();
-        _plotterTrackMatch.createRegions(2,3);
+        _plotterTrackMatch.createRegions(2, 3);
         _plotterTrackMatch.region(0).plot(_trkmatch_top_plus_dx);
         _plotterTrackMatch.region(1).plot(_trkmatch_top_minus_dx);
         _plotterTrackMatch.region(2).plot(_trkmatch_bot_plus_dx);
@@ -1107,25 +1157,25 @@
         _plotterTrackMult.setTitle("Track multiplicity");
         _plotterTrackAtConv.setTitle("Track @ converter");
         _plotterTrackMatch.setTitle("Track-cluster matching");
-        
-        for(int i=0;i<3;++i) {
+
+        for (int i = 0; i < 3; ++i) {
             ((PlotterRegion) _plotterParticleVertex.region(i)).getPlot().setAllowUserInteraction(true);
             ((PlotterRegion) _plotterParticleVertex.region(i)).getPlot().setAllowPopupMenus(true);
             ((PlotterRegion) _plotterTrackVertex.region(i)).getPlot().setAllowUserInteraction(true);
             ((PlotterRegion) _plotterTrackVertex.region(i)).getPlot().setAllowPopupMenus(true);
             ((PlotterRegion) _plotterTrackVertexNonBend.region(i)).getPlot().setAllowUserInteraction(true);
             ((PlotterRegion) _plotterTrackVertexNonBend.region(i)).getPlot().setAllowPopupMenus(true);
-			((PlotterRegion) _plotterTrackMatch.region(i)).getPlot().setAllowUserInteraction(true);
-			((PlotterRegion) _plotterTrackMatch.region(i)).getPlot().setAllowPopupMenus(true);
-            if(i<2) {
-            	if(i==0) {
-            		((PlotterRegion) _plotterTrackMult.region(i)).getPlot().setAllowUserInteraction(true);
-            		((PlotterRegion) _plotterTrackMult.region(i)).getPlot().setAllowPopupMenus(true);
-            	}
-            }
-        }
-        
-        if(!this.hideFrame) {
+            ((PlotterRegion) _plotterTrackMatch.region(i)).getPlot().setAllowUserInteraction(true);
+            ((PlotterRegion) _plotterTrackMatch.region(i)).getPlot().setAllowPopupMenus(true);
+            if (i < 2) {
+                if (i == 0) {
+                    ((PlotterRegion) _plotterTrackMult.region(i)).getPlot().setAllowUserInteraction(true);
+                    ((PlotterRegion) _plotterTrackMult.region(i)).getPlot().setAllowPopupMenus(true);
+                }
+            }
+        }
+
+        if (!this.hideFrame) {
             this._plotterParticleVertex.show();
             this._plotterTrackVertex.show();
             this._plotterTrackVertexFr.show();
@@ -1133,53 +1183,44 @@
             //this._plotterTrackMult.show();
             _plotterTrackAtConv.show();
             _plotterTrackMatch.show();
-        } 
-    }
-
-      
+        }
+    }
+
     private void createWriter() {
-    	try {
+        try {
             fileWriter = new FileWriter(outputNameTextTuple);
         } catch (IOException ex) {
             Logger.getLogger(ROOTFlatTupleDriver.class.getName()).log(Level.SEVERE, null, ex);
         }
         printWriter = new PrintWriter(fileWriter);
     }
-    
-    
-    
+
     /*
      * Find the path length where the two helix cross in the non-bend plane
      */
-    
     private double getCrossingS(Track trk1, Track trk2) {
-        double slope_1 = ((SeedTrack)trk1).getSeedCandidate().getHelix().slope();
-        double slope_2 = ((SeedTrack)trk2).getSeedCandidate().getHelix().slope();
-        double z0_1 = ((SeedTrack)trk1).getSeedCandidate().getHelix().z0();
-        double z0_2 = ((SeedTrack)trk2).getSeedCandidate().getHelix().z0();        
+        double slope_1 = ((SeedTrack) trk1).getSeedCandidate().getHelix().slope();
+        double slope_2 = ((SeedTrack) trk2).getSeedCandidate().getHelix().slope();
+        double z0_1 = ((SeedTrack) trk1).getSeedCandidate().getHelix().z0();
+        double z0_2 = ((SeedTrack) trk2).getSeedCandidate().getHelix().z0();
         double s = getPathLengthCrossingPoint(slope_1, z0_1, slope_2, z0_2);
-        double zAtCross = z0_1 + s*slope_1;
+        double zAtCross = z0_1 + s * slope_1;
         //System.out.printf("%s: s1=%f z1=%f s2=%f z2=%f => path=%f and zAtCross=%f\n",this.getClass().getSimpleName(),slope_1,z0_1,slope_2,z0_2,s,zAtCross);
         return zAtCross;
     }
-    
-    
+
     private StraightLineTrack[] getSLTs(Track trk1, Track trk2, boolean useFringe) {
         // find the point on the x- and y-axis by 
         // 1) go outside the fringe region 
         // 2) assume straight lines 
         // 3) solve for the position where the z-position is at the crossing point
-        double zStart = useFringe==true ? -100. : 0.;
-        StraightLineTrack slt1 = TrackUtils.findSLTAtZ(trk1,zStart,useFringe);
-        StraightLineTrack slt2 = TrackUtils.findSLTAtZ(trk2,zStart,useFringe);
-        StraightLineTrack[] vv = {slt1,slt2};
+        double zStart = useFringe == true ? -100. : 0.;
+        StraightLineTrack slt1 = TrackUtils.findSLTAtZ(trk1, zStart, useFringe);
+        StraightLineTrack slt2 = TrackUtils.findSLTAtZ(trk2, zStart, useFringe);
+        StraightLineTrack[] vv = {slt1, slt2};
         return vv;
     }
-    
-    
-     
-
-    
+
     /*
      * Calculate the point where two 1-D lines cross
      * Use SZ coordinate system nomenclature
@@ -1187,33 +1228,33 @@
      * slope: slope of track in SZ plane
      * z0: z-coordinate at which S=0
      */
-    private double getPathLengthCrossingPoint(double slope_1,double z0_1,double slope_2,double z0_2) {
+    private double getPathLengthCrossingPoint(double slope_1, double z0_1, double slope_2, double z0_2) {
         double s; //path length
-        s = (z0_1-z0_2)/(slope_2-slope_1);
+        s = (z0_1 - z0_2) / (slope_2 - slope_1);
         return s;
     }
 
     /**
      * Print out informatoin about ecal geometry
+     *
      * @param detector
      */
     private void printEcalInfo(Detector detector) {
-    Subdetector det = detector.getSubdetector("Ecal");
-    if(det!=null) {
-    	System.out.printf("found %s with %d children:\n",det.getName(),det.getDetectorElement().getChildren().size());
-    	System.out.printf("%5s %5s %45s %45s\n","ix","iy","global pos"," translation");
-    	for(IDetectorElement idet : det.getDetectorElement().getChildren()) {
-        		//System.out.printf("%s\n",idet.getName());
-        		IIdentifierHelper helper = idet.getIdentifierHelper();
-        		IExpandedIdentifier expId = idet.getExpandedIdentifier();
-        		int ix = expId.getValue(helper.getFieldIndex("ix"));
-        		int iy = expId.getValue(helper.getFieldIndex("iy"));
-        		System.out.printf("%5d %5d %45s %45s\n",ix,iy, idet.getGeometry().getPosition().toString(),idet.getGeometry().getPhysicalVolume().getTranslation().toString());
-        }
-    }
-    else {
-    	System.out.printf("found no ecal\n");
-    }
-    }
-    
+        Subdetector det = detector.getSubdetector("Ecal");
+        if (det != null) {
+            System.out.printf("found %s with %d children:\n", det.getName(), det.getDetectorElement().getChildren().size());
+            System.out.printf("%5s %5s %45s %45s\n", "ix", "iy", "global pos", " translation");
+            for (IDetectorElement idet : det.getDetectorElement().getChildren()) {
+                //System.out.printf("%s\n",idet.getName());
+                IIdentifierHelper helper = idet.getIdentifierHelper();
+                IExpandedIdentifier expId = idet.getExpandedIdentifier();
+                int ix = expId.getValue(helper.getFieldIndex("ix"));
+                int iy = expId.getValue(helper.getFieldIndex("iy"));
+                System.out.printf("%5d %5d %45s %45s\n", ix, iy, idet.getGeometry().getPosition().toString(), idet.getGeometry().getPhysicalVolume().getTranslation().toString());
+            }
+        } else {
+            System.out.printf("found no ecal\n");
+        }
+    }
+
 }

Modified: java/trunk/users/src/main/java/org/hps/users/phansson/TriggerTurnOnAnalysis.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/phansson/TriggerTurnOnAnalysis.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/phansson/TriggerTurnOnAnalysis.java	Thu Jan 22 15:22:11 2015
@@ -10,17 +10,15 @@
 import hep.aida.IHistogramFactory;
 import hep.aida.IPlotter;
 import hep.physics.vec.Hep3Vector;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-
 import org.hps.analysis.ecal.HPSMCParticlePlotsDriver;
-import org.hps.readout.ecal.TriggerData;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.MCParticle;
 import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
@@ -118,10 +116,10 @@
         
 
         
-        List<TriggerData> trigger_data = null;
-        
-        if(event.hasCollection(TriggerData.class, triggerDataCollectionName)) {
-            trigger_data = event.get(TriggerData.class, triggerDataCollectionName);
+        List<GenericObject> trigger_data = null;
+        
+        if(event.hasCollection(GenericObject.class, triggerDataCollectionName)) {
+            trigger_data = event.get(GenericObject.class, triggerDataCollectionName);
             if(_DEBUG) System.out.println(this.getClass().getSimpleName() + ": event " + event.getRunNumber() + " has trigger data");
         }
         else {