4 modified files
lcsim/src/org/lcsim/recon/pfa/identifier
diff -u -r1.5 -r1.6
--- MIPChargedParticleMaker.java 4 Apr 2007 17:18:57 -0000 1.5
+++ MIPChargedParticleMaker.java 16 May 2007 21:25:43 -0000 1.6
@@ -15,7 +15,10 @@
import org.lcsim.geometry.Detector;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.recon.cluster.util.ClusterEnergyCalculator;
-
+import hep.physics.particle.properties.ParticleType;
+import org.lcsim.event.ParticleID;
+import org.lcsim.event.base.BaseParticleID;
+import hep.physics.particle.properties.ParticlePropertyManager;
/**
* Given a list of MIP clusters and a list of tracks,
@@ -32,7 +35,7 @@
* then the entire cluster is added to the ReconstructedParticle instead.
* The parent must be unique.
*
- * @version $Id: MIPChargedParticleMaker.java,v 1.5 2007/04/04 17:18:57 mcharles Exp $
+ * @version $Id: MIPChargedParticleMaker.java,v 1.6 2007/05/16 21:25:43 mcharles Exp $
*/
public class MIPChargedParticleMaker extends Driver
@@ -155,26 +158,22 @@
// Now that we have the track:cluster association, make output
// particles. We have to watch for the special case where >1 track
// is matched to a cluster.
- Map<Cluster,LocalReconstructedParticle> matchedClusters = new HashMap<Cluster,LocalReconstructedParticle> ();
+ Map<Cluster,BaseReconstructedParticle> matchedClusters = new HashMap<Cluster,BaseReconstructedParticle> ();
for (Track tr : matchedTracks.keySet()) {
Cluster clus = matchedTracks.get(tr);
- if (matchedClusters.keySet().contains(clus)) {
- // Already used this cluster in a particle => just add the track to that particle
- LocalReconstructedParticle part = matchedClusters.get(clus);
- part.addTrack(tr);
- part.recomputeKinematics();
- } else {
+ if ( ! matchedClusters.keySet().contains(clus)) {
// This cluster hasn't been used yet -- initialize its particle
- LocalReconstructedParticle part = new LocalReconstructedParticle();
- part.addTrack(tr);
+ BaseReconstructedParticle part = new BaseReconstructedParticle();
part.addCluster(clus);
- part.recomputeKinematics();
matchedClusters.put(clus, part);
}
+ BaseReconstructedParticle part = matchedClusters.get(clus);
+ part.addTrack(tr);
+ recomputeKinematics(part);
}
if (m_checkEoverP) {
- for (LocalReconstructedParticle part : matchedClusters.values()) {
+ for (BaseReconstructedParticle part : matchedClusters.values()) {
boolean energyOK = checkEoverP(part);
if (energyOK) {
outputParticleList.add(part);
@@ -247,55 +246,7 @@
protected String m_outputParticleListName;
protected Map<String,String> m_clusterLists;
- // Really, this belongs in a central implementation.
- // It may change at any time (hence private).
- private class LocalReconstructedParticle extends BaseReconstructedParticle
- {
- public void setEnergy(double e) {
- super.set4Vector(new BasicHepLorentzVector(e,_fourVec.v3()));
- }
- public void setMomentum(Hep3Vector p3) {
- super.set4Vector(new BasicHepLorentzVector(_fourVec.t(),p3));
- }
- public void setReferencePoint(Hep3Vector p3) {
- _referencePoint = new BasicHep3Vector(p3.x(), p3.y(), p3.z());
- }
- public void setCharge(double q) {
- _charge = q;
- }
- public void recomputeKinematics() {
- double energy = 0.0;
- int charge = 0;
- double px = 0.0;
- double py = 0.0;
- double pz = 0.0;
- for (Track tr : this.getTracks()) {
- double[] trackMomentum = tr.getMomentum();
- double trackMomentumMagSq = (trackMomentum[0]*trackMomentum[0] + trackMomentum[1]*trackMomentum[1] + trackMomentum[2]*trackMomentum[2]);
- double mass = 0.140;
- Particle truthParticle = null;
- if (tr instanceof ReconTrack) {
- truthParticle = ((ReconTrack)(tr)).getMCParticle();
- } else if (tr instanceof CheatTrack) {
- truthParticle = ((CheatTrack)(tr)).getMCParticle();
- }
- if (truthParticle != null) {
- mass = truthParticle.getMass();
- }
- double trackEnergy = Math.sqrt(trackMomentumMagSq + mass*mass);
- energy += trackEnergy;
- charge += tr.getCharge();
- px += trackMomentum[0];
- py += trackMomentum[1];
- pz += trackMomentum[2];
- }
- this.setEnergy(energy);
- this.setCharge(charge);
- this.setMomentum(new BasicHep3Vector(px,py,pz));
- }
- }
-
- protected boolean checkEoverP(LocalReconstructedParticle part) {
+ protected boolean checkEoverP(BaseReconstructedParticle part) {
// We don't expect an exact match due to resolution, energy lost
// to fragments etc., but a good portion of the energy should be
// in the cluster
@@ -336,4 +287,57 @@
private double estimateClusterEnergy(Cluster clus) {
return m_calib.getEnergy(clus);
}
+
+ // This particle has >= 1 track.
+ // Recompute its 4-vector and mass.
+ protected void recomputeKinematics(BaseReconstructedParticle part) {
+ if (part.getTracks().size() < 1 ) { throw new AssertionError("Charged particle with no tracks: internal consistency failure."); }
+ double energy = 0.0;
+ int charge = 0;
+ double px = 0.0;
+ double py = 0.0;
+ double pz = 0.0;
+ Particle firstTruthParticle = null;
+ for (Track tr : part.getTracks()) {
+ double[] trackMomentum = tr.getMomentum();
+ double trackMomentumMagSq = (trackMomentum[0]*trackMomentum[0] + trackMomentum[1]*trackMomentum[1] + trackMomentum[2]*trackMomentum[2]);
+ double mass = 0.140;
+ Particle truthParticle = null;
+ if (tr instanceof ReconTrack) {
+ truthParticle = ((ReconTrack)(tr)).getMCParticle();
+ } else if (tr instanceof CheatTrack) {
+ truthParticle = ((CheatTrack)(tr)).getMCParticle();
+ }
+ if (truthParticle != null) {
+ mass = truthParticle.getMass();
+ if (firstTruthParticle == null) { firstTruthParticle = truthParticle; }
+ }
+ double trackEnergy = Math.sqrt(trackMomentumMagSq + mass*mass);
+ energy += trackEnergy;
+ charge += tr.getCharge();
+ px += trackMomentum[0];
+ py += trackMomentum[1];
+ pz += trackMomentum[2];
+ }
+ Hep3Vector threeMomentum = new BasicHep3Vector(px,py,pz);
+ HepLorentzVector fourMomentum = new BasicHepLorentzVector(energy, threeMomentum);
+ part.setCharge(charge);
+ part.set4Vector(fourMomentum);
+ part.setMass(fourMomentum.magnitude());
+ if (part.getTracks().size() == 1) {
+ // Unique track => PID etc somewhat well-defined
+ ParticleType type = null;
+ if (firstTruthParticle != null) {
+ type = firstTruthParticle.getType();
+ } else {
+ int pdg = 211 * charge; // everything is a pion
+ type = ParticlePropertyManager.getParticlePropertyProvider().get(pdg);
+ }
+ part.setParticleIdUsed(new BaseParticleID(type));
+ part.setReferencePoint(new BasicHep3Vector(part.getTracks().get(0).getReferencePoint()));
+ } else {
+ // Multiple tracks => some quantities not well-defined
+ // Leave at defaults.
+ }
+ }
}
lcsim/src/org/lcsim/recon/pfa/identifier
diff -u -r1.9 -r1.10
--- SimpleChargedParticleMaker.java 4 Apr 2007 17:18:57 -0000 1.9
+++ SimpleChargedParticleMaker.java 16 May 2007 21:25:43 -0000 1.10
@@ -18,6 +18,10 @@
import org.lcsim.mc.fast.tracking.ReconTrack;
import org.lcsim.event.base.BaseReconstructedParticle;
import org.lcsim.recon.ztracking.cheater.CheatTrack;
+import hep.physics.particle.properties.ParticleType;
+import org.lcsim.event.ParticleID;
+import org.lcsim.event.base.BaseParticleID;
+import hep.physics.particle.properties.ParticlePropertyManager;
/**
* Given lists of clusters and tracks, make a list of charged
@@ -25,7 +29,7 @@
*
* Currently, PID is done by cheating.
*
- * @version $Id: SimpleChargedParticleMaker.java,v 1.9 2007/04/04 17:18:57 mcharles Exp $
+ * @version $Id: SimpleChargedParticleMaker.java,v 1.10 2007/05/16 21:25:43 mcharles Exp $
*/
public class SimpleChargedParticleMaker extends Driver
@@ -67,22 +71,19 @@
// Now, we need to make output particles for the tracks.
// We have to watch out for the special cases where:
// >1 track is matched to a cluster
- Map<Cluster,LocalReconstructedParticle> matchedClusters = new HashMap<Cluster,LocalReconstructedParticle> ();
+ Map<Cluster,BaseReconstructedParticle> matchedClusters = new HashMap<Cluster,BaseReconstructedParticle> ();
for (Track tr : matchedTracks.keySet()) {
Cluster clus = matchedTracks.get(tr);
- if (matchedClusters.keySet().contains(clus)) {
- // Already used this cluster in a particle => just add the track to that particle
- LocalReconstructedParticle part = matchedClusters.get(clus);
- part.addTrack(tr);
- part.recomputeKinematics();
- } else {
+ if ( ! matchedClusters.keySet().contains(clus)) {
// This cluster hasn't been used yet -- initialize its particle
- LocalReconstructedParticle part = new LocalReconstructedParticle();
- part.addTrack(tr);
+ BaseReconstructedParticle part = new BaseReconstructedParticle();
part.addCluster(clus);
- part.recomputeKinematics();
matchedClusters.put(clus, part);
}
+ // Now update the particle for the track:
+ BaseReconstructedParticle part = matchedClusters.get(clus);
+ part.addTrack(tr);
+ recomputeKinematics(part);
}
outputParticleList.addAll(matchedClusters.values());
@@ -105,52 +106,58 @@
String m_inputClusterListName;
String m_outputParticleListName;
- // This should be replaced by a central implementation
- private class LocalReconstructedParticle extends BaseReconstructedParticle
- {
- public void setEnergy(double e) {
- super.set4Vector(new BasicHepLorentzVector(e,_fourVec.v3()));
- }
- public void setMomentum(Hep3Vector p3) {
- super.set4Vector(new BasicHepLorentzVector(_fourVec.t(),p3));
- }
- public void setReferencePoint(Hep3Vector p3) {
- _referencePoint = new BasicHep3Vector(p3.x(), p3.y(), p3.z());
- }
- public void setCharge(double q) {
- _charge = q;
- }
- public void recomputeKinematics() {
- double energy = 0.0;
- int charge = 0;
- double px = 0.0;
- double py = 0.0;
- double pz = 0.0;
- for (Track tr : this.getTracks()) {
- double[] trackMomentum = tr.getMomentum();
- double trackMomentumMagSq = (trackMomentum[0]*trackMomentum[0] + trackMomentum[1]*trackMomentum[1] + trackMomentum[2]*trackMomentum[2]);
- double mass = 0.140;
- Particle truthParticle = null;
- if (tr instanceof ReconTrack) {
- truthParticle = ((ReconTrack)(tr)).getMCParticle();
- } else if (tr instanceof CheatTrack) {
- truthParticle = ((CheatTrack)(tr)).getMCParticle();
- }
- if (truthParticle != null) {
- mass = truthParticle.getMass();
- }
- double trackEnergy = Math.sqrt(trackMomentumMagSq + mass*mass);
- energy += trackEnergy;
- charge += tr.getCharge();
- px += trackMomentum[0];
- py += trackMomentum[1];
- pz += trackMomentum[2];
+ // This particle has >= 1 track.
+ // Recompute its 4-vector and mass.
+ protected void recomputeKinematics(BaseReconstructedParticle part) {
+ if (part.getTracks().size() < 1 ) { throw new AssertionError("Charged particle with no tracks: internal consistency failure."); }
+ double energy = 0.0;
+ int charge = 0;
+ double px = 0.0;
+ double py = 0.0;
+ double pz = 0.0;
+ Particle firstTruthParticle = null;
+ for (Track tr : part.getTracks()) {
+ double[] trackMomentum = tr.getMomentum();
+ double trackMomentumMagSq = (trackMomentum[0]*trackMomentum[0] + trackMomentum[1]*trackMomentum[1] + trackMomentum[2]*trackMomentum[2]);
+ double mass = 0.140;
+ Particle truthParticle = null;
+ if (tr instanceof ReconTrack) {
+ truthParticle = ((ReconTrack)(tr)).getMCParticle();
+ } else if (tr instanceof CheatTrack) {
+ truthParticle = ((CheatTrack)(tr)).getMCParticle();
+ }
+ if (truthParticle != null) {
+ mass = truthParticle.getMass();
+ if (firstTruthParticle == null) { firstTruthParticle = truthParticle; }
}
- this.setEnergy(energy);
- this.setCharge(charge);
- this.setMomentum(new BasicHep3Vector(px,py,pz));
+ double trackEnergy = Math.sqrt(trackMomentumMagSq + mass*mass);
+ energy += trackEnergy;
+ charge += tr.getCharge();
+ px += trackMomentum[0];
+ py += trackMomentum[1];
+ pz += trackMomentum[2];
+ }
+ Hep3Vector threeMomentum = new BasicHep3Vector(px,py,pz);
+ HepLorentzVector fourMomentum = new BasicHepLorentzVector(energy, threeMomentum);
+ part.setCharge(charge);
+ part.set4Vector(fourMomentum);
+ part.setMass(fourMomentum.magnitude());
+ if (part.getTracks().size() == 1) {
+ // Unique track => PID etc somewhat well-defined
+ ParticleType type = null;
+ if (firstTruthParticle != null) {
+ type = firstTruthParticle.getType();
+ } else {
+ int pdg = 211 * charge; // everything is a pion
+ type = ParticlePropertyManager.getParticlePropertyProvider().get(pdg);
+ }
+ part.setParticleIdUsed(new BaseParticleID(type));
+ part.setReferencePoint(new BasicHep3Vector(part.getTracks().get(0).getReferencePoint()));
+ } else {
+ // Multiple tracks => some quantities not well-defined
+ // Leave at defaults.
}
- }
+ }
}
lcsim/src/org/lcsim/recon/pfa/identifier
diff -u -r1.6 -r1.7
--- SimpleNeutralParticleMaker.java 11 Feb 2007 17:12:53 -0000 1.6
+++ SimpleNeutralParticleMaker.java 16 May 2007 21:25:43 -0000 1.7
@@ -5,11 +5,15 @@
import hep.physics.vec.BasicHep3Vector;
import hep.physics.vec.VecOp;
import hep.physics.vec.BasicHepLorentzVector;
+import hep.physics.vec.HepLorentzVector;
import hep.physics.particle.properties.ParticlePropertyProvider;
import hep.physics.particle.properties.ParticlePropertyManager;
import hep.physics.particle.properties.ParticleType;
import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.base.BaseReconstructedParticle;
import org.lcsim.event.EventHeader;
+import org.lcsim.event.ParticleID;
+import org.lcsim.event.base.BaseParticleID;
import org.lcsim.util.Driver;
import org.lcsim.event.Cluster;
import org.lcsim.event.base.BaseReconstructedParticle;
@@ -17,12 +21,13 @@
import org.lcsim.geometry.Detector;
import org.lcsim.event.MCParticle;
import org.lcsim.recon.cluster.util.ClusterEnergyCalculator;
+
/**
* Given lists of clusters, make a list of neutral ReconstructedParticles.
*
* Currently, PID is predetermined.
*
- * @version $Id: SimpleNeutralParticleMaker.java,v 1.6 2007/02/11 17:12:53 cassell Exp $
+ * @version $Id: SimpleNeutralParticleMaker.java,v 1.7 2007/05/16 21:25:43 mcharles Exp $
*/
public class SimpleNeutralParticleMaker extends Driver
@@ -45,6 +50,7 @@
ParticlePropertyProvider mgr = ParticlePropertyManager.getParticlePropertyProvider();
ParticleType type = mgr.get(pdg);
m_mass = type.getMass();
+ m_id = new BaseParticleID(type);
}
// Process one event
@@ -57,16 +63,21 @@
List<ReconstructedParticle> outputParticleList = new Vector<ReconstructedParticle>();
for (Cluster clus : inputClusterList) {
- LocalReconstructedParticle part = new LocalReconstructedParticle();
+ // Create the particle
+ BaseReconstructedParticle part = new BaseReconstructedParticle();
part.addCluster(clus);
- double clusterEnergy = estimateClusterEnergy(clus); // clumsy, not a real calibration...
- double particleEnergy = Math.sqrt(clusterEnergy*clusterEnergy + m_mass*m_mass);
- part.setEnergy(particleEnergy);
+ // The cluster energy now includes, at a crude level, the particle mass.
+ double clusterEnergy = estimateClusterEnergy(clus);
+ Hep3Vector threeMomentum = computeMomentum(clusterEnergy, clus);
// Set the other particle properties that are needed to render
// properly in the event display.
- part.setMomentum(computeMomentum(particleEnergy, clus));
- part.setReferencePoint(new BasicHep3Vector(0,0,0));
+ HepLorentzVector fourMomentum = new BasicHepLorentzVector(clusterEnergy, threeMomentum);
+ part.set4Vector(fourMomentum);
+ part.setReferencePoint(0,0,0);
part.setCharge(0);
+ // Set the PID and mass
+ part.setParticleIdUsed(m_id);
+ part.setMass(m_mass);
// Add to the output list
outputParticleList.add(part);
}
@@ -81,33 +92,21 @@
// Now, what's the momentum?
// p^2 = E^2 - m^2
double momentumSquared = energy*energy - m_mass*m_mass;
- double momentumMagnitude = Math.sqrt(momentumSquared); // may complain if -ve...
+ if (momentumSquared < 0) {
+ // A low-energy cluster that we think came from a
+ // massive particle -- it must be very soft.
+ // Treat as zero momentum.
+ momentumSquared = 0;
+ }
+ double momentumMagnitude = Math.sqrt(momentumSquared);
Hep3Vector momentum = VecOp.mult(momentumMagnitude, unitDirection);
return momentum;
}
- String m_inputClusterListName;
- String m_outputParticleListName;
- double m_mass;
-
- // This should be replaced by a central implementation
- class LocalReconstructedParticle extends BaseReconstructedParticle
- {
- public void setEnergy(double e) {
- super.set4Vector(new BasicHepLorentzVector(e,_fourVec.v3()));
- }
- public void setMomentum(Hep3Vector p3) {
- super.set4Vector(new BasicHepLorentzVector(_fourVec.t(),p3));
- }
- public void setReferencePoint(Hep3Vector p3) {
- _referencePoint = new BasicHep3Vector(p3.x(), p3.y(), p3.z());
- }
- public void setCharge(double q) {
- _charge = q;
- }
- }
-
- // What is the energy of the cluster?
+ protected String m_inputClusterListName;
+ protected String m_outputParticleListName;
+ protected double m_mass;
+ protected ParticleID m_id = null;
protected ClusterEnergyCalculator m_calib = null;
protected double estimateClusterEnergy(Cluster clus) {
lcsim/src/org/lcsim/recon/pfa/identifier
diff -u -r1.2 -r1.3
--- SmallPhotonMaker.java 26 Apr 2007 17:21:32 -0000 1.2
+++ SmallPhotonMaker.java 16 May 2007 21:25:43 -0000 1.3
@@ -3,6 +3,8 @@
import java.util.*;
import hep.physics.vec.Hep3Vector;
import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.BasicHepLorentzVector;
+import hep.physics.vec.HepLorentzVector;
import org.lcsim.recon.cluster.structural.FragmentIdentifier;
import org.lcsim.event.EventHeader;
import org.lcsim.util.Driver;
@@ -12,6 +14,7 @@
import org.lcsim.event.ReconstructedParticle;
import org.lcsim.event.MCParticle;
import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.base.BaseReconstructedParticle;
/**
* Given a list of clusters, make ones that are consistent with
@@ -48,15 +51,15 @@
CalorimeterHit firstHitInECAL = findInnermostHitInECAL(clus);
boolean isPhoton = (firstHitInECAL!=null && getLayer(firstHitInECAL)<4);
if (isPhoton) {
- LocalReconstructedParticle part = new LocalReconstructedParticle();
+ BaseReconstructedParticle part = new BaseReconstructedParticle();
part.addCluster(clus);
- double clusterEnergy = estimateClusterEnergy(clus); // clumsy, not a real calibration...
- double particleEnergy = Math.sqrt(clusterEnergy*clusterEnergy + m_mass*m_mass);
- part.setEnergy(particleEnergy);
+ double clusterEnergy = estimateClusterEnergy(clus);
+ Hep3Vector threeMomentum = computeMomentum(clusterEnergy, clus);
// Set the other particle properties that are needed to render
// properly in the event display.
- part.setMomentum(computeMomentum(particleEnergy, clus));
- part.setReferencePoint(new BasicHep3Vector(0,0,0));
+ HepLorentzVector fourMomentum = new BasicHepLorentzVector(clusterEnergy, threeMomentum);
+ part.set4Vector(fourMomentum);
+ part.setReferencePoint(0,0,0);
part.setCharge(0);
// Add to the output list
outputParticleList.add(part);
CVSspam 0.2.8