ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/LeptonSelection/src/MuonSelection.cc
Revision: 1.3
Committed: Wed Feb 29 10:10:18 2012 UTC (13 years, 2 months ago) by anlevin
Content type: text/plain
Branch: MAIN
Changes since 1.2: +58 -0 lines
Log Message:
added a backdoor muon selection and a preselection that automatically passes

File Contents

# User Rev Content
1 khahn 1.1 #include <math.h>
2     #include <iostream>
3    
4     #include "HiggsAnaDefs.hh"
5    
6     #include "MuonSelection.h"
7     #include "ParseArgs.h"
8     #include "SelectionStatus.h"
9    
10 anlevin 1.3 SelectionStatus noPreSelection( ControlFlags &ctrl, const mithep::TMuon * mu ) {
11     SelectionStatus status;
12     status.setStatus(SelectionStatus::PRESELECTION);
13     if(ctrl.debug) cout << "muon presel returning status : " << status.getStatus() << endl;
14     return status;
15     }
16 khahn 1.1
17     SelectionStatus muonPreSelection( ControlFlags &ctrl, const mithep::TMuon * mu ) {
18     if(ctrl.debug) cout << "inside muonpresel ... " << endl;
19     bool ret = isMuFO(mu);
20     if(ctrl.debug) cout << "iS fo? ... " << ret << endl;
21 khahn 1.2 ret &= ( fabs(mu->ip3dSig) < 4 );
22 khahn 1.1 if(ctrl.debug) cout << "and pass IP (" << mu->ip3dSig << ") ? ... " << ret << endl;
23 khahn 1.2 ret &= ( mu->pt > 5 );
24 khahn 1.1 if(ctrl.debug) cout << "and >5 GeV ? ... " << ret << endl;
25 khahn 1.2 ret &= ( fabs(mu->eta) < 2.4 );
26 khahn 1.1 if(ctrl.debug) cout << "and < 2.4 eta ? ... " << ret << endl;
27    
28     SelectionStatus status;
29     if( ret ) status.setStatus(SelectionStatus::PRESELECTION);
30     if(ctrl.debug) cout << "muon presel returning status : " << status.getStatus() << endl;
31     return status;
32     }
33    
34     bool isMuFO( const mithep::TMuon * mu ) {
35     bool isgood=true;
36     float reliso = mu->pfIso03/mu->pt;
37    
38     if( mu->pt < 5 ) isgood=false;
39     if ( fabs(mu->dz) > 0.2 ) isgood=false; // needed to remove cosmics in HF sample
40    
41     //
42    
43     // HF seems to not want tkquality, SS does
44     if( mu->pt>20 ) {
45     if ( !((mu->typeBits & kGlobal) && mu->nSeg>0 ) ) isgood=false; //&& mu->nValidHits>0
46     } else {
47     if ( !((mu->typeBits & kGlobal) && mu->nSeg>0 ) //&& //&& mu->nValidHits>0
48     && !( (mu->typeBits & kTracker) && (mu->qualityBits & kTMOneStationLoose)
49     )
50     ) isgood=false;
51     }
52    
53    
54     //
55     // for HF MC to agree w/ data, cannot put any Tk quality bits
56     // but to get to 5% closure in the SS test, we need at least Tk oneStationLoose
57    
58     /*
59     && ( (mu->qualityBits & kTMOneStationLoose) ||
60     (mu->qualityBits & kTMLastStationOptimizedBarrelLowPtLoose) ||
61     (mu->qualityBits & kTMLastStationOptimizedLowPtLoose)
62     )
63     */
64    
65    
66     // comment for more stats for mu fake shape
67     if( mu->pt < 20 ) {
68     if( reliso > 3 ) isgood=false;
69     } else {
70     if( reliso > 5 ) isgood=false;
71     }
72    
73     return isgood;
74     };
75    
76    
77     SelectionStatus passSoftMuonSelection( ControlFlags &ctrl, const mithep::TMuon * mu ) {
78    
79     int level=0;
80     unsigned failmask=0x0;
81    
82     if(mu->nTkHits < 11 )
83     failmask |= (1<<level);
84     level++;
85    
86     if(fabs(mu->d0) > 0.2)
87     failmask |= (1<<level);
88     level++;
89    
90     if(fabs(mu->dz) > 0.1)
91     failmask |= (1<<level);
92     level++;
93    
94     if(!(mu->typeBits & kTracker))
95     failmask |= (1<<level);
96     level++;
97    
98     if(!(mu->qualityBits & kTMLastStationAngTight))
99     failmask |= (1<<level);
100     level++;
101    
102     Double_t iso = (mu->trkIso03 + mu->emIso03 + mu->hadIso03)/mu->pt;
103     if(mu->pt>20 && iso<0.1)
104     failmask |= (1<<level);
105    
106     bool passtight = !(failmask);
107     bool passloose = !(failmask);
108     return SelectionStatus( passtight | passloose );
109    
110     }
111    
112    
113     //unsigned passMuonSelectionZZ( const mithep::TMuon * mu ) {
114     SelectionStatus passMuonSelectionZZ( ControlFlags &ctrl, const mithep::TMuon * mu ) {
115     int level=0;
116     unsigned failmask=0x0;
117    
118     if(mu->pt < 5) {
119     failmask |= (1<<level);
120     }
121    
122     level++;
123     if(fabs(mu->eta) > 2.4) {
124     failmask |= (1<<level);
125     }
126    
127     level++;
128     if(!(mu->typeBits & kGlobal)) {
129     failmask |= (1<<level);
130     }
131    
132     level++;
133     if(mu->nTkHits < 10) {
134     failmask |= (1<<level);
135     }
136    
137    
138     level++;
139     if( (mu->trkIso03/mu->pt) > 0.7 ) {
140     failmask |= (1<<level);
141     }
142    
143     // if(muon->nPixHits < 1) return false;
144     // if(muon->muNchi2 > 10) return false;
145     // if(muon->nMatch < 2) return false;
146     // if(muon->nValidHits < 1) return false;
147     // if(muon->pterr/muon->pt > 0.1) return false;
148     // if(fabs(muon->dz) > 0.1) return false;
149    
150     SelectionStatus status;
151     if( !failmask ) status.setStatus(SelectionStatus::LOOSEID);
152     if( !failmask ) status.setStatus(SelectionStatus::TIGHTID);
153     return status;
154    
155    
156    
157     };
158    
159    
160    
161    
162     //
163     // Kevin's WW selection
164     //
165     SelectionStatus passMuonSelection( ControlFlags &ctrl, const mithep::TMuon * mu ) {
166     int level=0;
167     unsigned failmask=0x0;
168    
169 anlevin 1.3
170 khahn 1.1 // 0x1
171     if(mu->pt < 5) {
172     failmask |= (1<<level);
173     }
174    
175     // 0x2
176     level++;
177     if(fabs(mu->eta) > 2.4) {
178     failmask |= (1<<level);
179     }
180    
181     // 0x4
182     level++;
183     if(mu->ptErr/mu->pt > 0.1) {
184     failmask |= (1<<level);
185     }
186    
187     // 0x8
188     level++;
189     if( fabs(mu->dz) > 0.1 ) {
190     failmask |= (1<<level);
191     }
192    
193    
194     Bool_t isGlobal = (mu->typeBits & kGlobal) && (mu->muNchi2 < 10) && (mu->nMatch > 1) && (mu->nValidHits > 0);
195     Bool_t isTracker = (mu->typeBits & kTracker) && (mu->qualityBits & kTMLastStationTight);
196    
197     // 0x10
198     level++;
199     if(!isGlobal && !isTracker) {
200     failmask |= (1<<level);
201     }
202    
203     // 0x20
204     level++;
205     if( mu->nTkHits < 10 ) {
206     failmask |= (1<<level);
207     }
208    
209     level++;
210     if(mu->nPixHits < 1) {
211     failmask |= (1<<level);
212     }
213    
214    
215     level++;
216     if(fabs(mu->d0)>0.02) {
217     failmask |= (1<<level);
218     }
219    
220     /*
221     if(mu->pt>20) {
222     if(fabs(mu->d0)>0.02) {
223     failmask |= (1<<level);
224     }
225     } else {
226     if(fabs(mu->d0)>0.01) {
227     failmask |= (1<<level);
228     }
229     }
230     */
231    
232     SelectionStatus status;
233     if( !failmask ) status.setStatus(SelectionStatus::LOOSEID);
234     if( !failmask ) status.setStatus(SelectionStatus::TIGHTID);
235     return status;
236    
237    
238     };
239    
240 anlevin 1.3 SelectionStatus passMuonSelectionBackDoor( ControlFlags &ctrl, const mithep::TMuon * mu ) {
241     int level=0;
242     unsigned failmask=0x0;
243    
244     if(mu->pt < 5) {
245     failmask |= (1<<level);
246     }
247    
248     level++;
249     if(fabs(mu->eta) > 2.5) {
250     failmask |= (1<<level);
251     }
252    
253     level++;
254     if(!(mu->typeBits & kGlobal) || !(mu->typeBits & kTracker)) {
255     failmask |= (1<<level);
256     }
257    
258     level++;
259     if(mu->nTkHits <= 10) {
260     failmask |= (1<<level);
261     }
262    
263     level++;
264     if(mu->ip3dSig > 4) {
265     failmask |= (1<<level);
266     }
267    
268     level++;
269     if(mu->muNchi2 >= 10) {
270     failmask |= (1<<level);
271     }
272    
273     level++;
274     if(mu->nValidHits < 1) {
275     failmask |= (1<<level);
276     }
277    
278     level++;
279     if(mu->nMatch < 2) {
280     failmask |= (1<<level);
281     }
282    
283     SelectionStatus status;
284    
285     if( !failmask ) status.setStatus(SelectionStatus::LOOSEID);
286     if( !failmask ) status.setStatus(SelectionStatus::TIGHTID);
287    
288     return status;
289    
290     };