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.12 by khahn, Sun Oct 23 10:53:01 2011 UTC

# Line 10 | Line 10
10  
11   RunLumiRangeMap rlrm;
12  
13 + unsigned getGenChannel(mithep::TGenInfo * ginfo) {
14 +  int gchannel=-1;
15 +  if( abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kElectron )  gchannel=0;
16 +  else if( abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kMuon ) gchannel=1;
17 +  else if( (abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kMuon) ||
18 +           (abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kElectron) ) gchannel=2;
19 +  
20 +  return gchannel;
21 + };
22 +
23 +
24   void initRunLumiRangeMap() {
25    rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
26 <  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
26 >  //  rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
27 >  rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
28    rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));  
29    rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));  
30   };
# Line 24 | Line 36 | unsigned fails_HZZ4L_selection(ControlFl
36                                 double eventweight,           // weight
37                                 TTree * passtuple ) {
38  
39 <  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL );
39 >  fails_HZZ4L_selection( ctrl, NULL, info, electronArr, muonArr, eventweight, passtuple, NULL );
40  
41   };
42  
43 +
44 +
45   unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
46                                 mithep::TEventInfo *info,     // input event inof
47                                 TClonesArray *electronArr,    // input electrons
# Line 35 | Line 49 | unsigned fails_HZZ4L_selection(ControlFl
49                                 double eventweight,           // weight
50                                 LabVectors  *l ) {
51  
52 <  fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, NULL, l );
52 >  fails_HZZ4L_selection( ctrl, NULL, info, electronArr, muonArr, eventweight, NULL, l );
53  
54   };
55  
56  
57   unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
58 <                               mithep::TEventInfo *info,     // input event inof
58 >                               mithep::TGenInfo *ginfo ,     // input gen info
59 >                               mithep::TEventInfo *info,     // input event info
60 >                               TClonesArray *electronArr,    // input electrons
61 >                               TClonesArray *muonArr,        // input muons
62 >                               double eventweight,           // weight
63 >                               TTree * passtuple ) {
64 >
65 >  fails_HZZ4L_selection( ctrl, ginfo, info, electronArr, muonArr, eventweight, passtuple, NULL );
66 >
67 > };
68 >
69 >
70 > unsigned fails_HZZ4L_selection(ControlFlags &ctrl,           // input control
71 >                               mithep::TGenInfo *ginfo,     // input gen info
72 >                               mithep::TEventInfo *info,     // input event info
73                                 TClonesArray *electronArr,    // input electrons
74                                 TClonesArray *muonArr,        // input muons
75                                 double eventweight,           // weight
# Line 49 | Line 77 | unsigned fails_HZZ4L_selection(ControlFl
77                                 LabVectors * l) {       // output ntuple
78  
79    unsigned evtfail = 0x0;
80 +  unsigned gchannel=0xdeaddead;
81 +
82 +  if( ctrl.mc && ginfo != NULL ) {
83 +    gchannel = getGenChannel(ginfo);
84 +  }
85  
86  
87    if( ctrl.debug ) {
# Line 106 | Line 139 | unsigned fails_HZZ4L_selection(ControlFl
139    //----------------------------------------------------
140    for(Int_t i=0; i<muonArr->GetEntries(); i++) {
141      const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
142 <    unsigned muonfail = passMuonSelectionZZ(mu);
142 >    unsigned muonfail;
143 >    if( ctrl.muSele == "ksWW" )
144 >      muonfail = passMuonSelection(mu);
145 >    else
146 >      muonfail = passMuonSelectionZZ(mu);
147      if( ctrl.debug ) {
148        cout << "muon:: pt: " << mu->pt
149             << "\teta: " << mu->eta
# Line 125 | Line 162 | unsigned fails_HZZ4L_selection(ControlFl
162        tmplep.isoTrk  = mu->trkIso03;
163        tmplep.isoEcal = mu->emIso03;
164        tmplep.isoHcal = mu->hadIso03;
165 +      tmplep.isoPF03 = mu->pfIso03;
166        tmplep.isoPF04 = mu->pfIso04;
167        tmplep.ip3dSig = mu->ip3dSig;
168        tmplep.is4l    = false;
# Line 151 | Line 189 | unsigned fails_HZZ4L_selection(ControlFl
189        }
190      }
191  
192 <    unsigned FAIL=0;
193 <    CICStruct ciccuts = getCiCCuts(ctrl.eleSeleScheme);
192 >    unsigned FAIL=0, isEleTight=0;
193 >
194      unsigned  failsCIC=0;
195 +    CICStruct ciccuts_tight, ciccuts_medium, ciccuts_loose;
196      if(ctrl.eleSele=="cic") {
197 <      failsCIC = failsCicSelection(ctrl, ele, ciccuts, ctrl.kinematics);
197 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
198 >        ciccuts_medium = getCiCCuts("medium");
199 >        unsigned failsCICMedium = failsCicSelection(ctrl, ele, ciccuts_medium, ctrl.kinematics);
200 >        ciccuts_loose = getCiCCuts("loose");
201 >        unsigned failsCICLoose = failsCicSelection(ctrl, ele, ciccuts_loose, ctrl.kinematics);
202 >        failsCIC = ( failsCICLoose > 0 && failsCICMedium > 0 );
203 >        if( !failsCICMedium ) isEleTight=1;
204 >      }
205 >      else {
206 >        ciccuts_tight = getCiCCuts(ctrl.eleSeleScheme);
207 >        failsCIC = failsCicSelection(ctrl, ele, ciccuts_tight, ctrl.kinematics);
208 >        if( !failsCIC ) isEleTight=1;
209 >      }
210        FAIL = failsCIC;
211      }
212 +
213      LikStruct likcuts;
214      unsigned failsLike=0;
215      if(ctrl.eleSele=="lik") {
# Line 165 | Line 217 | unsigned fails_HZZ4L_selection(ControlFl
217        failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
218        FAIL = failsLike;
219      }
220 <    unsigned  failsBDT=0;
220 >    unsigned failsBDT=0;
221      if(ctrl.eleSele=="bdt") {
222 <      failsBDT = failsBDTSelection(ctrl,ele);
222 >      if( ctrl.eleSeleScheme == "mediumloose" ) {
223 >        unsigned failsBDTMedium = failsBDTSelection(ctrl,"medium",ele);
224 >        unsigned failsBDTLoose  = failsBDTSelection(ctrl,"loose",ele);
225 >        failsBDT = ( failsBDTLoose > 0 && failsBDTMedium > 0 );
226 >        if( !failsBDTMedium ) isEleTight=1;
227 >      } else {
228 >        failsBDT = failsBDTSelection(ctrl,"tight",ele);
229 >        if( !failsBDT ) isEleTight=1;
230 >      }
231        FAIL = failsBDT;
232      }
233      unsigned  failsSi=0;
# Line 203 | Line 263 | unsigned fails_HZZ4L_selection(ControlFl
263        tmplep.isoTrk  = ele->trkIso03;
264        tmplep.isoEcal = ele->emIso03;
265        tmplep.isoHcal = ele->hadIso03;
266 +      tmplep.isoPF03 = ele->pfIso03;
267        tmplep.isoPF04 = ele->pfIso04;
268        tmplep.ip3dSig = ele->ip3dSig;
269        tmplep.is4l    = false;
270 +      tmplep.isTight = isEleTight;
271        tmplep.isEB    = ele->isEB;
272        lepvec.push_back(tmplep);
273        if( ctrl.debug ) { cout << "\telectron passes ... " << endl; }
# Line 306 | Line 368 | unsigned fails_HZZ4L_selection(ControlFl
368    Double_t BestZ2Mass = -1;
369    if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
370    for(int i = 0; i < lepvec.size(); ++i) {
371 +    if( abs(lepvec[i].type) == 11 &&
372 +        ctrl.eleSeleScheme == "mediumloose" &&
373 +        !(lepvec[i].isTight) ) continue;
374 +
375      for(int j = i+1; j < lepvec.size(); ++j) {
376 +      if( abs(lepvec[j].type) == 11 &&
377 +          ctrl.eleSeleScheme == "mediumloose" &&
378 +          !(lepvec[j].isTight) ) continue;
379 +
380        //            cout << "i: " << i << "\tj: " << j << endl;
381        if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) {
382          //            cout << "\ti matches a Z1 index, skipping ..." << endl;
# Line 346 | Line 416 | unsigned fails_HZZ4L_selection(ControlFl
416              if (!(dilepton.M() > 12.0)) continue;
417              if (!(fourLepton.M() > 100.0)) continue;
418  
419 <            
419 >            /*
420              //for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12
421              if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
422                TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
# Line 354 | Line 424 | unsigned fails_HZZ4L_selection(ControlFl
424                if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
425                if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
426              }
427 <            
427 >            */
428 >
429              //Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin
430              if (Z2LeptonPlusIndex < 0) {
431                if (lepvec[i].charge > 0) {
# Line 433 | Line 504 | unsigned fails_HZZ4L_selection(ControlFl
504          //***************************************************************
505          bool failiso=false;
506  
507 <        if( ctrl.isoScheme = "pf" ) {
507 >        if( ctrl.isoScheme == "pf" ) {
508  
509            for( int i=0; i<lepvec.size(); i++ ) {
510 +
511              if( !(lepvec[i].is4l) ) continue;
512 +
513              if( abs(lepvec[i].type) == 11 ) {
514 <              if( (lepvec[i].isEB && lepvec[i].isoPF04 >0.13) ||
515 <                  (!(lepvec[i].isEB) && lepvec[i].isoPF04 >0.09) ) {
514 >              float reliso = lepvec[i].isoPF04/lepvec[i].vec.Pt();
515 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EB_HIGHPT ) {
516 >                failiso = true;
517 >                break;
518 >              }
519 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EB_LOWPT ) {
520 >                failiso = true;
521 >                break;
522 >              }
523 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EE_HIGHPT ) {
524 >                failiso = true;
525 >                break;
526 >              }
527 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EE_LOWPT ) {
528                  failiso = true;
529                  break;
530                }
531              }
532 +
533              if( abs(lepvec[i].type) == 13 ) {
534 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && lepvec[i].isoPF04 > 0.13 ) {
534 >
535 >              float reliso = lepvec[i].isoPF03/lepvec[i].vec.Pt();
536 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EB_HIGHPT ) {  //0.13
537                  failiso = true;
538                  break;
539                }
540 <              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && lepvec[i].isoPF04 > 0.06 ) {
540 >              if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EB_LOWPT ) { //0.06
541                  failiso = true;
542                  break;
543                }
544 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && lepvec[i].isoPF04 > 0.09 ) {
544 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EE_HIGHPT ) { //0.09
545                  failiso = true;
546                  break;
547                }
548 <              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && lepvec[i].isoPF04 > 0.05 ) {
548 >              if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EE_LOWPT ) { //0.05
549                  failiso = true;
550                  break;
551                }
552              }
553            }  
554 <        } else {
554 >        } else if ( ctrl.isoScheme == "pairwise" ) {
555            float rho = info->rho;
556            for( int i=0; i<lepvec.size(); i++ ) {
557              if( !(lepvec[i].is4l) ) continue;
# Line 597 | Line 685 | unsigned fails_HZZ4L_selection(ControlFl
685            //      continue;
686          }
687          
688 <        int channel;
688 >        unsigned channel;
689          if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0;
690          if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1;
691          if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) ||
# Line 615 | Line 703 | unsigned fails_HZZ4L_selection(ControlFl
703            float mZ2      = Z2Candidate.M() ;
704            float m4l      = ZZSystem.M() ;
705            float pt4l     = ZZSystem.Pt() ;
706 +          unsigned tZ1   = abs(lepvec[Z1LeptonMinusIndex].type);
707 +          unsigned tZ2   = abs(lepvec[Z2LeptonMinusIndex].type);
708 +          passtuple->SetBranchAddress("channel",  &channel);
709            passtuple->SetBranchAddress("run",  &run);
710            passtuple->SetBranchAddress("evt",  &evt);
711            passtuple->SetBranchAddress("lumi", &lumi);
712            passtuple->SetBranchAddress("mZ1",  &mZ1);
713            passtuple->SetBranchAddress("mZ2",  &mZ2);
714 +          passtuple->SetBranchAddress("tZ1",  &tZ1);
715 +          passtuple->SetBranchAddress("tZ2",  &tZ2);
716            passtuple->SetBranchAddress("m4l",  &m4l);
717            passtuple->SetBranchAddress("pt4l", &pt4l);
718            passtuple->SetBranchAddress("w",    &w);
719 +          if( ctrl.mc )           passtuple->SetBranchAddress("gchannel",  &gchannel);
720            passtuple->Fill( );
721          }
722  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines