Commit in lcsim on MAIN
src/org/lcsim/contrib/compile/SteveMagill/BTrMipClus.java+5-51.1 -> 1.2
src/org/lcsim/digisim/DigiSimMain.java+4-31.8 -> 1.9
                     /Digitizer.java+2-21.8 -> 1.9
                     /MyCalorimeterHit.java+11-501.2 -> 1.3
src/org/lcsim/event/CalorimeterHit.java+26-71.4 -> 1.5
                   /EventHeader.java+21.9 -> 1.10
src/org/lcsim/event/util/CalorimeterHitEsort.java+1-11.1 -> 1.2
src/org/lcsim/plugin/browser/CalorimeterHitTableModel.java+1-11.1 -> 1.2
src/org/lcsim/recon/cluster/fixedcone/FixedConeClusterer.java+3-31.6 -> 1.7
src/org/lcsim/recon/cluster/nn/NearestNeighborCluster.java+1-11.7 -> 1.8
src/org/lcsim/recon/cluster/util/BasicCluster.java+6-61.3 -> 1.4
                                /CalorimeterCluster.java+2-21.4 -> 1.5
                                /DefaultClusterPropertyCalculator.java+1-11.2 -> 1.3
                                /FixedConeClusterPropertyCalculator.java+2-21.1 -> 1.2
                                /HitsCluster.java+1-11.2 -> 1.3
                                /TensorClusterPropertyCalculator.java+1-11.3 -> 1.4
src/org/lcsim/util/event/BaseCalorimeterHit.java+64added 1.1
                        /SamplingFractionManager.java+50added 1.1
                        /SubdetectorLocator.java+26added 1.1
                        /BaseLCSimEvent.java+51.13 -> 1.14
src/org/lcsim/util/heprep/CalorimeterHitConverter.java+4-41.2 -> 1.3
                         /ClusterConverter.java+2-21.1 -> 1.2
src/org/lcsim/util/lcio/AbstractBlockHandler.java+2-21.4 -> 1.5
                       /SIOCalorimeterHit.java+19-451.3 -> 1.4
                       /SIOCalorimeterHitBlockHandler.java+5-31.1 -> 1.2
                       /SIOClusterBlockHandler.java+1-11.1 -> 1.2
                       /SIOLCRelationBlockHandler.java+2-21.1 -> 1.2
                       /SIOMCParticleBlockHandler.java+1-11.3 -> 1.4
                       /SIORawCalorimeterHitBlockHandler.java+2-21.1 -> 1.2
                       /SIOReconstructedParticleBlockHandler.java+1-11.1 -> 1.2
                       /SIOSimCalorimeterHit.java+114-1291.3 -> 1.4
                       /SIOSimCalorimeterHitBlockHandler.java+5-21.3 -> 1.4
                       /SIOSimTrackerHitBlockHandler.java+1-11.3 -> 1.4
                       /SIOTPCHitBlockHandler.java+1-11.1 -> 1.2
                       /SIOTrackBlockHandler.java+1-11.1 -> 1.2
                       /SIOTrackerHitBlockHandler.java+1-11.1 -> 1.2
test/org/lcsim/conditions/ConditionsManagerTest.java+1-11.6 -> 1.7
test/SamplingFractionTest.java+64added 1.1
+441-285
4 added + 34 modified, total 38 files
Change CalorimeterHit to allow hits from different collections to be mixed in clusters
Add support for sampling fraction calculations

lcsim/src/org/lcsim/contrib/compile/SteveMagill
BTrMipClus.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- BTrMipClus.java	23 Jul 2005 01:49:56 -0000	1.1
+++ BTrMipClus.java	2 Aug 2005 17:18:02 -0000	1.2
@@ -135,7 +135,7 @@
 //          {
 //              aida.cloud1D("DIAG : EM B Calib hit E").fill(embhit.getEnergy()/_sfEMB);     
 //          }
-          EMBESum += embhit.getEnergy();
+          EMBESum += embhit.getRawEnergy();
           nhitsEMB++;    
       }
       aida.cloud1D("Nhits in original EMBhitmap").fill(embhitmap.size());
@@ -160,7 +160,7 @@
 //              aida.cloud1D("DIAG : HAD B Vis hit E").fill(hadbhit.getEnergy());
 //              aida.cloud1D("DIAG : HAD B Calib hit E").fill(hadbhit.getEnergy()/_sfHB);
 //          }
-          HADBESum += hadbhit.getEnergy();
+          HADBESum += hadbhit.getRawEnergy();
           nhitsHADB++;
       }
       aida.cloud1D("Nhits in original HADBhitmap").fill(hadbhitmap.size());
@@ -623,9 +623,9 @@
           {
               CalorimeterHit ebhit = ebcluster.getCalorimeterHits().get(i);
               double[] ebhpos = ebhit.getPosition();
-              ebhX += ebhpos[0]*ebhit.getEnergy()/_sfEMB;
-              ebhY += ebhpos[1]*ebhit.getEnergy()/_sfEMB;
-              ebhZ += ebhpos[2]*ebhit.getEnergy()/_sfEMB;
+              ebhX += ebhpos[0]*ebhit.getRawEnergy()/_sfEMB;
+              ebhY += ebhpos[1]*ebhit.getRawEnergy()/_sfEMB;
+              ebhZ += ebhpos[2]*ebhit.getRawEnergy()/_sfEMB;
           }
           ebhX = ebhX/(ebcluster.getEnergy()/_sfEMB);
           ebhY = ebhY/(ebcluster.getEnergy()/_sfEMB);

lcsim/src/org/lcsim/digisim
DigiSimMain.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- DigiSimMain.java	26 Jul 2005 23:58:41 -0000	1.8
+++ DigiSimMain.java	2 Aug 2005 17:18:02 -0000	1.9
@@ -21,7 +21,7 @@
  * The main driver for standalone digitization simulation
  *
  * @author Guilherme Lima
- * @version $Id: DigiSimMain.java,v 1.8 2005/07/26 23:58:41 lima Exp $
+ * @version $Id: DigiSimMain.java,v 1.9 2005/08/02 17:18:02 tonyj Exp $
  */
 public class DigiSimMain extends Driver {
 
@@ -86,7 +86,7 @@
       for( LCRelation rel : raw2simLinks ) {
 	RawCalorimeterHit rawhit = (RawCalorimeterHit)rel.getFrom();
 	SimCalorimeterHit simhit = (SimCalorimeterHit)rel.getTo();
-	int simE = (int)(simhit.getEnergy()*100000000.0);
+	int simE = (int)(simhit.getRawEnergy()*100000000.0);
 	assert simE == rawhit.getAmplitude()
 	    : "Discrepancy on EcalBarr: simE=" + simE
 	    + ", rawE=" + rawhit.getAmplitude() ;
@@ -147,6 +147,7 @@
 
 	  // make sure sim,raw cells are good neighbors
 //       IDDecoder decoder = new IDDecoder();
+
 	  assert ((simid & 0x7f) == (rawid & 0x7f))
 	    : "link "+ilink+", layer discrepancy: "+ simid +" "+rawid;
 	  assert ((simid & 0x1f80) == (rawid & 0x1f80))
@@ -164,7 +165,7 @@
 	  assert ((delphi>=0) && (delphi<=2))
 	      : "link "+ilink+", phi discrepancy: "+ simid +" "+rawid;
 
-	  int simE = (int)(simhit.getEnergy()*1000000.0);
+	  int simE = (int)(simhit.getRawEnergy()*1000000.0);
 	  int rawE = (int)(rawhit.getAmplitude());
 	  System.out.println("X-check: simid="+Long.toHexString(simid)
 			     +", simE=" + simE

lcsim/src/org/lcsim/digisim
Digitizer.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- Digitizer.java	20 Jul 2005 21:04:31 -0000	1.8
+++ Digitizer.java	2 Aug 2005 17:18:02 -0000	1.9
@@ -23,7 +23,7 @@
  * simulation process for a specific subdetector.
  *
  * @author Guilherme Lima
- * @version $Id: Digitizer.java,v 1.8 2005/07/20 21:04:31 lima Exp $
+ * @version $Id: Digitizer.java,v 1.9 2005/08/02 17:18:02 tonyj Exp $
  */
 class Digitizer {
 
@@ -56,7 +56,7 @@
 
 	    // For now, use same input cell id for output cell id
 	    TempCalHit tmphit = new TempCalHit( simhit.getCellID(),
-						simhit.getEnergy(),
+						simhit.getRawEnergy(),
 						simhit.getContributedTime(0) );
 
 //     cout<<" tmphit:"<< std::hex ihit.getCellID0()<< std::dec

lcsim/src/org/lcsim/digisim
MyCalorimeterHit.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- MyCalorimeterHit.java	26 Jul 2005 23:59:46 -0000	1.2
+++ MyCalorimeterHit.java	2 Aug 2005 17:18:02 -0000	1.3
@@ -1,59 +1,20 @@
 package org.lcsim.digisim;
-
-import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.util.event.BaseCalorimeterHit;
 
 /**
  * Implements a calorimeter hit, to be created from unpacking DigiSim output.
  *
  * @author Guilherme Lima
- * @version $Id: MyCalorimeterHit.java,v 1.2 2005/07/26 23:59:46 lima Exp $
+ * @version $Id: MyCalorimeterHit.java,v 1.3 2005/08/02 17:18:02 tonyj Exp $
  */
-public class MyCalorimeterHit implements CalorimeterHit
+public class MyCalorimeterHit extends BaseCalorimeterHit
 {
-    /** Full constructor */
-    MyCalorimeterHit(RawCalorimeterHit rawhit) {
-	_cellid = rawhit.getCellID();
-	_energy = ((double)rawhit.getAmplitude())/100000000;
-	_timeStamp = (double)rawhit.getTimeStamp()/100000000;
-	_rawhit = rawhit;
-	_type = 0;
-    }
-
-    /** Channel ID for this raw hit */
-    public long getCellID() {
-	return _cellid;
-    }
-
-    /** Total energy in this raw hit */
-    public double getEnergy() {
-	return _energy;
-    }
-
-    /** Time stamp */
-    public double getTime() {
-	return _timeStamp;
-    }
-
-    public double[] getPosition() {
-	double[] pos = new double[3];
-	return pos;
-    }
-
-    public int getType() {
-	return _type;
-    }
-
-    //=== FIELDS ===
-
-    /** Cell ID */
-    private long _cellid;
-    /** Amplitude */
-    private double _energy;
-    /** Time stamp */
-    private double _timeStamp;
-    /** Reference to the corresponding raw hit */
-    private RawCalorimeterHit _rawhit;
-    /** Type of calorimeter hit */
-    private int _type;
-}
+   /** Full constructor */
+   MyCalorimeterHit(RawCalorimeterHit rawhit)
+   {
+      id = rawhit.getCellID();
+      rawEnergy = ((double)rawhit.getAmplitude())/100000000;
+      time = (double)rawhit.getTimeStamp()/1000000;
+   }
+}
\ No newline at end of file

lcsim/src/org/lcsim/event
CalorimeterHit.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- CalorimeterHit.java	15 Mar 2005 05:14:09 -0000	1.4
+++ CalorimeterHit.java	2 Aug 2005 17:18:03 -0000	1.5
@@ -1,29 +1,48 @@
 package org.lcsim.event;
 
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
+
 /**
- *
+ * A hit in a calorimeter. 
  * @author tonyj
+ * @version $Id: CalorimeterHit.java,v 1.5 2005/08/02 17:18:03 tonyj Exp $
  */
 public interface CalorimeterHit
 {
    /**
     * Raw energy deposited in Calorimeter Cell
     */
-   public double getEnergy();
+   public double getRawEnergy();
+   /**
+    * Corrected energy deposted in Calorimeter Cell.
+    */
+   public double getCorrectedEnergy();
    /**
     * The ID of the cell. This can be converted to a physical
     * position using a IDDecoder object obtained from the event
-    * meta-data.
+    * meta-data or from this hit.
     */
    public long getCellID();
    
+   /** 
+    * Get the ID decoder for this hit. Note that all hits in a collection are 
+    * gauranteed to share the same id decoder, but once hits have been combined
+    * into clusters each hit may have its own id decoder.
+    */
+   public IDDecoder getIDDecoder();
+   
+   /**
+    * The subdetector corresponding to this hit.
+    */
+   public Subdetector getSubdetector();
+   
    public double getTime();
 
    /**
-    * The position of the hit. Use of this method is not recommended, since
-    * it will only return a value if the hit position is stored in the source
-    * LCIO file. Better is to use the IDDecoder to get the hit position from
-    * the hit ID.
+    * The position of the hit. If the hit position is stored in the source
+    * LCIO file this will be returned. Otherwise the IDDecoder is used to get 
+    * the hit position from the hit ID.
     */
    public double[] getPosition();
 }

lcsim/src/org/lcsim/event
EventHeader.java 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- EventHeader.java	26 Jul 2005 14:44:33 -0000	1.9
+++ EventHeader.java	2 Aug 2005 17:18:03 -0000	1.10
@@ -107,5 +107,7 @@
       Map<String,int[]> getIntegerParameters();
       Map<String,float[]> getFloatParameters();
       Map<String,String[]> getStringParameters();
+      
+      EventHeader getEvent();
    }
 }
\ No newline at end of file

lcsim/src/org/lcsim/event/util
CalorimeterHitEsort.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- CalorimeterHitEsort.java	5 Mar 2005 07:34:34 -0000	1.1
+++ CalorimeterHitEsort.java	2 Aug 2005 17:18:03 -0000	1.2
@@ -10,7 +10,7 @@
     {
         CalorimeterHit v1 = (CalorimeterHit) obj1;
         CalorimeterHit v2 = (CalorimeterHit) obj2;
-        if(v1.getEnergy()-v2.getEnergy()>0.) return -1;
+        if(v1.getRawEnergy()-v2.getRawEnergy()>0.) return -1;
         return 1;
     }
 }
