Print

Print


Commit in java/branches/hps_java_trunk_HPSJAVA-251 on MAIN
ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java+10-91011 -> 1012
                                                   /FADCTriggerDriver.java+20-201011 -> 1012
                                                   /SimpleEcalReadoutDriver.java+13-11011 -> 1012
                                                   /TimeEvolutionEcalReadoutDriver.java+11-11011 -> 1012
                                                   /TriggerData.java-1111011 removed
evio/src/main/java/org/hps/evio/ECalEvioReader.java+74-121011 -> 1012
                               /ECalHitWriter.java+106-171011 -> 1012
                               /TestRunReconToEvio.java+131011 -> 1012
                               /TestRunTriggeredReconToEvio.java+17-11011 -> 1012
                               /TestRunTriggeredReconToLcio.java+91011 -> 1012
+273-172
1 removed + 9 modified, total 10 files
Another attempt at merging branched modules.

java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal
FADCEcalReadoutDriver.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -241,7 +241,7 @@
 
             FADCPipeline pipeline = pipelineMap.get(cellID);
             pipeline.step();
-           
+            
             // Get the channel data.
             EcalChannelConstants channelData = findChannel(cellID);
 
@@ -300,7 +300,7 @@
         }
         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");
+                System.out.println(this.getName() + ": Stale hit in output queue");
                 outputQueue.poll();
             } else {
                 buffer.add(outputQueue.poll());
@@ -515,7 +515,8 @@
 
     private double pulseAmplitude(double time, long cellID) {
     	
-    	EcalChannelConstants channelData = findChannel(cellID);
+        // Get the channel data.
+        EcalChannelConstants channelData = findChannel(cellID);
     	
         if (use2014Gain) {
             //if fixedGain is set, multiply the default gain by this factor
@@ -625,7 +626,11 @@
         }
     }
     
-    // Convert physical ID to gain value.
+    /** 
+     * Convert physical ID to gain value.
+     * @param cellID (long)
+     * @return channel constants (EcalChannelConstants)
+     */
     private EcalChannelConstants findChannel(long cellID) {
         // Make an ID object from raw hit ID.
         IIdentifier id = new Identifier(cellID);
@@ -637,13 +642,9 @@
         
         // Create an ID to search for in channel collection.
         GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
-        
-        // Find the ECAL channel.
-//        return channels.findChannel(geometryId);
                 
         // Get the channel data.
-        return ecalConditions.getChannelConstants(channels.findChannel(geometryId));
+        return ecalConditions.getChannelConstants(channels.findChannel(geometryId));    
     }
-    
 }
 

java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal
FADCTriggerDriver.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCTriggerDriver.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCTriggerDriver.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -134,16 +134,6 @@
     }
 
     /**
-     * Set X coordinate used as the origin for cluster coplanarity and distance
-     * calculations. Defaults to the ECal midplane. Units of mm.
-     *
-     * @param originX
-     */
-    public void setOriginX(double originX) {
-        this.originX = originX;
-    }
-
-    /**
      * Used for plot ranges and cuts that scale with energy. 1.1, 2.2 and 6.6
      * are associated with default cuts. Units of GeV.
      *
@@ -154,15 +144,6 @@
     }
 
     /**
-     * Use default cuts based on beam energy.
-     *
-     * @param useDefaultCuts
-     */
-    public void setUseDefaultCuts(boolean useDefaultCuts) {
-        this.useDefaultCuts = useDefaultCuts;
-    }
-
-    /**
      * Minimum hit count for a cluster.
      *
      * @param minHitCount
@@ -243,6 +224,25 @@
         }
     }
 
+    /**
+     * Set X coordinate used as the origin for cluster coplanarity and distance
+     * calculations. Defaults to the ECal midplane.
+     *
+     * @param originX
+     */
+    public void setOriginX(double originX) {
+        this.originX = originX;
+    }
+
+    /**
+     * Use default cuts based on beam energy.
+     *
+     * @param useDefaultCuts
+     */
+    public void setUseDefaultCuts(boolean useDefaultCuts) {
+        this.useDefaultCuts = useDefaultCuts;
+    }
+
     @Override
     public void detectorChanged(Detector detector) {
         if (beamEnergy < 0) {
@@ -675,4 +675,4 @@
     protected double getClusterDistance(HPSEcalCluster cluster) {
         return Math.hypot(cluster.getSeedHit().getPosition()[0] - originX, cluster.getSeedHit().getPosition()[1]);
     }
-}
\ No newline at end of file
+}

java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal
SimpleEcalReadoutDriver.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SimpleEcalReadoutDriver.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/SimpleEcalReadoutDriver.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -6,6 +6,7 @@
 
 import org.hps.recon.ecal.HPSCalorimeterHit;
 import org.lcsim.event.CalorimeterHit;
+import org.lcsim.geometry.Detector;
 
 /**
  * Performs readout of ECal hits.
@@ -17,12 +18,21 @@
 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;
 	}
 
     @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");
@@ -32,7 +42,9 @@
 //            if (iy == 1 && ix*side >= -10 && ix*side <= -2)
 //                continue;
             if (eDepMap.get(cellID) > threshold)
-                hits.add(new HPSCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType));
+            	h = new HPSCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType); 
+                h.setDetector(detector);
+                hits.add(h);
         }
         //reset hit integration
         eDepMap = new HashMap<Long, Double>();

java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal
TimeEvolutionEcalReadoutDriver.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TimeEvolutionEcalReadoutDriver.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -6,6 +6,7 @@
 
 import org.hps.recon.ecal.HPSCalorimeterHit;
 import org.lcsim.event.CalorimeterHit;
+import org.lcsim.geometry.Detector;
 
 /**
  * Performs readout of ECal hits.
@@ -16,12 +17,19 @@
  */
 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)
     int bufferLength = 20;
     //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;
@@ -45,7 +53,9 @@
 //                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));
+            	HPSCalorimeterHit h = new HPSCalorimeterHit(eDepBuffer.currentValue(), readoutTime(), cellID, hitType);
+            	h.setDetector(detector);
+            	hits.add(h);
             }
             eDepBuffer.step();
         }

java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal
TriggerData.java removed after 1011
--- java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/ecal-readout-sim/src/main/java/org/hps/readout/ecal/TriggerData.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -1,111 +0,0 @@
-package org.hps.readout.ecal;
-
-import org.lcsim.event.GenericObject;
-
-/**
- *
- * @author Sho Uemura <[log in to unmask]>
- * @version $Id: TriggerData.java,v 1.3 2012/08/03 23:14:39 meeg Exp $
- */
-public class TriggerData implements GenericObject {
-
-    public static final int OR_TRIG = 3;
-    public static final int TOP_TRIG = 4;
-    public static final int BOT_TRIG = 5;
-    public static final int AND_TRIG = 6;
-    public static final int TIME = 7;
-    public static final int TRIG_BANK_SIZE = 8;
-    public static final String TRIG_COLLECTION = "TriggerBank";
-    private int[] bank;
-
-    public TriggerData(int[] bank) {
-        this.bank = bank;
-    }
-
-    public int getTime() {
-        return getIntVal(TIME);
-    }
-
-    public int getOrTrig() {
-        return getIntVal(OR_TRIG);
-    }
-
-    public int getTopTrig() {
-        return getIntVal(TOP_TRIG);
-    }
-
-    public int getBotTrig() {
-        return getIntVal(BOT_TRIG);
-    }
-
-    public int getAndTrig() {
-        return getIntVal(AND_TRIG);
-    }
-
-    public int[] getBank() {
-        return bank;
-    }
-
-    public static int getTime(GenericObject object) {
-        return object.getIntVal(TIME);
-    }
-
-    public static int getOrTrig(GenericObject object) {
-        return object.getIntVal(OR_TRIG);
-    }
-
-    public static int getTopTrig(GenericObject object) {
-        return object.getIntVal(TOP_TRIG);
-    }
-
-    public static int getBotTrig(GenericObject object) {
-        return object.getIntVal(BOT_TRIG);
-    }
-
-    public static int getAndTrig(GenericObject object) {
-        return object.getIntVal(AND_TRIG);
-    }
-
-    public static int[] getBank(GenericObject object) {
-        int[] bank = new int[8];
-        for (int i = 0; i < 8; i++) {
-            bank[i] = object.getIntVal(i);
-        }
-        return bank;
-    }
-
-    @Override
-    public int getNInt() {
-        return TRIG_BANK_SIZE;
-    }
-
-    @Override
-    public int getNFloat() {
-        return 0;
-    }
-
-    @Override
-    public int getNDouble() {
-        return 0;
-    }
-
-    @Override
-    public int getIntVal(int index) {
-        return bank[index];
-    }
-
-    @Override
-    public float getFloatVal(int index) {
-        throw new UnsupportedOperationException("No float values in " + this.getClass().getSimpleName());
-    }
-
-    @Override
-    public double getDoubleVal(int index) {
-        throw new UnsupportedOperationException("No double values in " + this.getClass().getSimpleName());
-    }
-
-    @Override
-    public boolean isFixedSize() {
-        return true;
-    }
-}

java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio
ECalEvioReader.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/ECalEvioReader.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/ECalEvioReader.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -3,18 +3,32 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hps.conditions.deprecated.EcalConditions;
+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;
+//import org.hps.conditions.deprecated.EcalConditions;
 import org.jlab.coda.jevio.BaseStructure;
 import org.jlab.coda.jevio.BaseStructureHeader;
 import org.jlab.coda.jevio.CompositeData;
 import org.jlab.coda.jevio.EvioEvent;
 import org.jlab.coda.jevio.EvioException;
-import org.lcsim.detector.identifier.Identifier;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.RawTrackerHit;
 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;
 
 /**
@@ -27,9 +41,35 @@
 
     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; 
 
     public ECalEvioReader() {
         hitCollectionName = "EcalReadoutHits";
+        
+        detector = DatabaseConditionsManager.getInstance().getDetectorObject();
+        subDetector = detector.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();
     }
 
     @Override
@@ -91,7 +131,7 @@
                 }
             }
         }
-        String readoutName = EcalConditions.getSubdetector().getReadout().getName();
+//        String readoutName = ;
         lcsimEvent.put(hitCollectionName, hits, hitClass, flags, readoutName);
 //        for (Object hit : hits) {
 //            System.out.println(((RawTrackerHit) hit).getIDDecoder().getIDDescription().toString());
@@ -126,22 +166,44 @@
                 if (debug) {
                     System.out.println("  channel=" + channel + "; nSamples=" + nSamples);
                 }
-                Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
 
+                
+                 long id = daqToGeometryId(crate, slot, channel);
+//                Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
+
+                 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 {
-                    hits.add(new BaseRawTrackerHit(0, id, adcValues, new ArrayList<SimTrackerHit>(), EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
-                }
+//                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)));
+//                }
             }
         }
         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 List<BaseRawTrackerHit> makePulseHits(CompositeData cdata, int crate) {
         List<BaseRawTrackerHit> hits = new ArrayList<BaseRawTrackerHit>();
         if (debug) {
@@ -168,7 +230,7 @@
                 if (debug) {
                     System.out.println("  channel=" + channel + "; npulses=" + npulses);
                 }
-                Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
+                Long id = daqToGeometryId(crate, slot, channel);
                 for (int k = 0; k < npulses; k++) {
                     short pulseNum = cdata.getByte();
                     int sampleCount = cdata.getNValue();
@@ -179,7 +241,7 @@
                     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(pulseNum, id, adcValues, new ArrayList<SimTrackerHit>(), EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
+                        hits.add(new BaseRawTrackerHit(pulseNum, id, adcValues, new ArrayList<SimTrackerHit>(), subDetector.getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
                     }
                 }
             }
@@ -213,7 +275,7 @@
                 if (debug) {
                     System.out.println("  channel=" + channel + "; npulses=" + npulses);
                 }
-                Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
+                Long id = daqToGeometryId(crate, slot, channel);
 
                 for (int k = 0; k < npulses; k++) {
                     short pulseTime = cdata.getShort();

java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio
ECalHitWriter.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/ECalHitWriter.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/ECalHitWriter.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -5,17 +5,30 @@
 import java.util.List;
 import java.util.Map;
 
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.DatabaseConditionsManager;
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+//import org.hps.conditions.deprecated.EcalConditions;
 import org.jlab.coda.jevio.BaseStructure;
 import org.jlab.coda.jevio.CompositeData;
 import org.jlab.coda.jevio.DataType;
 import org.jlab.coda.jevio.EventBuilder;
 import org.jlab.coda.jevio.EvioBank;
 import org.jlab.coda.jevio.EvioException;
+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.lcsim.event.EventHeader;
 import org.lcsim.event.RawCalorimeterHit;
 import org.lcsim.event.RawTrackerHit;
+import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
 import org.lcsim.lcio.LCIOConstants;
 
 import static org.hps.evio.EventConstants.*;
@@ -30,8 +43,38 @@
     private String hitCollectionName = "EcalReadoutHits";
     private int mode = EventConstants.ECAL_PULSE_INTEGRAL_MODE;
 
-    public ECalHitWriter() {
+    // FIXME: Hard-coded detector names.
+    private static String subdetectorName = "Ecal";
+    Detector detector = null;
+    public Subdetector subDetector;
+    
+    static EcalConditions ecalConditions = null;
+    static IIdentifierHelper helper = null;
+    static EcalChannelCollection channels = null;     
+    
+    public ECalHitWriter() { 	
     }
+    
+    /** 
+     * Must be set when an object EcalHitWriter is created.
+     * @param detector (long)
+     */   
+    void setDetector(Detector detector) {
+    	
+        this.detector = detector;
+        subDetector = detector.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 ECalHitWriter.java");   
+    }
 
     public void setHitCollectionName(String hitCollectionName) {
         this.hitCollectionName = hitCollectionName;
@@ -86,8 +129,8 @@
         List<Object> topHits = new ArrayList<Object>();
         List<Object> bottomHits = new ArrayList<Object>();
         for (Object hit : rawCalorimeterHits) {
-            Long daqID = EcalConditions.physicalToDaqID(getCellID(hit));
-            int crate = EcalConditions.getCrate(daqID);
+//            Long daqID = EcalConditions.physicalToDaqID(getCellID(hit));
+            int crate = getCrate(getCellID(hit));
             if (crate == ECAL_BOTTOM_BANK_TAG) {
                 bottomHits.add(hit);
             } else {
@@ -150,6 +193,7 @@
 
     private long getCellID(Object hit) {
         if (RawCalorimeterHit.class.isInstance(hit)) {
+        	System.out.println("hit.getCellID() " + ((RawCalorimeterHit) hit).getCellID());
             return ((RawCalorimeterHit) hit).getCellID();
         } else if (RawTrackerHit.class.isInstance(hit)) {
             return ((RawTrackerHit) hit).getCellID();
@@ -163,7 +207,7 @@
         }
 
         // Get the ID decoder.
-        IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
+        IDDecoder dec = subDetector.getIDDecoder();
 
         // Make a hit map; allow for multiple hits in a crystal.
         Map<Long, List<RawCalorimeterHit>> hitMap = new HashMap<Long, List<RawCalorimeterHit>>();
@@ -182,9 +226,9 @@
             dec.setID(id);
 //			System.out.println(dec.getIDDescription());
 //			System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
-            Long daqID = EcalConditions.physicalToDaqID(id);
+//            Long daqID = EcalConditions.physicalToDaqID(id);
 //			System.out.printf("physicalID %d, daqID %d\n", id, daqID);
-            int slot = EcalConditions.getSlot(daqID);
+            int slot = getSlot(id);
             if (slotMap.get(slot) == null) {
                 slotMap.put(slot, new ArrayList<Long>());
             }
@@ -205,7 +249,7 @@
             data.addN(nhits); // number of channels
             for (Long id : hitIDs) {
                 dec.setID(id);
-                int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
+                int channel = getChannel(id);
                 data.addUchar((byte) channel); // channel #
                 List<RawCalorimeterHit> channelHits = hitMap.get(id);
                 data.addN(channelHits.size()); // number of pulses
@@ -236,7 +280,7 @@
         }
 
         // Get the ID decoder.
-        IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
+        IDDecoder dec = subDetector.getIDDecoder();
 
         // Make a hit map; allow for multiple hits in a crystal.
         Map<Long, List<RawTrackerHit>> hitMap = new HashMap<Long, List<RawTrackerHit>>();
@@ -255,9 +299,9 @@
             dec.setID(id);
 //			System.out.println(dec.getIDDescription());
 //			System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
-            Long daqID = EcalConditions.physicalToDaqID(id);
+//            Long daqID = EcalConditions.physicalToDaqID(id);
 //			System.out.printf("physicalID %d, daqID %d\n", id, daqID);
-            int slot = EcalConditions.getSlot(daqID);
+            int slot = getSlot(id);
             if (slotMap.get(slot) == null) {
                 slotMap.put(slot, new ArrayList<Long>());
             }
@@ -278,7 +322,7 @@
             data.addN(nhits); // number of channels
             for (Long id : hitIDs) {
                 dec.setID(id);
-                int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
+                int channel = getChannel(id);
                 data.addUchar((byte) channel); // channel #
                 List<RawTrackerHit> channelHits = hitMap.get(id);
                 data.addN(channelHits.size()); // number of pulses
@@ -313,7 +357,7 @@
         }
 
         // Get the ID decoder.
-        IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
+        IDDecoder dec = subDetector.getIDDecoder();
 
         // Make a hit map; allow for multiple hits in a crystal.
         Map<Long, RawTrackerHit> hitMap = new HashMap<Long, RawTrackerHit>();
@@ -328,9 +372,9 @@
             dec.setID(id);
 //			System.out.println(dec.getIDDescription());
 //			System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
-            Long daqID = EcalConditions.physicalToDaqID(id);
+//            Long daqID = EcalConditions.physicalToDaqID(id);
 //			System.out.printf("physicalID %d, daqID %d\n", id, daqID);
-            int slot = EcalConditions.getSlot(daqID);
+            int slot = getSlot(id);
             if (slotMap.get(slot) == null) {
                 slotMap.put(slot, new ArrayList<Long>());
             }
@@ -355,7 +399,7 @@
             data.addN(nhits); // number of channels
             for (Long id : hitIDs) {
                 dec.setID(id);
-                int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
+                int channel = getChannel(id);
                 data.addUchar((byte) channel); // channel #
                 RawTrackerHit hit = hitMap.get(id);
                 data.addN(hit.getADCValues().length); // number of samples
@@ -382,7 +426,7 @@
 
     @Override
     public void writeData(EventHeader event, EventHeader toEvent) {
-        String readoutName = EcalConditions.getSubdetector().getReadout().getName();
+        String readoutName = ((org.lcsim.geometry.compact.Subdetector) subDetector).getReadout().getName();   
         switch (mode) {
             case EventConstants.ECAL_WINDOW_MODE:
             case EventConstants.ECAL_PULSE_MODE:
@@ -401,4 +445,49 @@
                 break;
         }
     }
+    
+ 
+    
+    /**
+     * 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);         
+    }  
+    
+    private int getChannel(long cellID){
+      // Make an ID object from hit ID.
+      IIdentifier idd = new Identifier(cellID);
+    
+      // Get physical field values.
+      int system = helper.getValue(idd, "system");
+      int x = helper.getValue(idd, "ix");
+      int y = helper.getValue(idd, "iy");
+    
+      // Create an ID to search for in channel collection.
+      GeometryId geometryId = new GeometryId(helper, new int[] { system, x, y });
+            
+      // Get the channel data.
+      return channels.findChannel(geometryId).getChannelId(); 
+    
+    }
+    
 }

java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio
TestRunReconToEvio.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/TestRunReconToEvio.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/TestRunReconToEvio.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -2,12 +2,16 @@
 
 import java.io.IOException;
 
+import org.hps.conditions.TableConstants;
+import org.hps.conditions.ecal.EcalConditions;
 import org.jlab.coda.jevio.DataType;
 import org.jlab.coda.jevio.EventBuilder;
 import org.jlab.coda.jevio.EventWriter;
 import org.jlab.coda.jevio.EvioBank;
 import org.jlab.coda.jevio.EvioException;
+import org.lcsim.conditions.ConditionsManager;
 import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
 
 /**
@@ -26,9 +30,17 @@
 	private int eventsWritten = 0;
 	ECalHitWriter ecalWriter = null;
 	SVTHitWriter svtWriter = null;
+	
+	Detector detector = null;
 
 	public TestRunReconToEvio() {
 	}
+	
+    @Override
+    public void detectorChanged(Detector detector) {    	
+    	// set the detector
+        this.detector = detector;
+    }
 
 	public void setEvioOutputFile(String evioOutputFile) {
 		this.evioOutputFile = evioOutputFile;
@@ -49,6 +61,7 @@
 		}
 
 		ecalWriter = new ECalHitWriter();
+		ecalWriter.setDetector(detector);
 		ecalWriter.setHitCollectionName(rawCalorimeterHitCollectionName);
 
 		svtWriter = new SVTHitWriter();

java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio
TestRunTriggeredReconToEvio.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -5,8 +5,9 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
+import org.hps.conditions.DatabaseConditionsManager;
 import org.hps.conditions.deprecated.CalibrationDriver;
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.ecal.EcalConditions;
 import org.hps.readout.ecal.ReadoutTimestamp;
 import org.hps.readout.ecal.TriggerDriver;
 import org.hps.readout.ecal.TriggerableDriver;
@@ -16,6 +17,7 @@
 import org.jlab.coda.jevio.EvioBank;
 import org.jlab.coda.jevio.EvioException;
 import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
 import org.lcsim.util.Driver;
 
 /**
@@ -39,10 +41,19 @@
     TriggerDataWriter triggerWriter = null;
     List<HitWriter> writers = null;
     private int ecalMode = EventConstants.ECAL_PULSE_INTEGRAL_MODE;
+    
+    Detector detector;
 
     public TestRunTriggeredReconToEvio() {
         setTriggerDelay(0);
     }
+    
+    @Override
+    public void detectorChanged(Detector detector) {    	
+    	//ecalWriter.setDetector(detector);
+        if(detector == null) System.out.println("detectorChanged, Detector == null");
+        else System.out.println("detectorChanged, Detector != null");
+    }
 
     public void setEcalMode(int ecalMode) {
         this.ecalMode = ecalMode;
@@ -75,12 +86,17 @@
         }
 
         writePrestartEvent();
+        this.detector = DatabaseConditionsManager.getInstance().getDetectorObject();
 
         writers = new ArrayList<HitWriter>();
 
         ecalWriter = new ECalHitWriter();
+        if(detector == null) System.out.println("Detector == null");
+        else System.out.println("Detector != null");
+        //ecalWriter.setDetector(detector);
         ecalWriter.setMode(ecalMode);
         ecalWriter.setHitCollectionName(rawCalorimeterHitCollectionName);
+        ecalWriter.setDetector(detector);
         writers.add(ecalWriter);
 
         svtWriter = new SVTHitWriter();

java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio
TestRunTriggeredReconToLcio.java 1011 -> 1012
--- java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java	2014-09-12 02:32:40 UTC (rev 1011)
+++ java/branches/hps_java_trunk_HPSJAVA-251/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java	2014-09-12 03:11:00 UTC (rev 1012)
@@ -18,6 +18,7 @@
 import org.lcsim.event.MCParticle;
 import org.lcsim.event.SimCalorimeterHit;
 import org.lcsim.event.SimTrackerHit;
+import org.lcsim.geometry.Detector;
 import org.lcsim.lcio.LCIOWriter;
 import org.lcsim.util.Driver;
 
@@ -60,10 +61,17 @@
     static final String trackerCollectionName = "TrackerHits";
     private String relationCollectionName = "SVTTrueHitRelations";
     String ecalScoringPlaneHitsCollectionName = "TrackerHitsECal";
+    Detector detector = null;
 
     public TestRunTriggeredReconToLcio() {
         setTriggerDelay(0);
     }
+    
+    @Override
+    public void detectorChanged(Detector detector) {    	
+    	// set the detector
+        this.detector = detector;
+    }
 
     public void setEcalMode(int ecalMode) {
         this.ecalMode = ecalMode;
@@ -100,6 +108,7 @@
         writers = new ArrayList<HitWriter>();
 
         ecalWriter = new ECalHitWriter();
+        ecalWriter.setDetector(detector);
         ecalWriter.setMode(ecalMode);
         ecalWriter.setHitCollectionName(rawCalorimeterHitCollectionName);
         writers.add(ecalWriter);
SVNspam 0.1