ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/LeptonSelection/src/MuonSelection.cc
Revision: 1.1
Committed: Mon Feb 13 09:35:20 2012 UTC (13 years, 3 months ago) by khahn
Content type: text/plain
Branch: MAIN
Log Message:
*** empty log message ***

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