Commit in lcsim/src/org/lcsim on MAIN
event/MCCluster.java+15added 1.1
recon/cluster/util/BasicCluster.java+2-21.11 -> 1.12
util/lcio/SIOMCClusterBlockHandler.java+27added 1.1
         /SIOMCCluster.java+41added 1.1
         /HandlerManager.java+3-21.7 -> 1.8
         /SIOCluster.java+23-231.3 -> 1.4
+111-27
3 added + 3 modified, total 6 files
GL: Make MCClusters persistable

lcsim/src/org/lcsim/event
MCCluster.java added at 1.1
diff -N MCCluster.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MCCluster.java	20 Feb 2006 22:24:56 -0000	1.1
@@ -0,0 +1,15 @@
+package org.lcsim.event;
+import java.util.List;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.MCParticle;
+
+/** The LCIO MC cluster.
+ *
+ * @author Guilherme Lima
+ * @version $Id: MCCluster.java,v 1.1 2006/02/20 22:24:56 lima Exp $
+ */
+
+public interface MCCluster extends Cluster
+{
+    public MCParticle getMCParticle();
+}

lcsim/src/org/lcsim/recon/cluster/util
BasicCluster.java 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- BasicCluster.java	16 Feb 2006 19:56:01 -0000	1.11
+++ BasicCluster.java	20 Feb 2006 22:24:56 -0000	1.12
@@ -21,8 +21,8 @@
     protected List<CalorimeterHit> hits = new ArrayList<CalorimeterHit>();
     protected List<Cluster> clusters = new ArrayList<Cluster>();
     protected List<Subdetector> detectors = new ArrayList<Subdetector>();
-    public double raw_energy;
-    public double corrected_energy;
+    protected double raw_energy;
+    protected double corrected_energy;
     protected double[] subdetector_raw_energies = new double[10];
     protected double[] subdetector_corrected_energies = new double[10];
     protected List<Double> hit_energies = new ArrayList<Double>();

lcsim/src/org/lcsim/util/lcio
SIOMCClusterBlockHandler.java added at 1.1
diff -N SIOMCClusterBlockHandler.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SIOMCClusterBlockHandler.java	20 Feb 2006 22:24:57 -0000	1.1
@@ -0,0 +1,27 @@
+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.MCCluster;
+
+/**
+ * Block handler for Monte Carlo clusters
+ * @author Guilherme Lima
+ */
+class SIOMCClusterBlockHandler extends AbstractBlockHandler
+{
+   public String getType() { return "MCCluster"; }
+   public Class getClassForType() { return MCCluster.class; }
+   void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+   {
+      for (int i = 0; i < n; i++)
+         collection.add(new SIOMCCluster(in, collection.getFlags(), version));
+   }
+
+   void writeCollectionElement(Object element, SIOOutputStream out, int flags) throws IOException
+   {
+       SIOMCCluster.write((MCCluster) element, out, flags);
+   }
+}

lcsim/src/org/lcsim/util/lcio
SIOMCCluster.java added at 1.1
diff -N SIOMCCluster.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SIOMCCluster.java	20 Feb 2006 22:24:57 -0000	1.1
@@ -0,0 +1,41 @@
+package org.lcsim.util.lcio;
+
+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.MCParticle;
+import org.lcsim.event.MCCluster;
+
+/**
+ * Class used to read MCClusters from persistent media
+ * @author Guilherme Lima
+ */
+public class SIOMCCluster extends SIOCluster implements MCCluster
+{
+    private MCParticle _mcparticle = null;
+    private SIORef _tempMCParticle = null;
+
+    SIOMCCluster(SIOInputStream in, int flag, int version) throws IOException {
+	super(in,flag,version);
+	// read MCParticle pointer
+	_tempMCParticle = in.readPntr();
+    }
+
+    public MCParticle getMCParticle() {
+	if(_mcparticle==null) {
+	    _mcparticle = (MCParticle)_tempMCParticle.getObject();
+	}
+	return _mcparticle;
+    }
+
+    static void write(MCCluster cluster, SIOOutputStream out, int flag) throws IOException
+    {
+	// stream out the base class first
+	SIOCluster.write(cluster,out,flag);
+	// then the MCParticle
+	MCParticle mcp = cluster.getMCParticle();
+	out.writePntr( mcp );
+    }
+}

lcsim/src/org/lcsim/util/lcio
HandlerManager.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- HandlerManager.java	9 Aug 2005 01:34:01 -0000	1.7
+++ HandlerManager.java	20 Feb 2006 22:24:57 -0000	1.8
@@ -26,6 +26,7 @@
       register(new SIOSimCalorimeterHitBlockHandler());
       register(new SIOSimTrackerHitBlockHandler());
       register(new SIOMCParticleBlockHandler());
+      register(new SIOMCClusterBlockHandler());
       register(new SIOClusterBlockHandler());
       register(new SIOTPCHitBlockHandler());
       register(new SIOTrackerHitBlockHandler());
@@ -47,12 +48,12 @@
    LCIOBlockHandler handlerForClass(Class type)
    {
       LCIOBlockHandler handler = handlerForClass.get(type);
-      
+
       if (handler == null)
       {
          for (LCIOBlockHandler h : handlerForType.values())
          {
-            if (h.getClassForType().isAssignableFrom(type)) 
+            if (h.getClassForType().isAssignableFrom(type))
             {
                handler = h;
                handlerForClass.put(type,h);

lcsim/src/org/lcsim/util/lcio
SIOCluster.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SIOCluster.java	20 Feb 2006 22:12:52 -0000	1.3
+++ SIOCluster.java	20 Feb 2006 22:24:57 -0000	1.4
@@ -33,7 +33,7 @@
    private double[] subdetectorEnergies;
    private List<SIORef> tempHits;
    private List<SIORef> tempClusters;
-   
+
    SIOCluster(SIOInputStream in, int flag, int version) throws IOException
    {
       type = in.readInt();
@@ -62,7 +62,7 @@
       {
          shape[i] = in.readFloat();
       }
-      
+
       if( version > 1002)
       {
          int nPid = in.readInt() ;
@@ -81,7 +81,7 @@
          particleType[1] = in.readFloat();
          particleType[2] = in.readFloat();
       }
-      
+
       int nClust = in.readInt();
       tempClusters = new ArrayList<SIORef>(nClust);
       clusters = null;
@@ -109,7 +109,7 @@
       }
       in.readPTag(this);
    }
-   
+
    public List<CalorimeterHit> getCalorimeterHits()
    {
       if (calorimeterHits == null && tempHits != null)
@@ -120,10 +120,10 @@
             calorimeterHits.add((CalorimeterHit) ref.getObject());
          }
          tempHits = null;
-      } 
+      }
       return calorimeterHits;
    }
-   
+
    public List<Cluster> getClusters()
    {
       if (clusters == null && tempClusters != null)
@@ -137,53 +137,53 @@
       }
       return clusters;
    }
-   
+
    public double[] getDirectionError()
    {
       return directionError;
    }
-   
+
     /** Return corrected cluster energy */
    public double getEnergy()
    {
       return energy;
    }
-   
+
    public double[] getHitContributions()
    {
       return hitContributions;
    }
-   
+
    public double getIPhi()
    {
       return phi;
    }
-   
+
    public double getITheta()
    {
       return theta;
    }
-   
+
    public double[] getPosition()
    {
       return position;
    }
-   
+
    public double[] getPositionError()
    {
       return positionError;
    }
-   
+
    public double[] getShape()
    {
       return shape;
    }
-   
+
    public double[] getSubdetectorEnergies()
    {
       return subdetectorEnergies;
    }
-   
+
    public int getType()
    {
       return type;
@@ -203,7 +203,7 @@
       p = cluster.getDirectionError();
       if (p == null) p = dummy;
       for (int i=0; i<3; i++) out.writeFloat((float) p[i]);
-      
+
       p = cluster.getShape();
       if (p == null) {
 	  out.writeInt(0);
@@ -215,7 +215,7 @@
 	     out.writeFloat((float) p[i]);
 	 }
       }
-      
+
       out.writeInt(0);
       //List pids = cluster.getParticleIDs() ;
       //out.writeInt( pids.size());
@@ -224,14 +224,14 @@
       //   ParticleID pid = (ParticleID) iter.next();
       //   SIOParticleID.write(pid,out);
       //}
-      
+
       List<Cluster> clusters = cluster.getClusters();
       out.writeInt(clusters.size());
       for (Cluster c : clusters)
       {
          out.writePntr(c);
       }
-      
+
       if ((flag & (1<<LCIOConstants.CLBIT_HITS)) != 0)
       {
          List<CalorimeterHit> calorimeterHits = cluster.getCalorimeterHits();
@@ -258,9 +258,9 @@
       out.writePTag(cluster);
    }
 
-    /** Return the hits comprising the cluster, including hits in
-     * subclusters, as per interface.  Hits belonging to more than one
-     * cluster/subcluster should be counted only once.
+    /** Return the number of hits comprising the cluster, including
+     * hits in subclusters, as per interface.  Hits belonging to more
+     * than one cluster/subcluster should be counted only once.
      */
     public int getSize()
     {
CVSspam 0.2.8