LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  May 2016

HPS-SVN May 2016

Subject:

r4376 - in /java/trunk/analysis/src/main/java/org/hps/analysis: dataquality/ tuple/

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Wed, 25 May 2016 01:30:45 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (3820 lines)

Author: [log in to unmask]
Date: Tue May 24 18:30:43 2016
New Revision: 4376

Log:
clean up tuple code

Added:
    java/trunk/analysis/src/main/java/org/hps/analysis/tuple/
    java/trunk/analysis/src/main/java/org/hps/analysis/tuple/FEETupleDriver.java
      - copied, changed from r4342, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java
    java/trunk/analysis/src/main/java/org/hps/analysis/tuple/MollerTupleDriver.java
      - copied, changed from r4372, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java
    java/trunk/analysis/src/main/java/org/hps/analysis/tuple/TridentTupleDriver.java
      - copied, changed from r4372, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java
    java/trunk/analysis/src/main/java/org/hps/analysis/tuple/TupleDriver.java
      - copied, changed from r4372, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java
Modified:
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java
    java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java	Tue May 24 18:30:43 2016
@@ -1,7 +1,5 @@
 package org.hps.analysis.dataquality;
 
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.HashMap;
@@ -9,7 +7,6 @@
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import org.apache.commons.lang3.StringUtils;
 import org.hps.record.triggerbank.AbstractIntData;
 import org.hps.record.triggerbank.TIData;
 import org.lcsim.event.EventHeader;
@@ -39,11 +36,6 @@
     protected boolean debug = false;
     protected boolean outputPlots = false;
     protected String outputPlotDir = "DQMOutputPlots/";
-
-    protected PrintWriter tupleWriter = null;
-    protected String[] tupleVariables = {};
-    protected final Map<String, Double> tupleMap = new HashMap<String, Double>();
-    protected boolean cutTuple = false;
 
     String triggerType = "all";//allowed types are "" (blank) or "all", singles0, singles1, pairs0,pairs1
     public boolean isGBL = false;
@@ -116,9 +108,6 @@
             }
             dumpDQMData();
         }
-        if (tupleWriter != null) {
-            tupleWriter.close();
-        }
     }
 
     private void makeNewRow() {
@@ -239,43 +228,4 @@
     //format for making the db column headers
     public void printDQMStrings() {
     }
-
-    protected void writeTuple() {
-        for (String variable : tupleVariables) {
-            Double value = tupleMap.get(variable);
-            if (value == null) {
-                value = -9999.0;
-            }
-            if (variable.endsWith("/I") || variable.endsWith("/B")) {
-                tupleWriter.format("%d\t", Math.round(value));
-            } else {
-                tupleWriter.format("%f\t", value);
-            }
-        }
-        tupleWriter.println();
-        tupleMap.clear();
-    }
-
-    public void setTupleFile(String tupleFile) {
-        try {
-            tupleWriter = new PrintWriter(tupleFile);
-        } catch (FileNotFoundException e) {
-            tupleWriter = null;
-        }
-        tupleWriter.println(StringUtils.join(tupleVariables, ":"));
-//        for (String variable : tupleVariables) {
-//            tupleWriter.format("%s:", variable);
-//        }
-//        tupleWriter.println();
-    }
-
-    /**
-     * apply loose cuts to the tuple (cuts to be defined in the specific DQM
-     * driver)
-     *
-     * @param cutTuple
-     */
-    public void setCutTuple(boolean cutTuple) {
-        this.cutTuple = cutTuple;
-    }
 }

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java	Tue May 24 18:30:43 2016
@@ -10,7 +10,6 @@
 import java.util.List;
 import java.util.logging.Logger;
 import org.hps.conditions.beam.BeamEnergy.BeamEnergyCollection;
-import org.hps.recon.ecal.cluster.ClusterUtilities;
 import org.hps.recon.particle.HpsReconParticleDriver;
 import org.hps.recon.particle.ReconParticleDriver;
 import org.hps.recon.tracking.TrackType;
@@ -18,7 +17,6 @@
 import org.hps.recon.vertexing.BilliorTrack;
 import org.hps.recon.vertexing.BilliorVertex;
 import org.hps.recon.vertexing.BilliorVertexer;
-import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.ReconstructedParticle;
 import org.lcsim.event.RelationalTable;
@@ -177,39 +175,10 @@
     private final double trkTimeDiff = 5.0;
 //    private final double clusterTimeDiffCut = 2.5;
 
-    private final double tupleTrkPCut = 0.9;
-    private final double tupleMinSumCut = 0.7;
-    private final double tupleMaxSumCut = 1.3;
-
 //    private double l1IsoMin = 0.5;
     private final double[] beamSize = {0.001, 0.130, 0.050}; //rough estimate from harp scans during engineering run production running
     private final double[] beamPos = {0.0, 0.0, 0.0};
     private final double[] vzcBeamSize = {0.001, 100, 100};
