java/trunk/recon/src/main/java/org/hps/recon/particle
--- java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java 2014-05-06 18:55:25 UTC (rev 556)
+++ java/trunk/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java 2014-05-07 21:42:41 UTC (rev 557)
@@ -181,7 +181,10 @@
// Check if the Ecal cluster and track are within the same
// detector volume i.e. both top or bottom
- if(clusterPosition.y()*track.getTrackStates().get(0).getZ0() < 0) continue;
+ if(clusterPosition.y()*track.getTrackStates().get(0).getZ0() < 0){
+ this.printDebug("Track and Ecal cluster are in opposite volumes. Track Z0 = " + track.getTrackStates().get(0).getZ0());
+ continue;
+ }
// Extrapolate the track to the Ecal cluster position
Hep3Vector trackPosAtEcal = TrackUtils.extrapolateTrack(track, clusterPosition.z());
@@ -223,16 +226,17 @@
}
if(!unmatchedTracks.isEmpty()){
- for(Track track : unmatchedTracks){
+ for(Track unmatchedTrack : unmatchedTracks){
+
// Create a reconstructed particle and add it to the
// collection of particles
ReconstructedParticle particle = new BaseReconstructedParticle();
HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0);
- particle.addTrack(matchedTrack);
- Hep3Vector momentum = new BasicHep3Vector(track.getTrackStates().get(0).getMomentum());
+ particle.addTrack(unmatchedTrack);
+ Hep3Vector momentum = new BasicHep3Vector(unmatchedTrack.getTrackStates().get(0).getMomentum());
((BasicHepLorentzVector) fourVector).setV3(fourVector.t(), momentum);
- ((BaseReconstructedParticle) particle).setCharge(track.getCharge()*flipSign);
+ ((BaseReconstructedParticle) particle).setCharge(unmatchedTrack.getCharge()*flipSign);
((BaseReconstructedParticle) particle).set4Vector(fourVector);
particles.add(particle);
java/trunk/recon/src/test/java/org/hps/recon/particle
--- java/trunk/recon/src/test/java/org/hps/recon/particle/HpsReconParticleDriverTest.java 2014-05-06 18:55:25 UTC (rev 556)
+++ java/trunk/recon/src/test/java/org/hps/recon/particle/HpsReconParticleDriverTest.java 2014-05-07 21:42:41 UTC (rev 557)
@@ -112,10 +112,32 @@
List<HPSEcalCluster> emptyClusters = new ArrayList<HPSEcalCluster>();
particleTracks = particleDriver.makeReconstructedParticles(emptyClusters, tracks);
+ //
+ // The list contains two Tracks which should result in two
+ // ReconstructedParticles.
+ //
assertTrue("More particles than expected were created.", particleTracks.size() == 2);
-
System.out.println("\nThe number of ReconstructedParticles created: " + particleTracks.size());
+
+ for(int particleN = 0; particleN < particleTracks.size(); particleN++){
+ //
+ // Check if the RecontructedParticle track is the same as the track
+ // that created it
+ //
+ assertTrue("The particle track does not match the track that created it",
+ particleTracks.get(particleN).getTracks().get(0).equals(tracks.get(particleN)));
+
+
+ //
+ // Check that the charge of the ReconstructedParticles was set properly
+ //
+ assertTrue("The charge of the ReconstructedParticle is equal to zero.",
+ Math.abs(particleTracks.get(particleN).getCharge()) != 0);
+ System.out.println("The charge of ReconstructedParticle number " + particleN + ": " + particleTracks.get(particleN).getCharge());
+
+ }
+
//
// Check that the momentum of the ReconstructedParticles was set properly
//
@@ -132,15 +154,6 @@
particleTracks.get(1).getMomentum().equals(bottomMomentum));
System.out.println("The momentum of the second ReconstructedParticle: " + particleTracks.get(1).getMomentum().toString());
-
- //
- // Check that the charge of the ReconstructedParticles was set properly
- //
- for(int particleN = 0; particleN < particleTracks.size(); particleN++){
- assertTrue("The charge of the ReconstructedParticle is equal to zero.", Math.abs(particleTracks.get(particleN).getCharge()) != 0);
-
- System.out.println("The charge of ReconstructedParticle number " + particleN + ": " + particleTracks.get(particleN).getCharge());
- }
}