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.3 by dkralph, Thu Sep 22 18:01:19 2011 UTC vs.
Revision 1.11 by khahn, Mon Oct 17 16:23:43 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  
11   RunLumiRangeMap rlrm;
12  
13   void initRunLumiRangeMap() {
14    rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
15 <  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
15 >  //  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
16 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
17    rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));  
18    rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));  
19   };
# Line 18 | Line 23 | unsigned fails_HZZ4L_selection(ControlFl
23                                 TClonesArray *electronArr,    // input electrons
24                                 TClonesArray *muonArr,        // input muons
25                                 double eventweight,           // weight
26 <                               TNtuple * passtuple ) {
26 >                               TTree * passtuple ) {
27  
28    fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL );
29  
# Line 41 | Line 46 | unsigned fails_HZZ4L_selection(ControlFl
46                                 TClonesArray *electronArr,    // input electrons
47                                 TClonesArray *muonArr,        // input muons
48                                 double eventweight,           // weight
49 <                               TNtuple * passtuple,
49 >                               TTree * passtuple,
50                                 LabVectors * l) {       // output ntuple
51  
52    unsigned evtfail = 0x0;
53  
54 +
55 +  if( ctrl.debug ) {
56 +    cout << "Run: " << info->runNum
57 +         << "\tEvt: " << info->evtNum
58 +         << "\tLumi: " << info->lumiSec
59 +         << endl;
60 +  }
61 +
62    if( !ctrl.mc ) {
63      // not accounting for overlap atm
64      RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);      
65      if( !(rlrm.HasRunLumi(rl)) )  {
66 +      if( ctrl.debug ) cout << "\tfails JSON" << endl;
67        evtfail |= (1<<EVTFAIL_JSON);
68        return evtfail;
69      }
70    }
71    
72    
73 <  if( ctrl.debug ) {
60 <    cout << "Run: " << info->runNum
61 <         << "\tEvt: " << info->evtNum
62 <         << "\tLumi: " << info->lumiSec
63 <         << endl;
64 <  }
73 >
74    
75    
76    //********************************************************
# Line 98 | Line 107 | unsigned fails_HZZ4L_selection(ControlFl
107    //----------------------------------------------------
108    for(Int_t i=0; i<muonArr->GetEntries(); i++) {
109      const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
110 <    unsigned muonfail = passMuonSelectionZZ(mu);
110 >    unsigned muonfail;
111 >    if( ctrl.muSele == "ksWW" )
112 >      muonfail = passMuonSelection(mu);
113 >    else
114 >      muonfail = passMuonSelectionZZ(mu);
115      if( ctrl.debug ) {
116        cout << "muon:: pt: " << mu->pt
117             << "\teta: " << mu->eta
# Line 117 | Line 130 | unsigned fails_HZZ4L_selection(ControlFl
130        tmplep.isoTrk  = mu->trkIso03;
131        tmplep.isoEcal = mu->emIso03;
132        tmplep.isoHcal = mu->hadIso03;
133 +      tmplep.isoPF03 = mu->pfIso03;
134 +      tmplep.isoPF04 = mu->pfIso04;
135        tmplep.ip3dSig = mu->ip3dSig;
136        tmplep.is4l    = false;
137        tmplep.isEB    = (fabs(mu->eta) < 1.479 ? 1 : 0 );
# Line 142 | Line 157 | unsigned fails_HZZ4L_selection(ControlFl
157        }
158      }
159  
160 <    unsigned FAIL;
161 <    CICStruct tightcuts = getTightCuts();
162 <    unsigned  failsCIC  = failsCicSelection(ctrl, ele, tightcuts, ctrl.kinematics);
163 <    LikStruct likcuts = getLikCuts(ctrl.lik_cut);
164 <    unsigned  failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
160 >    unsigned FAIL=0, isEleTight=0;
161 >
162 >    unsigned  failsCIC=0;
163 >    CICStruct ciccuts_tight, ciccuts_medium, ciccuts_loose;
164 >    if(ctrl.eleSele=="cic") {
165 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
166 >        ciccuts_medium = getCiCCuts("medium");
167 >        unsigned failsCICMedium = failsCicSelection(ctrl, ele, ciccuts_medium, ctrl.kinematics);
168 >        ciccuts_loose = getCiCCuts("loose");
169 >        unsigned failsCICLoose = failsCicSelection(ctrl, ele, ciccuts_loose, ctrl.kinematics);
170 >        failsCIC = ( failsCICLoose | failsCICMedium );
171 >        if( !failsCICMedium ) isEleTight=1;
172 >      }
173 >      else {
174 >        ciccuts_tight = getCiCCuts(ctrl.eleSeleScheme);
175 >        failsCIC = failsCicSelection(ctrl, ele, ciccuts_tight, ctrl.kinematics);
176 >        if( !failsCIC ) isEleTight=1;
177 >      }
178 >      FAIL = failsCIC;
179 >    }
180 >
181 >    LikStruct likcuts;
182 >    unsigned failsLike=0;
183 >    if(ctrl.eleSele=="lik") {
184 >      likcuts = getLikCuts(ctrl.eleSeleScheme);
185 >      failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
186 >      FAIL = failsLike;
187 >    }
188 >    unsigned failsBDT=0;
189 >    if(ctrl.eleSele=="bdt") {
190 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
191 >        unsigned failsBDTMedium = failsBDTSelection(ctrl,"medium",ele);
192 >        unsigned failsBDTLoose  = failsBDTSelection(ctrl,"loose",ele);
193 >        failsBDT = ( failsBDTLoose | failsBDTMedium );
194 >        if( !failsBDTMedium ) isEleTight=1;
195 >      } else {
196 >        failsBDT = failsBDTSelection(ctrl,"tight",ele);
197 >        if( !failsBDT ) isEleTight=1;
198 >      }
199 >      FAIL = failsBDT;
200 >    }
201 >    unsigned  failsSi=0;
202 >    if(ctrl.eleSele=="si") {
203 >      failsSi = failsSiMVAElectronSelection(ctrl, ele, 0.95, ctrl.kinematics);
204 >      FAIL = failsSi;
205 >    }
206 >
207 >
208  
151    if ( ctrl.cic ) { FAIL = failsCIC;}
152    else            { FAIL = failsLike; }
209  
210      if( ctrl.debug ){
211        cout << "CIC category: " << cicCategory(ele)
# Line 157 | Line 213 | unsigned fails_HZZ4L_selection(ControlFl
213             << "\tFAIL:  0x"     << hex << FAIL      << dec
214             << "\tfailsCIC:  0x" << hex << failsCIC  << dec
215             << "\tfailsLike: 0x" << hex << failsLike << dec
216 +           << "\tfailsBDT:  0x" << hex << failsBDT << dec
217             << "\tscEt: " << ele->scEt
218             << "\tscEta: " << ele->scEta
219             << "\tncluster: " << ele->ncluster
# Line 174 | Line 231 | unsigned fails_HZZ4L_selection(ControlFl
231        tmplep.isoTrk  = ele->trkIso03;
232        tmplep.isoEcal = ele->emIso03;
233        tmplep.isoHcal = ele->hadIso03;
234 +      tmplep.isoPF03 = ele->pfIso03;
235 +      tmplep.isoPF04 = ele->pfIso04;
236        tmplep.ip3dSig = ele->ip3dSig;
237        tmplep.is4l    = false;
238 +      tmplep.isTight = isEleTight;
239        tmplep.isEB    = ele->isEB;
240        lepvec.push_back(tmplep);
241        if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
# Line 276 | Line 336 | unsigned fails_HZZ4L_selection(ControlFl
336    Double_t BestZ2Mass = -1;
337    if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
338    for(int i = 0; i < lepvec.size(); ++i) {
339 +    if( abs(lepvec[i].type) == 11 &&
340 +        ctrl.eleSeleScheme == "mediumloose" &&
341 +        !(lepvec[i].isTight) ) continue;
342 +
343      for(int j = i+1; j < lepvec.size(); ++j) {
344 +      if( abs(lepvec[j].type) == 11 &&
345 +          ctrl.eleSeleScheme == "mediumloose" &&
346 +          !(lepvec[j].isTight) ) continue;
347 +
348        //            cout << "i: " << i << "\tj: " << j << endl;
349        if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
350          //            cout << "\ti matches a Z1 index, skipping ..." << endl;
# Line 316 | Line 384 | unsigned fails_HZZ4L_selection(ControlFl
384              if (!(dilepton.M() > 12.0)) continue;
385              if (!(fourLepton.M() > 100.0)) continue;
386  
387 <            
387 >            /*
388              //for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
389              if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
390                TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
# Line 324 | Line 392 | unsigned fails_HZZ4L_selection(ControlFl
392                if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
393                if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
394              }
395 <            
395 >            */
396 >
397              //Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
398              if (Z2LeptonPlusIndex < 0) {
399                if (lepvec[i].charge > 0) {
# Line 403 | Line 472 | unsigned fails_HZZ4L_selection(ControlFl
472          //***************************************************************
473          bool failiso=false;
474  
475 <        /*
407 <        int i,j;
408 <        i=Z1LeptonPlusIndex;
409 <        j=Z1LeptonMinusIndex;
410 <        float RIso1 = (lepvec[i].isoTrk+lepvec[i].isoEcal+lepvec[i].isoHcal)/lepvec[i].vec.Pt();
411 <        float RIso2 = (lepvec[j].isoTrk+lepvec[j].isoEcal+lepvec[j].isoHcal)/lepvec[j].vec.Pt();
412 <        float comboIso12 = RIso1 + RIso2;
413 <        i=Z2LeptonPlusIndex;
414 <        j=Z2LeptonMinusIndex;
415 <        float RIso3 = (lepvec[i].isoTrk+lepvec[i].isoEcal+lepvec[i].isoHcal)/lepvec[i].vec.Pt();
416 <        float RIso4 = (lepvec[j].isoTrk+lepvec[j].isoEcal+lepvec[j].isoHcal)/lepvec[j].vec.Pt();
417 <        float comboIso34 = RIso3 + RIso4;
418 <        if( comboIso12 > 0.35 || comboIso34 > 0.35 ) {
419 <              failiso = true;
420 <        }
421 <        */
475 >        if( ctrl.isoScheme == "pf" ) {
476  
477 <        float rho = info->rho;
478 <        for( int i=0; i<lepvec.size(); i++ ) {
479 <          if( !(lepvec[i].is4l) ) continue;
477 >          for( int i=0; i<lepvec.size(); i++ ) {
478 >
479 >            if( !(lepvec[i].is4l) ) continue;
480 >
481 >            if( abs(lepvec[i].type) == 11 ) {
482 >              float reliso = lepvec[i].isoPF04/lepvec[i].vec.Pt();
483 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EB_HIGHPT ) {
484 >                failiso = true;
485 >                break;
486 >              }
487 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EB_LOWPT ) {
488 >                failiso = true;
489 >                break;
490 >              }
491 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EE_HIGHPT ) {
492 >                failiso = true;
493 >                break;
494 >              }
495 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EE_LOWPT ) {
496 >                failiso = true;
497 >                break;
498 >              }
499 >            }
500 >
501 >            if( abs(lepvec[i].type) == 13 ) {
502 >
503 >              float reliso = lepvec[i].isoPF03/lepvec[i].vec.Pt();
504 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_TIGHT_EB_HIGHPT ) {  //0.13
505 >                failiso = true;
506 >                break;
507 >              }
508 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_TIGHT_EB_LOWPT ) { //0.06
509 >                failiso = true;
510 >                break;
511 >              }
512 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_TIGHT_EE_HIGHPT ) { //0.09
513 >                failiso = true;
514 >                break;
515 >              }
516 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_TIGHT_EE_LOWPT ) { //0.05
517 >                failiso = true;
518 >                break;
519 >              }
520 >            }
521 >          }  
522 >        } else if ( ctrl.isoScheme == "pairwise" ) {
523 >          float rho = info->rho;
524 >          for( int i=0; i<lepvec.size(); i++ ) {
525 >            if( !(lepvec[i].is4l) ) continue;
526              float effArea_ecal_i, effArea_hcal_i;
527              if( lepvec[i].isEB ) {
528                if( lepvec[i].type == 11 ) {
# Line 498 | Line 598 | unsigned fails_HZZ4L_selection(ControlFl
598                  //            break;
599                }
600              }
601 +          }
602          }
603 +
604 +
605          if( failiso ) {
606            evtfail |= ( 1<<EVTFAIL_ISOLATION );
607            return evtfail;
# Line 557 | Line 660 | unsigned fails_HZZ4L_selection(ControlFl
660              (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
661          
662  
663 <        
663 >
664          if( passtuple != NULL ) {
665 <          passtuple->Fill( info->runNum,
666 <                           info->evtNum,
667 <                           info->lumiSec,
668 <                           channel,
669 <                           Z1Candidate.M(),
670 <                           Z2Candidate.M(),
671 <                           ZZSystem.M(),
672 <                           ZZSystem.Pt(),
673 <                           eventweight);
665 >          unsigned run   = info->runNum;
666 >          unsigned evt   = info->evtNum;
667 >          unsigned lumi  = info->lumiSec;
668 >          unsigned chan  = channel;
669 >          double   w     = eventweight;
670 >          float mZ1      = Z1Candidate.M() ;
671 >          float mZ2      = Z2Candidate.M() ;
672 >          float m4l      = ZZSystem.M() ;
673 >          float pt4l     = ZZSystem.Pt() ;
674 >          unsigned tZ1   = abs(lepvec[Z1LeptonMinusIndex].type);
675 >          unsigned tZ2   = abs(lepvec[Z2LeptonMinusIndex].type);
676 >          passtuple->SetBranchAddress("run",  &run);
677 >          passtuple->SetBranchAddress("evt",  &evt);
678 >          passtuple->SetBranchAddress("lumi", &lumi);
679 >          passtuple->SetBranchAddress("mZ1",  &mZ1);
680 >          passtuple->SetBranchAddress("mZ2",  &mZ2);
681 >          passtuple->SetBranchAddress("tZ1",  &tZ1);
682 >          passtuple->SetBranchAddress("tZ2",  &tZ2);
683 >          passtuple->SetBranchAddress("m4l",  &m4l);
684 >          passtuple->SetBranchAddress("pt4l", &pt4l);
685 >          passtuple->SetBranchAddress("w",    &w);
686 >          passtuple->Fill( );
687          }
688  
689          if( ctrl.debug ) cout  << "run: " << info->runNum  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines