Commit in java/trunk on MAIN
analysis/src/main/java/org/hps/analysis/ecal/HPSMCParticlePlotsDriver.java+1-1361 -> 363
analysis/src/main/java/org/hps/analysis/examples/DetailedAnalysisDriver.java+6-6361 -> 363
                                                /FastTrackAnalysisDriver.java+6-6361 -> 363
                                                /JasAnalysisDriver.java+7-7361 -> 363
                                                /StarterAnalysisDriver.java+1-1361 -> 363
ecal-readout-sim/pom.xml-47347 removed
ecal-readout-sim/src/main/java/org/hps/readout/ecal/DummyTriggerDriver.java-24347 removed
                                                   /EcalReadoutDriver.java-154347 removed
                                                   /FADCEcalReadoutDriver.java-571347 removed
                                                   /FADCTriggerDriver.java-522347 removed
                                                   /TimeEvolutionEcalReadoutDriver.java-94347 removed
                                                   /TriggerDriver.java-187347 removed
                                                   /TriggerableDriver.java-57347 removed
ecal-recon/pom.xml-43346 removed
evio/pom.xml-42356 removed
evio/src/main/java/org/hps/evio/BasicEvioFileReader.java-113356 removed
tracking/pom.xml-61348 removed
tracking/src/main/java/org/hps/recon/tracking/SimpleSvtReadout.java-425348 removed
tracking/src/main/java/org/hps/recon/tracking/apv25/Apv25Full.java-290348 removed
                                                   /HPSAPV25.java-353348 removed
                                                   /HPSSiSensorReadout.java-474348 removed
                                                   /SvtReadout.java-318348 removed
+21-3796
17 removed + 5 modified, total 22 files
Moving development from sandbox on new modules.  Builds on trunk should be unaffected for now

java/trunk/analysis/src/main/java/org/hps/analysis/ecal
HPSMCParticlePlotsDriver.java 361 -> 363
--- java/sandbox/analysis/src/main/java/org/hps/analysis/ecal/HPSMCParticlePlotsDriver.java	2014-03-26 02:17:16 UTC (rev 361)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/ecal/HPSMCParticlePlotsDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -14,7 +14,7 @@
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.MCParticle;
 import org.lcsim.event.base.ParticleTypeClassifier;
-import org.lcsim.hps.util.AIDAFrame;
+import org.hps.util.AIDAFrame;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
 

java/trunk/analysis/src/main/java/org/hps/analysis/examples
DetailedAnalysisDriver.java 361 -> 363
--- java/sandbox/analysis/src/main/java/org/hps/analysis/examples/DetailedAnalysisDriver.java	2014-03-26 02:17:16 UTC (rev 361)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/examples/DetailedAnalysisDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -41,12 +41,12 @@
 import org.lcsim.fit.helicaltrack.HelixParamCalculator;
 import org.lcsim.fit.helicaltrack.HelixUtils;
 import org.lcsim.fit.helicaltrack.TrackDirection;
-import org.lcsim.hps.recon.vertexing.BilliorTrack;
-import org.lcsim.hps.recon.vertexing.BilliorVertex;
-import org.lcsim.hps.recon.vertexing.StraightLineTrack;
-import org.lcsim.hps.recon.tracking.FindableTrack;
-import org.lcsim.hps.recon.tracking.TrackAnalysis;
-import org.lcsim.hps.recon.vertexing.BilliorVertexer;
+import org.hps.recon.vertexing.BilliorTrack;
+import org.hps.recon.vertexing.BilliorVertex;
+import org.hps.recon.vertexing.StraightLineTrack;
+import org.hps.recon.tracking.FindableTrack;
+import org.hps.recon.tracking.TrackAnalysis;
+import org.hps.recon.vertexing.BilliorVertexer;
 import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
 import org.lcsim.recon.tracking.seedtracker.SeedCandidate;
 import org.lcsim.recon.tracking.seedtracker.SeedTrack;

java/trunk/analysis/src/main/java/org/hps/analysis/examples
FastTrackAnalysisDriver.java 361 -> 363
--- java/sandbox/analysis/src/main/java/org/hps/analysis/examples/FastTrackAnalysisDriver.java	2014-03-26 02:17:16 UTC (rev 361)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/examples/FastTrackAnalysisDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -32,12 +32,12 @@
 import org.lcsim.fit.helicaltrack.HelicalTrackStrip;
 import org.lcsim.fit.helicaltrack.HelixUtils;
 import org.lcsim.fit.helicaltrack.TrackDirection;
-import org.lcsim.hps.recon.vertexing.BilliorTrack;
-import org.lcsim.hps.recon.vertexing.BilliorVertex;
-import org.lcsim.hps.recon.vertexing.StraightLineTrack;
-import org.lcsim.hps.recon.tracking.FindableTrack;
-import org.lcsim.hps.recon.tracking.TrackAnalysis;
-import org.lcsim.hps.recon.vertexing.BilliorVertexer;
+import org.hps.recon.vertexing.BilliorTrack;
+import org.hps.recon.vertexing.BilliorVertex;
+import org.hps.recon.vertexing.StraightLineTrack;
+import org.hps.recon.tracking.FindableTrack;
+import org.hps.recon.tracking.TrackAnalysis;
+import org.hps.recon.vertexing.BilliorVertexer;
 import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
 import org.lcsim.recon.tracking.seedtracker.SeedCandidate;
 import org.lcsim.recon.tracking.seedtracker.SeedTrack;

java/trunk/analysis/src/main/java/org/hps/analysis/examples
JasAnalysisDriver.java 361 -> 363
--- java/sandbox/analysis/src/main/java/org/hps/analysis/examples/JasAnalysisDriver.java	2014-03-26 02:17:16 UTC (rev 361)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/examples/JasAnalysisDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -34,13 +34,13 @@
 import org.lcsim.fit.helicaltrack.HelicalTrackHit;
 import org.lcsim.fit.helicaltrack.HelixParamCalculator;
 import org.lcsim.fit.helicaltrack.HelixUtils;
-import org.lcsim.hps.recon.vertexing.BFitter;
-import org.lcsim.hps.recon.vertexing.BilliorTrack;
-import org.lcsim.hps.recon.vertexing.BilliorVertex;
-import org.lcsim.hps.recon.vertexing.StraightLineTrack;
-import org.lcsim.hps.recon.tracking.FindableTrack;
-import org.lcsim.hps.recon.tracking.TrackAnalysis;
-import org.lcsim.hps.recon.vertexing.*;
+import org.hps.recon.vertexing.BFitter;
+import org.hps.recon.vertexing.BilliorTrack;
+import org.hps.recon.vertexing.BilliorVertex;
+import org.hps.recon.vertexing.StraightLineTrack;
+import org.hps.recon.tracking.FindableTrack;
+import org.hps.recon.tracking.TrackAnalysis;
+import org.hps.recon.vertexing.*;
 import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D;
 import org.lcsim.recon.tracking.seedtracker.SeedCandidate;
 import org.lcsim.recon.tracking.seedtracker.SeedTrack;

java/trunk/analysis/src/main/java/org/hps/analysis/examples
StarterAnalysisDriver.java 361 -> 363
--- java/sandbox/analysis/src/main/java/org/hps/analysis/examples/StarterAnalysisDriver.java	2014-03-26 02:17:16 UTC (rev 361)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/examples/StarterAnalysisDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -16,7 +16,7 @@
 import org.lcsim.geometry.compact.Field;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
-import org.lcsim.hps.recon.tracking.LCIOTrackAnalysis;
+import org.hps.recon.tracking.LCIOTrackAnalysis;
 
 /*
  * Example analysis driver.

java/trunk/ecal-readout-sim
pom.xml removed after 347
--- java/sandbox/ecal-readout-sim/pom.xml	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/pom.xml	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>hps-ecal-readout-sim</artifactId>
-    <name>hps-ecal-readout-sim</name>
-    <description>HPS ECAL readout simulation</description>
-    
-    <parent>
-        <groupId>org.hps</groupId>
-        <artifactId>hps-parent</artifactId>
-        <relativePath>../parent/pom.xml</relativePath>
-        <version>3.0.2-SNAPSHOT</version>
-    </parent>
-    
-    <scm>
-        <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-readout-sim/</url>
-        <connection>scm:svn:svn://svn.freehep.org/hps/java/trunk/ecal-readout-sim/</connection>
-        <developerConnection>scm:svn:svn://svn.freehep.org/hps/java/trunk/ecal-readout-sim/</developerConnection>
-    </scm>
-    
-    <dependencies>
-        <dependency>
-            <groupId>org.lcsim</groupId>
-            <artifactId>lcsim-distribution</artifactId>
-            <version>${lcsimVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-ecal-recon</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-conditions</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-util</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-            <version>3.2</version>
-        </dependency>
-    </dependencies>
-    
-</project>

java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal
DummyTriggerDriver.java removed after 347
--- java/sandbox/ecal-readout-sim/src/main/java/org/hps/readout/ecal/DummyTriggerDriver.java	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/DummyTriggerDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,24 +0,0 @@
-package org.hps.readout.ecal;
-
-import org.lcsim.event.EventHeader;
-import org.lcsim.hps.util.ClockSingleton;
-
-/**
- * Free-running trigger - triggers on every Nth event
- *
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: DummyTriggerDriver.java,v 1.3 2013/04/02 01:11:11 meeg Exp $
- */
-public class DummyTriggerDriver extends TriggerDriver {
-
-    int period = 100;
-
-    public void setPeriod(int period) {
-        this.period = period;
-    }
-
-    @Override
-    public boolean triggerDecision(EventHeader event) {
-        return (ClockSingleton.getClock() % period == 0);
-    }
-}

java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal
EcalReadoutDriver.java removed after 347
--- java/sandbox/ecal-readout-sim/src/main/java/org/hps/readout/ecal/EcalReadoutDriver.java	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/EcalReadoutDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,154 +0,0 @@
-package org.hps.readout.ecal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.lcsim.event.CalorimeterHit;
-import org.lcsim.event.EventHeader;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.lcio.LCIOConstants;
-
-/**
- * Performs readout of ECal hits.
- *
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: EcalReadoutDriver.java,v 1.4 2013/03/20 01:03:32 meeg Exp $
- */
-public abstract class EcalReadoutDriver<T> extends TriggerableDriver {
-
-    String ecalCollectionName;
-    String ecalRawCollectionName = "EcalRawHits";
-    String ecalReadoutName = "EcalHits";
-    Class hitClass;
-    //hit type as in org.lcsim.recon.calorimetry.CalorimeterHitType
-    int hitType = 0;
-    //number of bunches in readout cycle
-    int readoutCycle = 1;
-    //minimum readout value to write a hit
-    double threshold = 0.0;
-    //LCIO flags
-    int flags = 0;
-    //readout period in ns
-    double readoutPeriod = 2.0;
-    //readout period time offset in ns
-    double readoutOffset = 0.0;
-    //readout period counter
-    int readoutCounter;
-    public static boolean readoutBit = false;
-    protected boolean debug = false;
-
-    public EcalReadoutDriver() {
-        flags += 1 << LCIOConstants.CHBIT_LONG; //store position
-        flags += 1 << LCIOConstants.RCHBIT_ID1; //store cell ID
-        triggerDelay = 100.0;
-    }
-
-    public void setDebug(boolean debug) {
-        this.debug = debug;
-    }
-
-    public void setEcalReadoutName(String ecalReadoutName) {
-        this.ecalReadoutName = ecalReadoutName;
-    }
-
-    public void setEcalRawCollectionName(String ecalRawCollectionName) {
-        this.ecalRawCollectionName = ecalRawCollectionName;
-    }
-
-    public void setEcalCollectionName(String ecalCollectionName) {
-        this.ecalCollectionName = ecalCollectionName;
-    }
-
-    public void setReadoutCycle(int readoutCycle) {
-        this.readoutCycle = readoutCycle;
-        if (readoutCycle > 0) {
-            this.readoutPeriod = readoutCycle * ClockSingleton.getDt();
-        }
-    }
-
-    public void setReadoutOffset(double readoutOffset) {
-        this.readoutOffset = readoutOffset;
-    }
-
-    public void setReadoutPeriod(double readoutPeriod) {
-        this.readoutPeriod = readoutPeriod;
-        this.readoutCycle = -1;
-    }
-
-    public void setThreshold(double threshold) {
-        this.threshold = threshold;
-    }
-
-    @Override
-    public void startOfData() {
-        super.startOfData();
-        if (ecalCollectionName == null) {
-            throw new RuntimeException("The parameter ecalCollectionName was not set!");
-        }
-
-        readoutCounter = 0;
-
-        initReadout();
-    }
-
-    @Override
-    public void process(EventHeader event) {
-        //System.out.println(this.getClass().getCanonicalName() + " - process");
-        // Get the list of ECal hits.        
-        if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) {
-            List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
-
-            //write hits into buffers
-            putHits(hits);
-        }
-
-        ArrayList<T> newHits = null;
-
-        //if at the end of a readout cycle, write buffers to hits
-        if (readoutCycle > 0) {
-            if ((ClockSingleton.getClock() + 1) % readoutCycle == 0) {
-                if (newHits == null) {
-                    newHits = new ArrayList<T>();
-                }
-                readHits(newHits);
-                readoutCounter++;
-            }
-        } else {
-            while (ClockSingleton.getTime() - readoutTime() + ClockSingleton.getDt() >= readoutPeriod) {
-                if (newHits == null) {
-                    newHits = new ArrayList<T>();
-                }
-                readHits(newHits);
-                readoutCounter++;
-            }
-        }
-
-        if (newHits != null) {
-            event.put(ecalRawCollectionName, newHits, hitClass, flags, ecalReadoutName);
-        }
-
-        checkTrigger(event);
-    }
-
-    protected double readoutTime() {
-        return readoutCounter * readoutPeriod + readoutOffset;
-    }
-
-    //read analog signal out of buffers and make hits; reset buffers
-    protected abstract void readHits(List<T> hits);
-
-    //add deposited energy to buffers
-    //must be run every event, even if the list is empty
-    protected abstract void putHits(List<CalorimeterHit> hits);
-
-    @Override
-    protected void processTrigger(EventHeader event) {
-    }
-
-    //initialize buffers
-    protected abstract void initReadout();
-    
-    public int getTimestampType() {
-        return ReadoutTimestamp.SYSTEM_ECAL;
-    }
-}
\ No newline at end of file

