CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
analysisSelections.cc
Go to the documentation of this file.
1 #include "Math/VectorUtil.h"
7 
8 namespace HWWFunctions {
9 
10  void doCutFlow(HWW& hww, int i_hyp, EventMonitor& monitor, EGammaMvaEleEstimator* egammaMvaEleEstimator, MuonMVAEstimator* muonMVAEstimator){
11 
13  double weight = 1.0;
14 
15  monitor.count(type, "baseline", weight);
16  if(!passCharge(hww, i_hyp)) return;
17  monitor.count(type, "opposite sign", weight);
18  if(!passFullLep(hww, i_hyp, egammaMvaEleEstimator, muonMVAEstimator)) return;
19  monitor.count(type, "full lepton selection", weight);
20  if(!passExtraLeptonVeto(hww, i_hyp, egammaMvaEleEstimator, muonMVAEstimator)) return;
21  monitor.count(type, "extra lepton veto", weight);
22  if(!(hww.evt_pfmet() > 20.0)) return;
23  monitor.count(type, "met > 20 GeV", weight);
24  if(!(hww.hyp_p4().at(i_hyp).mass() > 12.0)) return;
25  monitor.count(type, "mll > 12 GeV", weight);
26  if(!passZVeto(hww, i_hyp)) return;
27  monitor.count(type, "|mll - mZ| > 15 GeV", weight);
28  if(!passMinMet(hww, i_hyp)) return;
29  monitor.count(type, "minMET > 20 GeV", weight);
30  if(!passMinMet40(hww, i_hyp)) return;
31  monitor.count(type, "minMET > 40 GeV for ee/mm", weight);
32  if(!passDPhiDiLepJet(hww, i_hyp)) return;
33  monitor.count(type, "dPhiDiLepJet < 165 dg for ee/mm", weight);
34  if(!passSoftMuonVeto(hww, i_hyp)) return;
35  monitor.count(type, "SoftMuons==0", weight);
36  if(!passTopVeto(hww, i_hyp)) return;
37  monitor.count(type, "top veto", weight);
38  if(hww.hyp_p4().at(i_hyp).pt() <= 45.0) return;
39  monitor.count(type, "ptll > 45 GeV", weight);
40 
41  int njets = numberOfJets(hww, i_hyp);
42  std::vector<JetPair> sortedJets = getJets(hww, i_hyp, 30.0, 4.7, true, false);
43 
44  LorentzVector jet1;
45  LorentzVector jet2;
46  LorentzVector jet3;
47 
48  if(njets==0){
49  monitor.count(type, "njets == 0", weight);
50  if(max(hww.hyp_ll_p4().at(i_hyp).pt(), hww.hyp_lt_p4().at(i_hyp).pt()) < 30) return;
51  monitor.count(type, "max(lep1.pt(),lep2.pt())>30", weight);
52  if(min(hww.hyp_ll_p4().at(i_hyp).pt(), hww.hyp_lt_p4().at(i_hyp).pt()) < 25) return;
53  monitor.count(type, "min(lep1.pt(),lep2.pt())>25", weight);
54  }
55  if(njets==1){
56  monitor.count( type, "njets == 1", weight);
57  }
58  if ( njets==2 || njets==3 ) {
59  monitor.count(type, "njets == 2 or 3", weight);
60  if (fabs(sortedJets[0].first.eta())>=4.7 || fabs(sortedJets[1].first.eta())>=4.7) return;
61  monitor.count(type,"abs(jet1.eta())<4.7 && abs(jet2.eta())<4.7",weight);
62  if (njets==3 && sortedJets[2].first.pt()>30 && ((sortedJets[0].first.eta()-sortedJets[2].first.eta() > 0 && sortedJets[1].first.eta()-sortedJets[2].first.eta() < 0) ||
63  (sortedJets[1].first.eta()-sortedJets[2].first.eta() > 0 && sortedJets[0].first.eta()-sortedJets[2].first.eta() < 0)) ) return;
64  monitor.count(type, "no central jets", weight);
65 
66  }
67 
68  return;
69 
70  }
71 
72  int bestHypothesis(HWW& hww, const std::vector<int>& candidates){
73  int best = -1;
74  for( unsigned int i = 0; i < candidates.size(); ++i ) {
75  unsigned int i_hyp = candidates.at(i);
76  if (best<0){
77  best = i_hyp;
78  continue;
79  }
80  if ( std::max(hww.hyp_lt_p4().at(i_hyp).pt(), hww.hyp_ll_p4().at(i_hyp).pt()) >= //GC add = in case the lepton is the same
81  std::max(hww.hyp_lt_p4().at(best).pt(), hww.hyp_ll_p4().at(best).pt()) &&
82  std::min(hww.hyp_lt_p4().at(i_hyp).pt(), hww.hyp_ll_p4().at(i_hyp).pt()) >=
83  std::min(hww.hyp_lt_p4().at(best).pt(), hww.hyp_ll_p4().at(best).pt()) )
84  best = i_hyp;
85  }
86  return best;
87  }
88 
89  bool passFirstCuts(HWW& hww, int i_hyp){
90 
91  if ( std::min(hww.hyp_lt_p4().at(i_hyp).pt(),hww.hyp_ll_p4().at(i_hyp).pt())<10 ) return false;
92  if ( std::max(hww.hyp_lt_p4().at(i_hyp).pt(),hww.hyp_ll_p4().at(i_hyp).pt())<20 ) return false;
93  if (hww.trks_d0().size()==0) return false;
94  if (!isGoodVertex(hww, 0)) return false;
95  if (nGoodVertex(hww)<1) return false;
96  if (hww.hyp_p4().at(i_hyp).mass2()<0) return false;
97 
98  return true;
99  }
100 
101  bool passCharge(HWW& hww, int i_hyp){
102 
103  if (hww.hyp_lt_id().at(i_hyp)*hww.hyp_ll_id().at(i_hyp)>0) return false;
104  return true;
105  }
106 
107  bool passBaseline(HWW& hww, int i_hyp, EGammaMvaEleEstimator* egammaMvaEleEstimator, MuonMVAEstimator* muonMVAEstimator){
108 
109  if (abs(hww.hyp_lt_id().at(i_hyp)) == 13 && !ww_muBase(hww, hww.hyp_lt_index().at(i_hyp)) ) return false;
110  if (abs(hww.hyp_ll_id().at(i_hyp)) == 13 && !ww_muBase(hww, hww.hyp_ll_index().at(i_hyp)) ) return false;
111  if (abs(hww.hyp_lt_id().at(i_hyp)) == 11 && !ww_elBase(hww, hww.hyp_lt_index().at(i_hyp)) ) return false;
112  if (abs(hww.hyp_ll_id().at(i_hyp)) == 11 && !ww_elBase(hww, hww.hyp_ll_index().at(i_hyp)) ) return false;
113 
114  bool lockToCoreSelectors = false;
115  bool useLHeleId = false;
116  int useMVAeleId = 1;//zero means off, otherwise it's the mva version
117  bool useMVAmuId = false;
118 
119  MuonIDMVA* muonIdMVA = 0;
120  std::vector<Int_t> nullMu; // null identified muons
121  std::vector<Int_t> nullEle; // null identified electrons
122 
123  bool PASSED_LT_FINAL = false;
124  bool PASSED_LT_FO_MU2 = false;
125  bool PASSED_LT_FO_ELEV4 = false;
126  bool PASSED_LL_FINAL = false;
127  bool PASSED_LL_FO_MU2 = false;
128  bool PASSED_LL_FO_ELEV4 = false;
129 
130  if (abs(hww.hyp_lt_id().at(i_hyp)) == 13){
131  unsigned int index = hww.hyp_lt_index().at(i_hyp);
132  if ( goodMuonIsolated(hww, index, lockToCoreSelectors, useMVAmuId, muonIdMVA, muonMVAEstimator, nullMu, nullEle) ) PASSED_LT_FINAL = true;
133  if ( fakableMuon(hww, index,MuFOV2, muonMVAEstimator, nullMu, nullEle) && !goodMuonIsolated(hww, index, lockToCoreSelectors, useMVAmuId, muonIdMVA, muonMVAEstimator, nullMu, nullEle)) PASSED_LT_FO_MU2 = true;
134  }
135  if (abs(hww.hyp_ll_id().at(i_hyp)) == 13){
136  unsigned int index = hww.hyp_ll_index().at(i_hyp);
137  if ( goodMuonIsolated(hww, index, lockToCoreSelectors, useMVAmuId, muonIdMVA, muonMVAEstimator, nullMu, nullEle) ) PASSED_LL_FINAL = true;
138  if ( fakableMuon(hww, index,MuFOV2, muonMVAEstimator, nullMu, nullEle) && !goodMuonIsolated(hww, index, lockToCoreSelectors, useMVAmuId, muonIdMVA, muonMVAEstimator, nullMu, nullEle)) PASSED_LL_FO_MU2 = true;
139  }
140  if (abs(hww.hyp_lt_id().at(i_hyp)) == 11){
141  unsigned int index = hww.hyp_lt_index().at(i_hyp);
142  if ( goodElectronIsolated(hww, index, useLHeleId, useMVAeleId, egammaMvaEleEstimator, lockToCoreSelectors) ) PASSED_LT_FINAL = true;
143  if ( fakableElectron(hww, index,EleFOV4) && !goodElectronIsolated(hww, index, useLHeleId, useMVAeleId, egammaMvaEleEstimator, lockToCoreSelectors)) PASSED_LT_FO_ELEV4 = true;
144  }
145  if (abs(hww.hyp_ll_id().at(i_hyp)) == 11){
146  unsigned int index = hww.hyp_ll_index().at(i_hyp);
147  if ( goodElectronIsolated(hww, index, useLHeleId, useMVAeleId, egammaMvaEleEstimator, lockToCoreSelectors) ) PASSED_LL_FINAL = true;
148  if ( fakableElectron(hww, index,EleFOV4) && !goodElectronIsolated(hww, index, useLHeleId, useMVAeleId, egammaMvaEleEstimator, lockToCoreSelectors)) PASSED_LL_FO_ELEV4 = true;
149  }
150 
151  if( PASSED_LT_FINAL && PASSED_LL_FINAL ) return true;
152  if( PASSED_LT_FINAL && PASSED_LL_FO_MU2 ) return true;
153  if( PASSED_LT_FINAL && PASSED_LL_FO_ELEV4 ) return true;
154  if( PASSED_LL_FINAL && PASSED_LT_FINAL ) return true;
155  if( PASSED_LL_FINAL && PASSED_LT_FO_MU2 ) return true;
156  if( PASSED_LL_FINAL && PASSED_LT_FO_ELEV4 ) return true;
157 
158  return false;
159  }
160 
161  bool passFullLep(HWW& hww, int i_hyp, EGammaMvaEleEstimator* egammaMvaEleEstimator, MuonMVAEstimator* muonMVAEstimator){
162 
163  bool lockToCoreSelectors = false;
164  bool useLHeleId = false;
165  int useMVAeleId = 1;//zero means off, otherwise it's the mva version
166  bool useMVAmuId = false;
167 
168  MuonIDMVA* muonIdMVA = 0;
169  std::vector<Int_t> nullMu; // null identified muons
170  std::vector<Int_t> nullEle; // null identified electrons
171 
172  bool PASSED_LT_FINAL = false;
173  bool PASSED_LL_FINAL = false;
174 
175  if (abs(hww.hyp_lt_id().at(i_hyp)) == 13){
176  unsigned int index = hww.hyp_lt_index().at(i_hyp);
177  if ( goodMuonIsolated(hww, index, lockToCoreSelectors, useMVAmuId, muonIdMVA, muonMVAEstimator, nullMu, nullEle) ) PASSED_LT_FINAL = true;
178  }
179  if (abs(hww.hyp_ll_id().at(i_hyp)) == 13){
180  unsigned int index = hww.hyp_ll_index().at(i_hyp);
181  if ( goodMuonIsolated(hww, index, lockToCoreSelectors, useMVAmuId, muonIdMVA, muonMVAEstimator, nullMu, nullEle) ) PASSED_LL_FINAL = true;
182  }
183  if (abs(hww.hyp_lt_id().at(i_hyp)) == 11){
184  unsigned int index = hww.hyp_lt_index().at(i_hyp);
185  if ( goodElectronIsolated(hww, index, useLHeleId, useMVAeleId, egammaMvaEleEstimator, lockToCoreSelectors) ) PASSED_LT_FINAL = true;
186  }
187  if (abs(hww.hyp_ll_id().at(i_hyp)) == 11){
188  unsigned int index = hww.hyp_ll_index().at(i_hyp);
189  if ( goodElectronIsolated(hww, index, useLHeleId, useMVAeleId, egammaMvaEleEstimator, lockToCoreSelectors) ) PASSED_LL_FINAL = true;
190  }
191 
192  if(PASSED_LT_FINAL && PASSED_LL_FINAL) return true;
193 
194  return false;
195  }
196 
197 
198  bool passExtraLeptonVeto(HWW& hww, int i_hyp, EGammaMvaEleEstimator* egammaMvaEleEstimator, MuonMVAEstimator* muonMVAEstimator){
199 
200  bool useLHeleId = false;
201  int useMVAeleId = 1;//zero means off, otherwise it's the mva version
202  bool useMVAmuId = false;
203 
204  MuonIDMVA* muonIdMVA = 0;
205  std::vector<Int_t> nullMu; // null identified muons
206  std::vector<Int_t> nullEle; // null identified electrons
207 
208  return ( numberOfExtraLeptons(hww, i_hyp,10, useLHeleId, useMVAeleId, egammaMvaEleEstimator, useMVAmuId, muonIdMVA,muonMVAEstimator, nullMu, nullEle) == 0);
209 
210  }
211 
212  bool passZVeto(HWW& hww, int i_hyp){
213 
214  if(hww.hyp_type().at(i_hyp) == 1 || hww.hyp_type().at(i_hyp) == 2) return true; //em or me dileptons have no cut on the z mass
215  if(fabs(hww.hyp_p4().at(i_hyp).mass() - 91.1876) > 15.0) return true;
216  return false;
217 
218  }
219 
220 
221  bool passMinMet(HWW& hww, int i_hyp){
222 
223  double pmet = projectedMet(hww, i_hyp, hww.evt_pfmet(), hww.evt_pfmetPhi());
224  double pTrackMet = projectedMet(hww, i_hyp, hww.trk_met().at(i_hyp), hww.trk_metPhi().at(i_hyp) );
225  return(min(pmet,pTrackMet)>20);
226 
227  }
228 
229  bool passMinMet40(HWW& hww, int i_hyp){
230 
231  //require minMet > 40 GeV for ee and mm hypotheses
232 
233  if(hww.hyp_type().at(i_hyp) == 1) return true;
234  if(hww.hyp_type().at(i_hyp) == 2) return true;
235  double pmet = projectedMet(hww, i_hyp, hww.evt_pfmet(), hww.evt_pfmetPhi());
236  double pTrackMet = projectedMet(hww, i_hyp, hww.trk_met().at(i_hyp), hww.trk_metPhi().at(i_hyp) );
237  return(min(pmet,pTrackMet)>40);
238 
239  }
240 
241 
242  bool passDPhiDiLepJet(HWW& hww, int i_hyp){
243 
244  //pass if em or me hypothesis
245  if(hww.hyp_type().at(i_hyp)==1) return true;
246  if(hww.hyp_type().at(i_hyp)==2) return true;
247 
248  int njets = numberOfJets(hww, i_hyp);
249  std::vector<JetPair> sortedJets = getJets(hww, i_hyp, 15.0, 4.7, true, false);
250 
251  if (sortedJets.size()>0) {
252  if (njets<2 && fabs(ROOT::Math::VectorUtil::DeltaPhi(sortedJets[0].first,hww.hyp_p4().at(i_hyp))) >= (165.*TMath::Pi()/180.)) return false;
253  else if ( (njets>= 2) && (fabs(ROOT::Math::VectorUtil::DeltaPhi( (sortedJets[0].first+sortedJets[1].first),hww.hyp_p4().at(i_hyp))) >= (165.*TMath::Pi()/180.)) ) return false;
254  else return true;
255  }
256  return true;
257 
258  }
259 
260 
261  bool passSoftMuonVeto(HWW& hww, int i_hyp){
262 
263  return(numberOfSoftMuons(hww, i_hyp,true)==0);
264 
265  }
266 
267 
268  bool passTopVeto(HWW& hww, int i_hyp){
269 
270  return(!toptag(hww, i_hyp, 10));
271 
272  }
273 
274 
275  std::vector<JetPair> getJets(HWW& hww, int i_hyp, double etThreshold, double etaMax, bool sortJets, bool btag){
276 
277  std::vector<JetPair> jets;
278  const double vetoCone = 0.3;
279  // bug fix for mva jet id
280  vector <float> fixedpfjetmva_analobj; getGoodMVAs(hww, fixedpfjetmva_analobj, "mvavalue");
281 
282  for ( unsigned int i=0; i < hww.pfjets_p4().size(); ++i) {
283  if (i >= hww.pfjets_JEC().size())
284  break;
285 
286  double jec = hww.pfjets_JEC().at(i);
287 
288  if ( (hww.pfjets_p4().at(i).pt() * jec) < etThreshold ) continue;
289  if ( btag && !defaultBTag(hww, i, jec) ) continue;
290  if ( TMath::Abs(hww.pfjets_p4().at(i).eta()) > etaMax ) continue;
291  if ( (hww.hyp_lt_p4().at(i_hyp).pt() > 0 && TMath::Abs(ROOT::Math::VectorUtil::DeltaR(hww.hyp_lt_p4().at(i_hyp), hww.pfjets_p4().at(i))) < vetoCone) ||
292  (hww.hyp_ll_p4().at(i_hyp).pt() > 0 && TMath::Abs(ROOT::Math::VectorUtil::DeltaR(hww.hyp_ll_p4().at(i_hyp), hww.pfjets_p4().at(i))) < vetoCone) ) continue;
293  if ( !passMVAJetId(hww.pfjets_p4().at(i).pt() * jec, hww.pfjets_p4().at(i).eta(), fixedpfjetmva_analobj[i], 2) ) continue;
294 
295 
296  jets.push_back(JetPair(hww.pfjets_p4().at(i) * jec,i));
297  }
298  if ( sortJets ) std::sort(jets.begin(), jets.end(), comparePt);
299  return jets;
300  }
301 
302 
303 
304  std::vector<JetPair> getDefaultJets(HWW& hww, unsigned int i_hyp, bool btagged){
305  return getJets(hww, i_hyp, 30, 4.7, false, btagged);
306  }
307 
308 
309 
310  unsigned int numberOfJets(HWW& hww, unsigned int i_hyp){
311  return getDefaultJets(hww, i_hyp, false).size();
312  }
313 
314 
315 
316  bool defaultBTag(HWW& hww, unsigned int iJet, float jec) {
317 
318  if ( hww.pfjets_trackCountingHighEffBJetTag().at(iJet) > 2.1) return true;
319  return 0;
320  }
321 
322  Bool_t comparePt(JetPair lv1, JetPair lv2) {
323  return lv1.first.pt() > lv2.first.pt();
324  }
325 
326 
327 
328  // tightness : 2=loose 1=medium 0=tight
329  bool passMVAJetId(double corjetpt, double jeteta, double mvavalue, unsigned int tightness)
330  {
331  if(tightness>2)
332  {
333  edm::LogError("InvalidParameter") << "ERROR : tightness should be 0, 1, or 2. ";
334  return false;
335  }
336 
337  double fMVACut[3][4][4];
338 
339  //Tight Id
340  fMVACut[0][0][0] = 0.5; fMVACut[0][0][1] = 0.6; fMVACut[0][0][2] = 0.6; fMVACut[0][0][3] = 0.9;
341  fMVACut[0][1][0] = -0.2; fMVACut[0][1][1] = 0.2; fMVACut[0][1][2] = 0.2; fMVACut[0][1][3] = 0.6;
342  fMVACut[0][2][0] = 0.3; fMVACut[0][2][1] = 0.4; fMVACut[0][2][2] = 0.7; fMVACut[0][2][3] = 0.8;
343  fMVACut[0][3][0] = 0.5; fMVACut[0][3][1] = 0.4; fMVACut[0][3][2] = 0.8; fMVACut[0][3][3] = 0.9;
344  //Medium id
345  fMVACut[1][0][0] = 0.2; fMVACut[1][0][1] = 0.4; fMVACut[1][0][2] = 0.2; fMVACut[1][0][3] = 0.6;
346  fMVACut[1][1][0] = -0.3; fMVACut[1][1][1] = 0. ; fMVACut[1][1][2] = 0. ; fMVACut[1][1][3] = 0.5;
347  fMVACut[1][2][0] = 0.2; fMVACut[1][2][1] = 0.2; fMVACut[1][2][2] = 0.5; fMVACut[1][2][3] = 0.7;
348  fMVACut[1][3][0] = 0.3; fMVACut[1][3][1] = 0.2; fMVACut[1][3][2] = 0.7; fMVACut[1][3][3] = 0.8;
349  //Loose Id
350  fMVACut[2][0][0] = -0.2; fMVACut[2][0][1] = 0. ; fMVACut[2][0][2] = 0.2; fMVACut[2][0][3] = 0.5;
351  fMVACut[2][1][0] = -0.4; fMVACut[2][1][1] = -0.4; fMVACut[2][1][2] = -0.4; fMVACut[2][1][3] = 0.4;
352  fMVACut[2][2][0] = 0. ; fMVACut[2][2][1] = 0. ; fMVACut[2][2][2] = 0.2; fMVACut[2][2][3] = 0.6;
353  fMVACut[2][3][0] = 0. ; fMVACut[2][3][1] = 0. ; fMVACut[2][3][2] = 0.6; fMVACut[2][3][3] = 0.2;
354 
355  // pT categorization
356  int ptId = 0;
357  if( corjetpt > 10 && corjetpt < 20 ) ptId = 1;
358  if( corjetpt > 20 && corjetpt < 30 ) ptId = 2;
359  if( corjetpt > 30 ) ptId = 3;
360 
361  // eta categorization
362  int etaId = 0;
363  if( fabs(jeteta) > 2.5 && fabs(jeteta) < 2.75 ) etaId = 1;
364  if( fabs(jeteta) > 2.75 && fabs(jeteta) < 3.0 ) etaId = 2;
365  if( fabs(jeteta) > 3.0 && fabs(jeteta) < 5.0 ) etaId = 3;
366 
367  // return
368  if( mvavalue > fMVACut[tightness][ptId][etaId] ) return true;
369  return false;
370  }
371 
372 
373  bool isGoodVertex(HWW& hww, int ivtx) {
374 
375  if (hww.vtxs_isFake().at(ivtx)) return false;
376  if (hww.vtxs_ndof().at(ivtx) <= 4.) return false;
377  if (hww.vtxs_position().at(ivtx).Rho() > 2.0) return false;
378  if (fabs(hww.vtxs_position().at(ivtx).Z()) > 24.0) return false;
379  return true;
380 
381  }
382 
383  unsigned int nGoodVertex(HWW& hww) {
384  unsigned int nVtx = 0;
385  for ( unsigned int i = 0; i < hww.vtxs_sumpt().size(); ++i ){
386  if (!isGoodVertex(hww, i)) continue;
387  nVtx++;
388  }
389  return nVtx;
390  }
391 
393  return 0;
394  }
395 
396  //
397  // Electron ID
398  //
399 
400  bool goodElectronWithoutIsolation(HWW& hww, unsigned int i, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator* egammaMvaEleEstimator){
401  return ww_elBase(hww, i) && ww_elId(hww, i, useLHeleId, useMVAeleId, egammaMvaEleEstimator) && ww_eld0PV(hww, i) && ww_eldZPV(hww, i);
402  }
403 
404  bool goodElectronIsolated(HWW& hww, unsigned int i, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator* egammaMvaEleEstimator, bool lockToCoreSelectors){
405  bool ptcut = hww.els_p4().at(i).pt() >= 10.0;
406  bool core = ptcut && pass_electronSelection(hww, i, electronSelection_smurfV6);
407  bool internal = ww_elBase(hww, i) && ww_elId(hww, i, useLHeleId, useMVAeleId, egammaMvaEleEstimator) && ww_eld0PV(hww, i) && ww_eldZPV(hww, i) && ww_elIso(hww, i);
408  assert(!lockToCoreSelectors || core==internal);
409  return internal;
410  }
411 
412  bool ElectronFOIdV4(HWW& hww, unsigned int i) {
413 
414  float pt = hww.els_p4().at(i).pt();
415  float etaSC = hww.els_etaSC().at(i);
416 
417  if (fabs(etaSC)<1.479) {
418  if (hww.els_sigmaIEtaIEta().at(i)>0.01 ||
419  fabs(hww.els_dEtaIn().at(i))>0.007 ||
420  fabs(hww.els_dPhiIn().at(i))>0.15 ||
421  hww.els_hOverE().at(i)>0.12 ||
422  hww.els_tkIso().at(i)/pt>0.2 ||
423  (hww.els_ecalIso().at(i) - 1.0)/pt>0.2 ||
424  hww.els_hcalIso().at(i)/pt>0.2 ) return false;
425  } else {
426  if (hww.els_sigmaIEtaIEta().at(i)>0.03 ||
427  fabs(hww.els_dEtaIn().at(i))>0.009 ||
428  fabs(hww.els_dPhiIn().at(i))>0.10 ||
429  hww.els_hOverE().at(i)>0.10 ||
430  hww.els_tkIso().at(i)/pt>0.2 ||
431  hww.els_ecalIso().at(i)/pt>0.2 ||
432  hww.els_hcalIso().at(i)/pt>0.2 ) return false;
433  }
434 
435  // MIT conversion
436  if ( isFromConversionMIT(hww, i) ) return false;
437  // conversion rejection - hit based
438  if ( hww.els_exp_innerlayers().at(i) > 0 ) return false;
439 
440  return true;
441  }
442 
443  bool ElectronFOV4(HWW& hww, unsigned int i){
444  return ww_elBase(hww, i) && ElectronFOIdV4(hww, i) && ww_eld0PV(hww, i) && ww_eldZPV(hww, i);
445  }
446 
447  bool fakableElectron(HWW& hww, unsigned int i, EleFOTypes type){
448  if ( hww.els_p4().at(i).pt() < 10.0 ) return false;
449  switch (type){
453  case EleFOV4: return ElectronFOV4(hww, i);
454  }
455  return false;
456  }
457 
458  //
459  // Muon ID
460  //
461 
462  bool goodMuonTMVA(HWW& hww, MuonIDMVA* mva, unsigned int i) {
463  //Find MVA Bin
464  int subdet = 0;
465  if (fabs(hww.mus_p4().at(i).eta()) < 1.479) subdet = 0;
466  else subdet = 1;
467  int ptBin = 0;
468  if (hww.mus_p4().at(i).pt() > 14.5) ptBin = 1;
469  if (hww.mus_p4().at(i).pt() > 20.0) ptBin = 2;
470 
471  int MVABin = -1;
472  if (subdet == 0 && ptBin == 0) MVABin = 0;
473  if (subdet == 1 && ptBin == 0) MVABin = 1;
474  if (subdet == 0 && ptBin == 1) MVABin = 2;
475  if (subdet == 1 && ptBin == 1) MVABin = 3;
476  if (subdet == 0 && ptBin == 2) MVABin = 4;
477  if (subdet == 1 && ptBin == 2) MVABin = 5;
478 
479  double MVACut = -999.;
480  //same signal eff as cut-based (using V10 - Detector Based Iso)
481  if (MVABin == 0) MVACut = -0.5618;
482  if (MVABin == 1) MVACut = -0.3002;
483  if (MVABin == 2) MVACut = -0.4642;
484  if (MVABin == 3) MVACut = -0.2478;
485  if (MVABin == 4) MVACut = 0.1706;
486  if (MVABin == 5) MVACut = 0.8146;
487 
488  double mvaValue=mva->MVAValue(hww, i, 0);
489 
490  //Isolation
491  double iso03 = 0;
492  iso03 = muonIsoValuePF(hww, i,0,0.3);
493 
494  //Explicitly Apply M2 Denominator Cuts
495  bool pass = true;
496  if (hww.mus_p4().at(i).pt() < 10) pass = false;
497  if (fabs(hww.mus_p4().at(i).eta()) >= 2.4) pass = false;
498 
499  if (! ( (0==0)
500  &&
501  (
502  (((hww.mus_type().at(i)) & (1<<1)) == (1<<1)
503  && hww.mus_gfit_chi2().at(i)/hww.mus_gfit_ndof().at(i) < 10.0
504  && (hww.mus_gfit_validSTAHits().at(i) > 0)
505  && (hww.mus_nmatches().at(i) > 1 )
506  )
507  ||
508  ( ((hww.mus_type().at(i)) & (1<<2)) == (1<<2)
509  && hww.mus_pid_TMLastStationTight().at(i) == 1
510  )
511  )
512  && ((hww.mus_type().at(i)) & (1<<2)) == (1<<2)
513  && hww.mus_validHits().at(i) > 10
514  && (hww.trks_valid_pixelhits().at(hww.mus_trkidx().at(i)) > 0)
515  && iso03 < 0.4
516  && ( hww.mus_ptErr().at(i)/hww.mus_p4().at(i).pt() < 0.1)
517  && hww.mus_trkKink().at(i) < 20.
518  && mvaValue > MVACut
519  )
520  ) {
521  pass = false;
522  }
523  return pass;
524  }
525 
526  bool goodMuonWithoutIsolation(HWW& hww, unsigned int i, bool useMVAmuId, MuonIDMVA *mva,
527  MuonMVAEstimator* muonMVAEstimator, std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle){
528  return ww_muBase(hww, i) && ww_mud0PV(hww, i) && ww_mudZPV(hww, i, 0.1) && ww_muId(hww, i, useMVAmuId, mva) && passMuonRingsMVAFO(hww, i, muonMVAEstimator, IdentifiedMu, IdentifiedEle);
529  }
530 
531  bool goodMuonIsolated(HWW& hww, unsigned int i, bool lockToCoreSelectors, bool useMVAmuId, MuonIDMVA *mva,
532  MuonMVAEstimator* muonMVAEstimator, std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle ){
533  bool ptcut = hww.mus_p4().at(i).pt() >= 10.0;
534  bool core = ptcut && muonId(hww, i, NominalSmurfV6);
535  bool internal = ww_muBase(hww, i) && ww_mud0PV(hww, i) && ww_mudZPV(hww, i, 0.1) && ww_muId(hww, i, useMVAmuId, mva) && ww_muIso(hww, i, muonMVAEstimator, IdentifiedMu, IdentifiedEle);
536  assert(!lockToCoreSelectors || core==internal);
537  return internal;
538  }
539 
540 
544 
545  bool ww_elBase(HWW& hww, unsigned int index){
546  if (hww.els_p4().at(index).pt() < 10.0) return false;
547  if (fabs(hww.els_p4().at(index).eta()) > 2.5) return false;
548  return true;
549  }
550 
551 
552  bool ww_elId(HWW& hww, unsigned int index, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator* egammaMvaEleEstimator) {
553 
554  if (useLHeleId) {
555  if (hww.els_p4().at(index).pt()>20 && (passLikelihoodId_v2(hww, index,hww.els_lh().at(index),0) & (1<<ELEID_ID))!=(1<<ELEID_ID) ) return false;
556  if (hww.els_p4().at(index).pt()<20 && (passLikelihoodId_v2(hww, index,hww.els_lh().at(index),0) & (1<<ELEID_ID))!=(1<<ELEID_ID) ) return false;
557  }
558  if (useMVAeleId>0){
559  if (!goodElectronTMVA(hww, egammaMvaEleEstimator, useMVAeleId, index)) return false;
560  } else {
561  if (!pass_electronSelection(hww, index, electronSelection_smurfV3_id, false, false) ) return false;
562  }
563 
564  // MIT conversion
565  if ( isFromConversionMIT(hww, index) ) return false;
566  // conversion rejection - hit based
567  if ( hww.els_exp_innerlayers().at(index) > 0 ) return false;
568 
569  return true;
570  }
571 
572  bool ww_eld0(HWW& hww, unsigned int index){
573  return fabs(hww.els_d0corr().at(index)) < 0.02;
574  }
575 
576 
577  bool ww_eld0PV(HWW& hww, unsigned int index){
578  int vtxIndex = primaryVertex();
579  if (vtxIndex<0) return false;
580  double dxyPV = hww.els_d0().at(index)-
581  hww.vtxs_position().at(vtxIndex).x()*sin(hww.els_trk_p4().at(index).phi())+
582  hww.vtxs_position().at(vtxIndex).y()*cos(hww.els_trk_p4().at(index).phi());
583  return fabs(dxyPV) < 0.02;
584  }
585 
586  bool ww_eldZPV(HWW& hww, unsigned int index){
587  int vtxIndex = primaryVertex();
588  if (vtxIndex<0) return false;
589  double dzpv = dzPV(hww.els_vertex_p4().at(index), hww.els_trk_p4().at(index), hww.vtxs_position().at(vtxIndex));
590  return fabs(dzpv)<0.1;
591  }
592 
593  double ww_elIsoVal(HWW& hww, unsigned int index){
595  }
596 
597  bool ww_elIso(HWW& hww, unsigned int index){
598  float pfiso = ww_elIsoVal(hww, index);
599  return pfiso<0.15;
600  }
601 
602 
606 
607  bool ww_muBase(HWW& hww, unsigned int index){
608  if (hww.mus_p4().at(index).pt() < 10.0) return false;
609  if (fabs(hww.mus_p4().at(index).eta()) > 2.4) return false;
610  if (hww.mus_type().at(index) == 8) return false; // not STA
611  return true;
612  }
613 
614  bool ww_mud0(HWW& hww, unsigned int index){
615  return fabs(hww.mus_d0corr().at(index)) < 0.02;
616  }
617 
618  double ww_mud0ValuePV(HWW& hww, unsigned int index){
619  int vtxIndex = primaryVertex();
620  if (vtxIndex<0) return 9999;
621  double dxyPV = hww.mus_d0().at(index)-
622  hww.vtxs_position().at(vtxIndex).x()*sin(hww.mus_trk_p4().at(index).phi())+
623  hww.vtxs_position().at(vtxIndex).y()*cos(hww.mus_trk_p4().at(index).phi());
624  return fabs(dxyPV);
625  }
626 
627  bool ww_mud0PV(HWW& hww, unsigned int index){
628  if ( hww.mus_p4().at(index).pt() < 20. ) return ww_mud0ValuePV(hww, index) < 0.01;
629  return ww_mud0ValuePV(hww, index) < 0.02;
630  }
631 
632  bool ww_mudZPV(HWW& hww, unsigned int index, float cut){
633  int vtxIndex = primaryVertex();
634  if (vtxIndex<0) return false;
635  double dzpv = dzPV(hww.mus_vertex_p4().at(index), hww.mus_trk_p4().at(index), hww.vtxs_position().at(vtxIndex));
636  return fabs(dzpv)<cut;
637  }
638 
639  bool ww_muId(HWW& hww, unsigned int index, bool useMVAmuId, MuonIDMVA *mva){
640  if (useMVAmuId){
641  if (!goodMuonTMVA(hww, mva,index)) return false;
642  return true;
643  }
644 
645  if (((hww.mus_type().at(index)) & (1<<2)) == 0) return false; // tracker muon
646  if (hww.trks_nlayers().at(hww.mus_trkidx().at(index)) < 6) return false; // # of tracker hits
647  if (hww.mus_ptErr().at(index)/hww.mus_trk_p4().at(index).pt()>0.1) return false; // Does pt come from track?
648  if (hww.trks_valid_pixelhits().at(hww.mus_trkidx().at(index))==0) return false;
649  if (hww.mus_trkKink().at(index) > 20.) return false; //kink finder
650  if (!hww.mus_pid_PFMuon().at(index)) return false; // should be a pfmuon
651  // global muon
652  bool goodMuonGlobalMuon = false;
653  if (((hww.mus_type().at(index)) & (1<<1)) == (1<<1)){
654  goodMuonGlobalMuon = true;
655  if (hww.mus_gfit_chi2().at(index)/hww.mus_gfit_ndof().at(index) >= 10) goodMuonGlobalMuon = false; //glb fit chisq
656  if (hww.mus_gfit_validSTAHits().at(index)==0 ) goodMuonGlobalMuon = false;
657  if (hww.mus_nmatches().at(index)<2) goodMuonGlobalMuon = false;
658  }
659  return goodMuonGlobalMuon ||
660  hww.mus_pid_TMLastStationTight().at(index) == 1; // TM id
661  }
662 
663  double ww_muIsoVal(HWW& hww, unsigned int index){
664  double sum = hww.mus_iso03_sumPt().at(index) +
665  hww.mus_iso03_emEt().at(index) +
666  hww.mus_iso03_hadEt().at(index);
667  double pt = hww.mus_p4().at(index).pt();
668  return sum/pt;
669  }
670 
671  bool ww_muIso(HWW& hww, unsigned int index){
672  if (hww.mus_p4().at(index).pt()>20) {
673  if (TMath::Abs(hww.mus_p4().at(index).eta())<1.479)
674  return muonIsoValuePF(hww, index,0,0.3) < 0.13;
675  else
676  return muonIsoValuePF(hww, index,0,0.3) < 0.09;
677  } else {
678  if (TMath::Abs(hww.mus_p4().at(index).eta())<1.479)
679  return muonIsoValuePF(hww, index,0,0.3) < 0.06;
680  else
681  return muonIsoValuePF(hww, index,0,0.3) < 0.05;
682  }
683  }
684 
685  bool ww_muIso(HWW& hww, unsigned int index, MuonMVAEstimator* muonMVAEstimator, std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle){
686  return passMuonRingsMVA(hww, index, muonMVAEstimator, IdentifiedMu, IdentifiedEle);
687  }
688 
689 
690 
691  bool goodElectronTMVA(HWW& hww, EGammaMvaEleEstimator* egammaMvaEleEstimator, int useMVAeleId, unsigned int i)
692  {
693 
694  float pt = hww.els_p4().at(i).pt();
695  float etaSC = hww.els_etaSC().at(i);
696 
697  //preselection
698  if (fabs(etaSC)<1.479) {
699  if (hww.els_sigmaIEtaIEta().at(i)>0.01 ||
700  fabs(hww.els_dEtaIn().at(i))>0.007 ||
701  fabs(hww.els_dPhiIn().at(i))>0.15 ||
702  hww.els_hOverE().at(i)>0.12 ||
703  hww.els_tkIso().at(i)/pt>0.2 ||
704  TMath::Max(hww.els_ecalIso().at(i) - 1.0, 0.0)/pt>0.20 ||
705  hww.els_hcalIso().at(i)/pt>0.20 ) return 0;
706  } else {
707  if (hww.els_sigmaIEtaIEta().at(i)>0.03 ||
708  fabs(hww.els_dEtaIn().at(i))>0.009 ||
709  fabs(hww.els_dPhiIn().at(i))>0.10 ||
710  hww.els_hOverE().at(i)>0.10 ||
711  hww.els_tkIso().at(i)/pt>0.2 ||
712  hww.els_ecalIso().at(i)/pt>0.20 ||
713  hww.els_hcalIso().at(i)/pt>0.20 ) return 0;
714  }
715 
716  // MIT conversion
717  if ( isFromConversionMIT(hww, i) ) return false;
718  // conversion rejection - hit based
719  if ( hww.els_exp_innerlayers().at(i) > 0 ) return false;
720 
721  double mvavalue = egammaMvaEleEstimator->mvaValue(hww, i,false);
722 
723  if( pt > 20 ) {
724  if( fabs(etaSC)>=1.479 && mvavalue>0.92) return true;
725  if( fabs(etaSC)>=0.8 && fabs(etaSC)<1.479 && mvavalue>0.85) return true;
726  if( fabs(etaSC)<0.8 && mvavalue>0.94) return true;
727  return false;
728  }
729  else {
730  if( fabs(etaSC)>=1.479 && mvavalue>0.62) return true;
731  if( fabs(etaSC)>=0.8 && fabs(etaSC)<1.479 && mvavalue>0.1) return true;
732  if( fabs(etaSC)<0.8 && mvavalue>0.0) return true;
733  return false;
734  }
735  }
736 
737  bool passMuonRingsMVA(HWW& hww, unsigned int mu, MuonMVAEstimator* muonMVAEstimator, std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle)
738  {
739  double mvavalue = muonMVAEstimator->mvaValueIso(hww, mu, hww.evt_ww_rho(), MuonEffectiveArea::kMuEAFall11MC,
740  IdentifiedEle, IdentifiedMu, false );
741 
742  double pt = hww.mus_trk_p4().at(mu).pt();
743  double eta = hww.mus_trk_p4().at(mu).eta();
744 
745  if( pt>20 ) {
746  if( fabs(eta)>=1.479 && fabs(eta)<2.4 && mvavalue>0.86 ) return true;
747  if( fabs(eta)<1.479 && mvavalue>0.82 ) return true;
748  return false;
749  }
750  else {
751  if( fabs(eta)>=1.479 && fabs(eta)<2.4 && mvavalue>0.82 ) return true;
752  if( fabs(eta)<1.479 && mvavalue>0.86 ) return true;
753  return false;
754  }
755  }
756 
757  bool passMuonRingsMVAFO(HWW& hww, unsigned int mu, MuonMVAEstimator* muonMVAEstimator, std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle)
758  {
759  double mvavalue = muonMVAEstimator->mvaValueIso(hww, mu, hww.evt_ww_rho(), MuonEffectiveArea::kMuEAFall11MC,
760  IdentifiedEle, IdentifiedMu, false );
761 
762  if( mvavalue>-0.6 ) return true;
763  return false;
764  }
765 
766  bool MuonFOV2(HWW& hww, unsigned int i, MuonMVAEstimator* muonMVAEstimator,
767  std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle){
768 
769  if (((hww.mus_type().at(i)) & (1<<2)) == 0) return false; // tracker muon
770  if (hww.trks_nlayers().at(hww.mus_trkidx().at(i)) < 6) return false; // # of tracker hits
771  if (hww.mus_ptErr().at(i)/hww.mus_trk_p4().at(i).pt()>0.1) return false; // Does pt come from track?
772  if (hww.trks_valid_pixelhits().at(hww.mus_trkidx().at(i))==0) return false;
773  if (hww.mus_trkKink().at(i) > 20.) return false; //kink finder
774  if (!hww.mus_pid_PFMuon().at(i)) return false; // should be a pfmuon
775  // global muon
776  bool goodMuonGlobalMuon = false;
777  if (((hww.mus_type().at(i)) & (1<<1)) == (1<<1)) {
778  goodMuonGlobalMuon = true;
779  if (hww.mus_gfit_chi2().at(i)/hww.mus_gfit_ndof().at(i) >= 10) goodMuonGlobalMuon = false; //glb fit chisq
780  if (hww.mus_gfit_validSTAHits().at(i)==0 ) goodMuonGlobalMuon = false;
781  if (hww.mus_nmatches().at(i)<2) goodMuonGlobalMuon = false;
782  }
783 
784  return (goodMuonGlobalMuon || hww.mus_pid_TMLastStationTight().at(i) == 1) && // ---> Id
785  ww_muBase(hww, i) &&
786  ww_mud0ValuePV(hww, i)<0.2 &&
787  ww_mudZPV(hww, i) &&
788  passMuonRingsMVAFO(hww, i, muonMVAEstimator, IdentifiedMu, IdentifiedEle);
789  }
790 
791 
792  bool fakableMuon(HWW& hww, unsigned int i, MuFOTypes type,MuonMVAEstimator* muonMVAEstimator,
793  std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle){
794  if ( hww.mus_p4().at(i).pt() < 10.0 ) return false;
795  switch (type){
796  case MuFOV1: return muonId(hww, i, muonSelectionFO_mu_smurf_10);
797  case MuFOV2: return MuonFOV2(hww, i, muonMVAEstimator, IdentifiedMu, IdentifiedEle);
798  }
799  return false;
800  }
801 
802 
803  std::vector<LeptonPair> getExtraLeptons(HWW& hww, int i_hyp, double minPt, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator* egammaMvaEleEstimator, bool useMVAmuId, MuonIDMVA *mumva,
804  MuonMVAEstimator* muonMVAEstimator, std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle ){
805 
806  std::vector<LeptonPair> leptons;
807  for (int i=0; i < int(hww.mus_charge().size()); ++i) {
808  if ( hww.mus_p4().at(i).pt() < minPt ) continue;
809  if ( TMath::Abs(hww.hyp_lt_id().at(i_hyp)) == 13 && hww.hyp_lt_index().at(i_hyp) == i ) continue;
810  if ( TMath::Abs(hww.hyp_ll_id().at(i_hyp)) == 13 && hww.hyp_ll_index().at(i_hyp) == i ) continue;
811  if ( ! (ww_mud0PV(hww, i) && ww_muId(hww, i, useMVAmuId, mumva) && ww_muIso(hww, i, muonMVAEstimator, IdentifiedMu, IdentifiedEle) &&
812  fabs(hww.mus_p4().at(i).eta()) <2.4) ) continue;
813  leptons.push_back(LeptonPair(true,i));
814  }
815  for (int i=0; i < int(hww.els_charge().size()); ++i) {
816  if ( hww.els_p4().at(i).pt() < minPt ) continue;
817  if ( TMath::Abs(ROOT::Math::VectorUtil::DeltaR(hww.hyp_lt_p4().at(i_hyp),hww.els_p4().at(i)) <0.1) ) continue;
818  if ( TMath::Abs(ROOT::Math::VectorUtil::DeltaR(hww.hyp_ll_p4().at(i_hyp),hww.els_p4().at(i)) <0.1) ) continue;
819  if ( !(ww_elId(hww, i, useLHeleId, useMVAeleId, egammaMvaEleEstimator) && ww_eld0PV(hww, i) && ww_elIso(hww, i) &&
820  fabs(hww.els_p4().at(i).eta()) < 2.5) ) continue;
821  leptons.push_back(LeptonPair(false,i));
822  }
823  return leptons;
824  }
825 
826  unsigned int numberOfExtraLeptons(HWW& hww, int i_hyp, double minPt, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator* egammaMvaEleEstimator, bool useMVAmuId, MuonIDMVA *mumva,
827  MuonMVAEstimator* muonMVAEstimator, std::vector<Int_t> IdentifiedMu, std::vector<Int_t> IdentifiedEle){
828  return getExtraLeptons(hww, i_hyp, minPt, useLHeleId, useMVAeleId, egammaMvaEleEstimator, useMVAmuId, mumva,muonMVAEstimator,IdentifiedMu,IdentifiedEle).size();
829  }
830 
831 
832  unsigned int numberOfSoftMuons(HWW& hww, int i_hyp, bool nonisolated)
833  {
834 
835  const std::vector<JetPair> vetojets = std::vector<JetPair>(); //empty, so there is no jet veto
836 
837  unsigned int nMuons = 0;
838  for (int imu=0; imu < int(hww.mus_charge().size()); ++imu) {
839  // quality cuts
840  if ( ((hww.mus_goodmask().at(imu)) & (1<<19)) == 0 ) continue; // TMLastStationAngTight
841  if ( hww.mus_p4().at(imu).pt() < 3 ) continue;
842  if ( ww_mud0ValuePV(hww, imu) > 0.2) continue;
843  if ( ! ww_mudZPV(hww, imu,0.2) ) continue; //newcuts, was 0.1
844  if (hww.trks_nlayers().at(hww.mus_trkidx().at(imu)) < 6) return false; // # of tracker hits
845  if ( TMath::Abs(hww.hyp_lt_id().at(i_hyp)) == 13 && hww.hyp_lt_index().at(i_hyp) == imu ) continue;
846  if ( TMath::Abs(hww.hyp_ll_id().at(i_hyp)) == 13 && hww.hyp_ll_index().at(i_hyp) == imu ) continue;
847  if ( nonisolated && ww_muIsoVal(hww, imu)<0.1 && hww.mus_p4().at(imu).pt()>20 ) continue;
848  bool skip = false;
849  for ( std::vector<JetPair>::const_iterator ijet = vetojets.begin(); ijet != vetojets.end(); ++ijet ){
850  if ( TMath::Abs(ROOT::Math::VectorUtil::DeltaR(ijet->first,hww.mus_p4().at(imu))) < 0.3 ) skip=true;
851  }
852  if ( skip ) continue;
853  ++nMuons;
854  }
855  return nMuons;
856  }
857 
858 
859  double nearestDeltaPhi(HWW& hww, double Phi, int i_hyp)
860  {
861  double tightDPhi = fabs(hww.hyp_lt_p4().at(i_hyp).Phi() - Phi);
862  tightDPhi = std::min(2*TMath::Pi() - tightDPhi, tightDPhi);
863  double looseDPhi = fabs(hww.hyp_ll_p4().at(i_hyp).Phi() - Phi);
864  looseDPhi = std::min(2*TMath::Pi() - looseDPhi, looseDPhi);
865  return TMath::Min(tightDPhi, looseDPhi);
866  }
867 
868 
869  double projectedMet(HWW& hww, unsigned int i_hyp, double met, double phi)
870  {
871  double DeltaPhi = nearestDeltaPhi(hww, phi,i_hyp);
872  if (DeltaPhi < TMath::Pi()/2) return met*TMath::Sin(DeltaPhi);
873  return met;
874  }
875 
876 
877 
878  bool toptag(HWW& hww, int i_hyp, double minPt, std::vector<JetPair> ignoreJets)
879  {
880  const double vetoCone = 0.3;
881  // bug fix for mva jet id
882  vector <float> fixedpfjetmva_analsel; getGoodMVAs(hww, fixedpfjetmva_analsel, "mvavalue");
883 
884  for ( unsigned int i=0; i < hww.pfjets_p4().size(); ++i) {
885  if (i >= hww.pfjets_JEC().size())
886  break;
887 
888  if ( hww.pfjets_p4().at(i).pt() < minPt ) continue;
889  bool ignoreJet = false;
890  for ( std::vector<JetPair>::const_iterator ijet = ignoreJets.begin();
891  ijet != ignoreJets.end(); ++ijet )
892  if ( TMath::Abs(ROOT::Math::VectorUtil::DeltaR(ijet->first,hww.pfjets_p4().at(i))) < vetoCone ) ignoreJet=true;
893  if ( ignoreJet ) continue;
894 
895  if ( TMath::Abs(ROOT::Math::VectorUtil::DeltaR(hww.hyp_lt_p4().at(i_hyp),hww.pfjets_p4().at(i))) < vetoCone ||
896  TMath::Abs(ROOT::Math::VectorUtil::DeltaR(hww.hyp_ll_p4().at(i_hyp),hww.pfjets_p4().at(i))) < vetoCone ) continue;
897 
898  double jec = hww.pfjets_JEC().at(i);
899 
900  if ( !passMVAJetId( hww.pfjets_p4().at(i).pt() * jec, hww.pfjets_p4().at(i).eta(), fixedpfjetmva_analsel[i], 2) ) continue;
901 
902  if ( !defaultBTag(hww, i, jec) ) continue;
903 
904  return true;
905  }
906  return false;
907  }
908 }
static const cuts_t electronSelection_smurfV6
float & evt_pfmetPhi()
Definition: HWW.cc:643
bool ww_mud0(HWW &hww, unsigned int i)
bool ww_muId(HWW &hww, unsigned int i, bool useMVAmuId, MuonIDMVA *mva)
const double Pi
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
std::vector< float > & trk_met()
Definition: HWW.cc:761
bool passMinMet40(HWW &, int)
bool fakableElectron(HWW &hww, unsigned int i, EleFOTypes)
Bool_t comparePt(JetPair lv1, JetPair lv2)
std::vector< int > & mus_pid_PFMuon()
Definition: HWW.cc:539
Double_t mvaValue(Double_t fbrem, Double_t kfchi2, Int_t kfhits, Double_t gsfchi2, Double_t deta, Double_t dphi, Double_t detacalo, Double_t see, Double_t spp, Double_t etawidth, Double_t phiwidth, Double_t e1x5e5x5, Double_t R9, Double_t HoE, Double_t EoP, Double_t IoEmIoP, Double_t eleEoPout, Double_t PreShowerOverRaw, Double_t d0, Double_t ip3d, Double_t eta, Double_t pt, Bool_t printDebug=kFALSE)
double ww_muIsoVal(HWW &hww, unsigned int i)
std::vector< float > & els_tkIso()
Definition: HWW.cc:137
std::vector< int > & els_exp_innerlayers()
Definition: HWW.cc:337
std::vector< int > & hyp_ll_id()
Definition: HWW.cc:585
std::vector< int > & trks_valid_pixelhits()
Definition: HWW.cc:63
bool ww_elId(HWW &hww, unsigned int i, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator *egammaMvaEleEstimator)
std::pair< LorentzVector, unsigned int > JetPair
Definition: analysisEnums.h:11
bool passLikelihoodId_v2(HWW &, unsigned int index, float lhValue, int workingPoint)
float & evt_pfmet()
Definition: HWW.cc:639
HypothesisType getHypothesisTypeNew(HWW &, unsigned int i_hyp)
Definition: wwtypes.cc:57
bool passTopVeto(HWW &, int)
EleFOTypes
Definition: analysisEnums.h:25
bool goodElectronIsolated(HWW &hww, unsigned int i, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator *egammaMvaEleEstimator, bool lockToCoreSelectors)
std::vector< float > & mus_gfit_chi2()
Definition: HWW.cc:383
bool passCharge(HWW &, int)
bool goodElectronTMVA(HWW &hww, EGammaMvaEleEstimator *egammaMvaEleEstimator, int useMVAeleId, unsigned int i)
std::vector< float > & mus_d0corr()
Definition: HWW.cc:399
unsigned int numberOfSoftMuons(HWW &hww, int i_hyp, bool nonisolated)
bool passBaseline(HWW &, int, EGammaMvaEleEstimator *, MuonMVAEstimator *)
std::vector< LorentzVector > & els_vertex_p4()
Definition: HWW.cc:109
std::vector< float > & els_hOverE()
Definition: HWW.cc:133
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
assert(m_qm.get())
bool muonId(HWW &, unsigned int index, SelectionType type)
bool goodElectronWithoutIsolation(HWW &hww, unsigned int i, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator *egammaMvaEleEstimator)
std::vector< int > & mus_pid_TMLastStationTight()
Definition: HWW.cc:543
std::vector< float > & els_d0corr()
Definition: HWW.cc:141
bool passMVAJetId(double, double, double, unsigned int)
std::vector< float > & trk_metPhi()
Definition: HWW.cc:765
std::vector< int > & mus_trkidx()
Definition: HWW.cc:535
bool ww_eldZPV(HWW &hww, unsigned int i)
bool goodMuonWithoutIsolation(HWW &hww, unsigned int i, bool useMVAmuId, MuonIDMVA *mva, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
std::vector< float > & els_d0()
Definition: HWW.cc:145
std::vector< float > & mus_ptErr()
Definition: HWW.cc:391
std::vector< int > & hyp_lt_index()
Definition: HWW.cc:581
bool toptag(HWW &hww, int i_hyp, double minPt, std::vector< JetPair > ignoreJets=std::vector< JetPair >())
std::vector< LeptonPair > getExtraLeptons(HWW &hww, int i_hyp, double minPt, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator *egammaMvaEleEstimator, bool useMVAmuId, MuonIDMVA *mumva, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
std::vector< LorentzVector > & mus_p4()
Definition: HWW.cc:367
bool ElectronFOV4(HWW &hww, unsigned int i)
std::vector< float > & mus_iso03_hadEt()
Definition: HWW.cc:467
std::vector< int > & mus_nmatches()
Definition: HWW.cc:547
T Min(T a, T b)
Definition: MathUtil.h:39
MuFOTypes
Definition: analysisEnums.h:26
bool goodMuonTMVA(HWW &hww, MuonIDMVA *mva, unsigned int i)
bool ww_eld0(HWW &hww, unsigned int i)
std::vector< float > & mus_iso03_sumPt()
Definition: HWW.cc:459
std::vector< float > & trks_d0()
Definition: HWW.cc:55
float electronIsoValuePF2012_FastJetEffArea_HWW(HWW &, int index)
std::vector< int > & mus_gfit_validSTAHits()
Definition: HWW.cc:515
std::pair< bool, unsigned int > LeptonPair
Definition: analysisEnums.h:12
bool passMuonRingsMVA(HWW &hww, unsigned int mu, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
double ww_mud0ValuePV(HWW &hww, unsigned int index)
double projectedMet(HWW &hww, unsigned int i_hyp, double met, double phi)
bool ww_elIso(HWW &hww, unsigned int i)
bool ww_mud0PV(HWW &hww, unsigned int i)
bool defaultBTag(HWW &hww, unsigned int, float)
bool ElectronFOIdV4(HWW &hww, unsigned int i)
std::vector< LorentzVector > & hyp_ll_p4()
Definition: HWW.cc:569
bool passDPhiDiLepJet(HWW &, int)
std::vector< LorentzVector > & mus_trk_p4()
Definition: HWW.cc:371
std::vector< int > & mus_validHits()
Definition: HWW.cc:531
bool fakableMuon(HWW &hww, unsigned int i, MuFOTypes, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
std::vector< float > & els_ecalIso()
Definition: HWW.cc:261
static const cuts_t electronSelectionFO_el_smurf_v1
std::vector< JetPair > getJets(HWW &hww, int, double, double, bool, bool)
void count(HypothesisType type, const char *name, double weight=1.0)
Definition: monitor.cc:53
vector< PseudoJet > jets
static const cuts_t electronSelection_smurfV3_id
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< float > & vtxs_ndof()
Definition: HWW.cc:9
T Abs(T a)
Definition: MathUtil.h:49
std::vector< int > & mus_charge()
Definition: HWW.cc:527
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< float > & mus_gfit_ndof()
Definition: HWW.cc:387
std::vector< float > & els_lh()
Definition: HWW.cc:113
int bestHypothesis(HWW &hww, const std::vector< int > &)
unsigned int numberOfJets(HWW &hww, unsigned int)
Double_t mvaValueIso(HWW &, Int_t imu, Double_t rho, MuonEffectiveArea::MuonEffectiveAreaTarget EATarget, std::vector< Int_t > IdentifiedEle, std::vector< Int_t > IdentifiedMu, Bool_t printDebug)
std::vector< LorentzVector > & vtxs_position()
Definition: HWW.cc:5
const int mu
Definition: Constants.h:22
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< int > & hyp_type()
Definition: HWW.cc:601
std::vector< float > & els_hcalIso()
Definition: HWW.cc:265
std::vector< LorentzVector > & els_p4()
Definition: HWW.cc:101
std::vector< float > & els_etaSC()
Definition: HWW.cc:117
bool ww_elBase(HWW &hww, unsigned int i)
static const cuts_t electronSelectionFO_el_smurf_v3
bool pass_electronSelection(HWW &, const unsigned int index, const cuts_t selectionType, bool applyAlignmentCorrection=false, bool removedEtaCutInEndcap=false, bool useGsfTrack=true)
bool ww_muBase(HWW &hww, unsigned int i)
Definition: HWW.h:12
bool passExtraLeptonVeto(HWW &, int, EGammaMvaEleEstimator *, MuonMVAEstimator *)
tuple btag
Definition: BTagSF.py:17
bool goodMuonIsolated(HWW &hww, unsigned int i, bool lockToCoreSelectors, bool useMVAmuId, MuonIDMVA *mva, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
bool passSoftMuonVeto(HWW &, int)
T Max(T a, T b)
Definition: MathUtil.h:44
void doCutFlow(HWW &, int, EventMonitor &, EGammaMvaEleEstimator *, MuonMVAEstimator *)
bool ww_mudZPV(HWW &hww, unsigned int i, float cut=0.1)
double muonIsoValuePF(HWW &, unsigned int imu, unsigned int ivtx, float coner=0.4, float minptn=1.0, float dzcut=0.1, int filterId=0)
bool passFirstCuts(HWW &, int)
std::vector< float > & mus_trkKink()
Definition: HWW.cc:395
bool MuonFOV2(HWW &hww, unsigned int i, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
unsigned int nGoodVertex(HWW &hww)
std::vector< int > & els_charge()
Definition: HWW.cc:329
bool getGoodMVAs(HWW &, std::vector< float > &goodmvas, std::string variable)
std::vector< LorentzVector > & hyp_p4()
Definition: HWW.cc:565
std::vector< float > & pfjets_trackCountingHighEffBJetTag()
Definition: HWW.cc:789
std::vector< float > & mus_d0()
Definition: HWW.cc:403
bool isFromConversionMIT(HWW &, const unsigned int index)
double nearestDeltaPhi(HWW &hww, double Phi, int i_hyp)
double ww_elIsoVal(HWW &hww, unsigned int i)
std::vector< int > & hyp_lt_id()
Definition: HWW.cc:589
bool passMuonRingsMVAFO(HWW &hww, unsigned int mu, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
std::vector< float > & els_dPhiIn()
Definition: HWW.cc:129
double dzPV(const LorentzVector &vtx, const LorentzVector &p4, const LorentzVector &pv)
std::vector< LorentzVector > & hyp_lt_p4()
Definition: HWW.cc:573
std::vector< int > & vtxs_isFake()
Definition: HWW.cc:17
std::vector< float > & pfjets_JEC()
Definition: HWW.cc:781
std::vector< float > & els_dEtaIn()
Definition: HWW.cc:125
bool ww_muIso(HWW &hww, unsigned int i)
bool passFullLep(HWW &, int, EGammaMvaEleEstimator *, MuonMVAEstimator *)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: pfjetMVAtools.h:10
std::vector< int > & trks_nlayers()
Definition: HWW.cc:59
float & evt_ww_rho()
Definition: HWW.cc:627
std::vector< LorentzVector > & pfjets_p4()
Definition: HWW.cc:769
volatile std::atomic< bool > shutdown_flag false
int weight
Definition: histoStyle.py:50
std::vector< LorentzVector > & mus_vertex_p4()
Definition: HWW.cc:375
std::vector< JetPair > getDefaultJets(HWW &hww, unsigned int, bool)
std::vector< float > & els_sigmaIEtaIEta()
Definition: HWW.cc:121
Double_t MVAValue(HWW &, const unsigned int mu, const unsigned int vertex)
Definition: MuonIDMVA.cc:211
bool ww_eld0PV(HWW &hww, unsigned int i)
std::vector< int > & mus_goodmask()
Definition: HWW.cc:551
unsigned int numberOfExtraLeptons(HWW &hww, int i_hyp, double minPt, bool useLHeleId, int useMVAeleId, EGammaMvaEleEstimator *egammaMvaEleEstimator, bool useMVAmuId, MuonIDMVA *mumva, MuonMVAEstimator *muonMVAEstimator, std::vector< Int_t > IdentifiedMu, std::vector< Int_t > IdentifiedEle)
static const cuts_t electronSelectionFO_el_smurf_v2
std::vector< float > & vtxs_sumpt()
Definition: HWW.cc:13
std::vector< float > & mus_iso03_emEt()
Definition: HWW.cc:463
std::vector< LorentzVector > & els_trk_p4()
Definition: HWW.cc:105
bool passMinMet(HWW &, int)
std::vector< int > & mus_type()
Definition: HWW.cc:555
bool passZVeto(HWW &, int)
bool isGoodVertex(HWW &hww, int)
std::vector< int > & hyp_ll_index()
Definition: HWW.cc:577