Commit in java/branches/hps_java_trunk_HPSJAVA-255 on MAIN
conditions/src/main/java/org/hps/conditions/ConditionsDriver.java+17-101113 -> 1114
ecal-readout-sim/src/main/java/org/hps/readout/ecal/SimpleEcalReadoutDriver.java+12-191113 -> 1114
                                                   /TimeEvolutionEcalReadoutDriver.java-191113 -> 1114
ecal-recon/src/main/java/org/hps/recon/ecal/CTPEcalClusterer.java-21113 -> 1114
                                           /EcalClusterer.java-11113 -> 1114
                                           /EcalConverterDriver.java-11113 -> 1114
                                           /EcalEdepToTriggerConverterDriver.java+11-191113 -> 1114
                                           /EcalRawConverter.java+1-61113 -> 1114
                                           /EcalRawConverterDriver.java+41-441113 -> 1114
                                           /EcalReadoutToTriggerConverterDriver.java-11113 -> 1114
                                           /EcalTriggerFilterDriver.java+29-511113 -> 1114
                                           /GTPEcalClusterer.java-11113 -> 1114
                                           /HPSCalorimeterHit.java+34-701113 -> 1114
                                           /HPSEcalCluster.java+213-2621113 -> 1114
evio/src/main/java/org/hps/evio/ECalEvioReader.java+40-441113 -> 1114
                               /TestRunEvioToLcio.java+4-21113 -> 1114
                               /TestRunTriggeredReconToEvio.java-21113 -> 1114
                               /TestRunTriggeredReconToLcio.java+1-31113 -> 1114
steering-files/src/main/resources/org/hps/steering/recon/TestRunOfflineRecon.lcsim+61113 -> 1114
+409-557
19 modified files
clean up, make TestRunEvioToLcio work

java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions
ConditionsDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/conditions/src/main/java/org/hps/conditions/ConditionsDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -1,10 +1,12 @@
 package org.hps.conditions;
 
+import org.lcsim.conditions.ConditionsManager;
+
 /**
- * This {@link org.lcsim.util.Driver} is a subclass of {@link AbstractConditionsDriver}
- * and specifies the database connection parameters and configuration for the
- * development database. 
- * 
+ * This {@link org.lcsim.util.Driver} is a subclass of
+ * {@link AbstractConditionsDriver} and specifies the database connection
+ * parameters and configuration for the development database.
+ *
  * @author Omar Moreno <[log in to unmask]>
  * @author Jeremy McCormick <[log in to unmask]>
  */
@@ -15,11 +17,16 @@
 
     // Default database connection parameters, which points to the SLAC development database.
     static final String DB_CONNECTION = "/org/hps/conditions/config/conditions_dev.properties";
-    
-    public ConditionsDriver(){
-        manager = new DatabaseConditionsManager();
-        manager.setConnectionResource(DB_CONNECTION);
-        manager.configure(DB_CONFIG);
-        manager.register();
+
+    public ConditionsDriver() {
+        if (ConditionsManager.defaultInstance() instanceof DatabaseConditionsManager) {
+            System.out.println(this.getName()+": Found existing DatabaseConditionsManager");
+            manager = (DatabaseConditionsManager) ConditionsManager.defaultInstance();
+        } else {
+            manager = new DatabaseConditionsManager();
+            manager.setConnectionResource(DB_CONNECTION);
+            manager.configure(DB_CONFIG);
+            manager.register();
+        }
     }
 }

java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal
SimpleEcalReadoutDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SimpleEcalReadoutDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SimpleEcalReadoutDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -6,33 +6,26 @@
 
 import org.hps.recon.ecal.HPSCalorimeterHit;
 import org.lcsim.event.CalorimeterHit;
-import org.lcsim.geometry.Detector;
 
 /**
- * Performs readout of ECal hits.
- * No time evolution - this just integrates all hits in a cycle.
+ * Performs readout of ECal hits. No time evolution - this just integrates all
+ * hits in a cycle.
  *
  * @author Sho Uemura <[log in to unmask]>
- * @version $Id: SimpleEcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $
+ * @version $Id: SimpleEcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp
+ * $
  */
 public class SimpleEcalReadoutDriver extends EcalReadoutDriver<HPSCalorimeterHit> {
+
     //buffer for deposited energy
+
     Map<Long, Double> eDepMap = null;
-    
-    Detector detector = null;
-    
-    HPSCalorimeterHit h = null;
 
-	public SimpleEcalReadoutDriver() {
-		hitClass = HPSCalorimeterHit.class;
-	}
+    public SimpleEcalReadoutDriver() {
+        hitClass = HPSCalorimeterHit.class;
+    }
 
     @Override
-    public void detectorChanged(Detector detector) {
-    	this.detector = detector;
-    }
-	
-    @Override
     protected void readHits(List<HPSCalorimeterHit> hits) {
         for (Long cellID : eDepMap.keySet()) {
 //            int ix = dec.getValue("ix");
@@ -41,10 +34,10 @@
 //            int side = dec.getValue("side");
 //            if (iy == 1 && ix*side >= -10 && ix*side <= -2)
 //                continue;
-            if (eDepMap.get(cellID) > threshold)
-            	h = new HPSCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType); 
-                h.setDetector(detector);
+            if (eDepMap.get(cellID) > threshold) {
+                HPSCalorimeterHit h = new HPSCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType);
                 hits.add(h);
+            }
         }
         //reset hit integration
         eDepMap = new HashMap<Long, Double>();

java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal
TimeEvolutionEcalReadoutDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -6,7 +6,6 @@
 
 import org.hps.recon.ecal.HPSCalorimeterHit;
 import org.lcsim.event.CalorimeterHit;
-import org.lcsim.geometry.Detector;
 
 /**
  * Performs readout of ECal hits.
@@ -16,9 +15,6 @@
  * @version $Id: TimeEvolutionEcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $
  */
 public class TimeEvolutionEcalReadoutDriver extends EcalReadoutDriver<HPSCalorimeterHit> {
-
-	Detector detector = null;
-	
     //buffer for deposited energy
     Map<Long, RingBuffer> eDepMap = null;
     //length of ring buffer (in readout cycles)
@@ -26,11 +22,6 @@
     //shaper time constant in ns; negative values generate square pulses of the given width
     double t0 = 18.0;
     
-    @Override
-    public void detectorChanged(Detector detector) {
-    	this.detector = detector;
-    }
-
     public TimeEvolutionEcalReadoutDriver() {
 		hitClass = HPSCalorimeterHit.class;
     }
@@ -49,12 +40,7 @@
         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());
             	HPSCalorimeterHit h = new HPSCalorimeterHit(eDepBuffer.currentValue(), readoutTime(), cellID, hitType);
-            	h.setDetector(detector);
             	hits.add(h);
             }
             eDepBuffer.step();
@@ -65,11 +51,6 @@
     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);

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
CTPEcalClusterer.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/CTPEcalClusterer.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/CTPEcalClusterer.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -355,12 +355,10 @@
                 
                 // Generate a new cluster seed hit from the above results.
                 HPSCalorimeterHit seedHit = new HPSCalorimeterHit(0.0, clusterTime, possibleCluster, hits.get(0).getType());               
-                seedHit.setDetector(detector);
                 seedHit.setMetaData(hits.get(0).getMetaData());
                 
                 // Generate a new cluster from the seed hit.
                 HPSEcalCluster cluster = new HPSEcalCluster();