java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal
FADCEcalReadoutDriver.java removed after 347
--- java/sandbox/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,571 +0,0 @@
-package org.hps.readout.ecal;
-
-import static org.hps.recon.ecal.ECalUtils.ecalReadoutPeriod;
-import static org.hps.recon.ecal.ECalUtils.fallTime;
-import static org.hps.recon.ecal.ECalUtils.maxVolt;
-import static org.hps.recon.ecal.ECalUtils.nBit;
-import static org.hps.recon.ecal.ECalUtils.readoutGain;
-import static org.hps.recon.ecal.ECalUtils.riseTime;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-import java.util.Set;
-
-import org.hps.conditions.deprecated.EcalConditions;
-import org.hps.recon.ecal.ECalUtils;
-import org.hps.recon.ecal.HPSRawCalorimeterHit;
-import org.lcsim.event.CalorimeterHit;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.RawCalorimeterHit;
-import org.lcsim.event.RawTrackerHit;
-import org.lcsim.event.base.BaseRawCalorimeterHit;
-import org.lcsim.event.base.BaseRawTrackerHit;
-import org.lcsim.geometry.Detector;
-import org.lcsim.geometry.Subdetector;
-import org.lcsim.geometry.subdetector.HPSEcal3;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.hps.util.RandomGaussian;
-import org.lcsim.hps.util.RingBuffer;
-import org.lcsim.lcio.LCIOConstants;
-
-/**
- * Performs readout of ECal hits. Simulates time evolution of preamp output
- * pulse.
- *
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: FADCEcalReadoutDriver.java,v 1.4 2013/10/31 00:11:02 meeg Exp $
- */
-public class FADCEcalReadoutDriver extends EcalReadoutDriver<RawCalorimeterHit> {
-
-    // Repeated here from EventConstants in evio module to avoid depending on it.
-    private static final int ECAL_WINDOW_MODE = 1;
-    private static final int ECAL_PULSE_MODE = 2;
-    private static final int ECAL_PULSE_INTEGRAL_MODE = 3;
-    
-    String ecalName = "Ecal";
-    Subdetector ecal;
-    //buffer for preamp signals (units of volts, no pedestal)
-    private Map<Long, RingBuffer> signalMap = null;
-    //ADC pipeline for readout (units of ADC counts)
-    private Map<Long, FADCPipeline> pipelineMap = null;
-    //buffer for window sums
-    private Map<Long, Double> sumMap = null;
-    //buffer for timestamps
-    private Map<Long, Integer> timeMap = null;
-    //queue for hits to be output to clusterer
-    private PriorityQueue<HPSRawCalorimeterHit> outputQueue = null;
-    //length of ring buffer (in readout cycles)
-    private int bufferLength = 100;
-    //length of readout pipeline (in readout cycles)
-    private int pipelineLength = 2000;
-    //switch between two pulse shape functions
-    private boolean useCRRCShape = true;
-    //shaper time constant in ns; negative values generate square pulses of the given width (for test run sim)
-    private double tp = 14.0;
-    //delay (number of readout periods) between start of summing window and output of hit to clusterer
-    private int delay0 = 32;
-    //start of readout window relative to trigger time (in readout cycles)
-    //in FADC documentation, "Programmable Latency" or PL
-    private int readoutLatency = 100;
-    //number of ADC samples to read out
-    //in FADC documentation, "Programmable Trigger Window" or PTW
-    private int readoutWindow = 100;
-    //number of ADC samples to read out before each rising threshold crossing
-    //in FADC documentation, "number of samples before" or NSB
-    private int numSamplesBefore = 5;
-    //number of ADC samples to read out after each rising threshold crossing
-    //in FADC documentation, "number of samples before" or NSA
-    private int numSamplesAfter = 30;
-//    private HPSEcalConverter converter = null;
-    //output buffer for hits
-    private LinkedList<HPSRawCalorimeterHit> buffer = new LinkedList<HPSRawCalorimeterHit>();
-    //number of readout periods for which a given hit stays in the buffer
-    private int coincidenceWindow = 2;
-    //output collection name for hits read out from trigger
-    private String ecalReadoutCollectionName = "EcalReadoutHits";
-    private int mode = ECAL_PULSE_INTEGRAL_MODE;
-    private int readoutThreshold = 50;
-    private int triggerThreshold = 50;
-    //amplitude ADC counts/GeV
-//    private double gain = 0.5*1000 * 80.0 / 60;
-    private double scaleFactor = 128;
-    private double fixedGain = -1;
-    private boolean constantTriggerWindow = false;
-    private boolean addNoise = false;
-    private double pePerMeV = 2.0; //photoelectrons per MeV, used to calculate noise
-
-    public FADCEcalReadoutDriver() {
-        flags = 0;
-        flags += 1 << LCIOConstants.RCHBIT_TIME; //store cell ID
-        hitClass = HPSRawCalorimeterHit.class;
-        setReadoutPeriod(ecalReadoutPeriod);
-//        converter = new HPSEcalConverter(null);
-    }
-
-    public void setAddNoise(boolean addNoise) {
-        this.addNoise = addNoise;
-    }
-
-    public void setConstantTriggerWindow(boolean constantTriggerWindow) {
-        this.constantTriggerWindow = constantTriggerWindow;
-    }
-
-    public void setFixedGain(double fixedGain) {
-        this.fixedGain = fixedGain;
-    }
-
-    public void setEcalName(String ecalName) {
-        this.ecalName = ecalName;
-    }
-
-    public void setReadoutThreshold(int readoutThreshold) {
-        this.readoutThreshold = readoutThreshold;
-    }
-
-    public void setScaleFactor(double scaleFactor) {
-        this.scaleFactor = scaleFactor;
-    }
-
-    public void setTriggerThreshold(int triggerThreshold) {
-        this.triggerThreshold = triggerThreshold;
-    }
-
-    public void setEcalReadoutCollectionName(String ecalReadoutCollectionName) {
-        this.ecalReadoutCollectionName = ecalReadoutCollectionName;
-    }
-
-    public void setNumSamplesAfter(int numSamplesAfter) {
-        this.numSamplesAfter = numSamplesAfter;
-    }
-
-    public void setNumSamplesBefore(int numSamplesBefore) {
-        this.numSamplesBefore = numSamplesBefore;
-    }
-
-    public void setReadoutLatency(int readoutLatency) {
-        this.readoutLatency = readoutLatency;
-    }
-
-    public void setReadoutWindow(int readoutWindow) {
-        this.readoutWindow = readoutWindow;
-    }
-
-    public void setCoincidenceWindow(int coincidenceWindow) {
-        this.coincidenceWindow = coincidenceWindow;
-    }
-
-    public void setUseCRRCShape(boolean useCRRCShape) {
-        this.useCRRCShape = useCRRCShape;
-    }
-
-    public void setTp(double tp) {
-        this.tp = tp;
-    }
-
-//    public void setFallTime(double fallTime) {
-//        this.fallTime = fallTime;
-//    }
-    public void setPePerMeV(double pePerMeV) {
-        this.pePerMeV = pePerMeV;
-    }
-
-//    public void setRiseTime(double riseTime) {
-//        this.riseTime = riseTime;
-//    }
-    public void setDelay0(int delay0) {
-        this.delay0 = delay0;
-    }
-
-    public void setBufferLength(int bufferLength) {
-        this.bufferLength = bufferLength;
-        resetFADCBuffers();
-    }
-
-    public void setPipelineLength(int pipelineLength) {
-        this.pipelineLength = pipelineLength;
-        resetFADCBuffers();
-    }
-
-    public void setMode(int mode) {
-        this.mode = mode;
-        if (mode != ECAL_WINDOW_MODE && mode != ECAL_PULSE_MODE && mode != ECAL_PULSE_INTEGRAL_MODE) {
-            throw new IllegalArgumentException("invalid mode " + mode);
-        }
-    }
-
-    /**
-     * Return the map of preamp signal buffers. For debug only.
-     *
-     * @return
-     */
-    public Map<Long, RingBuffer> getSignalMap() {
-        return signalMap;
-    }
-
-    /**
-     * Return the map of FADC pipelines. For debug only.
-     *
-     * @return
-     */
-    public Map<Long, FADCPipeline> getPipelineMap() {
-        return pipelineMap;
-    }
-
-    @Override
-    protected void readHits(List<RawCalorimeterHit> hits) {
-
-        for (Long cellID : signalMap.keySet()) {
-            RingBuffer signalBuffer = signalMap.get(cellID);
-
-            FADCPipeline pipeline = pipelineMap.get(cellID);
-            pipeline.step();
-
-            double currentValue = signalBuffer.currentValue() * ((Math.pow(2, nBit) - 1) / maxVolt); //12-bit ADC with maxVolt V range
-            double pedestal = EcalConditions.physicalToPedestal(cellID);
-            pipeline.writeValue(Math.min((int) Math.round(pedestal + currentValue), (int) Math.pow(2, nBit))); //ADC can't return a value larger than 4095; 4096 (overflow) is returned for any input >2V
-            //System.out.println(signalBuffer.currentValue() + "   " + currentValue + "   " + pipeline.currentValue());
-
-            Double sum = sumMap.get(cellID);
-            if (sum == null && currentValue > triggerThreshold) {
-                timeMap.put(cellID, readoutCounter);
-                if (constantTriggerWindow) {
-                    double sumBefore = 0;
-                    for (int i = 0; i < numSamplesBefore; i++) {
-                        if (debug) {
-                            System.out.format("trigger %d, %d: %d\n", cellID, i, pipeline.getValue(numSamplesBefore - i - 1));
-                        }
-                        sumBefore += pipeline.getValue(numSamplesBefore - i - 1);
-                    }
-                    sumMap.put(cellID, sumBefore);
-                } else {
-                    sumMap.put(cellID, currentValue);
-                }
-            }
-            if (sum != null) {
-                if (constantTriggerWindow) {
-                    if (timeMap.get(cellID) + numSamplesAfter >= readoutCounter) {
-                        if (debug) {
-                            System.out.format("trigger %d, %d: %d\n", cellID, readoutCounter - timeMap.get(cellID) + numSamplesBefore - 1, pipeline.getValue(0));
-                        }
-                        sumMap.put(cellID, sum + pipeline.getValue(0));
-                    } else if (timeMap.get(cellID) + delay0 <= readoutCounter) {
-//                        System.out.printf("sum = %f\n", sum);
-                        outputQueue.add(new HPSRawCalorimeterHit(cellID,
-                                (int) Math.round(sum / scaleFactor),
-                                64 * timeMap.get(cellID),
-                                readoutCounter - timeMap.get(cellID) + 1));
-                        sumMap.remove(cellID);
-                    }
-                } else {
-                    if (currentValue < triggerThreshold || timeMap.get(cellID) + delay0 == readoutCounter) {
-//					System.out.printf("sum = %f\n",sum);
-                        outputQueue.add(new HPSRawCalorimeterHit(cellID,
-                                (int) Math.round((sum + currentValue) / scaleFactor),
-                                64 * timeMap.get(cellID),
-                                readoutCounter - timeMap.get(cellID) + 1));
-                        sumMap.remove(cellID);
-                    } else {
-                        sumMap.put(cellID, sum + currentValue);
-                    }
-                }
-            }
-            signalBuffer.step();
-        }
-        while (outputQueue.peek() != null && outputQueue.peek().getTimeStamp() / 64 <= readoutCounter - delay0) {
-            if (outputQueue.peek().getTimeStamp() / 64 < readoutCounter - delay0) {
-                System.out.println("Stale hit in output queue");
-                outputQueue.poll();
-            } else {
-                buffer.add(outputQueue.poll());
-            }
-        }
-        while (!buffer.isEmpty() && buffer.peek().getTimeStamp() / 64 <= readoutCounter - delay0 - coincidenceWindow) {
-            buffer.remove();
-        }
-        if (debug) {
-            for (RawCalorimeterHit hit : buffer) {
-                System.out.format("new hit: energy %d\n", hit.getAmplitude());
-            }
-        }
-
-        hits.addAll(buffer);
-    }
-
-    @Override
-    public void startOfData() {
-        super.startOfData();
-        if (ecalReadoutCollectionName == null) {
-            throw new RuntimeException("The parameter ecalReadoutCollectionName was not set!");
-        }
-    }
-
-    @Override
-    protected void processTrigger(EventHeader event) {
-        switch (mode) {
-            case ECAL_WINDOW_MODE:
-                if (debug) {
-                    System.out.println("Reading out ECal in window mode");
-                }
-                event.put(ecalReadoutCollectionName, readWindow(), RawTrackerHit.class, 0, ecalReadoutName);
-                break;
-            case ECAL_PULSE_MODE:
-                if (debug) {
-                    System.out.println("Reading out ECal in pulse mode");
-                }
-                event.put(ecalReadoutCollectionName, readPulses(), RawTrackerHit.class, 0, ecalReadoutName);
-                break;
-            case ECAL_PULSE_INTEGRAL_MODE:
-                if (debug) {
-                    System.out.println("Reading out ECal in integral mode");
-                }
-                event.put(ecalReadoutCollectionName, readIntegrals(), RawCalorimeterHit.class, flags, ecalReadoutName);
-                break;
-        }
-    }
-
-    @Override
-    public double readoutDeltaT() {
-        double triggerTime = ClockSingleton.getTime() + triggerDelay;
-        int cycle = (int) Math.floor((triggerTime - readoutOffset + ClockSingleton.getDt()) / readoutPeriod);
-        double readoutTime = (cycle - readoutLatency) * readoutPeriod + readoutOffset - ClockSingleton.getDt();
-        return readoutTime;
-    }
-
-    protected short[] getWindow(long cellID) {
-        FADCPipeline pipeline = pipelineMap.get(cellID);
-        short[] adcValues = new short[readoutWindow];
-        for (int i = 0; i < readoutWindow; i++) {
-            adcValues[i] = (short) pipeline.getValue(readoutLatency - i - 1);
-//			if (adcValues[i] != 0) {
-//				System.out.println("getWindow: " + adcValues[i] + " at i = " + i);
-//			}
-        }
-        return adcValues;
-    }
-
-    protected List<RawTrackerHit> readWindow() {
-//		System.out.println("Reading FADC data");
-        List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
-        for (Long cellID : pipelineMap.keySet()) {
-            short[] adcValues = getWindow(cellID);
-            hits.add(new BaseRawTrackerHit(cellID, 0, adcValues));
-        }
-        return hits;
-    }
-
-    protected List<RawTrackerHit> readPulses() {
-//		System.out.println("Reading FADC data");
-        List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
-        for (Long cellID : pipelineMap.keySet()) {
-            short[] window = getWindow(cellID);
-            short[] adcValues = null;
-            int pointerOffset = 0;
-            int numSamplesToRead = 0;
-            int thresholdCrossing = 0;
-            for (int i = 0; i < readoutWindow; i++) {
-                if (numSamplesToRead != 0) {
-                    adcValues[adcValues.length - numSamplesToRead] = window[i - pointerOffset];
-                    numSamplesToRead--;
-                    if (numSamplesToRead == 0) {
-                        hits.add(new BaseRawTrackerHit(cellID, thresholdCrossing, adcValues));
-                    }
-                } else if ((i == 0 || window[i - 1] <= EcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > EcalConditions.physicalToPedestal(cellID) + readoutThreshold) {
-                    thresholdCrossing = i;
-                    pointerOffset = Math.min(numSamplesBefore, i);
-                    numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1);
-                    adcValues = new short[numSamplesToRead];
-                }
-            }
-        }
-        return hits;
-    }
-
-    protected List<RawCalorimeterHit> readIntegrals() {
-//		System.out.println("Reading FADC data");
-        List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>();
-        for (Long cellID : pipelineMap.keySet()) {
-            short[] window = getWindow(cellID);
-            int adcSum = 0;
-            int pointerOffset = 0;
-            int numSamplesToRead = 0;
-            int thresholdCrossing = 0;
-            if (window != null) {
-                for (int i = 0; i < readoutWindow; i++) {
-                    if (numSamplesToRead != 0) {
-                        if (debug) {
-                            System.out.format("readout %d, %d: %d\n", cellID, numSamplesBefore + numSamplesAfter - numSamplesToRead, window[i - pointerOffset]);
-                        }
-                        adcSum += window[i - pointerOffset];
-                        numSamplesToRead--;
-                        if (numSamplesToRead == 0) {
-                            hits.add(new BaseRawCalorimeterHit(cellID, adcSum, 64 * thresholdCrossing));
-                        }
-                    } else if ((i == 0 || window[i - 1] <= EcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > EcalConditions.physicalToPedestal(cellID) + readoutThreshold) {
-                        thresholdCrossing = i;
-                        pointerOffset = Math.min(numSamplesBefore, i);
-                        numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1);
-                        adcSum = 0;
-                    }
-                }
-            }
-        }
-        return hits;
-    }
-
-    @Override
-    protected void putHits(List<CalorimeterHit> hits) {
-        //fill the readout buffers
-        for (CalorimeterHit hit : hits) {
-            RingBuffer eDepBuffer = signalMap.get(hit.getCellID());
-            double energyAmplitude = hit.getRawEnergy();
-            if (addNoise) {
-                //add preamp noise and photoelectron Poisson noise in quadrature
-                double noise;
-                if (!useCRRCShape) {
-                    noise = Math.sqrt(Math.pow(EcalConditions.physicalToNoise(hit.getCellID()) * EcalConditions.physicalToGain(hit.getCellID()) * ECalUtils.gainFactor * ECalUtils.ecalReadoutPeriod, 2) + hit.getRawEnergy() * ECalUtils.MeV / pePerMeV);
-                } else {
-                    noise = Math.sqrt(Math.pow(EcalConditions.physicalToNoise(hit.getCellID()) * EcalConditions.physicalToGain(hit.getCellID()) * ECalUtils.MeV, 2) + hit.getRawEnergy() * ECalUtils.MeV / pePerMeV);
-                }
-                energyAmplitude += RandomGaussian.getGaussian(0, noise);
-            }
-            for (int i = 0; i < bufferLength; i++) {
-                eDepBuffer.addToCell(i, energyAmplitude * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime()), hit.getCellID()));
-            }
-        }
-    }
-
-    @Override
-    protected void initReadout() {
-        //initialize buffers
-        sumMap = new HashMap<Long, Double>();
-        timeMap = new HashMap<Long, Integer>();
-        outputQueue = new PriorityQueue(20, new HPSRawCalorimeterHit.TimeComparator());
-        resetFADCBuffers();
-    }
-
-    @Override
-    public void detectorChanged(Detector detector) {
-        // Get the Subdetector.
-        ecal = detector.getSubdetector(ecalName);
-        resetFADCBuffers();
-    }
-
-    private boolean resetFADCBuffers() {
-        if (ecal == null) {
-            return false;
-        }
-        signalMap = new HashMap<Long, RingBuffer>();
-        pipelineMap = new HashMap<Long, FADCPipeline>();
-        Set<Long> cells = ((HPSEcal3) ecal).getNeighborMap().keySet();
-        for (Long cellID : cells) {
-            signalMap.put(cellID, new RingBuffer(bufferLength));
-            pipelineMap.put(cellID, new FADCPipeline(pipelineLength, (int) Math.round(EcalConditions.physicalToPedestal(cellID))));
-        }
-        return true;
-    }
-
-    private double pulseAmplitude(double time, long cellID) {
-        if (useCRRCShape) {
-            if (time <= 0.0) {
-                return 0.0;
-            }
-
-            //normalization constant from cal gain (MeV/integral bit) to amplitude gain (amplitude bit/GeV)
-            double gain;
-            if (fixedGain > 0) {
-                gain = readoutPeriod / (fixedGain * ECalUtils.MeV * ((Math.pow(2, nBit) - 1) / maxVolt));
-            } else {
-                gain = readoutPeriod / (EcalConditions.physicalToGain(cellID) * ECalUtils.MeV * ((Math.pow(2, nBit) - 1) / maxVolt));
-            }
-
-            if (tp > 0.0) {
-                return gain * ((time / tp) * Math.exp(1.0 - time / tp)) / (tp * Math.E);
-            } else {
-                if (time < -tp) {
-                    return 1.0;
-                } else {
-                    return 0.0;
-                }
-            }
-        } else {   // According to measurements the output signal can be fitted by two gaussians, one for the rise of the signal, one for the fall
-            // Time corresponds to t-(t_eve+pulseDelay) such that the maximum of the amplitude is reached pulseDelay ns after the event t_eve
-            // Without the coefficient, the integral is equal to 1
-            if (time <= 0.0) {
-                return 0.0;
-            }
-
-            //if fixedGain is set, multiply the default gain by this factor
-            double corrGain = 1.0;
-            if (fixedGain > 0) {
-                corrGain = fixedGain;
-            } else {
-                corrGain = 1.0 / EcalConditions.physicalToGain(cellID);
-            }
-
-            double norm = ((riseTime + fallTime) / 2) * Math.sqrt(2 * Math.PI); //to ensure the total integral is equal to 1: = 33.8
-
-            if (time < 3 * riseTime) {
-                return corrGain * readoutGain * funcGaus(time - 3 * riseTime, riseTime) / norm;
-            } else {
-                return corrGain * readoutGain * funcGaus(time - 3 * riseTime, fallTime) / norm;
-            }
-        }
-    }
-
-    // Gaussian function needed for the calculation of the pulse shape amplitude  
-    public static double funcGaus(double t, double sig) {
-        return Math.exp(-t * t / (2 * sig * sig));
-    }
-
-    public class FADCPipeline {
-
-        private int[] array;
-        private int size;
-        private int ptr;
-
-        public FADCPipeline(int size) {
-            this.size = size;
-            array = new int[size]; //initialized to 0
-            ptr = 0;
-        }
-
-        //construct pipeline with a nonzero initial value
-        public FADCPipeline(int size, int init) {
-            this.size = size;
-            array = new int[size];
-            for (int i = 0; i < size; i++) {
-                array[i] = init;
-            }
-            ptr = 0;
-        }
-
-        /**
-         * Write value to current cell
-         */
-        public void writeValue(int val) {
-            array[ptr] = val;
-        }
-
-        /**
-         * Write value to current cell
-         */
-        public void step() {
-            ptr++;
-            if (ptr == size) {
-                ptr = 0;
-            }
-        }
-
-        //return content of specified cell (pos=0 for current cell)
-        public int getValue(int pos) {
-            if (pos >= size || pos < 0) {
-                throw new ArrayIndexOutOfBoundsException();
-            }
-            return array[((ptr - pos) % size + size) % size];
-        }
-    }
-}

java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal
FADCTriggerDriver.java removed after 347
--- java/sandbox/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCTriggerDriver.java	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCTriggerDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,522 +0,0 @@
-package org.hps.readout.ecal;
-
-import hep.aida.IHistogram1D;
-import hep.aida.IHistogram2D;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-
-import org.hps.recon.ecal.ECalUtils;
-import org.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.event.Cluster;
-import org.lcsim.event.EventHeader;
-import org.lcsim.geometry.Detector;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.util.aida.AIDA;
-
-/**
- * Reads clusters and makes trigger decision using opposite quadrant criterion.
- * Prints triggers to file if file path specified.
- *
- * @author Omar Moreno <[log in to unmask]>
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: FADCTriggerDriver.java,v 1.4 2013/09/02 21:56:56 phansson Exp $
- */
-public class FADCTriggerDriver extends TriggerDriver {
-
-    int nTriggers;
-    int totalEvents;
-    protected double beamEnergy = 2.2 * ECalUtils.GeV;
-    private int minHitCount = 1;
-    private double clusterEnergyHigh = 1.85 / 2.2;
-    private double clusterEnergyLow = .1 / 2.2;
-    private double energySumThreshold = 1.0;
-    private double energyDifferenceThreshold = 1.5 / 2.2;
-    private double maxCoplanarityAngle = 35; // degrees
-//    private double energyDistanceDistance = 250; // mm
-//    private double energyDistanceThreshold = 0.8 / 2.2;
-    private double energyDistanceDistance = 200; // mm
-    private double energyDistanceThreshold = 0.5;
-    // maximum time difference between two clusters, in units of readout cycles (4 ns).
-    private int pairCoincidence = 2;
-    int allPairs;
-    int oppositeQuadrantCount;
-    int clusterEnergyCount;
-    int energySumCount;
-    int energyDifferenceCount;
-    int energyDistanceCount;
-    int coplanarityCount;
-    AIDA aida = AIDA.defaultInstance();
-    IHistogram2D clusterHitCount2DAll, clusterEnergy2DAll, clusterSumDiff2DAll, energyDistance2DAll, clusterAngles2DAll, clusterCoplanarity2DAll;
-    IHistogram2D clusterHitCount2D, clusterEnergy2D, clusterSumDiff2D, energyDistance2D, clusterAngles2D, clusterCoplanarity2D;
-    IHistogram1D triggerBits1D, triggerTimes1D;
-    int truthPeriod = 250;
-    private boolean useQuadrants = false;
-    protected String clusterCollectionName = "EcalClusters";
-    // FIFO queues of lists of clusters in each ECal half.
-    // Each list corresponds to one readout cycle.
-    private Queue<List<HPSEcalCluster>> topClusterQueue = null;
-    private Queue<List<HPSEcalCluster>> botClusterQueue = null;
-
-    private enum Flag {
-
-        CLUSTER_HITCOUNT(4), CLUSTER_ENERGY(3), ENERGY_SUM_DIFF(2), ENERGY_DISTANCE(1), COPLANARITY(0);
-        private final int index;
-
-        Flag(int i) {
-            index = i;
-        }
-
-        static int bitmask(EnumSet<Flag> flags) {
-            int mask = 0;
-            for (Flag flag : flags) {
-                mask |= 1 << flag.index;
-            }
-            return mask;
-        }
-    }
-
-    public void setClusterCollectionName(String clusterCollectionName) {
-        this.clusterCollectionName = clusterCollectionName;
-    }
-
-    public void setBeamEnergy(double beamEnergy) {
-        if (beamEnergy == 1.1) {
-            System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 1.1 GeV beam");
-            maxCoplanarityAngle = 90;
-            clusterEnergyHigh = .7 / beamEnergy;
-            clusterEnergyLow = .1 / beamEnergy;
-            energySumThreshold = 0.8 / beamEnergy;
-        } else if (beamEnergy == 2.2) {
-            System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 2.2 GeV beam");
-            maxCoplanarityAngle = 45;
-            clusterEnergyHigh = 1.6 / beamEnergy;
-            clusterEnergyLow = .1 / beamEnergy;
-            energySumThreshold = 1.7 / beamEnergy;
-        } else if (beamEnergy == 6.6) {
-            System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 6.6 GeV beam");
-            maxCoplanarityAngle = 60;
-            clusterEnergyHigh = 5.0 / beamEnergy;
-            clusterEnergyLow = .1 / beamEnergy;
-            energySumThreshold = 5.5 / beamEnergy;
-        }
-        this.beamEnergy = beamEnergy * ECalUtils.GeV;
-    }
-
-    protected double getBeamEnergyFromDetector(Detector detector) {
-        if (detector.getName().contains("1pt1")) {
-            return 1.1;
-        } else if (detector.getName().contains("2pt2")) {
-            return 2.2;
-        } else if (detector.getName().contains("6pt6")) {
-            return 6.6;
-        } else {
-            return -1.0;
-        }
-    }
-
-    public void setTruthPeriod(int truthPeriod) {
-        this.truthPeriod = truthPeriod;
-    }
-
-    public void setPairCoincidence(int pairCoincidence) {
-        this.pairCoincidence = pairCoincidence;
-    }
-
-    @Override
-    public void detectorChanged(Detector detector) {
-        setBeamEnergy(this.getBeamEnergyFromDetector(detector));
-
-        clusterHitCount2DAll = aida.histogram2D("All cluster pairs: hit count (less energetic vs. more energetic)", 9, 0.5, 9.5, 9, 0.5, 9.5);
-        clusterSumDiff2DAll = aida.histogram2D("All cluster pairs: energy difference vs. sum", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy);
-        clusterEnergy2DAll = aida.histogram2D("All cluster pairs: energy (less energetic vs. more energetic)", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy);
-        energyDistance2DAll = aida.histogram2D("All cluster pairs: distance vs. energy (less energetic cluster)", 100, 0.0, 0.5 * beamEnergy, 25, 0.0, 400.0);
-        clusterCoplanarity2DAll = aida.histogram2D("All cluster pairs: cluster angle uncoplanarity vs. less energetic cluster angle", 100, -180.0, 180.0, 100, -180.0, 180.0);
-        clusterAngles2DAll = aida.histogram2D("All cluster pairs: cluster angle (less energetic vs. more energetic)", 100, -180.0, 180.0, 100, -180.0, 180.0);
-
-        clusterHitCount2D = aida.histogram2D("Passed other cuts: hit count (less energetic vs. more energetic)", 9, 0.5, 9.5, 9, 0.5, 9.5);
-        clusterSumDiff2D = aida.histogram2D("Passed other cuts: energy difference vs. sum", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy);
-        clusterEnergy2D = aida.histogram2D("Passed other cuts: energy (less energetic vs. more energetic)", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy);
-        energyDistance2D = aida.histogram2D("Passed other cuts: distance vs. energy (less energetic cluster)", 100, 0.0, 0.5 * beamEnergy, 25, 0.0, 400.0);
-        clusterCoplanarity2D = aida.histogram2D("Passed other cuts: cluster angle uncoplanarity vs. less energetic cluster angle", 100, -180.0, 180.0, 100, -180.0, 180.0);
-        clusterAngles2D = aida.histogram2D("Passed other cuts: cluster angle (less energetic vs. more energetic)", 100, -180.0, 180.0, 100, -180.0, 180.0);
-
-        triggerBits1D = aida.histogram1D(detector.getDetectorName() + " : " + clusterCollectionName + " : trigger bits", 33, -1.5, 31.5);
-        triggerTimes1D = aida.histogram1D(detector.getDetectorName() + " : " + clusterCollectionName + " : trigger times", truthPeriod, -0.5, truthPeriod - 0.5);
-    }
-
-    @Override
-    public void startOfData() {
-        //initialize queues and fill with empty lists
-        topClusterQueue = new LinkedList<List<HPSEcalCluster>>();
-        botClusterQueue = new LinkedList<List<HPSEcalCluster>>();
-        for (int i = 0; i < 2 * pairCoincidence + 1; i++) {
-            topClusterQueue.add(new ArrayList<HPSEcalCluster>());
-        }
-        for (int i = 0; i < pairCoincidence + 1; i++) {
-            botClusterQueue.add(new ArrayList<HPSEcalCluster>());
-        }
-        super.startOfData();
-        if (clusterCollectionName == null) {
-            throw new RuntimeException("The parameter clusterCollectionName was not set!");
-        }
-
-        allPairs = 0;
-        oppositeQuadrantCount = 0;
-        clusterEnergyCount = 0;
-        energySumCount = 0;
-        energyDifferenceCount = 0;
-        energyDistanceCount = 0;
-        coplanarityCount = 0;
-    }
-
-    @Override
-    public void process(EventHeader event) {
-        if (event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) {
-            // this needs to run every readout cycle whether or not trigger is live
-            updateClusterQueues(event.get(HPSEcalCluster.class, clusterCollectionName));
-        }
-        super.process(event);
-    }
-
-    @Override
-    protected boolean triggerDecision(EventHeader event) {
-        // Get the list of raw ECal hits.
-        if (event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) {
-            return testTrigger();
-        } else {
-            return false;
-        }
-    }
-
-    public boolean testTrigger() {
-        boolean trigger = false;
-
-        List<HPSEcalCluster[]> clusterPairs = getClusterPairsTopBot();
-
-        //--- Apply Trigger Cuts ---//
-
-        // Iterate through all cluster pairs present in the event.  If at least
-        // one of the cluster pairs satisfies all of the trigger conditions,
-        // a trigger signal is sent to all other detectors.
-        for (HPSEcalCluster[] clusterPair : clusterPairs) {
-
-            EnumSet<Flag> bits = EnumSet.noneOf(Flag.class);
-
-            if (outputStream != null) {
-                outputStream.printf("Event %d: cluster pair (energy %f in quadrant %d (%s), energy %f in quadrant %d (%s))\n",
-                        ClockSingleton.getClock(),
-                        clusterPair[0].getEnergy(), ECalUtils.getQuadrant(clusterPair[0]), clusterPair[0].getSeedHit().getPositionVec().toString(),
-                        clusterPair[1].getEnergy(), ECalUtils.getQuadrant(clusterPair[1]), clusterPair[1].getSeedHit().getPositionVec().toString());
-            }
-
-            allPairs++;
-
-            if (useQuadrants) {
-                // Require that the event have at least two clusters in opposite
-                // quadrants
-                if (!oppositeQuadrantsCut(clusterPair)) {
-                    if (outputStream != null) {
-                        outputStream.println("Failed opposite quadrant cut");
-                    }
-                    continue;
-                }
-                oppositeQuadrantCount++;
-            }
-
-            // Require the components of a cluster pair to have at least one 
-            // hit each (should always be true)
-            if (clusterHitCount(clusterPair)) {
-                bits.add(Flag.CLUSTER_HITCOUNT);
-            }
-
-            // Require the components of a cluster pair to have an energy in
-            // the range of 100 MeV to 1.85 GeV
-            if (clusterECut(clusterPair)) {
-                bits.add(Flag.CLUSTER_ENERGY);
-            }
-
-            bits.add(Flag.ENERGY_SUM_DIFF);
-            // Require the sum of the energies of the components of the
-            // cluster pair to be less than the
-            // (Beam Energy)*(Sampling Fraction) ( 2 GeV for the Test Run )
-            if (!energySum(clusterPair)) {
-                bits.remove(Flag.ENERGY_SUM_DIFF);
-            }
-
-            // Require the difference in energy of the components of the
-            // cluster pair to be less than 1.5 GeV
-            if (!energyDifference(clusterPair)) {
-                bits.remove(Flag.ENERGY_SUM_DIFF);
-            }
-
-            // Apply a low energy cluster vs. distance cut of the form
-            // E_low + .0032 GeV/mm < .8 GeV
-            if (energyDistanceCut(clusterPair)) {
-                bits.add(Flag.ENERGY_DISTANCE);
-            }
-
-            // Require that the two clusters are coplanar with the beam within
-            // 35 degrees
-            if (coplanarityCut(clusterPair)) {
-                bits.add(Flag.COPLANARITY);
-            }
-
-            if (bits.contains(Flag.CLUSTER_ENERGY)) {
-                clusterEnergyCount++;
-                if (energySum(clusterPair)) {
-                    energySumCount++;
-                    if (energyDifference(clusterPair)) {
-                        energyDifferenceCount++;
-                        if (bits.contains(Flag.ENERGY_DISTANCE)) {
-                            energyDistanceCount++;
-                            if (bits.contains(Flag.COPLANARITY)) {
-                                coplanarityCount++;
-                            } else if (outputStream != null) {
-                                outputStream.println("Failed coplanarity cut");
-                            }
-                        } else if (outputStream != null) {
-                            outputStream.println("Failed energy-distance cut");
-                        }
-                    } else if (outputStream != null) {
-                        outputStream.println("Failed energy difference cut");
-                    }
-                } else if (outputStream != null) {
-                    outputStream.println("Failed energy sum cut");
-                }
-            } else if (outputStream != null) {
-                outputStream.println("Failed cluster energy cut");
-            }
-
-            clusterHitCount2DAll.fill(clusterPair[0].getCalorimeterHits().size(), clusterPair[1].getCalorimeterHits().size());
-            clusterSumDiff2DAll.fill(clusterPair[0].getEnergy() + clusterPair[1].getEnergy(), clusterPair[0].getEnergy() - clusterPair[1].getEnergy());
-            clusterEnergy2DAll.fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy());
-            energyDistance2DAll.fill(clusterPair[1].getEnergy(), getClusterDistance(clusterPair[1]));
-            clusterCoplanarity2DAll.fill(getClusterAngle(clusterPair[1]), pairUncoplanarity(clusterPair));
-            clusterAngles2DAll.fill(getClusterAngle(clusterPair[0]), getClusterAngle(clusterPair[1]));
-
-            if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.CLUSTER_HITCOUNT)))) {
-                clusterHitCount2D.fill(clusterPair[0].getCalorimeterHits().size(), clusterPair[1].getCalorimeterHits().size());
-            }
-
-            if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.ENERGY_SUM_DIFF, Flag.CLUSTER_ENERGY)))) { //cluster energy, energy-distance, coplanarity
-                clusterSumDiff2D.fill(clusterPair[0].getEnergy() + clusterPair[1].getEnergy(), clusterPair[0].getEnergy() - clusterPair[1].getEnergy());
-                clusterEnergy2D.fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy());
-            }
-            if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.ENERGY_DISTANCE)))) {
-                energyDistance2D.fill(clusterPair[1].getEnergy(), getClusterDistance(clusterPair[1]));
-            }
-            if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.COPLANARITY)))) {
-                clusterCoplanarity2D.fill(getClusterAngle(clusterPair[1]), pairUncoplanarity(clusterPair));
-                clusterAngles2D.fill(getClusterAngle(clusterPair[0]), getClusterAngle(clusterPair[1]));
-            }
-
-            triggerBits1D.fill(Flag.bitmask(bits));
-
-            if (bits.containsAll(EnumSet.allOf(Flag.class))) {
-                // If all cuts are pased, we have a trigger
-                if (outputStream != null) {
-                    outputStream.println("Passed all cuts");
-                }
-                trigger = true;
-            }
-        }
-        if (trigger) {
-            triggerBits1D.fill(-1);
-            triggerTimes1D.fill(ClockSingleton.getClock() % truthPeriod);
-        }
-        return trigger;
-    }
-
-    @Override
-    public void endOfData() {
-        if (outputStream != null) {
-            printCounts(outputStream);
-        }
-        printCounts(new PrintWriter(System.out));
-        super.endOfData();
-    }
-
-    private void printCounts(PrintWriter writer) {
-        writer.printf("Number of pairs: %d\n", allPairs);
-        writer.printf("Number of cluster pairs after successive trigger conditions:\n");
-        if (useQuadrants) {
-            writer.printf("Opposite quadrants: %d\n", oppositeQuadrantCount);
-        }
-        writer.printf("Cluster energy: %d\n", clusterEnergyCount);
-        writer.printf("Energy sum: %d\n", energySumCount);
-        writer.printf("Energy difference: %d\n", energyDifferenceCount);
-        writer.printf("Energy-distance cut: %d\n", energyDistanceCount);
-        writer.printf("Coplanarity: %d\n", coplanarityCount);
-        writer.printf("Trigger count: %d\n", numTriggers);
-        writer.close();
-    }
-
-    protected void updateClusterQueues(List<HPSEcalCluster> ecalClusters) {
-        ArrayList<HPSEcalCluster> topClusterList = new ArrayList<HPSEcalCluster>();
-        ArrayList<HPSEcalCluster> botClusterList = new ArrayList<HPSEcalCluster>();
-        for (HPSEcalCluster ecalCluster : ecalClusters) {
-//            System.out.format("add cluster\t%f\t%d\n", ecalCluster.getSeedHit().getTime(), ecalCluster.getSeedHit().getIdentifierFieldValue("iy"));
-            if (ecalCluster.getSeedHit().getIdentifierFieldValue("iy") > 0) {
-                topClusterList.add(ecalCluster);
-            } else {
-                botClusterList.add(ecalCluster);
-            }
-        }
-
-        topClusterQueue.add(topClusterList);
-        botClusterQueue.add(botClusterList);
-        topClusterQueue.remove();
-        botClusterQueue.remove();
-    }
-
-    /**
-     * Get a list of all unique cluster pairs in the event
-     *
-     * @param ecalClusters : List of ECal clusters
-     * @return list of cluster pairs
-     */
-    protected List<HPSEcalCluster[]> getClusterPairsTopBot() {
-        // Make a list of cluster pairs
-        List<HPSEcalCluster[]> clusterPairs = new ArrayList<HPSEcalCluster[]>();
-
-        // Loop over all top-bottom pairs of clusters; higher-energy cluster goes first in the pair
-        // To apply pair coincidence time, use only bottom clusters from the 
-        // readout cycle pairCoincidence readout cycles ago, and top clusters 
-        // from all 2*pairCoincidence+1 previous readout cycles
-        for (HPSEcalCluster botCluster : botClusterQueue.element()) {
-            for (List<HPSEcalCluster> topClusters : topClusterQueue) {
-                for (HPSEcalCluster topCluster : topClusters) {
-//                    System.out.format("%f\t%f\n", topCluster.getSeedHit().getTime(), botCluster.getSeedHit().getTime());
-                    if (topCluster.getEnergy() > botCluster.getEnergy()) {
-                        HPSEcalCluster[] clusterPair = {topCluster, botCluster};
-                        clusterPairs.add(clusterPair);
-                    } else {
-                        HPSEcalCluster[] clusterPair = {botCluster, topCluster};
-                        clusterPairs.add(clusterPair);
-                    }
-                }
-            }
-        }
-        return clusterPairs;
-    }
-
-    /**
-     * Checks if the ECal clusters making up a cluster pair lie in opposite
-     * quadrants
-     *
-     * @param clusterPair : pair of clusters
-     * @return true if opposite quadrants, false otherwise
-     */
-    protected boolean oppositeQuadrantsCut(HPSEcalCluster[] clusterPair) {
-        int quad1 = ECalUtils.getQuadrant(clusterPair[0]);
-        int quad2 = ECalUtils.getQuadrant(clusterPair[1]);
-
-        //if clusters are in the same quadrant, they're not opposite quadrants
-        if (quad1 == quad2) {
-            return false;
-        } //opposite pairs of quadrants are either both even (2 and 4) or both odd (1 and 3)
-        else {
-            return ((quad1 & 1) == (quad2 & 1));
-        }
-    }
-
-    /**
-     * Checks if the ECal clusters making up a cluster pair both have at least
-     * the minimum number of hits.
-     *
-     * @param clusterPair: pair of clusters
-     * @return true if pair passes cut, false if fail
-     */
-    protected boolean clusterHitCount(HPSEcalCluster[] clusterPair) {
-        return (clusterPair[0].getCalorimeterHits().size() >= minHitCount
-                && clusterPair[1].getCalorimeterHits().size() >= minHitCount);
-    }
-
-    /**
-     * Checks if the ECal clusters making up a cluster pair lie above the low
-     * energy threshold and below the high energy threshold
-     *
-     * @param clusterPair : pair of clusters
-     * @return true if a pair is found, false otherwise
-     */
-    protected boolean clusterECut(HPSEcalCluster[] clusterPair) {
-        return (clusterPair[0].getEnergy() < beamEnergy * clusterEnergyHigh
-                && clusterPair[1].getEnergy() < beamEnergy * clusterEnergyHigh
-                && clusterPair[0].getEnergy() > beamEnergy * clusterEnergyLow
-                && clusterPair[1].getEnergy() > beamEnergy * clusterEnergyLow);
-    }
-
-    /**
-     * Checks if the sum of the energies of ECal clusters making up a cluster
-     * pair is below an energy sum threshold
-     *
-     * @param clusterPair : pair of clusters
-     * @return true if a pair is found, false otherwise
-     */
-    protected boolean energySum(Cluster[] clusterPair) {
-        double clusterESum = clusterPair[0].getEnergy() + clusterPair[1].getEnergy();
-        return (clusterESum < beamEnergy * energySumThreshold);
-    }
-
-    /**
-     * Checks if the energy difference between the ECal clusters making up a
-     * cluster pair is below an energy difference threshold
-     *
-     * @param clusterPair : pair of clusters
-     * @return true if pair is found, false otherwise
-     */
-    protected boolean energyDifference(HPSEcalCluster[] clusterPair) {
-        double clusterEDifference = clusterPair[0].getEnergy() - clusterPair[1].getEnergy();
-
-        return (clusterEDifference < beamEnergy * energyDifferenceThreshold);
-    }
-
-    /**
-     * Require that the distance from the beam of the lowest energy cluster in a
-     * cluster pair satisfies the following E_low + d_b*.0032 GeV/mm < .8 GeV
-     *
-     * @param clusterPair : pair of clusters
-     * @return true if pair is found, false otherwise
-     */
-    protected boolean energyDistanceCut(HPSEcalCluster[] clusterPair) {
-        HPSEcalCluster lowEnergyCluster = clusterPair[1];
-
-        // Calculate its position
-        double lowEClusterDistance = getClusterDistance(clusterPair[1]);
-        // event passes cut if above the line with X- and Y-intercepts defined by energyDistanceDistance and beamEnergy*energyDistanceThreshold
-        double clusterDistvsE = lowEnergyCluster.getEnergy() + lowEClusterDistance * beamEnergy * energyDistanceThreshold / energyDistanceDistance;
-
-        return (clusterDistvsE > beamEnergy * energyDistanceThreshold);
-    }
-
-    /**
-     * Checks if a cluster pair is coplanar to the beam within a given angle
-     *
-     * @param clusterPair : pair of clusters
-     * @return true if pair is found, false otherwise
-     */
-    protected boolean coplanarityCut(HPSEcalCluster[] clusterPair) {
-        return (Math.abs(pairUncoplanarity(clusterPair)) < maxCoplanarityAngle);
-    }
-
-    protected double pairUncoplanarity(HPSEcalCluster[] clusterPair) { // Find the angle between clusters in the pair
-        double cluster1Angle = (getClusterAngle(clusterPair[0]) + 180.0) % 180.0;
-        double cluster2Angle = (getClusterAngle(clusterPair[1]) + 180.0) % 180.0;
-
-        return cluster2Angle - cluster1Angle;
-    }
-
-    protected double getClusterAngle(HPSEcalCluster cluster) { //returns angle in range of -180 to 180
-        double position[] = cluster.getSeedHit().getPosition();
-        return Math.toDegrees(Math.atan2(position[1], position[0]));
-    }
-
-    protected double getClusterDistance(HPSEcalCluster cluster) {
-        return Math.hypot(cluster.getSeedHit().getPosition()[0], cluster.getSeedHit().getPosition()[1]);
-    }
-}
\ No newline at end of file

java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal
TimeEvolutionEcalReadoutDriver.java removed after 347
--- java/sandbox/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,94 +0,0 @@
-package org.hps.readout.ecal;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.hps.recon.ecal.HPSCalorimeterHit;
-import org.lcsim.event.CalorimeterHit;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.hps.util.RingBuffer;
-
-/**
- * Performs readout of ECal hits.
- * Simulates time evolution of preamp output pulse.
- *
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: TimeEvolutionEcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $
- */
-public class TimeEvolutionEcalReadoutDriver extends EcalReadoutDriver<HPSCalorimeterHit> {
-
-    //buffer for deposited energy
-    Map<Long, RingBuffer> eDepMap = null;
-    //length of ring buffer (in readout cycles)
-    int bufferLength = 20;
-    //shaper time constant in ns; negative values generate square pulses of the given width
-    double t0 = 18.0;
-
-    public TimeEvolutionEcalReadoutDriver() {
-		hitClass = HPSCalorimeterHit.class;
-    }
-
-    public void setT0(double t0) {
-        this.t0 = t0;
-    }
-
-    public void setBufferLength(int bufferLength) {
-        this.bufferLength = bufferLength;
-        eDepMap = new HashMap<Long, RingBuffer>();
-    }
-
-    @Override
-    protected void readHits(List<HPSCalorimeterHit> hits) {
-        for (Long cellID : eDepMap.keySet()) {
-            RingBuffer eDepBuffer = eDepMap.get(cellID);
-            if (eDepBuffer.currentValue() > threshold) {
-//                int ix = dec.getValue("ix");
-//                int iy = dec.getValue("iy");
-//                if (iy == 1 && ix == -2)
-//                    System.out.printf("Time %f, output signal %f\n", ClockSingleton.getTime(), eDepBuffer.currentValue());
-                hits.add(new HPSCalorimeterHit(eDepBuffer.currentValue(), readoutTime(), cellID, hitType));
-            }
-            eDepBuffer.step();
-        }
-    }
-
-    @Override
-    protected void putHits(List<CalorimeterHit> hits) {
-        //fill the readout buffers
-        for (CalorimeterHit hit : hits) {
-//            int ix = dec.getValue("ix");
-//            int iy = dec.getValue("iy");
-//            if (iy == 1 && ix == -2)
-//                System.out.printf("Time %f, input hit %f)\n", ClockSingleton.getTime() + hit.getTime(), hit.getRawEnergy());
-
-            RingBuffer eDepBuffer = eDepMap.get(hit.getCellID());
-            if (eDepBuffer == null) {
-                eDepBuffer = new RingBuffer(bufferLength);
-                eDepMap.put(hit.getCellID(), eDepBuffer);
-            }
-            for (int i = 0; i < bufferLength; i++) {
-                eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime())));
-            }
-        }
-    }
-
-    @Override
-    protected void initReadout() {
-        //initialize buffers
-        eDepMap = new HashMap<Long, RingBuffer>();
-    }
-
-    private double pulseAmplitude(double time) {
-        if (time < 0.0)
-            return 0.0;
-        if (t0 > 0.0) {
-            return (time / t0) * Math.exp(1.0 - time / t0);
-        } else {
-            if (time < -t0)
-                return 1.0;
-            else
-                return 0.0;
-        }
-    }
-}

java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal
TriggerDriver.java removed after 347
--- java/sandbox/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerDriver.java	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,187 +0,0 @@
-package org.hps.readout.ecal;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.hps.recon.ecal.TriggerData;
-import org.lcsim.event.EventHeader;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.lcio.LCIOWriter;
-
-/**
- * Makes trigger decision and sends trigger to readout drivers.
- * Prints triggers to file if file path specified.
- * Writes trigger events to LCIO if file path specified.
- * To implement: extend this class and write your own triggerDecision().
- *
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: TriggerDriver.java,v 1.7 2013/09/02 21:56:56 phansson Exp $
- */
-public abstract class TriggerDriver extends TriggerableDriver {
-
-    private boolean _DEBUG = false;
-    protected String outputFileName = null;
-    protected PrintWriter outputStream = null;
-    protected int numTriggers;
-    private int lastTrigger = Integer.MIN_VALUE;
-    private int deadTime = 0;
-    private static boolean triggerBit = false;
-    private String lcioFile = null;
-    LCIOWriter lcioWriter = null;
-    private static final List<TriggerableDriver> triggerables = new ArrayList<TriggerableDriver>();
-
-    public TriggerDriver() {
-        triggerDelay = 50.0;
-    }
-
-    public void setLcioFile(String lcioFile) {
-        this.lcioFile = lcioFile;
-    }
-
-    /**
-     * Set dead time; 0 for no dead time
-     * @param deadTime Minimum number of clock ticks between triggers
-     */
-    public void setDeadTime(int deadTime) {
-        this.deadTime = deadTime;
-    }
-
-    public void setOutputFileName(String outputFileName) {
-        this.outputFileName = outputFileName;
-    }
-
-    @Override
-    public void startOfData() {
-        addTriggerable(this);
-
-        if (outputFileName != null) {
-            try {
-                outputStream = new PrintWriter(new PrintStream(outputFileName), true);
-            } catch (IOException ex) {
-                throw new RuntimeException("Invalid outputFilePath!");
-            }
-        } else {
-            if (_DEBUG) {
-                outputStream = new PrintWriter(System.out, true);
-            }
-        }
-
-        if (lcioFile != null) {
-            try {
-                lcioWriter = new LCIOWriter(new File(lcioFile));
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        numTriggers = 0;
-    }
-
-    @Override
-    public void process(EventHeader event) {
-        triggerBit = false; //reset trigger
-        //System.out.println(this.getClass().getCanonicalName() + " - process");
-        if ((lastTrigger == Integer.MIN_VALUE || ClockSingleton.getClock() - lastTrigger > deadTime) && triggerDecision(event)) {
-            sendTrigger();
-            for (TriggerableDriver triggerable : triggerables) {
-                ReadoutTimestamp.addTimestamp(triggerable, event);
-            }
-            triggerBit = true;
-            lastTrigger = ClockSingleton.getClock();
-            numTriggers++;
-            if (_DEBUG) {
-                System.out.printf(this.getClass().getSimpleName() + ": Trigger on event %d\n", event.getEventNumber());
-            }
-            if (outputStream != null) {
-                outputStream.printf("Trigger on event %d\n", event.getEventNumber());
-            }
-
-            // If an ECal trigger signal has been sent store the trigger
-            // time offset by the trigger latencies
-            if (_DEBUG) {
-                System.out.println(this.getClass().getSimpleName() + ": Trigger added on event " + event.getEventNumber());
-            }
-
-            if (outputStream != null) {
-                outputStream.printf("trigger sent to ET event builder on event %d\n", event.getEventNumber());
-            }
-            makeTriggerData(event, "TriggerStatus");
-            if (lcioWriter != null) {
-                try {
-                    lcioWriter.write(event);
-                } catch (IOException ex) {
-                    Logger.getLogger(TriggerDriver.class.getName()).log(Level.SEVERE, null, ex);
-                }
-            }
-        }
-
-        // Check if there are any pending trigger bank triggers to process
-        checkTrigger(event);
-    }
-
-    protected static boolean sendTrigger() {
-        for (TriggerableDriver triggerable : triggerables) {
-            if (!triggerable.isLive()) {
-                return false;
-            }
-        }
-        for (TriggerableDriver triggerable : triggerables) {
-            triggerable.addTrigger();
-        }
-        return true;
-    }
-
-    public static void addTriggerable(TriggerableDriver triggerable) {
-        triggerables.add(triggerable);
-    }
-
-    @Override
-    protected void processTrigger(EventHeader event) {
-        if (outputStream != null) {
-            outputStream.printf("Trigger bank trigger sent on event %d\n", event.getEventNumber());
-        }
-        makeTriggerData(event, "TriggerBank");
-    }
-
-    protected abstract boolean triggerDecision(EventHeader event);
-
-    /**
-     * Make a dummy TriggerData
-     */
-    protected void makeTriggerData(EventHeader event, String collectionName) {
-        TriggerData tData = new TriggerData(new int[8]);
-        List<TriggerData> triggerList = new ArrayList<TriggerData>();
-        triggerList.add(tData);
-        event.put(collectionName, triggerList, TriggerData.class, 0);
-    }
-
-    @Override
-    public void endOfData() {
-        if (outputStream != null) {
-            outputStream.printf("Trigger count: %d\n", numTriggers);
-            outputStream.close();
-        }
-        if (lcioWriter != null) {
-            try {
-                lcioWriter.close();
-            } catch (IOException ex) {
-                Logger.getLogger(TriggerDriver.class.getName()).log(Level.SEVERE, null, ex);
-            }
-        }
-        System.out.printf(this.getClass().getSimpleName() + ": Trigger count: %d\n", numTriggers);
-    }
-
-    public static boolean triggerBit() {
-        return triggerBit;
-    }
-    
-    public int getTimestampType() {
-        return ReadoutTimestamp.SYSTEM_TRIGGER;
-    }
-}
\ No newline at end of file

java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal
TriggerableDriver.java removed after 347
--- java/sandbox/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerableDriver.java	2014-03-25 23:53:28 UTC (rev 347)
+++ java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerableDriver.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,57 +0,0 @@
-package org.hps.readout.ecal;
-
-import java.util.LinkedList;
-import java.util.Queue;
-import org.lcsim.event.EventHeader;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.util.Driver;
-
-/**
- * A driver that accepts triggers from TriggerDriver.
- * To implement, write your own processTrigger(), and call checkTrigger() somewhere in process().
- * You might want to set your own default latency in your constructor.
- * readoutDeltaT() and isLive() are meant to be overridden if you're doing something unusual.
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: TriggerableDriver.java,v 1.3 2013/03/20 01:03:32 meeg Exp $
- */
-public abstract class TriggerableDriver extends Driver {
-
-    private Queue<Double> triggerTimestamps = new LinkedList<Double>();
-    protected double triggerDelay = 0.0; // [ns]
-
-    public void setTriggerDelay(double triggerDelay) {
-        this.triggerDelay = triggerDelay;
-    }
-
-    /**
-     * 
-     * @return time reference for hits written by this driver in response to a trigger
-     */
-    public double readoutDeltaT() {
-        return ClockSingleton.getTime() + triggerDelay;
-    }
-
-    @Override
-    public void startOfData() {
-        TriggerDriver.addTriggerable(this);
-    }
-
-    protected abstract void processTrigger(EventHeader event);
-
-    protected void checkTrigger(EventHeader event) {
-        if (triggerTimestamps.peek() != null && ClockSingleton.getTime() >= triggerTimestamps.peek()) {
-            processTrigger(event);
-            triggerTimestamps.remove();
-        }
-    }
-
-    public void addTrigger() {
-        triggerTimestamps.add(ClockSingleton.getTime() + triggerDelay);
-    }
-
-    public boolean isLive() {
-        return true;
-    }
-    
-    public abstract int getTimestampType();
-}

java/trunk/ecal-recon
pom.xml removed after 346
--- java/sandbox/ecal-recon/pom.xml	2014-03-25 23:35:20 UTC (rev 346)
+++ java/trunk/ecal-recon/pom.xml	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>hps-ecal-recon</artifactId>
-    <name>hps-ecal-recon</name>
-    <description>HPS ECAL reconstruction module</description>
-    
-    <parent>
-        <groupId>org.hps</groupId>
-        <artifactId>hps-parent</artifactId>
-        <relativePath>../parent/pom.xml</relativePath>
-        <version>3.0.2-SNAPSHOT</version>
-    </parent>
-    
-    <scm>
-        <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-recon/</url>
-        <connection>scm:svn:svn://svn.freehep.org/hps/java/trunk/ecal-recon/</connection>
-        <developerConnection>scm:svn:svn://svn.freehep.org/hps/java/trunk/ecal-recon/</developerConnection>
-    </scm>
-    
-    <dependencies>
-        <dependency>
-            <groupId>org.lcsim</groupId>
-            <artifactId>lcsim-distribution</artifactId>
-            <version>${lcsimVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-conditions</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-util</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-            <version>3.2</version>
-        </dependency>
-    </dependencies>
-    
-</project>

java/trunk/evio
pom.xml removed after 356
--- java/sandbox/evio/pom.xml	2014-03-26 01:28:51 UTC (rev 356)
+++ java/trunk/evio/pom.xml	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>hps-evio</artifactId>
-    <name>hps-evio</name>
-    <description>HPS EVIO utilities package</description>
-    
-    <parent>
-        <groupId>org.hps</groupId>
-        <artifactId>hps-parent</artifactId>
-        <relativePath>../parent/pom.xml</relativePath>
-        <version>3.0.2-SNAPSHOT</version>
-    </parent>
-    
-    <scm>
-        <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/evio/</url>
-        <connection>scm:svn:svn://svn.freehep.org/hps/java/trunk/evio/</connection>
-        <developerConnection>scm:svn:svn://svn.freehep.org/hps/java/trunk/evio/</developerConnection>
-    </scm>
-    
-    <dependencies>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-jevio</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-et</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-tracking</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-            <version>3.2</version>
-        </dependency>
-    </dependencies>
-    
-</project>

java/trunk/evio/src/main/java/org/hps/evio
BasicEvioFileReader.java removed after 356
--- java/sandbox/evio/src/main/java/org/hps/evio/BasicEvioFileReader.java	2014-03-26 01:28:51 UTC (rev 356)
+++ java/trunk/evio/src/main/java/org/hps/evio/BasicEvioFileReader.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,113 +0,0 @@
-package org.hps.evio;
-
-import java.io.File;
-import org.jlab.coda.jevio.*;
-
-public class BasicEvioFileReader {
-
-    static public void main(String[] args) {
-        if (args.length < 1) {
-            throw new RuntimeException("Missing EVIO file name.");
-        }
-        String evioFileName = args[0];
-        File evioFile = new File(evioFileName);
-        if (!evioFile.exists()) {
-            throw new RuntimeException("File " + evioFileName + " does not exist.");
-        }
-        try {
-            org.jlab.coda.jevio.EvioReader reader = new org.jlab.coda.jevio.EvioReader(evioFile);
-            int eventN = 1;
-            int badEvents = 0;
-            fileLoop:
-            while (true) {
-                System.out.println("Reading event " + eventN);
-                try {
-                    EvioEvent event = reader.nextEvent();
-                    if (event == null) {
-                        break fileLoop;
-                    }
-                    reader.parseEvent(event);
-                    //printBytes(event.getRawBytes()); // DEBUG
-                    System.out.println("Successfully read event " + eventN);// + " which contains " + event.getTotalBytes() + " bytes.");
-                    printBank(event, "");
-                } catch (Exception e) {
-                    System.out.println("Caught Exception processing event " + eventN + " which was...");
-                    e.printStackTrace();
-                    ++badEvents;
-                }
-                ++eventN;
-                System.out.println("-------");
-            }
-            System.out.println("There were " + badEvents + " bad events out of " + eventN + " total.");
-            reader.close();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private static void printBank(BaseStructure bank, String indent) throws EvioException {
-        System.out.println(indent + "Bank contains " + bank.getTotalBytes() + " bytes.");
-        System.out.println(indent + "Bank has " + bank.getChildCount() + " sub-banks.");
-        System.out.format(indent + "Bank tag: 0x%x length: %d type: %s num: %d\n", bank.getHeader().getTag(), bank.getHeader().getLength(), bank.getHeader().getDataType(), bank.getHeader().getNumber());
-        if (bank.getChildCount() > 0) {
-            for (BaseStructure child : bank.getChildren()) {
-                printBank(child, indent + "\t");
-            }
-        }
-        if (bank.getHeader().getDataType() == DataType.COMPOSITE) {
-//            for (CompositeData cdata : bank.getCompositeData()) {
-            CompositeData cdatalist[] = bank.getCompositeData();
-            for (CompositeData cdata:cdatalist)
-            switch (bank.getHeader().getTag()) {
-                case 0xe101:
-                    printWindow(cdata, indent + "\t");
-                    break;
-                case 0xe102:
-                    printComposite(cdata, indent + "\t");
-                    break;
-                case 0xe103:
-                    printComposite(cdata, indent + "\t");
-                    break;
-            }
-//            }
-        }
-        if (bank.getHeader().getDataType() == DataType.UINT32) {
-            int[] data = bank.getIntData();
-            if (data.length < 100) {
-                for (int i = 0; i < data.length; i++) {
-                    System.out.format(indent + "0x%x\n", data[i]);
-                }
-            }
-        }
-    }
-
-    private static void printComposite(CompositeData cdata, String indent) {
-        System.out.println(indent + "Raw byte count: " + cdata.getRawBytes().length);
-        System.out.println(cdata.toString(indent));
-    }
-
-    private static void printWindow(CompositeData cdata, String indent) {
-        while (cdata.index() < cdata.getItems().size()) {
-            System.out.println(indent + "Byte count: " + cdata.getRawBytes().length);
-            System.out.println(indent + "Slot: " + cdata.getByte());
-            System.out.println(indent + "Trigger: " + cdata.getInt());
-            System.out.println(indent + "Timestamp: " + cdata.getLong());
-            int nchannels = cdata.getNValue();
-            System.out.println(indent + "NChannels: " + nchannels);
-            for (int j = 0; j < nchannels; j++) {
-                System.out.println(indent + "Channel: " + cdata.getByte());
-                int nSamples = cdata.getNValue();
-                System.out.println(indent + "NSamples: " + nSamples);
-                for (int i = 0; i < nSamples; i++) {
-                    cdata.getShort();
-                }
-            }
-        }
-    }
-
-    /*
-     * private static void printBytes(final byte[] bytes) { for (int i=0;
-     * i<bytes.length; i++) { if (i%4==0) System.out.println();
-     * System.out.println(Byte.toString(bytes[i])); } }
-     */
-}
\ No newline at end of file

java/trunk/tracking
pom.xml removed after 348
--- java/sandbox/tracking/pom.xml	2014-03-26 00:20:42 UTC (rev 348)
+++ java/trunk/tracking/pom.xml	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>hps-tracking</artifactId>
-    <name>hps-tracking</name>
-    <description>HPS tracking reconstruction module</description>
-    
-    <parent>
-        <groupId>org.hps</groupId>
-        <artifactId>hps-parent</artifactId>
-        <relativePath>../parent/pom.xml</relativePath>
-        <version>3.0.2-SNAPSHOT</version>
-    </parent>
-    
-    <scm>
-        <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/tracking/</url>
-        <connection>scm:svn:svn://svn.freehep.org/hps/java/trunk/tracking/</connection>
-        <developerConnection>scm:svn:svn://svn.freehep.org/hps/java/trunk/tracking/</developerConnection>
-    </scm>
-    
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>org/lcsim/hps/recon/tracking/TruthResidualTest.java</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.lcsim</groupId>
-            <artifactId>lcsim-distribution</artifactId>
-            <version>${lcsimVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-conditions</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-util</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.hps</groupId>
-            <artifactId>hps-ecal-readout-sim</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-            <version>3.2</version>
-        </dependency>
-    </dependencies>
-    
-</project>

java/trunk/tracking/src/main/java/org/hps/recon/tracking
SimpleSvtReadout.java removed after 348
--- java/sandbox/tracking/src/main/java/org/hps/recon/tracking/SimpleSvtReadout.java	2014-03-26 00:20:42 UTC (rev 348)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/SimpleSvtReadout.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,425 +0,0 @@
-package org.hps.recon.tracking;
-
-//--- java ---//
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.PriorityQueue;
-import java.util.Set;
-
-import org.hps.conditions.deprecated.HPSSVTCalibrationConstants;
-import org.hps.conditions.deprecated.HPSSVTConstants;
-import org.hps.conditions.deprecated.SvtUtils;
-import org.hps.readout.ecal.ReadoutTimestamp;
-import org.hps.readout.ecal.TriggerableDriver;
-//--- lcsim ---//
-import org.lcsim.detector.tracker.silicon.ChargeCarrier;
-import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.LCRelation;
-import org.lcsim.event.RawTrackerHit;
-import org.lcsim.event.SimTrackerHit;
-import org.lcsim.event.base.BaseLCRelation;
-import org.lcsim.event.base.BaseRawTrackerHit;
-import org.lcsim.geometry.Detector;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.hps.util.RandomGaussian;
-import org.lcsim.lcio.LCIOConstants;
-import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
-import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeData;
-import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeDataCollection;
-import org.lcsim.recon.tracking.digitization.sisim.SiSensorSim;
-import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver;
-
-/**
- *
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: SimpleSvtReadout.java,v 1.19 2013/08/07 23:38:32 meeg Exp $
- */
-public class SimpleSvtReadout extends TriggerableDriver {
-
-    private SimTrackerHitReadoutDriver readoutDriver = new SimTrackerHitReadoutDriver();
-    private SiSensorSim siSimulation = new CDFSiSensorSim();
-    private String outputCollection = "SVTRawTrackerHits";
-    private String relationCollection = "SVTTrueHitRelations";
-    private Map<SiSensor, PriorityQueue<StripHit>[]> hitMap = new HashMap<SiSensor, PriorityQueue<StripHit>[]>();
-    //readout period time offset in ns
-    private double readoutOffset = 0.0;
-    private double readoutLatency = 240.0;
-    private double pileupCutoff = 300.0;
-    private String readout = "TrackerHits";
-    private double timeOffset = 30.0;
-    private boolean noPileup = false;
-    private boolean addNoise = true;
-    //cut settings
-    private boolean enableThresholdCut = true;
-    private int samplesAboveThreshold = 3;
-    private double noiseThreshold = 2.0;
-    private boolean enablePileupCut = true;
-    private boolean dropBadChannels = true;
-
-    public SimpleSvtReadout() {
-        add(readoutDriver);
-        triggerDelay = 100.0;
-    }
-
-    public void setAddNoise(boolean addNoise) {
-        this.addNoise = addNoise;
-    }
-
-    public void setEnablePileupCut(boolean enablePileupCut) {
-        this.enablePileupCut = enablePileupCut;
-    }
-
-    public void setEnableThresholdCut(boolean enableThresholdCut) {
-        this.enableThresholdCut = enableThresholdCut;
-    }
-
-    public void setNoiseThreshold(double noiseThreshold) {
-        this.noiseThreshold = noiseThreshold;
-    }
-
-    public void setSamplesAboveThreshold(int samplesAboveThreshold) {
-        this.samplesAboveThreshold = samplesAboveThreshold;
-    }
-
-    public void setNoPileup(boolean noPileup) {
-        this.noPileup = noPileup;
-    }
-
-    public void setDropBadChannels(boolean dropBadChannels) {
-        this.dropBadChannels = dropBadChannels;
-    }
-
-    /**
-     *
-     */
-    @Override
-    public void detectorChanged(Detector detector) {
-        super.detectorChanged(detector);
-
-        String[] readouts = {readout};
-        readoutDriver.setCollections(readouts);
-
-        if (!noPileup) {
-            for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-                PriorityQueue<StripHit>[] hitQueues = new PriorityQueue[HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR];
-                hitMap.put(sensor, hitQueues);
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    @Override
-    public void process(EventHeader event) {
-        super.process(event);
-
-        List<StripHit> stripHits = doSiSimulation();
-
-        if (!noPileup) {
-            for (StripHit stripHit : stripHits) {
-                SiSensor sensor = stripHit.sensor;
-                int channel = stripHit.channel;
-
-                PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor);
-                if (hitQueues[channel] == null) {
-                    hitQueues[channel] = new PriorityQueue<StripHit>();
-                }
-                hitQueues[channel].add(stripHit);
-            }
-
-            // dump stale hits
-            for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-                PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor);
-                for (int i = 0; i < hitQueues.length; i++) {
-                    if (hitQueues[i] != null) {
-                        while (!hitQueues[i].isEmpty() && hitQueues[i].peek().time < ClockSingleton.getTime() - (readoutLatency + pileupCutoff)) {
-//                                System.out.format("Time %f: Dump stale hit with time %f\n",ClockSingleton.getTime(),hitQueues[i].peek().time);
-                            hitQueues[i].poll();
-                        }
-                        if (hitQueues[i].isEmpty()) {
-                            hitQueues[i] = null;
-                        }
-                    }
-                }
-            }
-
-            // If an ECal trigger is received, make hits from pipelines
-            checkTrigger(event);
-        } else {
-            // Create a list to hold the analog data
-            List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
-
-            for (StripHit stripHit : stripHits) {
-                SiSensor sensor = stripHit.sensor;
-                int channel = stripHit.channel;
-                double amplitude = stripHit.amplitude;
-                short[] samples = new short[6];
-
-                double[] signal = new double[6];
-                for (int i = 0; i < 6; i++) {
-                    signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel);
-                }
-                if (addNoise) {
-                    addNoise(sensor, channel, signal);
-                }
-
-                for (int i = 0; i < 6; i++) {
-                    double time = i * HPSSVTConstants.SAMPLING_INTERVAL - timeOffset;
-                    signal[i] += amplitude * pulseAmplitude(time, HPSSVTCalibrationConstants.getTShaping(sensor, channel));
-//                    signal[i] += amplitude * pulseAmplitude(time, HPSSVTCalibrationConstants.getTShaping(sensor, channel)) + HPSSVTCalibrationConstants.getPedestal(sensor, channel);
-                    samples[i] = (short) Math.round(signal[i]);
-                }
-
-                long cell_id = SvtUtils.makeCellID(sensor, channel);
-
-                RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, new ArrayList<SimTrackerHit>(stripHit.simHits), sensor);
-//                        System.out.println("Making RTH");
-                if (readoutCuts(hit)) {
-//                    System.out.println("RTH passed cuts");
-                    hits.add(hit);
-                }
-            }
-
-            int flags = 1 << LCIOConstants.TRAWBIT_ID1;
-//            flags += 1 << LCIOConstants.RTHBIT_HITS;
-            event.put(outputCollection, hits, RawTrackerHit.class, flags, readout);
-//            System.out.println("Made " + hits.size() + " RawTrackerHits");
-        }
-    }
-
-    private List<StripHit> doSiSimulation() {
-        List<StripHit> stripHits = new ArrayList<StripHit>();
-        for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-
-            // Set the sensor to be used in the charge deposition simulation
-            siSimulation.setSensor(sensor);
-
-            // Perform the charge deposition simulation
-            Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap = siSimulation.computeElectrodeData();
-
-            for (ChargeCarrier carrier : ChargeCarrier.values()) {
-
-                // If the sensor is capable of collecting the given charge carrier
-                // then obtain the electrode data for the sensor
-                if (sensor.hasElectrodesOnSide(carrier)) {
-
-                    SiElectrodeDataCollection electrodeDataCol = electrodeDataMap.get(carrier);
-
-                    // If there is no electrode data available create a new instance of electrode data
-                    if (electrodeDataCol == null) {
-                        electrodeDataCol = new SiElectrodeDataCollection();
-                    }
-
-                    // Loop over all sensor channels
-                    for (Integer channel : electrodeDataCol.keySet()) {
-
-                        // Get the electrode data for this channel
-                        SiElectrodeData electrodeData = electrodeDataCol.get(channel);
-                        Set<SimTrackerHit> simHits = electrodeData.getSimulatedHits();
-
-                        // compute hit time as the unweighted average of SimTrackerHit times; this is dumb but okay since there's generally only one SimTrackerHit
-                        double time = 0.0;
-                        for (SimTrackerHit hit : simHits) {
-                            time += hit.getTime();
-                        }
-                        time /= simHits.size();
-                        time += ClockSingleton.getTime();
-
-                        // Get the charge in units of electrons
-                        double charge = electrodeData.getCharge();
-
-                        double resistorValue = 100;  // Ohms
-                        double inputStageGain = 1.5;
-                        double amplitude = (charge / HPSSVTConstants.MIP) * resistorValue * inputStageGain * Math.pow(2, 14) / 2000;
-
-                        stripHits.add(new StripHit(sensor, channel, amplitude, time, simHits));
-                    }
-                }
-            }
-            // Clear the sensors of all deposited charge
-            siSimulation.clearReadout();
-        }
-        return stripHits;
-    }
-
-    private void addNoise(SiSensor sensor, int channel, double[] signal) {
-        double noise = HPSSVTCalibrationConstants.getNoise(sensor, channel);
-        for (int i = 0; i < 6; i++) {
-            signal[i] += RandomGaussian.getGaussian(0, noise);
-        }
-    }
-
-    private boolean readoutCuts(RawTrackerHit hit) {
-        if (enableThresholdCut && !samplesAboveThreshold(hit)) {
-//            System.out.println("Failed threshold cut");
-            return false;
-        }
-        if (enablePileupCut && !pileupCut(hit)) {
-//            System.out.println("Failed pileup cut");
-            return false;
-        }
-        if (dropBadChannels && !badChannelCut(hit)) {
-//            System.out.println("Failed bad channel cut");
-            return false;
-        }
-        return true;
-    }
-
-    private boolean badChannelCut(RawTrackerHit hit) {
-        SiSensor sensor = (SiSensor) hit.getDetectorElement();
-        int channel = hit.getIdentifierFieldValue("strip");
-        return !HPSSVTCalibrationConstants.isBadChannel(sensor, channel);
-    }
-
-    private boolean pileupCut(RawTrackerHit hit) {
-        short[] samples = hit.getADCValues();
-        return (samples[2] > samples[1] || samples[3] > samples[2]);
-    }
-
-    private boolean samplesAboveThreshold(RawTrackerHit hit) {
-        SiSensor sensor = (SiSensor) hit.getDetectorElement();
-        int channel = hit.getIdentifierFieldValue("strip");
-        HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
-        double pedestal = HPSSVTCalibrationConstants.getPedestal(sensor, channel);
-        double noise = HPSSVTCalibrationConstants.getNoise(sensor, channel);
-        int count = 0;
-        short[] samples = hit.getADCValues();
-        for (int i = 0; i < samples.length; i++) {
-//            System.out.format("%d, %d\n", samples[i] - pedestal, noise * 3.0);
-            if (samples[i] - pedestal > noise * noiseThreshold) {
-                count++;
-            }
-        }
-        return count >= samplesAboveThreshold;
-    }
-
-    @Override
-    protected void processTrigger(EventHeader event) {
-        if (noPileup) {
-            return;
-        }
-//            System.out.println("Got trigger");
-
-        // Create a list to hold the analog data
-        List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>();
-        List<LCRelation> trueHitRelations = new ArrayList<LCRelation>();
-        // Calculate time of first sample
-        double firstSample = Math.floor((ClockSingleton.getTime() - readoutLatency - readoutOffset) / HPSSVTConstants.SAMPLING_INTERVAL) * HPSSVTConstants.SAMPLING_INTERVAL + readoutOffset;
-
-        for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-            PriorityQueue<StripHit>[] hitQueues = hitMap.get(sensor);
-            for (int channel = 0; channel < hitQueues.length; channel++) {
-                if (!addNoise && (hitQueues[channel] == null || hitQueues[channel].isEmpty())) {
-                    continue;
-                }
-                double[] signal = new double[6];
-                for (int i = 0; i < 6; i++) {
-                    signal[i] = HPSSVTCalibrationConstants.getPedestal(sensor, channel);
-                }
-                if (addNoise) {
-                    addNoise(sensor, channel, signal);
-                }
-
-                List<SimTrackerHit> simHits = new ArrayList<SimTrackerHit>();
-
-                if (hitQueues[channel] != null) {
-                    for (StripHit hit : hitQueues[channel]) {
-                        double totalContrib = 0;
-                        for (int i = 0; i < 6; i++) {
-                            double sampleTime = firstSample + i * HPSSVTConstants.SAMPLING_INTERVAL;
-                            double signalAtTime = hit.amplitude * pulseAmplitude(sampleTime - hit.time, HPSSVTCalibrationConstants.getTShaping(sensor, channel));
-                            totalContrib += signalAtTime;
-                            signal[i] += signalAtTime;
-//                                    System.out.format("new value of signal[%d] = %f\n", i, signal[i]);
-                        }
-                        if (totalContrib > 4.0 * HPSSVTCalibrationConstants.getNoise(sensor, channel)) {
-//                            System.out.format("adding %d simHits\n", hit.simHits.size());
-                            simHits.addAll(hit.simHits);
-                        }
-                    }
-                }
-
-                short[] samples = new short[6];
-                for (int i = 0; i < 6; i++) {
-                    samples[i] = (short) Math.round(signal[i]);
-                }
-//                        if (hitQueues[channel] != null && !hitQueues[channel].isEmpty()) {
-//                            for (int i = 0; i < 6; i++) {
-//                                System.out.format("samples[%d] = %d\n", i, samples[i]);
-//                            }
-//                        }
-                long cell_id = SvtUtils.makeCellID(sensor, channel);
-                RawTrackerHit hit = new BaseRawTrackerHit(0, cell_id, samples, simHits, sensor);
-                if (readoutCuts(hit)) {
-                    hits.add(hit);
-//                    System.out.format("simHits: %d\n", simHits.size());
-                    for (SimTrackerHit simHit : hit.getSimTrackerHits()) {
-                        LCRelation hitRelation = new BaseLCRelation(hit, simHit);
-                        trueHitRelations.add(hitRelation);
-                    }
-                }
-            }
-        }
-
-        int flags = 1 << LCIOConstants.TRAWBIT_ID1;
-//            flags += 1 << LCIOConstants.RTHBIT_HITS;
-        event.put(outputCollection, hits, RawTrackerHit.class, flags, readout);
-        event.put(relationCollection, trueHitRelations, LCRelation.class, 0);
-        System.out.println("Made " + hits.size() + " RawTrackerHits");
-        System.out.println("Made " + trueHitRelations.size() + " LCRelations");
-    }
-
-    @Override
-    public double readoutDeltaT() {
-        double triggerTime = ClockSingleton.getTime() + triggerDelay;
-//        int cycle = (int) Math.floor((triggerTime - readoutOffset + ClockSingleton.getDt()) / Apv25Constants.SAMPLING_INTERVAL);
-        // Calculate time of first sample
-        double firstSample = Math.floor((triggerTime - readoutLatency - readoutOffset) / HPSSVTConstants.SAMPLING_INTERVAL) * HPSSVTConstants.SAMPLING_INTERVAL + readoutOffset;
-
-        return firstSample;
-    }
-
-    private class StripHit implements Comparable {
-
-        SiSensor sensor;
-        int channel;
-        double amplitude;
-        double time;
-        Set<SimTrackerHit> simHits;
-
-        public StripHit(SiSensor sensor, int channel, double amplitude, double time, Set<SimTrackerHit> simHits) {
-            this.sensor = sensor;
-            this.channel = channel;
-            this.amplitude = amplitude;
-            this.time = time;
-            this.simHits = simHits;
-        }
-
-        @Override
-        public int compareTo(Object o) {
-            double deltaT = time - ((StripHit) o).time;
-            if (deltaT > 0) {
-                return 1;
-            } else if (deltaT < 0) {
-                return -1;
-            } else {
-                return 0;
-            }
-        }
-    }
-
-    private double pulseAmplitude(double time, double tp) {
-        if (time <= 0.0) {
-            return 0.0;
-        }
-        return (time / tp) * Math.exp(1.0 - time / tp);
-    }
-    
-    public int getTimestampType() {
-        return ReadoutTimestamp.SYSTEM_TRACKER;
-    }
-}

java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25
Apv25Full.java removed after 348
--- java/sandbox/tracking/src/main/java/org/hps/recon/tracking/apv25/Apv25Full.java	2014-03-26 00:20:42 UTC (rev 348)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25/Apv25Full.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,290 +0,0 @@
-package org.hps.recon.tracking.apv25;
-
-//--- Constants ---//
-import org.hps.conditions.deprecated.HPSSVTConstants;
-//--- hps-java ---//
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.hps.util.RingBuffer;
-
-/**
- * 
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: Apv25Full.java,v 1.9 2013/04/25 22:11:14 meeg Exp $
- */
-public class Apv25Full {
-    
-    // APV25 trigger bit
-    public static boolean readoutBit = false;
-    protected int triggerLatency = 0;	// Clock cycles
-    protected int triggerLatencyTime = 240; // ns
-    
-    // APV25 Channels; An APV25 Readout Chip contains a total of 128 channels
-    private Apv25Channel[] channels = new Apv25Channel[HPSSVTConstants.CHANNELS];
-  
-    /**
-     * Default Ctor
-     */
-    public Apv25Full(){
-        
-        // Instantiate all APV25 channels
-        for(int channelN = 0; channelN < HPSSVTConstants.CHANNELS; channelN++){
-            channels[channelN] = new Apv25Channel();
-        }
-        // Set the trigger latency
-        this.setLatency(triggerLatencyTime);
-    }
-    
-    /**
-     * 
-     */
-    public void setLatency(int triggerLatencyTime /*ns*/){
-        this.triggerLatency = (int) Math.floor(triggerLatencyTime/HPSSVTConstants.SAMPLING_INTERVAL);
-        for(int channelN = 0; channelN < HPSSVTConstants.CHANNELS; channelN++) channels[channelN].getPipeline().resetPointerPositions();
-    }
-    
-    /**
-     * Return an instance of an APV25 channel
-     * 
-     * @param channel: APV25 channel of interest (0-127)
-     * @return an instance of an Apv25Channel
-     */
-    public Apv25Channel getChannel(int channel){
-        if(channel >= HPSSVTConstants.CHANNELS) throw new RuntimeException();
-        return channels[channel];
-    }
-    
-    /**
-     * Inject charge into a channel and shape the signal.  The resulting 
-     * shaper signal is then sampled into the analog pipeline
-     * 
-     * @param charge   : Total charge being injected
-     * @param pipeline : Analog pipeline associated with a channel
-     */
-    public void injectCharge(int channel, double charge) {
-        
-        	// Shape the injected charge
-            this.getChannel(channel).shapeSignal(charge);
-
-            // Sample the resulting shaper signal
-            this.getChannel(channel).sampleShaperSignal();
-    }
-    
-    /**
-     * 
-     */
-    public void incrementPointerPositions(){
-        for(int channel = 0; channel < channels.length; channel++){
-            channels[channel].pipeline.step();
-        }
-    }
-    
-    /**
-     * 
-     */
-    public Apv25AnalogData readOut(){
-        
-        Apv25AnalogData data = new Apv25AnalogData();
-        for(int channel = 0; channel < HPSSVTConstants.CHANNELS; channel++){
-            
-            // Only readout the channel if the channel isn't bad
-            if(!this.getChannel(channel).isBadChannel()){
-                // Readout the value stored in the buffer
-                double sample = (this.getChannel(channel).getPipeline().readout()/HPSSVTConstants.FRONT_END_GAIN)*HPSSVTConstants.MULTIPLEXER_GAIN;
-                data.setChannelData(channel, sample);
-            }
-        }
-        return data;
-    }
-    
-    //------------------------------------------//
-    //               APV25 Channel              //
-    //------------------------------------------//
-    public class Apv25Channel {
-        
-        private Apv25ShaperSignal shaperSignal;
-        private Apv25Pipeline pipeline = new Apv25Pipeline();
-        
-        private double shapingTime = 50; // [ns]
-        boolean badChannel = false;
-        
-        /**
-         * Default Constructor
-         */
-        public Apv25Channel(){
-        }
-        
-        /**
-         * Set the shaping time
-         * 
-         * @param shapingTime : APV25 shaping time. The default Tp is set to 50 ns.
-         */
-        public void setShapingTime(double shapingTime) {
-            this.shapingTime = shapingTime;
-        }
-        
-        /**
-         * 
-         */
-        public void markAsBadChannel(){
-            badChannel = true;
-        }
-        
-        /**
-         * 
-         */
-        public boolean isBadChannel(){
-            return badChannel;
-        }
-        
-        /**
-         * 
-         */
-        public Apv25Pipeline getPipeline(){
-        	return pipeline;
-        }
-                
-        /**
-         * Shape the injected charge
-         * 
-         * @param charge 
-         */
-        public void shapeSignal(double charge){
-            shaperSignal = new Apv25ShaperSignal(charge);
-        }
-        
-        /**
-         *
-         */
-        public void sampleShaperSignal(){
-            
-            // Obtain the beam time
-            double beamTime = ClockSingleton.getTime();
-            
-            // Fill the analog pipeline starting with the cell to which the writer pointer is pointing 
-            // to. Signals arriving within the same bucket of length <samplingTime> will be shifted in
-            // time depending on when they arrive.
-            for(int cell = 0; cell < HPSSVTConstants.ANALOG_PIPELINE_LENGTH; cell++){
-                
-                // Time at which the shaper signal will be sampled
-            	int sampleTime = cell*((int) HPSSVTConstants.SAMPLING_INTERVAL) - (int) (beamTime%HPSSVTConstants.SAMPLING_INTERVAL);
-                
-                // Sample the shaper signal
-                double sample = shaperSignal.getAmplitudeAtTime(sampleTime, shapingTime);
-                
-                // Add the value to the pipeline
-                pipeline.addToCell(cell, sample);
-            }
-        }
-    }
-    
-    //-------------------------------------//
-    //       APV25 Analog Pipeline         //
-    //-------------------------------------//
-    public class Apv25Pipeline extends RingBuffer {
-
-        // TODO: Possibly store the pipeline in the event
-        
-        // Note: ptr gives the position of the trigger pointer
-        private int writerPointer = 0;
-        
-        /**
-         * Constructor
-         */
-        public Apv25Pipeline(){
-             
-            // Initialize the pipeline to the APV25 pipeline length
-            super(HPSSVTConstants.ANALOG_PIPELINE_LENGTH);
-            
-            // Initialize the position of the trigger pointer to a random position
-            this.ptr = (int) (Math.random()*HPSSVTConstants.ANALOG_PIPELINE_LENGTH);
-        }        
-        
-        /**
-         * 
-         */
-        public void resetPointerPositions(){
-        	writerPointer = (ptr + triggerLatency)%HPSSVTConstants.ANALOG_PIPELINE_LENGTH;
-        }
-        
-        /**
-         * 
-         */
-        @Override
-        public void addToCell(int position, double element){
-            int writePosition = (writerPointer + position)%HPSSVTConstants.ANALOG_PIPELINE_LENGTH;
-            if(writePosition == this.ptr) return;
-            array[writePosition] += element;
-        }
-        
-        /**
-         * 
-         */
-        public double readout(){
-            double triggerPointerValue = this.currentValue();
-            array[ptr] = 0;
-            return triggerPointerValue;
-        }
-        
-        /**
-         * 
-         */
-        @Override
-        public void step(){
-            super.step();
-            writerPointer = (ptr + triggerLatency)%HPSSVTConstants.ANALOG_PIPELINE_LENGTH;
-        }
-        
-        /**
-         * 
-         */
-        @Override
-        public String toString(){
-            String analogPipeline = "[ ";
-            for(int element = 0; element < HPSSVTConstants.ANALOG_PIPELINE_LENGTH; element++){
-                if(element == ptr) analogPipeline += " TP ===>";
-                else if(element == writerPointer) analogPipeline += " WP ===>";
-                analogPipeline += (array[element] + ", ");
-            }
-            analogPipeline += "] ";
-            return analogPipeline;
-        }
-        
-        /**
-         * 
-         */
-        public double getWriterPointerValue(){
-        	return array[writerPointer];
-        }
-    }
-
-    //-----------------------------------//
-    //        APV25 Shaper Signal        //
-    //-----------------------------------//
-    public class Apv25ShaperSignal {
-
-        // Shaper signal maximum amplitude
-        private double maxAmp = 0;
-
-        /**
-         * Constructor
-         * 
-         * @param charge: Charge injected into a channel
-         */
-        Apv25ShaperSignal(double charge) {
-            // Find the maximum amplitude of the shaper signal
-            maxAmp = (charge/HPSSVTConstants.MIP)*HPSSVTConstants.FRONT_END_GAIN;  // mV
-        }
-
-        /**
-         * Get the amplitude at a time t
-         * 
-         * @param time: time at which the shaper signal is to be sampled
-         */
-        public double getAmplitudeAtTime(double time, double shapingTime) {
-            return maxAmp * (Math.max(0, time) / shapingTime) * Math.exp(1 - (time / shapingTime));
-        }
-
-    }
-    
-
-}

java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25
HPSAPV25.java removed after 348
--- java/sandbox/tracking/src/main/java/org/hps/recon/tracking/apv25/HPSAPV25.java	2014-03-26 00:20:42 UTC (rev 348)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25/HPSAPV25.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,353 +0,0 @@
-package org.hps.recon.tracking.apv25;
-
-//--- Java ---//
-import java.util.HashMap;
-import java.util.Map;
-
-//--- org.lcsim ---//
-import org.hps.recon.tracking.apv25.HPSAPV25.APV25Channel.APV25AnalogPipeline;
-//--- hps-java ---//
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.hps.util.RingBuffer;
-import org.lcsim.util.aida.AIDA;
-
-/**
- *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSAPV25.java,v 1.8 2012/08/03 00:05:26 meeg Exp $
- */
-public class HPSAPV25 {
-
-	//--- APV25 parameters ---//
-	//------------------------//
-	private static final double APV25_FRONT_END_GAIN = 100.0; // [mV/MIP]
-	private static final double APV25_MULTIPLEXER_GAIN = 1;   // mA/MIP
-	private static final double APV25_NOISE_INTERCEPT_PEAK = 270; // e- RMS
-	private static final double APV25_NOISE_INTERCEPT_DECON = 396;  //e- RMS
-	private static final double APV25_NOISE_SLOPE_PEAK = 36;       // e- rms/pF
-	private static final double APV25_NOISE_SLOPE_DECON = 59.4;       // e- rms/pF
-	
-	// Number of electron-hole pairs created by a min. ionizing particle 
-	// in 300 micrometers of Si
-	private static final int MIP = 25000;  // electron-hole pairs
-	
-	// Total number of channels per APV25 chip
-	private static final int APV25_CHANNELS = 128;
-	
-	// APV25 trigger bit
-	public static boolean readoutBit = false;
-	
-	// 
-	private int apv25ShapingTime = 35; // [ns] 
-	private int apv25SamplingTime = 24; // [ns]
-	private double analogDCLevel = 0;  // [mA] (Pedestal)
-	public int apv25ClockCycle = 0;
-	private String apv25Mode = "multi-peak";
-	
-	// APV25 Channel
-	private APV25Channel channel;
-	
-	// Histograms
-	protected AIDA aida = AIDA.defaultInstance();
-
-	/**
-	 * Constructor
-	 */
-	public HPSAPV25() {
-		// Create a single instance of an APV25 channel
-		channel = new APV25Channel();
-
-	}
-
-	//--- Methods ---//
-	//---------------//
-	/**
-	 * Set the APV25 shaping time
-	 * 
-	 * @param shapingTime : APV25 shaping time
-	 */
-	public void setShapingTime(int shapingTime) {
-		apv25ShapingTime = shapingTime;
-	}
-
-	/**
-	 * Set the operating mode of the APV25 to either "peak", 
-	 * "deconvolution", or "multi-peak".
-	 * 
-	 * @param mode : APV25 operating mode 
-	 */
-	public void setAPV25Mode(String mode) {
-		apv25Mode = mode;
-	}
-
-	/**
-	 * Set the time interval at which the shaper output is sampled
-	 * 
-	 * @param sampleTime : time interval
-	 */
-	public void setSamplingTime(int sampleTime) {
-		apv25SamplingTime = sampleTime;
-	}
-
-	/**
-	 * 
-	 */
-	public void setAnalogDCLevel(double dcLevel) {
-		analogDCLevel = dcLevel;
-	}
-
-	/**
-	 * Return an instance of an APV25 channel. Currently, there is only a 
-	 * single instance of the channel ( instead of 128 that the actual chip
-	 * has).  However, the analog buffers of each channels are distinct and 
-	 * are stored in a sorted map for later use.
-	 *
-	 * @return an instance of APV25Channel
-	 */
-	public APV25Channel getChannel() {
-		return channel;
-	}
-
-	/**
-	 * Inject charge into a channel and shape the signal.  The resulting 
-	 * shaper signal is then sampled into the analog pipeline
-	 * 
-	 * @param charge   : Total charge being injected
-	 * @param pipeline : Analog pipeline associated with a channel
-	 */
-	public void injectCharge(double charge, double noiseRMS, APV25AnalogPipeline pipeline) {
-		
-		// Shape the injected charge
-		getChannel().shapeSignal(charge);
-
-		// Sample the resulting shaper signal
-		getChannel().sampleShaperSignal(pipeline, noiseRMS);
-	}
-
-	/**
-	 * Increment the position of the trigger and writer pointers of all
-	 * channels
-	 * 
-	 * @param analogPipelineMap : 
-	 */
-	public void incrementAllPointerPositions(Map<Integer, APV25AnalogPipeline> analogPipelineMap) {
-		// Loop through all of the channels and increment the position of
-		// all the trigger and writer pointers
-		for (Map.Entry<Integer, APV25AnalogPipeline> entry : analogPipelineMap.entrySet()) {
-			entry.getValue().step();
-		}
-	}
-
-	/**
-	 * 
-	 */
-	public int getSamplingTime() {
-		return apv25SamplingTime;
-	}
-
-	/**
-	 * Increment the APV25 clock cycle by one
-	 */
-	public void stepAPV25Clock() {
-		apv25ClockCycle += 1;
-	}
-
-	/**
-	 * 
-	 */
-	public Map<Integer, double[]> APV25Multiplexer(
-			Map<Integer, APV25AnalogPipeline> pipelineMap) {
-
-		Map<Integer /* chip */, double[]> apv25Map = new HashMap<Integer, double[]>();
-
-		// The address of the APV25.  There is only a single address for all
-		// chips
-		double[] apv25Address = {4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0};
-		double[] output;
-
-		// Create the data streams
-		for (int chipIndex = 0; chipIndex < Math.ceil((double) pipelineMap.size() / APV25_CHANNELS); chipIndex++) {
-			apv25Map.put(chipIndex, createOutputArray(apv25Address, -4));
-		}
-
-		// Loop over all channels and readout the cells which the
-		// trigger pointer points to
-		for (int channelN = 0; channelN < pipelineMap.size(); channelN++) {
-			output = apv25Map.get((int) Math.floor(channelN / APV25_CHANNELS));
-			output[channelN % 128 + 12] += (pipelineMap.get(channelN).readOut() / APV25_FRONT_END_GAIN) * APV25_MULTIPLEXER_GAIN + analogDCLevel;
-		}
-		return apv25Map;
-	}
-
-	/**
-	 * 
-	 */
-	private double[] createOutputArray(double[] address, double error) {
-
-		// Create the array which will contain the output format. The array values
-		// will range from -4 microAmps to 4 microAmps.
-		double[] output = new double[141];
-		for (int index = 0; index < output.length; index++) {
-			output[ index] = -4.0;  // microAmps
-		}
-
-		// Header
-		double[] header = {4.0, 4.0, 4.0};
-
-		// Fill the array with the header, address and error bit and tick
-		System.arraycopy(header, 0, output, 0, 3);
-		output[header.length] = error;
-		System.arraycopy(address, 0, output, 4, 8);
-		output[ output.length - 1] = 4.0;
-
-		return output;
-	}
-
-	//------------------------------------------//
-	//               APV25 Channel            //
-	//-----------------------------------------//
-	public class APV25Channel {
-
-		// Analog pipeline length
-		private static final int ANALOG_PIPELINE_LENGTH = 192;
-		// Shaper signal
-		private APV25ShaperSignal shaperSignal;
-
-		/**
-		 * Constructor 
-		 */
-		public APV25Channel() {
-		}
-
-		/**
-		 * Shape the injected charge
-		 * 
-		 * @param charge 
-		 */
-		private void shapeSignal(double charge) {
-			shaperSignal = new APV25ShaperSignal(charge);
-		}
-
-		/**
-		 * Return the noise in electrons for a given strip capacitance
-		 * 
-		 * @param capacitance : strip capacitance in pF
-		 * @return noise in electrons
-		 */
-		public double computeNoise(double capacitance) {
-			if (apv25Mode.equals("peak") || apv25Mode.equals("multi-peak"))
-				return APV25_NOISE_INTERCEPT_PEAK + APV25_NOISE_SLOPE_PEAK * capacitance;
-			else return APV25_NOISE_INTERCEPT_DECON + APV25_NOISE_SLOPE_DECON * capacitance;
-		}
-
-		/**
-		 * Sample the shaper signal and fill the analog pipeline.
-		 * 
-		 * @param channel : Channel number
-		 */
-		private void sampleShaperSignal(
-				APV25AnalogPipeline pipeline, double noiseRMS) {
-
-			// Obtain the beam time
-			double beam_time = ClockSingleton.getTime();
-
-			// Fill the analog pipeline starting with the cell to which 
-			// the writer pointer is pointing to.  Signals arriving within 
-			// the same bucket of length apv25SamplingTime will be shifted
-			// in time depending on when they arrive.
-			for (int cell = 0; cell < ANALOG_PIPELINE_LENGTH; cell++) {
-
-				// Time at which the shaper signal will be sampled
-				int sample_time = cell * apv25SamplingTime
-						- ((int) beam_time) % apv25SamplingTime;
-				// Sample the shaper signal
-				double sample = shaperSignal.getAmplitudeAtTime(sample_time);
-
-				pipeline.addToCell(cell, sample);
-			}
-		}
-
-		//-----------------------------------//
-		//---     APV25 Shaper Signal     ---//
-		//-----------------------------------//
-		/**
-		 * 
-		 */
-		private class APV25ShaperSignal {
-
-			// Shaper signal maximum amplitude
-			private double maxAmp = 0;
-
-			/**
-			 * Constructor
-			 * 
-			 * @param charge : input charge into the channel
-			 */
-			APV25ShaperSignal(double charge) {
-
-				maxAmp = (charge / MIP) * APV25_FRONT_END_GAIN;  // mV
-
-				//--->
-				aida.histogram1D("Shaper Signal Max Amplitude", 100, 0, 500).fill(maxAmp);
-				//--->
-			}
-
-			/**
-			 * Get the amplitude at a time t
-			 * 
-			 * @param time : time at which the shaper signal is to be
-			 *               sampled
-			 */
-			private double getAmplitudeAtTime(double time) {
-				return maxAmp * (Math.max(0, time) / apv25ShapingTime) * Math.exp(1 - (time / apv25ShapingTime));
-			}
-		}
-
-		//-------------------------------------//
-		//---    APV25 Analog Pipeline      ---//
-		//-------------------------------------//
-		// Note that the buffer is modeled after a circular buffer
-		public class APV25AnalogPipeline extends RingBuffer {
-			private int _trigger_latency = (int) Math.floor(270 / apv25SamplingTime);
-
-			public APV25AnalogPipeline() { super(ANALOG_PIPELINE_LENGTH); }
-
-			/**
-			 * Set the trigger latency
-			 * 
-			 * @param latency : trigger latency in [ns]
-			 */
-			public void setTriggerLatency(int latency) {
-				_trigger_latency = (int) Math.floor(latency / apv25SamplingTime);
-			}
-
-			private double readOut() {
-				double pipelineValue = currentValue();
-				array[0] = 0;
-				return pipelineValue;
-			}
-
-			@Override
-			public void addToCell(int position, double element) {
-				if (position + _trigger_latency > array.length) {
-					return;
-				}
-				super.addToCell(position + _trigger_latency, element);
-			}
-
-			public void printAnalogPipeline() {
-				System.out.print("[ ");
-				for (int index = 0; index < array.length; index++) {
-					if (index == ptr) {
-						System.out.print("TP====>");
-					}
-					if (index == ptr + _trigger_latency) {
-						System.out.print("WP====>");
-					}
-					System.out.print(array[index] + ", ");
-				}
-				System.out.println("] ");
-			}
-		}
-	}
-}

java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25
HPSSiSensorReadout.java removed after 348
--- java/sandbox/tracking/src/main/java/org/hps/recon/tracking/apv25/HPSSiSensorReadout.java	2014-03-26 00:20:42 UTC (rev 348)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25/HPSSiSensorReadout.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,474 +0,0 @@
-package org.hps.recon.tracking.apv25;
-
-//--- Java ---//
-import hep.aida.ref.histogram.Profile1D;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Queue;
-import java.util.Random;
-import java.util.Set;
-
-//--- apache ---//
-import org.apache.commons.math.MathException;
-import org.apache.commons.math.distribution.BinomialDistribution;
-import org.apache.commons.math.distribution.BinomialDistributionImpl;
-import org.apache.commons.math.distribution.NormalDistribution;
-import org.apache.commons.math.distribution.NormalDistributionImpl;
-import org.hps.conditions.deprecated.SvtUtils;
-//--- hps-java ---//
-import org.hps.recon.tracking.apv25.HPSAPV25.APV25Channel.APV25AnalogPipeline;
-//--- org.lcsim ---//
-import org.lcsim.detector.tracker.silicon.ChargeCarrier;
-import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
-import org.lcsim.event.EventHeader;
-import org.lcsim.geometry.Detector;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.math.probability.Erf;
-import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
-import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeData;
-import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeDataCollection;
-import org.lcsim.recon.tracking.digitization.sisim.SiSensorSim;
-import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver;
-import org.lcsim.util.Driver;
-import org.lcsim.util.aida.AIDA;
-
-/**
- * Class used to Readout HPS APV25's
- *
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: HPSSiSensorReadout.java,v 1.12 2013/03/15 21:05:28 meeg Exp $
- */
-public class HPSSiSensorReadout extends Driver {
-
-    //
-    boolean debug = true;
-    String subdetectorName = "tracker";
-    // Array to store the trigger time
-    public static final List<Double> triggerTimeStamp = new ArrayList<Double>();
-    //
-    List<String> readouts = new ArrayList<String>();
-    // FIFO queue to store trigger times
-    public Queue<Integer> triggerQueue;
-    private HPSAPV25 apv25;
-    private SiSensorSim siSimulation;
-    private HPSRTM rtm;
-    private HPSDataProcessingModule dpm;
-    private static Random random = new Random();
-    private static BinomialDistribution binomial = new BinomialDistributionImpl(1, 1);
-    private static NormalDistribution gaussian = new NormalDistributionImpl(0.0, 1.0);
-    private double noiseThreshold = 4;  // e- RMS
-    private boolean addNoise = false;
-    // A map used to associate a sensor to the channels and analog pipelines 
-    // of the APV25s being used to readout the sensor
-    public Map<SiSensor /* sensor */, Map<Integer /* channel */, APV25AnalogPipeline>> sensorToPipelineMap;
-    // A map used to associate an APV25 channel to its analog pipeline
-    public Map<Integer /* channel */, APV25AnalogPipeline> analogPipelineMap;
-    // A map used to associate a sensor to the output of the APV25s being 
-    // used to readout the sensor
-    public Map<SiSensor, Map<Integer /* chip # */, double[]>> sensorToAnalogDataMap;
-    // A map used to associate a sensor to the digitized output of the APV25s
-    // being used to readout the sensor
-    public Map<SiSensor, Map<Integer /*chip # */, double[]>> sensorToDigitalDataMap;
-    //
-    public Map<Integer, double[]> analogData;
-    public Map<Integer, double[]> digitalData;
-    //
-    protected AIDA aida = AIDA.defaultInstance();
-    public Profile1D pipe;
-    int n_events = 0;
-
-    /**
-     * Constructor
-     */
-    public HPSSiSensorReadout() {
-
-        sensorToPipelineMap = new HashMap<SiSensor, Map<Integer, APV25AnalogPipeline>>();
-        sensorToAnalogDataMap = new HashMap<SiSensor, Map<Integer, double[]>>();
-        sensorToDigitalDataMap = new HashMap<SiSensor, Map<Integer, double[]>>();
-
-        //--- Sensor Simulation ---//
-        //-------------------------//
-        siSimulation = new CDFSiSensorSim();
-
-        //--- APV25 Simulation ---//
-        //------------------------//
-        apv25 = new HPSAPV25();
-        // Set the APV25 Shaping time [ns]
-        apv25.setShapingTime(35);
-        // Set the APV25 operating mode
-        apv25.setAPV25Mode("multi-peak");
-        // Set the APV25 analog pipeline sampling time
-        apv25.setSamplingTime(24);
-
-        // 
-        rtm = new HPSRTM(14);
-
-        // Instantiate the DPM
-        dpm = new HPSDataProcessingModule();
-        dpm.setNoise(18);
-        dpm.setNoiseThreshold(2);
-        dpm.setSamplesAboveThresh(3);
-        dpm.setPedestal(1638);
-        dpm.enableThresholdCut();
-        dpm.enableTailCut();
-
-        add(dpm);
-
-        // Instantiate trigger time queue
-        triggerQueue = new LinkedList<Integer>();
-
-        // Specify the readouts to process
-        readouts.add("TrackerHits");
-
-    }
-
-    public void setAddNoise(boolean addNoise) {
-        this.addNoise = addNoise;
-    }
-
-    /**
-     * 
-     */
-    @Override
-    public void detectorChanged(Detector detector) {
-        // Call the sub-Drivfer's detectorChanged methods
-        super.detectorChanged(detector);
-
-        // Instantiate all maps
-        for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-
-            sensorToPipelineMap.put(sensor, new HashMap<Integer, APV25AnalogPipeline>());
-
-            // Instantiate all analog pipelines
-            for (int channel = 0; channel < sensor.getReadoutElectrodes(ChargeCarrier.HOLE).getNCells(); channel++) {
-                sensorToPipelineMap.get(sensor).put(channel, apv25.getChannel().new APV25AnalogPipeline());
-            }
-
-            if (debug) {
-                System.out.println(this.getClass().getSimpleName() + ": Sensor: " + sensor.getName()
-                        + ": Number of Analog Pipelines: " + sensorToPipelineMap.get(sensor).size());
-            }
-
-            sensorToAnalogDataMap.put(sensor, new HashMap<Integer, double[]>());
-            sensorToDigitalDataMap.put(sensor, new HashMap<Integer, double[]>());
-        }
-    }
-
-    /**
-     * 
-     */
-    @Override
-    public void startOfData() {
-        // Set up readouts if they haven't been set
-        if (!readouts.isEmpty()) {
-            super.add(new SimTrackerHitReadoutDriver(readouts));
-        }
-
-        super.startOfData();
-        readouts.clear();
-
-    }
-
-    /**
-     * 
-     */
-    @Override
-    public void process(EventHeader event) {
-
-
-        super.process(event);
-
-        if ((ClockSingleton.getTime() + ClockSingleton.getDt()) % 24 == 0) {
-            for (Map.Entry<SiSensor, Map<Integer, APV25AnalogPipeline>> sensor : sensorToPipelineMap.entrySet()) {
-                apv25.incrementAllPointerPositions(sensor.getValue());
-            }
-            apv25.stepAPV25Clock();
-        }
-
-        // Loop over all sensors
-        for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
-            // Readout the sensors
-            readoutSensor(sensor);
-        }
-
-        // If a trigger is received readout the APV25 and digitize all hits
-        if (HPSAPV25.readoutBit) {
-
-            triggerTimeStamp.add(ClockSingleton.getTime());
-
-            // Only add the trigger if there isn't another trigger being 
-            // processed
-            if (!triggerQueue.contains(apv25.apv25ClockCycle)) {
-                // Add the time at which each of the six samples should be 
-                // collected to the trigger queue
-                for (int sample = 0; sample < 6; sample++) {
-                    triggerQueue.offer(apv25.apv25ClockCycle + sample);
-                }
-            }
-            // Reset the APV25 trigger bit
-            HPSAPV25.readoutBit = false;
-        }
-
-        // Process any triggers in the queue
-        if (triggerQueue.peek() != null) {
-
-            // Remove any samples that might have already been processed
-            if (triggerQueue.peek() < apv25.apv25ClockCycle) {
-                for (int sample = 0; sample < 6; sample++) {
-                    triggerQueue.remove();
-                }
-            } else if (triggerQueue.peek() == apv25.apv25ClockCycle) {
-                readoutAPV25();
-                triggerQueue.remove();
-            }
-        }
-    }
-
-    /**
-     * Readout the electrodes of an HPS Si sensor and inject the charge into 
-     * the APV25 readout chip.
-     * 
-     * @param sensor : HPS Si sensor
-     */
-    public void readoutSensor(SiSensor sensor) {
-        // Set the sensor to be used in the charge deposition simulation
-        siSimulation.setSensor(sensor);
-
-        // Perform the charge deposition simulation
-        Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap = siSimulation.computeElectrodeData();
-
-        // Loop over each charge carrier (electron or hole)
-        for (ChargeCarrier carrier : ChargeCarrier.values()) {
-
-            // If the sensor is capable of collecting the given charge carrier
-            // then obtain the electrode data for the sensor
-            if (sensor.hasElectrodesOnSide(carrier)) {
-
-                SiElectrodeDataCollection electrodeDataCol = electrodeDataMap.get(carrier);
-
-                // If there is no electrode data available create a new instance of electrode data
-                if (electrodeDataCol == null) {
-                    electrodeDataCol = new SiElectrodeDataCollection();
-                }
-
-                // Get the readout electrodes
-                SiSensorElectrodes readoutElectrodes = sensor.getReadoutElectrodes(carrier);
-
-                // Add noise to the electrodes
-                if (addNoise) {
-                    addNoise(electrodeDataCol, readoutElectrodes);
-                }
-
-                // Get the analog pipeline map associated with this sensor
-                analogPipelineMap = sensorToPipelineMap.get(sensor);
-
-                // Loop over all channels
-                for (Integer channel : electrodeDataCol.keySet()) {
-
-                    // Get the electrode data for this channel
-                    SiElectrodeData electrodeData = electrodeDataCol.get(channel);
-
-                    // Get the charge in units of electrons
-                    double charge = electrodeData.getCharge();
-
-                    //====> Charge deposition on electrode 
-                    aida.histogram1D("Charge", 100, 0, 200000).fill(charge);
-                    //====>
-
-                    // Get the RMS noise for this channel
-                    double noise = apv25.getChannel().computeNoise(
-                            readoutElectrodes.getCapacitance(channel));
-
-                    //===>
-                    aida.histogram1D(this.getClass().getName() + " - RMS Noise - All Channels", 1000, 3500, 4500).fill(noise);
-                    //===>
-
-                    // Check to see if an analog pipeline for this channel
-                    // exist.  If it doesn't, create one.
-                    if (!analogPipelineMap.containsKey(channel)) {
-                        analogPipelineMap.put(channel,
-                                apv25.getChannel().new APV25AnalogPipeline());
-                    }
-
-                    // Get the analog pipeline associated with this channel
-                    APV25AnalogPipeline pipeline = analogPipelineMap.get(channel);
-
-                    // Inject the charge into the APV25 amplifier chain
-                    apv25.injectCharge(charge, noise, pipeline);
-                }
-            }
-        }
-
-        // Place the analog pipeline back into the sensor map
-        sensorToPipelineMap.put(sensor, analogPipelineMap);
-
-        // Clear the sensors of all deposited charge
-        siSimulation.clearReadout();
-    }
-
-    /**
-     * 
-     */
-    public void readoutAPV25() {
-        // Readout all apv25s
-        for (Map.Entry<SiSensor, Map<Integer, APV25AnalogPipeline>> sensor : sensorToPipelineMap.entrySet()) {
-            sensorToAnalogDataMap.put(sensor.getKey(), apv25.APV25Multiplexer(sensor.getValue()));
-        }
-
-        // Digitize all signals
-        for (Map.Entry<SiSensor, Map<Integer, double[]>> sensor : sensorToAnalogDataMap.entrySet()) {
-            sensorToDigitalDataMap.put(sensor.getKey(), rtm.digitize(sensor.getValue()));
-        }
-
-        // Buffer the samples for further processing
-        //---> Needs to change!
-        dpm.addSample(sensorToDigitalDataMap);
-        //--->
-    }
-
-    /**
-     * 
-     * @param electrodeDataCol
-     * @param electrodes 
-     */
-    public void addNoise(SiElectrodeDataCollection electrodeDataCol,
-            SiSensorElectrodes electrodes) {
-        // First add readout noise to the strips in the 
-        // SiElectrodeDataCollection.
-
-        // Loop over the entries in the SiElectrodeDataCollection
-        for (Entry electrodeDatum : electrodeDataCol.entrySet()) {
-
-            // Get the channel number and electrode data for this entry
-            int channel = (Integer) electrodeDatum.getKey();
-            SiElectrodeData electrodeData = (SiElectrodeData) electrodeDatum.getValue();
-
-            // Get the RMS noise for this channel in units of electrons
-            double noise = apv25.getChannel().computeNoise(
-                    electrodes.getCapacitance(channel));
-
-            // Add readout noise to the deposited charge
-            int noiseCharge = (int) Math.round(random.nextGaussian() * noise);
-            electrodeData.addCharge(noiseCharge);
-        }
-
-        // Find the number of strips that are not currently hit
-        int nElectrodes = electrodes.getNCells();
-        int nElectrodesEmpty = nElectrodes - electrodeDataCol.size();
-
-        // Get the noise threshold in units of the noise charge
-
-        // Calculate how many channels should get noise hits
-        double integral = Erf.phic(noiseThreshold);
-        int nChannelsThrow = drawBinomial(nElectrodesEmpty, integral);
-
-        // Now throw Gaussian randoms above the seed threshold and put signals
-        // on unoccupied channels
-        for (int ithrow = 0; ithrow < nChannelsThrow; ithrow++) {
-            // Throw to get a channel number
-            int channel = random.nextInt(nElectrodes);
-            while (electrodeDataCol.keySet().contains(channel)) {
-                channel = random.nextInt(nElectrodes);
-            }
-
-            // Calculate the noise for this channel in units of electrons
-            double noise = apv25.getChannel().computeNoise(
-                    electrodes.getCapacitance(channel));
-
-            // Throw Gaussian above threshold
-            int charge = (int) Math.round(drawGaussianAboveThreshold(integral) * noise);
-
-            // Add the noise hit to the electrode data collection
-            electrodeDataCol.add(channel, new SiElectrodeData(charge));
-        }
-
-        // Now throw to lower threshold on channels that neighbor hits until
-        // we are exhausted
-
-        nChannelsThrow = 1;
-        while (nChannelsThrow > 0) {
-
-            // Get neighbor channels
-            Set<Integer> neighbors = new HashSet<Integer>();
-            for (int channel : electrodeDataCol.keySet()) {
-                neighbors.addAll(electrodes.getNearestNeighborCells(channel));
-            }
-            neighbors.removeAll(electrodeDataCol.keySet());
-
-            nElectrodesEmpty = neighbors.size();
-
-            integral = Erf.phic(noiseThreshold);
-            nChannelsThrow = drawBinomial(nElectrodesEmpty, integral);
-
-            // Now throw Gaussian randoms above a threshold and put signals on
-            // unoccopied channels
-            for (int ithrow = 0; ithrow < nChannelsThrow; ithrow++) {
-
-                // Throw to get a channel number
-                List<Integer> neighborList = new ArrayList<Integer>(neighbors);
-
-                int channel = neighborList.get(random.nextInt(nElectrodesEmpty));
-
-                while (electrodeDataCol.keySet().contains(channel)) {
-                    channel = neighborList.get(random.nextInt(nElectrodesEmpty));
-
-                }
-
-                // Calculate the noise for this channel in units of electrons
-                double noise = apv25.getChannel().computeNoise(
-                        electrodes.getCapacitance(channel));
-
-                // Throw Gaussian above threshold
-                int charge = (int) Math.round(drawGaussianAboveThreshold(integral) * noise);
-
-                // Add the noise hit to the electrode data collection
-                electrodeDataCol.add(channel, new SiElectrodeData(charge));
-            }
-        }
-    }
-
-    /**
-     * 
-     */
-    public static int drawBinomial(int ntrials, double probability) {
-        binomial.setNumberOfTrials(ntrials);
-        binomial.setProbabilityOfSuccess(probability);
-
-        int nsuccess = 0;
-        try {
-            nsuccess = binomial.inverseCumulativeProbability(random.nextDouble());
-        } catch (MathException exception) {
-            throw new RuntimeException("APV25 failed to calculate inverse cumulative probability of binomial!");
-        }
-        return nsuccess;
-    }
-
-    /**
-     * Return a random variable following normal distribution, but beyond
-     * threshold provided during initialization.
-     */
-    public static double drawGaussianAboveThreshold(double prob_above_threshold) {
-        double cumulative_probability;
-
-        cumulative_probability = 1.0 + prob_above_threshold * (random.nextDouble() - 1.0);
-
-        assert cumulative_probability < 1.0 : "cumulProb=" + cumulative_probability + ", probAboveThreshold=" + prob_above_threshold;
-        assert cumulative_probability >= 0.0 : "cumulProb=" + cumulative_probability + ", probAboveThreshold=" + prob_above_threshold;
-
-        double gaussian_random = 0;
-        try {
-            gaussian_random = gaussian.inverseCumulativeProbability(cumulative_probability);
-        } catch (MathException e) {
-            System.out.println("MathException caught: " + e);
-        }
-
-        return gaussian_random;
-    }
-}

java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25
SvtReadout.java removed after 348
--- java/sandbox/tracking/src/main/java/org/hps/recon/tracking/apv25/SvtReadout.java	2014-03-26 00:20:42 UTC (rev 348)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/apv25/SvtReadout.java	2014-03-26 02:46:31 UTC (rev 363)
@@ -1,318 +0,0 @@
-
-package org.hps.recon.tracking.apv25;
-
-//--- java ---//
-import static org.hps.conditions.deprecated.HPSSVTConstants.TOTAL_APV25_CHANNELS;
-import static org.hps.conditions.deprecated.HPSSVTConstants.TOTAL_NUMBER_OF_SAMPLES;
-import static org.hps.conditions.deprecated.HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-
-import org.hps.conditions.deprecated.HPSSVTConstants;
-import org.hps.conditions.deprecated.SvtUtils;
-//--- lcsim ---//
-import org.lcsim.detector.tracker.silicon.ChargeCarrier;
-import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.event.EventHeader;
-import org.lcsim.event.RawTrackerHit;
-import org.lcsim.geometry.Detector;
-import org.lcsim.hps.util.ClockSingleton;
-import org.lcsim.recon.tracking.digitization.sisim.CDFSiSensorSim;
-import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeData;
-import org.lcsim.recon.tracking.digitization.sisim.SiElectrodeDataCollection;
-import org.lcsim.recon.tracking.digitization.sisim.SiSensorSim;
-import org.lcsim.recon.tracking.digitization.sisim.config.SimTrackerHitReadoutDriver;
-import org.lcsim.util.Driver;
-//--- Constants ---//
-//--- hps-java ---//
-
-/**
- * 
- * @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtReadout.java,v 1.12 2013/04/25 22:11:14 meeg Exp $
- */
-public class SvtReadout extends Driver {
-
-    private Set<SvtHalfModule> halfModules = new HashSet<SvtHalfModule>();
-    private SiSensorSim siSimulation = new CDFSiSensorSim(); 
-    SimTrackerHitReadoutDriver readout = null;
-    // FIFO queue used to store readout times
-    private Queue<Double> fifo = new LinkedList<Double>();
-    
-    List<String> readouts = new ArrayList<String>();
-    Map<SiSensor, List<Integer>> sensorToChannel = new HashMap<SiSensor, List<Integer>>();
-    
-    // Assuming at 41.6 MHz clock, minimum readout time per sample is 3.36 us
-    // For now, a dead time of 250 ns is fine
-    double readoutDeadTimePerSample = 250; // ns
-    double lastTriggerTime = 0;
-    
-    static private int nTriggers = 0;
-    int nTriggersDropped = 0;
-    int triggerLatencyTime = 0; // ns
-    int eventNumber = 0;
-    
-    boolean debug = false;
-    boolean pedestalRun = false;
-    
-    // Collection Names
-    String apv25AnalogDataCollectioName = "APV25AnalogData";
-    String simTrackerHitCollectionName = "TrackerHits";
-    
-    /**
-     * Default Ctor
-     */
-    public SvtReadout(){
-    }
-    
-    /**
-     * 
-     */
-    public void setDebug(boolean debug){
-    	this.debug = debug;
-    }
-    
-    /**
-     * 
-     */
-    public void setPedestalRun(boolean pedestalRun){
-    	this.pedestalRun = pedestalRun;
-    }
-    
-    /**
-     * 
-     */
-    public void setTriggerLatencyTime(int triggerLatencyTime /* ns */){
-    	this.triggerLatencyTime = triggerLatencyTime;
-    }
-    
-    /**
-     * 
-     */
-    static public int getNumberOfTriggers(){
-    	return nTriggers;
-    }
-    
-    /**
-     * 
-     */
-    public void setReadoutDeadTime(int readoutDeadTimePerSample){
-    	this.readoutDeadTimePerSample = readoutDeadTimePerSample;
-    }
-    
-    /**
-     * Set the SimTrackerHit collection name
-     */
-    public void setSimTrackerHitCollectionName(String simTrackerHitCollectionName){
-        this.simTrackerHitCollectionName = simTrackerHitCollectionName;
-    }
-    
-    /**
-     * 
-     */
-    @Override
-    public void detectorChanged(Detector detector){
-        super.detectorChanged(detector);
-        
-        // Instantiate all SVT Half modules
-        for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
-            halfModules.add(new SvtHalfModule(sensor));
-        }
-        
-        // Set the trigger latency
-        for(SvtHalfModule halfModule : halfModules){
-        	for(Apv25Full apv : halfModule.getAllApv25s()){
-        		apv.setLatency(triggerLatencyTime);
-        	}
-        	sensorToChannel.put(halfModule.getSensor(), new ArrayList<Integer>());
-        }
-        
-    	// Load the driver which transfers SimTrackerHits to their 
-    	// corresponding sensor readout
-        if(readout == null){
-        	add(new SimTrackerHitReadoutDriver(readouts));
-        }
-    }
-    
-    /**
-     * 
-     */
-    @Override
-    public void process(EventHeader event){
-        super.process(event);
-        
-        eventNumber++;
-        
-        // Increment all trigger pointer and writer positions when necessary
-        if((ClockSingleton.getTime() + ClockSingleton.getDt()) % HPSSVTConstants.SAMPLING_INTERVAL == 0){
-        	for(SvtHalfModule halfModule : halfModules){
-                for(Apv25Full apv : halfModule.getAllApv25s()){
-                	apv.incrementPointerPositions();
-                }
-            }
-        }
-        
-        // Create a list to hold the analog data
-        List<Apv25AnalogData> analogData = new ArrayList<Apv25AnalogData>();
-
-        // Loop over all half-modules, perform charge deposition simulation and read them out
-        for(SvtHalfModule halfModule : halfModules){
-            this.readoutSensor(halfModule);
-        }
-            
-        // If an Ecal trigger is received, readout six samples from each APV25
-        if(Apv25Full.readoutBit){
-
-            nTriggers++;
-            Apv25Full.readoutBit = false;
-
-            // An APV25 cannot receive a trigger while it's still reading out samples; 
-            // drop the trigger 
-            if(ClockSingleton.getTime() >= (lastTriggerTime + readoutDeadTimePerSample*TOTAL_NUMBER_OF_SAMPLES)){
-            
-            	if(debug) System.out.println(this.getClass().getSimpleName() + ": APVs have been triggered on event " + eventNumber);
-            	
-                lastTriggerTime = ClockSingleton.getTime();
-            
-                for(int sample = 0; sample < TOTAL_NUMBER_OF_SAMPLES; sample++){
-                
-                    // Add the time at which each of the six samples should be collected 
-                    // the trigger queue
-                    fifo.offer(ClockSingleton.getTime() + sample*24);
-                }
-            } else {
-            	if(debug) System.out.println(this.getClass().getSimpleName() + ": Trigger has been dropped!");
-                //make an empty hit collection to make the DAQ happy
-                //TODO: block the event builder from making an event
-                event.put("SVTRawTrackerHits", new ArrayList<RawTrackerHit>(), RawTrackerHit.class, 0);
-            	nTriggersDropped++;
-            	nTriggers--;
-            }
-        }
-
-        // Process any triggers in the queue
-        if(fifo.peek() != null){
-            
-            if(fifo.peek() == ClockSingleton.getTime()){
-
-            	// Clear the analog data and readout all APV25's
-                analogData.addAll(this.readoutAPV25s());
-                fifo.remove();
-            }
-        }
-
-        if(!analogData.isEmpty())
-            event.put(apv25AnalogDataCollectioName, analogData, Apv25AnalogData.class, 0);
-    }
-    
-    /**
-     * Readout the electrodes of an HPS Si sensor and inject the charge into 
-     * the APV25 readout chip.
-     * 
-     * @param halfModule : SVT Half Module
-     */
-    public void readoutSensor(SvtHalfModule halfModule){
-        
-        // Set the sensor to be used in the charge deposition simulation
-        siSimulation.setSensor(halfModule.getSensor());
-        
-        // Perform the charge deposition simulation
-        Map<ChargeCarrier, SiElectrodeDataCollection> electrodeDataMap = siSimulation.computeElectrodeData();
-        
-        for (ChargeCarrier carrier : ChargeCarrier.values()) {
-            
-            // If the sensor is capable of collecting the given charge carrier
-            // then obtain the electrode data for the sensor
-            if (halfModule.getSensor().hasElectrodesOnSide(carrier)) {
-                
-                SiElectrodeDataCollection electrodeDataCol = electrodeDataMap.get(carrier);
-                
-                // If there is no electrode data available create a new instance of electrode data
-                if (electrodeDataCol == null) {
-                    electrodeDataCol = new SiElectrodeDataCollection();
-                }
-                
-                // Loop over all sensor channels
-                for(Integer physicalChannel : electrodeDataCol.keySet()){
-                    
-                    // find the APV channel number from the physical channel
-                    int channel = physicalChannel - TOTAL_STRIPS_PER_SENSOR
-                            + halfModule.getAPV25Number(physicalChannel)*TOTAL_APV25_CHANNELS + (TOTAL_APV25_CHANNELS - 1); 
-                    
-                    // Only inject charge if the channels isn't considered bad
-                    if(halfModule.getAPV25(physicalChannel).getChannel(channel).isBadChannel()) continue;
-                    
-                    // Get the electrode data for this channel
-                    SiElectrodeData electrodeData = electrodeDataCol.get(physicalChannel);
-                    
-                    // Get the charge in units of electrons
-                    double charge = pedestalRun ? 0 : electrodeData.getCharge();
-                    
-                    if(debug){
-                        if(charge > 0){ 
-                        	System.out.println(this.getClass().getSimpleName() 
-                        		+ ": Sensor: " + SvtUtils.getInstance().getDescription(halfModule.getSensor()) 
-                        		+ ": Injecting charge " + charge + " into channel " + physicalChannel);
-                        	sensorToChannel.get(halfModule.getSensor()).add(physicalChannel);
-                        }
-                    }
-                    
-                    // Inject the charge into the APV25 amplifier chain
-                    halfModule.getAPV25(physicalChannel).injectCharge(channel, charge);
-                }
-            }
-        }
-        
-        // Clear the sensors of all deposited charge
-        siSimulation.clearReadout();
-    }
-    
-    /**
-     * 
-     */
-    public List<Apv25AnalogData> readoutAPV25s(){
-        
-        // Create a list to hold the analog data
-        List<Apv25AnalogData> analogData = new ArrayList<Apv25AnalogData>();
-
-        for(SvtHalfModule halfModule : halfModules){
-            
-            // Get the sensor associated with this half-module
-            SiSensor sensor = halfModule.getSensor();
-            
-            // Get all of the APVs associated with the sensor
-            Apv25Full[] apv25 = halfModule.getAllApv25s();
-        
-            if(debug){
-            	for(int physicalChannel = 0; physicalChannel < TOTAL_APV25_CHANNELS; physicalChannel++){
-            		if(sensorToChannel.get(halfModule.getSensor()).contains(physicalChannel)){
-            			int channel = physicalChannel - TOTAL_STRIPS_PER_SENSOR
-                                + halfModule.getAPV25Number(physicalChannel)*TOTAL_APV25_CHANNELS + (TOTAL_APV25_CHANNELS - 1); 
-            			System.out.println("\nPhysical Channel: " + physicalChannel 
-            					+ " Sensor: " + SvtUtils.getInstance().getDescription(halfModule.getSensor())
-            					+ apv25[halfModule.getAPV25Number(physicalChannel)].getChannel(channel).getPipeline().toString() + "\n");
-            		}
-            	}
-            }
-
-            // Readout all APV25's 
-            for(int apvN = 0; apvN < apv25.length; apvN++){
-                Apv25AnalogData analogDatum = apv25[apvN].readOut();
-                analogDatum.setSensor(sensor);
-                analogDatum.setApv(apvN);
-                analogData.add(analogDatum);
-
-            }
-            sensorToChannel.get(halfModule.getSensor()).clear();
-        }
-        
-        return analogData;
-    }
-}
SVNspam 0.1