Commit in lcsim/src/org/lcsim/util/lcio on MAIN
SIOCalorimeterHit.java+74added 1.1
SIOCalorimeterHitBlockHandler.java+32added 1.1
+106
2 added files
GL: Add support for CalorimeterHits

lcsim/src/org/lcsim/util/lcio
SIOCalorimeterHit.java added at 1.1
diff -N SIOCalorimeterHit.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SIOCalorimeterHit.java	20 Jul 2005 21:11:06 -0000	1.1
@@ -0,0 +1,74 @@
+package org.lcsim.util.lcio;
+
+import hep.lcd.io.sio.SIOInputStream;
+import hep.lcd.io.sio.SIOOutputStream;
+
+import java.io.IOException;
+import org.lcsim.event.CalorimeterHit;
+
+/**
+ * SIO-based I/O implementation of the CalorimeterHit interface
+ *
+ * @author Guilherme Lima
+ * @version $Id: SIOCalorimeterHit.java,v 1.1 2005/07/20 21:11:06 lima Exp $
+ */
+class SIOCalorimeterHit implements CalorimeterHit
+{
+   private int _cellid0;
+   private int _cellid1;
+   private float _energy;
+   private float _time;
+
+   SIOCalorimeterHit(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();
+      _time = in.readFloat();
+
+//       if (!LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_NO_PTR)) 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();
+      out.writeInt( (int)cellID );
+      if( LCIOUtil.bitTest( flags, LCIOConstants.CHBIT_ID1)) {
+	  out.writeInt((int) (cellID>>32));
+      }
+
+      out.writeFloat( (float)hit.getEnergy() );
+      out.writeFloat( (float)hit.getTime() );
+
+//       if(!LCIOUtil.bitTest(flags,LCIOConstants.CHBIT_NO_PTR)) {
+// 	  out.writePTag( hit );
+//       }
+   }
+}

lcsim/src/org/lcsim/util/lcio
SIOCalorimeterHitBlockHandler.java added at 1.1
diff -N SIOCalorimeterHitBlockHandler.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SIOCalorimeterHitBlockHandler.java	20 Jul 2005 21:11:06 -0000	1.1
@@ -0,0 +1,32 @@
+package org.lcsim.util.lcio;
+
+import hep.lcd.io.sio.SIOInputStream;
+import hep.lcd.io.sio.SIOOutputStream;
+import java.io.IOException;
+
+import org.lcsim.event.CalorimeterHit;
+
+/**
+ * Block handler for calorimeter hits.
+ *
+ * @author Guilherme Lima
+ * @version $Id: SIOCalorimeterHitBlockHandler.java,v 1.1 2005/07/20 21:11:06 lima Exp $
+ */
+class SIOCalorimeterHitBlockHandler extends AbstractBlockHandler
+{
+    public String getType() { return "CalorimeterHit"; }
+    public Class getClassForType() { return CalorimeterHit.class; }
+    public void addCollectionElements(LCIOCollection collection,
+				      SIOInputStream in, int n, int version)
+	throws IOException
+    {
+      for (int i = 0; i < n; i++)
+	collection.add(new SIOCalorimeterHit(in, collection.getFlags(), version));
+    }
+
+    void writeCollectionElement(Object element, SIOOutputStream out, int flags)
+	throws IOException
+    {
+	SIOCalorimeterHit.write((CalorimeterHit) element, out, flags);
+    }
+}
CVSspam 0.2.8