View Javadoc
1   package org.hps.record;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import org.apache.commons.math3.distribution.ChiSquaredDistribution;
7   
8   public class StandardCuts {
9       // max number of hits a track can share with other tracks
10      private int maxSharedHitsPerTrack;
11      // max GBL chisq prob for all tracks 
12      private double maxTrackChisqProb;
13      // max GBL raw chisq for various numbers of hits
14      private Map<Integer, Double> maxTrackChisq;
15      // max (absolute) chisq for track-cluster match for recon particle 
16      private double maxMatchChisq;
17      // max time diff [ns] between track and cluster time for recon particle
18      private double maxMatchDt;
19      // max vertex momentum (magnitude)
20      private double maxVertexP;
21      // max chisq prob for V0 vertex fit
22      private double minVertexChisqProb;
23      // max chisq prob for vertex fit
24      private double minMollerChisqProb;
25      // max time diff [ns] between the two recon particle clusters in vertex
26      private double maxVertexClusterDt;
27      // max momentum for good electron recon particle
28      private double maxElectronP;
29      // min momentum sum of tracks in good Moller vertex
30      private double minMollerP;
31      // max momentum sum of tracks in good Moller vertex
32      private double maxMollerP;
33      // this should be set in data according to beam energy, but may be different in MC
34      private double trackClusterTimeOffset;
35      
36      
37      // members that don't involve chi2 can only be set ONCE
38      private boolean maxElectronPset = false;
39      private boolean minMollerPset = false;
40      private boolean maxMollerPset = false;
41      private boolean maxVertexPset = false;
42      private boolean OffsetSet = false;
43      private boolean maxSharedHitsPerTrackSet = false;
44      private boolean maxMatchDtSet = false;
45      private boolean maxVertexClusterDtSet = false;
46      
47      
48      public double getTrackClusterTimeOffset() {
49          return trackClusterTimeOffset;
50      }
51      
52      public void setTrackClusterTimeOffset(double input) {
53          if (!OffsetSet) {
54              trackClusterTimeOffset = input;
55              OffsetSet = true;
56          }
57      }
58      
59      public void setMaxSharedHitsPerTrack(int input) {
60          if (!maxSharedHitsPerTrackSet) {
61              maxSharedHitsPerTrack = input;
62              maxSharedHitsPerTrackSet = true;
63          }
64      }
65      public int getMaxSharedHitsPerTrack() {
66          return maxSharedHitsPerTrack;
67      }
68      
69      public void setMaxTrackChisq(int nhits, double input) {
70          int dof = nhits*2-5;
71          maxTrackChisq.put(dof, input);
72      }
73      
74      public double getMaxTrackChisq(int nhits) {
75          int dof = nhits*2-5;
76          if (!maxTrackChisq.containsKey(dof)) {
77              maxTrackChisq.put(dof, new ChiSquaredDistribution(dof).inverseCumulativeProbability(1.0-maxTrackChisqProb));
78          }
79          return maxTrackChisq.get(dof);
80      }
81      
82      public void setMaxMatchChisq(double input) {
83          maxMatchChisq = input;
84      }
85      public double getMaxMatchChisq() {
86          return maxMatchChisq;
87      }
88      
89      public void setMaxVertexP(double input) {
90          if (!maxVertexPset) {
91              maxVertexP = input;
92              maxVertexPset = true;
93          }
94      }
95      public double getMaxVertexP() {
96          return maxVertexP;
97      }
98      
99      public void setMinVertexChisqProb(double input) {
100         minVertexChisqProb = input;
101     }
102     public void setMinMollerChisqProb(double input) {
103         minMollerChisqProb = input;
104     }
105     
106     public double getMinVertexChisqProb() {
107         return minVertexChisqProb;
108     }
109     public double getMinMollerChisqProb() {
110         return minMollerChisqProb;
111     }
112     
113     public void setMaxMatchDt(double input) {
114         if (!maxMatchDtSet) {
115             maxMatchDt = input;
116             maxMatchDtSet = true;
117         }
118     }
119     public double getMaxMatchDt() {
120         return maxMatchDt;
121     }
122     
123     public void setMaxVertexClusterDt(double input) {
124         if (!maxVertexClusterDtSet) {
125             maxVertexClusterDt = input;
126             maxVertexClusterDtSet = true;
127         }
128     }
129     public double getMaxVertexClusterDt() {
130         return maxVertexClusterDt;
131     }
132     
133     public void setMaxElectronP(double input) {
134         if (!maxElectronPset) {
135             maxElectronP = input;
136             maxElectronPset = true;
137         }
138     }
139     public double getMaxElectronP() {
140         return maxElectronP;
141     }
142     
143     public void setMaxMollerP(double input) {
144         if (!maxMollerPset) {
145             maxMollerP = input;
146             maxMollerPset = true;
147         }
148     }
149     public double getMaxMollerP() {
150         return maxMollerP;
151     }
152     
153     public void setMinMollerP(double input) {
154         if (!minMollerPset) {
155             minMollerP = input;
156             minMollerPset = true;
157         }
158     }
159     public double getMinMollerP() {
160         return minMollerP;
161     }
162     
163     public StandardCuts(double ebeam) {
164         maxSharedHitsPerTrack = 5;
165         maxMatchChisq = 10.0;
166         maxMatchDt = 6.0;
167         maxVertexClusterDt = 2.0;
168         minVertexChisqProb = 0.00001;
169         minMollerChisqProb = 0.00001;
170         maxTrackChisqProb = 0.00001;
171         
172         maxElectronPset = false;
173         minMollerPset = false;
174         maxMollerPset = false;
175         maxVertexPset = false;
176         OffsetSet = false;
177         
178         maxTrackChisq = new HashMap<Integer, Double>();
179         maxTrackChisq.put(5, new ChiSquaredDistribution(5).inverseCumulativeProbability(1.0-maxTrackChisqProb));
180         maxTrackChisq.put(7, new ChiSquaredDistribution(7).inverseCumulativeProbability(1.0-maxTrackChisqProb));
181         
182         maxElectronP = 0.75*ebeam;
183         minMollerP = 0.8*ebeam;
184         maxMollerP = 1.2*ebeam;
185         maxVertexP = 1.2*ebeam;
186         if (ebeam < 2)
187             trackClusterTimeOffset=43;
188         else
189             trackClusterTimeOffset=55;
190     }
191     
192     public void changeChisqTrackProb(double prob) {        
193         for (int dof : maxTrackChisq.keySet()) {
194             maxTrackChisq.put(dof, new ChiSquaredDistribution(dof).inverseCumulativeProbability(1.0-prob));
195         }
196     }
197     
198     public void changeBeamEnergy(double ebeam) {
199         setMaxElectronP(0.75*ebeam);
200         setMinMollerP(0.8*ebeam);
201         setMaxMollerP(1.2*ebeam);
202         setMaxVertexP(1.2*ebeam);
203         if (ebeam < 2)
204             setTrackClusterTimeOffset(43);
205         else
206             setTrackClusterTimeOffset(55);
207     }
208     
209     public StandardCuts() {
210         this(1.056);
211     }
212 }