\ No newline at end of file

lcsim/src/org/lcsim/plugin/browser
CalorimeterHitTableModel.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- CalorimeterHitTableModel.java	14 Mar 2005 16:11:33 -0000	1.1
+++ CalorimeterHitTableModel.java	2 Aug 2005 17:18:03 -0000	1.2
@@ -61,7 +61,7 @@
       if (column < decoder.getFieldCount()) return decoder.getValue(column);
       else switch (column-decoder.getFieldCount())
       {
-         case 0: return hit.getEnergy();
+         case 0: return hit.getRawEnergy();
          case 1: return decoder.getX();
          case 2: return decoder.getY();
          case 3: return decoder.getZ();

lcsim/src/org/lcsim/recon/cluster/fixedcone
FixedConeClusterer.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- FixedConeClusterer.java	27 Jul 2005 16:06:21 -0000	1.6
+++ FixedConeClusterer.java	2 Aug 2005 17:18:03 -0000	1.7
@@ -114,10 +114,10 @@
             if (!used[i])
             {
                 CalorimeterHit p = in.get(i);
-                if (p.getEnergy()>_seedEnergy)
+                if (p.getRawEnergy()>_seedEnergy)
                 {
                     decoder.setID(p.getCellID());
-                    double cellE = p.getEnergy();
+                    double cellE = p.getRawEnergy();
                     double px = cellE*Math.cos(decoder.getPhi())*Math.sin(decoder.getTheta());
                     double py = cellE*Math.sin(decoder.getPhi())*Math.sin(decoder.getTheta());
                     double pz = cellE*Math.cos(decoder.getTheta());
@@ -171,7 +171,7 @@
                             if(cond)
                             {
                                 //  particle within cone
-                                cellE = p2.getEnergy();
+                                cellE = p2.getRawEnergy();
                                 px = cellE*Math.cos(decoder.getPhi())*Math.sin(decoder.getTheta());
                                 py = cellE*Math.sin(decoder.getPhi())*Math.sin(decoder.getTheta());
                                 pz = cellE*Math.cos(decoder.getTheta());

lcsim/src/org/lcsim/recon/cluster/nn
NearestNeighborCluster.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- NearestNeighborCluster.java	20 Jul 2005 20:35:44 -0000	1.7
+++ NearestNeighborCluster.java	2 Aug 2005 17:18:04 -0000	1.8
@@ -51,7 +51,7 @@
                 // if so, does it meet or exceed threshold?
                 if (h != null)
                 {
-                    if (h.getEnergy() >= threshold)
+                    if (h.getRawEnergy() >= threshold)
                         addHit(h);
                     hitmap.remove(neighbors[j]);
                 }

lcsim/src/org/lcsim/recon/cluster/util
BasicCluster.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- BasicCluster.java	18 Jul 2005 03:06:19 -0000	1.3
+++ BasicCluster.java	2 Aug 2005 17:18:04 -0000	1.4
@@ -38,7 +38,7 @@
     public void addHit(CalorimeterHit hit)
     {
         hits.add(hit);
-        raw_energy += hit.getEnergy();
+        raw_energy += hit.getRawEnergy();
                 /*
                  Subdetector d = hit.getSubdetector();
                  int detector_index = detectors.indexOf(d);
@@ -58,10 +58,10 @@
             subdetector_raw_energies.add(0.);
             subdetector_corrected_energies.add(0.);
         }
-        double hce = hit.getEnergy()/sampling_fraction;
+        double hce = hit.getRawEnergy()/sampling_fraction;
         corrected_energy += hce;
         hit_energies.add(hce);
-        subdetector_raw_energies.set(detector_index,subdetector_raw_energies.get(detector_index) + hit.getEnergy());
+        subdetector_raw_energies.set(detector_index,subdetector_raw_energies.get(detector_index) + hit.getRawEnergy());
         subdetector_corrected_energies.set(detector_index,subdetector_corrected_energies.get(detector_index) + hce);
         needsPropertyCalculation = true;
     }
@@ -73,7 +73,7 @@
     {
         int indx = hits.indexOf(hit);
         hits.remove(hit);
-        raw_energy -= hit.getEnergy();
+        raw_energy -= hit.getRawEnergy();
                 /*
                  Subdetector d = hit.getSubdetector();
                  int detector_index = detectors.indexOf(d);
@@ -88,10 +88,10 @@
                  */
         int detector_index = 0;
         double sampling_fraction = 1.;
-        double hce = hit.getEnergy()/sampling_fraction;
+        double hce = hit.getRawEnergy()/sampling_fraction;
         corrected_energy -= hce;
         hit_energies.remove(indx);
-        subdetector_raw_energies.set(detector_index,subdetector_raw_energies.get(detector_index) - hit.getEnergy());
+        subdetector_raw_energies.set(detector_index,subdetector_raw_energies.get(detector_index) - hit.getRawEnergy());
         subdetector_corrected_energies.set(detector_index,subdetector_corrected_energies.get(detector_index) - hce);
         needsPropertyCalculation = true;
     }

lcsim/src/org/lcsim/recon/cluster/util
CalorimeterCluster.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- CalorimeterCluster.java	8 Jul 2005 17:15:07 -0000	1.4
+++ CalorimeterCluster.java	2 Aug 2005 17:18:04 -0000	1.5
@@ -56,7 +56,7 @@
             _decoder.setID(h.getCellID());
             // this is a change...
             // incorporate sampling fractions to get correct cluster energy
-            double e = h.getEnergy()/_samplingFraction;
+            double e = h.getRawEnergy()/_samplingFraction;
             if (e>_highestCellEnergy)
             {
                 _highestCellEnergy = e;
@@ -125,7 +125,7 @@
             double phi = _decoder.getPhi();
             double theta=_decoder.getTheta();
             
-            double cellE = p2.getEnergy()/_samplingFraction;
+            double cellE = p2.getRawEnergy()/_samplingFraction;
             double px = cellE*Math.cos(_decoder.getPhi())*Math.sin(_decoder.getTheta());
             double py = cellE*Math.sin(_decoder.getPhi())*Math.sin(_decoder.getTheta());
             double pz = cellE*Math.cos(_decoder.getTheta());

lcsim/src/org/lcsim/recon/cluster/util
DefaultClusterPropertyCalculator.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- DefaultClusterPropertyCalculator.java	8 Jul 2005 17:15:08 -0000	1.2
+++ DefaultClusterPropertyCalculator.java	2 Aug 2005 17:18:04 -0000	1.3
@@ -49,7 +49,7 @@
 		//	Subdetector d = hit.getSubdetector();
 		//	double sampling_fraction = d.getSamplingFraction();
 			double sampling_fraction = 1.;
-			double wt = hit.getEnergy()/sampling_fraction;
+			double wt = hit.getRawEnergy()/sampling_fraction;
 			wtsum += wt;
 			for(int j=0;j<3;j++)
 			{

lcsim/src/org/lcsim/recon/cluster/util
FixedConeClusterPropertyCalculator.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- FixedConeClusterPropertyCalculator.java	18 Jul 2005 03:08:42 -0000	1.1
+++ FixedConeClusterPropertyCalculator.java	2 Aug 2005 17:18:04 -0000	1.2
@@ -66,7 +66,7 @@
 			_decoder.setID(h.getCellID());
             // this is a change...
             // incorporate sampling fractions to get correct cluster energy
-            double e = h.getEnergy()/_samplingFraction;
+            double e = h.getRawEnergy()/_samplingFraction;
             if (e>_highestCellEnergy)
             {
                 _highestCellEnergy = e;
@@ -148,7 +148,7 @@
 			pos[0] = _decoder.getX();
 			pos[1] = _decoder.getY();
 			pos[2] = _decoder.getZ();
-			double wt = hit.getEnergy()/sampling_fraction;
+			double wt = hit.getRawEnergy()/sampling_fraction;
 			wtsum += wt;
 			for(int j=0;j<3;j++)
 			{

lcsim/src/org/lcsim/recon/cluster/util
HitsCluster.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HitsCluster.java	4 Mar 2005 08:18:34 -0000	1.2
+++ HitsCluster.java	2 Aug 2005 17:18:04 -0000	1.3
@@ -18,7 +18,7 @@
    public void addHit(CalorimeterHit hit)
    {
       hits.add(hit);
-      energy += hit.getEnergy();
+      energy += hit.getRawEnergy();
    }
    
    public List<CalorimeterHit> getCalorimeterHits()

lcsim/src/org/lcsim/recon/cluster/util
TensorClusterPropertyCalculator.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- TensorClusterPropertyCalculator.java	18 Jul 2005 03:06:19 -0000	1.3
+++ TensorClusterPropertyCalculator.java	2 Aug 2005 17:18:04 -0000	1.4
@@ -83,7 +83,7 @@
             //	Subdetector d = hit.getSubdetector();
             //	double sampling_fraction = d.getSamplingFraction();
             double sampling_fraction = 1.;
-            double E = hit.getEnergy()/sampling_fraction;
+            double E = hit.getRawEnergy()/sampling_fraction;
             Etot += E;
             CEx += E*pos[0];
             CEy += E*pos[1];

lcsim/src/org/lcsim/util/event
BaseCalorimeterHit.java added at 1.1
diff -N BaseCalorimeterHit.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BaseCalorimeterHit.java	2 Aug 2005 17:18:05 -0000	1.1
@@ -0,0 +1,64 @@
+package org.lcsim.util.event;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.geometry.Subdetector;
+
+/**
+ *
+ * @author tonyj
+ */
+public abstract class BaseCalorimeterHit implements CalorimeterHit
+{
+   // Fixme: Maybe energy should be left to subclass to allow double/float, same for time
+   protected double rawEnergy;
+   protected LCMetaData data;
+   protected double[] position;
+   protected double time;
+   protected long id;
+  
+   public double getTime()
+   {
+      return time;
+   }
+
+   public Subdetector getSubdetector()
+   {
+      return SubdetectorLocator.locateSubdetector(data,id);
+   }
+
+   public double getRawEnergy()
+   {
+      return rawEnergy;
+   }
+
+   public double[] getPosition()
+   {
+      if (position == null)
+      {
+         IDDecoder iddecoder = data.getIDDecoder();
+         position = new double[3];
+         position[0] = iddecoder.getX();
+         position[1] = iddecoder.getY();
+         position[2] = iddecoder.getZ();
+      }
+      return position;
+   }
+
+   public IDDecoder getIDDecoder()
+   {
+      return data.getIDDecoder();
+   }
+
+   public double getCorrectedEnergy()
+   {
+      double sf = SamplingFractionManager.defaultInstance().getSamplingFraction(SubdetectorLocator.locateSubdetector(data,id));
+      return rawEnergy/sf;
+   }
+
+   public long getCellID()
+   {
+      return id;
+   }  
+}
\ No newline at end of file

lcsim/src/org/lcsim/util/event
SamplingFractionManager.java added at 1.1
diff -N SamplingFractionManager.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SamplingFractionManager.java	2 Aug 2005 17:18:05 -0000	1.1
@@ -0,0 +1,50 @@
+package org.lcsim.util.event;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.lcsim.conditions.ConditionsListener;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsSet;
+import org.lcsim.geometry.Subdetector;
+
+/**
+ * Currently assumes that each subdetector has a single sampling fraction.
+ * This is obviously not true if the subdetector has more than one layering scheme, 
+ * or if a single "subdetector" represents more than one physical detector (e.g. 
+ * barrel and endcap).
+ * @author tonyj
+ */
+public class SamplingFractionManager
+{
+   private Listener listener = new Listener();
+   private Map<String,Double> cache = new HashMap<String,Double>();
+   private static SamplingFractionManager theSamplingFractionManager = new SamplingFractionManager();
+   
+   private SamplingFractionManager()
+   {
+   }
+   double getSamplingFraction(Subdetector d)
+   {
+      String name = d.getName();
+      Double result = cache.get(name);
+      if (result == null)
+      {
+         ConditionsSet set = ConditionsManager.defaultInstance().getConditions("/SamplingFractions/"+name);
+         set.addConditionsListener(listener);
+         result = set.getDouble("samplingFraction");
+         cache.put(name, result);
+      }
+      return result;
+   }
+   private class Listener implements ConditionsListener
+   {
+      public void conditionsChanged(org.lcsim.conditions.ConditionsEvent event)
+      {
+         cache.clear();
+      }
+   }
+   static SamplingFractionManager defaultInstance()
+   {
+      return theSamplingFractionManager;
+   }
+}

lcsim/src/org/lcsim/util/event
SubdetectorLocator.java added at 1.1
diff -N SubdetectorLocator.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SubdetectorLocator.java	2 Aug 2005 17:18:05 -0000	1.1
@@ -0,0 +1,26 @@
+package org.lcsim.util.event;
+
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.geometry.CalorimeterIDDecoder;
+import org.lcsim.geometry.Subdetector;
+
+/**
+ * This class enables us to find the subdector and sampling fraction from
+ * a hit ID plus an LCMetaData. The problem is that LCIO format does not mandate
+ * how this should be done. Two obvious possibilities are:
+ * <ol>
+ * <li>The ID contains a SystemID which leads us to the detector
+ * <li>Each collection is associated to a specific subdetector.
+ * </ol>
+ * Currently it cheats and uses a method which should not exist.
+ * @author tonyj
+ */
+class SubdetectorLocator
+{
+   static Subdetector locateSubdetector(LCMetaData d, long id)
+   {
+      // Fixme: We should not assume this is a calorimeter hit
+      // Fixme: This method getCalorimeter should not exist on CalorimeterIDDecoder
+      return ((CalorimeterIDDecoder) d.getIDDecoder()).getCalorimeter();
+   }
+}
\ No newline at end of file

lcsim/src/org/lcsim/util/event
BaseLCSimEvent.java 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- BaseLCSimEvent.java	26 Jul 2005 14:44:34 -0000	1.13
+++ BaseLCSimEvent.java	2 Aug 2005 17:18:05 -0000	1.14
@@ -211,6 +211,11 @@
          if (stringMap == null) stringMap = new HashMap<String, String[]>();
          return stringMap;
       }
+
+      public EventHeader getEvent()
+      {
+         return BaseLCSimEvent.this;
+      }
    }
    // All empty lists are considered equal, but we need to put several different possibly empty lists 
    // into the metadata map. ListHolder is a workaround for this.

lcsim/src/org/lcsim/util/heprep
CalorimeterHitConverter.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- CalorimeterHitConverter.java	2 Aug 2005 04:57:41 -0000	1.2
+++ CalorimeterHitConverter.java	2 Aug 2005 17:18:05 -0000	1.3
@@ -18,7 +18,7 @@
 /**
  *
  * @author tonyj
- * @version $Id: CalorimeterHitConverter.java,v 1.2 2005/08/02 04:57:41 ngraf Exp $
+ * @version $Id: CalorimeterHitConverter.java,v 1.3 2005/08/02 17:18:05 tonyj Exp $
  */
 class CalorimeterHitConverter implements HepRepCollectionConverter
 {
@@ -50,7 +50,7 @@
       {
          for (CalorimeterHit hit : (List<CalorimeterHit>) collection)
          {
-            double e = hit.getEnergy();
+            double e = hit.getRawEnergy();
             if (e > maxEnergy) maxEnergy = e;
             if (e > 0 && e < minEnergy) minEnergy = e;
          }
@@ -63,10 +63,10 @@
       {
          double[] pos = hasPos ?  hit.getPosition() : decoder.getPosition();
          HepRepInstance instanceX = factory.createHepRepInstance(instanceTree, typeX);
-         instanceX.addAttValue("energy",hit.getEnergy());
+         instanceX.addAttValue("energy",hit.getRawEnergy());
          if (hitColorMap != null)
          {
-            double v = (Math.log(hit.getEnergy())-Math.log(minEnergy))/(Math.log(maxEnergy)-Math.log(minEnergy));
+            double v = (Math.log(hit.getRawEnergy())-Math.log(minEnergy))/(Math.log(maxEnergy)-Math.log(minEnergy));
             instanceX.addAttValue("color",hitColorMap.getColor(v,1.0f));
          }
          HepRepPoint pp = factory.createHepRepPoint(instanceX,pos[0],pos[1],pos[2]);

lcsim/src/org/lcsim/util/heprep
ClusterConverter.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ClusterConverter.java	14 May 2005 00:26:53 -0000	1.1
+++ ClusterConverter.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -17,7 +17,7 @@
 /**
  *
  * @author tonyj
- * @version $Id: ClusterConverter.java,v 1.1 2005/05/14 00:26:53 tonyj Exp $
+ * @version $Id: ClusterConverter.java,v 1.2 2005/08/02 17:18:06 tonyj Exp $
  */
 class ClusterConverter implements HepRepCollectionConverter
 {
@@ -62,7 +62,7 @@
                // FixMe: What if hit doesn't have position?
                double[] pos = hit.getPosition();
                HepRepInstance instanceX = factory.createHepRepInstance(instanceTree, typeX);
-               instanceX.addAttValue("energy",hit.getEnergy());
+               instanceX.addAttValue("energy",hit.getRawEnergy());
                instanceX.addAttValue("cluster",cluster.getEnergy());
                instanceX.addAttValue("color",clusterColor);
                HepRepPoint pp = factory.createHepRepPoint(instanceX,pos[0],pos[1],pos[2]);

lcsim/src/org/lcsim/util/lcio
AbstractBlockHandler.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- AbstractBlockHandler.java	26 Jul 2005 14:44:34 -0000	1.4
+++ AbstractBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.5
@@ -34,10 +34,10 @@
       }
       int n = in.readInt();
       LCIOCollection collection = new LCIOCollection(getClassForType(), flags, n, colParameters);
-      addCollectionElements(collection,in,n,version);
       event.put(block.getBlockName(),collection);
+      addCollectionElements(event,collection,in,n,version);
    }
-   abstract void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException;
+   abstract void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException;
    
    public void writeBlock(SIOWriter writer, List collection, LCMetaData md) throws IOException
    {

lcsim/src/org/lcsim/util/lcio
SIOCalorimeterHit.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SIOCalorimeterHit.java	26 Jul 2005 23:46:56 -0000	1.3
+++ SIOCalorimeterHit.java	2 Aug 2005 17:18:06 -0000	1.4
@@ -2,72 +2,46 @@
 
 import hep.lcd.io.sio.SIOInputStream;
 import hep.lcd.io.sio.SIOOutputStream;
+import hep.lcd.io.sio.SIORef;
 
 import java.io.IOException;
 import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.util.event.BaseCalorimeterHit;
 import org.lcsim.event.RawCalorimeterHit;
 
 /**
  * SIO-based I/O implementation of the CalorimeterHit interface
  *
  * @author Guilherme Lima
- * @version $Id: SIOCalorimeterHit.java,v 1.3 2005/07/26 23:46:56 lima Exp $
+ * @version $Id: SIOCalorimeterHit.java,v 1.4 2005/08/02 17:18:06 tonyj Exp $
  */
-class SIOCalorimeterHit implements CalorimeterHit
+class SIOCalorimeterHit extends BaseCalorimeterHit
 {
-   private int _cellid0;
-   private int _cellid1;
-   private float _energy;
-   private float _time;
-   private RawCalorimeterHit _rawhit;
-   private int _type;
-
-   SIOCalorimeterHit(SIOInputStream in, int flags, int version) throws IOException
-   {
-      _cellid0 = in.readInt();
-      if( LCIOUtil.bitTest(flags,LCIOConstants.RCHBIT_ID1) || version==8) {
-	  _cellid1 = in.readInt();
+    SIOCalorimeterHit(SIOInputStream in, int flags, int version, LCMetaData meta) throws IOException
+    {
+      this.data = meta;
+      int cellid0 = in.readInt();
+      int cellid1 = 0;
+      if (LCIOUtil.bitTest(flags,LCIOConstants.RCHBIT_ID1) || version==8) {
+	 cellid1 = in.readInt();
       }
-      else _cellid1 = 0;
-
-      _energy = in.readFloat();
+      id = ((long) cellid1)<<32 | cellid0;
+      rawEnergy = in.readFloat();
 
       if( LCIOUtil.bitTest(flags,LCIOConstants.RCHBIT_TIME) || version==8) {
-	  _time = in.readFloat();
+         time = in.readFloat();
       }
 
-      _type = in.readInt();
+      int type = in.readInt();
 
       if (!LCIOUtil.bitTest(flags,LCIOConstants.RCHBIT_NO_PTR)) {
-	  _rawhit = (RawCalorimeterHit)in.readPntr();
+	  SIORef rawhit = in.readPntr();
       }
 
       in.readPTag(this);
    }
-
-   public long getCellID() {
-      return ((long) _cellid1)<<32 | _cellid0;
-   }
-
-   /**
-    * Raw energy deposited in Calorimeter Cell
-    */
-   public double getEnergy() {
-      return _energy;
-   }
-
-   public double getTime() {
-       return _time;
-   }
-
-   /**
-    * Always returns (0,0,0) for now
-    */
-   public double[] getPosition() {
-       double[] pos = new double[3];
-       return pos;
-   }
-
+   
    static void write(CalorimeterHit hit, SIOOutputStream out, int flags) throws IOException
    {
       long cellID = hit.getCellID();
@@ -77,7 +51,7 @@
 	  out.writeInt((int) (cellID>>32));
       }
 
-      out.writeFloat( (float)hit.getEnergy() );
+      out.writeFloat( (float)hit.getRawEnergy() );
 
       if( LCIOUtil.bitTest( flags, LCIOConstants.RCHBIT_TIME)) {
 	  out.writeFloat( (float)hit.getTime() );

lcsim/src/org/lcsim/util/lcio
SIOCalorimeterHitBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIOCalorimeterHitBlockHandler.java	20 Jul 2005 21:11:06 -0000	1.1
+++ SIOCalorimeterHitBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -5,23 +5,25 @@
 import java.io.IOException;
 
 import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader.LCMetaData;
 
 /**
  * Block handler for calorimeter hits.
  *
  * @author Guilherme Lima
- * @version $Id: SIOCalorimeterHitBlockHandler.java,v 1.1 2005/07/20 21:11:06 lima Exp $
+ * @version $Id: SIOCalorimeterHitBlockHandler.java,v 1.2 2005/08/02 17:18:06 tonyj Exp $
  */
 class SIOCalorimeterHitBlockHandler extends AbstractBlockHandler
 {
     public String getType() { return "CalorimeterHit"; }
     public Class getClassForType() { return CalorimeterHit.class; }
-    public void addCollectionElements(LCIOCollection collection,
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection,
 				      SIOInputStream in, int n, int version)
 	throws IOException
     {
+      LCMetaData meta = event.getMetaData(collection);
       for (int i = 0; i < n; i++)
-	collection.add(new SIOCalorimeterHit(in, collection.getFlags(), version));
+	collection.add(new SIOCalorimeterHit(in, collection.getFlags(), version, meta));
     }
 
     void writeCollectionElement(Object element, SIOOutputStream out, int flags)

lcsim/src/org/lcsim/util/lcio
SIOClusterBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIOClusterBlockHandler.java	16 Feb 2005 07:28:07 -0000	1.1
+++ SIOClusterBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -14,7 +14,7 @@
 {
    public String getType() { return "Cluster"; }
    public Class getClassForType() { return Cluster.class; }
-   void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
       for (int i = 0; i < n; i++)
          collection.add(new SIOCluster(in, collection.getFlags(), version));

lcsim/src/org/lcsim/util/lcio
SIOLCRelationBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIOLCRelationBlockHandler.java	26 Apr 2005 18:52:21 -0000	1.1
+++ SIOLCRelationBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -10,13 +10,13 @@
  * Block handler for relation objects.
  *
  * @author Guilherme Lima
- * @version $Id: SIOLCRelationBlockHandler.java,v 1.1 2005/04/26 18:52:21 lima Exp $
+ * @version $Id: SIOLCRelationBlockHandler.java,v 1.2 2005/08/02 17:18:06 tonyj Exp $
  */
 class SIOLCRelationBlockHandler extends AbstractBlockHandler
 {
     public String getType() { return "LCRelation"; }
     public Class getClassForType() { return LCRelation.class; }
-    public void addCollectionElements(LCIOCollection collection,
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection,
 				      SIOInputStream in, int n, int version)
 	throws IOException
     {

lcsim/src/org/lcsim/util/lcio
SIOMCParticleBlockHandler.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SIOMCParticleBlockHandler.java	3 Mar 2005 16:28:20 -0000	1.3
+++ SIOMCParticleBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.4
@@ -13,7 +13,7 @@
 {
    public String getType() { return "MCParticle"; }
    public Class getClassForType() { return MCParticle.class; }
-   void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
       for (int i = 0; i < n; i++)
          collection.add(new SIOMCParticle(in, collection.getFlags(), version));

lcsim/src/org/lcsim/util/lcio
SIORawCalorimeterHitBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIORawCalorimeterHitBlockHandler.java	26 Apr 2005 18:52:53 -0000	1.1
+++ SIORawCalorimeterHitBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -10,13 +10,13 @@
  * Block handler for raw calorimeter hits.
  *
  * @author Guilherme Lima
- * @version $Id: SIORawCalorimeterHitBlockHandler.java,v 1.1 2005/04/26 18:52:53 lima Exp $
+ * @version $Id: SIORawCalorimeterHitBlockHandler.java,v 1.2 2005/08/02 17:18:06 tonyj Exp $
  */
 class SIORawCalorimeterHitBlockHandler extends AbstractBlockHandler
 {
     public String getType() { return "RawCalorimeterHit"; }
     public Class getClassForType() { return RawCalorimeterHit.class; }
-    public void addCollectionElements(LCIOCollection collection,
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection,
 				      SIOInputStream in, int n, int version)
 	throws IOException
     {

lcsim/src/org/lcsim/util/lcio
SIOReconstructedParticleBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIOReconstructedParticleBlockHandler.java	30 Jun 2005 23:21:10 -0000	1.1
+++ SIOReconstructedParticleBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -13,7 +13,7 @@
 {
    public String getType() { return "ReconstructedParticle"; }
    public Class getClassForType() { return ReconstructedParticle.class; }
-   void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
       for (int i = 0; i < n; i++)
          collection.add(new SIOReconstructedParticle(in, collection.getFlags(), version));

lcsim/src/org/lcsim/util/lcio
SIOSimCalorimeterHit.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SIOSimCalorimeterHit.java	29 Jul 2005 02:43:28 -0000	1.3
+++ SIOSimCalorimeterHit.java	2 Aug 2005 17:18:06 -0000	1.4
@@ -5,141 +5,126 @@
 import hep.lcd.io.sio.SIORef;
 
 import java.io.IOException;
+import org.lcsim.event.EventHeader.LCMetaData;
 import org.lcsim.event.MCParticle;
 import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.util.event.BaseCalorimeterHit;
 
 /**
  *
  * @author Tony Johnson
- * @version $Id: SIOSimCalorimeterHit.java,v 1.3 2005/07/29 02:43:28 jeremy Exp $
+ * @version $Id: SIOSimCalorimeterHit.java,v 1.4 2005/08/02 17:18:06 tonyj Exp $
  */
-class SIOSimCalorimeterHit implements SimCalorimeterHit
+class SIOSimCalorimeterHit extends BaseCalorimeterHit implements SimCalorimeterHit
 {
-    private float energy;
-    private int cellId0;
-    private int cellId1;
-    private double[] position = new double[3];
-    private int nContributions;
-    private Object[] particle;
-    private float[] energyContrib;
-    private float[] time;
-    private int[] pdg;
-    
-    SIOSimCalorimeterHit(SIOInputStream in, int flags, int version) throws IOException
-    {
-        cellId0 = in.readInt();
-        if (LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_ID1) || version==8) cellId1 = in.readInt();
-        else cellId1 = 0;
-        energy = in.readFloat();
-        
-        if (LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_LONG))
-        {
-            position[0] = in.readFloat();
-            position[1] = in.readFloat();
-            position[2] = in.readFloat();
-        }
-        nContributions = in.readInt();
-        particle = new Object[nContributions];
-        energyContrib = new float[nContributions];
-        time = new float[nContributions];
-        
-        boolean hasPDG = LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_PDG);
-        if (hasPDG) pdg = new int[nContributions];
-        for (int i = 0; i < nContributions; i++)
-        {
-            particle[i] = in.readPntr();
-            energyContrib[i] = in.readFloat();
-            time[i] = in.readFloat();
-            if (hasPDG) pdg[i] = in.readInt();
-        }
-        if ( version > 1000 ) in.readPTag(this);
-    }
-    /**
-     * Raw energy deposited in Calorimeter Cell
-     */
-    public double getEnergy()
-    {
-        return energy;
-    }
-    
-    public long getCellID()
-    {
-        return ((long) cellId1)<<32 | cellId0;
-    }
-    
-    // Somewhat arbitrarily decide that the time of the hit
-    // is the earliest time from MCParticle contributions
-    public double getTime()
-    {      
-        if (time.length == 0) return 0;
-        double t = time[0];
-        if ( time.length > 1 )
-        {
-            for (int i=1; i<time.length; i++)
-            {
-                t = Math.min(t,time[i]);
-            }
-        }
-        return t;
-    }
-    
-    public MCParticle getMCParticle(int index)
-    {
-        Object p = particle[index];
-        if (p instanceof SIORef) p = ((SIORef) p).getObject();
-        return (MCParticle) p;
-    }
-    
-    public double getContributedEnergy(int index)
-    {
-        return energyContrib[index];
-    }
-    
-    public int getPDG(int index)
-    {
-        return pdg[index];
-    }
-    
-    public double getContributedTime(int index)
-    {
-        return time[index];
-    }
-    
-    public double[] getPosition()
-    {
-        return position;
-    }
-    
-    public int getMCParticleCount()
-    {
-        return particle.length;
-    }
-    static void write(SimCalorimeterHit hit, SIOOutputStream out, int flags) throws IOException
-    {
-        long cellID = hit.getCellID();
-        out.writeInt((int) cellID);
-        if (LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_ID1)) out.writeInt((int) (cellID>>32));
-        out.writeFloat((float) hit.getEnergy());
-        
-        if ((flags & (1 << LCIOConstants.CHBIT_LONG)) != 0)
-        {
-            double[] pos = hit.getPosition();
-            out.writeFloat((float) pos[0]);
-            out.writeFloat((float) pos[1]);
-            out.writeFloat((float) pos[2]);
-        }
-        
-        boolean hasPDG = LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_PDG);
-        int n = hit.getMCParticleCount();
-        out.writeInt(n);
-        for (int i = 0; i < n; i++)
-        {
-            out.writePntr(hit.getMCParticle(i));
-            out.writeFloat((float) hit.getContributedEnergy(i));
-            out.writeFloat((float) hit.getContributedTime(i));
-            if (hasPDG) out.writeInt(hit.getPDG(i));
-        }
-        out.writePTag(hit);
-    }
-    
+   private int nContributions;
+   private Object[] particle;
+   private float[] energyContrib;
+   private float[] time;
+   private int[] pdg;
+   
+   SIOSimCalorimeterHit(SIOInputStream in, int flags, int version, LCMetaData meta) throws IOException
+   {
+      this.data = meta;
+      int cellid0 = in.readInt();
+      int cellid1 = 0;
+      if (LCIOUtil.bitTest(flags,LCIOConstants.RCHBIT_ID1) || version==8) {
+	 cellid1 = in.readInt();
+      }
+
+      id = ((long) cellid1)<<32 | cellid0;
+      rawEnergy = in.readFloat();
+      
+      if (LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_LONG))
+      {
+         position = new double[3];
+         position[0] = in.readFloat();
+         position[1] = in.readFloat();
+         position[2] = in.readFloat();
+      }
+      nContributions = in.readInt();
+      particle = new Object[nContributions];
+      energyContrib = new float[nContributions];
+      time = new float[nContributions];
+      
+      boolean hasPDG = LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_PDG);
+      if (hasPDG) pdg = new int[nContributions];
+      for (int i = 0; i < nContributions; i++)
+      {
+         particle[i] = in.readPntr();
+         energyContrib[i] = in.readFloat();
+         time[i] = in.readFloat();
+         if (hasPDG) pdg[i] = in.readInt();
+      }
+      if ( version > 1000 ) in.readPTag(this);
+   }
+   
+   public double getTime()
+   {
+      // Somewhat arbitrarily decide that the time of the hit
+      // is the earliest hit contribution time
+      
+      if (time.length == 0) return 0;
+      double t = time[0];
+      for (int i=1; i<time.length; i++)
+      {
+         t = Math.min(t,time[i]);
+      }
+      return t;
+   }
+   
+   public MCParticle getMCParticle(int index)
+   {
+      Object p = particle[index];
+      if (p instanceof SIORef) p = ((SIORef) p).getObject();
+      return (MCParticle) p;
+   }
+   
+   public double getContributedEnergy(int index)
+   {
+      return energyContrib[index];
+   }
+   
+   public int getPDG(int index)
+   {
+      return pdg[index];
+   }
+   
+   public double getContributedTime(int index)
+   {
+      return time[index];
+   }
+   
+   public int getMCParticleCount()
+   {
+      return particle.length;
+   }
+   static void write(SimCalorimeterHit hit, SIOOutputStream out, int flags) throws IOException
+   {
+      long cellID = hit.getCellID();
+      out.writeInt((int) cellID);
+      if (LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_ID1)) out.writeInt((int) (cellID>>32));
+      out.writeFloat((float) hit.getRawEnergy());
+      
+      if ((flags & (1 << LCIOConstants.CHBIT_LONG)) != 0)
+      {
+         double[] pos = hit.getPosition();
+         out.writeFloat((float) pos[0]);
+         out.writeFloat((float) pos[1]);
+         out.writeFloat((float) pos[2]);
+      }
+      
+      boolean hasPDG = LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_PDG);
+      int n = hit.getMCParticleCount();
+      out.writeInt(n);
+      for (int i = 0; i < n; i++)
+      {
+         out.writePntr(hit.getMCParticle(i));
+         out.writeFloat((float) hit.getContributedEnergy(i));
+         out.writeFloat((float) hit.getContributedTime(i));
+         if (hasPDG) out.writeInt(hit.getPDG(i));
+      }
+      out.writePTag(hit);
+   }
 }

lcsim/src/org/lcsim/util/lcio
SIOSimCalorimeterHitBlockHandler.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SIOSimCalorimeterHitBlockHandler.java	26 Jul 2005 14:44:35 -0000	1.3
+++ SIOSimCalorimeterHitBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.4
@@ -3,9 +3,11 @@
 import hep.lcd.io.sio.SIOInputStream;
 import hep.lcd.io.sio.SIOOutputStream;
 import java.io.IOException;
+import org.lcsim.event.EventHeader.LCMetaData;
 
 import org.lcsim.event.SimCalorimeterHit;
 
+
 /**
  *
  * @author tonyj
@@ -14,10 +16,11 @@
 {
    public String getType() { return "SimCalorimeterHit"; }
    public Class getClassForType() { return SimCalorimeterHit.class; }
-   public void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+   void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
+      LCMetaData meta = event.getMetaData(collection);
       for (int i = 0; i < n; i++)
-         collection.add(new SIOSimCalorimeterHit(in, collection.getFlags(), version));
+         collection.add(new SIOSimCalorimeterHit(in, collection.getFlags(), version, meta));
    }
       
    void writeCollectionElement(Object element, SIOOutputStream out, int flags) throws IOException

lcsim/src/org/lcsim/util/lcio
SIOSimTrackerHitBlockHandler.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SIOSimTrackerHitBlockHandler.java	26 Jul 2005 14:44:35 -0000	1.3
+++ SIOSimTrackerHitBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.4
@@ -14,7 +14,7 @@
 {
    public String getType() { return "SimTrackerHit"; }
    public Class getClassForType() { return SimTrackerHit.class; }
-   public void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+   void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
       for (int i = 0; i < n; i++)
          collection.add(new SIOSimTrackerHit(in, collection.getFlags(), version));

lcsim/src/org/lcsim/util/lcio
SIOTPCHitBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIOTPCHitBlockHandler.java	22 Feb 2005 06:37:42 -0000	1.1
+++ SIOTPCHitBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -14,7 +14,7 @@
 {
    public String getType() { return "TPCHit"; }
    public Class getClassForType() { return TPCHit.class; }
-   void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+    void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
       for (int i = 0; i < n; i++)
          collection.add(new SIOTPCHit(in, collection.getFlags(), version));

lcsim/src/org/lcsim/util/lcio
SIOTrackBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIOTrackBlockHandler.java	22 Feb 2005 06:37:42 -0000	1.1
+++ SIOTrackBlockHandler.java	2 Aug 2005 17:18:06 -0000	1.2
@@ -15,7 +15,7 @@
 {
    public String getType() { return "Track"; }
    public Class getClassForType() { return Track.class; }
-   public void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+   void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
       for (int i = 0; i < n; i++)
          collection.add(new SIOTrack(in, collection.getFlags(), version));

lcsim/src/org/lcsim/util/lcio
SIOTrackerHitBlockHandler.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SIOTrackerHitBlockHandler.java	22 Feb 2005 06:37:42 -0000	1.1
+++ SIOTrackerHitBlockHandler.java	2 Aug 2005 17:18:07 -0000	1.2
@@ -15,7 +15,7 @@
 {
    public String getType() { return "TrackerHit"; }
    public Class getClassForType() { return TrackerHit.class; }
-   public void addCollectionElements(LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+   void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
    {
       for (int i = 0; i < n; i++)
          collection.add(new SIOTrackerHit(in, collection.getFlags(), version));

lcsim/test/org/lcsim/conditions
ConditionsManagerTest.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- ConditionsManagerTest.java	13 Jul 2005 01:12:46 -0000	1.6
+++ ConditionsManagerTest.java	2 Aug 2005 17:18:08 -0000	1.7
@@ -23,7 +23,7 @@
 {
     private ConditionsManager _mgr;
     public List<String> testDets;
-    public final static String[] condNames =  {"TrackParameters","ClusterParameters","HitSmearing","SamplingFractions"};
+    public final static String[] condNames =  {"TrackParameters","ClusterParameters","HitSmearing"};
     
     /** Creates a new instance of ConditionsReaderTest */
     public ConditionsManagerTest (String testName)

lcsim/test
SamplingFractionTest.java added at 1.1
diff -N SamplingFractionTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SamplingFractionTest.java	2 Aug 2005 17:18:08 -0000	1.1
@@ -0,0 +1,64 @@
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.geometry.IDDecoder;
+import org.lcsim.util.Driver;
+import org.lcsim.util.cache.FileCache;
+import org.lcsim.util.loop.LCIODriver;
+import org.lcsim.util.loop.LCSimLoop;
+/**
+ *
+ * @author tonyj
+ */
+public class SamplingFractionTest extends TestCase
+{
+   public SamplingFractionTest(String testName)
+   {
+      super(testName);
+   }
+   
+   public static Test suite()
+   {
+      return new TestSuite(SamplingFractionTest.class);
+   }
+   
+   public void testLCIORead() throws Exception
+   {
+      URL url = new URL("http://www.lcsim.org/datasamples/slic_sdjan03_K0S_Theta90_1-10GeV.slcio");
+      FileCache cache = new FileCache();
+      File file = cache.getCachedFile(url);
+      
+      LCSimLoop loop = new LCSimLoop();
+      loop.setLCIORecordSource(file);
+      loop.add(new TestDriver());
+      loop.loop(-1);
+      loop.dispose();
+   }
+   private class TestDriver extends Driver
+   {
+      public void process(EventHeader event)
+      {
+         // Loop over all calorimeter hits 
+         List<List<SimCalorimeterHit>> collections = event.get(SimCalorimeterHit.class);
+         for (List<SimCalorimeterHit> collection : collections)
+         {
+            LCMetaData meta = event.getMetaData(collection);
+            for (SimCalorimeterHit hit : collection)
+            {
+               assertEquals(meta.getIDDecoder(),hit.getIDDecoder());
+               double raw = hit.getRawEnergy();
+               double corrected = hit.getCorrectedEnergy();
+               assertTrue(corrected>raw);
+            }
+         }
+
+      }
+   }
+}
CVSspam 0.2.8