-                cluster.setDetector(detector);
                 cluster.setSeedHit(seedHit);
                 // Populate the cluster with each of the chosen neighbors.
                 for (CalorimeterHit clusterHit : hits) {

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
EcalClusterer.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterer.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalClusterer.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -164,7 +164,6 @@
             if (isSeed) {
                 // Make a cluster from the hit list.
                 HPSEcalCluster cluster = new HPSEcalCluster();
-                cluster.setDetector(detector);
                 cluster.setSeedHit(hit);
                 cluster.addHit(hit);
                 for (CalorimeterHit clusHit : neighborHits) {

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
EcalConverterDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalConverterDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalConverterDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -87,7 +87,6 @@
 
     private CalorimeterHit HitDtoA(RawCalorimeterHit hit) {
     	HPSCalorimeterHit h = new HPSCalorimeterHit(DtoA(hit.getAmplitude(), hit.getCellID()), period * hit.getTimeStamp() + dt, hit.getCellID(), 0);
-        h.setDetector(detector);
     	return h;
     }
 

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
EcalEdepToTriggerConverterDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -5,13 +5,11 @@
 
 
 //import org.hps.conditions.deprecated.EcalConditions;
-import org.hps.conditions.ConditionsDriver;
 import org.hps.conditions.TableConstants;
 import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
 import org.hps.conditions.ecal.EcalChannel.GeometryId;
 import org.hps.conditions.ecal.EcalChannelConstants;
 import org.hps.conditions.ecal.EcalConditions;
-import org.hps.conditions.ecal.EcalConditionsUtil;
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.detector.identifier.IIdentifier;
 import org.lcsim.detector.identifier.IIdentifierHelper;
@@ -30,28 +28,27 @@
  */
 public class EcalEdepToTriggerConverterDriver extends Driver {
 	
-	Detector detector = null;
-    static EcalConditions ecalConditions = null;
-    static IIdentifierHelper helper = null;
-    static EcalChannelCollection channels = null; 
+    private static EcalConditions ecalConditions = null;
+    private static IIdentifierHelper helper = null;
+    private static EcalChannelCollection channels = null; 
     
-    private static boolean isBadChannelLoaded = true;
+    private static final boolean isBadChannelLoaded = true;
 	
-    private String ecalReadoutName = "EcalHits";
+    private final String ecalReadoutName = "EcalHits";
     private String inputCollection = "EcalHits";
     private String readoutCollection = "EcalCalHits";
     private String triggerCollection = "EcalTriggerHits";
     private boolean applyBadCrystalMap = true;
     private double tp = 14.0;
-    private double readoutPeriod = 4.0;
-    private int readoutThreshold = 50;
-    private int triggerThreshold = 80;
+    private final double readoutPeriod = 4.0;
+    private final int readoutThreshold = 50;
+    private final int triggerThreshold = 80;
     private int truncateScale = 128;
-    private double pulseIntegral = tp * Math.E / readoutPeriod;
-    private double gainScale = 1.0; //gain miscalibration factor
+    private final double pulseIntegral = tp * Math.E / readoutPeriod;
+    private final double gainScale = 1.0; //gain miscalibration factor
     private double _gain = -1.0; //constant gain, activated if >0
     private boolean addNoise = false;
-    private double pePerMeV = 2.0; //photoelectrons per MeV, used to calculate noise
+    private final double pePerMeV = 2.0; //photoelectrons per MeV, used to calculate noise
 
     public EcalEdepToTriggerConverterDriver() {
     }
@@ -99,9 +96,6 @@
     @Override
     public void detectorChanged(Detector detector) {
     	
-    	//Must be set to use the database conditions
-        this.detector = detector;
-    	
         // ECAL combined conditions object.
         ecalConditions = ConditionsManager.defaultInstance()
                 .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
@@ -181,7 +175,6 @@
         int truncatedIntegral = (int) Math.floor(triggerIntegral / truncateScale);
         if (truncatedIntegral > 0) {
         	HPSCalorimeterHit h = new HPSCalorimeterHit(truncatedIntegral, hit.getTime(), hit.getCellID(), 0);
-        	h.setDetector(detector);
             return h ;
         }
         return null;
@@ -222,7 +215,6 @@
 
 //        System.out.format("readout: %f %f\n", amplitude, integral);
         HPSCalorimeterHit h = new HPSCalorimeterHit(integral, hit.getTime(), hit.getCellID(), 0);
-        h.setDetector(detector);
         return h;
     }
 

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
EcalRawConverter.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -1,13 +1,10 @@
 package org.hps.recon.ecal;
 
-import org.hps.conditions.ConditionsDriver;
-import org.hps.conditions.DatabaseConditionsManager;
 import org.hps.conditions.TableConstants;
 import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
 import org.hps.conditions.ecal.EcalChannel.GeometryId;
 import org.hps.conditions.ecal.EcalChannelConstants;
 import org.hps.conditions.ecal.EcalConditions;
-import org.hps.conditions.ecal.EcalConditionsUtil;
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.detector.identifier.IIdentifier;
 import org.lcsim.detector.identifier.IIdentifierHelper;
@@ -25,7 +22,7 @@
  */
 public class EcalRawConverter {
 
-    private boolean debug = false;
+    private final boolean debug = false;
     private boolean constantGain = false;
     private double gain;
     private boolean use2014Gain = true;
@@ -78,7 +75,6 @@
         long id = hit.getCellID();
         double rawEnergy = adcToEnergy(sumADC(hit), id);
         HPSCalorimeterHit h1 = new HPSCalorimeterHit(rawEnergy + 0.0000001, time, id, 0);
-        h1.setDetector(detector);
 //        double[] pos = hit.getDetectorElement().getGeometry().getPosition().v();
         //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY
         return h1;
@@ -95,7 +91,6 @@
         double adcSum = hit.getAmplitude() - window * channelData.getCalibration().getPedestal();
         double rawEnergy = adcToEnergy(adcSum, id);
         HPSCalorimeterHit h2 = new HPSCalorimeterHit(rawEnergy + 0.0000001, time + timeOffset, id, 0);
-        h2.setDetector(detector);
         //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY
         return h2;
     }

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
EcalRawConverterDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -3,16 +3,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hps.conditions.ConditionsDriver;
 import org.hps.conditions.TableConstants;
-import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
 import org.hps.conditions.ecal.EcalChannel.GeometryId;
 import org.hps.conditions.ecal.EcalChannelConstants;
 import org.hps.conditions.ecal.EcalConditions;
 import org.hps.conditions.ecal.EcalConditionsUtil;
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.detector.identifier.Identifier;
 import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
 import org.lcsim.detector.identifier.IIdentifierHelper;
@@ -32,13 +29,14 @@
  */
 public class EcalRawConverterDriver extends Driver {
 
-	// To import database conditions
-    static EcalConditions ecalConditions = null;
-    static IIdentifierHelper helper = null;
-    static EcalChannelCollection channels = null; 
-    
+    // To import database conditions
+    private static EcalConditions ecalConditions = null;
+    private static IIdentifierHelper helper = null;
+    private static EcalChannelCollection channels = null;
+    EcalConditionsUtil util = null;
+
     Detector detector = null;
-    
+
     EcalRawConverter converter = null;
     String rawCollectionName = "EcalReadoutHits";
     String ecalReadoutName = "EcalHits";
@@ -53,7 +51,7 @@
     private boolean useTruthTime = false;
 
     public EcalRawConverterDriver() {
-    	converter = new EcalRawConverter();    	
+        converter = new EcalRawConverter();
     }
 
     public void setUse2014Gain(boolean use2014Gain) {
@@ -113,43 +111,46 @@
 
     @Override
     public void detectorChanged(Detector detector) {
-    	
-    	converter.setDetector(detector);
-    	
-    	// set the detector for the converter
+
+        converter.setDetector(detector);
+
+        // set the detector for the converter
         this.detector = detector;
-    	
+
         // ECAL combined conditions object.
         ecalConditions = ConditionsManager.defaultInstance()
                 .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
-        
+
         // List of channels.
         channels = ecalConditions.getChannelCollection();
-        
+
         // ID helper.
         helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
-        
+
+        util = new EcalConditionsUtil();
+
         System.out.println("You are now using the database conditions for EcalRawConverterDriver.");
     }
+
     /**
      * @return false if the channel is a good one, true if it is a bad one
      * @param CalorimeterHit
      */
-    public static boolean isBadCrystal(CalorimeterHit hit) {   	
+    public static boolean isBadCrystal(CalorimeterHit hit) {
         // Get the channel data.
         EcalChannelConstants channelData = findChannel(hit.getCellID());
-    	
+
         return channelData.isBadChannel();
     }
-    
+
     /**
      * @return false if the ADC is a good one, true if it is a bad one
      * @param CalorimeterHit
      */
-    public boolean isBadFADC(CalorimeterHit hit) {    	
+    public boolean isBadFADC(CalorimeterHit hit) {
         return (getCrate(hit.getCellID()) == 1 && getSlot(hit.getCellID()) == 3);
     }
-    
+
     private static double getTimestamp(int system, EventHeader event) { //FIXME: copied from org.hps.readout.ecal.ReadoutTimestamp
         if (event.hasCollection(GenericObject.class, "ReadoutTimestamps")) {
             List<GenericObject> timestamps = event.get(GenericObject.class, "ReadoutTimestamps");
@@ -181,7 +182,6 @@
             timeOffset += ((t0ECal + 250.0) % 500.0) - 250.0;
         }
 
-
         int flags = 0;
         flags += 1 << LCIOConstants.RCHBIT_TIME; //store hit time
         flags += 1 << LCIOConstants.RCHBIT_LONG; //store hit position; this flag has no effect for RawCalorimeterHits
@@ -195,10 +195,10 @@
 
                 for (RawTrackerHit hit : hits) {
                     CalorimeterHit newHit = converter.HitDtoA(hit);
-             
+
                     // Get the channel data.
                     EcalChannelConstants channelData = findChannel(newHit.getCellID());
-                    
+
                     if (applyBadCrystalMap && channelData.isBadChannel()) {
                         continue;
                     }
@@ -219,7 +219,7 @@
                         System.out.format("old hit energy %d\n", hit.getAmplitude());
                     }
                     CalorimeterHit newHit = converter.HitDtoA(hit, integralWindow, timeOffset);
-                    
+
                     if (newHit.getRawEnergy() > threshold) {
                         if (applyBadCrystalMap && isBadCrystal(newHit)) {
                             continue;
@@ -256,52 +256,49 @@
             }
         }
     }
-    
-    
-    /** 
+
+    /**
      * Convert physical ID to gain value.
+     *
      * @param cellID (long)
      * @return channel constants (EcalChannelConstants)
      */
     private static EcalChannelConstants findChannel(long cellID) {
         // Make an ID object from raw hit ID.
         IIdentifier id = new Identifier(cellID);
-        
+
         // Get physical field values.
         int system = helper.getValue(id, "system");
         int x = helper.getValue(id, "ix");
         int y = helper.getValue(id, "iy");
-        
+
         // Create an ID to search for in channel collection.
-        GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
-                
+        GeometryId geometryId = new GeometryId(helper, new int[]{system, x, y});
+
         // Get the channel data.
-        return ecalConditions.getChannelConstants(channels.findChannel(geometryId));    
+        return ecalConditions.getChannelConstants(channels.findChannel(geometryId));
     }
-    
+
     /**
      * Return crate number from cellID
+     *
      * @param cellID (long)
      * @return Crate number (int)
      */
     private int getCrate(long cellID) {
-        
-        EcalConditionsUtil util = new EcalConditionsUtil();
-
         // Find the ECAL channel and return the crate number.
         return util.getCrate(helper, cellID);
     }
-    
+
     /**
      * Return slot number from cellID
+     *
      * @param cellID (long)
      * @return Slot number (int)
      */
     private int getSlot(long cellID) {
-        EcalConditionsUtil util = new EcalConditionsUtil();
-
         // Find the ECAL channel and return the crate number.
-        return util.getSlot(helper, cellID);         
+        return util.getSlot(helper, cellID);
     }
-    
+
 }

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
EcalReadoutToTriggerConverterDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalReadoutToTriggerConverterDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalReadoutToTriggerConverterDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -207,7 +207,6 @@
             truncatedIntegral = 0;
         }
         HPSCalorimeterHit h = new HPSCalorimeterHit(truncatedIntegral, hitTime, id, 0);
-        h.setDetector(detector);
 //        CalorimeterHit h = new HPSRawCalorimeterHit(triggerIntegral + 0.0000001, hit.getPosition(), hitTime, id, 0);
         //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY
         return h;

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
EcalTriggerFilterDriver.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/EcalTriggerFilterDriver.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -5,17 +5,8 @@
 import java.util.Queue;
 import java.util.concurrent.ArrayBlockingQueue;
 
-import org.hps.conditions.ConditionsDriver;
-import org.hps.conditions.TableConstants;
-import org.hps.conditions.ecal.EcalChannel;
-import org.hps.conditions.ecal.EcalChannel.DaqId;
-import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
 import org.hps.conditions.ecal.EcalChannel.GeometryId;
-import org.hps.conditions.ecal.EcalChannelConstants;
-import org.hps.conditions.ecal.EcalConditions;
 import org.hps.conditions.ecal.EcalConditionsUtil;
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.detector.identifier.IIdentifier;
 import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.EventHeader;
@@ -24,23 +15,22 @@
 
 /**
  * Changes ECal hit IDs to match what the test run trigger sees.
+ *
  * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54
  * phansson Exp $
  */
 public class EcalTriggerFilterDriver extends Driver {
 
-	// To import database conditions
-    static EcalConditions ecalConditions = null;
-    static IIdentifierHelper helper = null;
-    static EcalChannelCollection channels = null;
-    int systemId;
-    Detector detector = null;
-    
-    private String ecalReadoutName = "EcalHits";
+    // To import database conditions
+    private IIdentifierHelper helper = null;
+    private int systemId;
+    private EcalConditionsUtil util = null;
+
+    private final String ecalReadoutName = "EcalHits";
     private String inputCollection = "EcalReadoutHits";
     private String outputCollection = "EcalCalHits";
-    private int topDelay = 0;
-    private int bottomDelay = 5;
+    private final int topDelay = 0;
+    private final int bottomDelay = 5;
     private Queue<List<CalorimeterHit>> topHitsQueue = null;
     private Queue<List<CalorimeterHit>> bottomHitsQueue = null;
 
@@ -73,21 +63,13 @@
 
     @Override
     public void detectorChanged(Detector detector) {
-    	
-    	this.detector = detector;
-    	
-        // ECAL combined conditions object.
-        ecalConditions = ConditionsManager.defaultInstance()
-                .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
-        
-        // List of channels.
-        channels = ecalConditions.getChannelCollection();
-        
         // ID helper.
         helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
 
         systemId = detector.getSubdetector("Ecal").getSystemID();
-        
+
+        util = new EcalConditionsUtil();
+
         System.out.println("You are now using the database conditions for EcalTriggerFilterDriver.");
     }
 
@@ -103,7 +85,8 @@
             for (CalorimeterHit hit : hits) {
                 CalorimeterHit newHit = filterHit(hit);
                 if (newHit != null) {
-                    if (hit.getIdentifierFieldValue("iy") > 0) { //should really be checking newHit, but it doesn't have metadata yet
+                    newHit.setMetaData(hit.getMetaData());
+                    if (newHit.getIdentifierFieldValue("iy") > 0) {
                         topHits.add(newHit);
                     } else {
                         bottomHits.add(newHit);
@@ -121,6 +104,7 @@
 
     /**
      * This method takes input hits and makes new hits with different ix
+     *
      * @param CalorimeterHit hit
      * @return new HPSCalorimeterHit
      */
@@ -130,8 +114,8 @@
         int crate = getCrate(hit.getCellID());
         int slot = getSlot(hit.getCellID());
 
-        int delay = iy>0?topDelay:bottomDelay;  
-        
+        int delay = iy > 0 ? topDelay : bottomDelay;
+
         // no triggers from crate 1, slot 3 
         if (crate == 1 && slot == 3) {
             return null;
@@ -141,43 +125,37 @@
         if (ix > 0 && iy > 0) {
             ix = 24 - ix;
         }
-     
+
         int values[] = {systemId, ix, iy};
-        GeometryId geomId = new GeometryId(helper, values);       
+        GeometryId geomId = new GeometryId(helper, values);
         // Creating the new channel from cell id, ix and iy, then reading its ID       
-        long newID = geomId.encode();      
-        
+        long newID = geomId.encode();
+
         //make new hit; set position to null so it gets recalculated
-        HPSCalorimeterHit h = new HPSCalorimeterHit(hit.getRawEnergy(), hit.getTime()+delay*4, newID, hit.getType());
-        h.setDetector(detector);
+        HPSCalorimeterHit h = new HPSCalorimeterHit(hit.getRawEnergy(), hit.getTime() + delay * 4, newID, hit.getType());
         return h;
     }
-    
+
     /**
      * Return crate number from cellID
+     *
      * @param cellID (long)
      * @return Crate number (int)
      */
     private int getCrate(long cellID) {
-        
-        EcalConditionsUtil util = new EcalConditionsUtil();
-
         // Find the ECAL channel and return the crate number.
         return util.getCrate(helper, cellID);
     }
-    
+
     /**
      * Return slot number from cellID
+     *
      * @param cellID (long)
      * @return Slot number (int)
      */
     private int getSlot(long cellID) {
-        EcalConditionsUtil util = new EcalConditionsUtil();
-
         // Find the ECAL channel and return the crate number.
-        return util.getSlot(helper, cellID);         
-    } 
- 
-    
-    
+        return util.getSlot(helper, cellID);
+    }
+
 }

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
GTPEcalClusterer.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/GTPEcalClusterer.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/GTPEcalClusterer.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -160,7 +160,6 @@
             // Store the crystals that are part of this potential cluster, 
             // starting with the cluster seed candidate.
             HPSEcalCluster cluster = new HPSEcalCluster();
-            cluster.setDetector(detector);
             cluster.setSeedHit(currentHit);
             cluster.addHit(currentHit);
             

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
HPSCalorimeterHit.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSCalorimeterHit.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSCalorimeterHit.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -4,21 +4,10 @@
 
 import java.util.Comparator;
 
-import org.hps.conditions.ConditionsDriver;
-import org.hps.conditions.TableConstants;
-import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
-import org.hps.conditions.ecal.EcalChannel.GeometryId;
-import org.hps.conditions.ecal.EcalChannelConstants;
-import org.hps.conditions.ecal.EcalConditions;
-import org.hps.conditions.ecal.EcalConditionsUtil;
-import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.detector.identifier.IIdentifier;
-import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.detector.IDetectorElement;
 import org.lcsim.detector.IDetectorElementContainer;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.base.BaseCalorimeterHit;
-import org.lcsim.geometry.Detector;
 
 /**
  * An implementation of CalorimeterHit, with a constructor that sets rawEnergy
@@ -29,11 +18,6 @@
  */
 public class HPSCalorimeterHit extends BaseCalorimeterHit {
 
-    Detector detector = null;    
-    static EcalConditions ecalConditions = null;
-    static IIdentifierHelper helper = null;
-    static EcalChannelCollection channels = null; 
-
     /**
      * Fully qualified constructor that sets rawEnergy
      *
@@ -46,37 +30,33 @@
      */
     public HPSCalorimeterHit(double energy, double time, long id, int type) {
         this.rawEnergy = energy;
-//      if (position != null) {
-//          this.positionVec = new BasicHep3Vector(position);
-//      } else {
-//          positionVec = null;
-//      }
-      this.time = time;
-      this.id = id;
-      this.type = type;
+        this.correctedEnergy = energy;
+        this.time = time;
+        this.id = id;
+        this.type = type;
     }
     
-    /**
-     * Fully qualified constructor that sets rawEnergy
-     *
-     * @param energy   Raw energy for this cell
-     * @param position Global Cartesian coordinate for this cell
-     * @param time     Time of energy deposition
-     * @param id       Cell ID
-     * @param type     Type
-     * WARNING: setDetector(detector) must be called after initialization
-     */
-    public HPSCalorimeterHit(CalorimeterHit hit) {
-        this.rawEnergy = hit.getRawEnergy();
-//      if (position != null) {
-//          this.positionVec = new BasicHep3Vector(position);
-//      } else {
-//          positionVec = null;
-//      }
-      this.time = hit.getTime();
-      this.id = hit.getCellID();
-      this.type = hit.getType();
-    }
+//    /**
+//     * Fully qualified constructor that sets rawEnergy
+//     *
+//     * @param energy   Raw energy for this cell
+//     * @param position Global Cartesian coordinate for this cell
+//     * @param time     Time of energy deposition
+//     * @param id       Cell ID
+//     * @param type     Type
+//     * WARNING: setDetector(detector) must be called after initialization
+//     */
+//    public HPSCalorimeterHit(CalorimeterHit hit) {
+//        this.rawEnergy = hit.getRawEnergy();
+////      if (position != null) {
+////          this.positionVec = new BasicHep3Vector(position);
+////      } else {
+////          positionVec = null;
+////      }
+//      this.time = hit.getTime();
+//      this.id = hit.getCellID();
+//      this.type = hit.getType();
+//    }
     
     /**
      * Fully qualified constructor that sets rawEnergy
@@ -103,7 +83,7 @@
     public IDetectorElement getDetectorElement() {
         if (de == null) {
 //            findDetectorElementByPosition();
-            IDetectorElementContainer detectorElements = detector.getDetectorElement().findDetectorElement(getIdentifier());
+            IDetectorElementContainer detectorElements = getSubdetector().getDetectorElement().findDetectorElement(getIdentifier());
             if (detectorElements.size() != 1) {
                 throw new RuntimeException("Expected exactly one DetectorElement matching ID " + getIdentifier() + ", got " + detectorElements.size());
             } else {
@@ -116,12 +96,18 @@
 
     @Override
     public double[] getPosition() {
-        return getPositionVec().v();
+        if (positionVec == null) {
+            positionVec = this.getDetectorElement().getGeometry().getPosition();
+        }
+        return super.getPosition();
     }
 
     @Override
     public Hep3Vector getPositionVec() {
-        return this.getDetectorElement().getGeometry().getPosition();
+        if (positionVec == null) {
+            positionVec = this.getDetectorElement().getGeometry().getPosition();
+        }
+        return super.getPositionVec();
     }
 
     static class TimeComparator implements Comparator<CalorimeterHit> {
@@ -131,26 +117,4 @@
             return Double.compare(o1.getTime(), o2.getTime());
         }
     }
-    
-    /** 
-     * Must be set when an object HPSCalorimeterHit is created.
-     * @param detector (long)
-     */
-    public void setDetector(Detector detector) {
-        this.detector = detector;
-        
-        // ECAL combined conditions object.
-        ecalConditions = ConditionsManager.defaultInstance()
-                .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
-        
-        // List of channels.
-        channels = ecalConditions.getChannelCollection();
-        
-        // ID helper.
-        helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
-        
-//        System.out.println("You are now using the database conditions for HPSCalorimeterHit.");
-    }
-    
-    
 }

java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal
HPSEcalCluster.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalCluster.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalCluster.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -6,17 +6,11 @@
 
 import java.util.List;
 
-import org.hps.conditions.TableConstants;
-import org.hps.conditions.ecal.EcalConditions;
-import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
-import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.detector.IGeometryInfo;
-import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.detector.solids.Trd;
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.Cluster;
 import org.lcsim.event.base.BaseCluster;
-import org.lcsim.geometry.Detector;
 
 /**
  * Cluster with position defined by seed hit (for 1-bit trigger)
@@ -25,50 +19,42 @@
  * @version $Id: HPSEcalCluster.java,v 1.11 2013/02/25 22:39:24 meeg Exp $
  */
 public class HPSEcalCluster extends BaseCluster {
-	
-    Detector detector = null;    
-    static EcalConditions ecalConditions = null;
-    static IIdentifierHelper helper = null;
-    static EcalChannelCollection channels = null;
 
     private CalorimeterHit seedHit = null;
     private long cellID;
-    
-    static final double eCriticalW = 800.0*ECalUtils.MeV/(74+1);
+
+    static final double eCriticalW = 800.0 * ECalUtils.MeV / (74 + 1);
     static final double radLenW = 8.8; //mm
     double[] electronPosAtDepth = new double[3];
     private boolean needsElectronPosCalculation = true;
     double[] photonPosAtDepth = new double[3];
     private boolean needsPhotonPosCalculation = true;
 
-    /** 
-     * After the declaration, yourHPSEcalCluster.setDetector(detector) must be called
+    /**
      * @param cellID (long)
      */
     public HPSEcalCluster() {
-    }    
-    
-    /** 
-     * After the declaration, yourHPSEcalCluster.setDetector(detector) must be called
+    }
+
+    /**
+     *
      * @param cellID (long)
      */
     public HPSEcalCluster(Long cellID) {
         this.cellID = cellID;
     }
 
-    /** 
-     * Before using this method yourHPSEcalCluster.setDetector(detector) must be called
+    /**
+     *
      * @param CalorimeterHit
-     */ 
+     */
     public void setSeedHit(CalorimeterHit seedHit) {
         this.seedHit = seedHit;
-        ((HPSCalorimeterHit) seedHit).setDetector(detector);
         this.cellID = seedHit.getCellID();
     }
 
     /**
-     * 
-     * @param 
+     *
      * @return CalorimeterHit
      */
     public CalorimeterHit getSeedHit() {
@@ -83,18 +69,13 @@
         }
         return seedHit;
     }
-    
-    /** 
-     * Must be set when an object HPSEcalCluster is created.
-     * @param detector (long)
-     */
-    public void setDetector(Detector detector) {
-        this.detector = detector;
-    }
-    
+
     /**
-     * Find highest-energy hit in a cluster. For clusters made by GTPEcalClusterer, HPSEcalCluster.getSeedHit(cluster) should be equivalent to cluster.getSeedHit().
-     * Since this method doesn't require that the cluster be an HPSEcalCluster, it will work on clusters read from LCIO.
+     * Find highest-energy hit in a cluster. For clusters made by
+     * GTPEcalClusterer, HPSEcalCluster.getSeedHit(cluster) should be equivalent
+     * to cluster.getSeedHit(). Since this method doesn't require that the
+     * cluster be an HPSEcalCluster, it will work on clusters read from LCIO.
+     *
      * @param cluster
      * @return CalorimeterHit
      */
@@ -107,7 +88,7 @@
         }
         return seedHit;
     }
-    
+
 //    public double[] getPosition() {
 //        return getSeedHit().getPosition();
 //    }
@@ -117,45 +98,40 @@
         //Electron by default!?
         return this.getPositionAtShowerMax(true);
     }
-        
+
     public double[] getPositionAtShowerMax(boolean isElectron) {
-        if( isElectron) {
-            if(needsElectronPosCalculation) {
+        if (isElectron) {
+            if (needsElectronPosCalculation) {
                 this.calcPositionAtShowerMax(true);
             }
             return this.electronPosAtDepth;
-        }
-        else {
-            if(needsPhotonPosCalculation) {
+        } else {
+            if (needsPhotonPosCalculation) {
                 this.calcPositionAtShowerMax(false);
             }
             return this.photonPosAtDepth;
-        }  
+        }
     }
-        
+
     public void calcPositionAtShowerMax(boolean isElectron) {
         double E = this.getEnergy();
-        double y = E/eCriticalW;
+        double y = E / eCriticalW;
         double Cj = isElectron ? -0.5 : 0.5;
         double tmax = Math.log(y) + Cj; //Maximum of dE/dt profile in units of rad. len. 
-        double dmax = tmax*radLenW; //mm
-        if(isElectron) {
-            electronPosAtDepth =  calculatePositionAtDepth(dmax);
+        double dmax = tmax * radLenW; //mm
+        if (isElectron) {
+            electronPosAtDepth = calculatePositionAtDepth(dmax);
         } else {
-            photonPosAtDepth =  calculatePositionAtDepth(dmax);
+            photonPosAtDepth = calculatePositionAtDepth(dmax);
         }
-            
+
     }
-    
-    
-    
-    public double[] calculatePositionAtDepth(double dmax) 
-    {
+
+    public double[] calculatePositionAtDepth(double dmax) {
         return this.calculatePositionAtDepth(this.getCalorimeterHits(), dmax);
-    }    
-    
-    public double[] calculatePositionAtDepth(List<CalorimeterHit> hits, double dmax)
-    {
+    }
+
+    public double[] calculatePositionAtDepth(List<CalorimeterHit> hits, double dmax) {
         //copy from package org.lcsim.recon.cluster.util.TensorClusterPropertyCalculator;
 
         double positionErrorLocal[] = new double[6];
@@ -164,17 +140,16 @@
         double positionLocal[] = new double[3];
         double ithetaLocal;
         double iphiLocal;
-        
-        
+
         double[] mm_NE = new double[3];
         double[] mm_CE = new double[3];
         double[][] mm_PA = new double[3][3];
-        for(int i=0;i<3;++i)
-        {
+        for (int i = 0; i < 3; ++i) {
             mm_NE[i] = 0.;
             mm_CE[i] = 0.;
-            for(int j=0;j<3;++j)
-            {mm_PA[i][j]= 0.;}
+            for (int j = 0; j < 3; ++j) {
+                mm_PA[i][j] = 0.;
+            }
         }
         double Etot = 0.0;
         double Exx = 0.0;
@@ -197,8 +172,7 @@
         double M = 0.0;
         double Det = 0.0;
         int nhits = hits.size();
-        for(int i=0;i<hits.size();i++)
-        {
+        for (int i = 0; i < hits.size(); i++) {
             CalorimeterHit hit = hits.get(i);
             //	CalorimeterIDDecoder decoder = hit.getDecoder();
             //	decoder.setID(hit.getCellID());
@@ -209,52 +183,50 @@
             //double[] pos = hit.getPosition();
             //Find position at shower max
             IGeometryInfo geom = hit.getDetectorElement().getGeometry();
-            double[] pos = geom.transformLocalToGlobal(VecOp.add(geom.transformGlobalToLocal(geom.getPosition()),(Hep3Vector)new BasicHep3Vector(0,0,dmax-1*((Trd)geom.getLogicalVolume().getSolid()).getZHalfLength()))).v();
-                        
+            double[] pos = geom.transformLocalToGlobal(VecOp.add(geom.transformGlobalToLocal(geom.getPosition()), (Hep3Vector) new BasicHep3Vector(0, 0, dmax - 1 * ((Trd) geom.getLogicalVolume().getSolid()).getZHalfLength()))).v();
+
 //            System.out.println("global pos " + global_pos.toString());
 //            System.out.println("local pos " + local_pos.toString());
 //            System.out.println("local pos tmax " + local_pos_tmax.toString());
 //            System.out.println("global pos tmax " + global_pos_tmax.toString());
 //            
             //pos = global_pos_tmax.v();
-            
             double E = hit.getCorrectedEnergy();
             Etot += E;
-            CEx += E*pos[0];
-            CEy += E*pos[1];
-            CEz += E*pos[2];
-            Exx += E*(pos[1]*pos[1] + pos[2]*pos[2]);
-            Eyy += E*(pos[0]*pos[0] + pos[2]*pos[2]);
-            Ezz += E*(pos[1]*pos[1] + pos[0]*pos[0]);
-            Exy -= E*pos[0]*pos[1];
-            Eyz -= E*pos[1]*pos[2];
-            Exz -= E*pos[0]*pos[2];
+            CEx += E * pos[0];
+            CEy += E * pos[1];
+            CEz += E * pos[2];
+            Exx += E * (pos[1] * pos[1] + pos[2] * pos[2]);
+            Eyy += E * (pos[0] * pos[0] + pos[2] * pos[2]);
+            Ezz += E * (pos[1] * pos[1] + pos[0] * pos[0]);
+            Exy -= E * pos[0] * pos[1];
+            Eyz -= E * pos[1] * pos[2];
+            Exz -= E * pos[0] * pos[2];
         }
-        CEx = CEx/Etot;
-        CEy = CEy/Etot;
-        CEz = CEz/Etot;
-        double CErSq = CEx*CEx + CEy*CEy + CEz*CEz;
+        CEx = CEx / Etot;
+        CEy = CEy / Etot;
+        CEz = CEz / Etot;
+        double CErSq = CEx * CEx + CEy * CEy + CEz * CEz;
         CEr = Math.sqrt(CErSq);
         // now go to center of energy coords.
-        if (nhits > 3 )
-        {
-            Exx = Exx - Etot*(CErSq - CEx*CEx);
-            Eyy = Eyy - Etot*(CErSq - CEy*CEy);
-            Ezz = Ezz - Etot*(CErSq - CEz*CEz);
-            Exy = Exy + Etot*CEx*CEy;
-            Eyz = Eyz + Etot*CEy*CEz;
-            Exz = Exz + Etot*CEz*CEx;
+        if (nhits > 3) {
+            Exx = Exx - Etot * (CErSq - CEx * CEx);
+            Eyy = Eyy - Etot * (CErSq - CEy * CEy);
+            Ezz = Ezz - Etot * (CErSq - CEz * CEz);
+            Exy = Exy + Etot * CEx * CEy;
+            Eyz = Eyz + Etot * CEy * CEz;
+            Exz = Exz + Etot * CEz * CEx;
 
             //
             Tr = Exx + Eyy + Ezz;
-            double Dxx = Eyy*Ezz - Eyz*Eyz;
-            double Dyy = Ezz*Exx - Exz*Exz;
-            double Dzz = Exx*Eyy - Exy*Exy;
+            double Dxx = Eyy * Ezz - Eyz * Eyz;
+            double Dyy = Ezz * Exx - Exz * Exz;
+            double Dzz = Exx * Eyy - Exy * Exy;
             M = Dxx + Dyy + Dzz;
-            double Dxy = Exy*Ezz - Exz*Eyz;
-            double Dxz = Exy*Eyz - Exz*Eyy;
-            Det = Exx*Dxx - Exy*Dxy + Exz*Dxz;
-            double xt = Tr*Tr - 3*M;
+            double Dxy = Exy * Ezz - Exz * Eyz;
+            double Dxz = Exy * Eyz - Exz * Eyy;
+            Det = Exx * Dxx - Exy * Dxy + Exz * Dxz;
+            double xt = Tr * Tr - 3 * M;
             double sqrtxt = Math.sqrt(xt);
             // eqn to solve for eigenvalues is x**3 - x**2*Tr + x*M - Det = 0
             // crosses y axis at -Det and inflection points are
@@ -262,180 +234,165 @@
             double mE1 = 0.;
             double mE2 = 0.;
             double mE3 = 0.;
-            double a = (3*M - Tr*Tr)/3.;
-            double b = (-2*Tr*Tr*Tr + 9*Tr*M -27*Det)/27.;
-            double test = b*b/4. + a*a*a/27.;
-            if(test >= 0.01)
-            {
+            double a = (3 * M - Tr * Tr) / 3.;
+            double b = (-2 * Tr * Tr * Tr + 9 * Tr * M - 27 * Det) / 27.;
+            double test = b * b / 4. + a * a * a / 27.;
+            if (test >= 0.01) {
                 //System.out.println("AbstractCluster: Only 1 real root!!!");
                 //System.out.println("  nhits = " + nhits + "\n");
                 //System.out.println(" a,b,test = " + a + " " + b + " " + test + "\n");
-            }
-            else
-            {
+            } else {
                 double temp;
-                if(test >= 0.)temp = 1.;
-                else temp = Math.sqrt(b*b*27./(-a*a*a*4.));
-                if(b > 0.)temp = -temp;
+                if (test >= 0.) {
+                    temp = 1.;
+                } else {
+                    temp = Math.sqrt(b * b * 27. / (-a * a * a * 4.));
+                }
+                if (b > 0.) {
+                    temp = -temp;
+                }
                 double phi = Math.acos(temp);
-                double temp1 = 2.*Math.sqrt(-a/3.);
-                mE1 = Tr/3. + 2.*Math.sqrt(-a/3.)*Math.cos(phi/3.);
-                mE2 = Tr/3. + 2.*Math.sqrt(-a/3.)*Math.cos(phi/3. + 2.*Math.PI/3.);
-                mE3 = Tr/3. + 2.*Math.sqrt(-a/3.)*Math.cos(phi/3. + 4.*Math.PI/3.);
+                double temp1 = 2. * Math.sqrt(-a / 3.);
+                mE1 = Tr / 3. + 2. * Math.sqrt(-a / 3.) * Math.cos(phi / 3.);
+                mE2 = Tr / 3. + 2. * Math.sqrt(-a / 3.) * Math.cos(phi / 3. + 2. * Math.PI / 3.);
+                mE3 = Tr / 3. + 2. * Math.sqrt(-a / 3.) * Math.cos(phi / 3. + 4. * Math.PI / 3.);
             }
-            if(mE1 < mE2)
-            {
-                if(mE1 < mE3)
-                {
+            if (mE1 < mE2) {
+                if (mE1 < mE3) {
                     E1 = mE1;
-                    if(mE2 < mE3)
-                    {
+                    if (mE2 < mE3) {
                         E2 = mE2;
                         E3 = mE3;
-                    }
-                    else
-                    {
+                    } else {
                         E2 = mE3;
                         E3 = mE2;
                     }
-                }
-                else
-                {
+                } else {
                     E1 = mE3;
                     E2 = mE1;
                     E3 = mE2;
                 }
-            }
-            else
-            {
-                if(mE2 < mE3)
-                {
+            } else {
+                if (mE2 < mE3) {
                     E1 = mE2;
-                    if(mE1 < mE3)
-                    {
+                    if (mE1 < mE3) {
                         E2 = mE1;
                         E3 = mE3;
-                    }
-                    else
-                    {
+                    } else {
                         E2 = mE3;
                         E3 = mE1;
                     }
-                }
-                else
-                {
+                } else {
                     E1 = mE3;
                     E2 = mE2;
                     E3 = mE1;
                 }
             }
 
-            NE1 = E1/Etot;
-            NE2 = E2/Etot;
-            NE3 = E3/Etot;
+            NE1 = E1 / Etot;
+            NE2 = E2 / Etot;
+            NE3 = E3 / Etot;
             double[] EV = new double[3];
             EV[0] = E1;
             EV[1] = E2;
             EV[2] = E3;
             // Now calculate principal axes
-	    // For eigenvalue EV, the axis is (nx, ny, nz) where:
-	    //    (Exx - EV)nx + (Exy)ny + (Exz)nz = 0
-	    //    (Eyx)nx + (Eyy - EV)ny + (Eyz)nz = 0
-	    //    (Ezx)nx + (Ezy)ny + (Ezz - EV)nz = 0
-	    // Setting nx = 1, we have:
-	    //    (Exx - EV) + (Exy)ny + (Exz)nz = 0
-	    //    (Eyx) + (Eyy - EV)ny + (Eyz)nz = 0
-	    //    (Ezx) + (Ezy)ny + (Ezz - EV)nz = 0
-	    // and so
-	    //    (Exy)ny = EV - Exx - (Exz)nz  =>  ny = (EV - Exx - Exz*nz)/Exy
-	    // What if Exy = 0? Then provided Eyz is non-zero we can write:
-	    //    (Ezx) + (Ezy)ny + (Ezz - EV)nz = 0
-	    //    ny = (Exz - (Ezz-EV)*nz)/Eyz
-	    // What if Exy = 0 and Eyz = 0 but (Eyy - EV) is non-zero?
-	    //    (Eyy - EV)ny + (Eyz)nz = 0
-	    //    ny = -(Eyz*nz)/(Eyy-EV)
+            // For eigenvalue EV, the axis is (nx, ny, nz) where:
+            //    (Exx - EV)nx + (Exy)ny + (Exz)nz = 0
+            //    (Eyx)nx + (Eyy - EV)ny + (Eyz)nz = 0
+            //    (Ezx)nx + (Ezy)ny + (Ezz - EV)nz = 0
+            // Setting nx = 1, we have:
+            //    (Exx - EV) + (Exy)ny + (Exz)nz = 0
+            //    (Eyx) + (Eyy - EV)ny + (Eyz)nz = 0
+            //    (Ezx) + (Ezy)ny + (Ezz - EV)nz = 0
+            // and so
+            //    (Exy)ny = EV - Exx - (Exz)nz  =>  ny = (EV - Exx - Exz*nz)/Exy
+            // What if Exy = 0? Then provided Eyz is non-zero we can write:
+            //    (Ezx) + (Ezy)ny + (Ezz - EV)nz = 0
+            //    ny = (Exz - (Ezz-EV)*nz)/Eyz
+            // What if Exy = 0 and Eyz = 0 but (Eyy - EV) is non-zero?
+            //    (Eyy - EV)ny + (Eyz)nz = 0
+            //    ny = -(Eyz*nz)/(Eyy-EV)
 
-	    // In the pathological case where Exz = Eyz = Ezz = 0:
-	    //    (Exx - EV)nx + (Exy)ny = 0  =>  ny/nx = -(Exx-EV)/Exy
-	    //    (Eyx)nx + (Eyy - EV)ny = 0  =>  ny/nx = -Eyx/(Eyy-EV)
-	    //    (EV)nz = 0
-	    // so
-	    //     -ny/nx = (EV-Exx)/Exy = Eyx/(EV-Eyy)
-	    // But watch out for order! Recalculate eigenvalues for this pathological case.
-	    //     (EV-Exx)(EV-Eyy) = Eyx*Exy
-	    //     EV^2 - EV(Exx+Eyy) + Exx*Eyy - Eyx*Exy = 0
-	    // 
-	    // In another pathological case, Exz = Exy = 0:
-	    //    (Exx - EV)nx = 0
-	    //    (Eyy - EV)ny + (Eyz)nz = 0 => ny/nz = -(Eyz)/(Eyy-EV)
-	    //    (Ezy)ny + (Ezz - EV)nz = 0 => ny/nz = -(Ezz-EV)/(Ezy)
-	    // so we cannot set nx = 1. Instead, write:
-	    //    -ny/nz = (Eyz)/(Eyy-EV) = (Ezz-EV)/(Ezy)
-	    // Then
-	    //    (Eyz)(Ezy) = (Eyy-EV)(Ezz-EV)
-	    //    (Eyz)^2 = (Eyy)(Ezz) - (Eyy)(EV) - (Ezz)(EV) + (EV)^2
-	    //    EV^2 - EV(Eyy+Ezz) + Eyy*Ezz - Eyz*Eyz = 0
-
-	    // Handle pathological case
-	    if (Exz == 0.0 && Eyz == 0.0) {
-		// Recompute eigenvectors.
-		EV[0] = 0.5*(Exx+Eyy) + 0.5*Math.sqrt((Exx+Eyy)*(Exx+Eyy) + 4.0*Exy*Exy);
-		EV[1] = 0.5*(Exx+Eyy) - 0.5*Math.sqrt((Exx+Eyy)*(Exx+Eyy) + 4.0*Exy*Exy);
-		EV[2] = 0.0;
-		for( int i = 0 ; i < 2 ; i++ ) {
-		    double nx_over_ny = Exy / (Exx-EV[i]);
-		    double nx_unnormalized = nx_over_ny;
-		    double ny_unnormalized = 1.0;
-		    double norm = Math.sqrt(nx_unnormalized*nx_unnormalized + ny_unnormalized*ny_unnormalized);
-		    mm_PA[i][0] = ny_unnormalized/norm;
-		    mm_PA[i][1] = nx_unnormalized/norm;
-		    mm_PA[i][2] = 0.0;
-		}
-		// ... and now set third eigenvector to the z direction:
-		mm_PA[2][0] = 0.0;
-		mm_PA[2][1] = 0.0;
-		mm_PA[2][2] = 1.0;
-	    } else if (Exz == 0.0 && Exy == 0.0) {
-		// Another pathological case
-		EV[0] = 0.5*(Eyy+Ezz) + 0.5*Math.sqrt((Eyy+Ezz)*(Eyy+Ezz) + 4.0*Eyz*Eyz);
-		EV[1] = 0.5*(Eyy+Ezz) - 0.5*Math.sqrt((Eyy+Ezz)*(Eyy+Ezz) + 4.0*Eyz*Eyz);
-		EV[2] = 0.0;
-		for( int i = 0 ; i < 2 ; i++ ) {
-		    double ny_over_nz = Eyz / (Eyy-EV[i]);
-		    double ny_unnormalized = ny_over_nz;
-		    double nz_unnormalized = 1.0;
-		    double norm = Math.sqrt(ny_unnormalized*ny_unnormalized + nz_unnormalized*nz_unnormalized);
-		    mm_PA[i][0] = nz_unnormalized/norm;
-		    mm_PA[i][1] = ny_unnormalized/norm;
-		    mm_PA[i][2] = 0.0;
-		}
-		mm_PA[2][0] = 0.0;
-		mm_PA[2][1] = 0.0;
-		mm_PA[2][2] = 1.0;
-	    } else {
-		for( int i = 0 ; i < 3 ; i++ )
-		    {
-			double[] C = new double[3];
-			C[0] = 1.0;
-			C[2] = (Exy*Exy + (Eyy - EV[i])*(EV[i] - Exx))/
-			    ((Eyy - EV[i])*Exz - Eyz*Exy);
-			C[1] = (EV[i] - Exx - Exz*C[2])/Exy;
-			if (Exy == 0.0) {
-			    // Recompute
-			    if (Eyz != 0.0) {
-				// ny = (Exz - (Ezz-EV)*nz)/Eyz
-				C[1] = (Exz - (Ezz-EV[i])*C[2])/Eyz;
-			    } else {
-				// ny = -(Eyz*nz)/(Eyy-EV)
-				C[1] = -(Eyz*C[2])/(Eyy-EV[i]);
-			    }
-			}
-			double norm = Math.sqrt(C[0]*C[0] + C[1]*C[1] + C[2]*C[2]);
-			mm_PA[i][0] = C[0]/norm;
-			mm_PA[i][1] = C[1]/norm;
-			mm_PA[i][2] = C[2]/norm;
-		    }
-	    }
+            // In the pathological case where Exz = Eyz = Ezz = 0:
+            //    (Exx - EV)nx + (Exy)ny = 0  =>  ny/nx = -(Exx-EV)/Exy
+            //    (Eyx)nx + (Eyy - EV)ny = 0  =>  ny/nx = -Eyx/(Eyy-EV)
+            //    (EV)nz = 0
+            // so
+            //     -ny/nx = (EV-Exx)/Exy = Eyx/(EV-Eyy)
+            // But watch out for order! Recalculate eigenvalues for this pathological case.
+            //     (EV-Exx)(EV-Eyy) = Eyx*Exy
+            //     EV^2 - EV(Exx+Eyy) + Exx*Eyy - Eyx*Exy = 0
+            // 
+            // In another pathological case, Exz = Exy = 0:
+            //    (Exx - EV)nx = 0
+            //    (Eyy - EV)ny + (Eyz)nz = 0 => ny/nz = -(Eyz)/(Eyy-EV)
+            //    (Ezy)ny + (Ezz - EV)nz = 0 => ny/nz = -(Ezz-EV)/(Ezy)
+            // so we cannot set nx = 1. Instead, write:
+            //    -ny/nz = (Eyz)/(Eyy-EV) = (Ezz-EV)/(Ezy)
+            // Then
+            //    (Eyz)(Ezy) = (Eyy-EV)(Ezz-EV)
+            //    (Eyz)^2 = (Eyy)(Ezz) - (Eyy)(EV) - (Ezz)(EV) + (EV)^2
+            //    EV^2 - EV(Eyy+Ezz) + Eyy*Ezz - Eyz*Eyz = 0
+            // Handle pathological case
+            if (Exz == 0.0 && Eyz == 0.0) {
+                // Recompute eigenvectors.
+                EV[0] = 0.5 * (Exx + Eyy) + 0.5 * Math.sqrt((Exx + Eyy) * (Exx + Eyy) + 4.0 * Exy * Exy);
+                EV[1] = 0.5 * (Exx + Eyy) - 0.5 * Math.sqrt((Exx + Eyy) * (Exx + Eyy) + 4.0 * Exy * Exy);
+                EV[2] = 0.0;
+                for (int i = 0; i < 2; i++) {
+                    double nx_over_ny = Exy / (Exx - EV[i]);
+                    double nx_unnormalized = nx_over_ny;
+                    double ny_unnormalized = 1.0;
+                    double norm = Math.sqrt(nx_unnormalized * nx_unnormalized + ny_unnormalized * ny_unnormalized);
+                    mm_PA[i][0] = ny_unnormalized / norm;
+                    mm_PA[i][1] = nx_unnormalized / norm;
+                    mm_PA[i][2] = 0.0;
+                }
+                // ... and now set third eigenvector to the z direction:
+                mm_PA[2][0] = 0.0;
+                mm_PA[2][1] = 0.0;
+                mm_PA[2][2] = 1.0;
+            } else if (Exz == 0.0 && Exy == 0.0) {
+                // Another pathological case
+                EV[0] = 0.5 * (Eyy + Ezz) + 0.5 * Math.sqrt((Eyy + Ezz) * (Eyy + Ezz) + 4.0 * Eyz * Eyz);
+                EV[1] = 0.5 * (Eyy + Ezz) - 0.5 * Math.sqrt((Eyy + Ezz) * (Eyy + Ezz) + 4.0 * Eyz * Eyz);
+                EV[2] = 0.0;
+                for (int i = 0; i < 2; i++) {
+                    double ny_over_nz = Eyz / (Eyy - EV[i]);
+                    double ny_unnormalized = ny_over_nz;
+                    double nz_unnormalized = 1.0;
+                    double norm = Math.sqrt(ny_unnormalized * ny_unnormalized + nz_unnormalized * nz_unnormalized);
+                    mm_PA[i][0] = nz_unnormalized / norm;
+                    mm_PA[i][1] = ny_unnormalized / norm;
+                    mm_PA[i][2] = 0.0;
+                }
+                mm_PA[2][0] = 0.0;
+                mm_PA[2][1] = 0.0;
+                mm_PA[2][2] = 1.0;
+            } else {
+                for (int i = 0; i < 3; i++) {
+                    double[] C = new double[3];
+                    C[0] = 1.0;
+                    C[2] = (Exy * Exy + (Eyy - EV[i]) * (EV[i] - Exx))
+                            / ((Eyy - EV[i]) * Exz - Eyz * Exy);
+                    C[1] = (EV[i] - Exx - Exz * C[2]) / Exy;
+                    if (Exy == 0.0) {
+                        // Recompute
+                        if (Eyz != 0.0) {
+                            // ny = (Exz - (Ezz-EV)*nz)/Eyz
+                            C[1] = (Exz - (Ezz - EV[i]) * C[2]) / Eyz;
+                        } else {
+                            // ny = -(Eyz*nz)/(Eyy-EV)
+                            C[1] = -(Eyz * C[2]) / (Eyy - EV[i]);
+                        }
+                    }
+                    double norm = Math.sqrt(C[0] * C[0] + C[1] * C[1] + C[2] * C[2]);
+                    mm_PA[i][0] = C[0] / norm;
+                    mm_PA[i][1] = C[1] / norm;
+                    mm_PA[i][2] = C[2] / norm;
+                }
+            }
         }
         mm_NE[0] = NE1;
         mm_NE[1] = NE2;
@@ -443,40 +400,34 @@
         mm_CE[0] = CEx;
         mm_CE[1] = CEy;
         mm_CE[2] = CEz;
-        for(int i=0;i<6;i++)
-        {
+        for (int i = 0; i < 6; i++) {
             positionErrorLocal[i] = 0.;
             directionErrorLocal[i] = 0.;
             shapeParametersLocal[i] = 0.;
         }
-        for(int i=0;i<3;i++)
-        {
+        for (int i = 0; i < 3; i++) {
             positionLocal[i] = mm_CE[i];
             shapeParametersLocal[i] = mm_NE[i];
         }
-        if(nhits > 3)
-        {
-            double dr = Math.sqrt(  (position[0]+mm_PA[0][0])*(position[0]+mm_PA[0][0]) +
-                    (position[1]+mm_PA[0][1])*(position[1]+mm_PA[0][1]) +
-                    (position[2]+mm_PA[0][2])*(position[2]+mm_PA[0][2]) ) -
-                    Math.sqrt(	(position[0])*(position[0]) +
-                    (position[1])*(position[1]) +
-                    (position[2])*(position[2]) ) ;
+        if (nhits > 3) {
+            double dr = Math.sqrt((position[0] + mm_PA[0][0]) * (position[0] + mm_PA[0][0])
+                    + (position[1] + mm_PA[0][1]) * (position[1] + mm_PA[0][1])
+                    + (position[2] + mm_PA[0][2]) * (position[2] + mm_PA[0][2]))
+                    - Math.sqrt((position[0]) * (position[0])
+                            + (position[1]) * (position[1])
+                            + (position[2]) * (position[2]));
             double sign = 1.;
-            if(dr < 0.)sign = -1.;
-            itheta = Math.acos(sign*mm_PA[0][2]);
-            iphi = Math.atan2(sign*mm_PA[0][1],sign*mm_PA[0][0]);
-        }
-        else
-        {
+            if (dr < 0.) {
+                sign = -1.;
+            }
+            itheta = Math.acos(sign * mm_PA[0][2]);
+            iphi = Math.atan2(sign * mm_PA[0][1], sign * mm_PA[0][0]);
+        } else {
             itheta = 999.;
             iphi = 999.;
         }
-    
+
         return positionLocal;
     }
-    
-    
-    
-    
+
 }

java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
ECalEvioReader.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/ECalEvioReader.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/ECalEvioReader.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -4,15 +4,12 @@
 import java.util.List;
 
 import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
-import org.hps.conditions.ConditionsDriver;
 import org.hps.conditions.DatabaseConditionsManager;
 import org.hps.conditions.TableConstants;
 import org.hps.conditions.ecal.EcalChannel;
 import org.hps.conditions.ecal.EcalChannel.DaqId;
 import org.hps.conditions.ecal.EcalChannel.GeometryId;
-import org.hps.conditions.ecal.EcalChannelConstants;
 import org.hps.conditions.ecal.EcalConditions;
-import org.hps.conditions.ecal.EcalConditionsUtil;
 import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.detector.identifier.Identifier;
@@ -27,7 +24,6 @@
 import org.lcsim.event.SimTrackerHit;
 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.lcio.LCIOConstants;
 
@@ -41,32 +37,31 @@
 
     private int bankTag = EventConstants.ECAL_PULSE_INTEGRAL_BANK_TAG;
     private Class hitClass = BaseRawCalorimeterHit.class;
-    
+
     // FIXME: Hard-coded detector names.
-    private static String readoutName = "EcalHits";
-    private static String subdetectorName = "Ecal";
-    Detector detector;
-    Subdetector subDetector;
-    
-    static EcalConditions ecalConditions = null;
-    static IIdentifierHelper helper = null;
-    static EcalChannelCollection channels = null; 
+    private static final String readoutName = "EcalHits";
+    private static final String subdetectorName = "Ecal";
+//    private Detector detector;
+    private final Subdetector subDetector;
 
+    private static EcalConditions ecalConditions = null;
+    private static IIdentifierHelper helper = null;
+    private static EcalChannelCollection channels = null;
+
     public ECalEvioReader() {
         hitCollectionName = "EcalReadoutHits";
-        
-        detector = DatabaseConditionsManager.getInstance().getDetectorObject();
-        subDetector = detector.getSubdetector(subdetectorName);
-        
+
+        subDetector =  DatabaseConditionsManager.getInstance().getDetectorObject().getSubdetector(subdetectorName);
+
         // ECAL combined conditions object.
         ecalConditions = ConditionsManager.defaultInstance()
                 .getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
-        
+
         // List of channels.
         channels = ecalConditions.getChannelCollection();
-        
+
         helper = subDetector.getDetectorElement().getIdentifierHelper();
-        
+
         System.out.println("You are now using the database conditions for ECalEvioReader.java");
         // ID helper.
 //        helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
@@ -167,42 +162,43 @@
                     System.out.println("  channel=" + channel + "; nSamples=" + nSamples);
                 }
 
-                
-                 long id = daqToGeometryId(crate, slot, channel);
+                Long id = daqToGeometryId(crate, slot, channel);
 //                Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
 
-                 System.out.println("The long id is: " + id);
-                 
+                System.out.println("The long id is: " + id);
+
                 short[] adcValues = new short[nSamples];
                 for (int i = 0; i < nSamples; i++) {
                     adcValues[i] = cdata.getShort();
                 }
-//                if (id == null) {
-//                    System.out.printf("Crate %d, slot %d, channel %d not found in map\n", crate, slot, channel);
-//                } else {
+                if (id == null) {
+                    System.out.printf("Crate %d, slot %d, channel %d not found in map\n", crate, slot, channel);
+                } else {
                     hits.add(new BaseRawTrackerHit(
-                    		0, 
-                    		id, 
-                    		adcValues, 
-                    		new ArrayList<SimTrackerHit>(), 
-                    		subDetector
-                    		    .getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
-//                }
+                            0,
+                            id,
+                            adcValues,
+                            new ArrayList<SimTrackerHit>(),
+                            subDetector
+                            .getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
+                }
             }
         }
         return hits;
     }
 
-	private long daqToGeometryId(int crate, short slot, short channel) {
-		DaqId daqId = new DaqId(new int[]{crate,slot,channel});
-		 EcalChannel ecalChannel = channels.findChannel(daqId);
-		 if(ecalChannel == null) throw new RuntimeException("Daq Id not found.");
-		 int ix = ecalChannel.getX();
-		 int iy = ecalChannel.getY();
-		 GeometryId geometryId = new GeometryId(helper, new int[]{subDetector.getSystemID(),ix,iy});
-		 long id = geometryId.encode();
-		return id;
-	}
+    private Long daqToGeometryId(int crate, short slot, short channel) {
+        DaqId daqId = new DaqId(new int[]{crate, slot, channel});
+        EcalChannel ecalChannel = channels.findChannel(daqId);
+        if (ecalChannel == null) {
+            return null;
+        }
+        int ix = ecalChannel.getX();
+        int iy = ecalChannel.getY();
+        GeometryId geometryId = new GeometryId(helper, new int[]{subDetector.getSystemID(), ix, iy});
+        Long id = geometryId.encode();
+        return id;
+    }
 
     private List<BaseRawTrackerHit> makePulseHits(CompositeData cdata, int crate) {
         List<BaseRawTrackerHit> hits = new ArrayList<BaseRawTrackerHit>();

java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
TestRunEvioToLcio.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunEvioToLcio.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunEvioToLcio.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -20,6 +20,7 @@
 import org.jlab.coda.jevio.EvioReader;
 import org.lcsim.event.EventHeader;
 import org.hps.util.RunControlDialog;
+import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.job.JobControlManager;
 import org.lcsim.lcio.LCIOWriter;
 
@@ -100,7 +101,6 @@
         //if (cl.hasOption("e")) {
         //    System.out.println("Option -e is deprecated; EVIO file name is now a non-option argument");
         //}
-
         // LCIO output file.
         if (cl.hasOption("l")) {
             lcioFileName = cl.getOptionValue("l");
@@ -177,6 +177,8 @@
             }
         }
 
+        new org.hps.conditions.config.TestRunReadOnlyConfiguration(false).setup().load(detectorName, 0);
+
         jobManager.setup(steeringStream);
         jobManager.configure();
 
@@ -306,4 +308,4 @@
             System.out.println("closed writer");
         }
     }
-}
\ No newline at end of file
+}

java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
TestRunTriggeredReconToEvio.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -9,7 +9,6 @@
 import org.hps.conditions.deprecated.CalibrationDriver;
 import org.hps.conditions.ecal.EcalConditions;
 import org.hps.readout.ecal.ReadoutTimestamp;
-import org.hps.readout.ecal.TriggerDriver;
 import org.hps.readout.ecal.TriggerableDriver;
 import org.jlab.coda.jevio.DataType;
 import org.jlab.coda.jevio.EventBuilder;
@@ -18,7 +17,6 @@
 import org.jlab.coda.jevio.EvioException;
 import org.lcsim.event.EventHeader;
 import org.lcsim.geometry.Detector;
-import org.lcsim.util.Driver;
 
 /**
  * This class takes raw data generated from MC and converts it to EVIO. The goal

java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio
TestRunTriggeredReconToLcio.java 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java	2014-09-30 19:49:00 UTC (rev 1114)
@@ -11,7 +11,6 @@
 import org.hps.conditions.deprecated.QuietBaseLCSimEvent;
 import org.hps.readout.ecal.ClockSingleton;
 import org.hps.readout.ecal.ReadoutTimestamp;
-import org.hps.readout.ecal.TriggerDriver;
 import org.hps.readout.ecal.TriggerableDriver;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.LCRelation;
@@ -20,7 +19,6 @@
 import org.lcsim.event.SimTrackerHit;
 import org.lcsim.geometry.Detector;
 import org.lcsim.lcio.LCIOWriter;
-import org.lcsim.util.Driver;
 
 /**
  * This class takes raw data generated from MC and converts it to EVIO. The goal
@@ -59,7 +57,7 @@
     List<SimTrackerHit> triggerECalScoringPlaneHits = null;
     static final String ecalCollectionName = "EcalHits";
     static final String trackerCollectionName = "TrackerHits";
-    private String relationCollectionName = "SVTTrueHitRelations";
+    private final String relationCollectionName = "SVTTrueHitRelations";
     String ecalScoringPlaneHitsCollectionName = "TrackerHitsECal";
     Detector detector = null;
 

java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/recon
TestRunOfflineRecon.lcsim 1113 -> 1114
--- java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/recon/TestRunOfflineRecon.lcsim	2014-09-30 16:25:14 UTC (rev 1113)
+++ java/branches/hps_java_trunk_HPSJAVA-255/steering-files/src/main/resources/org/hps/steering/recon/TestRunOfflineRecon.lcsim	2014-09-30 19:49:00 UTC (rev 1114)
@@ -7,6 +7,9 @@
        xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
     <execute>
         <driver name="EventMarkerDriver"/>
+
+        <driver name="ConditionsDriver"/>   
+
         <driver name="CalibrationDriver"/>
         <driver name="RawTrackerHitSensorSetup"/>
         <driver name="BadChannelFilter" />
@@ -25,6 +28,9 @@
         <driver name="CalibrationDriver" type="org.hps.conditions.deprecated.CalibrationDriver">
             <runNumber>${runNumber}</runNumber>
         </driver>   
+        <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver">
+            <loadSvtConditions>false</loadSvtConditions>
+        </driver>
         <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
             <eventInterval>1000</eventInterval>
         </driver>        
SVNspam 0.1