-
-    public MollerMonitoring() {
-        this.tupleVariables = new String[]{"run/I", "event/I",
-            "nTrk/I", "nPos/I",
-            "uncPX/D", "uncPY/D", "uncPZ/D", "uncP/D",
-            "uncVX/D", "uncVY/D", "uncVZ/D", "uncChisq/D", "uncM/D",
-            "bscPX/D", "bscPY/D", "bscPZ/D", "bscP/D",
-            "bscVX/D", "bscVY/D", "bscVZ/D", "bscChisq/D", "bscM/D",
-            "tarPX/D", "tarPY/D", "tarPZ/D", "tarP/D",
-            "tarVX/D", "tarVY/D", "tarVZ/D", "tarChisq/D", "tarM/D",
-            "vzcPX/D", "vzcPY/D", "vzcPZ/D", "vzcP/D",
-            "vzcVX/D", "vzcVY/D", "vzcVZ/D", "vzcChisq/D", "vzcM/D",
-            "topPX/D", "topPY/D", "topPZ/D", "topP/D",
-            "topTrkChisq/D", "topTrkHits/I", "topTrkType/I", "topTrkT/D",
-            "topTrkD0/D", "topTrkZ0/D", "topTrkEcalX/D", "topTrkEcalY/D",
-            "topHasL1/B", "topHasL2/B",
-            "topMatchChisq/D", "topClT/D", "topClE/D", "topClX/D", "topClY/D", "topClZ/D", "topClHits/I",
-            "botPX/D", "botPY/D", "botPZ/D", "botP/D",
-            "botTrkChisq/D", "botTrkHits/I", "botTrkType/I", "botTrkT/D",
-            "botTrkD0/D", "botTrkZ0/D", "botTrkEcalX/D", "botTrkEcalY/D",
-            "botHasL1/B", "botHasL2/B",
-            "botMatchChisq/D", "botClT/D", "botClE/D", "botClX/D", "botClY/D", "botClZ/D", "botClHits/I",
-            "minL1Iso/D"
-        };
-    }
 
     public void setMaxChi2GBLTrack(double maxChi2GBLTrack) {
         this.maxChi2GBLTrack = maxChi2GBLTrack;
@@ -445,110 +414,6 @@
             Hep3Vector vzcMomRot = VecOp.mult(beamAxisRotation, vzcV0.getMomentum());
             Hep3Vector vzcVtx = VecOp.mult(beamAxisRotation, vzcV0.getStartVertex().getPosition());
 
-            if (tupleWriter != null) {
-                boolean trkCut = top.getMomentum().magnitude() < tupleTrkPCut * ebeam && bot.getMomentum().magnitude() < tupleTrkPCut * ebeam;
-                boolean sumCut = top.getMomentum().magnitude() + bot.getMomentum().magnitude() > tupleMinSumCut * ebeam && top.getMomentum().magnitude() + bot.getMomentum().magnitude() < tupleMaxSumCut * ebeam;
-
-                if (!cutTuple || (trkCut && sumCut)) {
-
-                    tupleMap.put("run/I", (double) event.getRunNumber());
-                    tupleMap.put("event/I", (double) event.getEventNumber());
-
-                    tupleMap.put("uncPX/D", v0MomRot.x());
-                    tupleMap.put("uncPY/D", v0MomRot.y());
-                    tupleMap.put("uncPZ/D", v0MomRot.z());
-                    tupleMap.put("uncP/D", v0MomRot.magnitude());
-                    tupleMap.put("uncVX/D", v0Vtx.x());
-                    tupleMap.put("uncVY/D", v0Vtx.y());
-                    tupleMap.put("uncVZ/D", v0Vtx.z());
-                    tupleMap.put("uncChisq/D", uncV0.getStartVertex().getChi2());
-                    tupleMap.put("uncM/D", uncV0.getMass());
-
-                    tupleMap.put("bscPX/D", bscMomRot.x());
-                    tupleMap.put("bscPY/D", bscMomRot.y());
-                    tupleMap.put("bscPZ/D", bscMomRot.z());
-                    tupleMap.put("bscP/D", bscMomRot.magnitude());
-                    tupleMap.put("bscVX/D", bscVtx.x());
-                    tupleMap.put("bscVY/D", bscVtx.y());
-                    tupleMap.put("bscVZ/D", bscVtx.z());
-                    tupleMap.put("bscChisq/D", bscV0.getStartVertex().getChi2());
-                    tupleMap.put("bscM/D", bscV0.getMass());
-
-                    tupleMap.put("tarPX/D", tarMomRot.x());
-                    tupleMap.put("tarPY/D", tarMomRot.y());
-                    tupleMap.put("tarPZ/D", tarMomRot.z());
-                    tupleMap.put("tarP/D", tarMomRot.magnitude());
-                    tupleMap.put("tarVX/D", tarVtx.x());
-                    tupleMap.put("tarVY/D", tarVtx.y());
-                    tupleMap.put("tarVZ/D", tarVtx.z());
-                    tupleMap.put("tarChisq/D", tarV0.getStartVertex().getChi2());
-                    tupleMap.put("tarM/D", tarV0.getMass());
-
-                    tupleMap.put("vzcPX/D", vzcMomRot.x());
-                    tupleMap.put("vzcPY/D", vzcMomRot.y());
-                    tupleMap.put("vzcPZ/D", vzcMomRot.z());
-                    tupleMap.put("vzcP/D", vzcMomRot.magnitude());
-                    tupleMap.put("vzcVX/D", vzcVtx.x());
-                    tupleMap.put("vzcVY/D", vzcVtx.y());
-                    tupleMap.put("vzcVZ/D", vzcVtx.z());
-                    tupleMap.put("vzcChisq/D", vzcV0.getStartVertex().getChi2());
-                    tupleMap.put("vzcM/D", vzcV0.getMass());
-
-                    tupleMap.put("topPX/D", pTopRot.x());
-                    tupleMap.put("topPY/D", pTopRot.y());
-                    tupleMap.put("topPZ/D", pTopRot.z());
-                    tupleMap.put("topP/D", pTopRot.magnitude());
-                    tupleMap.put("topTrkD0/D", top.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("topTrkZ0/D", top.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("topTrkEcalX/D", topAtEcal.x());
-                    tupleMap.put("topTrkEcalY/D", topAtEcal.y());
-                    tupleMap.put("topTrkChisq/D", top.getTracks().get(0).getChi2());
-                    tupleMap.put("topTrkHits/I", (double) top.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("topTrkType/I", (double) top.getType());
-                    tupleMap.put("topTrkT/D", tTop);
-                    tupleMap.put("topHasL1/B", topIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("topHasL2/B", topIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("topMatchChisq/D", top.getGoodnessOfPID());
-                    if (!top.getClusters().isEmpty()) {
-                        Cluster topC = top.getClusters().get(0);
-                        tupleMap.put("topClT/D", ClusterUtilities.getSeedHitTime(topC));
-                        tupleMap.put("topClE/D", topC.getEnergy());
-                        tupleMap.put("topClX/D", topC.getPosition()[0]);
-                        tupleMap.put("topClY/D", topC.getPosition()[1]);
-                        tupleMap.put("topClZ/D", topC.getPosition()[2]);
-                        tupleMap.put("topClHits/I", (double) topC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("botPX/D", pBotRot.x());
-                    tupleMap.put("botPY/D", pBotRot.y());
-                    tupleMap.put("botPZ/D", pBotRot.z());
-                    tupleMap.put("botP/D", pBotRot.magnitude());
-                    tupleMap.put("botTrkD0/D", bot.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("botTrkZ0/D", bot.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("botTrkEcalX/D", botAtEcal.x());
-                    tupleMap.put("botTrkEcalY/D", botAtEcal.y());
-                    tupleMap.put("botTrkChisq/D", bot.getTracks().get(0).getChi2());
-                    tupleMap.put("botTrkHits/I", (double) bot.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("botTrkType/I", (double) bot.getType());
-                    tupleMap.put("botTrkT/D", tBot);
-                    tupleMap.put("botHasL1/B", botIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("botHasL2/B", botIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("botMatchChisq/D", bot.getGoodnessOfPID());
-                    if (!bot.getClusters().isEmpty()) {
-                        Cluster botC = bot.getClusters().get(0);
-                        tupleMap.put("botClT/D", ClusterUtilities.getSeedHitTime(botC));
-                        tupleMap.put("botClE/D", botC.getEnergy());
-                        tupleMap.put("botClHits/I", (double) botC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("minL1Iso/D", minL1Iso);
-
-                    tupleMap.put("nTrk/I", (double) ntrk);
-                    tupleMap.put("nPos/I", (double) npos);
-                    writeTuple();
-                }
-            }
-
             //start applying cuts
             EnumSet<Cut> bits = EnumSet.noneOf(Cut.class);
 

Modified: java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java	Tue May 24 18:30:43 2016
@@ -23,7 +23,6 @@
 import org.hps.recon.vertexing.BilliorTrack;
 import org.hps.recon.vertexing.BilliorVertex;
 import org.hps.recon.vertexing.BilliorVertexer;
-import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.ReconstructedParticle;
 import org.lcsim.event.RelationalTable;
@@ -265,9 +264,6 @@
 
     private double l1IsoMin = 0.5;
 
-    private final double tupleTrkPCut = 0.9;
-    private final double tupleMaxSumCut = 1.3;
-
     private final double[] beamSize = {0.001, 0.130, 0.050}; //rough estimate from harp scans during engineering run production running
     private final double[] beamPos = {0.0, 0.0, 0.0};
     private final double[] vzcBeamSize = {0.001, 100, 100};
@@ -282,30 +278,6 @@
     private float nRecoV0 = 0;
     private final float[] nPassCut = new float[Cut.nCuts];
 
-    public TridentMonitoring() {
-        this.tupleVariables = new String[]{"run/I", "event/I",
-            "nTrk/I", "nPos/I",
-            "uncPX/D", "uncPY/D", "uncPZ/D", "uncP/D",
-            "uncVX/D", "uncVY/D", "uncVZ/D", "uncChisq/D", "uncM/D",
-            "bscPX/D", "bscPY/D", "bscPZ/D", "bscP/D",
-            "bscVX/D", "bscVY/D", "bscVZ/D", "bscChisq/D", "bscM/D",
-            "tarPX/D", "tarPY/D", "tarPZ/D", "tarP/D",
-            "tarVX/D", "tarVY/D", "tarVZ/D", "tarChisq/D", "tarM/D",
-            "vzcPX/D", "vzcPY/D", "vzcPZ/D", "vzcP/D",
-            "vzcVX/D", "vzcVY/D", "vzcVZ/D", "vzcChisq/D", "vzcM/D",
-            "elePX/D", "elePY/D", "elePZ/D", "eleP/D",
-            "eleTrkChisq/D", "eleTrkHits/I", "eleTrkType/I", "eleTrkT/D",
-            "eleTrkD0/D", "eleTrkZ0/D", "eleTrkEcalX/D", "eleTrkEcalY/D",
-            "eleHasL1/B", "eleHasL2/B",
-            "eleMatchChisq/D", "eleClT/D", "eleClE/D", "eleClHits/I",
-            "posPX/D", "posPY/D", "posPZ/D", "posP/D",
-            "posTrkChisq/D", "posTrkHits/I", "posTrkType/I", "posTrkT/D",
-            "posTrkD0/D", "posTrkZ0/D", "posTrkEcalX/D", "posTrkEcalY/D",
-            "posHasL1/B", "posHasL2/B",
-            "posMatchChisq/D", "posClT/D", "posClE/D", "posClHits/I",
-            "minL1Iso/D"
-        };
-    }
 
     public void setMaxChi2GBLTrack(double maxChi2GBLTrack) {
         this.maxChi2GBLTrack = maxChi2GBLTrack;
@@ -355,7 +327,11 @@
         this.beamPos[2] = beamPosY;
     }
 
-    double ebeam;
+    public void setEbeam(double ebeam) {
+        this.ebeam = ebeam;
+    }
+
+    private double ebeam = Double.NaN;
 
     @Override
     protected void detectorChanged(Detector detector) {
@@ -364,7 +340,9 @@
 
         BeamEnergyCollection beamEnergyCollection
                 = this.getConditionsManager().getCachedConditions(BeamEnergyCollection.class, "beam_energies").getCachedData();
-        ebeam = beamEnergyCollection.get(0).getBeamEnergy();
+        if (Double.isNaN(ebeam)) {
+            ebeam = beamEnergyCollection.get(0).getBeamEnergy();
+        }
         aida.tree().cd("/");
         String trkType = "SeedTrack/";
         if (isGBL) {
@@ -585,14 +563,18 @@
             Hep3Vector v0MomRot = VecOp.mult(beamAxisRotation, uncV0.getMomentum());
             Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, uncVert.getPosition());
 
-            List<Track> tracks = new ArrayList<Track>();
             ReconstructedParticle electron = uncV0.getParticles().get(ReconParticleDriver.ELECTRON);
             ReconstructedParticle positron = uncV0.getParticles().get(ReconParticleDriver.POSITRON);
             if (electron.getCharge() != -1 || positron.getCharge() != 1) {
                 throw new RuntimeException("incorrect charge on v0 daughters");
             }
-            tracks.add(electron.getTracks().get(0));
-            tracks.add(positron.getTracks().get(0));
+
+            Track eleTrack = electron.getTracks().get(0);
+            Track posTrack = positron.getTracks().get(0);
+
+            List<Track> tracks = new ArrayList<Track>();
+            tracks.add(eleTrack);
+            tracks.add(posTrack);
             if (tracks.size() != 2) {
                 throw new RuntimeException("expected two tracks in vertex, got " + tracks.size());
             }
@@ -612,22 +594,67 @@
             stdDev /= (hitTimes.size() - 1);
             stdDev = Math.sqrt(stdDev);
 
-            Double[] eleIso = TrackUtils.getIsolations(electron.getTracks().get(0), hitToStrips, hitToRotated);
-            Double[] posIso = TrackUtils.getIsolations(positron.getTracks().get(0), hitToStrips, hitToRotated);
-            double minL1Iso = -9999;
-            if (eleIso[0] != null && posIso[0] != null) {
-                double eleL1Iso = Math.min(Math.abs(eleIso[0]), Math.abs(eleIso[1]));
-                double posL1Iso = Math.min(Math.abs(posIso[0]), Math.abs(posIso[1]));
-                minL1Iso = Math.min(eleL1Iso, posL1Iso);
-            }
-
-            double tEle = TrackUtils.getTrackTime(electron.getTracks().get(0), hitToStrips, hitToRotated);
-            double tPos = TrackUtils.getTrackTime(positron.getTracks().get(0), hitToStrips, hitToRotated);
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, electron.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, positron.getMomentum());
-
-            Hep3Vector eleAtEcal = TrackUtils.getTrackPositionAtEcal(electron.getTracks().get(0));
-            Hep3Vector posAtEcal = TrackUtils.getTrackPositionAtEcal(positron.getTracks().get(0));
+            Double[] eleIso = TrackUtils.getIsolations(eleTrack, hitToStrips, hitToRotated);
+            Double[] posIso = TrackUtils.getIsolations(posTrack, hitToStrips, hitToRotated);
+            double minPositiveIso = 9999;
+            double minNegativeIso = 9999;
+//            double eleIsoStereo = -9999, eleIsoAxial = -9999;
+            for (int i = 0; i < 6; i++) {
+                if (eleIso[2 * i] != null) {
+//                    if (pEleRot.y() < 0) {
+//                        eleIsoStereo = eleIso[2 * i];
+//                        eleIsoAxial = eleIso[2 * i + 1];
+//                    } else {
+//                        eleIsoAxial = eleIso[2 * i];
+//                        eleIsoStereo = eleIso[2 * i + 1];
+//                    }
+                    for (int j = 2 * i; j < 2 * i + 2; j++) {
+                        if (eleIso[j] < 100) {
+                            if (eleIso[j] > 0) {
+                                if (minPositiveIso > 100 || eleIso[j] < minPositiveIso) {
+                                    minPositiveIso = eleIso[j];
+                                }
+                            } else {
+                                if (minNegativeIso > 100 || eleIso[j] > minNegativeIso) {
+                                    minNegativeIso = eleIso[j];
+                                }
+                            }
+                        }
+                    }
+                    break;
+                }
+            }
+//            double posIsoStereo = -9999, posIsoAxial = -9999;
+            for (int i = 0; i < 6; i++) {
+                if (posIso[2 * i] != null) {
+//                    if (pPosRot.y() < 0) {
+//                        posIsoStereo = posIso[2 * i];
+//                        posIsoAxial = posIso[2 * i + 1];
+//                    } else {
+//                        posIsoAxial = posIso[2 * i];
+//                        posIsoStereo = posIso[2 * i + 1];
+//                    }
+                    for (int j = 2 * i; j < 2 * i + 2; j++) {
+                        if (posIso[j] < 100) {
+                            if (posIso[j] > 0) {
+                                if (minPositiveIso > 100 || posIso[j] < minPositiveIso) {
+                                    minPositiveIso = posIso[j];
+                                }
+                            } else {
+                                if (minNegativeIso > 100 || posIso[j] > minNegativeIso) {
+                                    minNegativeIso = posIso[j];
+                                }
+                            }
+                        }
+                    }
+                    break;
+                }
+            }
+
+            double minIso = Math.min(Math.abs(minPositiveIso), Math.abs(minNegativeIso));
+
+            double tEle = TrackUtils.getTrackTime(eleTrack, hitToStrips, hitToRotated);
+            double tPos = TrackUtils.getTrackTime(posTrack, hitToStrips, hitToRotated);
 
             BilliorVertexer vtxFitter = new BilliorVertexer(TrackUtils.getBField(event.getDetector()).y());
             vtxFitter.setBeamSize(beamSize);
@@ -655,106 +682,6 @@
             Hep3Vector vzcMomRot = VecOp.mult(beamAxisRotation, vzcV0.getMomentum());
             Hep3Vector vzcVtx = VecOp.mult(beamAxisRotation, vzcV0.getStartVertex().getPosition());
 
-            if (tupleWriter != null) {
-                boolean trkCut = electron.getMomentum().magnitude() < tupleTrkPCut * ebeam && positron.getMomentum().magnitude() < tupleTrkPCut * ebeam;
-                boolean sumCut = electron.getMomentum().magnitude() + positron.getMomentum().magnitude() < tupleMaxSumCut * ebeam;
-                if (!cutTuple || (trkCut && sumCut)) {
-
-                    tupleMap.put("run/I", (double) event.getRunNumber());
-                    tupleMap.put("event/I", (double) event.getEventNumber());
-
-                    tupleMap.put("uncPX/D", v0MomRot.x());
-                    tupleMap.put("uncPY/D", v0MomRot.y());
-                    tupleMap.put("uncPZ/D", v0MomRot.z());
-                    tupleMap.put("uncP/D", v0MomRot.magnitude());
-                    tupleMap.put("uncVX/D", v0Vtx.x());
-                    tupleMap.put("uncVY/D", v0Vtx.y());
-                    tupleMap.put("uncVZ/D", v0Vtx.z());
-                    tupleMap.put("uncChisq/D", uncV0.getStartVertex().getChi2());
-                    tupleMap.put("uncM/D", uncV0.getMass());
-
-                    tupleMap.put("bscPX/D", bscMomRot.x());
-                    tupleMap.put("bscPY/D", bscMomRot.y());
-                    tupleMap.put("bscPZ/D", bscMomRot.z());
-                    tupleMap.put("bscP/D", bscMomRot.magnitude());
-                    tupleMap.put("bscVX/D", bscVtx.x());
-                    tupleMap.put("bscVY/D", bscVtx.y());
-                    tupleMap.put("bscVZ/D", bscVtx.z());
-                    tupleMap.put("bscChisq/D", bscV0.getStartVertex().getChi2());
-                    tupleMap.put("bscM/D", bscV0.getMass());
-
-                    tupleMap.put("tarPX/D", tarMomRot.x());
-                    tupleMap.put("tarPY/D", tarMomRot.y());
-                    tupleMap.put("tarPZ/D", tarMomRot.z());
-                    tupleMap.put("tarP/D", tarMomRot.magnitude());
-                    tupleMap.put("tarVX/D", tarVtx.x());
-                    tupleMap.put("tarVY/D", tarVtx.y());
-                    tupleMap.put("tarVZ/D", tarVtx.z());
-                    tupleMap.put("tarChisq/D", tarV0.getStartVertex().getChi2());
-                    tupleMap.put("tarM/D", tarV0.getMass());
-
-                    tupleMap.put("vzcPX/D", vzcMomRot.x());
-                    tupleMap.put("vzcPY/D", vzcMomRot.y());
-                    tupleMap.put("vzcPZ/D", vzcMomRot.z());
-                    tupleMap.put("vzcP/D", vzcMomRot.magnitude());
-                    tupleMap.put("vzcVX/D", vzcVtx.x());
-                    tupleMap.put("vzcVY/D", vzcVtx.y());
-                    tupleMap.put("vzcVZ/D", vzcVtx.z());
-                    tupleMap.put("vzcChisq/D", vzcV0.getStartVertex().getChi2());
-                    tupleMap.put("vzcM/D", vzcV0.getMass());
-
-                    tupleMap.put("elePX/D", pEleRot.x());
-                    tupleMap.put("elePY/D", pEleRot.y());
-                    tupleMap.put("elePZ/D", pEleRot.z());
-                    tupleMap.put("eleP/D", pEleRot.magnitude());
-                    tupleMap.put("eleTrkD0/D", electron.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("eleTrkZ0/D", electron.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("eleTrkEcalX/D", eleAtEcal.x());
-                    tupleMap.put("eleTrkEcalY/D", eleAtEcal.y());
-                    tupleMap.put("eleTrkChisq/D", electron.getTracks().get(0).getChi2());
-                    tupleMap.put("eleTrkHits/I", (double) electron.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("eleTrkType/I", (double) electron.getType());
-                    tupleMap.put("eleTrkT/D", tEle);
-                    tupleMap.put("eleHasL1/B", eleIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("eleHasL2/B", eleIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("eleMatchChisq/D", electron.getGoodnessOfPID());
-                    if (!electron.getClusters().isEmpty()) {
-                        Cluster eleC = electron.getClusters().get(0);
-                        tupleMap.put("eleClT/D", ClusterUtilities.getSeedHitTime(eleC));
-                        tupleMap.put("eleClE/D", eleC.getEnergy());
-                        tupleMap.put("eleClHits/I", (double) eleC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("posPX/D", pPosRot.x());
-                    tupleMap.put("posPY/D", pPosRot.y());
-                    tupleMap.put("posPZ/D", pPosRot.z());
-                    tupleMap.put("posP/D", pPosRot.magnitude());
-                    tupleMap.put("posTrkD0/D", positron.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("posTrkZ0/D", positron.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("posTrkEcalX/D", posAtEcal.x());
-                    tupleMap.put("posTrkEcalY/D", posAtEcal.y());
-                    tupleMap.put("posTrkChisq/D", positron.getTracks().get(0).getChi2());
-                    tupleMap.put("posTrkHits/I", (double) positron.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("posTrkType/I", (double) positron.getType());
-                    tupleMap.put("posTrkT/D", tPos);
-                    tupleMap.put("posHasL1/B", posIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("posHasL2/B", posIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("posMatchChisq/D", positron.getGoodnessOfPID());
-                    if (!positron.getClusters().isEmpty()) {
-                        Cluster posC = positron.getClusters().get(0);
-                        tupleMap.put("posClT/D", ClusterUtilities.getSeedHitTime(posC));
-                        tupleMap.put("posClE/D", posC.getEnergy());
-                        tupleMap.put("posClHits/I", (double) posC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("minL1Iso/D", minL1Iso);
-
-                    tupleMap.put("nTrk/I", (double) ntrk);
-                    tupleMap.put("nPos/I", (double) npos);
-                    writeTuple();
-                }
-            }
-
             //start applying cuts
             EnumSet<Cut> bits = EnumSet.noneOf(Cut.class);
 
@@ -804,7 +731,7 @@
                 bits.add(Cut.FRONT_HITS);
             }
 
-            boolean isoCut = minL1Iso > l1IsoMin;
+            boolean isoCut = minIso > l1IsoMin;
             if (!frontHitsCut || isoCut) { //diagnostic plots look better if failing the front hits cut makes you pass this one
                 bits.add(Cut.ISOLATION);
             }
@@ -827,8 +754,8 @@
                     if (uncV0.getMass() > plotsMinMass * ebeam && uncV0.getMass() < plotsMaxMass * ebeam && uncV0.getMomentum().magnitude() > radCut * ebeam) {
                         switch (cut) {
                             case ISOLATION:
-                                l1Iso.fill(minL1Iso);
-                                zVsL1Iso.fill(minL1Iso, v0Vtx.z());
+                                l1Iso.fill(minIso);
+                                zVsL1Iso.fill(minIso, v0Vtx.z());
                                 break;
                             case EVENT_QUALITY:
                                 eventTrkCount.fill(ntrk);

Copied: java/trunk/analysis/src/main/java/org/hps/analysis/tuple/FEETupleDriver.java (from r4342, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java)
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/tuple/FEETupleDriver.java	Tue May 24 18:30:43 2016
@@ -1,341 +1,22 @@
-package org.hps.analysis.dataquality;
+package org.hps.analysis.tuple;
 
-import hep.aida.IHistogram1D;
-import hep.aida.IHistogram2D;
-import hep.physics.vec.BasicHep3Matrix;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
-import java.util.ArrayList;
-import java.util.EnumSet;
 import java.util.List;
-import java.util.logging.Logger;
-import org.hps.conditions.beam.BeamEnergy.BeamEnergyCollection;
-import org.hps.recon.ecal.cluster.ClusterUtilities;
-import org.hps.recon.particle.HpsReconParticleDriver;
-import org.hps.recon.particle.ReconParticleDriver;
 import org.hps.recon.tracking.TrackType;
-import org.hps.recon.tracking.TrackUtils;
-import org.hps.recon.vertexing.BilliorTrack;
-import org.hps.recon.vertexing.BilliorVertex;
-import org.hps.recon.vertexing.BilliorVertexer;
-import org.lcsim.event.Cluster;
+import org.hps.record.triggerbank.AbstractIntData;
+import org.hps.record.triggerbank.TIData;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.ReconstructedParticle;
-import org.lcsim.event.RelationalTable;
-import org.lcsim.event.Track;
-import org.lcsim.event.Vertex;
-import org.lcsim.geometry.Detector;
 
-/**
- * DQM driver V0 particles (i.e. e+e- pars) plots things like number of vertex
- * position an mass
- *
- * @author mgraham on May 14, 2014
- *
- */
-public class MollerMonitoring extends DataQualityMonitor {
-
-    private enum Cut {
-
-        TRK_QUALITY("Trk Quality"),
-        VTX_QUALITY("Vtx Quality"),
-        VERTEX_CUTS("Vtx Cuts"),
-        TIMING("Timing"),
-        TRACK_CUTS("Trk Cuts"),
-        EVENT_QUALITY("Evt Quality"),
-        FRONT_HITS("Front Hits");
-        private final String name;
-        private final static int firstVertexingCut = 6;
-
-        Cut(String name) {
-            this.name = name;
-        }
-
-        static int bitmask(EnumSet<Cut> flags) {
-            int mask = 0;
-            for (Cut flag : flags) {
-                mask |= 1 << flag.ordinal();
-            }
-            return mask;
-        }
-
-        @Override
-        public String toString() {
-            return name;
-        }
-    }
-
-    private final static Logger LOGGER = Logger.getLogger(MollerMonitoring.class.getPackage().getName());
-
-    private final BasicHep3Matrix beamAxisRotation = new BasicHep3Matrix();
-//    private static final int nCuts = 9;
-//    private final String[] cutNames = {"Trk Quality",
-//        "V0 Quality",
-//        "V0 Vertex",
-//        "Timing",
-//        "Tracking",
-//        "Cluster",
-//        "Event",
-//        "Front Hits",
-//        "Isolation"};
-//    private int firstVertexingCut = 0;
+public class FEETupleDriver extends TupleDriver {
 
     private final String finalStateParticlesColName = "FinalStateParticles";
-    private final String unconstrainedV0CandidatesColName = "UnconstrainedMollerCandidates";
-//    private final String beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
-//    private final String targetV0ConCandidatesColName = "TargetConstrainedV0Candidates";
-//    private final String trackListName = "MatchedTracks";
-    private final String[] fpQuantNames = {"nV0_per_Event", "avg_BSCon_mass", "avg_BSCon_Vx", "avg_BSCon_Vy", "avg_BSCon_Vz", "sig_BSCon_Vx", "sig_BSCon_Vy", "sig_BSCon_Vz", "avg_BSCon_Chi2"};
+    private final double tupleTrkPCut = 0.7;
 
-    private final String plotDir = "MollerMonitoring/";
-
-//    private IHistogram2D triTrackTime2D;
-//    private IHistogram1D triTrackTimeDiff;
-    private IHistogram2D triMassMomentum;
-    private IHistogram2D triZVsMomentum;
-    private IHistogram2D triTrackMomentum2D;
-    private IHistogram2D triPyEleVsPyPos;
-    private IHistogram2D triPxEleVsPxPos;
-    private IHistogram1D triDeltaP;
-    private IHistogram1D triSumP;
-    private IHistogram1D triMass;
-    private IHistogram2D triZVsMass;
-//    private IHistogram1D triX;
-//    private IHistogram1D triY;
-//    private IHistogram1D triZ;
-//    private IHistogram2D triZY;
-//    private IHistogram2D triXY;
-    private IHistogram1D triPx;
-    private IHistogram1D triPy;
-    private IHistogram1D triPz;
-    private IHistogram2D triPxPy;
-    private IHistogram1D triU;
-    private IHistogram1D triV;
-
-//    private IHistogram2D vertTrackTime2D;
-//    private IHistogram1D vertTrackTimeDiff;
-    private IHistogram2D vertMassMomentum;
-    private IHistogram2D vertZVsMomentum;
-    private IHistogram2D vertTrackMomentum2D;
-    private IHistogram2D vertPyEleVsPyPos;
-    private IHistogram2D vertPxEleVsPxPos;
-    private IHistogram1D vertDeltaP;
-    private IHistogram1D vertSumP;
-    private IHistogram1D vertMass;
-    private IHistogram2D vertZVsMass;
-    private IHistogram1D vertX;
-    private IHistogram1D vertY;
-//    private IHistogram1D vertZ;
-    private IHistogram2D vertZY;
-    private IHistogram2D vertXY;
-    private IHistogram1D vertPx;
-    private IHistogram1D vertPy;
-    private IHistogram1D vertPz;
-    private IHistogram2D vertPxPy;
-    private IHistogram1D vertU;
-    private IHistogram1D vertV;
-
-    private IHistogram1D nTriCand;
-    private IHistogram1D nVtxCand;
-//    IHistogram1D vertexW;
-//    IHistogram2D vertexVZ;
-
-    //clean up event first
-    private final int nTrkMax = 5;
-    private final int nPosMax = 1;
-
-    private final double maxChi2SeedTrack = 7.0;
-    private double maxChi2GBLTrack = 15.0;
-    private double maxUnconVertChi2 = 10.0;
-    private double maxBsconVertChi2 = 1000.0; //disable by default
-
-    //v0 plot ranges
-    private final double v0PzMax = 1.25;//GeV 
-    private final double v0PzMin = 0.1;// GeV
-    private final double v0PyMax = 0.01;//GeV absolute value
-    private final double v0PxMax = 0.02;//GeV absolute value
-    private final double v0VzMax = 50.0;// mm from target...someday make mass dependent
-    private final double v0VyMax = 2.0;// mm from target...someday make mass dependent
-    private final double v0VxMax = 2.0;// mm from target...someday make mass dependent
-
-    //v0 cuts
-    private final double v0PzMaxCut = 1.25;//GeV 
-    private final double v0PzMinCut = 0.8;// GeV
-    private final double v0PyCut = 0.01;//GeV absolute value
-    private final double v0PxCut = 0.02;//GeV absolute value
-    private final double v0UnconVzCut = 50.0;// mm from target...someday make mass dependent
-    private double v0UnconVyCut = 10.0;// mm from target...someday make mass dependent
-    private double v0UnconVxCut = 10.0;// mm from target...someday make mass dependent
-    private double v0BsconVyCut = 10.0; //disable by default
-    private double v0BsconVxCut = 10.0; //disable by default
-
-//  track quality cuts
-    private final double maxTrkPCut = 0.85;
-//    private final double minTrkPCut = 0.05;
-//    private double trkPyMax = 0.2;
-//    private double trkPxMax = 0.2;
-    private final double trkTimeDiff = 5.0;
-//    private final double clusterTimeDiffCut = 2.5;
-
-    private final double tupleTrkPCut = 0.9;
-    private final double tupleMinSumCut = 0.7;
-    private final double tupleMaxSumCut = 1.3;
-
-//    private double l1IsoMin = 0.5;
-    private final double[] beamSize = {0.001, 0.130, 0.050}; //rough estimate from harp scans during engineering run production running
-    private final double[] beamPos = {0.0, 0.0, 0.0};
-    private final double[] vzcBeamSize = {0.001, 100, 100};
-
-    public MollerMonitoring() {
-        this.tupleVariables = new String[]{"run/I", "event/I",
-            "nTrk/I", "nPos/I",
-            "uncPX/D", "uncPY/D", "uncPZ/D", "uncP/D",
-            "uncVX/D", "uncVY/D", "uncVZ/D", "uncChisq/D", "uncM/D",
-            "bscPX/D", "bscPY/D", "bscPZ/D", "bscP/D",
-            "bscVX/D", "bscVY/D", "bscVZ/D", "bscChisq/D", "bscM/D",
-            "tarPX/D", "tarPY/D", "tarPZ/D", "tarP/D",
-            "tarVX/D", "tarVY/D", "tarVZ/D", "tarChisq/D", "tarM/D",
-            "vzcPX/D", "vzcPY/D", "vzcPZ/D", "vzcP/D",
-            "vzcVX/D", "vzcVY/D", "vzcVZ/D", "vzcChisq/D", "vzcM/D",
-            "topPX/D", "topPY/D", "topPZ/D", "topP/D",
-            "topTrkChisq/D", "topTrkHits/I", "topTrkType/I", "topTrkT/D",
-            "topTrkD0/D", "topTrkZ0/D", "topTrkEcalX/D", "topTrkEcalY/D",
-            "topHasL1/B", "topHasL2/B",
-            "topMatchChisq/D", "topClT/D", "topClE/D", "topClX/D", "topClY/D", "topClZ/D", "topClHits/I",
-            "botPX/D", "botPY/D", "botPZ/D", "botP/D",
-            "botTrkChisq/D", "botTrkHits/I", "botTrkType/I", "botTrkT/D",
-            "botTrkD0/D", "botTrkZ0/D", "botTrkEcalX/D", "botTrkEcalY/D",
-            "botHasL1/B", "botHasL2/B",
-            "botMatchChisq/D", "botClT/D", "botClE/D", "botClX/D", "botClY/D", "botClZ/D", "botClHits/I",
-            "minL1Iso/D"
-        };
-    }
-
-    public void setMaxChi2GBLTrack(double maxChi2GBLTrack) {
-        this.maxChi2GBLTrack = maxChi2GBLTrack;
-    }
-
-    public void setMaxUnconVertChi2(double maxUnconVertChi2) {
-        this.maxUnconVertChi2 = maxUnconVertChi2;
-    }
-
-    public void setMaxBsconVertChi2(double maxBsconVertChi2) {
-        this.maxBsconVertChi2 = maxBsconVertChi2;
-    }
-
-    public void setV0UnconVyCut(double v0UnconVyCut) {
-        this.v0UnconVyCut = v0UnconVyCut;
-    }
-
-    public void setV0UnconVxCut(double v0UnconVxCut) {
-        this.v0UnconVxCut = v0UnconVxCut;
-    }
-
-    public void setV0BsconVyCut(double v0BsconVyCut) {
-        this.v0BsconVyCut = v0BsconVyCut;
-    }
-
-    public void setV0BsconVxCut(double v0BsconVxCut) {
-        this.v0BsconVxCut = v0BsconVxCut;
-    }
-
-    public void setBeamSizeX(double beamSizeX) {
-        this.beamSize[1] = beamSizeX;
-    }
-
-    public void setBeamSizeY(double beamSizeY) {
-        this.beamSize[2] = beamSizeY;
-    }
-
-    public void setBeamPosX(double beamPosX) {
-        this.beamPos[1] = beamPosX;
-    }
-
-    public void setBeamPosY(double beamPosY) {
-        this.beamPos[2] = beamPosY;
-    }
-
-    double ebeam;
-
-    @Override
-    protected void detectorChanged(Detector detector) {
-        LOGGER.info("MollerMonitoring::detectorChanged  Setting up the plotter");
-        beamAxisRotation.setActiveEuler(Math.PI / 2, -0.0305, -Math.PI / 2);
-
-        BeamEnergyCollection beamEnergyCollection
-                = this.getConditionsManager().getCachedConditions(BeamEnergyCollection.class, "beam_energies").getCachedData();
-        ebeam = beamEnergyCollection.get(0).getBeamEnergy();
-        aida.tree().cd("/");
-        String trkType = "SeedTrack/";
-        if (isGBL) {
-            trkType = "GBLTrack/";
-        }
-        /*  V0 Quantities   */
-        /*  Mass, vertex, chi^2 of fit */
-        /* beamspot constrained */
-//        IHistogram1D nV0 = aida.histogram1D(plotDir +  triggerType + "/"+"Number of V0 per event", 10, 0, 10);
-//        IHistogram1D bsconMass = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Mass (GeV)", 100, 0, 0.200);
-//        IHistogram1D bsconVx = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vx (mm)", 50, -1, 1);
-//        IHistogram1D bsconVy = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vy (mm)", 50, -1, 1);
-//        IHistogram1D bsconVz = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vz (mm)", 50, -10, 10);
-//        IHistogram1D bsconChi2 = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Chi2", 25, 0, 25);
-//        /* target constrained */
-//        IHistogram1D tarconMass = aida.histogram1D(plotDir +  triggerType + "/"+"Target Constrained Mass (GeV)", 100, 0, 0.200);
-//        IHistogram1D tarconVx = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vx (mm)", 50, -1, 1);
-//        IHistogram1D tarconVy = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vy (mm)", 50, -1, 1);
-//        IHistogram1D tarconVz = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vz (mm)", 50, -10, 10);
-//        IHistogram1D tarconChi2 = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Chi2", 25, 0, 25);
-        nTriCand = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Number of Moller Candidates", 5, 0, 4);
-
-//        triTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Track time difference", 100, -10, 10);
-//        triTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-        triTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Bottom vs. top momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        triDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Moller: Bottom - top momentum", 100, -ebeam, ebeam);
-        triSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Moller: Bottom + top momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        triPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Py(t) vs Py(b)", 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam, 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam);
-        triPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Px(t) vs Px(b)", 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam, 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam);
-
-        triMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Vertex mass vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, 0, 0.1 * ebeam);
-        triZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Vertex Z vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, -v0VzMax, v0VzMax);
-        triMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Moller: Vertex mass", 100, 0, 0.1 * ebeam);
-        triZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-//        triX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex X", 100, -v0VxMax, v0VxMax);
-//        triY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Y", 100, -v0VyMax, v0VyMax);
-//        triZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z", 100, -v0VzMax, v0VzMax);
-//        triXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-//        triZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-        triPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Px", 100, -v0PxMax, v0PxMax);
-        triPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py", 100, -v0PyMax, v0PyMax);
-        triPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Pz", 100, v0PzMin, v0PzMax);
-        triPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py vs. Px", 100, -v0PxMax, v0PxMax, 100, -v0PyMax, v0PyMax);
-        triU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Px over Ptot", 100, -0.1, 0.1);
-        triV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-//        vertTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Track time difference", 100, -10, 10);
-//        vertTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-        vertTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Bottom vs. top momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        vertDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Bottom - top momentum", 100, -ebeam, ebeam);
-        vertSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Bottom + top momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        vertPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Py(t) vs Py(b)", 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam, 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam);
-        vertPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Px(t) vs Px(b)", 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam, 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam);
-
-        vertMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex mass vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, 0, 0.1 * ebeam);
-        vertZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, -v0VzMax, v0VzMax);
-        vertMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex mass", 100, 0, 0.1 * ebeam);
-        vertZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-        vertX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex X", 100, -v0VxMax, v0VxMax);
-        vertY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Y", 100, -v0VyMax, v0VyMax);
-//        vertZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z", 100, -v0VzMax, v0VzMax);
-        vertXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-        vertZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-        vertPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Px", 100, -v0PxMax, v0PxMax);
-        vertPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py", 100, -v0PyMax, v0PyMax);
-        vertPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Pz", 100, v0PzMin, v0PzMax);
-        vertPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py vs. Px", 100, -v0PxMax, v0PxMax, 100, -v0PyMax, v0PyMax);
-        vertU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Px over Ptot", 100, -0.1, 0.1);
-        vertV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-        nVtxCand = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Number of Vertexing Candidates", 5, 0, 4);
+    public FEETupleDriver() {
+        tupleVariables.clear();
+        addEventVariables();
+        addParticleVariables("fsp");
     }
 
     @Override
@@ -344,365 +25,37 @@
         if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) {
             return;
         }
-        if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName)) {
-            return;
+        TIData triggerData = null;
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            for (GenericObject data : event.get(GenericObject.class, "TriggerBank")) {
+                if (AbstractIntData.getTag(data) == TIData.BANK_TAG) {
+                    triggerData = new TIData(data);
+                }
+            }
         }
-//        if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName)) {
-//            return;
-//        }
-//        if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName)) {
-//            return;
-//        }
 
         //check to see if this event is from the correct trigger (or "all");
-        if (!matchTrigger(event)) {
+        if (triggerData != null && !matchTriggerType(triggerData)) {
             return;
         }
 
-        List<ReconstructedParticle> unConstrainedV0List = event.get(ReconstructedParticle.class, unconstrainedV0CandidatesColName);
+        List<ReconstructedParticle> fspList = event.get(ReconstructedParticle.class, finalStateParticlesColName);
 
-        RelationalTable hitToStrips = TrackUtils.getHitToStripsTable(event);
-        RelationalTable hitToRotated = TrackUtils.getHitToRotatedTable(event);
-
-        List<ReconstructedParticle> fspList = event.get(ReconstructedParticle.class, finalStateParticlesColName);
-        int npos = 0;
-        int ntrk = 0;
         for (ReconstructedParticle fsp : fspList) {
             if (isGBL != TrackType.isGBL(fsp.getType())) {
                 continue;
             }
-            if (fsp.getCharge() != 0) {
-                ntrk++;
-            }
-            if (fsp.getCharge() > 0) {
-                npos++;
-            }
-        }
+            tupleMap.clear();
+            fillEventVariables(event, triggerData);
 
-        List<ReconstructedParticle> candidateList = new ArrayList<>();
-        List<ReconstructedParticle> vertCandidateList = new ArrayList<>();
-        for (ReconstructedParticle uncV0 : unConstrainedV0List) {
-            if (isGBL != TrackType.isGBL(uncV0.getType())) {
-                continue;
-            }
-            Vertex uncVert = uncV0.getStartVertex();
-//  v0 & vertex-quality cuts
-            Hep3Vector v0MomRot = VecOp.mult(beamAxisRotation, uncV0.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, uncVert.getPosition());
-
-            List<Track> tracks = new ArrayList<Track>();
-            ReconstructedParticle top = uncV0.getParticles().get(ReconParticleDriver.MOLLER_TOP);
-            ReconstructedParticle bot = uncV0.getParticles().get(ReconParticleDriver.MOLLER_BOT);
-            if (top.getCharge() != -1 || bot.getCharge() != -1) {
-                throw new RuntimeException("incorrect charge on v0 daughters");
-            }
-            tracks.add(top.getTracks().get(0));
-            tracks.add(bot.getTracks().get(0));
-            if (tracks.size() != 2) {
-                throw new RuntimeException("expected two tracks in vertex, got " + tracks.size());
-            }
-
-            Double[] topIso = TrackUtils.getIsolations(top.getTracks().get(0), hitToStrips, hitToRotated);
-            Double[] botIso = TrackUtils.getIsolations(bot.getTracks().get(0), hitToStrips, hitToRotated);
-            double minL1Iso = -9999;
-            if (topIso[0] != null && botIso[0] != null) {
-                double topL1Iso = Math.min(Math.abs(topIso[0]), Math.abs(topIso[1]));
-                double botL1Iso = Math.min(Math.abs(botIso[0]), Math.abs(botIso[1]));
-                minL1Iso = Math.min(topL1Iso, botL1Iso);
-            }
-
-            double tTop = TrackUtils.getTrackTime(top.getTracks().get(0), hitToStrips, hitToRotated);
-            double tBot = TrackUtils.getTrackTime(bot.getTracks().get(0), hitToStrips, hitToRotated);
-            Hep3Vector pTopRot = VecOp.mult(beamAxisRotation, top.getMomentum());
-            Hep3Vector pBotRot = VecOp.mult(beamAxisRotation, bot.getMomentum());
-
-            Hep3Vector topAtEcal = TrackUtils.getTrackPositionAtEcal(top.getTracks().get(0));
-            Hep3Vector botAtEcal = TrackUtils.getTrackPositionAtEcal(bot.getTracks().get(0));
-
-            BilliorVertexer vtxFitter = new BilliorVertexer(TrackUtils.getBField(event.getDetector()).y());
-            vtxFitter.setBeamSize(beamSize);
-            vtxFitter.setBeamPosition(beamPos);
-            List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
-            billiorTracks.add(new BilliorTrack(top.getTracks().get(0)));
-            billiorTracks.add(new BilliorTrack(bot.getTracks().get(0)));
-
-            vtxFitter.doBeamSpotConstraint(true);
-            BilliorVertex bsconVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle bscV0 = HpsReconParticleDriver.makeReconstructedParticle(top, bot, bsconVertex);
-            Hep3Vector bscMomRot = VecOp.mult(beamAxisRotation, bscV0.getMomentum());
-            Hep3Vector bscVtx = VecOp.mult(beamAxisRotation, bscV0.getStartVertex().getPosition());
-
-            vtxFitter.doTargetConstraint(true);
-            BilliorVertex tarVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle tarV0 = HpsReconParticleDriver.makeReconstructedParticle(top, bot, tarVertex);
-            Hep3Vector tarMomRot = VecOp.mult(beamAxisRotation, tarV0.getMomentum());
-            Hep3Vector tarVtx = VecOp.mult(beamAxisRotation, tarV0.getStartVertex().getPosition());
-
-            vtxFitter.setBeamSize(vzcBeamSize);
-            vtxFitter.doTargetConstraint(true);
-            BilliorVertex vzcVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle vzcV0 = HpsReconParticleDriver.makeReconstructedParticle(top, bot, vzcVertex);
-            Hep3Vector vzcMomRot = VecOp.mult(beamAxisRotation, vzcV0.getMomentum());
-            Hep3Vector vzcVtx = VecOp.mult(beamAxisRotation, vzcV0.getStartVertex().getPosition());
+            fillParticleVariables(event, fsp, "fsp");
 
             if (tupleWriter != null) {
-                boolean trkCut = top.getMomentum().magnitude() < tupleTrkPCut * ebeam && bot.getMomentum().magnitude() < tupleTrkPCut * ebeam;
-                boolean sumCut = top.getMomentum().magnitude() + bot.getMomentum().magnitude() > tupleMinSumCut * ebeam && top.getMomentum().magnitude() + bot.getMomentum().magnitude() < tupleMaxSumCut * ebeam;
-
-                if (!cutTuple || (trkCut && sumCut)) {
-
-                    tupleMap.put("run/I", (double) event.getRunNumber());
-                    tupleMap.put("event/I", (double) event.getEventNumber());
-
-                    tupleMap.put("uncPX/D", v0MomRot.x());
-                    tupleMap.put("uncPY/D", v0MomRot.y());
-                    tupleMap.put("uncPZ/D", v0MomRot.z());
-                    tupleMap.put("uncP/D", v0MomRot.magnitude());
-                    tupleMap.put("uncVX/D", v0Vtx.x());
-                    tupleMap.put("uncVY/D", v0Vtx.y());
-                    tupleMap.put("uncVZ/D", v0Vtx.z());
-                    tupleMap.put("uncChisq/D", uncV0.getStartVertex().getChi2());
-                    tupleMap.put("uncM/D", uncV0.getMass());
-
-                    tupleMap.put("bscPX/D", bscMomRot.x());
-                    tupleMap.put("bscPY/D", bscMomRot.y());
-                    tupleMap.put("bscPZ/D", bscMomRot.z());
-                    tupleMap.put("bscP/D", bscMomRot.magnitude());
-                    tupleMap.put("bscVX/D", bscVtx.x());
-                    tupleMap.put("bscVY/D", bscVtx.y());
-                    tupleMap.put("bscVZ/D", bscVtx.z());
-                    tupleMap.put("bscChisq/D", bscV0.getStartVertex().getChi2());
-                    tupleMap.put("bscM/D", bscV0.getMass());
-
-                    tupleMap.put("tarPX/D", tarMomRot.x());
-                    tupleMap.put("tarPY/D", tarMomRot.y());
-                    tupleMap.put("tarPZ/D", tarMomRot.z());
-                    tupleMap.put("tarP/D", tarMomRot.magnitude());
-                    tupleMap.put("tarVX/D", tarVtx.x());
-                    tupleMap.put("tarVY/D", tarVtx.y());
-                    tupleMap.put("tarVZ/D", tarVtx.z());
-                    tupleMap.put("tarChisq/D", tarV0.getStartVertex().getChi2());
-                    tupleMap.put("tarM/D", tarV0.getMass());
-
-                    tupleMap.put("vzcPX/D", vzcMomRot.x());
-                    tupleMap.put("vzcPY/D", vzcMomRot.y());
-                    tupleMap.put("vzcPZ/D", vzcMomRot.z());
-                    tupleMap.put("vzcP/D", vzcMomRot.magnitude());
-                    tupleMap.put("vzcVX/D", vzcVtx.x());
-                    tupleMap.put("vzcVY/D", vzcVtx.y());
-                    tupleMap.put("vzcVZ/D", vzcVtx.z());
-                    tupleMap.put("vzcChisq/D", vzcV0.getStartVertex().getChi2());
-                    tupleMap.put("vzcM/D", vzcV0.getMass());
-
-                    tupleMap.put("topPX/D", pTopRot.x());
-                    tupleMap.put("topPY/D", pTopRot.y());
-                    tupleMap.put("topPZ/D", pTopRot.z());
-                    tupleMap.put("topP/D", pTopRot.magnitude());
-                    tupleMap.put("topTrkD0/D", top.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("topTrkZ0/D", top.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("topTrkEcalX/D", topAtEcal.x());
-                    tupleMap.put("topTrkEcalY/D", topAtEcal.y());
-                    tupleMap.put("topTrkChisq/D", top.getTracks().get(0).getChi2());
-                    tupleMap.put("topTrkHits/I", (double) top.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("topTrkType/I", (double) top.getType());
-                    tupleMap.put("topTrkT/D", tTop);
-                    tupleMap.put("topHasL1/B", topIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("topHasL2/B", topIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("topMatchChisq/D", top.getGoodnessOfPID());
-                    if (!top.getClusters().isEmpty()) {
-                        Cluster topC = top.getClusters().get(0);
-                        tupleMap.put("topClT/D", ClusterUtilities.getSeedHitTime(topC));
-                        tupleMap.put("topClE/D", topC.getEnergy());
-                        tupleMap.put("topClX/D", topC.getPosition()[0]);
-                        tupleMap.put("topClY/D", topC.getPosition()[1]);
-                        tupleMap.put("topClZ/D", topC.getPosition()[2]);
-                        tupleMap.put("topClHits/I", (double) topC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("botPX/D", pBotRot.x());
-                    tupleMap.put("botPY/D", pBotRot.y());
-                    tupleMap.put("botPZ/D", pBotRot.z());
-                    tupleMap.put("botP/D", pBotRot.magnitude());
-                    tupleMap.put("botTrkD0/D", bot.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("botTrkZ0/D", bot.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("botTrkEcalX/D", botAtEcal.x());
-                    tupleMap.put("botTrkEcalY/D", botAtEcal.y());
-                    tupleMap.put("botTrkChisq/D", bot.getTracks().get(0).getChi2());
-                    tupleMap.put("botTrkHits/I", (double) bot.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("botTrkType/I", (double) bot.getType());
-                    tupleMap.put("botTrkT/D", tBot);
-                    tupleMap.put("botHasL1/B", botIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("botHasL2/B", botIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("botMatchChisq/D", bot.getGoodnessOfPID());
-                    if (!bot.getClusters().isEmpty()) {
-                        Cluster botC = bot.getClusters().get(0);
-                        tupleMap.put("botClT/D", ClusterUtilities.getSeedHitTime(botC));
-                        tupleMap.put("botClE/D", botC.getEnergy());
-                        tupleMap.put("botClHits/I", (double) botC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("minL1Iso/D", minL1Iso);
-
-                    tupleMap.put("nTrk/I", (double) ntrk);
-                    tupleMap.put("nPos/I", (double) npos);
+                boolean trkCut = tupleMap.get("fspP/D") > tupleTrkPCut * ebeam;
+                if (!cutTuple || (trkCut)) {
                     writeTuple();
                 }
             }
-
-            //start applying cuts
-            EnumSet<Cut> bits = EnumSet.noneOf(Cut.class);
-
-            boolean trackQualityCut = Math.max(top.getTracks().get(0).getChi2(), bot.getTracks().get(0).getChi2()) < (isGBL ? maxChi2GBLTrack : maxChi2SeedTrack);
-            if (trackQualityCut) {
-                bits.add(Cut.TRK_QUALITY);
-            }
-
-            boolean v0QualityCut = uncVert.getChi2() < maxUnconVertChi2 && bsconVertex.getChi2() < maxBsconVertChi2;
-            if (v0QualityCut) {
-                bits.add(Cut.VTX_QUALITY);
-            }
-
-            boolean vertexMomentumCut = v0MomRot.z() < v0PzMaxCut * ebeam && v0MomRot.z() > v0PzMinCut * ebeam && Math.abs(v0MomRot.x()) < v0PxCut * ebeam && Math.abs(v0MomRot.y()) < v0PyCut * ebeam;
-            boolean vertexPositionCut = Math.abs(v0Vtx.x()) < v0UnconVxCut && Math.abs(v0Vtx.y()) < v0UnconVyCut && Math.abs(v0Vtx.z()) < v0UnconVzCut && Math.abs(bscVtx.x()) < v0BsconVxCut && Math.abs(bscVtx.y()) < v0BsconVyCut;
-            if (vertexMomentumCut && vertexPositionCut) {
-                bits.add(Cut.VERTEX_CUTS);
-            }
-
-            boolean trackTimeDiffCut = Math.abs(tTop - tBot) < trkTimeDiff;
-            if (trackTimeDiffCut) {
-                bits.add(Cut.TIMING);
-            }
-
-//            boolean topBottomCut = top.getMomentum().y() * bot.getMomentum().y() < 0;
-//            boolean pMinCut = top.getMomentum().magnitude() > minTrkPCut * ebeam && bot.getMomentum().magnitude() > minTrkPCut * ebeam;
-            boolean pMaxCut = top.getMomentum().magnitude() < maxTrkPCut * ebeam && bot.getMomentum().magnitude() < maxTrkPCut * ebeam;
-//            boolean pSumCut = top.getMomentum().magnitude() + bot.getMomentum().magnitude() < maxPSumCut * ebeam && top.getMomentum().magnitude() + bot.getMomentum().magnitude() < minPSumCut * ebeam;
-//            boolean pMaxCut = top.getMomentum().magnitude() < maxTrkPCut * ebeam && bot.getMomentum().magnitude() < maxTrkPCut * ebeam;
-            if (pMaxCut) {
-                bits.add(Cut.TRACK_CUTS);
-            }
-
-            boolean eventTrkCountCut = ntrk >= 2 && ntrk <= nTrkMax;
-            boolean eventPosCountCut = npos >= 1 && npos <= nPosMax;
-            if (eventTrkCountCut && eventPosCountCut) {
-                bits.add(Cut.EVENT_QUALITY);
-            }
-
-            boolean frontHitsCut = topIso[0] != null && botIso[0] != null && topIso[2] != null && botIso[2] != null;
-            if (frontHitsCut) {
-                bits.add(Cut.FRONT_HITS);
-            }
-
-            for (Cut cut : Cut.values()) {
-                if (bits.contains(cut)) {
-                    if (cut.ordinal() == Cut.firstVertexingCut) {//if we get here, we've passed all non-vertexing cuts
-                        candidateList.add(uncV0);
-                    }
-                } else {
-                    break;
-                }
-            }
-
-            if (bits.containsAll(EnumSet.range(Cut.values()[0], Cut.values()[Cut.firstVertexingCut - 1]))) {
-                candidateList.add(uncV0);
-            }
-            if (bits.equals(EnumSet.allOf(Cut.class))) {
-                vertCandidateList.add(uncV0);
-            }
-        }
-
-        nTriCand.fill(candidateList.size());
-        nVtxCand.fill(vertCandidateList.size());
-
-        if (!candidateList.isEmpty()) {
-            // pick the best candidate...for now just pick a random one. 
-            ReconstructedParticle bestCandidate = candidateList.get((int) (Math.random() * candidateList.size()));
-
-            //fill some stuff: 
-            ReconstructedParticle top = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_TOP);
-            ReconstructedParticle bot = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_BOT);
-            if (top.getCharge() != -1 || bot.getCharge() != -1) {
-                throw new RuntimeException("vertex needs two e- but is missing one or both");
-            }
-
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, top.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, bot.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, bestCandidate.getStartVertex().getPosition());
-            Hep3Vector pBestV0Rot = VecOp.mult(beamAxisRotation, bestCandidate.getMomentum());
-
-//            triTrackTime2D.fill(tEle, tPos);
-//            triTrackTimeDiff.fill(tEle - tPos);
-            triZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-            triMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-            triTrackMomentum2D.fill(top.getMomentum().magnitude(), bot.getMomentum().magnitude());
-            triPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-            triPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-            triSumP.fill(bestCandidate.getMomentum().magnitude());
-            triDeltaP.fill(bot.getMomentum().magnitude() - top.getMomentum().magnitude());
-
-            triPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-            triMass.fill(bestCandidate.getMass());
-            triZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-//            triX.fill(v0Vtx.x());
-//            triY.fill(v0Vtx.y());
-//            triZ.fill(v0Vtx.z());
-            triPx.fill(pBestV0Rot.x());
-            triPy.fill(pBestV0Rot.y());
-            triPz.fill(pBestV0Rot.z());
-            triU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-            triV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-//            triXY.fill(v0Vtx.x(), v0Vtx.y());
-//            triZY.fill(v0Vtx.y(), v0Vtx.z());
-        }
-
-        if (!vertCandidateList.isEmpty()) {
-            // pick the best candidate...for now just pick a random one. 
-            ReconstructedParticle bestCandidate = vertCandidateList.get((int) (Math.random() * vertCandidateList.size()));
-            Vertex unconVertex = bestCandidate.getStartVertex();
-
-            //fill some stuff: 
-            ReconstructedParticle top = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_TOP);
-            ReconstructedParticle bot = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_BOT);
-            if (top.getCharge() != -1 || bot.getCharge() != -1) {
-                throw new RuntimeException("vertex needs two e- but is missing one or both");
-            }
-
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, top.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, bot.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, unconVertex.getPosition());
-            Hep3Vector pBestV0Rot = VecOp.mult(beamAxisRotation, bestCandidate.getMomentum());
-
-//            vertTrackTime2D.fill(tEle, tPos);
-//            vertTrackTimeDiff.fill(tEle - tPos);
-            vertZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-            vertMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-            vertTrackMomentum2D.fill(top.getMomentum().magnitude(), bot.getMomentum().magnitude());
-            vertPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-            vertPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-            vertSumP.fill(bestCandidate.getMomentum().magnitude());
-            vertDeltaP.fill(bot.getMomentum().magnitude() - top.getMomentum().magnitude());
-
-            vertPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-            vertMass.fill(bestCandidate.getMass());
-            vertZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-            vertX.fill(v0Vtx.x());
-            vertY.fill(v0Vtx.y());
-//            vertZ.fill(v0Vtx.z());
-            vertPx.fill(pBestV0Rot.x());
-            vertPy.fill(pBestV0Rot.y());
-            vertPz.fill(pBestV0Rot.z());
-            vertU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-            vertV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-            vertXY.fill(v0Vtx.x(), v0Vtx.y());
-            vertZY.fill(v0Vtx.y(), v0Vtx.z());
-        }
-    }
-
-    @Override
-    public void printDQMStrings() {
-        for (int i = 0; i < 9; i++)//TODO:  do this in a smarter way...loop over the map
-        {
-            LOGGER.info("ALTER TABLE dqm ADD " + fpQuantNames[i] + " double;");
         }
     }
 }

Copied: java/trunk/analysis/src/main/java/org/hps/analysis/tuple/MollerTupleDriver.java (from r4372, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java)
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/MollerMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/tuple/MollerTupleDriver.java	Tue May 24 18:30:43 2016
@@ -1,708 +1,101 @@
-package org.hps.analysis.dataquality;
+package org.hps.analysis.tuple;
 
-import hep.aida.IHistogram1D;
-import hep.aida.IHistogram2D;
-import hep.physics.vec.BasicHep3Matrix;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
 import java.util.ArrayList;
-import java.util.EnumSet;
+import java.util.Arrays;
 import java.util.List;
-import java.util.logging.Logger;
-import org.hps.conditions.beam.BeamEnergy.BeamEnergyCollection;
-import org.hps.recon.ecal.cluster.ClusterUtilities;
-import org.hps.recon.particle.HpsReconParticleDriver;
 import org.hps.recon.particle.ReconParticleDriver;
 import org.hps.recon.tracking.TrackType;
-import org.hps.recon.tracking.TrackUtils;
 import org.hps.recon.vertexing.BilliorTrack;
-import org.hps.recon.vertexing.BilliorVertex;
-import org.hps.recon.vertexing.BilliorVertexer;
-import org.lcsim.event.Cluster;
+import org.hps.record.triggerbank.AbstractIntData;
+import org.hps.record.triggerbank.TIData;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.ReconstructedParticle;
-import org.lcsim.event.RelationalTable;
 import org.lcsim.event.Track;
-import org.lcsim.event.Vertex;
-import org.lcsim.geometry.Detector;
+import org.lcsim.event.TrackState;
 
-/**
- * DQM driver V0 particles (i.e. e+e- pars) plots things like number of vertex
- * position an mass
- *
- * @author mgraham on May 14, 2014
- *
- */
-public class MollerMonitoring extends DataQualityMonitor {
+public class MollerTupleDriver extends TupleDriver {
 
-    private enum Cut {
-
-        TRK_QUALITY("Trk Quality"),
-        VTX_QUALITY("Vtx Quality"),
-        VERTEX_CUTS("Vtx Cuts"),
-        TIMING("Timing"),
-        TRACK_CUTS("Trk Cuts"),
-        EVENT_QUALITY("Evt Quality"),
-        FRONT_HITS("Front Hits");
-        private final String name;
-        private final static int firstVertexingCut = 6;
-
-        Cut(String name) {
-            this.name = name;
-        }
-
-        static int bitmask(EnumSet<Cut> flags) {
-            int mask = 0;
-            for (Cut flag : flags) {
-                mask |= 1 << flag.ordinal();
-            }
-            return mask;
-        }
-
-        @Override
-        public String toString() {
-            return name;
-        }
-    }
-
-    private final static Logger LOGGER = Logger.getLogger(MollerMonitoring.class.getPackage().getName());
-
-    private final BasicHep3Matrix beamAxisRotation = new BasicHep3Matrix();
-//    private static final int nCuts = 9;
-//    private final String[] cutNames = {"Trk Quality",
-//        "V0 Quality",
-//        "V0 Vertex",
-//        "Timing",
-//        "Tracking",
-//        "Cluster",
-//        "Event",
-//        "Front Hits",
-//        "Isolation"};
-//    private int firstVertexingCut = 0;
-
-    private final String finalStateParticlesColName = "FinalStateParticles";
     private final String unconstrainedV0CandidatesColName = "UnconstrainedMollerCandidates";
-//    private final String beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
-//    private final String targetV0ConCandidatesColName = "TargetConstrainedV0Candidates";
-//    private final String trackListName = "MatchedTracks";
-    private final String[] fpQuantNames = {"nV0_per_Event", "avg_BSCon_mass", "avg_BSCon_Vx", "avg_BSCon_Vy", "avg_BSCon_Vz", "sig_BSCon_Vx", "sig_BSCon_Vy", "sig_BSCon_Vz", "avg_BSCon_Chi2"};
-
-    private final String plotDir = "MollerMonitoring/";
-
-//    private IHistogram2D triTrackTime2D;
-//    private IHistogram1D triTrackTimeDiff;
-    private IHistogram2D triMassMomentum;
-    private IHistogram2D triZVsMomentum;
-    private IHistogram2D triTrackMomentum2D;
-    private IHistogram2D triPyEleVsPyPos;
-    private IHistogram2D triPxEleVsPxPos;
-    private IHistogram1D triDeltaP;
-    private IHistogram1D triSumP;
-    private IHistogram1D triMass;
-    private IHistogram2D triZVsMass;
-//    private IHistogram1D triX;
-//    private IHistogram1D triY;
-//    private IHistogram1D triZ;
-//    private IHistogram2D triZY;
-//    private IHistogram2D triXY;
-    private IHistogram1D triPx;
-    private IHistogram1D triPy;
-    private IHistogram1D triPz;
-    private IHistogram2D triPxPy;
-    private IHistogram1D triU;
-    private IHistogram1D triV;
-
-//    private IHistogram2D vertTrackTime2D;
-//    private IHistogram1D vertTrackTimeDiff;
-    private IHistogram2D vertMassMomentum;
-    private IHistogram2D vertZVsMomentum;
-    private IHistogram2D vertTrackMomentum2D;
-    private IHistogram2D vertPyEleVsPyPos;
-    private IHistogram2D vertPxEleVsPxPos;
-    private IHistogram1D vertDeltaP;
-    private IHistogram1D vertSumP;
-    private IHistogram1D vertMass;
-    private IHistogram2D vertZVsMass;
-    private IHistogram1D vertX;
-    private IHistogram1D vertY;
-//    private IHistogram1D vertZ;
-    private IHistogram2D vertZY;
-    private IHistogram2D vertXY;
-    private IHistogram1D vertPx;
-    private IHistogram1D vertPy;
-    private IHistogram1D vertPz;
-    private IHistogram2D vertPxPy;
-    private IHistogram1D vertU;
-    private IHistogram1D vertV;
-
-    private IHistogram1D nTriCand;
-    private IHistogram1D nVtxCand;
-//    IHistogram1D vertexW;
-//    IHistogram2D vertexVZ;
-
-    //clean up event first
-    private final int nTrkMax = 5;
-    private final int nPosMax = 1;
-
-    private final double maxChi2SeedTrack = 7.0;
-    private double maxChi2GBLTrack = 15.0;
-    private double maxUnconVertChi2 = 10.0;
-    private double maxBsconVertChi2 = 1000.0; //disable by default
-
-    //v0 plot ranges
-    private final double v0PzMax = 1.25;//GeV 
-    private final double v0PzMin = 0.1;// GeV
-    private final double v0PyMax = 0.01;//GeV absolute value
-    private final double v0PxMax = 0.02;//GeV absolute value
-    private final double v0VzMax = 50.0;// mm from target...someday make mass dependent
-    private final double v0VyMax = 2.0;// mm from target...someday make mass dependent
-    private final double v0VxMax = 2.0;// mm from target...someday make mass dependent
-
-    //v0 cuts
-    private final double v0PzMaxCut = 1.25;//GeV 
-    private final double v0PzMinCut = 0.8;// GeV
-    private final double v0PyCut = 0.01;//GeV absolute value
-    private final double v0PxCut = 0.02;//GeV absolute value
-    private final double v0UnconVzCut = 50.0;// mm from target...someday make mass dependent
-    private double v0UnconVyCut = 10.0;// mm from target...someday make mass dependent
-    private double v0UnconVxCut = 10.0;// mm from target...someday make mass dependent
-    private double v0BsconVyCut = 10.0; //disable by default
-    private double v0BsconVxCut = 10.0; //disable by default
 
 //  track quality cuts
-    private final double maxTrkPCut = 0.85;
-//    private final double minTrkPCut = 0.05;
-//    private double trkPyMax = 0.2;
-//    private double trkPxMax = 0.2;
-    private final double trkTimeDiff = 5.0;
-//    private final double clusterTimeDiffCut = 2.5;
-
     private final double tupleTrkPCut = 0.9;
     private final double tupleMinSumCut = 0.7;
     private final double tupleMaxSumCut = 1.3;
 
-//    private double l1IsoMin = 0.5;
-    private final double[] beamSize = {0.001, 0.130, 0.050}; //rough estimate from harp scans during engineering run production running
-    private final double[] beamPos = {0.0, 0.0, 0.0};
-    private final double[] vzcBeamSize = {0.001, 100, 100};
-
-    public MollerMonitoring() {
-        this.tupleVariables = new String[]{"run/I", "event/I",
-            "nTrk/I", "nPos/I",
-            "uncPX/D", "uncPY/D", "uncPZ/D", "uncP/D",
-            "uncVX/D", "uncVY/D", "uncVZ/D", "uncChisq/D", "uncM/D",
-            "bscPX/D", "bscPY/D", "bscPZ/D", "bscP/D",
-            "bscVX/D", "bscVY/D", "bscVZ/D", "bscChisq/D", "bscM/D",
-            "tarPX/D", "tarPY/D", "tarPZ/D", "tarP/D",
-            "tarVX/D", "tarVY/D", "tarVZ/D", "tarChisq/D", "tarM/D",
-            "vzcPX/D", "vzcPY/D", "vzcPZ/D", "vzcP/D",
-            "vzcVX/D", "vzcVY/D", "vzcVZ/D", "vzcChisq/D", "vzcM/D",
-            "topPX/D", "topPY/D", "topPZ/D", "topP/D",
-            "topTrkChisq/D", "topTrkHits/I", "topTrkType/I", "topTrkT/D",
-            "topTrkD0/D", "topTrkZ0/D", "topTrkEcalX/D", "topTrkEcalY/D",
-            "topHasL1/B", "topHasL2/B",
-            "topMatchChisq/D", "topClT/D", "topClE/D", "topClX/D", "topClY/D", "topClZ/D", "topClHits/I",
-            "botPX/D", "botPY/D", "botPZ/D", "botP/D",
-            "botTrkChisq/D", "botTrkHits/I", "botTrkType/I", "botTrkT/D",
-            "botTrkD0/D", "botTrkZ0/D", "botTrkEcalX/D", "botTrkEcalY/D",
-            "botHasL1/B", "botHasL2/B",
-            "botMatchChisq/D", "botClT/D", "botClE/D", "botClX/D", "botClY/D", "botClZ/D", "botClHits/I",
-            "minL1Iso/D"
-        };
-    }
-
-    public void setMaxChi2GBLTrack(double maxChi2GBLTrack) {
-        this.maxChi2GBLTrack = maxChi2GBLTrack;
-    }
-
-    public void setMaxUnconVertChi2(double maxUnconVertChi2) {
-        this.maxUnconVertChi2 = maxUnconVertChi2;
-    }
-
-    public void setMaxBsconVertChi2(double maxBsconVertChi2) {
-        this.maxBsconVertChi2 = maxBsconVertChi2;
-    }
-
-    public void setV0UnconVyCut(double v0UnconVyCut) {
-        this.v0UnconVyCut = v0UnconVyCut;
-    }
-
-    public void setV0UnconVxCut(double v0UnconVxCut) {
-        this.v0UnconVxCut = v0UnconVxCut;
-    }
-
-    public void setV0BsconVyCut(double v0BsconVyCut) {
-        this.v0BsconVyCut = v0BsconVyCut;
-    }
-
-    public void setV0BsconVxCut(double v0BsconVxCut) {
-        this.v0BsconVxCut = v0BsconVxCut;
-    }
-
-    public void setBeamSizeX(double beamSizeX) {
-        this.beamSize[1] = beamSizeX;
-    }
-
-    public void setBeamSizeY(double beamSizeY) {
-        this.beamSize[2] = beamSizeY;
-    }
-
-    public void setBeamPosX(double beamPosX) {
-        this.beamPos[1] = beamPosX;
-    }
-
-    public void setBeamPosY(double beamPosY) {
-        this.beamPos[2] = beamPosY;
-    }
-
-    double ebeam;
-
-    @Override
-    protected void detectorChanged(Detector detector) {
-        LOGGER.info("MollerMonitoring::detectorChanged  Setting up the plotter");
-        beamAxisRotation.setActiveEuler(Math.PI / 2, -0.0305, -Math.PI / 2);
-
-        BeamEnergyCollection beamEnergyCollection
-                = this.getConditionsManager().getCachedConditions(BeamEnergyCollection.class, "beam_energies").getCachedData();
-        ebeam = beamEnergyCollection.get(0).getBeamEnergy();
-        aida.tree().cd("/");
-        String trkType = "SeedTrack/";
-        if (isGBL) {
-            trkType = "GBLTrack/";
-        }
-        /*  V0 Quantities   */
-        /*  Mass, vertex, chi^2 of fit */
-        /* beamspot constrained */
-//        IHistogram1D nV0 = aida.histogram1D(plotDir +  triggerType + "/"+"Number of V0 per event", 10, 0, 10);
-//        IHistogram1D bsconMass = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Mass (GeV)", 100, 0, 0.200);
-//        IHistogram1D bsconVx = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vx (mm)", 50, -1, 1);
-//        IHistogram1D bsconVy = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vy (mm)", 50, -1, 1);
-//        IHistogram1D bsconVz = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vz (mm)", 50, -10, 10);
-//        IHistogram1D bsconChi2 = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Chi2", 25, 0, 25);
-//        /* target constrained */
-//        IHistogram1D tarconMass = aida.histogram1D(plotDir +  triggerType + "/"+"Target Constrained Mass (GeV)", 100, 0, 0.200);
-//        IHistogram1D tarconVx = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vx (mm)", 50, -1, 1);
-//        IHistogram1D tarconVy = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vy (mm)", 50, -1, 1);
-//        IHistogram1D tarconVz = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vz (mm)", 50, -10, 10);
-//        IHistogram1D tarconChi2 = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Chi2", 25, 0, 25);
-        nTriCand = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Number of Moller Candidates", 5, 0, 4);
-
-//        triTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Track time difference", 100, -10, 10);
-//        triTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-        triTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Bottom vs. top momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        triDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Moller: Bottom - top momentum", 100, -ebeam, ebeam);
-        triSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Moller: Bottom + top momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        triPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Py(t) vs Py(b)", 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam, 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam);
-        triPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Px(t) vs Px(b)", 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam, 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam);
-
-        triMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Vertex mass vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, 0, 0.1 * ebeam);
-        triZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Vertex Z vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, -v0VzMax, v0VzMax);
-        triMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Moller: Vertex mass", 100, 0, 0.1 * ebeam);
-        triZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Moller: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-//        triX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex X", 100, -v0VxMax, v0VxMax);
-//        triY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Y", 100, -v0VyMax, v0VyMax);
-//        triZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z", 100, -v0VzMax, v0VzMax);
-//        triXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-//        triZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-        triPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Px", 100, -v0PxMax, v0PxMax);
-        triPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py", 100, -v0PyMax, v0PyMax);
-        triPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Pz", 100, v0PzMin, v0PzMax);
-        triPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py vs. Px", 100, -v0PxMax, v0PxMax, 100, -v0PyMax, v0PyMax);
-        triU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Px over Ptot", 100, -0.1, 0.1);
-        triV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-//        vertTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Track time difference", 100, -10, 10);
-//        vertTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-        vertTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Bottom vs. top momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        vertDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Bottom - top momentum", 100, -ebeam, ebeam);
-        vertSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Bottom + top momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        vertPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Py(t) vs Py(b)", 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam, 50, -2 * v0PyMax * ebeam, 2 * v0PyMax * ebeam);
-        vertPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Px(t) vs Px(b)", 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam, 50, -2 * v0PxMax * ebeam, 2 * v0PxMax * ebeam);
-
-        vertMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex mass vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, 0, 0.1 * ebeam);
-        vertZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, -v0VzMax, v0VzMax);
-        vertMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex mass", 100, 0, 0.1 * ebeam);
-        vertZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-        vertX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex X", 100, -v0VxMax, v0VxMax);
-        vertY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Y", 100, -v0VyMax, v0VyMax);
-//        vertZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z", 100, -v0VzMax, v0VzMax);
-        vertXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-        vertZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-        vertPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Px", 100, -v0PxMax, v0PxMax);
-        vertPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py", 100, -v0PyMax, v0PyMax);
-        vertPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Pz", 100, v0PzMin, v0PzMax);
-        vertPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py vs. Px", 100, -v0PxMax, v0PxMax, 100, -v0PyMax, v0PyMax);
-        vertU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Px over Ptot", 100, -0.1, 0.1);
-        vertV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-        nVtxCand = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Number of Vertexing Candidates", 5, 0, 4);
+    public MollerTupleDriver() {
+        tupleVariables.clear();
+        addEventVariables();
+        addVertexVariables();
+        addParticleVariables("top");
+        addParticleVariables("bot");
+        String[] newVars = new String[]{"minPositiveIso/D", "minNegativeIso/D", "minIso/D"};
+        tupleVariables.addAll(Arrays.asList(newVars));
     }
 
     @Override
     public void process(EventHeader event) {
         /*  make sure everything is there */
-        if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) {
-            return;
-        }
         if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName)) {
             return;
         }
-//        if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName)) {
-//            return;
-//        }
-//        if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName)) {
-//            return;
-//        }
+
+        TIData triggerData = null;
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            for (GenericObject data : event.get(GenericObject.class, "TriggerBank")) {
+                if (AbstractIntData.getTag(data) == TIData.BANK_TAG) {
+                    triggerData = new TIData(data);
+                }
+            }
+        }
 
         //check to see if this event is from the correct trigger (or "all");
-        if (!matchTrigger(event)) {
+        if (triggerData != null && !matchTriggerType(triggerData)) {
             return;
         }
 
         List<ReconstructedParticle> unConstrainedV0List = event.get(ReconstructedParticle.class, unconstrainedV0CandidatesColName);
 
-        RelationalTable hitToStrips = TrackUtils.getHitToStripsTable(event);
-        RelationalTable hitToRotated = TrackUtils.getHitToRotatedTable(event);
-
-        List<ReconstructedParticle> fspList = event.get(ReconstructedParticle.class, finalStateParticlesColName);
-        int npos = 0;
-        int ntrk = 0;
-        for (ReconstructedParticle fsp : fspList) {
-            if (isGBL != TrackType.isGBL(fsp.getType())) {
-                continue;
-            }
-            if (fsp.getCharge() != 0) {
-                ntrk++;
-            }
-            if (fsp.getCharge() > 0) {
-                npos++;
-            }
-        }
-
-        List<ReconstructedParticle> candidateList = new ArrayList<>();
-        List<ReconstructedParticle> vertCandidateList = new ArrayList<>();
         for (ReconstructedParticle uncV0 : unConstrainedV0List) {
             if (isGBL != TrackType.isGBL(uncV0.getType())) {
                 continue;
             }
-            Vertex uncVert = uncV0.getStartVertex();
-//  v0 & vertex-quality cuts
-            Hep3Vector v0MomRot = VecOp.mult(beamAxisRotation, uncV0.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, uncVert.getPosition());
+            tupleMap.clear();
+            fillEventVariables(event, triggerData);
 
-            List<Track> tracks = new ArrayList<Track>();
             ReconstructedParticle top = uncV0.getParticles().get(ReconParticleDriver.MOLLER_TOP);
             ReconstructedParticle bot = uncV0.getParticles().get(ReconParticleDriver.MOLLER_BOT);
             if (top.getCharge() != -1 || bot.getCharge() != -1) {
                 throw new RuntimeException("incorrect charge on v0 daughters");
             }
-            tracks.add(top.getTracks().get(0));
-            tracks.add(bot.getTracks().get(0));
-            if (tracks.size() != 2) {
-                throw new RuntimeException("expected two tracks in vertex, got " + tracks.size());
-            }
 
-            Double[] topIso = TrackUtils.getIsolations(top.getTracks().get(0), hitToStrips, hitToRotated);
-            Double[] botIso = TrackUtils.getIsolations(bot.getTracks().get(0), hitToStrips, hitToRotated);
-            double minL1Iso = -9999;
-            if (topIso[0] != null && botIso[0] != null) {
-                double topL1Iso = Math.min(Math.abs(topIso[0]), Math.abs(topIso[1]));
-                double botL1Iso = Math.min(Math.abs(botIso[0]), Math.abs(botIso[1]));
-                minL1Iso = Math.min(topL1Iso, botL1Iso);
-            }
+            Track topTrack = top.getTracks().get(0);
+            Track botTrack = bot.getTracks().get(0);
 
-            double tTop = TrackUtils.getTrackTime(top.getTracks().get(0), hitToStrips, hitToRotated);
-            double tBot = TrackUtils.getTrackTime(bot.getTracks().get(0), hitToStrips, hitToRotated);
-            Hep3Vector pTopRot = VecOp.mult(beamAxisRotation, top.getMomentum());
-            Hep3Vector pBotRot = VecOp.mult(beamAxisRotation, bot.getMomentum());
+            TrackState topTSTweaked = fillParticleVariables(event, top, "top");
+            TrackState botTSTweaked = fillParticleVariables(event, bot, "bot");
 
-            Hep3Vector topAtEcal = TrackUtils.getTrackPositionAtEcal(top.getTracks().get(0));
-            Hep3Vector botAtEcal = TrackUtils.getTrackPositionAtEcal(bot.getTracks().get(0));
+            List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
+            billiorTracks.add(new BilliorTrack(topTSTweaked, topTrack.getChi2(), topTrack.getNDF()));
+            billiorTracks.add(new BilliorTrack(botTSTweaked, botTrack.getChi2(), botTrack.getNDF()));
 
-            BilliorVertexer vtxFitter = new BilliorVertexer(TrackUtils.getBField(event.getDetector()).y());
-            vtxFitter.setBeamSize(beamSize);
-            vtxFitter.setBeamPosition(beamPos);
-            List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
-            billiorTracks.add(new BilliorTrack(top.getTracks().get(0)));
-            billiorTracks.add(new BilliorTrack(bot.getTracks().get(0)));
+            double minPositiveIso = Math.min(tupleMap.get("topMinPositiveIso/D"), tupleMap.get("botMinPositiveIso/D"));
+            double minNegativeIso = Math.max(Math.min(tupleMap.get("topMinPositiveIso/D"), 9999), Math.min(tupleMap.get("botMinPositiveIso/D"), 9999));
+            double minIso = Math.min(Math.abs(minPositiveIso), Math.abs(minNegativeIso));
 
-            vtxFitter.doBeamSpotConstraint(true);
-            BilliorVertex bsconVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle bscV0 = HpsReconParticleDriver.makeReconstructedParticle(top, bot, bsconVertex);
-            Hep3Vector bscMomRot = VecOp.mult(beamAxisRotation, bscV0.getMomentum());
-            Hep3Vector bscVtx = VecOp.mult(beamAxisRotation, bscV0.getStartVertex().getPosition());
+            fillVertexVariables(event, billiorTracks, top, bot);
 
-            vtxFitter.doTargetConstraint(true);
-            BilliorVertex tarVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle tarV0 = HpsReconParticleDriver.makeReconstructedParticle(top, bot, tarVertex);
-            Hep3Vector tarMomRot = VecOp.mult(beamAxisRotation, tarV0.getMomentum());
-            Hep3Vector tarVtx = VecOp.mult(beamAxisRotation, tarV0.getStartVertex().getPosition());
-
-            vtxFitter.setBeamSize(vzcBeamSize);
-            vtxFitter.doTargetConstraint(true);
-            BilliorVertex vzcVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle vzcV0 = HpsReconParticleDriver.makeReconstructedParticle(top, bot, vzcVertex);
-            Hep3Vector vzcMomRot = VecOp.mult(beamAxisRotation, vzcV0.getMomentum());
-            Hep3Vector vzcVtx = VecOp.mult(beamAxisRotation, vzcV0.getStartVertex().getPosition());
+            tupleMap.put("minPositiveIso/D", minPositiveIso);
+            tupleMap.put("minNegativeIso/D", minNegativeIso);
+            tupleMap.put("minIso/D", minIso);
 
             if (tupleWriter != null) {
-                boolean trkCut = top.getMomentum().magnitude() < tupleTrkPCut * ebeam && bot.getMomentum().magnitude() < tupleTrkPCut * ebeam;
-                boolean sumCut = top.getMomentum().magnitude() + bot.getMomentum().magnitude() > tupleMinSumCut * ebeam && top.getMomentum().magnitude() + bot.getMomentum().magnitude() < tupleMaxSumCut * ebeam;
-
+                boolean trkCut = tupleMap.get("topP/D") < tupleTrkPCut * ebeam && tupleMap.get("botP/D") < tupleTrkPCut * ebeam;
+                boolean sumCut = tupleMap.get("topP/D") + tupleMap.get("botP/D") > tupleMinSumCut * ebeam && tupleMap.get("topP/D") + tupleMap.get("botP/D") < tupleMaxSumCut * ebeam;
                 if (!cutTuple || (trkCut && sumCut)) {
-
-                    tupleMap.put("run/I", (double) event.getRunNumber());
-                    tupleMap.put("event/I", (double) event.getEventNumber());
-
-                    tupleMap.put("uncPX/D", v0MomRot.x());
-                    tupleMap.put("uncPY/D", v0MomRot.y());
-                    tupleMap.put("uncPZ/D", v0MomRot.z());
-                    tupleMap.put("uncP/D", v0MomRot.magnitude());
-                    tupleMap.put("uncVX/D", v0Vtx.x());
-                    tupleMap.put("uncVY/D", v0Vtx.y());
-                    tupleMap.put("uncVZ/D", v0Vtx.z());
-                    tupleMap.put("uncChisq/D", uncV0.getStartVertex().getChi2());
-                    tupleMap.put("uncM/D", uncV0.getMass());
-
-                    tupleMap.put("bscPX/D", bscMomRot.x());
-                    tupleMap.put("bscPY/D", bscMomRot.y());
-                    tupleMap.put("bscPZ/D", bscMomRot.z());
-                    tupleMap.put("bscP/D", bscMomRot.magnitude());
-                    tupleMap.put("bscVX/D", bscVtx.x());
-                    tupleMap.put("bscVY/D", bscVtx.y());
-                    tupleMap.put("bscVZ/D", bscVtx.z());
-                    tupleMap.put("bscChisq/D", bscV0.getStartVertex().getChi2());
-                    tupleMap.put("bscM/D", bscV0.getMass());
-
-                    tupleMap.put("tarPX/D", tarMomRot.x());
-                    tupleMap.put("tarPY/D", tarMomRot.y());
-                    tupleMap.put("tarPZ/D", tarMomRot.z());
-                    tupleMap.put("tarP/D", tarMomRot.magnitude());
-                    tupleMap.put("tarVX/D", tarVtx.x());
-                    tupleMap.put("tarVY/D", tarVtx.y());
-                    tupleMap.put("tarVZ/D", tarVtx.z());
-                    tupleMap.put("tarChisq/D", tarV0.getStartVertex().getChi2());
-                    tupleMap.put("tarM/D", tarV0.getMass());
-
-                    tupleMap.put("vzcPX/D", vzcMomRot.x());
-                    tupleMap.put("vzcPY/D", vzcMomRot.y());
-                    tupleMap.put("vzcPZ/D", vzcMomRot.z());
-                    tupleMap.put("vzcP/D", vzcMomRot.magnitude());
-                    tupleMap.put("vzcVX/D", vzcVtx.x());
-                    tupleMap.put("vzcVY/D", vzcVtx.y());
-                    tupleMap.put("vzcVZ/D", vzcVtx.z());
-                    tupleMap.put("vzcChisq/D", vzcV0.getStartVertex().getChi2());
-                    tupleMap.put("vzcM/D", vzcV0.getMass());
-
-                    tupleMap.put("topPX/D", pTopRot.x());
-                    tupleMap.put("topPY/D", pTopRot.y());
-                    tupleMap.put("topPZ/D", pTopRot.z());
-                    tupleMap.put("topP/D", pTopRot.magnitude());
-                    tupleMap.put("topTrkD0/D", top.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("topTrkZ0/D", top.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("topTrkEcalX/D", topAtEcal.x());
-                    tupleMap.put("topTrkEcalY/D", topAtEcal.y());
-                    tupleMap.put("topTrkChisq/D", top.getTracks().get(0).getChi2());
-                    tupleMap.put("topTrkHits/I", (double) top.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("topTrkType/I", (double) top.getType());
-                    tupleMap.put("topTrkT/D", tTop);
-                    tupleMap.put("topHasL1/B", topIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("topHasL2/B", topIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("topMatchChisq/D", top.getGoodnessOfPID());
-                    if (!top.getClusters().isEmpty()) {
-                        Cluster topC = top.getClusters().get(0);
-                        tupleMap.put("topClT/D", ClusterUtilities.getSeedHitTime(topC));
-                        tupleMap.put("topClE/D", topC.getEnergy());
-                        tupleMap.put("topClX/D", topC.getPosition()[0]);
-                        tupleMap.put("topClY/D", topC.getPosition()[1]);
-                        tupleMap.put("topClZ/D", topC.getPosition()[2]);
-                        tupleMap.put("topClHits/I", (double) topC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("botPX/D", pBotRot.x());
-                    tupleMap.put("botPY/D", pBotRot.y());
-                    tupleMap.put("botPZ/D", pBotRot.z());
-                    tupleMap.put("botP/D", pBotRot.magnitude());
-                    tupleMap.put("botTrkD0/D", bot.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("botTrkZ0/D", bot.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("botTrkEcalX/D", botAtEcal.x());
-                    tupleMap.put("botTrkEcalY/D", botAtEcal.y());
-                    tupleMap.put("botTrkChisq/D", bot.getTracks().get(0).getChi2());
-                    tupleMap.put("botTrkHits/I", (double) bot.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("botTrkType/I", (double) bot.getType());
-                    tupleMap.put("botTrkT/D", tBot);
-                    tupleMap.put("botHasL1/B", botIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("botHasL2/B", botIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("botMatchChisq/D", bot.getGoodnessOfPID());
-                    if (!bot.getClusters().isEmpty()) {
-                        Cluster botC = bot.getClusters().get(0);
-                        tupleMap.put("botClT/D", ClusterUtilities.getSeedHitTime(botC));
-                        tupleMap.put("botClE/D", botC.getEnergy());
-                        tupleMap.put("botClHits/I", (double) botC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("minL1Iso/D", minL1Iso);
-
-                    tupleMap.put("nTrk/I", (double) ntrk);
-                    tupleMap.put("nPos/I", (double) npos);
                     writeTuple();
                 }
             }
-
-            //start applying cuts
-            EnumSet<Cut> bits = EnumSet.noneOf(Cut.class);
-
-            boolean trackQualityCut = Math.max(top.getTracks().get(0).getChi2(), bot.getTracks().get(0).getChi2()) < (isGBL ? maxChi2GBLTrack : maxChi2SeedTrack);
-            if (trackQualityCut) {
-                bits.add(Cut.TRK_QUALITY);
-            }
-
-            boolean v0QualityCut = uncVert.getChi2() < maxUnconVertChi2 && bsconVertex.getChi2() < maxBsconVertChi2;
-            if (v0QualityCut) {
-                bits.add(Cut.VTX_QUALITY);
-            }
-
-            boolean vertexMomentumCut = v0MomRot.z() < v0PzMaxCut * ebeam && v0MomRot.z() > v0PzMinCut * ebeam && Math.abs(v0MomRot.x()) < v0PxCut * ebeam && Math.abs(v0MomRot.y()) < v0PyCut * ebeam;
-            boolean vertexPositionCut = Math.abs(v0Vtx.x()) < v0UnconVxCut && Math.abs(v0Vtx.y()) < v0UnconVyCut && Math.abs(v0Vtx.z()) < v0UnconVzCut && Math.abs(bscVtx.x()) < v0BsconVxCut && Math.abs(bscVtx.y()) < v0BsconVyCut;
-            if (vertexMomentumCut && vertexPositionCut) {
-                bits.add(Cut.VERTEX_CUTS);
-            }
-
-            boolean trackTimeDiffCut = Math.abs(tTop - tBot) < trkTimeDiff;
-            if (trackTimeDiffCut) {
-                bits.add(Cut.TIMING);
-            }
-
-//            boolean topBottomCut = top.getMomentum().y() * bot.getMomentum().y() < 0;
-//            boolean pMinCut = top.getMomentum().magnitude() > minTrkPCut * ebeam && bot.getMomentum().magnitude() > minTrkPCut * ebeam;
-            boolean pMaxCut = top.getMomentum().magnitude() < maxTrkPCut * ebeam && bot.getMomentum().magnitude() < maxTrkPCut * ebeam;
-//            boolean pSumCut = top.getMomentum().magnitude() + bot.getMomentum().magnitude() < maxPSumCut * ebeam && top.getMomentum().magnitude() + bot.getMomentum().magnitude() < minPSumCut * ebeam;
-//            boolean pMaxCut = top.getMomentum().magnitude() < maxTrkPCut * ebeam && bot.getMomentum().magnitude() < maxTrkPCut * ebeam;
-            if (pMaxCut) {
-                bits.add(Cut.TRACK_CUTS);
-            }
-
-            boolean eventTrkCountCut = ntrk >= 2 && ntrk <= nTrkMax;
-            boolean eventPosCountCut = npos >= 1 && npos <= nPosMax;
-            if (eventTrkCountCut && eventPosCountCut) {
-                bits.add(Cut.EVENT_QUALITY);
-            }
-
-            boolean frontHitsCut = topIso[0] != null && botIso[0] != null && topIso[2] != null && botIso[2] != null;
-            if (frontHitsCut) {
-                bits.add(Cut.FRONT_HITS);
-            }
-
-            for (Cut cut : Cut.values()) {
-                if (bits.contains(cut)) {
-                    if (cut.ordinal() == Cut.firstVertexingCut) {//if we get here, we've passed all non-vertexing cuts
-                        candidateList.add(uncV0);
-                    }
-                } else {
-                    break;
-                }
-            }
-
-            if (bits.containsAll(EnumSet.range(Cut.values()[0], Cut.values()[Cut.firstVertexingCut - 1]))) {
-                candidateList.add(uncV0);
-            }
-            if (bits.equals(EnumSet.allOf(Cut.class))) {
-                vertCandidateList.add(uncV0);
-            }
-        }
-
-        nTriCand.fill(candidateList.size());
-        nVtxCand.fill(vertCandidateList.size());
-
-        if (!candidateList.isEmpty()) {
-            // pick the best candidate...for now just pick a random one. 
-            ReconstructedParticle bestCandidate = candidateList.get((int) (Math.random() * candidateList.size()));
-
-            //fill some stuff: 
-            ReconstructedParticle top = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_TOP);
-            ReconstructedParticle bot = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_BOT);
-            if (top.getCharge() != -1 || bot.getCharge() != -1) {
-                throw new RuntimeException("vertex needs two e- but is missing one or both");
-            }
-
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, top.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, bot.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, bestCandidate.getStartVertex().getPosition());
-            Hep3Vector pBestV0Rot = VecOp.mult(beamAxisRotation, bestCandidate.getMomentum());
-
-//            triTrackTime2D.fill(tEle, tPos);
-//            triTrackTimeDiff.fill(tEle - tPos);
-            triZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-            triMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-            triTrackMomentum2D.fill(top.getMomentum().magnitude(), bot.getMomentum().magnitude());
-            triPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-            triPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-            triSumP.fill(bestCandidate.getMomentum().magnitude());
-            triDeltaP.fill(bot.getMomentum().magnitude() - top.getMomentum().magnitude());
-
-            triPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-            triMass.fill(bestCandidate.getMass());
-            triZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-//            triX.fill(v0Vtx.x());
-//            triY.fill(v0Vtx.y());
-//            triZ.fill(v0Vtx.z());
-            triPx.fill(pBestV0Rot.x());
-            triPy.fill(pBestV0Rot.y());
-            triPz.fill(pBestV0Rot.z());
-            triU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-            triV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-//            triXY.fill(v0Vtx.x(), v0Vtx.y());
-//            triZY.fill(v0Vtx.y(), v0Vtx.z());
-        }
-
-        if (!vertCandidateList.isEmpty()) {
-            // pick the best candidate...for now just pick a random one. 
-            ReconstructedParticle bestCandidate = vertCandidateList.get((int) (Math.random() * vertCandidateList.size()));
-            Vertex unconVertex = bestCandidate.getStartVertex();
-
-            //fill some stuff: 
-            ReconstructedParticle top = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_TOP);
-            ReconstructedParticle bot = bestCandidate.getParticles().get(ReconParticleDriver.MOLLER_BOT);
-            if (top.getCharge() != -1 || bot.getCharge() != -1) {
-                throw new RuntimeException("vertex needs two e- but is missing one or both");
-            }
-
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, top.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, bot.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, unconVertex.getPosition());
-            Hep3Vector pBestV0Rot = VecOp.mult(beamAxisRotation, bestCandidate.getMomentum());
-
-//            vertTrackTime2D.fill(tEle, tPos);
-//            vertTrackTimeDiff.fill(tEle - tPos);
-            vertZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-            vertMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-            vertTrackMomentum2D.fill(top.getMomentum().magnitude(), bot.getMomentum().magnitude());
-            vertPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-            vertPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-            vertSumP.fill(bestCandidate.getMomentum().magnitude());
-            vertDeltaP.fill(bot.getMomentum().magnitude() - top.getMomentum().magnitude());
-
-            vertPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-            vertMass.fill(bestCandidate.getMass());
-            vertZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-            vertX.fill(v0Vtx.x());
-            vertY.fill(v0Vtx.y());
-//            vertZ.fill(v0Vtx.z());
-            vertPx.fill(pBestV0Rot.x());
-            vertPy.fill(pBestV0Rot.y());
-            vertPz.fill(pBestV0Rot.z());
-            vertU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-            vertV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-            vertXY.fill(v0Vtx.x(), v0Vtx.y());
-            vertZY.fill(v0Vtx.y(), v0Vtx.z());
-        }
-    }
-
-    @Override
-    public void printDQMStrings() {
-        for (int i = 0; i < 9; i++)//TODO:  do this in a smarter way...loop over the map
-        {
-            LOGGER.info("ALTER TABLE dqm ADD " + fpQuantNames[i] + " double;");
         }
     }
 }

Copied: java/trunk/analysis/src/main/java/org/hps/analysis/tuple/TridentTupleDriver.java (from r4372, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java)
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/tuple/TridentTupleDriver.java	Tue May 24 18:30:43 2016
@@ -1,1095 +1,96 @@
-package org.hps.analysis.dataquality;
+package org.hps.analysis.tuple;
 
-import hep.aida.IAnalysisFactory;
-import hep.aida.IFitFactory;
-import hep.aida.IFitResult;
-import hep.aida.IFitter;
-import hep.aida.IHistogram1D;
-import hep.aida.IHistogram2D;
-import hep.physics.vec.BasicHep3Matrix;
-import hep.physics.vec.Hep3Vector;
-import hep.physics.vec.VecOp;
 import java.util.ArrayList;
-import java.util.EnumSet;
+import java.util.Arrays;
 import java.util.List;
-import java.util.Map.Entry;
-import java.util.logging.Logger;
-import org.hps.conditions.beam.BeamEnergy.BeamEnergyCollection;
-import org.hps.recon.ecal.cluster.ClusterUtilities;
-import org.hps.recon.particle.HpsReconParticleDriver;
 import org.hps.recon.particle.ReconParticleDriver;
 import org.hps.recon.tracking.TrackType;
-import org.hps.recon.tracking.TrackUtils;
 import org.hps.recon.vertexing.BilliorTrack;
-import org.hps.recon.vertexing.BilliorVertex;
-import org.hps.recon.vertexing.BilliorVertexer;
-import org.lcsim.event.Cluster;
+import org.hps.record.triggerbank.AbstractIntData;
+import org.hps.record.triggerbank.TIData;
 import org.lcsim.event.EventHeader;
+import org.lcsim.event.GenericObject;
 import org.lcsim.event.ReconstructedParticle;
-import org.lcsim.event.RelationalTable;
 import org.lcsim.event.Track;
-import org.lcsim.event.TrackerHit;
-import org.lcsim.event.Vertex;
-import org.lcsim.geometry.Detector;
+import org.lcsim.event.TrackState;
 
-/**
- * DQM driver V0 particles (i.e. e+e- pars) plots things like number of vertex
- * position an mass
- *
- * @author mgraham on May 14, 2014
- *
- */
-public class TridentMonitoring extends DataQualityMonitor {
+public class TridentTupleDriver extends TupleDriver {
 
-    private enum Cut {
-
-        TRK_QUALITY("Trk Quality"),
-        VTX_QUALITY("Vtx Quality"),
-        VERTEX_CUTS("Vtx Cuts"),
-        TIMING("Timing"),
-        TRACK_CUTS("Trk Cuts"),
-        CLUSTER_CUTS("Cluster"),
-        EVENT_QUALITY("Evt Quality"),
-        FRONT_HITS("Front Hits"),
-        ISOLATION("Isolation");
-        private final String name;
-        private final static int nCuts = 9;
-        private final static int firstVertexingCut = 7;
-
-        Cut(String name) {
-            this.name = name;
-        }
-
-        static int bitmask(EnumSet<Cut> flags) {
-            int mask = 0;
-            for (Cut flag : flags) {
-                mask |= 1 << flag.ordinal();
-            }
-            return mask;
-        }
-
-        @Override
-        public String toString() {
-            return name;
-        }
-    }
-
-    private final static Logger LOGGER = Logger.getLogger(TridentMonitoring.class.getPackage().getName());
-
-    private final BasicHep3Matrix beamAxisRotation = new BasicHep3Matrix();
-//    private static final int nCuts = 9;
-//    private final String[] cutNames = {"Trk Quality",
-//        "V0 Quality",
-//        "V0 Vertex",
-//        "Timing",
-//        "Tracking",
-//        "Cluster",
-//        "Event",
-//        "Front Hits",
-//        "Isolation"};
-//    private int firstVertexingCut = 0;
-    private static final int TRIDENT = 0;
-    private static final int VERTEX = 1;
-
-    private final String finalStateParticlesColName = "FinalStateParticles";
     private final String unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates";
-//    private final String beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
-//    private final String targetV0ConCandidatesColName = "TargetConstrainedV0Candidates";
-//    private final String trackListName = "MatchedTracks";
-    private final String[] fpQuantNames = {"nV0_per_Event", "avg_BSCon_mass", "avg_BSCon_Vx", "avg_BSCon_Vy", "avg_BSCon_Vz", "sig_BSCon_Vx", "sig_BSCon_Vy", "sig_BSCon_Vz", "avg_BSCon_Chi2"};
-
-    private final String plotDir = "TridentMonitoring/";
-
-//    private IHistogram2D triTrackTime2D;
-//    private IHistogram1D triTrackTimeDiff;
-    private IHistogram2D triMassMomentum;
-    private IHistogram2D triZVsMomentum;
-    private IHistogram2D triTrackMomentum2D;
-    private IHistogram2D triPyEleVsPyPos;
-    private IHistogram2D triPxEleVsPxPos;
-    private IHistogram1D triDeltaP;
-    private IHistogram1D triSumP;
-    private IHistogram1D triMass;
-    private IHistogram2D triZVsMass;
-//    private IHistogram1D triX;
-//    private IHistogram1D triY;
-//    private IHistogram1D triZ;
-//    private IHistogram2D triZY;
-//    private IHistogram2D triXY;
-//    private IHistogram1D triPx;
-//    private IHistogram1D triPy;
-//    private IHistogram1D triPz;
-//    private IHistogram2D triPxPy;
-//    private IHistogram1D triU;
-//    private IHistogram1D triV;
-
-    private IHistogram2D triRadTrackTime2D;
-    private IHistogram1D triRadTrackTimeDiff;
-//    private IHistogram2D triRadMassMomentum;
-//    private IHistogram2D triRadZVsMomentum;
-    private IHistogram2D triRadTrackMomentum2D;
-    private IHistogram2D triRadPyEleVsPyPos;
-    private IHistogram2D triRadPxEleVsPxPos;
-    private IHistogram1D triRadDeltaP;
-    private IHistogram1D triRadSumP;
-    private IHistogram1D triRadMass;
-    private IHistogram2D triRadZVsMass;
-//    private IHistogram1D triRadX;
-//    private IHistogram1D triRadY;
-//    private IHistogram1D triRadZ;
-//    private IHistogram2D triRadZY;
-//    private IHistogram2D triRadXY;
-    private IHistogram1D triRadPx;
-    private IHistogram1D triRadPy;
-    private IHistogram1D triRadPz;
-    private IHistogram2D triRadPxPy;
-    private IHistogram1D triRadU;
-    private IHistogram1D triRadV;
-
-//    private IHistogram2D vertTrackTime2D;
-//    private IHistogram1D vertTrackTimeDiff;
-    private IHistogram2D vertMassMomentum;
-    private IHistogram2D vertZVsMomentum;
-    private IHistogram2D vertTrackMomentum2D;
-    private IHistogram2D vertPyEleVsPyPos;
-    private IHistogram2D vertPxEleVsPxPos;
-    private IHistogram1D vertDeltaP;
-    private IHistogram1D vertSumP;
-    private IHistogram1D vertMass;
-    private IHistogram2D vertZVsMass;
-//    private IHistogram1D vertX;
-    private IHistogram1D vertY;
-//    private IHistogram1D vertZ;
-    private IHistogram2D vertZY;
-    private IHistogram2D vertXY;
-//    private IHistogram1D vertPx;
-//    private IHistogram1D vertPy;
-//    private IHistogram1D vertPz;
-//    private IHistogram2D vertPxPy;
-//    private IHistogram1D vertU;
-//    private IHistogram1D vertV;
-
-    private IHistogram2D vertRadTrackTime2D;
-    private IHistogram1D vertRadTrackTimeDiff;
-    private IHistogram2D vertRadMassMomentum;
-    private IHistogram2D vertRadZVsMomentum;
-    private IHistogram2D vertRadTrackMomentum2D;
-    private IHistogram2D vertRadPyEleVsPyPos;
-    private IHistogram2D vertRadPxEleVsPxPos;
-    private IHistogram1D vertRadDeltaP;
-    private IHistogram1D vertRadSumP;
-    private IHistogram1D vertRadMass;
-    private IHistogram2D vertRadZVsMass;
-    private IHistogram1D vertRadX;
-    private IHistogram1D vertRadY;
-    private IHistogram1D vertRadZ;
-    private IHistogram2D vertRadZY;
-    private IHistogram2D vertRadXY;
-    private IHistogram1D vertRadPx;
-    private IHistogram1D vertRadPy;
-    private IHistogram1D vertRadPz;
-    private IHistogram2D vertRadPxPy;
-    private IHistogram1D vertRadU;
-    private IHistogram1D vertRadV;
-
-    private IHistogram2D vertRadUnconBsconChi2;
-
-    private IHistogram1D nTriCand;
-    private IHistogram1D nVtxCand;
-//    IHistogram1D vertexW;
-//    IHistogram2D vertexVZ;
-
-    private IHistogram1D maxTrkChi2;
-    private IHistogram2D zVsMaxTrkChi2;
-    private IHistogram1D v0Chi2;
-    private IHistogram1D bsconV0Chi2;
-    private IHistogram2D zVsV0Chi2;
-    private IHistogram2D zVsBsconV0Chi2;
-    private IHistogram1D v0Chi2Diff;
-    private IHistogram2D zVsV0Chi2Diff;
-    private IHistogram1D trackTimeDiff;
-    private IHistogram2D zVsTrackTimeDiff;
-    private IHistogram1D hitTimeStdDev;
-    private IHistogram2D zVsHitTimeStdDev;
-    private IHistogram1D eventTrkCount;
-    private IHistogram1D eventPosCount;
-    private IHistogram2D zVsEventTrkCount;
-    private IHistogram2D zVsEventPosCount;
-    private IHistogram1D l1Iso;
-    private IHistogram2D zVsL1Iso;
-
-    private final IHistogram1D[][] cutVertexMass = new IHistogram1D[Cut.nCuts][2];
-    private final IHistogram1D[][] cutVertexZ = new IHistogram1D[Cut.nCuts][2];
-    private final IHistogram2D[][] cutVertexZVsMass = new IHistogram2D[Cut.nCuts][2];
-
-    private final double plotsMinMass = 0.03;
-    private final double plotsMaxMass = 0.04;
-
-    //clean up event first
-    private final int nTrkMax = 5;
-    private final int nPosMax = 1;
-
-    private final double maxChi2SeedTrack = 7.0;
-    private double maxChi2GBLTrack = 15.0;
-    private double maxUnconVertChi2 = 7.0;
-    private double maxBsconVertChi2 = 1000.0; //disable by default
-
-    //v0 plot ranges
-    private final double v0PzMax = 1.25;//GeV 
-    private final double v0PzMin = 0.1;// GeV
-    private final double v0PyMax = 0.04;//GeV absolute value
-    private final double v0PxMax = 0.04;//GeV absolute value
-    private final double v0VzMax = 50.0;// mm from target...someday make mass dependent
-    private final double v0VyMax = 2.0;// mm from target...someday make mass dependent
-    private final double v0VxMax = 2.0;// mm from target...someday make mass dependent
-
-    //v0 cuts
-    private final double v0PzMaxCut = 1.25;//GeV 
-    private final double v0PzMinCut = 0.1;// GeV
-    private final double v0PyCut = 0.04;//GeV absolute value
-    private final double v0PxCut = 0.04;//GeV absolute value
-    private final double v0UnconVzCut = 50.0;// mm from target...someday make mass dependent
-    private double v0UnconVyCut = 2.0;// mm from target...someday make mass dependent
-    private double v0UnconVxCut = 2.0;// mm from target...someday make mass dependent
-    private double v0BsconVyCut = 10.0; //disable by default
-    private double v0BsconVxCut = 10.0; //disable by default
-
-//  track quality cuts
-    private final double beamPCut = 0.85;
-    private final double minPCut = 0.05;
-//    private double trkPyMax = 0.2;
-//    private double trkPxMax = 0.2;
-    private final double radCut = 0.8;
-    private final double trkTimeDiff = 5.0;
-    private final double clusterTimeDiffCut = 2.5;
-
-    private double l1IsoMin = 0.5;
 
     private final double tupleTrkPCut = 0.9;
     private final double tupleMaxSumCut = 1.3;
 
-    private final double[] beamSize = {0.001, 0.130, 0.050}; //rough estimate from harp scans during engineering run production running
-    private final double[] beamPos = {0.0, 0.0, 0.0};
-    private final double[] vzcBeamSize = {0.001, 100, 100};
-
-//cluster matching
-//    private boolean reqCluster = false;
-//    private int nClustMax = 3;
-//    private double eneLossFactor = 0.7; //average E/p roughly
-//    private double eneOverPCut = 0.3; //|(E/p)_meas - (E/p)_mean|<eneOverPCut
-//counters
-    private float nEvents = 0;
-    private float nRecoV0 = 0;
-    private final float[] nPassCut = new float[Cut.nCuts];
-
-    public TridentMonitoring() {
-        this.tupleVariables = new String[]{"run/I", "event/I",
-            "nTrk/I", "nPos/I",
-            "uncPX/D", "uncPY/D", "uncPZ/D", "uncP/D",
-            "uncVX/D", "uncVY/D", "uncVZ/D", "uncChisq/D", "uncM/D",
-            "bscPX/D", "bscPY/D", "bscPZ/D", "bscP/D",
-            "bscVX/D", "bscVY/D", "bscVZ/D", "bscChisq/D", "bscM/D",
-            "tarPX/D", "tarPY/D", "tarPZ/D", "tarP/D",
-            "tarVX/D", "tarVY/D", "tarVZ/D", "tarChisq/D", "tarM/D",
-            "vzcPX/D", "vzcPY/D", "vzcPZ/D", "vzcP/D",
-            "vzcVX/D", "vzcVY/D", "vzcVZ/D", "vzcChisq/D", "vzcM/D",
-            "elePX/D", "elePY/D", "elePZ/D", "eleP/D",
-            "eleTrkChisq/D", "eleTrkHits/I", "eleTrkType/I", "eleTrkT/D",
-            "eleTrkD0/D", "eleTrkZ0/D", "eleTrkEcalX/D", "eleTrkEcalY/D",
-            "eleHasL1/B", "eleHasL2/B",
-            "eleMatchChisq/D", "eleClT/D", "eleClE/D", "eleClHits/I",
-            "posPX/D", "posPY/D", "posPZ/D", "posP/D",
-            "posTrkChisq/D", "posTrkHits/I", "posTrkType/I", "posTrkT/D",
-            "posTrkD0/D", "posTrkZ0/D", "posTrkEcalX/D", "posTrkEcalY/D",
-            "posHasL1/B", "posHasL2/B",
-            "posMatchChisq/D", "posClT/D", "posClE/D", "posClHits/I",
-            "minL1Iso/D"
-        };
-    }
-
-    public void setMaxChi2GBLTrack(double maxChi2GBLTrack) {
-        this.maxChi2GBLTrack = maxChi2GBLTrack;
-    }
-
-    public void setMaxUnconVertChi2(double maxUnconVertChi2) {
-        this.maxUnconVertChi2 = maxUnconVertChi2;
-    }
-
-    public void setMaxBsconVertChi2(double maxBsconVertChi2) {
-        this.maxBsconVertChi2 = maxBsconVertChi2;
-    }
-
-    public void setV0UnconVyCut(double v0UnconVyCut) {
-        this.v0UnconVyCut = v0UnconVyCut;
-    }
-
-    public void setV0UnconVxCut(double v0UnconVxCut) {
-        this.v0UnconVxCut = v0UnconVxCut;
-    }
-
-    public void setV0BsconVyCut(double v0BsconVyCut) {
-        this.v0BsconVyCut = v0BsconVyCut;
-    }
-
-    public void setV0BsconVxCut(double v0BsconVxCut) {
-        this.v0BsconVxCut = v0BsconVxCut;
-    }
-
-    public void setL1IsoMin(double l1IsoMin) {
-        this.l1IsoMin = l1IsoMin;
-    }
-
-    public void setBeamSizeX(double beamSizeX) {
-        this.beamSize[1] = beamSizeX;
-    }
-
-    public void setBeamSizeY(double beamSizeY) {
-        this.beamSize[2] = beamSizeY;
-    }
-
-    public void setBeamPosX(double beamPosX) {
-        this.beamPos[1] = beamPosX;
-    }
-
-    public void setBeamPosY(double beamPosY) {
-        this.beamPos[2] = beamPosY;
-    }
-
-    double ebeam;
-
-    @Override
-    protected void detectorChanged(Detector detector) {
-        LOGGER.info("TridendMonitoring::detectorChanged  Setting up the plotter");
-        beamAxisRotation.setActiveEuler(Math.PI / 2, -0.0305, -Math.PI / 2);
-
-        BeamEnergyCollection beamEnergyCollection
-                = this.getConditionsManager().getCachedConditions(BeamEnergyCollection.class, "beam_energies").getCachedData();
-        ebeam = beamEnergyCollection.get(0).getBeamEnergy();
-        aida.tree().cd("/");
-        String trkType = "SeedTrack/";
-        if (isGBL) {
-            trkType = "GBLTrack/";
-        }
-        /*  V0 Quantities   */
-        /*  Mass, vertex, chi^2 of fit */
-        /* beamspot constrained */
-//        IHistogram1D nV0 = aida.histogram1D(plotDir +  triggerType + "/"+"Number of V0 per event", 10, 0, 10);
-//        IHistogram1D bsconMass = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Mass (GeV)", 100, 0, 0.200);
-//        IHistogram1D bsconVx = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vx (mm)", 50, -1, 1);
-//        IHistogram1D bsconVy = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vy (mm)", 50, -1, 1);
-//        IHistogram1D bsconVz = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Vz (mm)", 50, -10, 10);
-//        IHistogram1D bsconChi2 = aida.histogram1D(plotDir +  triggerType + "/"+"BS Constrained Chi2", 25, 0, 25);
-//        /* target constrained */
-//        IHistogram1D tarconMass = aida.histogram1D(plotDir +  triggerType + "/"+"Target Constrained Mass (GeV)", 100, 0, 0.200);
-//        IHistogram1D tarconVx = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vx (mm)", 50, -1, 1);
-//        IHistogram1D tarconVy = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vy (mm)", 50, -1, 1);
-//        IHistogram1D tarconVz = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Vz (mm)", 50, -10, 10);
-//        IHistogram1D tarconChi2 = aida.histogram1D(plotDir +  triggerType + "/"+ triggerType + "/"+"Target Constrained Chi2", 25, 0, 25);
-        nTriCand = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Number of Trident Candidates", 5, 0, 4);
-
-//        triTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Track time difference", 100, -10, 10);
-//        triTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-        triTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Positron vs. electron momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        triDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Positron - electron momentum", 100, -ebeam, ebeam);
-        triSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Positron + electron momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        triPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Py(e) vs Py(p)", 50, -v0PyMax * ebeam, v0PyMax * ebeam, 50, -v0PyMax * ebeam, v0PyMax * ebeam);
-        triPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Px(e) vs Px(p)", 50, -v0PxMax * ebeam, v0PxMax * ebeam, 50, -v0PxMax * ebeam, v0PxMax * ebeam);
-
-        triMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex mass vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, 0, 0.1 * ebeam);
-        triZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, -v0VzMax, v0VzMax);
-        triMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex mass", 100, 0, 0.1 * ebeam);
-        triZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-//        triX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex X", 100, -v0VxMax, v0VxMax);
-//        triY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Y", 100, -v0VyMax, v0VyMax);
-//        triZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z", 100, -v0VzMax, v0VzMax);
-//        triXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-//        triZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-//        triPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Px", 100, -v0PxMax, v0PxMax);
-//        triPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py", 100, -v0PyMax, v0PyMax);
-//        triPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Pz", 100, v0PzMin, v0PzMax);
-//        triPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py vs. Px", 100, -v0PxMax, v0PxMax, 100, -v0PyMax, v0PyMax);
-//        triU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Px over Ptot", 100, -0.1, 0.1);
-//        triV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Trident: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-        triRadTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Track time difference", 100, -10, 10);
-        triRadTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-
-        triRadTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Positron vs. electron momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        triRadDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Positron - electron momentum", 100, -ebeam, ebeam);
-        triRadSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Positron + electron momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        triRadPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Py(e) vs Py(p)", 50, -v0PyMax * ebeam, v0PyMax * ebeam, 50, -v0PyMax * ebeam, v0PyMax * ebeam);
-        triRadPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Px(e) vs Px(p)", 50, -v0PxMax * ebeam, v0PxMax * ebeam, 50, -v0PxMax * ebeam, v0PxMax * ebeam);
-
-//        triRadMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex mass vs. vertex momentum", 100, v0PzMin, v0PzMax, 100, 0, 0.1);
-//        triRadZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Z vs. vertex momentum", 100, v0PzMin, v0PzMax, 100, -v0VzMax, v0VzMax);
-        triRadMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex mass", 100, 0, 0.1 * ebeam);
-        triRadZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-//        triRadX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex X", 100, -v0VxMax, v0VxMax);
-//        triRadY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Y", 100, -v0VyMax, v0VyMax);
-//        triRadZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Z", 100, -v0VzMax, v0VzMax);
-//        triRadXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-//        triRadZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-        triRadPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Px", 100, -v0PxMax * ebeam, v0PxMax * ebeam);
-        triRadPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Py", 100, -v0PyMax * ebeam, v0PyMax * ebeam);
-        triRadPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Pz", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        triRadPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Py vs. Px", 100, -v0PxMax * ebeam, v0PxMax * ebeam, 100, -v0PyMax * ebeam, v0PyMax * ebeam);
-        triRadU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Px over Ptot", 100, -0.1, 0.1);
-        triRadV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative trident: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-//        vertTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Track time difference", 100, -10, 10);
-//        vertTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-        vertTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Positron vs. electron momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        vertDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Positron - electron momentum", 100, -ebeam, ebeam);
-        vertSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Positron + electron momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        vertPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Py(e) vs Py(p)", 50, -v0PyMax * ebeam, v0PyMax * ebeam, 50, -v0PyMax * ebeam, v0PyMax * ebeam);
-        vertPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Px(e) vs Px(p)", 50, -v0PxMax * ebeam, v0PxMax * ebeam, 50, -v0PxMax * ebeam, v0PxMax * ebeam);
-
-        vertMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex mass vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, 0, 0.1 * ebeam);
-        vertZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, -v0VzMax, v0VzMax);
-        vertMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex mass", 100, 0, 0.1 * ebeam);
-        vertZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-//        vertX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex X", 100, -v0VxMax, v0VxMax);
-        vertY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Y", 100, -v0VyMax, v0VyMax);
-//        vertZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z", 100, -v0VzMax, v0VzMax);
-        vertXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-        vertZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-//        vertPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Px", 100, -v0PxMax, v0PxMax);
-//        vertPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py", 100, -v0PyMax, v0PyMax);
-//        vertPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Pz", 100, v0PzMin, v0PzMax);
-//        vertPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py vs. Px", 100, -v0PxMax, v0PxMax, 100, -v0PyMax, v0PyMax);
-//        vertU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Px over Ptot", 100, -0.1, 0.1);
-//        vertV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Vertex: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-        vertRadTrackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Track time difference", 100, -10, 10);
-        vertRadTrackTime2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Track time vs. track time", 100, -10, 10, 100, -10, 10);
-
-        vertRadTrackMomentum2D = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Positron vs. electron momentum", 100, 0, v0PzMax * ebeam, 100, 0, v0PzMax * ebeam);
-        vertRadDeltaP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Positron - electron momentum", 100, -ebeam, ebeam);
-        vertRadSumP = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Positron + electron momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        vertRadPyEleVsPyPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Py(e) vs Py(p)", 50, -v0PyMax * ebeam, v0PyMax * ebeam, 50, -v0PyMax * ebeam, v0PyMax * ebeam);
-        vertRadPxEleVsPxPos = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Px(e) vs Px(p)", 50, -v0PxMax * ebeam, v0PxMax * ebeam, 50, -v0PxMax * ebeam, v0PxMax * ebeam);
-
-        vertRadMassMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex mass vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, 0, 0.1 * ebeam);
-        vertRadZVsMomentum = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Z vs. vertex momentum", 100, v0PzMin * ebeam, v0PzMax * ebeam, 100, -v0VzMax, v0VzMax);
-        vertRadMass = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex mass", 100, 0, 0.1 * ebeam);
-        vertRadZVsMass = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Z vs. mass", 100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-        vertRadX = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex X", 100, -v0VxMax, v0VxMax);
-        vertRadY = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Y", 100, -v0VyMax, v0VyMax);
-        vertRadZ = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Z", 100, -v0VzMax, v0VzMax);
-        vertRadXY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Y vs. X", 100, -v0VxMax, v0VxMax, 100, -v0VyMax, v0VyMax);
-        vertRadZY = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Z vs. Y", 100, -v0VyMax, v0VyMax, 100, -v0VzMax, v0VzMax);
-        vertRadPx = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Px", 100, -v0PxMax * ebeam, v0PxMax * ebeam);
-        vertRadPy = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Py", 100, -v0PyMax * ebeam, v0PyMax * ebeam);
-        vertRadPz = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Pz", 100, v0PzMin * ebeam, v0PzMax * ebeam);
-        vertRadPxPy = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Py vs. Px", 100, -v0PxMax * ebeam, v0PxMax * ebeam, 100, -v0PyMax * ebeam, v0PyMax * ebeam);
-        vertRadU = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Px over Ptot", 100, -0.1, 0.1);
-        vertRadV = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Radiative vertex: Vertex Py over Ptot", 100, -0.1, 0.1);
-
-        vertRadUnconBsconChi2 = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Radiative vertex: beamspot chi2 vs. uncon chi2", 100, 0, 25.0, 100, 0, 25.0);
-
-        nVtxCand = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Number of Vertexing Candidates", 5, 0, 4);
-
-        maxTrkChi2 = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: Trk Chi2", 50, 0.0, 50.0);
-        zVsMaxTrkChi2 = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs Trk Chi2", 50, 0.0, 50.0, 50, -v0VzMax, v0VzMax);
-
-        v0Chi2 = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: V0 Chi2", 50, 0.0, 25.0);
-        zVsV0Chi2 = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs V0 Chi2", 50, 0.0, 25.0, 50, -v0VzMax, v0VzMax);
-        bsconV0Chi2 = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: Bscon V0 Chi2", 50, 0.0, 25.0);
-        zVsBsconV0Chi2 = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs Bscon V0 Chi2", 50, 0.0, 25.0, 50, -v0VzMax, v0VzMax);
-        v0Chi2Diff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: Bscon-Uncon V0 Chi2 Diff", 50, 0.0, 25.0);
-        zVsV0Chi2Diff = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs Bscon-Uncon V0 Chi2 Diff", 50, 0.0, 25.0, 50, -v0VzMax, v0VzMax);
-
-        trackTimeDiff = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: Trk Time Diff", 50, 0.0, 10.0);
-        hitTimeStdDev = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: Hit Time Std Dev", 50, 0.0, 10.0);
-        zVsTrackTimeDiff = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs Trk Time Diff", 50, 0.0, 10.0, 50, -v0VzMax, v0VzMax);
-        zVsHitTimeStdDev = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs Hit Time Std Dev", 50, 0.0, 10.0, 50, -v0VzMax, v0VzMax);
-
-        eventTrkCount = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: Num Tracks", 10, 0.5, 10.5);
-        eventPosCount = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: Num Positrons", 5, 0.5, 5.5);
-        zVsEventTrkCount = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs Num Tracks", 10, 0.5, 10.5, 50, -v0VzMax, v0VzMax);
-        zVsEventPosCount = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs Num Positrons", 5, 0.5, 5.5, 50, -v0VzMax, v0VzMax);
-
-        l1Iso = aida.histogram1D(plotDir + trkType + triggerType + "/" + "Cut: L1 Isolation", 100, 0.0, 5.0);
-        zVsL1Iso = aida.histogram2D(plotDir + trkType + triggerType + "/" + "Cut: Vz vs L1 Isolation", 100, 0.0, 5.0, 50, -v0VzMax, v0VzMax);
-
-        for (Cut cut : Cut.values()) {
-            for (int i = 0; i < 2; i++) {
-                cutVertexZ[cut.ordinal()][i] = aida.histogram1D(String.format("%s%s%s/failed cut %d: %s/%s: Vertex Z position (mm)", plotDir, trkType, triggerType, cut.ordinal(), cut.name, i == VERTEX ? "vertex" : "trident"),
-                        100, -v0VzMax, v0VzMax);
-                cutVertexMass[cut.ordinal()][i] = aida.histogram1D(String.format("%s%s%s/failed cut %d: %s/%s: Vertex mass (GeV)", plotDir, trkType, triggerType, cut.ordinal(), cut.name, i == VERTEX ? "vertex" : "trident"),
-                        100, 0, 0.1 * ebeam);
-                cutVertexZVsMass[cut.ordinal()][i] = aida.histogram2D(String.format("%s%s%s/failed cut %d: %s/%s: Vertex Z vs. mass", plotDir, trkType, triggerType, cut.ordinal(), cut.name, i == VERTEX ? "vertex" : "trident"),
-                        100, 0, 0.1 * ebeam, 100, -v0VzMax, v0VzMax);
-            }
-        }
+    public TridentTupleDriver() {
+        addEventVariables();
+        addVertexVariables();
+        addParticleVariables("ele");
+        addParticleVariables("pos");
+        String[] newVars = new String[]{"minPositiveIso/D", "minNegativeIso/D", "minIso/D"};
+        tupleVariables.addAll(Arrays.asList(newVars));
     }
 
     @Override
     public void process(EventHeader event) {
         /*  make sure everything is there */
-        if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) {
-            return;
-        }
         if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName)) {
             return;
         }
-//        if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName)) {
-//            return;
-//        }
-//        if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName)) {
-//            return;
-//        }
 
-        //check to see if this event is from the correct trigger (or "all");
-        if (!matchTrigger(event)) {
-            return;
-        }
-
-        nEvents++;
-
-        int nV0 = 0;
-        List<ReconstructedParticle> unConstrainedV0List = event.get(ReconstructedParticle.class, unconstrainedV0CandidatesColName);
-        for (ReconstructedParticle v0 : unConstrainedV0List) {
-            if (isGBL == TrackType.isGBL(v0.getType())) {
-                nV0++;
-            }
-        }
-        nRecoV0 += nV0;
-
-        RelationalTable hitToStrips = TrackUtils.getHitToStripsTable(event);
-        RelationalTable hitToRotated = TrackUtils.getHitToRotatedTable(event);
-
-        List<ReconstructedParticle> fspList = event.get(ReconstructedParticle.class, finalStateParticlesColName);
-        int npos = 0;
-        int ntrk = 0;
-        for (ReconstructedParticle fsp : fspList) {
-            if (isGBL != TrackType.isGBL(fsp.getType())) {
-                continue;
-            }
-            if (fsp.getCharge() != 0) {
-                ntrk++;
-            }
-            if (fsp.getCharge() > 0) {
-                npos++;
+        TIData triggerData = null;
+        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
+            for (GenericObject data : event.get(GenericObject.class, "TriggerBank")) {
+                if (AbstractIntData.getTag(data) == TIData.BANK_TAG) {
+                    triggerData = new TIData(data);
+                }
             }
         }
 
-        List<ReconstructedParticle> candidateList = new ArrayList<>();
-        List<ReconstructedParticle> vertCandidateList = new ArrayList<>();
+        //check to see if this event is from the correct trigger (or "all");
+        if (triggerData != null && !matchTriggerType(triggerData)) {
+            return;
+        }
+        List<ReconstructedParticle> unConstrainedV0List = event.get(ReconstructedParticle.class, unconstrainedV0CandidatesColName);
+
         for (ReconstructedParticle uncV0 : unConstrainedV0List) {
             if (isGBL != TrackType.isGBL(uncV0.getType())) {
                 continue;
             }
-            Vertex uncVert = uncV0.getStartVertex();
-//  v0 & vertex-quality cuts
-            Hep3Vector v0MomRot = VecOp.mult(beamAxisRotation, uncV0.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, uncVert.getPosition());
+            tupleMap.clear();
+            fillEventVariables(event, triggerData);
 
-            List<Track> tracks = new ArrayList<Track>();
             ReconstructedParticle electron = uncV0.getParticles().get(ReconParticleDriver.ELECTRON);
             ReconstructedParticle positron = uncV0.getParticles().get(ReconParticleDriver.POSITRON);
             if (electron.getCharge() != -1 || positron.getCharge() != 1) {
                 throw new RuntimeException("incorrect charge on v0 daughters");
             }
-            tracks.add(electron.getTracks().get(0));
-            tracks.add(positron.getTracks().get(0));
-            if (tracks.size() != 2) {
-                throw new RuntimeException("expected two tracks in vertex, got " + tracks.size());
-            }
-            List<Double> hitTimes = new ArrayList<Double>();
-            double mean = 0;
-            for (Track track : tracks) {
-                for (TrackerHit hit : TrackUtils.getStripHits(track, hitToStrips, hitToRotated)) {
-                    mean += hit.getTime();
-                    hitTimes.add(hit.getTime());
-                }
-            }
-            mean /= hitTimes.size();
-            double stdDev = 0;
-            for (Double time : hitTimes) {
-                stdDev += Math.pow(time - mean, 2);
-            }
-            stdDev /= (hitTimes.size() - 1);
-            stdDev = Math.sqrt(stdDev);
 
-            Double[] eleIso = TrackUtils.getIsolations(electron.getTracks().get(0), hitToStrips, hitToRotated);
-            Double[] posIso = TrackUtils.getIsolations(positron.getTracks().get(0), hitToStrips, hitToRotated);
-            double minL1Iso = -9999;
-            if (eleIso[0] != null && posIso[0] != null) {
-                double eleL1Iso = Math.min(Math.abs(eleIso[0]), Math.abs(eleIso[1]));
-                double posL1Iso = Math.min(Math.abs(posIso[0]), Math.abs(posIso[1]));
-                minL1Iso = Math.min(eleL1Iso, posL1Iso);
-            }
+            Track eleTrack = electron.getTracks().get(0);
+            Track posTrack = positron.getTracks().get(0);
 
-            double tEle = TrackUtils.getTrackTime(electron.getTracks().get(0), hitToStrips, hitToRotated);
-            double tPos = TrackUtils.getTrackTime(positron.getTracks().get(0), hitToStrips, hitToRotated);
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, electron.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, positron.getMomentum());
+            TrackState eleTSTweaked = fillParticleVariables(event, electron, "ele");
+            TrackState posTSTweaked = fillParticleVariables(event, positron, "pos");
 
-            Hep3Vector eleAtEcal = TrackUtils.getTrackPositionAtEcal(electron.getTracks().get(0));
-            Hep3Vector posAtEcal = TrackUtils.getTrackPositionAtEcal(positron.getTracks().get(0));
+            List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
+            billiorTracks.add(new BilliorTrack(eleTSTweaked, eleTrack.getChi2(), eleTrack.getNDF()));
+            billiorTracks.add(new BilliorTrack(posTSTweaked, posTrack.getChi2(), posTrack.getNDF()));
 
-            BilliorVertexer vtxFitter = new BilliorVertexer(TrackUtils.getBField(event.getDetector()).y());
-            vtxFitter.setBeamSize(beamSize);
-            vtxFitter.setBeamPosition(beamPos);
-            List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
-            billiorTracks.add(new BilliorTrack(electron.getTracks().get(0)));
-            billiorTracks.add(new BilliorTrack(positron.getTracks().get(0)));
+            double minPositiveIso = Math.min(tupleMap.get("eleMinPositiveIso/D"), tupleMap.get("posMinPositiveIso/D"));
+            double minNegativeIso = Math.max(Math.min(tupleMap.get("eleMinPositiveIso/D"), 9999), Math.min(tupleMap.get("posMinPositiveIso/D"), 9999));
+            double minIso = Math.min(Math.abs(minPositiveIso), Math.abs(minNegativeIso));
 
-            vtxFitter.doBeamSpotConstraint(true);
-            BilliorVertex bsconVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle bscV0 = HpsReconParticleDriver.makeReconstructedParticle(electron, positron, bsconVertex);
-            Hep3Vector bscMomRot = VecOp.mult(beamAxisRotation, bscV0.getMomentum());
-            Hep3Vector bscVtx = VecOp.mult(beamAxisRotation, bscV0.getStartVertex().getPosition());
+            fillVertexVariables(event, billiorTracks, electron, positron);
 
-            vtxFitter.doTargetConstraint(true);
-            BilliorVertex tarVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle tarV0 = HpsReconParticleDriver.makeReconstructedParticle(electron, positron, tarVertex);
-            Hep3Vector tarMomRot = VecOp.mult(beamAxisRotation, tarV0.getMomentum());
-            Hep3Vector tarVtx = VecOp.mult(beamAxisRotation, tarV0.getStartVertex().getPosition());
-
-            vtxFitter.setBeamSize(vzcBeamSize);
-            vtxFitter.doTargetConstraint(true);
-            BilliorVertex vzcVertex = vtxFitter.fitVertex(billiorTracks);
-            ReconstructedParticle vzcV0 = HpsReconParticleDriver.makeReconstructedParticle(electron, positron, vzcVertex);
-            Hep3Vector vzcMomRot = VecOp.mult(beamAxisRotation, vzcV0.getMomentum());
-            Hep3Vector vzcVtx = VecOp.mult(beamAxisRotation, vzcV0.getStartVertex().getPosition());
-
+            tupleMap.put("minPositiveIso/D", minPositiveIso);
+            tupleMap.put("minNegativeIso/D", minNegativeIso);
+            tupleMap.put("minIso/D", minIso);
             if (tupleWriter != null) {
-                boolean trkCut = electron.getMomentum().magnitude() < tupleTrkPCut * ebeam && positron.getMomentum().magnitude() < tupleTrkPCut * ebeam;
-                boolean sumCut = electron.getMomentum().magnitude() + positron.getMomentum().magnitude() < tupleMaxSumCut * ebeam;
+                boolean trkCut = tupleMap.get("eleP/D") < tupleTrkPCut * ebeam && tupleMap.get("posP/D") < tupleTrkPCut * ebeam;
+                boolean sumCut = tupleMap.get("eleP/D") + tupleMap.get("posP/D") < tupleMaxSumCut * ebeam;
                 if (!cutTuple || (trkCut && sumCut)) {
-
-                    tupleMap.put("run/I", (double) event.getRunNumber());
-                    tupleMap.put("event/I", (double) event.getEventNumber());
-
-                    tupleMap.put("uncPX/D", v0MomRot.x());
-                    tupleMap.put("uncPY/D", v0MomRot.y());
-                    tupleMap.put("uncPZ/D", v0MomRot.z());
-                    tupleMap.put("uncP/D", v0MomRot.magnitude());
-                    tupleMap.put("uncVX/D", v0Vtx.x());
-                    tupleMap.put("uncVY/D", v0Vtx.y());
-                    tupleMap.put("uncVZ/D", v0Vtx.z());
-                    tupleMap.put("uncChisq/D", uncV0.getStartVertex().getChi2());
-                    tupleMap.put("uncM/D", uncV0.getMass());
-
-                    tupleMap.put("bscPX/D", bscMomRot.x());
-                    tupleMap.put("bscPY/D", bscMomRot.y());
-                    tupleMap.put("bscPZ/D", bscMomRot.z());
-                    tupleMap.put("bscP/D", bscMomRot.magnitude());
-                    tupleMap.put("bscVX/D", bscVtx.x());
-                    tupleMap.put("bscVY/D", bscVtx.y());
-                    tupleMap.put("bscVZ/D", bscVtx.z());
-                    tupleMap.put("bscChisq/D", bscV0.getStartVertex().getChi2());
-                    tupleMap.put("bscM/D", bscV0.getMass());
-
-                    tupleMap.put("tarPX/D", tarMomRot.x());
-                    tupleMap.put("tarPY/D", tarMomRot.y());
-                    tupleMap.put("tarPZ/D", tarMomRot.z());
-                    tupleMap.put("tarP/D", tarMomRot.magnitude());
-                    tupleMap.put("tarVX/D", tarVtx.x());
-                    tupleMap.put("tarVY/D", tarVtx.y());
-                    tupleMap.put("tarVZ/D", tarVtx.z());
-                    tupleMap.put("tarChisq/D", tarV0.getStartVertex().getChi2());
-                    tupleMap.put("tarM/D", tarV0.getMass());
-
-                    tupleMap.put("vzcPX/D", vzcMomRot.x());
-                    tupleMap.put("vzcPY/D", vzcMomRot.y());
-                    tupleMap.put("vzcPZ/D", vzcMomRot.z());
-                    tupleMap.put("vzcP/D", vzcMomRot.magnitude());
-                    tupleMap.put("vzcVX/D", vzcVtx.x());
-                    tupleMap.put("vzcVY/D", vzcVtx.y());
-                    tupleMap.put("vzcVZ/D", vzcVtx.z());
-                    tupleMap.put("vzcChisq/D", vzcV0.getStartVertex().getChi2());
-                    tupleMap.put("vzcM/D", vzcV0.getMass());
-
-                    tupleMap.put("elePX/D", pEleRot.x());
-                    tupleMap.put("elePY/D", pEleRot.y());
-                    tupleMap.put("elePZ/D", pEleRot.z());
-                    tupleMap.put("eleP/D", pEleRot.magnitude());
-                    tupleMap.put("eleTrkD0/D", electron.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("eleTrkZ0/D", electron.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("eleTrkEcalX/D", eleAtEcal.x());
-                    tupleMap.put("eleTrkEcalY/D", eleAtEcal.y());
-                    tupleMap.put("eleTrkChisq/D", electron.getTracks().get(0).getChi2());
-                    tupleMap.put("eleTrkHits/I", (double) electron.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("eleTrkType/I", (double) electron.getType());
-                    tupleMap.put("eleTrkT/D", tEle);
-                    tupleMap.put("eleHasL1/B", eleIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("eleHasL2/B", eleIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("eleMatchChisq/D", electron.getGoodnessOfPID());
-                    if (!electron.getClusters().isEmpty()) {
-                        Cluster eleC = electron.getClusters().get(0);
-                        tupleMap.put("eleClT/D", ClusterUtilities.getSeedHitTime(eleC));
-                        tupleMap.put("eleClE/D", eleC.getEnergy());
-                        tupleMap.put("eleClHits/I", (double) eleC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("posPX/D", pPosRot.x());
-                    tupleMap.put("posPY/D", pPosRot.y());
-                    tupleMap.put("posPZ/D", pPosRot.z());
-                    tupleMap.put("posP/D", pPosRot.magnitude());
-                    tupleMap.put("posTrkD0/D", positron.getTracks().get(0).getTrackStates().get(0).getD0());
-                    tupleMap.put("posTrkZ0/D", positron.getTracks().get(0).getTrackStates().get(0).getZ0());
-                    tupleMap.put("posTrkEcalX/D", posAtEcal.x());
-                    tupleMap.put("posTrkEcalY/D", posAtEcal.y());
-                    tupleMap.put("posTrkChisq/D", positron.getTracks().get(0).getChi2());
-                    tupleMap.put("posTrkHits/I", (double) positron.getTracks().get(0).getTrackerHits().size());
-                    tupleMap.put("posTrkType/I", (double) positron.getType());
-                    tupleMap.put("posTrkT/D", tPos);
-                    tupleMap.put("posHasL1/B", posIso[0] != null ? 1.0 : 0.0);
-                    tupleMap.put("posHasL2/B", posIso[2] != null ? 1.0 : 0.0);
-                    tupleMap.put("posMatchChisq/D", positron.getGoodnessOfPID());
-                    if (!positron.getClusters().isEmpty()) {
-                        Cluster posC = positron.getClusters().get(0);
-                        tupleMap.put("posClT/D", ClusterUtilities.getSeedHitTime(posC));
-                        tupleMap.put("posClE/D", posC.getEnergy());
-                        tupleMap.put("posClHits/I", (double) posC.getCalorimeterHits().size());
-                    }
-
-                    tupleMap.put("minL1Iso/D", minL1Iso);
-
-                    tupleMap.put("nTrk/I", (double) ntrk);
-                    tupleMap.put("nPos/I", (double) npos);
                     writeTuple();
                 }
             }
-
-            //start applying cuts
-            EnumSet<Cut> bits = EnumSet.noneOf(Cut.class);
-
-            boolean trackQualityCut = Math.max(electron.getTracks().get(0).getChi2(), positron.getTracks().get(0).getChi2()) < (isGBL ? maxChi2GBLTrack : maxChi2SeedTrack);
-            if (trackQualityCut) {
-                bits.add(Cut.TRK_QUALITY);
-            }
-
-            boolean v0QualityCut = uncVert.getChi2() < maxUnconVertChi2 && bsconVertex.getChi2() < maxBsconVertChi2;
-            if (v0QualityCut) {
-                bits.add(Cut.VTX_QUALITY);
-            }
-
-            boolean vertexMomentumCut = v0MomRot.z() < v0PzMaxCut * ebeam && v0MomRot.z() > v0PzMinCut * ebeam && Math.abs(v0MomRot.x()) < v0PxCut * ebeam && Math.abs(v0MomRot.y()) < v0PyCut * ebeam;
-            boolean vertexPositionCut = Math.abs(v0Vtx.x()) < v0UnconVxCut && Math.abs(v0Vtx.y()) < v0UnconVyCut && Math.abs(v0Vtx.z()) < v0UnconVzCut && Math.abs(bscVtx.x()) < v0BsconVxCut && Math.abs(bscVtx.y()) < v0BsconVyCut;
-            if (vertexMomentumCut && vertexPositionCut) {
-                bits.add(Cut.VERTEX_CUTS);
-            }
-
-            boolean trackTimeDiffCut = Math.abs(tEle - tPos) < trkTimeDiff;
-            if (trackTimeDiffCut) {
-                bits.add(Cut.TIMING);
-            }
-
-            boolean topBottomCut = electron.getMomentum().y() * positron.getMomentum().y() < 0;
-            boolean pMinCut = electron.getMomentum().magnitude() > minPCut * ebeam && positron.getMomentum().magnitude() > minPCut * ebeam;
-            boolean pMaxCut = electron.getMomentum().magnitude() < beamPCut * ebeam && positron.getMomentum().magnitude() < beamPCut * ebeam;
-            if (topBottomCut && pMaxCut && pMinCut) {
-                bits.add(Cut.TRACK_CUTS);
-            }
-
-            boolean clusterMatchCut = !electron.getClusters().isEmpty() && !positron.getClusters().isEmpty();
-            boolean clusterTimeCut = clusterMatchCut && Math.abs(ClusterUtilities.getSeedHitTime(electron.getClusters().get(0)) - ClusterUtilities.getSeedHitTime(positron.getClusters().get(0))) < clusterTimeDiffCut;
-//disable cut for now
-//            if (clusterMatchCut && clusterTimeCut) {
-            bits.add(Cut.CLUSTER_CUTS);
-//            }
-
-            boolean eventTrkCountCut = ntrk >= 2 && ntrk <= nTrkMax;
-            boolean eventPosCountCut = npos >= 1 && npos <= nPosMax;
-            if (eventTrkCountCut && eventPosCountCut) {
-                bits.add(Cut.EVENT_QUALITY);
-            }
-
-            boolean frontHitsCut = eleIso[0] != null && posIso[0] != null && eleIso[2] != null && posIso[2] != null;
-            if (frontHitsCut) {
-                bits.add(Cut.FRONT_HITS);
-            }
-
-            boolean isoCut = minL1Iso > l1IsoMin;
-            if (!frontHitsCut || isoCut) { //diagnostic plots look better if failing the front hits cut makes you pass this one
-                bits.add(Cut.ISOLATION);
-            }
-
-            for (Cut cut : Cut.values()) {
-                if (bits.contains(cut)) {
-                    if (cut.ordinal() == Cut.firstVertexingCut) {//if we get here, we've passed all non-vertexing cuts
-                        candidateList.add(uncV0);
-                    }
-                    nPassCut[cut.ordinal()]++;
-                } else {
-                    break;
-                }
-            }
-
-            for (Cut cut : Cut.values()) {
-                EnumSet<Cut> allButThisCut = EnumSet.allOf(Cut.class);
-                allButThisCut.remove(cut);
-                if (bits.containsAll(allButThisCut)) {
-                    if (uncV0.getMass() > plotsMinMass * ebeam && uncV0.getMass() < plotsMaxMass * ebeam && uncV0.getMomentum().magnitude() > radCut * ebeam) {
-                        switch (cut) {
-                            case ISOLATION:
-                                l1Iso.fill(minL1Iso);
-                                zVsL1Iso.fill(minL1Iso, v0Vtx.z());
-                                break;
-                            case EVENT_QUALITY:
-                                eventTrkCount.fill(ntrk);
-                                eventPosCount.fill(npos);
-                                zVsEventTrkCount.fill(ntrk, v0Vtx.z());
-                                zVsEventPosCount.fill(npos, v0Vtx.z());
-                                break;
-                            case TIMING:
-                                trackTimeDiff.fill(Math.abs(tEle - tPos));
-                                hitTimeStdDev.fill(stdDev);
-                                zVsTrackTimeDiff.fill(Math.abs(tEle - tPos), v0Vtx.z());
-                                zVsHitTimeStdDev.fill(stdDev, v0Vtx.z());
-                                break;
-                            case VTX_QUALITY:
-                                v0Chi2.fill(uncVert.getChi2());
-                                zVsV0Chi2.fill(uncVert.getChi2(), v0Vtx.z());
-                                bsconV0Chi2.fill(bsconVertex.getChi2());
-                                zVsBsconV0Chi2.fill(bsconVertex.getChi2(), v0Vtx.z());
-                                v0Chi2Diff.fill(bsconVertex.getChi2() - uncVert.getChi2());
-                                zVsV0Chi2Diff.fill(bsconVertex.getChi2() - uncVert.getChi2(), v0Vtx.z());
-                                break;
-                            case TRK_QUALITY:
-                                maxTrkChi2.fill(Math.max(tracks.get(0).getChi2(), tracks.get(1).getChi2()));
-                                zVsMaxTrkChi2.fill(Math.max(tracks.get(0).getChi2(), tracks.get(1).getChi2()), v0Vtx.z());
-                                break;
-                        }
-                    }
-                    if (!bits.contains(cut)) {
-                        if (uncV0.getMass() > plotsMinMass * ebeam && uncV0.getMass() < plotsMaxMass * ebeam) {
-                            cutVertexZ[cut.ordinal()][VERTEX].fill(v0Vtx.z());
-                        }
-                        cutVertexMass[cut.ordinal()][VERTEX].fill(uncV0.getMass());
-                        cutVertexZVsMass[cut.ordinal()][VERTEX].fill(uncV0.getMass(), v0Vtx.z());
-                    }
-                }
-
-                EnumSet<Cut> allTriCutsButThisCut = EnumSet.range(Cut.values()[0], Cut.values()[Cut.firstVertexingCut - 1]);
-                allTriCutsButThisCut.remove(cut);
-                if (bits.containsAll(allTriCutsButThisCut)) {
-                    if (!bits.contains(cut)) {
-                        if (uncV0.getMass() > plotsMinMass * ebeam && uncV0.getMass() < plotsMaxMass * ebeam) {
-                            cutVertexZ[cut.ordinal()][TRIDENT].fill(v0Vtx.z());
-                        }
-                        cutVertexMass[cut.ordinal()][TRIDENT].fill(uncV0.getMass());
-                        cutVertexZVsMass[cut.ordinal()][TRIDENT].fill(uncV0.getMass(), v0Vtx.z());
-                    }
-                }
-            }
-
-            if (bits.containsAll(EnumSet.range(Cut.values()[0], Cut.values()[Cut.firstVertexingCut - 1]))) {
-                candidateList.add(uncV0);
-            }
-            if (bits.equals(EnumSet.allOf(Cut.class))) {
-                vertCandidateList.add(uncV0);
-            }
-        }
-
-        nTriCand.fill(candidateList.size());
-        nVtxCand.fill(vertCandidateList.size());
-
-        if (!candidateList.isEmpty()) {
-            // pick the best candidate...for now just pick a random one. 
-            ReconstructedParticle bestCandidate = candidateList.get((int) (Math.random() * candidateList.size()));
-
-            //fill some stuff: 
-            ReconstructedParticle electron = bestCandidate.getParticles().get(ReconParticleDriver.ELECTRON);
-            ReconstructedParticle positron = bestCandidate.getParticles().get(ReconParticleDriver.POSITRON);
-            if (electron.getCharge() != -1 || positron.getCharge() != 1) {
-                throw new RuntimeException("vertex needs e+ and e- but is missing one or both");
-            }
-
-            double tEle = TrackUtils.getTrackTime(electron.getTracks().get(0), hitToStrips, hitToRotated);
-            double tPos = TrackUtils.getTrackTime(positron.getTracks().get(0), hitToStrips, hitToRotated);
-            Hep3Vector pBestV0Rot = VecOp.mult(beamAxisRotation, bestCandidate.getMomentum());
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, electron.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, positron.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, bestCandidate.getStartVertex().getPosition());
-
-//            triTrackTime2D.fill(tEle, tPos);
-//            triTrackTimeDiff.fill(tEle - tPos);
-            triZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-            triMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-            triTrackMomentum2D.fill(electron.getMomentum().magnitude(), positron.getMomentum().magnitude());
-            triPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-            triPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-            triSumP.fill(bestCandidate.getMomentum().magnitude());
-            triDeltaP.fill(positron.getMomentum().magnitude() - electron.getMomentum().magnitude());
-
-//            triPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-            triMass.fill(bestCandidate.getMass());
-            triZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-//            triX.fill(v0Vtx.x());
-//            triY.fill(v0Vtx.y());
-//            triZ.fill(v0Vtx.z());
-//            triPx.fill(pBestV0Rot.x());
-//            triPy.fill(pBestV0Rot.y());
-//            triPz.fill(pBestV0Rot.z());
-//            triU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-//            triV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-//            triXY.fill(v0Vtx.x(), v0Vtx.y());
-//            triZY.fill(v0Vtx.y(), v0Vtx.z());
-            if (bestCandidate.getMomentum().magnitude() > radCut * ebeam) {
-                triRadTrackTime2D.fill(tEle, tPos);
-                triRadTrackTimeDiff.fill(tEle - tPos);
-//                triRadZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-//                triRadMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-                triRadTrackMomentum2D.fill(electron.getMomentum().magnitude(), positron.getMomentum().magnitude());
-                triRadPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-                triRadPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-                triRadSumP.fill(bestCandidate.getMomentum().magnitude());
-                triRadDeltaP.fill(positron.getMomentum().magnitude() - electron.getMomentum().magnitude());
-
-                triRadPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-                triRadMass.fill(bestCandidate.getMass());
-                triRadZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-//                triRadX.fill(v0Vtx.x());
-//                triRadY.fill(v0Vtx.y());
-//                triRadZ.fill(v0Vtx.z());
-                triRadPx.fill(pBestV0Rot.x());
-                triRadPy.fill(pBestV0Rot.y());
-                triRadPz.fill(pBestV0Rot.z());
-                triRadU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-                triRadV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-//                triRadXY.fill(v0Vtx.x(), v0Vtx.y());
-//                triRadZY.fill(v0Vtx.y(), v0Vtx.z());
-            }
-        }
-
-        if (!vertCandidateList.isEmpty()) {
-            // pick the best candidate...for now just pick a random one. 
-            ReconstructedParticle bestCandidate = vertCandidateList.get((int) (Math.random() * vertCandidateList.size()));
-            Vertex unconVertex = bestCandidate.getStartVertex();
-
-            //fill some stuff: 
-            ReconstructedParticle electron = bestCandidate.getParticles().get(ReconParticleDriver.ELECTRON);
-            ReconstructedParticle positron = bestCandidate.getParticles().get(ReconParticleDriver.POSITRON);
-            if (electron.getCharge() != -1 || positron.getCharge() != 1) {
-                throw new RuntimeException("vertex needs e+ and e- but is missing one or both");
-            }
-
-            double tEle = TrackUtils.getTrackTime(electron.getTracks().get(0), hitToStrips, hitToRotated);
-            double tPos = TrackUtils.getTrackTime(positron.getTracks().get(0), hitToStrips, hitToRotated);
-            Hep3Vector pBestV0Rot = VecOp.mult(beamAxisRotation, bestCandidate.getMomentum());
-            Hep3Vector pEleRot = VecOp.mult(beamAxisRotation, electron.getMomentum());
-            Hep3Vector pPosRot = VecOp.mult(beamAxisRotation, positron.getMomentum());
-            Hep3Vector v0Vtx = VecOp.mult(beamAxisRotation, unconVertex.getPosition());
-
-//            vertTrackTime2D.fill(tEle, tPos);
-//            vertTrackTimeDiff.fill(tEle - tPos);
-            vertZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-            vertMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-            vertTrackMomentum2D.fill(electron.getMomentum().magnitude(), positron.getMomentum().magnitude());
-            vertPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-            vertPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-            vertSumP.fill(bestCandidate.getMomentum().magnitude());
-            vertDeltaP.fill(positron.getMomentum().magnitude() - electron.getMomentum().magnitude());
-
-//            vertPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-            vertMass.fill(bestCandidate.getMass());
-            vertZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-//            vertX.fill(v0Vtx.x());
-            vertY.fill(v0Vtx.y());
-//            vertZ.fill(v0Vtx.z());
-//            vertPx.fill(pBestV0Rot.x());
-//            vertPy.fill(pBestV0Rot.y());
-//            vertPz.fill(pBestV0Rot.z());
-//            vertU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-//            vertV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-            vertXY.fill(v0Vtx.x(), v0Vtx.y());
-            vertZY.fill(v0Vtx.y(), v0Vtx.z());
-            if (bestCandidate.getMomentum().magnitude() > radCut * ebeam) {
-
-                BilliorVertexer vtxFitter = new BilliorVertexer(TrackUtils.getBField(event.getDetector()).y());
-                vtxFitter.setBeamSize(beamSize);
-                vtxFitter.setBeamPosition(beamPos);
-//                vtxFitter.setDebug(false);
-                List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
-                billiorTracks.add(new BilliorTrack(electron.getTracks().get(0)));
-                billiorTracks.add(new BilliorTrack(positron.getTracks().get(0)));
-                vtxFitter.doBeamSpotConstraint(true);
-                BilliorVertex bsconVertex = vtxFitter.fitVertex(billiorTracks);
-                vtxFitter.doTargetConstraint(true);
-                BilliorVertex tarconVertex = vtxFitter.fitVertex(billiorTracks);
-                vertRadUnconBsconChi2.fill(unconVertex.getChi2(), bsconVertex.getChi2());
-
-                vertRadTrackTime2D.fill(tEle, tPos);
-                vertRadTrackTimeDiff.fill(tEle - tPos);
-                vertRadZVsMomentum.fill(bestCandidate.getMomentum().magnitude(), v0Vtx.z());
-                vertRadMassMomentum.fill(bestCandidate.getMomentum().magnitude(), bestCandidate.getMass());
-                vertRadTrackMomentum2D.fill(electron.getMomentum().magnitude(), positron.getMomentum().magnitude());
-                vertRadPyEleVsPyPos.fill(pEleRot.y(), pPosRot.y());
-                vertRadPxEleVsPxPos.fill(pEleRot.x(), pPosRot.x());
-                vertRadSumP.fill(bestCandidate.getMomentum().magnitude());
-                vertRadDeltaP.fill(positron.getMomentum().magnitude() - electron.getMomentum().magnitude());
-
-                vertRadPxPy.fill(pBestV0Rot.x(), pBestV0Rot.y());
-                vertRadMass.fill(bestCandidate.getMass());
-                vertRadZVsMass.fill(bestCandidate.getMass(), v0Vtx.z());
-                vertRadX.fill(v0Vtx.x());
-                vertRadY.fill(v0Vtx.y());
-                vertRadZ.fill(v0Vtx.z());
-                vertRadPx.fill(pBestV0Rot.x());
-                vertRadPy.fill(pBestV0Rot.y());
-                vertRadPz.fill(pBestV0Rot.z());
-                vertRadU.fill(pBestV0Rot.x() / pBestV0Rot.magnitude());
-                vertRadV.fill(pBestV0Rot.y() / pBestV0Rot.magnitude());
-                vertRadXY.fill(v0Vtx.x(), v0Vtx.y());
-                vertRadZY.fill(v0Vtx.y(), v0Vtx.z());
-            }
         }
     }
-
-    @Override
-    // TODO: Change from System.out to use logger instead.
-    public void printDQMData() {
-        System.out.println("TridendMonitoring::printDQMData");
-        for (Entry<String, Double> entry : monitoredQuantityMap.entrySet()) {
-            System.out.println(entry.getKey() + " = " + entry.getValue());
-        }
-        System.out.println("*******************************");
-
-        System.out.println("TridendMonitoring::Tridend Selection Summary: " + (isGBL ? "GBLTrack" : "SeedTrack"));
-
-        System.out.println("\t\t\tTridend Selection Summary");
-        System.out.println("******************************************************************************************");
-        System.out.println(String.format("Number of      V0:\t%8.0f\t%8.6f\t%8.6f\t%8.6f\n", nRecoV0, nRecoV0 / nRecoV0, nRecoV0 / nRecoV0, nRecoV0 / nEvents));
-
-        for (Cut cut : Cut.values()) {
-            if (cut.ordinal() == Cut.firstVertexingCut) {
-                System.out.println("******************************************************************************************");
-                System.out.println("\t\t\tVertex Selection Summary");
-                System.out.println("******************************************************************************************");
-            }
-            System.out.format("%-12s Cuts:\t%8.0f\t%8.6f\t%8.6f\t%8.6f\n", cut.name, nPassCut[cut.ordinal()], nPassCut[cut.ordinal()] / (cut.ordinal() == 0 ? nRecoV0 : nPassCut[cut.ordinal() == 0 ? 0 : (cut.ordinal() - 1)]), nPassCut[cut.ordinal()] / nRecoV0, nPassCut[cut.ordinal()] / nEvents);
-        }
-        System.out.println("******************************************************************************************");
-    }
-
-    /**
-     * Calculate the averages here and fill the map
-     */
-    @Override
-    public void calculateEndOfRunQuantities() {
-
-        IAnalysisFactory analysisFactory = IAnalysisFactory.create();
-        IFitFactory fitFactory = analysisFactory.createFitFactory();
-        IFitter fitter = fitFactory.createFitter("chi2");
-
-    }
-
-    @Override
-    public void printDQMStrings() {
-        for (int i = 0; i < 9; i++)//TODO:  do this in a smarter way...loop over the map
-        {
-            LOGGER.info("ALTER TABLE dqm ADD " + fpQuantNames[i] + " double;");
-        }
-    }
-
-    IFitResult fitVertexPosition(IHistogram1D h1d, IFitter fitter, double[] init, String range
-    ) {
-        return fitter.fit(h1d, "g+p1", init, range);
-    }
-
 }

Copied: java/trunk/analysis/src/main/java/org/hps/analysis/tuple/TupleDriver.java (from r4372, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java)
 =============================================================================
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java	(original)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/tuple/TupleDriver.java	Tue May 24 18:30:43 2016
@@ -1,21 +1,38 @@
-package org.hps.analysis.dataquality;
-
+package org.hps.analysis.tuple;
+
+import hep.physics.vec.BasicHep3Matrix;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
 import java.io.FileNotFoundException;
 import java.io.PrintWriter;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import org.apache.commons.lang3.StringUtils;
-import org.hps.record.triggerbank.AbstractIntData;
+import org.hps.conditions.beam.BeamEnergy;
+import org.hps.recon.ecal.cluster.ClusterUtilities;
+import org.hps.recon.particle.HpsReconParticleDriver;
+import org.hps.recon.tracking.CoordinateTransformations;
+import org.hps.recon.tracking.TrackType;
+import org.hps.recon.tracking.TrackUtils;
+import org.hps.recon.tracking.gbl.GBLKinkData;
+import org.hps.recon.vertexing.BilliorTrack;
+import org.hps.recon.vertexing.BilliorVertex;
+import org.hps.recon.vertexing.BilliorVertexer;
 import org.hps.record.triggerbank.TIData;
+import org.lcsim.event.Cluster;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.GenericObject;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
+import org.lcsim.event.TrackState;
+import org.lcsim.event.base.BaseTrackState;
+import org.lcsim.fit.helicaltrack.HelicalTrackFit;
+import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
-import org.lcsim.util.aida.AIDA;
 
 /**
  * sort of an interface for DQM analysis drivers creates the DQM database
@@ -24,29 +41,87 @@
  * @author mgraham on Apr 15, 2014 update mgraham on May 15, 2014 to include
  * calculateEndOfRunQuantities & printDQMData i.e. useful methods
  */
-public class DataQualityMonitor extends Driver {
-
-    private static final Logger LOGGER = Logger.getLogger(DataQualityMonitor.class.getPackage().getName());
-
-    protected AIDA aida = AIDA.defaultInstance();
-    protected DQMDatabaseManager manager;
-    protected String recoVersion = "v0.0";
-    protected static int runNumber = 1350;
-    protected boolean overwriteDB = false;
-    protected boolean connectToDB = false;
-    protected boolean printDQMStrings = false;
-    protected Map<String, Double> monitoredQuantityMap = new HashMap<>();
+public class TupleDriver extends Driver {
+
     protected boolean debug = false;
-    protected boolean outputPlots = false;
-    protected String outputPlotDir = "DQMOutputPlots/";
 
     protected PrintWriter tupleWriter = null;
-    protected String[] tupleVariables = {};
+    protected final List<String> tupleVariables = new ArrayList<String>();
     protected final Map<String, Double> tupleMap = new HashMap<String, Double>();
     protected boolean cutTuple = false;
 
-    String triggerType = "all";//allowed types are "" (blank) or "all", singles0, singles1, pairs0,pairs1
+    protected String triggerType = "all";//allowed types are "" (blank) or "all", singles0, singles1, pairs0,pairs1
     public boolean isGBL = false;
+
+    private final String finalStateParticlesColName = "FinalStateParticles";
+    protected double bfield;
+    private final double[] beamSize = {0.001, 0.130, 0.050}; //rough estimate from harp scans during engineering run production running
+    private final double[] beamPos = {0.0, 0.0, 0.0};
+    private final double[] vzcBeamSize = {0.001, 100, 100};
+    private final double[] topTrackCorrection = {0, 0, 0, 0, 0};
+    private final double[] botTrackCorrection = {0, 0, 0, 0, 0};
+    protected final BasicHep3Matrix beamAxisRotation = new BasicHep3Matrix();
+    protected double ebeam = Double.NaN;
+
+    public void setEbeam(double ebeam) {
+        this.ebeam = ebeam;
+    }
+
+    public void setBeamSizeX(double beamSizeX) {
+        this.beamSize[1] = beamSizeX;
+    }
+
+    public void setBeamSizeY(double beamSizeY) {
+        this.beamSize[2] = beamSizeY;
+    }
+
+    public void setBeamPosX(double beamPosX) {
+        this.beamPos[1] = beamPosX;
+    }
+
+    public void setBeamPosY(double beamPosY) {
+        this.beamPos[2] = beamPosY;
+    }
+
+    public void setTopDZ0(double topDZ0) {
+        topTrackCorrection[HelicalTrackFit.z0Index] = topDZ0;
+    }
+
+    public void setTopDLambda(double topDLambda) {
+        topTrackCorrection[HelicalTrackFit.slopeIndex] = topDLambda;
+    }
+
+    public void setTopDD0(double topDD0) {
+        topTrackCorrection[HelicalTrackFit.dcaIndex] = topDD0;
+    }
+
+    public void setTopDPhi(double topDPhi) {
+        topTrackCorrection[HelicalTrackFit.phi0Index] = topDPhi;
+    }
+
+    public void setTopDOmega(double topDOmega) {
+        topTrackCorrection[HelicalTrackFit.curvatureIndex] = topDOmega;
+    }
+
+    public void setBotDZ0(double botDZ0) {
+        botTrackCorrection[HelicalTrackFit.z0Index] = botDZ0;
+    }
+
+    public void setBotDLambda(double botDLambda) {
+        botTrackCorrection[HelicalTrackFit.slopeIndex] = botDLambda;
+    }
+
+    public void setBotDD0(double botDD0) {
+        botTrackCorrection[HelicalTrackFit.dcaIndex] = botDD0;
+    }
+
+    public void setBotDPhi(double botDPhi) {
+        botTrackCorrection[HelicalTrackFit.phi0Index] = botDPhi;
+    }
+
+    public void setBotDOmega(double botDOmega) {
+        botTrackCorrection[HelicalTrackFit.curvatureIndex] = botDOmega;
+    }
 
     public void setTriggerType(String type) {
         this.triggerType = type;
@@ -56,141 +131,30 @@
         this.isGBL = isgbl;
     }
 
-    public void setRecoVersion(String recoVersion) {
-        this.recoVersion = recoVersion;
-    }
-
     public void setDebug(boolean debug) {
         this.debug = debug;
     }
 
-    public void setRunNumber(int run) {
-        DataQualityMonitor.runNumber = run;
-    }
-
-    public void setOverwriteDB(boolean overwrite) {
-        this.overwriteDB = overwrite;
-    }
-
-    public void setConnectToDB(boolean connect) {
-        this.connectToDB = connect;
-    }
-
-    public void setPrintDQMStrings(boolean print) {
-        this.printDQMStrings = print;
-    }
-
-    public void setOutputPlots(boolean out) {
-        this.outputPlots = out;
-    }
-
-    public void setOutputPlotDir(String dir) {
-        this.outputPlotDir = dir;
+    @Override
+    protected void detectorChanged(Detector detector) {
+        beamAxisRotation.setActiveEuler(Math.PI / 2, -0.0305, -Math.PI / 2);
+        bfield = TrackUtils.getBField(detector).magnitude();
+
+        BeamEnergy.BeamEnergyCollection beamEnergyCollection
+                = this.getConditionsManager().getCachedConditions(BeamEnergy.BeamEnergyCollection.class, "beam_energies").getCachedData();
+        if (Double.isNaN(ebeam)) {
+            ebeam = beamEnergyCollection.get(0).getBeamEnergy();
+        }
     }
 
     @Override
     public void endOfData() {
-        calculateEndOfRunQuantities();
-        fillEndOfRunPlots();
-        printDQMData();
-        if (printDQMStrings) {
-            printDQMStrings();
-        }
-        LOGGER.info("Write to database =  " + connectToDB);
-        if (connectToDB) {
-            LOGGER.info("Connecting To Database...getting DQMDBManager");
-            manager = DQMDatabaseManager.getInstance();
-            //check to see if I need to make a new db entry
-            boolean entryExists = false;
-            try {
-                entryExists = checkRowExists();
-                if (entryExists) {
-                    LOGGER.info("Found an existing run/reco entry in the dqm database; overwrite = " + overwriteDB);
-                }
-            } catch (SQLException ex) {
-                Logger.getLogger(DataQualityMonitor.class.getName()).log(Level.SEVERE, null, ex);
-            }
-
-            if (!entryExists) {
-                makeNewRow();
-            }
-            dumpDQMData();
-        }
         if (tupleWriter != null) {
             tupleWriter.close();
         }
     }
 
-    private void makeNewRow() {
-        LOGGER.info("is the data base connected?  " + manager.isConnected);
-        if (manager.isConnected) {
-            String ins = "insert into dqm SET runNumber=" + runNumber;
-//            LOGGER.info(ins);
-            manager.updateQuery(ins);
-            ins = "update  dqm SET recoVersion='" + recoVersion + "' where runNumber=" + runNumber;
-            manager.updateQuery(ins);
-        }
-        LOGGER.info("Made a new row for runNumber=" + runNumber + "; recoVersion=" + recoVersion);
-    }
-
-    private boolean checkRowExists() throws SQLException {
-        String ins = "select * from dqm where " + getRunRecoString();
-        ResultSet res = manager.selectQuery(ins);
-        return res.next(); //this is a funny way of determining if the ResultSet has any entries
-    }
-
-    public boolean checkSelectionIsNULL(String var) throws SQLException {
-        String ins = "select " + var + " from dqm where " + getRunRecoString();
-        ResultSet res = manager.selectQuery(ins);
-        res.next();
-        double result = res.getDouble(var);
-        if (res.wasNull()) {
-            return true;
-        }
-        LOGGER.info("checkSelectionIsNULL::" + var + " = " + result);
-        return false;
-    }
-
-    public String getRunRecoString() {
-        return "runNumber=" + runNumber + " and recoVersion='" + recoVersion + "'";
-    }
-
-    //override this method to do something interesting   
-    //like fill some plots that you only want to fill at end of data (e.g. for occupancies)
-    public void fillEndOfRunPlots() {
-    }
-
-    //override this method to do something interesting   
-    //like calculate averages etc. that can then be put in the db  
-    public void calculateEndOfRunQuantities() {
-    }
-
-    public void dumpDQMData() {
-        for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) {
-            String name = entry.getKey();
-            double val = entry.getValue();
-            boolean isnull = false;
-            try {
-                isnull = checkSelectionIsNULL(name);
-            } catch (SQLException ex) {
-                Logger.getLogger(SvtMonitoring.class.getName()).log(Level.SEVERE, null, ex);
-            }
-            if (!overwriteDB && !isnull) {
-                LOGGER.info("Not writing because " + name + " is already filled for this entry");
-                continue; //entry exists and I don't want to overwrite                
-            }
-            String put = "update dqm SET " + name + " = " + val + " WHERE " + getRunRecoString();
-            LOGGER.info(put);
-            manager.updateQuery(put);
-
-        }
-    }
-
-    public String getTriggerType() {
-        return triggerType;
-    }
-
-    public boolean matchTriggerType(TIData triggerData) {
+    protected boolean matchTriggerType(TIData triggerData) {
         if (triggerType.contentEquals("") || triggerType.contentEquals("all")) {
             return true;
         }
@@ -207,37 +171,6 @@
             return true;
         }
         return false;
-
-    }
-
-    public boolean matchTrigger(EventHeader event) {
-        boolean match = true;
-        if (event.hasCollection(GenericObject.class, "TriggerBank")) {
-            List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank");
-            for (GenericObject data : triggerList) {
-                if (AbstractIntData.getTag(data) == TIData.BANK_TAG) {
-                    TIData triggerData = new TIData(data);
-                    if (!matchTriggerType(triggerData))//only process singles0 triggers...
-                    {
-                        match = false;
-                    }
-                }
-            }
-        } else if (debug) {
-            LOGGER.info(this.getClass().getSimpleName() + ":  No trigger bank found...running over all trigger types");
-        }
-        return match;
-    }
-
-    //override this method to do something interesting   
-    //like print the DQM data log file
-    public void printDQMData() {
-    }
-
-    //override this method to do something interesting   
-    //like print the DQM db variable strings in a good 
-    //format for making the db column headers
-    public void printDQMStrings() {
     }
 
     protected void writeTuple() {
@@ -253,7 +186,7 @@
             }
         }
         tupleWriter.println();
-        tupleMap.clear();
+//        tupleMap.clear();
     }
 
     public void setTupleFile(String tupleFile) {
@@ -278,4 +211,232 @@
     public void setCutTuple(boolean cutTuple) {
         this.cutTuple = cutTuple;
     }
+
+    protected void addEventVariables() {
+        String[] newVars = new String[]{"run/I", "event/I",
+            "nTrk/I", "nPos/I",
+            "isCalib/B", "isPulser/B", "isSingle0/B", "isSingle1/B", "isPair0/B", "isPair1/B"};
+        tupleVariables.addAll(Arrays.asList(newVars));
+    }
+
+    protected void addVertexVariables() {
+        String[] newVars = new String[]{"uncPX/D", "uncPY/D", "uncPZ/D", "uncP/D",
+            "uncVX/D", "uncVY/D", "uncVZ/D", "uncChisq/D", "uncM/D",
+            "bscPX/D", "bscPY/D", "bscPZ/D", "bscP/D",
+            "bscVX/D", "bscVY/D", "bscVZ/D", "bscChisq/D", "bscM/D",
+            "tarPX/D", "tarPY/D", "tarPZ/D", "tarP/D",
+            "tarVX/D", "tarVY/D", "tarVZ/D", "tarChisq/D", "tarM/D",
+            "vzcPX/D", "vzcPY/D", "vzcPZ/D", "vzcP/D",
+            "vzcVX/D", "vzcVY/D", "vzcVZ/D", "vzcChisq/D", "vzcM/D"};
+        tupleVariables.addAll(Arrays.asList(newVars));
+    }
+
+    protected void addParticleVariables(String prefix) {
+        String[] newVars = new String[]{"PX/D", "PY/D", "PZ/D", "P/D",
+            "TrkChisq/D", "TrkHits/I", "TrkType/I", "TrkT/D",
+            "TrkZ0/D", "TrkLambda/D", "TrkD0/D", "TrkPhi/D", "TrkOmega/D",
+            "TrkEcalX/D", "TrkEcalY/D",
+            "HasL1/B", "HasL2/B", "HasL3/B",
+            "FirstHitX/D", "FirstHitY/D",
+            "LambdaKink1/D", "LambdaKink2/D", "LambdaKink3/D",
+            "PhiKink1/D", "PhiKink2/D", "PhiKink3/D",
+            "IsoStereo/D", "IsoAxial/D",
+            "MinPositiveIso/D", "MinNegativeIso/D",
+            "MatchChisq/D", "ClT/D", "ClE/D", "ClX/D", "ClY/D", "ClZ/D", "ClHits/I"};
+        for (int i = 0; i < newVars.length; i++) {
+            newVars[i] = prefix + newVars[i];
+        }
+        tupleVariables.addAll(Arrays.asList(newVars));
+    }
+
+    protected void fillEventVariables(EventHeader event, TIData triggerData) {
+        tupleMap.put("run/I", (double) event.getRunNumber());
+        tupleMap.put("event/I", (double) event.getEventNumber());
+        List<ReconstructedParticle> fspList = event.get(ReconstructedParticle.class, finalStateParticlesColName);
+        int npos = 0;
+        int ntrk = 0;
+        for (ReconstructedParticle fsp : fspList) {
+            if (isGBL != TrackType.isGBL(fsp.getType())) {
+                continue;
+            }
+            if (fsp.getCharge() != 0) {
+                ntrk++;
+            }
+            if (fsp.getCharge() > 0) {
+                npos++;
+            }
+        }
+
+        tupleMap.put("nTrk/I", (double) ntrk);
+        tupleMap.put("nPos/I", (double) npos);
+
+        if (triggerData != null) {
+            tupleMap.put("isCalib/B", triggerData.isCalibTrigger() ? 1.0 : 0.0);
+            tupleMap.put("isPulser/B", triggerData.isPulserTrigger() ? 1.0 : 0.0);
+            tupleMap.put("isSingle0/B", triggerData.isSingle0Trigger() ? 1.0 : 0.0);
+            tupleMap.put("isSingle1/B", triggerData.isSingle1Trigger() ? 1.0 : 0.0);
+            tupleMap.put("isPair0/B", triggerData.isPair0Trigger() ? 1.0 : 0.0);
+            tupleMap.put("isPair1/B", triggerData.isPair1Trigger() ? 1.0 : 0.0);
+        }
+    }
+
+    protected TrackState fillParticleVariables(EventHeader event, ReconstructedParticle particle, String prefix) {
+        Track track = particle.getTracks().get(0);
+        TrackState trackState = track.getTrackStates().get(0);
+        double[] param = new double[5];
+        for (int i = 0; i < 5; i++) {
+            param[i] = trackState.getParameters()[i] + ((trackState.getTanLambda() > 0) ? topTrackCorrection[i] : botTrackCorrection[i]);
+        }
+//            Arrays.
+        TrackState tweakedTrackState = new BaseTrackState(param, trackState.getReferencePoint(), trackState.getCovMatrix(), trackState.getLocation(), bfield);
+        Hep3Vector pRot = VecOp.mult(beamAxisRotation, CoordinateTransformations.transformVectorToDetector(new BasicHep3Vector(tweakedTrackState.getMomentum())));
+
+        Double[] iso = TrackUtils.getIsolations(track, TrackUtils.getHitToStripsTable(event), TrackUtils.getHitToRotatedTable(event));
+        double minPositiveIso = 9999;
+        double minNegativeIso = 9999;
+        double isoStereo = -9999, isoAxial = -9999;
+        for (int i = 0; i < 6; i++) {
+            if (iso[2 * i] != null) {
+                if (pRot.y() < 0) {
+                    isoStereo = iso[2 * i];
+                    isoAxial = iso[2 * i + 1];
+                } else {
+                    isoAxial = iso[2 * i];
+                    isoStereo = iso[2 * i + 1];
+                }
+                for (int j = 2 * i; j < 2 * i + 2; j++) {
+                    if (iso[j] < 100) {
+                        if (iso[j] > 0) {
+                            if (minPositiveIso > 100 || iso[j] < minPositiveIso) {
+                                minPositiveIso = iso[j];
+                            }
+                        } else {
+                            if (minNegativeIso > 100 || iso[j] > minNegativeIso) {
+                                minNegativeIso = iso[j];
+                            }
+                        }
+                    }
+                }
+                break;
+            }
+        }
+        double trkT = TrackUtils.getTrackTime(track, TrackUtils.getHitToStripsTable(event), TrackUtils.getHitToRotatedTable(event));
+        Hep3Vector atEcal = TrackUtils.getTrackPositionAtEcal(tweakedTrackState);
+        Hep3Vector firstHitPosition = VecOp.mult(beamAxisRotation, CoordinateTransformations.transformVectorToDetector(new BasicHep3Vector(track.getTrackerHits().get(0).getPosition())));
+        GenericObject kinks = GBLKinkData.getKinkData(event, track);
+
+        tupleMap.put(prefix + "PX/D", pRot.x());
+        tupleMap.put(prefix + "PY/D", pRot.y());
+        tupleMap.put(prefix + "PZ/D", pRot.z());
+        tupleMap.put(prefix + "P/D", pRot.magnitude());
+        tupleMap.put(prefix + "TrkZ0/D", tweakedTrackState.getZ0());
+        tupleMap.put(prefix + "TrkLambda/D", tweakedTrackState.getTanLambda());
+        tupleMap.put(prefix + "TrkD0/D", tweakedTrackState.getD0());
+        tupleMap.put(prefix + "TrkPhi/D", tweakedTrackState.getPhi());
+        tupleMap.put(prefix + "TrkOmega/D", tweakedTrackState.getOmega());
+        tupleMap.put(prefix + "TrkEcalX/D", atEcal.x());
+        tupleMap.put(prefix + "TrkEcalY/D", atEcal.y());
+        tupleMap.put(prefix + "TrkChisq/D", track.getChi2());
+        tupleMap.put(prefix + "TrkHits/I", (double) track.getTrackerHits().size());
+        tupleMap.put(prefix + "TrkType/I", (double) particle.getType());
+        tupleMap.put(prefix + "TrkT/D", trkT);
+        tupleMap.put(prefix + "HasL1/B", iso[0] != null ? 1.0 : 0.0);
+        tupleMap.put(prefix + "HasL2/B", iso[2] != null ? 1.0 : 0.0);
+        tupleMap.put(prefix + "HasL3/B", iso[4] != null ? 1.0 : 0.0);
+        tupleMap.put(prefix + "FirstHitX/D", firstHitPosition.x());
+        tupleMap.put(prefix + "FirstHitY/D", firstHitPosition.y());
+        tupleMap.put(prefix + "LambdaKink1/D", GBLKinkData.getLambdaKink(kinks, 1));
+        tupleMap.put(prefix + "LambdaKink2/D", GBLKinkData.getLambdaKink(kinks, 2));
+        tupleMap.put(prefix + "LambdaKink3/D", GBLKinkData.getLambdaKink(kinks, 3));
+        tupleMap.put(prefix + "PhiKink1/D", GBLKinkData.getPhiKink(kinks, 1));
+        tupleMap.put(prefix + "PhiKink2/D", GBLKinkData.getPhiKink(kinks, 2));
+        tupleMap.put(prefix + "PhiKink3/D", GBLKinkData.getPhiKink(kinks, 3));
+        tupleMap.put(prefix + "IsoStereo/D", isoStereo);
+        tupleMap.put(prefix + "IsoAxial/D", isoAxial);
+        tupleMap.put(prefix + "MinPositiveIso/D", minPositiveIso);
+        tupleMap.put(prefix + "MinNegativeIso/D", minNegativeIso);
+        tupleMap.put(prefix + "MatchChisq/D", particle.getGoodnessOfPID());
+        if (!particle.getClusters().isEmpty()) {
+            Cluster cluster = particle.getClusters().get(0);
+            tupleMap.put(prefix + "ClT/D", ClusterUtilities.getSeedHitTime(cluster));
+            tupleMap.put(prefix + "ClE/D", cluster.getEnergy());
+            tupleMap.put(prefix + "ClX/D", cluster.getPosition()[0]);
+            tupleMap.put(prefix + "ClY/D", cluster.getPosition()[1]);
+            tupleMap.put(prefix + "ClZ/D", cluster.getPosition()[2]);
+            tupleMap.put(prefix + "ClHits/I", (double) cluster.getCalorimeterHits().size());
+        }
+
+        return tweakedTrackState;
+    }
+
+    protected void fillVertexVariables(EventHeader event, List<BilliorTrack> billiorTracks, ReconstructedParticle electron, ReconstructedParticle positron) {
+        BilliorVertexer vtxFitter = new BilliorVertexer(TrackUtils.getBField(event.getDetector()).y());
+        vtxFitter.setBeamSize(beamSize);
+        vtxFitter.setBeamPosition(beamPos);
+
+        vtxFitter.doBeamSpotConstraint(false);
+        BilliorVertex uncVertex = vtxFitter.fitVertex(billiorTracks);
+        ReconstructedParticle uncV0 = HpsReconParticleDriver.makeReconstructedParticle(electron, positron, uncVertex);
+        Hep3Vector uncMomRot = VecOp.mult(beamAxisRotation, uncV0.getMomentum());
+        Hep3Vector uncVtx = VecOp.mult(beamAxisRotation, uncV0.getStartVertex().getPosition());
+
+        vtxFitter.doBeamSpotConstraint(true);
+        BilliorVertex bsconVertex = vtxFitter.fitVertex(billiorTracks);
+        ReconstructedParticle bscV0 = HpsReconParticleDriver.makeReconstructedParticle(electron, positron, bsconVertex);
+        Hep3Vector bscMomRot = VecOp.mult(beamAxisRotation, bscV0.getMomentum());
+        Hep3Vector bscVtx = VecOp.mult(beamAxisRotation, bscV0.getStartVertex().getPosition());
+
+        vtxFitter.doTargetConstraint(true);
+        BilliorVertex tarVertex = vtxFitter.fitVertex(billiorTracks);
+        ReconstructedParticle tarV0 = HpsReconParticleDriver.makeReconstructedParticle(electron, positron, tarVertex);
+        Hep3Vector tarMomRot = VecOp.mult(beamAxisRotation, tarV0.getMomentum());
+        Hep3Vector tarVtx = VecOp.mult(beamAxisRotation, tarV0.getStartVertex().getPosition());
+
+        vtxFitter.setBeamSize(vzcBeamSize);
+        vtxFitter.doTargetConstraint(true);
+        BilliorVertex vzcVertex = vtxFitter.fitVertex(billiorTracks);
+        ReconstructedParticle vzcV0 = HpsReconParticleDriver.makeReconstructedParticle(electron, positron, vzcVertex);
+        Hep3Vector vzcMomRot = VecOp.mult(beamAxisRotation, vzcV0.getMomentum());
+        Hep3Vector vzcVtx = VecOp.mult(beamAxisRotation, vzcV0.getStartVertex().getPosition());
+
+        tupleMap.put("uncPX/D", uncMomRot.x());
+        tupleMap.put("uncPY/D", uncMomRot.y());
+        tupleMap.put("uncPZ/D", uncMomRot.z());
+        tupleMap.put("uncP/D", uncMomRot.magnitude());
+        tupleMap.put("uncVX/D", uncVtx.x());
+        tupleMap.put("uncVY/D", uncVtx.y());
+        tupleMap.put("uncVZ/D", uncVtx.z());
+        tupleMap.put("uncChisq/D", uncV0.getStartVertex().getChi2());
+        tupleMap.put("uncM/D", uncV0.getMass());
+
+        tupleMap.put("bscPX/D", bscMomRot.x());
+        tupleMap.put("bscPY/D", bscMomRot.y());
+        tupleMap.put("bscPZ/D", bscMomRot.z());
+        tupleMap.put("bscP/D", bscMomRot.magnitude());
+        tupleMap.put("bscVX/D", bscVtx.x());
+        tupleMap.put("bscVY/D", bscVtx.y());
+        tupleMap.put("bscVZ/D", bscVtx.z());
+        tupleMap.put("bscChisq/D", bscV0.getStartVertex().getChi2());
+        tupleMap.put("bscM/D", bscV0.getMass());
+
+        tupleMap.put("tarPX/D", tarMomRot.x());
+        tupleMap.put("tarPY/D", tarMomRot.y());
+        tupleMap.put("tarPZ/D", tarMomRot.z());
+        tupleMap.put("tarP/D", tarMomRot.magnitude());
+        tupleMap.put("tarVX/D", tarVtx.x());
+        tupleMap.put("tarVY/D", tarVtx.y());
+        tupleMap.put("tarVZ/D", tarVtx.z());
+        tupleMap.put("tarChisq/D", tarV0.getStartVertex().getChi2());
+        tupleMap.put("tarM/D", tarV0.getMass());
+
+        tupleMap.put("vzcPX/D", vzcMomRot.x());
+        tupleMap.put("vzcPY/D", vzcMomRot.y());
+        tupleMap.put("vzcPZ/D", vzcMomRot.z());
+        tupleMap.put("vzcP/D", vzcMomRot.magnitude());
+        tupleMap.put("vzcVX/D", vzcVtx.x());
+        tupleMap.put("vzcVY/D", vzcVtx.y());
+        tupleMap.put("vzcVZ/D", vzcVtx.z());
+        tupleMap.put("vzcChisq/D", vzcV0.getStartVertex().getChi2());
+        tupleMap.put("vzcM/D", vzcV0.getMass());
+    }
 }

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use