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

Comparing UserCode/MitHzz4l/Selection/src/Selection.cc (file contents):
Revision 1.9 by khahn, Fri Oct 14 11:38:10 2011 UTC vs.
Revision 1.17 by khahn, Mon Nov 7 06:53:01 2011 UTC

# Line 7 | Line 7
7   #include "HZZLikelihoodElectronSelection.h"
8   #include "HZZBDTElectronSelection.h"
9   #include "RunLumiRangeMap.h"
10 + #include "EfficiencyWeightsInterface.h"
11  
12   RunLumiRangeMap rlrm;
13 + TH1D * hpu;
14  
15 +
16 + // #include "TH2D.h"
17 + // extern TH2D * h_mu_eff_idiso_2011a;
18 + // extern TH2D * h_mu_eff_idiso_s11;
19 + // extern TH2D * h_mu_effdata_trigger_doublemu7_2011a;
20 + // extern TH2D * h_mu_effdata_trigger_doublemu13_8_leading_2011a;
21 + // extern TH2D * h_mu_effdata_trigger_doublemu13_8_trailing_2011a;
22 +
23 + // unsigned getGenChannel(mithep::TGenInfo * ginfo) {
24 + //   int gchannel=-1;
25 + //   if( abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kElectron )  gchannel=0;
26 + //   else if( abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kMuon ) gchannel=1;
27 + //   else if( (abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kMuon) ||
28 + //         (abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kElectron) ) gchannel=2;
29 +  
30 + //   return gchannel;
31 + // };
32 +
33   void initRunLumiRangeMap() {
34    rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
35 <  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
35 >  //  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
36 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
37 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));  
38 >  rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));  
39 >  TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Run2011A.root");
40 >  hpu = (TH1D*)(puf->Get("puWeights"));
41 > };
42 >
43 > void initRunLumiRangeMap(RunLumiRangeMap &rlrm) {
44 >  cout << "adding JSONS ... "  << endl;
45 >  rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
46 >  //  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
47 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
48    rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));  
49    rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));  
50   };
51  
52 + // unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
53 + //                             mithep::TEventInfo *info,     // input event inof
54 + //                             TClonesArray *electronArr,    // input electrons
55 + //                             TClonesArray *muonArr,        // input muons
56 + //                             double eventweight,           // weight
57 + //                             TTree * passtuple ) {
58 +
59 + //   fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL );
60 +
61 + // };
62 +
63 +
64 +
65 + // unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
66 + //                             mithep::TEventInfo *info,     // input event inof
67 + //                             TClonesArray *electronArr,    // input electrons
68 + //                             TClonesArray *muonArr,        // input muons
69 + //                             double eventweight,           // weight
70 + //                             LabVectors  *l ) {
71 +
72 + //   fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, NULL, l );
73 +
74 + // };
75 +
76 +
77   unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
78 <                               mithep::TEventInfo *info,     // input event inof
78 >                               mithep::TGenInfo *ginfo ,     // input gen info
79 >                               mithep::TEventInfo *info,     // input event info
80                                 TClonesArray *electronArr,    // input electrons
81                                 TClonesArray *muonArr,        // input muons
82                                 double eventweight,           // weight
83                                 TTree * passtuple ) {
84  
85 <  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL );
85 >  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL, NULL );
86  
87   };
88  
89   unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
90 <                               mithep::TEventInfo *info,     // input event inof
90 >                               mithep::TEventInfo *info,     // input event info
91                                 TClonesArray *electronArr,    // input electrons
92                                 TClonesArray *muonArr,        // input muons
93                                 double eventweight,           // weight
94 <                               LabVectors  *l ) {
95 <
96 <  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, NULL, l );
97 <
40 < };
94 >                               TTree * passtuple,
95 >                               LabVectors * l ) {
96 >  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, l, NULL );
97 > }
98  
99  
100   unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
101 <                               mithep::TEventInfo *info,     // input event inof
101 >                               mithep::TEventInfo *info,     // input event info
102                                 TClonesArray *electronArr,    // input electrons
103                                 TClonesArray *muonArr,        // input muons
104                                 double eventweight,           // weight
105                                 TTree * passtuple,
106 <                               LabVectors * l) {       // output ntuple
106 >                               LabVectors * l=NULL,
107 >                               TClonesArray *jetArr=NULL ) {       // output ntuple
108  
109    unsigned evtfail = 0x0;
110 +  unsigned gchannel=0xdeaddead;
111 +
112 + //   if( ctrl.mc && ginfo != NULL ) {
113 + //     gchannel = getGenChannel(ginfo);
114 + //   }
115  
116  
117    if( ctrl.debug ) {
# Line 58 | Line 121 | unsigned fails_HZZ4L_selection(ControlFl
121           << endl;
122    }
123  
124 +  unsigned npu; double npuw;
125    if( !ctrl.mc ) {
126      // not accounting for overlap atm
127      RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);      
# Line 66 | Line 130 | unsigned fails_HZZ4L_selection(ControlFl
130        evtfail |= (1<<EVTFAIL_JSON);
131        return evtfail;
132      }
133 +  } else {
134 +    npu = info->nPU;
135 +    npuw = hpu->GetBinContent(hpu->FindBin(npu));
136    }
137    
138    
# Line 77 | Line 144 | unsigned fails_HZZ4L_selection(ControlFl
144    //********************************************************
145    if( !ctrl.mc ) {
146      //  if( !(passHLT(info->triggerBits, info->runNum, channel) )  ) {
147 <    if( !(passHLT(info->triggerBits, info->runNum, 999) )  ) {
148 <      evtfail |= (1<<EVTFAIL_TRIGGER);
149 <      return evtfail;
150 <    }  
147 > //     if( !(passHLT(info->triggerBits, info->runNum, 999) )  ) {
148 > //       evtfail |= (1<<EVTFAIL_TRIGGER);
149 > //       return evtfail;
150 > //     }        
151    } else {
152      if( !(passHLTMC(info->triggerBits)) ) {
153        evtfail |= (1<<EVTFAIL_TRIGGER);
# Line 106 | Line 173 | unsigned fails_HZZ4L_selection(ControlFl
173    //----------------------------------------------------
174    for(Int_t i=0; i<muonArr->GetEntries(); i++) {
175      const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
176 <    unsigned muonfail = passMuonSelectionZZ(mu);
176 >    unsigned muonfail;
177 >    if( ctrl.muSele == "ksWW" )
178 >      muonfail = passKSMuonSelection(mu);
179 >    else
180 >      muonfail = passMuonSelectionZZ(mu);
181      if( ctrl.debug ) {
182        cout << "muon:: pt: " << mu->pt
183             << "\teta: " << mu->eta
184             << "\tmask: 0x" << hex << muonfail << dec
185             << endl;
186      }
187 +
188 + #ifdef Z2FO
189 +    if ( isMuFO(mu) ) {
190 + #else
191      if ( !muonfail ) {
192 + #endif
193        SimpleLepton tmplep;
194 <      tmplep.vec.SetPtEtaPhiM(mu->pt,
194 >
195 >      float pt = mu->pt;
196 >      if( ctrl.do_escale_up   ) pt*=(1.01);
197 >      if( ctrl.do_escale_down ) pt*=(0.99);
198 >
199 >      tmplep.vec.SetPtEtaPhiM(pt,
200                                mu->eta,
201                                mu->phi,
202                                105.658369e-3);
203 +
204        tmplep.type    = 13;
205        tmplep.index   = i;
206        tmplep.charge  = mu->q;
207        tmplep.isoTrk  = mu->trkIso03;
208        tmplep.isoEcal = mu->emIso03;
209        tmplep.isoHcal = mu->hadIso03;
210 +      tmplep.isoPF03 = mu->pfIso03;
211        tmplep.isoPF04 = mu->pfIso04;
212        tmplep.ip3dSig = mu->ip3dSig;
213        tmplep.is4l    = false;
214        tmplep.isEB    = (fabs(mu->eta) < 1.479 ? 1 : 0 );
215 +      tmplep.isTight = (muonfail > 0 ? 0 : 1 );
216 +      tmplep.isLoose = (muonfail > 0 ? 0 : 1 );
217        lepvec.push_back(tmplep);
218        if( ctrl.debug ) { cout << "muon passes ... " << endl;}
219      }
# Line 140 | Line 225 | unsigned fails_HZZ4L_selection(ControlFl
225    for(Int_t i=0; i<electronArr->GetEntries(); i++) {
226      const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
227  
228 +    if( !(isEleFO(ctrl,ele) ) ) continue;
229 +    if( ele->pt < 7 ) continue; //move this to ID
230 +
231      Bool_t isMuonOverlap = kFALSE;
232      for (int k=0; k<lepvec.size(); ++k) {
233        TVector3 tmplep;
234        tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi);
235 <      if ( lepvec[k].type == 13 && lepvec[k].vec.Vect().DrEtaPhi(tmplep) < 0.1 ) {
235 >      if ( lepvec[k].isLoose && lepvec[k].type == 13 && lepvec[k].vec.Vect().DrEtaPhi(tmplep) < 0.1 ) {
236          if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
237          isMuonOverlap = kTRUE;
238          break;
239        }
240      }
241  
242 <    unsigned FAIL=0;
243 <    CICStruct ciccuts = getCiCCuts(ctrl.eleSeleScheme);
242 >    unsigned FAIL=0, isEleTight=0, isEleLoose=0;
243 >
244      unsigned  failsCIC=0;
245 +    CICStruct ciccuts_tight, ciccuts_medium, ciccuts_loose;
246      if(ctrl.eleSele=="cic") {
247 <      failsCIC = failsCicSelection(ctrl, ele, ciccuts, ctrl.kinematics);
247 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
248 >        ciccuts_medium = getCiCCuts("medium");
249 >        unsigned failsCICMedium = failsCicSelection(ctrl, ele, ciccuts_medium, ctrl.kinematics);
250 >        ciccuts_loose = getCiCCuts("loose");
251 >        unsigned failsCICLoose = failsCicSelection(ctrl, ele, ciccuts_loose, ctrl.kinematics);
252 >        failsCIC = ( failsCICLoose > 0 && failsCICMedium > 0 );
253 >        if( !failsCICMedium ) isEleTight=1;
254 >      }
255 >      else {
256 >        ciccuts_tight = getCiCCuts(ctrl.eleSeleScheme);
257 >        failsCIC = failsCicSelection(ctrl, ele, ciccuts_tight, ctrl.kinematics);
258 >        if( !failsCIC ) isEleTight=1;
259 >      }
260        FAIL = failsCIC;
261      }
262 +
263      LikStruct likcuts;
264      unsigned failsLike=0;
265      if(ctrl.eleSele=="lik") {
# Line 165 | Line 267 | unsigned fails_HZZ4L_selection(ControlFl
267        failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
268        FAIL = failsLike;
269      }
270 <    unsigned  failsBDT=0;
270 >    unsigned failsBDT=0;
271      if(ctrl.eleSele=="bdt") {
272 <      failsBDT = failsBDTSelection(ctrl,ele);
272 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
273 >        unsigned failsBDTMedium = failsBDTSelection(ctrl,"medium",ele);
274 >        unsigned failsBDTLoose  = failsBDTSelection(ctrl,"loose",ele);
275 >        failsBDT = ( failsBDTLoose > 0 && failsBDTMedium > 0 );
276 >        if( !failsBDTMedium ) isEleTight=1;
277 >        if( !failsBDTLoose ) isEleLoose=1;
278 >      } else {
279 >        failsBDT = failsBDTSelection(ctrl,"tight",ele);
280 >        if( !failsBDT ) isEleTight=1;
281 >      }
282        FAIL = failsBDT;
283      }
173    unsigned  failsSi=0;
174    if(ctrl.eleSele=="si") {
175      failsSi = failsSiMVAElectronSelection(ctrl, ele, 0.95, ctrl.kinematics);
176      FAIL = failsSi;
177    }
178
179
284  
285  
286      if( ctrl.debug ){
# Line 193 | Line 297 | unsigned fails_HZZ4L_selection(ControlFl
297      }
298      if ( !FAIL && !isMuonOverlap ) {
299        SimpleLepton tmplep;
300 <      tmplep.vec.SetPtEtaPhiM( ele->pt,
300 >
301 >      float pt = ele->pt;
302 >      if( ctrl.do_escale_up   ) pt*=(1.02);
303 >      if( ctrl.do_escale_down ) pt*=(0.98);
304 >
305 >      tmplep.vec.SetPtEtaPhiM( pt,
306                                 ele->eta,
307                                 ele->phi,
308                                 0.51099892e-3 );
# Line 203 | Line 312 | unsigned fails_HZZ4L_selection(ControlFl
312        tmplep.isoTrk  = ele->trkIso03;
313        tmplep.isoEcal = ele->emIso03;
314        tmplep.isoHcal = ele->hadIso03;
315 +      tmplep.isoPF03 = ele->pfIso03;
316        tmplep.isoPF04 = ele->pfIso04;
317        tmplep.ip3dSig = ele->ip3dSig;
318        tmplep.is4l    = false;
319 +      tmplep.isTight = isEleTight;
320        tmplep.isEB    = ele->isEB;
321        lepvec.push_back(tmplep);
322        if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
# Line 214 | Line 325 | unsigned fails_HZZ4L_selection(ControlFl
325    
326    sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
327  
328 +  for( int i=0; i<lepvec.size(); i++ ) {
329 +    //
330 +    //  check for a matched btagged jet
331 +    //
332 +    lepvec[i].tche = -1;
333 +    lepvec[i].tchp = -1;
334 +    lepvec[i].csv = -1;
335 +    lepvec[i].csvMva = -1;
336 +
337 +    if( jetArr != NULL ) {
338 +      for(int k=0; k<jetArr->GetEntries(); k++) {
339 +        const mithep::TJet *jet = (mithep::TJet*)((*jetArr)[k]);      
340 +        TVector3 jvec;
341 +        jvec.SetPtEtaPhi(jet->pt, jet->eta, jet->phi);
342 +        if( jvec.DrEtaPhi( lepvec[i].vec.Vect()) < 0.2 ) {
343 +          lepvec[i].tche = jet->tche;
344 +          lepvec[i].tchp = jet->tchp;
345 +          lepvec[i].csv = jet->csv;
346 +          lepvec[i].csvMva = jet->csvMva;
347 +        }
348 +      }
349 +    }
350 +  }
351 +
352    int nmu=0, nele=0;
353    for( int i=0; i<lepvec.size(); i++ ) {
354      if( abs(lepvec[i].type) == 11 ) nele++;
# Line 234 | Line 369 | unsigned fails_HZZ4L_selection(ControlFl
369    double BestZ1Mass = -999;
370    if( ctrl.debug ) { cout << "looking for a Z1 ..." << endl; }
371    for(int i = 0; i < lepvec.size(); ++i) {
372 +    if( !(lepvec[i].isLoose ) ) continue;
373      for(int j = i+1; j < lepvec.size(); ++j) {
374 +      if( !(lepvec[j].isLoose ) ) continue;
375        if( ctrl.debug ) { cout << "\tconsidering leptons " << i << " & " << j << endl; }
376        if (!(lepvec[i].vec.Pt() > 20.0 || lepvec[j].vec.Pt() > 20.0)) continue;
377        if( ctrl.debug ) { cout << "\tat least one is > 20 GeV" << endl; }
# Line 306 | Line 443 | unsigned fails_HZZ4L_selection(ControlFl
443    Double_t BestZ2Mass = -1;
444    if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
445    for(int i = 0; i < lepvec.size(); ++i) {
446 +
447 + #ifndef Z2FO
448 +    if( ctrl.eleSeleScheme == "mediumloose" &&
449 +        !(lepvec[i].isTight) ) continue;
450 + #endif
451 +
452      for(int j = i+1; j < lepvec.size(); ++j) {
453 +
454 + #ifndef Z2FO
455 +      if( ctrl.eleSeleScheme == "mediumloose" &&
456 +          !(lepvec[j].isTight) ) continue;
457 + #endif
458 +
459        //            cout << "i: " << i << "\tj: " << j << endl;
460        if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
461          //            cout << "\ti matches a Z1 index, skipping ..." << endl;
# Line 346 | Line 495 | unsigned fails_HZZ4L_selection(ControlFl
495              if (!(dilepton.M() > 12.0)) continue;
496              if (!(fourLepton.M() > 100.0)) continue;
497  
498 <            
498 >            /*
499              //for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
500              if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
501                TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
# Line 354 | Line 503 | unsigned fails_HZZ4L_selection(ControlFl
503                if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
504                if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
505              }
506 <            
506 >            */
507 >
508              //Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
509              if (Z2LeptonPlusIndex < 0) {
510                if (lepvec[i].charge > 0) {
# Line 433 | Line 583 | unsigned fails_HZZ4L_selection(ControlFl
583          //***************************************************************
584          bool failiso=false;
585  
586 <        if( ctrl.isoScheme = "pf" ) {
586 >        if( ctrl.isoScheme == "pf" ) {
587  
588            for( int i=0; i<lepvec.size(); i++ ) {
589 +
590              if( !(lepvec[i].is4l) ) continue;
591 +
592              if( abs(lepvec[i].type) == 11 ) {
593 <              if( (lepvec[i].isEB && lepvec[i].isoPF04 >0.13) ||
594 <                  (!(lepvec[i].isEB) && lepvec[i].isoPF04 >0.09) ) {
593 >              float reliso = lepvec[i].isoPF04/lepvec[i].vec.Pt();
594 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EB_HIGHPT ) {
595 >                failiso = true;
596 >                break;
597 >              }
598 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EB_LOWPT ) {
599 >                failiso = true;
600 >                break;
601 >              }
602 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EE_HIGHPT ) {
603 >                failiso = true;
604 >                break;
605 >              }
606 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EE_LOWPT ) {
607                  failiso = true;
608                  break;
609                }
610              }
611 +
612              if( abs(lepvec[i].type) == 13 ) {
613 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && lepvec[i].isoPF04 > 0.13 ) {
613 >
614 >              /*
615 >              float reliso = lepvec[i].isoPF03/lepvec[i].vec.Pt();
616 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EB_HIGHPT ) {  //0.13
617                  failiso = true;
618                  break;
619                }
620 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && lepvec[i].isoPF04 > 0.06 ) {
620 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EB_LOWPT ) { //0.06
621                  failiso = true;
622                  break;
623                }
624 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && lepvec[i].isoPF04 > 0.09 ) {
624 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EE_HIGHPT ) { //0.09
625                  failiso = true;
626                  break;
627                }
628 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && lepvec[i].isoPF04 > 0.05 ) {
628 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EE_LOWPT ) { //0.05
629                  failiso = true;
630                  break;
631                }
632 +              */
633              }
634            }  
635 <        } else {
635 >        } else if ( ctrl.isoScheme == "pairwise" ) {
636            float rho = info->rho;
637            for( int i=0; i<lepvec.size(); i++ ) {
638              if( !(lepvec[i].is4l) ) continue;
# Line 597 | Line 766 | unsigned fails_HZZ4L_selection(ControlFl
766            //      continue;
767          }
768          
769 <        int channel;
769 >        unsigned channel;
770          if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0;
771          if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1;
772          if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) ||
773              (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
774          
775  
776 +        double w_offline=-1, werr_offline=0;
777 +        double w_online=-1, werr_online=0;
778 +
779 +        if( ctrl.mc ) {
780 +
781 +          vector< pair <double,double> > wlegs; // pair here is eff & err
782 +          vector< pair <float,float> > mvec;  // pair here is eta & pt
783 +          // now deal with medium vs loose
784 +          //      vector< pair <float,float> > evec;  // pair here is eta & pt
785 +          vector< pair< bool, pair <float,float> > > evec;  // pair here is eta & pt
786 +
787 +          for( int k=0; k<lepvec.size(); k++ ) {
788 +            if( !(lepvec[k].is4l) ) continue;
789 +            if( abs(lepvec[k].type) == 13 ) {
790 +              mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
791 +              wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()),
792 +                                                                  lepvec[k].vec.Pt() ) );
793 +            } else {
794 +
795 +              // now deal with medium vs loose
796 +              //              evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
797 +
798 +              std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt());
799 +              evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) );
800  
801 +              wlegs.push_back( elePerLegOfflineEfficiencyWeight(  fabs(lepvec[k].vec.Eta()),
802 +                                                                 lepvec[k].vec.Pt() ) );
803 +            }
804 +          }
805 +
806 +          pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs );
807 +          w_offline    = offpair.first;
808 +          werr_offline = offpair.second;
809 +
810 +          pair<double,double> onpair  = getOnlineEfficiencyWeight( mvec, evec );
811 +          w_online    = onpair.first;
812 +          werr_online = onpair.second;
813 +
814 +        } // if mc
815 +
816 +
817 +        if( l != NULL ) {
818 +          l->vec4l  = ZZSystem;
819 +          l->vecz1  = Z1Candidate;
820 +          l->vecz2  = Z2Candidate;
821 +          l->vecl1p = lepvec[Z1LeptonPlusIndex].vec;
822 +          l->vecl1m = lepvec[Z1LeptonMinusIndex].vec;
823 +          l->vecl2p = lepvec[Z2LeptonPlusIndex].vec;
824 +          l->vecl2m = lepvec[Z2LeptonMinusIndex].vec;
825 +        }
826          if( passtuple != NULL ) {
827            unsigned run   = info->runNum;
828            unsigned evt   = info->evtNum;
# Line 615 | Line 833 | unsigned fails_HZZ4L_selection(ControlFl
833            float mZ2      = Z2Candidate.M() ;
834            float m4l      = ZZSystem.M() ;
835            float pt4l     = ZZSystem.Pt() ;
836 +          unsigned tZ1   = abs(lepvec[Z1LeptonMinusIndex].type);
837 +          unsigned tZ2   = abs(lepvec[Z2LeptonMinusIndex].type);
838 +          float l3tche   = lepvec[Z2LeptonMinusIndex].tche;
839 +          float l4tche   = lepvec[Z2LeptonPlusIndex].tche;
840 +          float l3tchp   = lepvec[Z2LeptonMinusIndex].tchp;
841 +          float l4tchp   = lepvec[Z2LeptonPlusIndex].tchp;
842 +          float l3csv    = lepvec[Z2LeptonMinusIndex].csv;
843 +          float l4csv    = lepvec[Z2LeptonPlusIndex].csv;
844 +          float l3csvMva = lepvec[Z2LeptonMinusIndex].csvMva;
845 +          float l4csvMva = lepvec[Z2LeptonPlusIndex].csvMva;
846 +
847 +
848 +          passtuple->SetBranchAddress("channel",  &channel);
849            passtuple->SetBranchAddress("run",  &run);
850            passtuple->SetBranchAddress("evt",  &evt);
851            passtuple->SetBranchAddress("lumi", &lumi);
852            passtuple->SetBranchAddress("mZ1",  &mZ1);
853            passtuple->SetBranchAddress("mZ2",  &mZ2);
854 +          passtuple->SetBranchAddress("tZ1",  &tZ1);
855 +          passtuple->SetBranchAddress("tZ2",  &tZ2);
856            passtuple->SetBranchAddress("m4l",  &m4l);
857            passtuple->SetBranchAddress("pt4l", &pt4l);
858            passtuple->SetBranchAddress("w",    &w);
859 +          if( ctrl.mc ) {
860 +            passtuple->SetBranchAddress("woff", &w_offline );
861 +            passtuple->SetBranchAddress("werroff", &werr_offline );
862 +            passtuple->SetBranchAddress("won", &w_online );
863 +            passtuple->SetBranchAddress("werron", &werr_online );
864 +            passtuple->SetBranchAddress("npu", &npu );
865 +            passtuple->SetBranchAddress("npuw", &npuw );
866 +            passtuple->SetBranchAddress("gchannel",  &gchannel);
867 +          }
868 +          if( ctrl.btag ) {
869 +          passtuple->SetBranchAddress("l3tche",    &l3tche);
870 +          passtuple->SetBranchAddress("l4tche",    &l4tche);
871 +          passtuple->SetBranchAddress("l3tchp",    &l3tchp);
872 +          passtuple->SetBranchAddress("l4tchp",    &l4tchp);
873 +          passtuple->SetBranchAddress("l3csv",     &l3csv);
874 +          passtuple->SetBranchAddress("l4csv",     &l4csv);
875 +          passtuple->SetBranchAddress("l3csvMva",  &l3csvMva);
876 +          passtuple->SetBranchAddress("l4csvMva",  &l4csvMva);
877 +          }
878 +
879            passtuple->Fill( );
880          }
881  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines