|
1 | 1 | package org.hps.recon.skims; |
| 2 | +import static java.lang.Math.abs; |
2 | 3 |
|
| 4 | +import java.util.List; |
3 | 5 | import java.util.Set; |
| 6 | +import java.io.BufferedReader; |
| 7 | +import java.io.IOException; |
| 8 | +import java.io.InputStream; |
| 9 | +import java.io.InputStreamReader; |
4 | 10 |
|
5 | | -import org.lcsim.event.EventHeader; |
| 11 | +import hep.physics.vec.BasicHep3Vector; |
| 12 | +import hep.physics.vec.Hep3Vector; |
6 | 13 |
|
| 14 | +import org.lcsim.event.EventHeader; |
| 15 | +import org.hps.recon.ecal.cluster.ClusterUtilities; |
| 16 | +import org.hps.recon.particle.ReconParticleDriver; |
| 17 | +import org.hps.recon.tracking.TrackData; |
| 18 | +import org.hps.recon.tracking.TrackType; |
| 19 | +import org.hps.record.epics.EpicsData; |
| 20 | +import org.hps.record.scalers.ScalerData; |
| 21 | +import org.lcsim.event.EventHeader; |
| 22 | +import org.lcsim.event.ReconstructedParticle; |
| 23 | +import org.lcsim.event.Vertex; |
7 | 24 |
|
8 | 25 | public class MollerSkimmer extends Skimmer { |
9 | | - private String _MollerCandidateCollectionName = "UnconstrainedMollerCandidates"; |
10 | | - private double _clusterTimingCut = 20.0; // only used if _tight is true |
11 | | - private double _v0Chi2Cut = 100.0; |
12 | | - private double _trackChi2Cut = 80.0; |
13 | | - private double _trackDtCut = 20.0; |
14 | | - private double _trackPMax = 0.9; |
15 | | - private double _v0PMax = 1.4; |
16 | | - private int _nHitsMin=10; |
17 | | - |
| 26 | + private String _MollerCandidateCollectionName = "UnconstrainedMollerCandidates_KF"; |
| 27 | + private String _MollerVertexCollectionName = "UnconstrainedMollerVertices_KF"; |
| 28 | + private double _vtxChi2Cut = 100.0; |
| 29 | + private double _trackChi2Cut = 30.0; |
| 30 | + private double _trackDtCut = 20.0; |
| 31 | + private int _nHitsMin=9; |
| 32 | + private boolean _debug=false; |
| 33 | + private int totalMollers=0; |
| 34 | + private int totalMollersPassing=0; |
| 35 | + |
18 | 36 | @Override |
19 | 37 | public boolean passSelection(EventHeader event){ |
20 | | - System.out.println(this.getClass().getName()+":: in pass selection"); |
21 | | - boolean pass=true; |
| 38 | + |
| 39 | + if(_debug) |
| 40 | + System.out.println(this.getClass().getName()+":: in pass selection"); |
| 41 | + incrementEventProcessed(); |
22 | 42 |
|
| 43 | + if (!event.hasCollection(ReconstructedParticle.class, _MollerCandidateCollectionName)) { |
| 44 | + return false; |
| 45 | + } |
| 46 | + if (!event.hasCollection(Vertex.class, _MollerVertexCollectionName)) { |
| 47 | + return false; |
| 48 | + } |
| 49 | + |
| 50 | + List<ReconstructedParticle> V0Candidates = event.get(ReconstructedParticle.class, _MollerCandidateCollectionName); |
| 51 | + List<Vertex> V0Vertexes= event.get(Vertex.class, _MollerVertexCollectionName); |
| 52 | + |
| 53 | + if(V0Candidates.size() != V0Vertexes.size()) |
| 54 | + System.out.println(this.getClass().getName()+":: Number of Vertexes = "+V0Vertexes.size()+ |
| 55 | + "; number of candidates = "+V0Candidates.size()); |
| 56 | + |
| 57 | + int nMollers = 0; |
| 58 | + totalMollers += V0Candidates.size(); |
| 59 | + for (ReconstructedParticle v0 : V0Candidates) { |
| 60 | + |
| 61 | + ReconstructedParticle eleTop = v0.getParticles().get(ReconParticleDriver.MOLLER_TOP); |
| 62 | + ReconstructedParticle eleBot = v0.getParticles().get(ReconParticleDriver.MOLLER_BOT); |
| 63 | + |
| 64 | + if (v0.getStartVertex().getChi2() > _vtxChi2Cut) { |
| 65 | + if(_debug)System.out.println(this.getClass().getName()+":: failed vertex chi2"); |
| 66 | + continue; |
| 67 | + } |
| 68 | + if(eleTop.getTracks().get(0).getTrackerHits().size()<_nHitsMin |
| 69 | + || eleBot.getTracks().get(0).getTrackerHits().size()<_nHitsMin){ |
| 70 | + if(_debug)System.out.println(this.getClass().getName()+":: failed nHitsMin "+eleTop.getTracks().get(0).getTrackerHits().size()+" "+eleBot.getTracks().get(0).getTrackerHits().size()+" nHitsMin = "+_nHitsMin); |
| 71 | + continue; |
| 72 | + } |
| 73 | + if ((eleTop.getTracks().get(0).getChi2()/eleTop.getTracks().get(0).getNDF()) > _trackChi2Cut |
| 74 | + || (eleBot.getTracks().get(0).getChi2()/eleBot.getTracks().get(0).getNDF()) > _trackChi2Cut) { |
| 75 | + if(_debug)System.out.println(this.getClass().getName()+":: failed track chi2"); |
| 76 | + continue; |
| 77 | + } |
| 78 | + |
| 79 | + double eleTime = TrackData.getTrackTime(TrackData.getTrackData(event, eleTop.getTracks().get(0))); |
| 80 | + double posTime = TrackData.getTrackTime(TrackData.getTrackData(event, eleBot.getTracks().get(0))); |
| 81 | + if (Math.abs(eleTime - posTime) > _trackDtCut) { |
| 82 | + if(_debug)System.out.println(this.getClass().getName()+":: failed track dt"); |
| 83 | + continue; |
| 84 | + } |
| 85 | + nMollers++; |
| 86 | + totalMollersPassing++; |
| 87 | + } |
| 88 | + |
| 89 | + if (nMollers>0){ |
| 90 | + incrementEventPassed(); |
| 91 | + return true; |
| 92 | + } else |
| 93 | + return false; |
23 | 94 |
|
24 | | - return pass; |
| 95 | + } |
| 96 | + |
| 97 | + public MollerSkimmer(String file) { |
| 98 | + super(file, null); |
| 99 | + } |
| 100 | + public MollerSkimmer(String file, Set<String> ignore) { |
| 101 | + super(file, ignore); |
25 | 102 | } |
26 | 103 |
|
27 | | - |
28 | 104 | @Override |
29 | 105 | public void setParameters(String parsFileName){ |
| 106 | + String infilePreResDir = "/org/hps/recon/skims/"; |
| 107 | + String infile=infilePreResDir+parsFileName; |
| 108 | + InputStream inParamStream = this.getClass().getResourceAsStream(infile); |
| 109 | + System.out.println(this.getClass().getName()+":: reading in Moller skimming cuts from "+infile); |
| 110 | + BufferedReader reader = new BufferedReader(new InputStreamReader(inParamStream)); |
| 111 | + String line; |
| 112 | + String delims = "[ ]+";// this will split strings between one or more spaces |
| 113 | + try { |
| 114 | + while ((line = reader.readLine()) != null) { |
| 115 | + String[] tokens = line.split(delims); |
| 116 | + String parName=tokens[0].replaceAll("\\s+",""); |
| 117 | + System.out.println(this.getClass().getName()+":: parameter name = " + parName + "; value = " + tokens[1]); |
| 118 | + putParam(parName,tokens[1]); |
| 119 | + |
| 120 | + } |
| 121 | + } catch (IOException ex) { |
| 122 | + System.out.println(this.getClass().getName()+":: died while reading parameters"); |
| 123 | + return; |
| 124 | + } |
30 | 125 | return; |
31 | 126 | } |
32 | 127 |
|
33 | | - public MollerSkimmer(String file) { |
34 | | - super(file, null); |
35 | | - // this(super.addFileExtension(file), null); |
| 128 | + |
| 129 | + private void putParam(String parName, String var){ |
| 130 | + if(parName.equals("MollerCandidateCollectionName")) |
| 131 | + _MollerCandidateCollectionName=var; |
| 132 | + else if(parName.equals("vtxChi2Cut")) |
| 133 | + _vtxChi2Cut=Double.parseDouble(var); |
| 134 | + else if(parName.equals("trackChi2Cut")) |
| 135 | + _trackChi2Cut=Double.parseDouble(var); |
| 136 | + else if(parName.equals("trackDtCut")) |
| 137 | + _trackDtCut=Double.parseDouble(var); |
| 138 | + else if(parName.equals("nHitsMin")) |
| 139 | + _nHitsMin=Integer.parseInt(var); |
| 140 | + else |
| 141 | + System.out.println(this.getClass().getName()+":: couldn't find "+parName+"!"); |
36 | 142 | } |
37 | | - public MollerSkimmer(String file, Set<String> ignore) { |
38 | | - super(file, ignore); |
| 143 | + |
| 144 | + public int getTotalMollersPassing(){ |
| 145 | + return totalMollersPassing; |
| 146 | + } |
| 147 | + |
| 148 | + public int getTotalMollers(){ |
| 149 | + return totalMollers; |
| 150 | + } |
| 151 | + |
| 152 | + public void setVtxChi2Cut(double cutVal){ |
| 153 | + this._vtxChi2Cut=cutVal; |
| 154 | + } |
| 155 | + public void setTrackChi2Cut(double cutVal){ |
| 156 | + this._trackChi2Cut=cutVal; |
| 157 | + } |
| 158 | + public void setTrackDtCut(double cutVal){ |
| 159 | + this._trackDtCut=cutVal; |
| 160 | + } |
| 161 | + public void setNHitsMin(int cutVal){ |
| 162 | + this._nHitsMin=cutVal; |
39 | 163 | } |
40 | 164 | } |
0 commit comments