Author: [log in to unmask] Date: Wed Sep 9 11:32:36 2015 New Revision: 3561 Log: First pass at a Driver to skim Møller candidates. Work in progress to tighten cuts. Added: java/trunk/analysis/src/main/java/org/hps/analysis/skim/ java/trunk/analysis/src/main/java/org/hps/analysis/skim/StripMollerEventsDriver.java - copied, changed from r3560, java/trunk/analysis/src/main/java/org/hps/analysis/examples/StripMollerEventsDriver.java Copied: java/trunk/analysis/src/main/java/org/hps/analysis/skim/StripMollerEventsDriver.java (from r3560, java/trunk/analysis/src/main/java/org/hps/analysis/examples/StripMollerEventsDriver.java) ============================================================================= --- java/trunk/analysis/src/main/java/org/hps/analysis/examples/StripMollerEventsDriver.java (original) +++ java/trunk/analysis/src/main/java/org/hps/analysis/skim/StripMollerEventsDriver.java Wed Sep 9 11:32:36 2015 @@ -12,12 +12,10 @@ /** * Class to strip off Moller candidates - * Currently defined as: - * e- e- events - * non-full-energy electrons - * momentum sum between 0.85 and 1.3 GeV - * six-hit tracks and - * nothing else in the event + * Currently defined as: + * e- e- events + * non-full-energy electrons, E < fullEnergyCut [0.85 GeV] + * momentum sum between molPSumMin [0.85 GeV] and molPSumMax [1.3 GeV] * * @author Norman A Graf * @@ -26,76 +24,80 @@ public class StripMollerEventsDriver extends Driver { - private String finalStateParticlesColName = "FinalStateParticles"; + private String finalStateParticlesColName = "TargetConstrainedMollerCandidates"; private int _numberOfEventsWritten = 0; - + private int _numberOfEventsProcessed = 0; private boolean debug; double molPSumMin = 0.85; double molPSumMax = 1.3; - double beambeamCut = 0.85; + double fullEnergyCut = 0.85; @Override protected void process(EventHeader event) { boolean skipEvent = true; + _numberOfEventsProcessed++; if (event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) { - List<ReconstructedParticle> finalStateParticles = event.get(ReconstructedParticle.class, finalStateParticlesColName); - if (debug) { - System.out.println("This events has " + finalStateParticles.size() + " final state particles"); + List<ReconstructedParticle> mollerCandidates = event.get(ReconstructedParticle.class, finalStateParticlesColName); + if (mollerCandidates.size() > 0) { + if (debug) { + System.out.println("This events has " + mollerCandidates.size() + " Møller Candidates"); + } + for (ReconstructedParticle rp : mollerCandidates) { + System.out.println("Moller candidate: " + rp); + } + skipEvent = false; } - // require two and only two ReconstructedParticles - // require no other tracks in the event - // require no other clusters in the event - if (finalStateParticles.size() == 2 - && event.get(Track.class, "MatchedTracks").size() == 2 - && event.get(Cluster.class, "EcalClustersGTP").size() == 2) { - // at this point we should have two and only two good particles in the event - // let's see what they are... - ReconstructedParticle ele1 = null; - ReconstructedParticle ele2 = null; - int sumCharge = 0; - int numChargedParticles = 0; - for (ReconstructedParticle fsPart : finalStateParticles) { - if (debug) { - System.out.println("PDGID = " + fsPart.getParticleIDUsed() + "; charge = " + fsPart.getCharge() + "; pz = " + fsPart.getMomentum().x()); - } - double charge = fsPart.getCharge(); - sumCharge += charge; - if (charge != 0) { - numChargedParticles++; - if (charge < 1) { - if (ele1 == null) { - ele1 = fsPart; - } else { - ele2 = fsPart; - } - } - } - } - - if (ele1 != null && ele2 != null) { - Hep3Vector p1 = ele1.getMomentum(); - Hep3Vector p2 = ele2.getMomentum(); - Hep3Vector beamAxis = new BasicHep3Vector(Math.sin(0.0305), 0, Math.cos(0.0305)); - double theta1 = Math.acos(VecOp.dot(p1, beamAxis) / p1.magnitude()); - double theta2 = Math.acos(VecOp.dot(p2, beamAxis) / p2.magnitude()); - //look at "Moller" events (if that's what they really are) - if (ele1.getMomentum().magnitude() + ele2.getMomentum().magnitude() > molPSumMin - && ele1.getMomentum().magnitude() + ele2.getMomentum().magnitude() < molPSumMax - && (p1.magnitude() < beambeamCut && p2.magnitude() < beambeamCut)) { - - // require that both tracks have six hits - Track ele1trk = ele1.getTracks().get(0); - Track ele2trk = ele2.getTracks().get(0); - if (ele1trk.getTrackerHits().size() == 6 - && ele2trk.getTrackerHits().size() == 6) { - // OK. we should be golden here - skipEvent = false; - } - } - } - } +// if (mollerCandidates.size() == 2 +// && event.get(Track.class, "MatchedTracks").size() == 2 +// && event.get(Cluster.class, "EcalClustersGTP").size() == 2) { +// // at this point we should have two and only two good particles in the event +// // let's see what they are... +// ReconstructedParticle ele1 = null; +// ReconstructedParticle ele2 = null; +// int sumCharge = 0; +// int numChargedParticles = 0; +// for (ReconstructedParticle fsPart : mollerCandidates) { +// if (debug) { +// System.out.println("PDGID = " + fsPart.getParticleIDUsed() + "; charge = " + fsPart.getCharge() + "; pz = " + fsPart.getMomentum().x()); +// } +// double charge = fsPart.getCharge(); +// sumCharge += charge; +// if (charge != 0) { +// numChargedParticles++; +// if (charge < 1) { +// if (ele1 == null) { +// ele1 = fsPart; +// } else { +// ele2 = fsPart; +// } +// } +// } +// } +// +// if (ele1 != null && ele2 != null) { +// Hep3Vector p1 = ele1.getMomentum(); +// Hep3Vector p2 = ele2.getMomentum(); +// Hep3Vector beamAxis = new BasicHep3Vector(Math.sin(0.0305), 0, Math.cos(0.0305)); +// double theta1 = Math.acos(VecOp.dot(p1, beamAxis) / p1.magnitude()); +// double theta2 = Math.acos(VecOp.dot(p2, beamAxis) / p2.magnitude()); +// //look at "Moller" events (if that's what they really are) +// if (ele1.getMomentum().magnitude() + ele2.getMomentum().magnitude() > molPSumMin +// && ele1.getMomentum().magnitude() + ele2.getMomentum().magnitude() < molPSumMax +// && (p1.magnitude() < fullEnergyCut && p2.magnitude() < fullEnergyCut)) { +// +// // require that both tracks have six hits +// Track ele1trk = ele1.getTracks().get(0); +// Track ele2trk = ele2.getTracks().get(0); +// if (ele1trk.getTrackerHits().size() == 6 +// && ele2trk.getTrackerHits().size() == 6) { +// // OK. we should be golden here +// skipEvent = false; +// } +// } +// } +// } } if (skipEvent) { @@ -106,17 +108,9 @@ } } - private double getMomentum(Track trk) - { - double px = trk.getTrackStates().get(0).getMomentum()[0]; - double py = trk.getTrackStates().get(0).getMomentum()[1]; - double pz = trk.getTrackStates().get(0).getMomentum()[2]; - return Math.sqrt(px * px + py * py + pz * pz); - } - @Override protected void endOfData() { - System.out.println("Wrote " + _numberOfEventsWritten + " events"); + System.out.println("Wrote " + _numberOfEventsWritten + " Møller candidate events out of "+_numberOfEventsProcessed+" events processed"); } }