hps-java/src/main/java/org/lcsim/hps/users/phansson
diff -u -r1.7 -r1.8
--- ParticleHelixProducer.java 9 Nov 2012 01:46:50 -0000 1.7
+++ ParticleHelixProducer.java 19 Nov 2012 22:20:07 -0000 1.8
@@ -32,7 +32,7 @@
/**
*
* @author phansson
- * @version $Id: ParticleHelixProducer.java,v 1.7 2012/11/09 01:46:50 omoreno Exp $
+ * @version $Id: ParticleHelixProducer.java,v 1.8 2012/11/19 22:20:07 omoreno Exp $
*/
public class ParticleHelixProducer extends Driver {
@@ -144,13 +144,35 @@
if(event.hasCollection(MCParticle.class)) {
List<MCParticle> mcparticles = event.get(MCParticle.class).get(0);
- if(debug) System.out.println(this.getClass().getSimpleName() + ": Number of MC particles = " + mcparticles.size());
List<MCParticle> fsParticles = HPSMCParticlePlotsDriver.makeGenFSParticleList(mcparticles);
- if(debug) System.out.println(this.getClass().getSimpleName()+": Number of FS MC particles = " + fsParticles.size());
+
+ //-----> DEBUG
+ if(debug){
+ String particleList = "[ ";
+ for(MCParticle mcParticle : mcparticles){
+ particleList += mcParticle.getPDGID() + ", ";
+ }
+ particleList += "]";
+ this.printDebug("MC Particles: " + particleList);
+ }
+ if(debug){
+ String particleList = "[ ";
+ for(MCParticle fsParticle : fsParticles){
+ particleList += fsParticle.getPDGID() + ", ";
+ }
+ particleList += "]";
+ this.printDebug("Final State MC Particles: " + particleList);
+ }
+ //------> DEBUG
+
double bfield = Math.abs(_bfield.z()); //remove sign from B-field, assumed to be along z-direction
if(debug) System.out.println(this.getClass().getSimpleName() + ": bfield " + bfield );
+
for(MCParticle part : fsParticles) {
- if(Math.random()>0.5) continue;
+ if(Math.random()>0.5){
+ this.printDebug("Random value below threshold. Skipping the final state MC particle " + part.getPDGID());
+ continue;
+ }
if(ParticleTypeClassifier.isElectron(part.getPDGID()) || ParticleTypeClassifier.isPositron(part.getPDGID())) {
@@ -240,15 +262,16 @@
}
}
}
- else {
- System.out.println(this.getClass().getSimpleName() + ": no MC particles in this event");
+
+ // If there were not HpsHelicalTrackFits created, skip the event
+ if(tracks.isEmpty()){
+ this.printDebug("No tracks were created. Skipping the event ...");
return;
}
- if(debug) System.out.println(this.getClass().getSimpleName() + ": created " + tracks.size() + " MC particle helix tracks");
-
- event.put(this.trackOutputCollectionName, tracks, HpsHelicalTrackFit.class, 0);
- _totalTracks += tracks.size();
+ this.printDebug("created " + tracks.size() + " MC particle helix tracks");
+ event.put(this.trackOutputCollectionName, tracks, HpsHelicalTrackFit.class, 0);
+ _totalTracks += tracks.size();
}
/**
@@ -263,6 +286,16 @@
new HashMap<HelicalTrackHit, Double>(), new HashMap<HelicalTrackHit, MultipleScatter>(), mcParticle);
}
+ /**
+ * print debug statement
+ *
+ * @param debugStatement : debug statement
+ */
+ public void printDebug(String debugStatement){
+ if(!debug) return;
+ System.out.println(this.getClass().getSimpleName() + ": " + debugStatement);
+ }
+
@Override
public void endOfData() {