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.4 by dkralph, Wed Oct 12 17:25:15 2011 UTC vs.
Revision 1.16 by khahn, Mon Nov 7 05:28:06 2011 UTC

# Line 1 | Line 1
1   #include "Selection.h"
2   #include "PassHLT.h"
3 +
4 + #include "SiMVAElectronSelection.h"
5 +
6   #include "HZZCiCElectronSelection.h"
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 <                               TNtuple * passtuple ) {
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 <
37 < };
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 <                               TNtuple * passtuple,
106 <                               LabVectors * l) {       // output ntuple
105 >                               TTree * passtuple,
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 ) {
118 +    cout << "Run: " << info->runNum
119 +         << "\tEvt: " << info->evtNum
120 +         << "\tLumi: " << info->lumiSec
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);      
128      if( !(rlrm.HasRunLumi(rl)) )  {
129 +      if( ctrl.debug ) cout << "\tfails JSON" << endl;
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    
139 <  if( ctrl.debug ) {
61 <    cout << "Run: " << info->runNum
62 <         << "\tEvt: " << info->evtNum
63 <         << "\tLumi: " << info->lumiSec
64 <         << endl;
65 <  }
139 >
140    
141    
142    //********************************************************
# Line 70 | 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 99 | 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
# Line 108 | Line 186 | unsigned fails_HZZ4L_selection(ControlFl
186      }
187      if ( !muonfail ) {
188        SimpleLepton tmplep;
189 <      tmplep.vec.SetPtEtaPhiM(mu->pt,
189 >
190 >      float pt = mu->pt;
191 >      if( ctrl.do_escale_up   ) pt*=(1.01);
192 >      if( ctrl.do_escale_down ) pt*=(0.99);
193 >
194 >      tmplep.vec.SetPtEtaPhiM(pt,
195                                mu->eta,
196                                mu->phi,
197                                105.658369e-3);
198 +
199        tmplep.type    = 13;
200        tmplep.index   = i;
201        tmplep.charge  = mu->q;
202        tmplep.isoTrk  = mu->trkIso03;
203        tmplep.isoEcal = mu->emIso03;
204        tmplep.isoHcal = mu->hadIso03;
205 +      tmplep.isoPF03 = mu->pfIso03;
206 +      tmplep.isoPF04 = mu->pfIso04;
207        tmplep.ip3dSig = mu->ip3dSig;
208        tmplep.is4l    = false;
209        tmplep.isEB    = (fabs(mu->eta) < 1.479 ? 1 : 0 );
# Line 132 | Line 218 | unsigned fails_HZZ4L_selection(ControlFl
218    for(Int_t i=0; i<electronArr->GetEntries(); i++) {
219      const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
220  
221 +    if( !(isEleFO(ctrl,ele) ) ) continue;
222 +    if( ele->pt < 7 ) continue; //move this to ID
223 +
224      Bool_t isMuonOverlap = kFALSE;
225      for (int k=0; k<lepvec.size(); ++k) {
226        TVector3 tmplep;
# Line 143 | Line 232 | unsigned fails_HZZ4L_selection(ControlFl
232        }
233      }
234  
235 <    unsigned FAIL=0;
236 <    CICStruct ciccuts = getCiCCuts(ctrl.eleSeleScheme);
235 >    unsigned FAIL=0, isEleTight=0;
236 >
237      unsigned  failsCIC=0;
238 +    CICStruct ciccuts_tight, ciccuts_medium, ciccuts_loose;
239      if(ctrl.eleSele=="cic") {
240 <      failsCIC = failsCicSelection(ctrl, ele, ciccuts, ctrl.kinematics);
240 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
241 >        ciccuts_medium = getCiCCuts("medium");
242 >        unsigned failsCICMedium = failsCicSelection(ctrl, ele, ciccuts_medium, ctrl.kinematics);
243 >        ciccuts_loose = getCiCCuts("loose");
244 >        unsigned failsCICLoose = failsCicSelection(ctrl, ele, ciccuts_loose, ctrl.kinematics);
245 >        failsCIC = ( failsCICLoose > 0 && failsCICMedium > 0 );
246 >        if( !failsCICMedium ) isEleTight=1;
247 >      }
248 >      else {
249 >        ciccuts_tight = getCiCCuts(ctrl.eleSeleScheme);
250 >        failsCIC = failsCicSelection(ctrl, ele, ciccuts_tight, ctrl.kinematics);
251 >        if( !failsCIC ) isEleTight=1;
252 >      }
253        FAIL = failsCIC;
254      }
255 +
256      LikStruct likcuts;
257      unsigned failsLike=0;
258      if(ctrl.eleSele=="lik") {
# Line 157 | Line 260 | unsigned fails_HZZ4L_selection(ControlFl
260        failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
261        FAIL = failsLike;
262      }
263 <    unsigned  failsBDT=0;
263 >    unsigned failsBDT=0;
264      if(ctrl.eleSele=="bdt") {
265 <      failsBDT = failsBDTSelection(ele,ctrl.kinematics,ctrl.eleSeleScheme);
265 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
266 >        unsigned failsBDTMedium = failsBDTSelection(ctrl,"medium",ele);
267 >        unsigned failsBDTLoose  = failsBDTSelection(ctrl,"loose",ele);
268 >        failsBDT = ( failsBDTLoose > 0 && failsBDTMedium > 0 );
269 >        if( !failsBDTMedium ) isEleTight=1;
270 >      } else {
271 >        failsBDT = failsBDTSelection(ctrl,"tight",ele);
272 >        if( !failsBDT ) isEleTight=1;
273 >      }
274        FAIL = failsBDT;
275      }
276  
277 +
278      if( ctrl.debug ){
279        cout << "CIC category: " << cicCategory(ele)
280             << "\tlikelihood: " << ele->likelihood
# Line 177 | Line 289 | unsigned fails_HZZ4L_selection(ControlFl
289      }
290      if ( !FAIL && !isMuonOverlap ) {
291        SimpleLepton tmplep;
292 <      tmplep.vec.SetPtEtaPhiM( ele->pt,
292 >
293 >      float pt = ele->pt;
294 >      if( ctrl.do_escale_up   ) pt*=(1.02);
295 >      if( ctrl.do_escale_down ) pt*=(0.98);
296 >
297 >      tmplep.vec.SetPtEtaPhiM( pt,
298                                 ele->eta,
299                                 ele->phi,
300                                 0.51099892e-3 );
# Line 187 | Line 304 | unsigned fails_HZZ4L_selection(ControlFl
304        tmplep.isoTrk  = ele->trkIso03;
305        tmplep.isoEcal = ele->emIso03;
306        tmplep.isoHcal = ele->hadIso03;
307 +      tmplep.isoPF03 = ele->pfIso03;
308 +      tmplep.isoPF04 = ele->pfIso04;
309        tmplep.ip3dSig = ele->ip3dSig;
310        tmplep.is4l    = false;
311 +      tmplep.isTight = isEleTight;
312        tmplep.isEB    = ele->isEB;
313        lepvec.push_back(tmplep);
314        if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
# Line 197 | Line 317 | unsigned fails_HZZ4L_selection(ControlFl
317    
318    sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort );
319  
320 +  for( int i=0; i<lepvec.size(); i++ ) {
321 +    //
322 +    //  check for a matched btagged jet
323 +    //
324 +    lepvec[i].tche = -1;
325 +    lepvec[i].tchp = -1;
326 +    lepvec[i].csv = -1;
327 +    lepvec[i].csvMva = -1;
328 +
329 +    if( jetArr != NULL ) {
330 +      for(int k=0; k<jetArr->GetEntries(); k++) {
331 +        const mithep::TJet *jet = (mithep::TJet*)((*jetArr)[k]);      
332 +        TVector3 jvec;
333 +        jvec.SetPtEtaPhi(jet->pt, jet->eta, jet->phi);
334 +        if( jvec.DrEtaPhi( lepvec[i].vec.Vect()) < 0.2 ) {
335 +          lepvec[i].tche = jet->tche;
336 +          lepvec[i].tchp = jet->tchp;
337 +          lepvec[i].csv = jet->csv;
338 +          lepvec[i].csvMva = jet->csvMva;
339 +        }
340 +      }
341 +    }
342 +  }
343 +
344    int nmu=0, nele=0;
345    for( int i=0; i<lepvec.size(); i++ ) {
346      if( abs(lepvec[i].type) == 11 ) nele++;
# Line 289 | Line 433 | unsigned fails_HZZ4L_selection(ControlFl
433    Double_t BestZ2Mass = -1;
434    if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
435    for(int i = 0; i < lepvec.size(); ++i) {
436 +    if( abs(lepvec[i].type) == 11 &&
437 +        ctrl.eleSeleScheme == "mediumloose" &&
438 +        !(lepvec[i].isTight) ) continue;
439 +
440      for(int j = i+1; j < lepvec.size(); ++j) {
441 +      if( abs(lepvec[j].type) == 11 &&
442 +          ctrl.eleSeleScheme == "mediumloose" &&
443 +          !(lepvec[j].isTight) ) continue;
444 +
445        //            cout << "i: " << i << "\tj: " << j << endl;
446        if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
447          //            cout << "\ti matches a Z1 index, skipping ..." << endl;
# Line 329 | Line 481 | unsigned fails_HZZ4L_selection(ControlFl
481              if (!(dilepton.M() > 12.0)) continue;
482              if (!(fourLepton.M() > 100.0)) continue;
483  
484 <            
484 >            /*
485              //for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
486              if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
487                TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
# Line 337 | Line 489 | unsigned fails_HZZ4L_selection(ControlFl
489                if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
490                if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
491              }
492 <            
492 >            */
493 >
494              //Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
495              if (Z2LeptonPlusIndex < 0) {
496                if (lepvec[i].charge > 0) {
# Line 416 | Line 569 | unsigned fails_HZZ4L_selection(ControlFl
569          //***************************************************************
570          bool failiso=false;
571  
572 <        /*
420 <        int i,j;
421 <        i=Z1LeptonPlusIndex;
422 <        j=Z1LeptonMinusIndex;
423 <        float RIso1 = (lepvec[i].isoTrk+lepvec[i].isoEcal+lepvec[i].isoHcal)/lepvec[i].vec.Pt();
424 <        float RIso2 = (lepvec[j].isoTrk+lepvec[j].isoEcal+lepvec[j].isoHcal)/lepvec[j].vec.Pt();
425 <        float comboIso12 = RIso1 + RIso2;
426 <        i=Z2LeptonPlusIndex;
427 <        j=Z2LeptonMinusIndex;
428 <        float RIso3 = (lepvec[i].isoTrk+lepvec[i].isoEcal+lepvec[i].isoHcal)/lepvec[i].vec.Pt();
429 <        float RIso4 = (lepvec[j].isoTrk+lepvec[j].isoEcal+lepvec[j].isoHcal)/lepvec[j].vec.Pt();
430 <        float comboIso34 = RIso3 + RIso4;
431 <        if( comboIso12 > 0.35 || comboIso34 > 0.35 ) {
432 <              failiso = true;
433 <        }
434 <        */
572 >        if( ctrl.isoScheme == "pf" ) {
573  
574 <        float rho = info->rho;
575 <        for( int i=0; i<lepvec.size(); i++ ) {
576 <          if( !(lepvec[i].is4l) ) continue;
574 >          for( int i=0; i<lepvec.size(); i++ ) {
575 >
576 >            if( !(lepvec[i].is4l) ) continue;
577 >
578 >            if( abs(lepvec[i].type) == 11 ) {
579 >              float reliso = lepvec[i].isoPF04/lepvec[i].vec.Pt();
580 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EB_HIGHPT ) {
581 >                failiso = true;
582 >                break;
583 >              }
584 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EB_LOWPT ) {
585 >                failiso = true;
586 >                break;
587 >              }
588 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EE_HIGHPT ) {
589 >                failiso = true;
590 >                break;
591 >              }
592 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EE_LOWPT ) {
593 >                failiso = true;
594 >                break;
595 >              }
596 >            }
597 >
598 >            if( abs(lepvec[i].type) == 13 ) {
599 >
600 >              /*
601 >              float reliso = lepvec[i].isoPF03/lepvec[i].vec.Pt();
602 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EB_HIGHPT ) {  //0.13
603 >                failiso = true;
604 >                break;
605 >              }
606 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EB_LOWPT ) { //0.06
607 >                failiso = true;
608 >                break;
609 >              }
610 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EE_HIGHPT ) { //0.09
611 >                failiso = true;
612 >                break;
613 >              }
614 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EE_LOWPT ) { //0.05
615 >                failiso = true;
616 >                break;
617 >              }
618 >              */
619 >            }
620 >          }  
621 >        } else if ( ctrl.isoScheme == "pairwise" ) {
622 >          float rho = info->rho;
623 >          for( int i=0; i<lepvec.size(); i++ ) {
624 >            if( !(lepvec[i].is4l) ) continue;
625              float effArea_ecal_i, effArea_hcal_i;
626              if( lepvec[i].isEB ) {
627                if( lepvec[i].type == 11 ) {
# Line 511 | Line 697 | unsigned fails_HZZ4L_selection(ControlFl
697                  //            break;
698                }
699              }
700 +          }
701          }
702 +
703 +
704          if( failiso ) {
705            evtfail |= ( 1<<EVTFAIL_ISOLATION );
706            return evtfail;
# Line 563 | Line 752 | unsigned fails_HZZ4L_selection(ControlFl
752            //      continue;
753          }
754          
755 <        int channel;
755 >        unsigned channel;
756          if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0;
757          if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1;
758          if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) ||
759              (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
760          
761  
762 <        
762 >        double w_offline=-1, werr_offline=0;
763 >        double w_online=-1, werr_online=0;
764 >
765 >        if( ctrl.mc ) {
766 >
767 >          vector< pair <double,double> > wlegs; // pair here is eff & err
768 >          vector< pair <float,float> > mvec;  // pair here is eta & pt
769 >          // now deal with medium vs loose
770 >          //      vector< pair <float,float> > evec;  // pair here is eta & pt
771 >          vector< pair< bool, pair <float,float> > > evec;  // pair here is eta & pt
772 >
773 >          for( int k=0; k<lepvec.size(); k++ ) {
774 >            if( !(lepvec[k].is4l) ) continue;
775 >            if( abs(lepvec[k].type) == 13 ) {
776 >              mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
777 >              wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()),
778 >                                                                  lepvec[k].vec.Pt() ) );
779 >            } else {
780 >
781 >              // now deal with medium vs loose
782 >              //              evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) );
783 >
784 >              std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt());
785 >              evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) );
786 >
787 >              wlegs.push_back( elePerLegOfflineEfficiencyWeight(  fabs(lepvec[k].vec.Eta()),
788 >                                                                 lepvec[k].vec.Pt() ) );
789 >            }
790 >          }
791 >
792 >          pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs );
793 >          w_offline    = offpair.first;
794 >          werr_offline = offpair.second;
795 >
796 >          pair<double,double> onpair  = getOnlineEfficiencyWeight( mvec, evec );
797 >          w_online    = onpair.first;
798 >          werr_online = onpair.second;
799 >
800 >        } // if mc
801 >
802 >
803 >        if( l != NULL ) {
804 >          l->vec4l  = ZZSystem;
805 >          l->vecz1  = Z1Candidate;
806 >          l->vecz2  = Z2Candidate;
807 >          l->vecl1p = lepvec[Z1LeptonPlusIndex].vec;
808 >          l->vecl1m = lepvec[Z1LeptonMinusIndex].vec;
809 >          l->vecl2p = lepvec[Z2LeptonPlusIndex].vec;
810 >          l->vecl2m = lepvec[Z2LeptonMinusIndex].vec;
811 >        }
812          if( passtuple != NULL ) {
813 <          passtuple->Fill( info->runNum,
814 <                           info->evtNum,
815 <                           info->lumiSec,
816 <                           channel,
817 <                           Z1Candidate.M(),
818 <                           Z2Candidate.M(),
819 <                           ZZSystem.M(),
820 <                           ZZSystem.Pt(),
821 <                           eventweight);
813 >          unsigned run   = info->runNum;
814 >          unsigned evt   = info->evtNum;
815 >          unsigned lumi  = info->lumiSec;
816 >          unsigned chan  = channel;
817 >          double   w     = eventweight;
818 >          float mZ1      = Z1Candidate.M() ;
819 >          float mZ2      = Z2Candidate.M() ;
820 >          float m4l      = ZZSystem.M() ;
821 >          float pt4l     = ZZSystem.Pt() ;
822 >          unsigned tZ1   = abs(lepvec[Z1LeptonMinusIndex].type);
823 >          unsigned tZ2   = abs(lepvec[Z2LeptonMinusIndex].type);
824 >          float l3tche   = lepvec[Z2LeptonMinusIndex].tche;
825 >          float l4tche   = lepvec[Z2LeptonPlusIndex].tche;
826 >          float l3tchp   = lepvec[Z2LeptonMinusIndex].tchp;
827 >          float l4tchp   = lepvec[Z2LeptonPlusIndex].tchp;
828 >          float l3csv    = lepvec[Z2LeptonMinusIndex].csv;
829 >          float l4csv    = lepvec[Z2LeptonPlusIndex].csv;
830 >          float l3csvMva = lepvec[Z2LeptonMinusIndex].csvMva;
831 >          float l4csvMva = lepvec[Z2LeptonPlusIndex].csvMva;
832 >
833 >
834 >          passtuple->SetBranchAddress("channel",  &channel);
835 >          passtuple->SetBranchAddress("run",  &run);
836 >          passtuple->SetBranchAddress("evt",  &evt);
837 >          passtuple->SetBranchAddress("lumi", &lumi);
838 >          passtuple->SetBranchAddress("mZ1",  &mZ1);
839 >          passtuple->SetBranchAddress("mZ2",  &mZ2);
840 >          passtuple->SetBranchAddress("tZ1",  &tZ1);
841 >          passtuple->SetBranchAddress("tZ2",  &tZ2);
842 >          passtuple->SetBranchAddress("m4l",  &m4l);
843 >          passtuple->SetBranchAddress("pt4l", &pt4l);
844 >          passtuple->SetBranchAddress("w",    &w);
845 >          if( ctrl.mc ) {
846 >            passtuple->SetBranchAddress("woff", &w_offline );
847 >            passtuple->SetBranchAddress("werroff", &werr_offline );
848 >            passtuple->SetBranchAddress("won", &w_online );
849 >            passtuple->SetBranchAddress("werron", &werr_online );
850 >            passtuple->SetBranchAddress("npu", &npu );
851 >            passtuple->SetBranchAddress("npuw", &npuw );
852 >            passtuple->SetBranchAddress("gchannel",  &gchannel);
853 >          }
854 >          if( ctrl.btag ) {
855 >          passtuple->SetBranchAddress("l3tche",    &l3tche);
856 >          passtuple->SetBranchAddress("l4tche",    &l4tche);
857 >          passtuple->SetBranchAddress("l3tchp",    &l3tchp);
858 >          passtuple->SetBranchAddress("l4tchp",    &l4tchp);
859 >          passtuple->SetBranchAddress("l3csv",     &l3csv);
860 >          passtuple->SetBranchAddress("l4csv",     &l4csv);
861 >          passtuple->SetBranchAddress("l3csvMva",  &l3csvMva);
862 >          passtuple->SetBranchAddress("l4csvMva",  &l4csvMva);
863 >          }
864 >
865 >          passtuple->Fill( );
866          }
867  
868          if( ctrl.debug ) cout  << "run: " << info->runNum  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines