Author: [log in to unmask]
Date: Wed May 13 11:10:45 2015
New Revision: 3605
Log:
Revert SIOCluster changes to fix LCIO incompatibility. LCSIM-246
Modified:
projects/lcsim/trunk/event-model/src/main/java/org/lcsim/lcio/SIOCluster.java
Modified: projects/lcsim/trunk/event-model/src/main/java/org/lcsim/lcio/SIOCluster.java
=============================================================================
--- projects/lcsim/trunk/event-model/src/main/java/org/lcsim/lcio/SIOCluster.java (original)
+++ projects/lcsim/trunk/event-model/src/main/java/org/lcsim/lcio/SIOCluster.java Wed May 13 11:10:45 2015
@@ -15,10 +15,9 @@
/**
*
* @author tonyj
- * @author Jeremy McCormick <[log in to unmask]>
*/
-public class SIOCluster implements Cluster {
-
+public class SIOCluster implements Cluster
+{
private final static double[] dummy = new double[6];
private int type;
private float energy;
@@ -36,12 +35,13 @@
private double[] subdetectorEnergies;
private List<SIORef> tempHits;
private List<SIORef> tempClusters;
- private int pid;
-
- SIOCluster(SIOInputStream in, int flag, int version) throws IOException {
+
+ SIOCluster(SIOInputStream in, int flag, int version) throws IOException
+ {
type = in.readInt();
energy = in.readFloat();
- if (version > 1051) {
+ if (version > 1051)
+ {
energyError = in.readFloat();
}
position = new double[3];
@@ -58,25 +58,32 @@
directionError[i] = in.readFloat();
int nShape;
- if (version > 1002) {
+ if (version > 1002)
+ {
nShape = in.readInt();
- } else {
+ }
+ else
+ {
nShape = 6;
}
shape = new double[nShape];
- for (int i = 0; i < nShape; i++) {
+ for (int i = 0; i < nShape; i++)
+ {
shape[i] = in.readFloat();
}
- if (version > 1002) {
- pid = in.readInt();
+ if (version > 1002)
+ {
+ int nPid = in.readInt();
// this.particleIDs = new ArrayList(nPid);
// for (int i=0; i<nPid; i++)
// {
// ParticleID id = new SIOParticleID(in,owner,flag,major,minor);
// particleIDs.add(id);
// }
- } else {
+ }
+ else
+ {
// read 3 dummy floats
float[] particleType = new float[3];
particleType[0] = in.readFloat();
@@ -87,31 +94,38 @@
int nClust = in.readInt();
tempClusters = new ArrayList<SIORef>(nClust);
clusters = null;
- for (int i = 0; i < nClust; i++) {
+ for (int i = 0; i < nClust; i++)
+ {
tempClusters.add(in.readPntr());
}
- if ((flag & (1 << LCIOConstants.CLBIT_HITS)) != 0) {
+ if ((flag & (1 << LCIOConstants.CLBIT_HITS)) != 0)
+ {
int n = in.readInt();
tempHits = new ArrayList<SIORef>(n);
calorimeterHits = null;
this.hitContributions = new double[n];
- for (int i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++)
+ {
tempHits.add(in.readPntr());
hitContributions[i] = in.readFloat();
}
}
int nEnergies = in.readInt();
subdetectorEnergies = new double[nEnergies];
- for (int i = 0; i < nEnergies; i++) {
+ for (int i = 0; i < nEnergies; i++)
+ {
subdetectorEnergies[i] = in.readFloat();
}
in.readPTag(this);
}
- public List<CalorimeterHit> getCalorimeterHits() {
- if (calorimeterHits == null && tempHits != null) {
+ public List<CalorimeterHit> getCalorimeterHits()
+ {
+ if (calorimeterHits == null && tempHits != null)
+ {
calorimeterHits = new ArrayList(tempHits.size());
- for (SIORef ref : tempHits) {
+ for (SIORef ref : tempHits)
+ {
calorimeterHits.add((CalorimeterHit) ref.getObject());
}
tempHits.clear();
@@ -123,10 +137,13 @@
return calorimeterHits;
}
- public List<Cluster> getClusters() {
- if (clusters == null && tempClusters != null) {
+ public List<Cluster> getClusters()
+ {
+ if (clusters == null && tempClusters != null)
+ {
clusters = new ArrayList(tempClusters.size());
- for (SIORef ref : tempClusters) {
+ for (SIORef ref : tempClusters)
+ {
clusters.add((Cluster) ref.getObject());
}
tempClusters.clear();
@@ -135,44 +152,54 @@
return clusters;
}
- public double[] getDirectionError() {
+ public double[] getDirectionError()
+ {
return directionError;
}
/** Return corrected cluster energy */
- public double getEnergy() {
+ public double getEnergy()
+ {
return energy;
}
- public double getEnergyError() {
+ public double getEnergyError()
+ {
return energyError;
}
- public double[] getHitContributions() {
+ public double[] getHitContributions()
+ {
return hitContributions;
}
- public double getIPhi() {
+ public double getIPhi()
+ {
return phi;
}
- public double getITheta() {
+ public double getITheta()
+ {
return theta;
}
- public double[] getPosition() {
+ public double[] getPosition()
+ {
return position;
}
- public double[] getPositionError() {
+ public double[] getPositionError()
+ {
return positionError;
}
- public double[] getShape() {
+ public double[] getShape()
+ {
return shape;
}
- public double[] getSubdetectorEnergies() {
+ public double[] getSubdetectorEnergies()
+ {
return subdetectorEnergies;
}
@@ -180,15 +207,18 @@
* Set the subdetector energy contributions
* @param energies
*/
- public void setSubdetectorEnergies(double[] energies) {
- subdetectorEnergies = energies;
- }
-
- public int getType() {
+ public void setSubdetectorEnergies(double[] energies)
+ {
+ subdetectorEnergies = energies;
+ }
+
+ public int getType()
+ {
return type;
}
- static void write(Cluster cluster, SIOOutputStream out, int flag) throws IOException {
+ static void write(Cluster cluster, SIOOutputStream out, int flag) throws IOException
+ {
out.writeInt(cluster.getType());
out.writeFloat((float) cluster.getEnergy());
out.writeFloat((float) cluster.getEnergyError());
@@ -211,16 +241,20 @@
out.writeFloat((float) p[i]);
p = cluster.getShape();
- if (p == null) {
+ if (p == null)
+ {
out.writeInt(0);
- } else {
+ }
+ else
+ {
out.writeInt(p.length);
- for (int i = 0; i < p.length; i++) {
+ for (int i = 0; i < p.length; i++)
+ {
out.writeFloat((float) p[i]);
}
}
- out.writeInt(cluster.getParticleId());
+ out.writeInt(0);
// List pids = cluster.getParticleIDs() ;
// out.writeInt( pids.size());
// for (Iterator iter = pids.iterator(); iter.hasNext();)
@@ -231,26 +265,33 @@
List<Cluster> clusters = cluster.getClusters();
out.writeInt(clusters.size());
- for (Cluster c : clusters) {
+ for (Cluster c : clusters)
+ {
out.writePntr(c);
}
- if ((flag & (1 << LCIOConstants.CLBIT_HITS)) != 0) {
+ if ((flag & (1 << LCIOConstants.CLBIT_HITS)) != 0)
+ {
List<CalorimeterHit> calorimeterHits = cluster.getCalorimeterHits();
double[] hitContributions = cluster.getHitContributions();
out.writeInt(calorimeterHits.size());
int ii = 0;
- for (CalorimeterHit hit : calorimeterHits) {
+ for (CalorimeterHit hit : calorimeterHits)
+ {
out.writePntr(hit);
out.writeFloat((float) hitContributions[ii++]);
}
}
p = cluster.getSubdetectorEnergies();
- if (p == null) {
+ if (p == null)
+ {
out.writeInt(0);
- } else {
+ }
+ else
+ {
out.writeInt(p.length);
- for (int i = 0; i < p.length; i++) {
+ for (int i = 0; i < p.length; i++)
+ {
out.writeFloat((float) p[i]);
}
}
@@ -258,11 +299,14 @@
}
/**
- * 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.
+ * 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() {
+ public int getSize()
+ {
Set<CalorimeterHit> hitSet = new HashSet<CalorimeterHit>(this.getCalorimeterHits());
- for (Cluster clus : this.getClusters()) {
+ for (Cluster clus : this.getClusters())
+ {
hitSet.addAll(clus.getCalorimeterHits());
}
@@ -275,22 +319,25 @@
/**
* Return the sum of the raw energies from the hits in the cluster
*/
- public double getRawEnergy() {
+ public double getRawEnergy()
+ {
if (raw_energy > 0)
return raw_energy;
Set<CalorimeterHit> hitSet = new HashSet<CalorimeterHit>(this.getCalorimeterHits());
- for (Cluster clus : this.getClusters()) {
+ for (Cluster clus : this.getClusters())
+ {
hitSet.addAll(clus.getCalorimeterHits());
}
- for (CalorimeterHit hit : hitSet) {
+ for (CalorimeterHit hit : hitSet)
+ {
raw_energy += hit.getRawEnergy();
}
return raw_energy;
}
public int getParticleId() {
- return pid;
+ return 0;
}
}
########################################################################
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1
|