java/trunk/recon/src/main/java/org/hps/recon/particle
--- java/trunk/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java 2014-06-04 01:37:17 UTC (rev 660)
+++ java/trunk/recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java 2014-06-04 01:43:16 UTC (rev 661)
@@ -28,36 +28,33 @@
*/
public class HpsReconParticleDriver extends ReconParticleDriver {
- public HpsReconParticleDriver(){}
+ private enum Constraint {
+ UNCONSTRAINED,
+ BS_CONSTRAINED,
+ TARGET_CONSTRAINED
+ }
+
+ public HpsReconParticleDriver(){}
@Override
protected void startOfData(){
unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates";
beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
- targetV0ConCandidatesColName = "TargetConstrainedV0Candidates";
+ targetConV0CandidatesColName = "TargetConstrainedV0Candidates";
+ unconstrainedV0VerticesColName = "UnconstrainedV0Vertices";
+ beamConV0VerticesColName = "BeamspotConstrainedV0Vertices";
+ targetConV0VerticesColName = "TargetConstrainedV0Vertices";
}
/**
*
*/
@Override
- void vertexParticles(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons) {
+ void findVertices(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons) {
- BilliorVertexer unconstrainedVtxFitter = new BilliorVertexer(bField);
- unconstrainedVtxFitter.doBeamSpotConstraint(false);
- unconstrainedVtxFitter.setBeamSize(beamsize);
-
-
- BilliorVertexer beamConVtxFitter = new BilliorVertexer(bField);
- beamConVtxFitter.doBeamSpotConstraint(true);
- beamConVtxFitter.setBeamSize(beamsize);
-
- BilliorVertexer targetConVtxFitter = new BilliorVertexer(bField);
- targetConVtxFitter.doTargetConstraint(true);
- targetConVtxFitter.setBeamSize(beamsize);
-
ReconstructedParticle candidate = null;
+ BilliorVertex vtxFit = null;
// Loop through both electrons and positrons and try to find a common vertex
for(ReconstructedParticle positron : positrons){
for(ReconstructedParticle electron : electrons){
@@ -70,76 +67,90 @@
BilliorTrack electronBTrack = toBilliorTrack(electronTrack);
BilliorTrack positronBTrack = toBilliorTrack(positronTrack);
- List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
- billiorTracks.add(electronBTrack);
- billiorTracks.add(positronBTrack);
+ for(Constraint constraint : Constraint.values()){
+
+ vtxFit = fitVertex(constraint, electronBTrack, positronBTrack);
- BilliorVertex vtxFit = unconstrainedVtxFitter.fitVertex(billiorTracks);
- BilliorVertex vtxFitCon = beamConVtxFitter.fitVertex(billiorTracks);
- BilliorVertex vtxFitTarget = targetConVtxFitter.fitVertex(billiorTracks);
-
- candidate = new BaseReconstructedParticle();
- ((BaseReconstructedParticle) candidate).setStartVertex(vtxFit);
- candidate.addParticle(electron);
- candidate.addParticle(positron);
- // TODO: The calculation of the total fitted momentum should be done within
- // BilloirVertex
- ((BaseReconstructedParticle) candidate).setMass(vtxFit.getParameters().get("invMass"));
- Hep3Vector fittedMomentum = new BasicHep3Vector(vtxFit.getParameters().get("p1X"),
- vtxFit.getParameters().get("p1Y"),
- vtxFit.getParameters().get("p1Z"));
- fittedMomentum = VecOp.add(fittedMomentum, new BasicHep3Vector(vtxFit.getParameters().get("p2X"),
- vtxFit.getParameters().get("p2Y"),
- vtxFit.getParameters().get("p2Z")));
- this.printDebug("Fitted momentum in tracking frame: " + fittedMomentum.toString());
- fittedMomentum = CoordinateTransformations.transformVectorToDetector(fittedMomentum);
- this.printDebug("Fitted momentum in detector frame: " + fittedMomentum.toString());
- HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0);
- ((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), fittedMomentum);
- ((BaseReconstructedParticle) candidate).set4Vector(fourVector);
- unconstrainedV0Candidates.add(candidate);
-
- candidate = new BaseReconstructedParticle();
- ((BaseReconstructedParticle) candidate).setStartVertex(vtxFitCon);
- candidate.addParticle(electron);
- candidate.addParticle(positron);
- ((BaseReconstructedParticle) candidate).setMass(vtxFitCon.getParameters().get("invMass"));
- fittedMomentum = new BasicHep3Vector(vtxFitCon.getParameters().get("p1X"),
- vtxFitCon.getParameters().get("p1Y"),
- vtxFitCon.getParameters().get("p1Z"));
- fittedMomentum = VecOp.add(fittedMomentum, new BasicHep3Vector(vtxFitCon.getParameters().get("p2X"),
- vtxFitCon.getParameters().get("p2Y"),
- vtxFitCon.getParameters().get("p2Z")));
- this.printDebug("Fitted momentum in tracking frame: " + fittedMomentum.toString());
- fittedMomentum = CoordinateTransformations.transformVectorToDetector(fittedMomentum);
- this.printDebug("Fitted momentum in detector frame: " + fittedMomentum.toString());
- fourVector = new BasicHepLorentzVector(0, 0, 0, 0);
- ((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), fittedMomentum);
- ((BaseReconstructedParticle) candidate).set4Vector(fourVector);
- beamConV0Candidates.add(candidate);
-
- candidate = new BaseReconstructedParticle();
- ((BaseReconstructedParticle) candidate).setStartVertex(vtxFitTarget);
- candidate.addParticle(electron);
- candidate.addParticle(positron);
- ((BaseReconstructedParticle) candidate).setMass(vtxFitTarget.getParameters().get("invMass"));
- fittedMomentum = new BasicHep3Vector(vtxFitTarget.getParameters().get("p1X"),
- vtxFitTarget.getParameters().get("p1Y"),
- vtxFitTarget.getParameters().get("p1Z"));
- fittedMomentum = VecOp.add(fittedMomentum, new BasicHep3Vector(vtxFitTarget.getParameters().get("p2X"),
- vtxFitTarget.getParameters().get("p2Y"),
- vtxFitTarget.getParameters().get("p2Z")));
- this.printDebug("Fitted momentum in tracking frame: " + fittedMomentum.toString());
- fittedMomentum = CoordinateTransformations.transformVectorToDetector(fittedMomentum);
- this.printDebug("Fitted momentum in detector frame: " + fittedMomentum.toString());
- fourVector = new BasicHepLorentzVector(0, 0, 0, 0);
- ((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), fittedMomentum);
- ((BaseReconstructedParticle) candidate).set4Vector(fourVector);
- targetConV0Candidates.add(candidate);
-
+ candidate = makeReconstructedParticle(electron, positron, vtxFit);
+
+
+ switch(constraint){
+ case UNCONSTRAINED:
+ unconstrainedV0Vertices.add(vtxFit);
+ unconstrainedV0Candidates.add(candidate);
+ break;
+ case BS_CONSTRAINED:
+ beamConV0Vertices.add(vtxFit);
+ beamConV0Candidates.add(candidate);
+ break;
+ case TARGET_CONSTRAINED:
+ targetConV0Vertices.add(vtxFit);
+ targetConV0Candidates.add(candidate);
+ break;
+ }
+ }
}
}
}
+
+ /**
+ *
+ */
+ BilliorVertex fitVertex(Constraint constraint, BilliorTrack electron, BilliorTrack positron){
+
+ BilliorVertexer vtxFitter = new BilliorVertexer(bField);
+ // TODO: The beam size should come from the conditions database
+ vtxFitter.setBeamSize(beamsize);
+
+ switch(constraint){
+ case UNCONSTRAINED:
+ vtxFitter.doBeamSpotConstraint(false);
+ break;
+ case BS_CONSTRAINED:
+ vtxFitter.doBeamSpotConstraint(true);
+ break;
+ case TARGET_CONSTRAINED:
+ vtxFitter.doTargetConstraint(true);
+ break;
+ }
+
+ List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
+ billiorTracks.add(electron);
+ billiorTracks.add(positron);
+
+ return vtxFitter.fitVertex(billiorTracks);
+ }
+
+ /**
+ *
+ */
+ ReconstructedParticle makeReconstructedParticle(ReconstructedParticle electron, ReconstructedParticle positron, BilliorVertex vtxFit){
+
+ ReconstructedParticle candidate = new BaseReconstructedParticle();
+ ((BaseReconstructedParticle) candidate).setStartVertex(vtxFit);
+ candidate.addParticle(electron);
+ candidate.addParticle(positron);
+
+ // TODO: The calculation of the total fitted momentum should be done within
+ // BilloirVertex
+ ((BaseReconstructedParticle) candidate).setMass(vtxFit.getParameters().get("invMass"));
+ Hep3Vector fittedMomentum = new BasicHep3Vector(vtxFit.getParameters().get("p1X"),
+ vtxFit.getParameters().get("p1Y"),
+ vtxFit.getParameters().get("p1Z"));
+ fittedMomentum = VecOp.add(fittedMomentum, new BasicHep3Vector(vtxFit.getParameters().get("p2X"),
+ vtxFit.getParameters().get("p2Y"),
+ vtxFit.getParameters().get("p2Z")));
+ this.printDebug("Fitted momentum in tracking frame: " + fittedMomentum.toString());
+ fittedMomentum = CoordinateTransformations.transformVectorToDetector(fittedMomentum);
+ this.printDebug("Fitted momentum in detector frame: " + fittedMomentum.toString());
+ HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0);
+ ((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), fittedMomentum);
+ ((BaseReconstructedParticle) candidate).set4Vector(fourVector);
+
+ return candidate;
+
+ }
+
/**
*
java/trunk/recon/src/main/java/org/hps/recon/particle
--- java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java 2014-06-04 01:37:17 UTC (rev 660)
+++ java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java 2014-06-04 01:43:16 UTC (rev 661)
@@ -12,6 +12,7 @@
import org.lcsim.event.EventHeader;
import org.lcsim.event.ReconstructedParticle;
import org.lcsim.event.Track;
+import org.lcsim.event.Vertex;
import org.lcsim.event.base.BaseReconstructedParticle;
import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;
@@ -39,6 +40,9 @@
List<ReconstructedParticle> targetConV0Candidates;
List<ReconstructedParticle> electrons;
List<ReconstructedParticle> positrons;
+ List<Vertex> unconstrainedV0Vertices;
+ List<Vertex> beamConV0Vertices;
+ List<Vertex> targetConV0Vertices;
// Collections
String ecalClustersCollectionName = "EcalClusters";
@@ -46,10 +50,13 @@
String finalStateParticlesColName = "FinalStateParticles";
String unconstrainedV0CandidatesColName = null;
String beamConV0CandidatesColName = null;
- String targetV0ConCandidatesColName = null;
+ String targetConV0CandidatesColName = null;
String vertexCandidatesColName = null;
String vertexBeamConsCandidatesName = null;
-
+ String unconstrainedV0VerticesColName = null;
+ String beamConV0VerticesColName = null;
+ String targetConV0VerticesColName = null;
+
// The beamsize array is in the tracking frame
/* TODO mg-May 14, 2014: the the beam size from the conditions db...also beam position! */
double[] beamsize = {0.001, 0.2, 0.02};
@@ -105,8 +112,8 @@
// All events should have a collection of Ecal clusters. If the event
// doesn't have one, skip the event.
- if (!event.hasCollection(HPSEcalCluster.class, ecalClustersCollectionName))
- return;
+ if (!event.hasCollection(HPSEcalCluster.class, ecalClustersCollectionName))
+ return;
// Get the collection of Ecal clusters from the event. A triggered
// event should have Ecal clusters. If it doesn't, skip the event.
@@ -124,6 +131,9 @@
unconstrainedV0Candidates = new ArrayList<ReconstructedParticle>();
beamConV0Candidates = new ArrayList<ReconstructedParticle>();
targetConV0Candidates = new ArrayList<ReconstructedParticle>();
+ unconstrainedV0Vertices = new ArrayList<Vertex>();
+ beamConV0Vertices = new ArrayList<Vertex>();
+ targetConV0Vertices = new ArrayList<Vertex>();
//
finalStateParticles = this.makeReconstructedParticles(clusters, tracks);
@@ -136,33 +146,46 @@
// charged particles to either electrons or positrons. These lists
// will be used for vertexing purposes.
for (ReconstructedParticle finalStateParticle : finalStateParticles) {
- this.printDebug("\t\tThis Charge = " + finalStateParticle.getCharge());
- if (finalStateParticle.getCharge() > 0)
- positrons.add(finalStateParticle);
- else if (finalStateParticle.getCharge() < 0)
- electrons.add(finalStateParticle);
+ if (finalStateParticle.getCharge() > 0) positrons.add(finalStateParticle);
+ else if (finalStateParticle.getCharge() < 0) electrons.add(finalStateParticle);
}
this.printDebug("Number of Electrons: " + electrons.size());
this.printDebug("Number of Positrons: " + positrons.size());
+
// Vertex electron and positron candidates
- vertexParticles(electrons, positrons);
+ findVertices(electrons, positrons);
- // If the list exist, put the vertexed candidates into the event
- if (unconstrainedV0CandidatesColName != null)
+ // If the list exist, put the vertexed candidates and vertices into the event
+ if (unconstrainedV0CandidatesColName != null){
this.printDebug("Total number of unconstrained V0 candidates: " + unconstrainedV0Candidates.size());
- event.put(unconstrainedV0CandidatesColName, unconstrainedV0Candidates, ReconstructedParticle.class, 0);
- if (beamConV0CandidatesColName != null)
+ event.put(unconstrainedV0CandidatesColName, unconstrainedV0Candidates, ReconstructedParticle.class, 0);
+ }
+ if (beamConV0CandidatesColName != null){
this.printDebug("Total number of beam constrained V0 candidates: " + unconstrainedV0Candidates.size());
- event.put(beamConV0CandidatesColName, beamConV0Candidates, ReconstructedParticle.class, 0);
- if (targetV0ConCandidatesColName != null)
+ event.put(beamConV0CandidatesColName, beamConV0Candidates, ReconstructedParticle.class, 0);
+ }
+ if (targetConV0CandidatesColName != null){
this.printDebug("Total number of target constrained V0 candidates: " + unconstrainedV0Candidates.size());
- event.put(targetV0ConCandidatesColName, targetConV0Candidates, ReconstructedParticle.class, 0);
+ event.put(targetConV0CandidatesColName, targetConV0Candidates, ReconstructedParticle.class, 0);
+ }
+ if(unconstrainedV0VerticesColName != null){
+ this.printDebug("Total number of unconstrained V0 vertices: " + unconstrainedV0Vertices.size());
+ event.put(unconstrainedV0VerticesColName, unconstrainedV0Vertices, Vertex.class, 0);
+ }
+ if(beamConV0VerticesColName != null){
+ this.printDebug("Total number of beam constrained V0 vertices: " + beamConV0Vertices.size());
+ event.put(beamConV0VerticesColName, beamConV0Vertices, Vertex.class, 0);
+ }
+ if(targetConV0VerticesColName != null){
+ this.printDebug("Total number of target constrained V0 vertices: " + beamConV0Vertices.size());
+ event.put(targetConV0VerticesColName, targetConV0Vertices, Vertex.class, 0);
+ }
}
/**
*
*/
- abstract void vertexParticles(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons);
+ abstract void findVertices(List<ReconstructedParticle> electrons, List<ReconstructedParticle> positrons);
/**
* make the final state particles from clusters & tracks