ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/LeptonSelection/src/MuonSelection.cc
(Generate patch)

Comparing UserCode/MitHzz4l/LeptonSelection/src/MuonSelection.cc (file contents):
Revision 1.8 by khahn, Mon Apr 30 23:54:34 2012 UTC vs.
Revision 1.32 by anlevin, Thu Jul 5 19:34:29 2012 UTC

# Line 13 | Line 13
13   mithep::MuonIDMVA * muIDMVA;
14   mithep::MuonTools muTools;
15  
16 + extern vector<bool> PFnoPUflag;
17   extern Float_t computePFMuonIso(const mithep::Muon *mu,
18 <                        const mithep::Vertex & vtx,
18 >                        const mithep::Vertex * vtx,
19                          const mithep::Array<mithep::PFCandidate> * pfCandidates,
20                          const Double_t dRMax);
21  
22 + bool muonPOG2012CutBasedIDTight(const mithep::Muon *mu, const mithep::Vertex * vtx, const mithep::Array<mithep::PFCandidate> * pfCandidates, const mithep::Array<mithep::PileupEnergyDensity> * puEnergyDensity)
23 + {
24 +
25 +  Float_t charged_iso = 0;
26 +  
27 +  Float_t sumChargedHadronPt = 0;
28 +  Float_t sumNeutralHadronPt = 0;
29 +  Float_t sumPhotonPt = 0;
30 +  Float_t sumPUPt = 0;
31 +
32 +  for(unsigned k=0; k<pfCandidates->GetEntries(); ++k) {
33 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*pfCandidates)[k]);
34 +    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
35 +    if(dr > 0.4) continue;
36 +    if(pf->TrackerTrk() && mu->TrackerTrk() && pf->TrackerTrk() == mu->TrackerTrk()) continue;
37 +
38 +    if(PFnoPUflag[k]){ //pf no pileup
39 +      if(abs(pf->PFType()) == mithep::PFCandidate::eHadron)
40 +        sumChargedHadronPt += pf->Pt();
41 +      else if (pf->Pt() > 0.5 && abs(pf->PFType()) == mithep::PFCandidate::eNeutralHadron)
42 +        sumNeutralHadronPt += pf->Pt();
43 +      else if (pf->Pt() > 0.5 && abs(pf->PFType()) == mithep::PFCandidate::eGamma)
44 +        sumPhotonPt += pf->Pt();
45 +    }
46 +    else {//pf pile up
47 +      if(pf->Charge() != 0)
48 +        sumPUPt += pf->Pt();
49 +    }
50 +  
51 +  }
52 +  double iso_sum =  sumChargedHadronPt+ max(0.,sumNeutralHadronPt+sumPhotonPt-0.5*sumPUPt);
53 +
54 +  bool pass = kTRUE;
55 +  if(!mu->IsGlobalMuon()) pass = kFALSE;
56 +
57 +  //there is not necessarily a global track or a tracker track if is global muon is false
58 +  if(!pass) return pass;
59 +
60 +  if(!mu->IsPFMuon()) pass = kFALSE;
61 +  if(mu->GlobalTrk()->RChi2() > 10) pass= kFALSE;
62 +  if(mu->NValidHits() == 0 ) pass= kFALSE;
63 +  if(mu->NMatches() <= 1) pass = kFALSE;
64 +  if(fabs(mu->TrackerTrk()->D0Corrected(*vtx)) > 0.2) pass = kFALSE;
65 +  if(fabs(mu->TrackerTrk()->DzCorrected(*vtx)) > 0.5) pass = kFALSE;
66 +  if(mu->BestTrk()->NPixelHits() == 0) pass = kFALSE;
67 +  if(mu->NTrkLayersHit() <= 5) pass = kFALSE;
68 +  if(iso_sum/mu->Pt() > 0.12 ) pass = kFALSE;
69 +
70 +  return pass;
71 +
72 +
73 + }
74 +
75 +
76 + bool muon2012CutBasedIDTight(const mithep::Muon *mu, const mithep::Vertex * vtx, const mithep::Array<mithep::PFCandidate> * pfCandidates, const mithep::Array<mithep::PileupEnergyDensity> * puEnergyDensity)
77 + {
78 +
79 +  mithep::MuonTools   muT;
80 +
81 +  Float_t charged_iso = 0;
82 +  Float_t neutral_iso = 0;
83 +  Float_t gamma_iso = 0;
84 +  
85 +  for(int k=0; k<pfCandidates->GetEntries(); ++k) {
86 +    
87 +    if( !(PFnoPUflag[k]) ) continue;
88 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*pfCandidates)[k]);
89 +    
90 +    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
91 +    if (dr > 0.4) continue;
92 +    
93 +    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
94 +      
95 +      if (abs(pf->PFType()) == mithep::PFCandidate::eElectron || abs(pf->PFType()) == mithep::PFCandidate::eMuon) continue;
96 +      
97 +      charged_iso += pf->Pt();
98 +    }
99 +    
100 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
101 +      
102 +      gamma_iso += pf->Pt();
103 +    }
104 +    
105 +    else {
106 +      neutral_iso += pf->Pt();
107 +    }
108 +  }
109 +  
110 +  mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2012;
111 +  float rho = puEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral();
112 +  
113 +  double iso_sum = charged_iso + fmax(0.0,(gamma_iso + neutral_iso
114 +                                        -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
115 +                                                                   mu->Eta(),EffectiveAreaVersion)));
116 +
117 +  bool pass = kTRUE;
118 +  if(!mu->IsGlobalMuon()) pass = kFALSE;
119 +
120 +  //there is not necessarily a global track or a tracker track if is global muon is false
121 +  if(!pass) return pass;
122 +
123 +  if(!mu->IsPFMuon()) pass = kFALSE;
124 +  if(mu->GlobalTrk()->RChi2() > 10) pass= kFALSE;
125 +  if(mu->NValidHits() == 0 ) pass= kFALSE;
126 +  if(mu->NMatches() <= 1) pass = kFALSE;
127 +  if(fabs(mu->TrackerTrk()->D0Corrected(*vtx)) > 0.2) pass = kFALSE;
128 +  if(fabs(mu->TrackerTrk()->DzCorrected(*vtx)) > 0.5) pass = kFALSE;
129 +  if(mu->BestTrk()->NPixelHits() == 0) pass = kFALSE;
130 +  if(mu->NTrkLayersHit() <= 5) pass = kFALSE;
131 +  if(iso_sum/mu->Pt() > 0.12 ) pass = kFALSE;
132 +
133 +  return pass;
134 +
135 +
136 + }
137 +
138 + bool trackToPFMuonSelection( const mithep::Track *track, const mithep::MuonCol * muoncol )
139 + {
140 +        bool pass = false;
141 +  for(UInt_t i=0; i<muoncol->GetEntries(); ++i) {
142 +    const mithep::Muon *mu = muoncol->At(i);
143 +                if(mu->TrackerTrk() == track && (mu->IsGlobalMuon() || mu->IsTrackerMuon()) && mu->IsPFMuon())
144 +                        pass = true;
145 +        }              
146 +                
147 +        return pass;            
148 +                
149 + }
150 +
151   //--------------------------------------------------------------------------------------------------
152   SelectionStatus muonDummyVeto(ControlFlags &ctrl,
153                                const mithep::Muon *muon,
154 <                              const mithep::Vertex &vtx)
154 >                              const mithep::Vertex * vtx)
155   //--------------------------------------------------------------------------------------------------
156   {
157    SelectionStatus status;
# Line 32 | Line 162 | SelectionStatus muonDummyVeto(ControlFla
162   //--------------------------------------------------------------------------------------------------
163   SelectionStatus muonCutBasedVeto(ControlFlags &ctrl,
164                                   const mithep::Muon *muon,
165 <                                 const mithep::Vertex &vtx)
165 >                                 const mithep::Vertex *vtx)
166   //--------------------------------------------------------------------------------------------------
167   {
168    //
# Line 64 | Line 194 | SelectionStatus noPreSelection( ControlF
194   //--------------------------------------------------------------------------------------------------
195   SelectionStatus muonPreSelection( ControlFlags &ctrl,  
196                                    const mithep::Muon * mu,
197 <                                  const mithep::Vertex & vtx,
197 >                                  const mithep::Vertex * vtx,
198                                    const mithep::Array<mithep::PFCandidate> * pfCandidates )
199   //--------------------------------------------------------------------------------------------------
200   {
201    bool ret = true;
202 <  if(ctrl.debug) cout << "inside muonpresel ... " << endl;
203 <  //  bool ret = isMuFO(mu,vtx,pfCandidates);
204 <  if(ctrl.debug) cout << "iS fo? ... " << ret << endl;  
75 <  ret &= ( fabs(mu->Ip3dPVSignificance()) < 4 );
76 <  if(ctrl.debug) cout << "and pass IP (" << mu->Ip3dPVSignificance() << ") ? ... " << ret << endl;  
77 <  ret &= ( mu->Pt() > 5 );
78 <  if(ctrl.debug) cout << "and >5 GeV (" << mu->Pt() << ") ? ... " << ret << endl;  
202 >
203 >  ret &= ( fabs(mu->Ip3dPVSignificance()) < 100 );
204 >  ret &= ( mu->Pt() >= 5 );
205    ret &= ( fabs(mu->Eta()) <= 2.4 );
206 <  if(ctrl.debug) cout << "and < 2.4 eta (" << mu->Eta() << ")? ... " << ret << endl;  
207 <  ret &=  (mu->IsTrackerMuon() && mu->HasTrackerTrk() &&
208 <           (mu->Quality().QualityMask().Mask() & mithep::MuonQuality::AllArbitrated));
209 <  if(ctrl.debug) cout << "and isTrackerMuon ? ... " << ret << endl;  
84 <  //  ret &=  (mu->IsoR03SumPt()/mu->Pt() < 0.7 );
85 <  ret &=  (mu->IsoR03SumPt()/mu->Pt() < 0.7 );
86 <  if(ctrl.debug) cout << "and loose trk iso ? ... " << ret << endl;  
206 >  ret &= ( mu->IsTrackerMuon() || mu->IsGlobalMuon() );
207 > //   if( mu->IsTrackerMuon() && mu->HasTrackerTrk() && !mu->IsGlobalMuon() )  
208 > //     ret &=  ( mu->Quality().QualityMask().Mask() & mithep::MuonQuality::AllArbitrated);
209 >  ret &= (  mu->IsoR03SumPt()/mu->Pt() < 0.7 );
210  
211    SelectionStatus status;
212    if( ret ) status.setStatus(SelectionStatus::PRESELECTION);
# Line 92 | Line 215 | SelectionStatus muonPreSelection( Contro
215   }
216  
217  
218 +
219   //--------------------------------------------------------------------------------------------------
220 < bool isMuFO( const mithep::Muon * mu,
221 <             const mithep::Vertex & vtx,
222 <             const mithep::Array<mithep::PFCandidate> * pfCandidates )
220 > SelectionStatus muonReferencePreSelection( ControlFlags &ctrl,  
221 >                                           const mithep::Muon * mu,
222 >                                           const mithep::Vertex * vtx,
223 >                                           const mithep::Array<mithep::PFCandidate> * pfCandidates )
224   //--------------------------------------------------------------------------------------------------
225   {
226 <  bool isgood=true;
102 <  float reliso = computePFMuonIso(mu,vtx,pfCandidates,0.3)/mu->Pt();
103 <
104 <  if( mu->Pt() < 5  )         isgood=false;                          
105 <  if ( fabs(mu->BestTrk()->DzCorrected(vtx)) > 0.2 ) isgood=false;   // needed to remove cosmics in HF sample
106 <
107 <  //
108 <
109 <  // HF seems to not want tkquality, SS does
110 <  if( mu->Pt()>20 ) {
111 <    if ( !((mu->IsGlobalMuon()) && mu->NSegments()>0  ) ) isgood=false; //&& mu->nValidHits>0
112 <  } else {
113 <    if ( !((mu->IsGlobalMuon()) && mu->NSegments()>0 ) //&& //&& mu->nValidHits>0
114 <         && !( (mu->IsTrackerMuon()) &&  (mu->Quality().QualityMask().Mask() & muTools.kTMOneStationLoose)
115 <               )
116 <         )   isgood=false;
117 <  }
118 <
119 <
120 <  //
121 <  // for HF MC to agree w/ data, cannot put any Tk quality bits
122 <  // but to get to 5% closure in the SS test, we need at least Tk oneStationLoose
123 <
124 <  /*
125 < && ( (mu->qualityBits & kTMOneStationLoose) ||
126 <                                               (mu->qualityBits & kTMLastStationOptimizedBarrelLowPtLoose) ||
127 <                                               (mu->qualityBits & kTMLastStationOptimizedLowPtLoose)
128 <                                               )
129 <  */
130 <
226 >  bool ret = true;
227  
228 <  // comment for more stats for mu fake shape
229 <  if( mu->Pt() < 20 ) {
230 <    if( reliso > 3 ) isgood=false;    
231 <  } else {
232 <    if( reliso > 5 ) isgood=false;    
233 <  }
228 >  if(ctrl.debug) cout << "inside muonpresel ... " << endl;
229 >  ret &= ( fabs(mu->Ip3dPVSignificance()) < 100 );
230 >  if(ctrl.debug) cout << "and pass IP (" << mu->Ip3dPVSignificance() << ") ? ... " << ret << endl;  
231 >  ret &= ( mu->Pt() >= 5 );
232 >  if(ctrl.debug) cout << "and >5 GeV (" << mu->Pt() << ") ? ... " << ret << endl;  
233 >  ret &= ( fabs(mu->Eta()) <= 2.4 );
234 >  if(ctrl.debug) cout << "and < 2.4 eta (" << mu->Eta() << ")? ... " << ret << endl;  
235 >  ret &= ( mu->IsTrackerMuon() || mu->IsGlobalMuon() );
236 >  if(ctrl.debug) cout << "is Tracker or Global? ... " << ret << endl;
237 >  ret &= (mu->HasTrackerTrk() &&
238 >          fabs(mu->TrackerTrk()->D0Corrected(*vtx)) < 0.5 &&
239 >          fabs(mu->TrackerTrk()->DzCorrected(*vtx)) < 1.0);
240 >  if(ctrl.debug) cout << "d0 and dz? ... " << ret << endl;  
241 >          
242 >  //  if( mu->IsTrackerMuon() && mu->HasTrackerTrk() && !mu->IsGlobalMuon() )  
243 >  //    ret &=  ( mu->Quality().QualityMask().Mask() & mithep::MuonQuality::AllArbitrated);
244 >  //  if(ctrl.debug) cout << "if isTrackerMuon, arbitrated ? ... " << ret << endl;  
245 >  //  ret &= ( mu->BestTrk()->DzCorrected(vtx) < 0.1);  
246 >  //  if( ctrl.debug ) cout << "elepresel : ret after dZcorr : " << ret <<  endl;
247  
139  return isgood;
140 };
248  
249 +  SelectionStatus status;
250 +  if( ret ) status.setStatus(SelectionStatus::PRESELECTION);
251 +  if(ctrl.debug) cout << "muon presel returning status : " << status.getStatus() << endl;  
252 +  return status;
253 + }
254   //--------------------------------------------------------------------------------------------------
255 < SelectionStatus passSoftMuonSelection( ControlFlags &ctrl,
256 <                                       const mithep::Muon * mu ,
257 <                                       const mithep::Vertex & vtx)
258 < //--------------------------------------------------------------------------------------------------
147 < {
148 <
149 <  int level=0;
150 <  unsigned failmask=0x0;
151 <  
152 <  // Use tracker track when available
153 <  const mithep::Track *muTrk=0;
154 <  if(mu->HasStandaloneTrk()) { muTrk = mu->StandaloneTrk(); }
155 <  else if(mu->HasTrackerTrk())         { muTrk = mu->TrackerTrk(); }
156 <  else if(mu->HasGlobalTrk())     { muTrk = mu->GlobalTrk(); }
157 <  assert(muTrk);                  
158 <
159 <  if(mu->TrackerTrk()->NHits() < 11 )  
160 <    failmask |= (1<<level);
161 <  level++;
162 <
163 <  if(fabs(muTrk->D0Corrected(vtx)) > 0.2)
164 <    failmask |= (1<<level);
165 <  level++;
166 <
167 <  if(fabs(muTrk->DzCorrected(vtx)) > 0.1)
168 <    failmask |= (1<<level);
169 <  level++;
170 <
171 <  if(!(mu->IsTrackerMuon()))
172 <    failmask |= (1<<level);
173 <  level++;
174 <
175 <  //  if(!(mu->Quality().QualityMask().Mask() & muTools.kTMLastStationAngTight))
176 <  if(!(mu->Quality().QualityMask().Mask() & muTools.kTMLastStationTight))
177 <    failmask |= (1<<level);      
178 <  level++;
179 <
180 <  Double_t iso = (mu->IsoR03SumPt() + mu->IsoR03EmEt() + mu->IsoR03HadEt())/mu->Pt();
181 <  if(mu->Pt()>20 && iso<0.1)
182 <    failmask |= (1<<level);
183 <
184 <  bool passtight  = !(failmask);
185 <  bool passloose  = !(failmask);
186 <  return SelectionStatus( passtight | passloose );
187 <  
188 < }
189 <
190 < //--------------------------------------------------------------------------------------------------
191 < //unsigned passMuonSelectionZZ( const mithep::TMuon * mu ) {
192 < SelectionStatus passMuonSelectionZZ( ControlFlags &ctrl, const mithep::Muon * mu )
255 > SelectionStatus muonDenominatorSelection( ControlFlags &ctrl,  
256 >                                          const mithep::Muon * mu,
257 >                                          const mithep::Vertex * vtx,
258 >                                          const mithep::Array<mithep::PFCandidate> * pfCandidates )
259   //--------------------------------------------------------------------------------------------------
260   {
261 <  int level=0;
196 <  unsigned failmask=0x0;
197 <
198 <  if(mu->Pt() < 5) {
199 <    failmask |= (1<<level);
200 <  }
201 <
202 <  level++;
203 <  if(fabs(mu->Eta()) > 2.4) {
204 <    failmask |= (1<<level);
205 <  }
206 <
207 <  level++;
208 <  if(!(mu->IsGlobalMuon())) {
209 <    failmask |= (1<<level);
210 <  }
211 <
212 <  level++;
213 <  if(mu->TrackerTrk()->NHits()  < 10) {
214 <    failmask |= (1<<level);
215 <  }
216 <
261 >  bool ret = true;
262  
263 <  level++;  
264 <  if( (mu->IsoR03SumPt()/mu->Pt()) > 0.7 ) {
265 <    failmask |= (1<<level);
266 <  }
263 >  ret &= ( fabs(mu->Ip3dPVSignificance()) < 100 );
264 >  ret &= ( mu->Pt() >= 5 );
265 >  ret &= ( fabs(mu->Eta()) <= 2.4 );
266 >  ret &= ( mu->IsTrackerMuon() || mu->IsGlobalMuon() );
267 >  ret &= (mu->HasTrackerTrk() &&
268 >          fabs(mu->TrackerTrk()->D0Corrected(*vtx)) < 0.5 &&
269 >          fabs(mu->TrackerTrk()->DzCorrected(*vtx)) < 1.0);
270  
223  //  if(muon->nPixHits   < 1)     return false;
224  //  if(muon->muNchi2    > 10)    return false;
225  //  if(muon->nMatch     < 2)     return false;
226  //  if(muon->nValidHits         < 1)     return false;
227  //  if(muon->pterr/muon->pt > 0.1)   return false;
228  //  if(fabs(muon->dz)       > 0.1)   return false;  
229  
271    SelectionStatus status;
272 <  if( !failmask ) status.orStatus(SelectionStatus::LOOSEID);
232 <  if( !failmask ) status.orStatus(SelectionStatus::TIGHTID);
272 >  if( ret ) status.setStatus(SelectionStatus::PRESELECTION);
273    return status;
274 + }
275  
235
236
237 };
238
239
240
241
242 //
243 // Kevin's WW selection
244 //
276   //--------------------------------------------------------------------------------------------------
277 < SelectionStatus passMuonSelection( ControlFlags &ctrl,
278 <                                   const mithep::Muon * mu,
279 <                                   const mithep::Vertex & vtx   )
277 > SelectionStatus muonPreSelectionNoD0DzIP( ControlFlags &ctrl,  
278 >                                          const mithep::Muon * mu,
279 >                                          const mithep::Vertex * vtx,
280 >                                          const mithep::Array<mithep::PFCandidate> * pfCandidates )
281   //--------------------------------------------------------------------------------------------------
282   {
283 <  SelectionStatus status;
252 <  int level=0;
253 <  unsigned failmask=0x0;
254 <
255 <  // Use tracker track when available
256 <  const mithep::Track *muTrk=0;
257 <  if(mu->HasTrackerTrk())         { muTrk = mu->TrackerTrk(); }
258 <  else if(mu->HasGlobalTrk())     { muTrk = mu->GlobalTrk(); }
259 <  else if(mu->HasStandaloneTrk()) { muTrk = mu->StandaloneTrk(); }
260 <  assert(muTrk);                  
261 <  
262 <
263 <
264 <  // 0x1
265 <  if(muTrk->Pt() < 5) {
266 <    failmask |= (1<<level);
267 <  }
268 <
269 <  // 0x2
270 <  level++;
271 <  if(fabs(muTrk->Eta()) > 2.4) {
272 <    failmask |= (1<<level);
273 <  }
274 <
275 <  // 0x4
276 <  level++;
277 <  if(muTrk->PtErr()/muTrk->Pt() > 0.1)   {
278 <    failmask |= (1<<level);
279 <  }
280 <
281 <  // 0x8
282 <  level++;
283 <  if( fabs(muTrk->DzCorrected(vtx)) > 0.1 )   {
284 <    failmask |= (1<<level);
285 <  }
286 <
287 <  double muNchi2;
288 <  if(mu->HasStandaloneTrk())      { muNchi2 = mu->StandaloneTrk()->RChi2(); }
289 <  else if(mu->HasGlobalTrk())     { muNchi2 = mu->GlobalTrk()->RChi2();     }
290 <  else if(mu->HasTrackerTrk())    { muNchi2 = mu->TrackerTrk()->RChi2();    }
291 <
292 <  unsigned qualityBits = mu->Quality().QualityMask().Mask();
293 <  
294 <  Bool_t isGlobal  = (mu->IsGlobalMuon()) && (muNchi2 < 10) && (mu->NMatches() > 1) && (mu->NValidHits() > 0);
295 <  Bool_t isTracker = (mu->IsTrackerMuon() ) && (qualityBits & muTools.kTMLastStationTight);
296 <
297 <  // 0x10
298 <  level++;
299 <  if((!isGlobal && !isTracker) || !(mu->HasTrackerTrk())) {
300 <    failmask |= (1<<level);
301 <    status.setStatus(SelectionStatus::FAIL);
302 <    return status;    
303 <  }
304 <
305 <  // 0x20
306 <  level++;
307 <  assert(mu->HasTrackerTrk());
308 <  assert(mu->TrackerTrk());
309 <  if( mu->TrackerTrk()->NHits() < 10 ) {
310 <    failmask |= (1<<level);
311 <  }
312 <
313 <  level++;
314 <  if(muTrk->NPixelHits()          < 1) {
315 <    failmask |= (1<<level);
316 <  }
317 <
283 >  bool ret = true;
284  
285 <  level++;
286 <  if(fabs(muTrk->D0Corrected(vtx))>0.02)   {
287 <    failmask |= (1<<level);
288 <  }
285 >  if(ctrl.debug) cout << "inside muonpresel ... " << endl;
286 >  ret &= ( mu->Pt() >= 5 );
287 >  if(ctrl.debug) cout << "and >5 GeV (" << mu->Pt() << ") ? ... " << ret << endl;  
288 >  ret &= ( fabs(mu->Eta()) <= 2.4 );
289 >  if(ctrl.debug) cout << "and < 2.4 eta (" << mu->Eta() << ")? ... " << ret << endl;  
290 >  ret &= ( mu->IsTrackerMuon() || mu->IsGlobalMuon() );
291 >  if(ctrl.debug) cout << "is Tracker or Global? ... " << ret << endl;
292 >          
293 >  //  if( mu->IsTrackerMuon() && mu->HasTrackerTrk() && !mu->IsGlobalMuon() )  
294 >  //    ret &=  ( mu->Quality().QualityMask().Mask() & mithep::MuonQuality::AllArbitrated);
295 >  //  if(ctrl.debug) cout << "if isTrackerMuon, arbitrated ? ... " << ret << endl;  
296 >  //  ret &= ( mu->BestTrk()->DzCorrected(vtx) < 0.1);  
297 >  //  if( ctrl.debug ) cout << "elepresel : ret after dZcorr : " << ret <<  endl;
298  
324  /*
325  if(mu->pt>20) {
326    if(fabs(mu->d0)>0.02)   {
327      failmask |= (1<<level);
328    }
329  } else {
330    if(fabs(mu->d0)>0.01)  {
331    failmask |= (1<<level);
332    }
333  }
334  */
299  
300 <  if( !failmask ) status.orStatus(SelectionStatus::LOOSEID);
301 <  if( !failmask ) status.orStatus(SelectionStatus::TIGHTID);
300 >  SelectionStatus status;
301 >  if( ret ) status.setStatus(SelectionStatus::PRESELECTION);
302 >  if(ctrl.debug) cout << "muon presel returning status : " << status.getStatus() << endl;  
303    return status;
304 + }
305  
306  
341 };
307  
308  
309   //--------------------------------------------------------------------------------------------------
310   SelectionStatus muonIDMVASelection(ControlFlags &ctrl,
311                                   const mithep::Muon *mu,
312 <                                 const mithep::Vertex & vtx   )
312 >                                 const mithep::Vertex * vtx   )
313   //--------------------------------------------------------------------------------------------------
314   {
350  assert(mu->IsTrackerMuon()); // must be
351  assert(mu->HasTrackerTrk());
352  assert(mu->TrackerTrk());
353
354  /*
355  cerr << "TrackerTrk: " << mu->TrackerTrk() << endl;
356  flush(cerr);
357  cerr << "Rchi2: " << mu->TrackerTrk()->RChi2() << endl;
358  flush(cerr);
359
360  cerr << "calling MVa ... "<< endl;
361  flush(cerr);
362  */
363
315    double global_rchi2 = (mu->IsGlobalMuon()) ? mu->GlobalTrk()->RChi2() : 0.;
316  
317 +  //
318 +  // WARNING !!! KH hacked out to sync
319 +  //
320 +  /*
321    double mvaval = muIDMVA->MVAValue_ID(mu->Pt(),
322                                      mu->Eta(),
323                                      mu->IsGlobalMuon(),
# Line 370 | Line 325 | SelectionStatus muonIDMVASelection(Contr
325                                      mu->TrackerTrk()->RChi2(),
326                                      global_rchi2,
327                                      (Double_t)(mu->NValidHits()),
328 <                                    (Double_t)(mu->TrackerTrk()->NHits()),
328 >                                    (Double_t)(mu->TrackerTrk()->NHits()),
329                                      (Double_t)(mu->TrackerTrk()->NPixelHits()),
330                                      (Double_t)(mu->NMatches()),
331                                      mu->TrkKink(),
# Line 381 | Line 336 | SelectionStatus muonIDMVASelection(Contr
336                                      mu->HadS9Energy(),
337                                      mu->EmS9Energy(),
338                                      (Bool_t)(ctrl.debug) );
339 <
339 >  */
340 >  double mvaval = 0.0;
341  
342    SelectionStatus status;
343    bool pass = false;
# Line 394 | Line 350 | SelectionStatus muonIDMVASelection(Contr
350             && fabs(mu->Eta()) > 1.5 && mu->Pt() <= 10 && mvaval >= MUON_IDMVA_CUT_BIN2)  pass = true;
351    else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
352             && fabs(mu->Eta()) > 1.5 && mu->Pt() > 10 && mvaval >= MUON_IDMVA_CUT_BIN3)  pass = true;
353 <  else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon()
354 <           && (mu->Quality().QualityMask().Mask() & mithep::MuonQuality::AllArbitrated) && mvaval >= MUON_IDMVA_CUT_BIN4)
355 <    pass = true;
353 >  else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon() && mvaval >= MUON_IDMVA_CUT_BIN4 )  pass = true;
354 >  else if( mu->IsGlobalMuon() && !(mu->IsTrackerMuon()) && mvaval >= MUON_IDMVA_CUT_BIN5 )  pass = true;
355 >  
356  
357  
358    if( pass ) {
# Line 423 | Line 379 | void initMuonIDMVA()
379                         mithep::MuonIDMVA::kIDV0,
380                         kTRUE, weightFiles);
381   }
382 +
383 + //--------------------------------------------------------------------------------------------------
384 + SelectionStatus muonIDPFSelection(ControlFlags &ctrl,
385 +                                  const mithep::Muon *mu,
386 +                                  const mithep::Vertex * vtx,
387 +                                  const mithep::Array<mithep::PFCandidate> * pfCandidates )
388 + //--------------------------------------------------------------------------------------------------
389 + {
390 +  bool pass = false;
391 +  SelectionStatus status; // init'ed to FAIL
392 +
393 +  // check that it matches to a PF muon
394 +  for( int i=0; i<pfCandidates->GetEntries(); i++ ) {
395 +    // tmp
396 +    if( !(PFnoPUflag[i]) ) continue; // my PF no PU hack
397 +
398 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*pfCandidates)[i]);
399 +    if( (pf->TrackerTrk() == mu->TrackerTrk()) && abs(pf->PFType()) == mithep::PFCandidate::eMuon ) {
400 +      pass = true;
401 +      break;
402 +    }
403 +  }
404 + //      
405 + //      if(mu->IsPFMuon()) pass = true;
406 + //      else pass = false;
407 +
408 +  //
409 +  // NB : ipsig here for reference synch ...
410 +  //
411 + #ifdef SYNC
412 +  if( pass && fabs(mu->Ip3dPVSignificance()) < 4 ) {
413 +    status.orStatus(SelectionStatus::LOOSEID);
414 +    status.orStatus(SelectionStatus::TIGHTID);
415 +  }
416 + #else
417 +  if( pass ) {
418 +    status.orStatus(SelectionStatus::LOOSEID);
419 +    status.orStatus(SelectionStatus::TIGHTID);
420 +  }
421 + #endif
422 +
423 +  return status;
424 + }
425 + //----------------------------------------------------------------------------------------
426 + SelectionStatus PassWwMuonSel(const mithep::Muon *mu, const mithep::Vertex *vtx,
427 +                              const mithep::Array<mithep::PFCandidate> *pfArr
428 + )
429 + {
430 +  bool passID=true;
431 +  bool passIso=true;
432 +  
433 +  if (mu->Pt() < 5)
434 +    passID = false;
435 +  if (fabs(mu->Eta()) > 2.4)
436 +    passID = false;
437 +  if (mu->BestTrk()->PtErr()/mu->Pt() > 0.1)
438 +    passID = false;
439 +  if (fabs(mu->BestTrk()->DzCorrected(*vtx)) > 0.1)
440 +    passID = false;
441 +  Bool_t isGlobal  = (mu->IsGlobalMuon()) && (mu->BestTrk()->RChi2() < 10) &&
442 +                      (mu->NMatches() > 1) && (mu->NValidHits() > 0);
443 +  Bool_t isTracker = (mu->IsTrackerMuon()) &&
444 +                      (mu->Quality().Quality(mithep::MuonQuality::TMLastStationTight));
445 +  if (!isGlobal && !isTracker)
446 +    passID = false;
447 +  int ntrkhits = (mu->HasTrackerTrk()) ? mu->TrackerTrk()->NHits() : 0;
448 +  if (ntrkhits < 10)
449 +    passID = false;
450 +  if (mu->BestTrk()->NPixelHits() < 1)
451 +    passID = false;
452 +  if (fabs(mu->BestTrk()->D0Corrected(*vtx)) > 0.02)
453 +    passID = false;
454 +  
455 +  // note: this isn't really ww muon isolation
456 +  float pfiso = computePFMuonIso(mu,vtx,pfArr,0.3);
457 +
458 +  if (pfiso > 0.2*mu->Pt())
459 +    passIso = false;
460 +
461 +  SelectionStatus status;
462 +  if(passID)  status |= SelectionStatus::TIGHTIDANDPRE;
463 +  if(passIso) status |= SelectionStatus::TIGHTISOANDPRE;
464 +  
465 +  return status;
466 +
467 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines