3 added + 8 modified, total 11 files
lcsim/src/org/lcsim/event/util
diff -u -r1.2 -r1.3
--- JetDriver.java 25 Aug 2005 05:54:51 -0000 1.2
+++ JetDriver.java 18 Sep 2007 03:46:26 -0000 1.3
@@ -12,6 +12,7 @@
import java.util.Map;
import org.lcsim.event.EventHeader;
import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Vertex;
import org.lcsim.util.Driver;
import org.lcsim.util.aida.AIDA;
@@ -19,7 +20,7 @@
* A simple driver which can be used to find jets from ReconstructedParticles.
* The resuslting jets are stored in a new collection of ReconstructedParticles.
* @author tonyj
- * @version $Id: JetDriver.java,v 1.2 2005/08/25 05:54:51 tonyj Exp $
+ * @version $Id: JetDriver.java,v 1.3 2007/09/18 03:46:26 tonyj Exp $
*/
public class JetDriver extends Driver
{
@@ -237,5 +238,9 @@
{
return null;
}
+ public Vertex getStartVertex()
+ {
+ return null;
+ }
}
}
lcsim/src/org/lcsim/util/lcio
diff -N SIOVertexBlockHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SIOVertexBlockHandler.java 18 Sep 2007 03:46:26 -0000 1.1
@@ -0,0 +1,70 @@
+package org.lcsim.util.lcio;
+
+import hep.lcd.io.sio.SIOInputStream;
+import hep.lcd.io.sio.SIOOutputStream;
+import hep.lcd.io.sio.SIOWriter;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.Vertex;
+
+/**
+ *
+ * @author tonyj
+ */
+class SIOVertexBlockHandler extends AbstractBlockHandler
+{
+ private static final String ALGORITHM_TYPES = "_lcio.VertexAlgorithmTypes";
+ private static final String PARAMETER_NAMES = "VertexParameterNames";
+
+ private List<String> algorithmTypeKeys = new ArrayList<String>();
+ private List<String> parameterNameKeys = new ArrayList<String>();
+
+ public String getType()
+ {
+ return "Vertex";
+ }
+ public Class getClassForType()
+ {
+ return Vertex.class;
+ }
+ void addCollectionElements(LCIOEvent event, LCIOCollection collection, SIOInputStream in, int n, int version) throws IOException
+ {
+ String[] typeKeys = collection.getParameters().getStringMap().get(ALGORITHM_TYPES);
+ String[] parameterNames = collection.getParameters().getStringMap().get(PARAMETER_NAMES);
+
+ for (int i = 0; i < n; i++)
+ collection.add(new SIOVertex(in, collection.getFlags(), version, typeKeys, parameterNames));
+ }
+ void writeCollectionElement(Object element, SIOOutputStream out, int flags) throws IOException
+ {
+ SIOVertex.write((Vertex) element, out, flags, algorithmTypeKeys, parameterNameKeys);
+ }
+
+ public void writeBlock(SIOWriter writer, List collection, EventHeader.LCMetaData md) throws IOException
+ {
+ Set<String> types = new HashSet<String>();
+ Set<String> names = new HashSet<String>();
+ for (Vertex v : (List<Vertex>) collection)
+ {
+ types.add(v.getAlgorithmType());
+ for (String name : v.getParameters().keySet())
+ {
+ names.add(name);
+ }
+ }
+ algorithmTypeKeys = new ArrayList(types);
+ String[] keyStrings = new String[types.size()];
+ md.getStringParameters().put(ALGORITHM_TYPES,types.toArray(keyStrings));
+
+ parameterNameKeys = new ArrayList(names);
+ String[] nameStrings = new String[names.size()];
+ md.getStringParameters().put(PARAMETER_NAMES,names.toArray(nameStrings));
+
+ super.writeBlock(writer, collection, md);
+ }
+}
lcsim/src/org/lcsim/util/lcio
diff -N SIOVertex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SIOVertex.java 18 Sep 2007 03:46:26 -0000 1.1
@@ -0,0 +1,117 @@
+package org.lcsim.util.lcio;
+
+import hep.lcd.io.sio.SIOInputStream;
+import hep.lcd.io.sio.SIOOutputStream;
+import hep.lcd.io.sio.SIORef;
+import hep.physics.matrix.SymmetricMatrix;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Vertex;
+
+/**
+ *
+ * @author Tony Johnson
+ * @version $Id: SIOVertex.java,v 1.1 2007/09/18 03:46:26 tonyj Exp $
+ */
+class SIOVertex implements Vertex
+{
+ private int primary;
+ private String type;
+ private double chi2;
+ private double probability;
+ private SIORef recPRef;
+ private SymmetricMatrix errorMatrix;
+ private Hep3Vector position;
+ private Map<String,Double> parameters;
+
+ SIOVertex(SIOInputStream in, int flag, int version, String[] keys, String[] parameterNames) throws IOException
+ {
+ this.primary = in.readInt();
+ this.type = keys[in.readInt()];
+ this.chi2 = in.readFloat();
+ this.probability = in.readFloat();
+ this.position = new BasicHep3Vector(in.readFloat(),in.readFloat(),in.readFloat());
+
+ double[] covMatrix = new double[6];
+ for (int i=0; i<covMatrix.length; i++) covMatrix[i] = in.readFloat();
+ errorMatrix = new SymmetricMatrix(3,covMatrix,true);
+ int n = in.readInt();
+ this.parameters = new HashMap<String,Double>(n);
+ for (int i=0; i<n; i++)
+ {
+ Float f = in.readFloat();
+ if (!f.isNaN()) parameters.put(parameterNames[i],Double.valueOf(f));
+ }
+ recPRef = in.readPntr();
+ in.readPTag(this);
+ }
+ static void write(Vertex v, SIOOutputStream out, int flag, List<String> keys, List<String> parameterNames) throws IOException
+ {
+ out.writeInt(v.isPrimary()?1:0);
+ out.writeInt(keys.indexOf(v.getAlgorithmType()));
+
+ out.writeFloat((float) v.getChi2());
+ out.writeFloat((float) v.getProbability());
+ Hep3Vector vec = v.getPosition();
+ out.writeFloat((float) vec.x());
+ out.writeFloat((float) vec.y());
+ out.writeFloat((float) vec.z());
+ double[] covMatrix = v.getCovMatrix().asPackedArray(true);
+ for (int i=0; i<6; i++) out.writeFloat((float) covMatrix[i]);
+ Map<String,Double> pars = v.getParameters();
+ out.writeInt(parameterNames.size());
+ for (String name : parameterNames)
+ {
+ Double d = pars.get(name);
+ out.writeFloat(d==null ? Float.NaN : d.floatValue());
+ }
+ out.writePntr(v.getAssociatedParticle());
+ out.writePTag(v);
+ }
+
+ public boolean isPrimary()
+ {
+ return primary != 0;
+ }
+
+ public String getAlgorithmType()
+ {
+ return type;
+ }
+
+ public double getChi2()
+ {
+ return chi2;
+ }
+
+ public double getProbability()
+ {
+ return probability;
+ }
+
+ public Hep3Vector getPosition()
+ {
+ return position;
+ }
+
+ public SymmetricMatrix getCovMatrix()
+ {
+ return errorMatrix;
+ }
+
+ public Map<String, Double> getParameters()
+ {
+ return parameters;
+ }
+
+ public ReconstructedParticle getAssociatedParticle()
+ {
+ return (ReconstructedParticle) recPRef.getObject();
+ }
+}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.5 -r1.6
--- SIOReconstructedParticle.java 11 Sep 2007 21:01:29 -0000 1.5
+++ SIOReconstructedParticle.java 18 Sep 2007 03:46:26 -0000 1.6
@@ -15,18 +15,20 @@
import org.lcsim.event.ParticleID;
import org.lcsim.event.ReconstructedParticle;
import org.lcsim.event.Track;
+import org.lcsim.event.Vertex;
import org.lcsim.event.base.BaseReconstructedParticle;
/**
*
* @author Tony Johnson
- * @version $Id: SIOReconstructedParticle.java,v 1.5 2007/09/11 21:01:29 tonyj Exp $
+ * @version $Id: SIOReconstructedParticle.java,v 1.6 2007/09/18 03:46:26 tonyj Exp $
*/
class SIOReconstructedParticle extends BaseReconstructedParticle
{
private List<SIORef> tempParticles;
private List<SIORef> tempTracks;
private List<SIORef> tempClusters;
+ private SIORef tempVertex;
SIOReconstructedParticle(SIOInputStream in, int flags, int version) throws IOException
{
@@ -72,8 +74,8 @@
}
if (version > 1007)
{
- // Fixme: This is not currently accessible
- SIORef startVertex = in.readPntr();
+ tempVertex = in.readPntr();
+ _vertex = null;
}
in.readPTag(this);
}
@@ -108,6 +110,7 @@
List<Cluster> clusters = particle.getClusters();
out.writeInt(clusters.size());
for (Cluster cluster : clusters) out.writePntr(cluster);
+ out.writePntr(particle.getStartVertex());
out.writePTag(particle);
}
@@ -143,4 +146,14 @@
}
return _tracks == null ? Collections.<Track>emptyList() : _tracks;
}
+
+ public Vertex getStartVertex()
+ {
+ if (_vertex == null && tempVertex != null)
+ {
+ _vertex = (Vertex) tempVertex.getObject();
+ tempVertex = null;
+ }
+ return super.getStartVertex();
+ }
}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.6 -r1.7
--- AbstractBlockHandler.java 26 Aug 2005 00:26:56 -0000 1.6
+++ AbstractBlockHandler.java 18 Sep 2007 03:46:26 -0000 1.7
@@ -43,7 +43,6 @@
Map<String,int[]> intMap = md.getIntegerParameters();
Map<String,float[]> floatMap = md.getFloatParameters();
Map<String,String[]> stringMap = md.getStringParameters();
- SIOLCParameters colParameters = null;
SIOLCParameters.write(intMap,floatMap,stringMap,out);
out.writeInt(collection.size());
for (Object element : collection)
@@ -53,4 +52,4 @@
out.close();
}
abstract void writeCollectionElement(Object element, SIOOutputStream out, int flags) throws IOException;
-}
\ No newline at end of file
+}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.8 -r1.9
--- LCIOConstants.java 4 Jun 2007 06:50:39 -0000 1.8
+++ LCIOConstants.java 18 Sep 2007 03:46:26 -0000 1.9
@@ -7,7 +7,7 @@
public interface LCIOConstants
{
int MAJORVERSION = 1;
- int MINORVERSION = 7;
+ int MINORVERSION = 8;
// bits in flag words
// SimCalorimeterHit (CH)
lcsim/src/org/lcsim/util/lcio
diff -u -r1.12 -r1.13
--- HandlerManager.java 4 Jun 2007 06:50:39 -0000 1.12
+++ HandlerManager.java 18 Sep 2007 03:46:26 -0000 1.13
@@ -39,6 +39,7 @@
register(new SIORawTrackerHitBlockHandler());
register(new SIOTrackerDataBlockHandler());
register(new SIOTrackerPulseBlockHandler());
+ register(new SIOVertexBlockHandler());
}
static HandlerManager instance()
{
lcsim/src/org/lcsim/event
diff -N Vertex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Vertex.java 18 Sep 2007 03:46:27 -0000 1.1
@@ -0,0 +1,46 @@
+package org.lcsim.event;
+
+import hep.physics.matrix.SymmetricMatrix;
+import hep.physics.vec.Hep3Vector;
+import java.util.Map;
+
+/**
+ * A representation of a vertex
+ * @author tonyj
+ */
+public interface Vertex
+{
+ /** Checks if the Vertex is the primary vertex of the event.
+ * Only one primary vertex per event is allowed
+ */
+ boolean isPrimary();
+
+ /** Type code for the algorithm that has been used to create the vertex - check/set the
+ * collection parameters AlgorithmName and AlgorithmType.
+ */
+ String getAlgorithmType();
+
+ /** Chi squared of the vertex fit.
+ */
+ double getChi2();
+
+ /** Probability of the vertex fit.
+ */
+ double getProbability();
+
+ /** Position of the vertex
+ */
+ Hep3Vector getPosition();
+
+ /** Covariance matrix of the position
+ */
+ SymmetricMatrix getCovMatrix();
+
+ /** Additional parameters related to this vertex.
+ */
+ Map<String,Double> getParameters();
+
+ /** Returns Reconstructed Particle associated to the Vertex
+ */
+ ReconstructedParticle getAssociatedParticle();
+}
lcsim/src/org/lcsim/event
diff -u -r1.2 -r1.3
--- ReconstructedParticle.java 28 Jun 2006 04:48:31 -0000 1.2
+++ ReconstructedParticle.java 18 Sep 2007 03:46:27 -0000 1.3
@@ -7,7 +7,7 @@
/**
* Represents a fully reconstructed particle.
* @author tonyj
- * @version $Id: ReconstructedParticle.java,v 1.2 2006/06/28 04:48:31 jstrube Exp $
+ * @version $Id: ReconstructedParticle.java,v 1.3 2007/09/18 03:46:27 tonyj Exp $
*/
public interface ReconstructedParticle
{
@@ -89,5 +89,10 @@
/**Returns this particles momentum and energy as a four vector
*/
HepLorentzVector asFourVector();
+
+ /**
+ * Returns the start vertex, or <code>null</code> if none is known
+ */
+ public Vertex getStartVertex();
}
lcsim/src/org/lcsim/recon/cheater
diff -u -r1.2 -r1.3
--- CheatReconstructedParticle.java 28 Sep 2005 00:35:50 -0000 1.2
+++ CheatReconstructedParticle.java 18 Sep 2007 03:46:27 -0000 1.3
@@ -21,6 +21,7 @@
import org.lcsim.event.ReconstructedParticle;
import org.lcsim.event.Track;
import org.lcsim.event.MCParticle;
+import org.lcsim.event.Vertex;
import org.lcsim.recon.ztracking.cheater.CheatTrack;
import org.lcsim.recon.cluster.cheat.CheatCluster;
@@ -221,5 +222,10 @@
StringBuffer sb = new StringBuffer("CheatReconstructedParticle: \n");
sb.append("E: "+getEnergy());
return sb.toString();
+ }
+
+ public Vertex getStartVertex()
+ {
+ return null;
}
}
lcsim/src/org/lcsim/mc/fast/reconstructedparticle
diff -u -r1.10 -r1.11
--- MCFastReconstructedParticle.java 16 Feb 2007 01:34:36 -0000 1.10
+++ MCFastReconstructedParticle.java 18 Sep 2007 03:46:27 -0000 1.11
@@ -1,5 +1,6 @@
package org.lcsim.mc.fast.reconstructedparticle;
+import org.lcsim.event.Vertex;
import org.lcsim.mc.fast.MCFast;
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.BasicHepLorentzVector;
@@ -233,4 +234,9 @@
sb.append("E: "+getEnergy());
return sb.toString();
}
+
+ public Vertex getStartVertex()
+ {
+ return null;
+ }
}
CVSspam 0.2.8