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.2 by dkralph, Wed Sep 14 12:11:57 2011 UTC vs.
Revision 1.6 by khahn, Thu Oct 13 14:20:55 2011 UTC

# Line 1 | Line 1
1   #include "Selection.h"
2   #include "PassHLT.h"
3   #include "HZZCiCElectronSelection.h"
4 + #include "HZZLikelihoodElectronSelection.h"
5 + #include "HZZBDTElectronSelection.h"
6   #include "RunLumiRangeMap.h"
7  
8   RunLumiRangeMap rlrm;
# Line 17 | Line 19 | unsigned fails_HZZ4L_selection(ControlFl
19                                 TClonesArray *electronArr,    // input electrons
20                                 TClonesArray *muonArr,        // input muons
21                                 double eventweight,           // weight
22 <                               TNtuple * passtuple ) {
22 >                               TTree * passtuple ) {
23  
24    fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL );
25  
# Line 40 | Line 42 | unsigned fails_HZZ4L_selection(ControlFl
42                                 TClonesArray *electronArr,    // input electrons
43                                 TClonesArray *muonArr,        // input muons
44                                 double eventweight,           // weight
45 <                               TNtuple * passtuple,
46 <                               LabVectors * l ) {       // output ntuple
45 >                               TTree * passtuple,
46 >                               LabVectors * l) {       // output ntuple
47  
48    unsigned evtfail = 0x0;
49  
50 +
51 +  if( ctrl.debug ) {
52 +    cout << "Run: " << info->runNum
53 +         << "\tEvt: " << info->evtNum
54 +         << "\tLumi: " << info->lumiSec
55 +         << endl;
56 +  }
57 +
58    if( !ctrl.mc ) {
59      // not accounting for overlap atm
60      RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);      
61      if( !(rlrm.HasRunLumi(rl)) )  {
62 +      if( ctrl.debug ) cout << "\tfails JSON" << endl;
63        evtfail |= (1<<EVTFAIL_JSON);
64        return evtfail;
65      }
66    }
67    
68    
69 <  if( ctrl.debug ) {
59 <    cout << "Run: " << info->runNum
60 <         << "\tEvt: " << info->evtNum
61 <         << "\tLumi: " << info->lumiSec
62 <         << endl;
63 <  }
69 >
70    
71    
72    //********************************************************
# Line 93 | Line 99 | unsigned fails_HZZ4L_selection(ControlFl
99    vector<SimpleLepton> lepvec;
100    
101    //    
102 <  cout << "\tnMuons: " << muonArr->GetEntries() << endl;
102 >  if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl;
103    //----------------------------------------------------
104    for(Int_t i=0; i<muonArr->GetEntries(); i++) {
105      const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
# Line 124 | Line 130 | unsigned fails_HZZ4L_selection(ControlFl
130      }
131    }
132    
127  //
133    if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; }
134 +
135    //----------------------------------------------------
136    for(Int_t i=0; i<electronArr->GetEntries(); i++) {
137      const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
# Line 135 | Line 141 | unsigned fails_HZZ4L_selection(ControlFl
141        TVector3 tmplep;
142        tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi);
143        if ( lepvec[k].type == 13 && lepvec[k].vec.Vect().DrEtaPhi(tmplep) < 0.1 ) {
144 <        cout << "-----> isMuonOverlap! " << endl;
144 >        if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
145          isMuonOverlap = kTRUE;
146          break;
147        }
148      }
149  
150 <    CICStruct tightcuts = getTightCuts();
151 <    unsigned failsCIC = failsCicSelection(ele, tightcuts);
150 >    unsigned FAIL=0;
151 >    CICStruct ciccuts = getCiCCuts(ctrl.eleSeleScheme);
152 >    unsigned  failsCIC=0;
153 >    if(ctrl.eleSele=="cic") {
154 >      failsCIC = failsCicSelection(ctrl, ele, ciccuts, ctrl.kinematics);
155 >      FAIL = failsCIC;
156 >    }
157 >    LikStruct likcuts;
158 >    unsigned failsLike=0;
159 >    if(ctrl.eleSele=="lik") {
160 >      likcuts = getLikCuts(ctrl.eleSeleScheme);
161 >      failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
162 >      FAIL = failsLike;
163 >    }
164 >    unsigned  failsBDT=0;
165 >    if(ctrl.eleSele=="bdt") {
166 >      failsBDT = failsBDTSelection(ele,ctrl.kinematics,ctrl.eleSeleScheme);
167 >      FAIL = failsBDT;
168 >    }
169 >
170      if( ctrl.debug ){
171        cout << "CIC category: " << cicCategory(ele)
172 <           << "\tfailmask : 0x" << hex << failsCIC  << dec
172 >           << "\tlikelihood: " << ele->likelihood
173 >           << "\tFAIL:  0x"     << hex << FAIL      << dec
174 >           << "\tfailsCIC:  0x" << hex << failsCIC  << dec
175 >           << "\tfailsLike: 0x" << hex << failsLike << dec
176 >           << "\tfailsBDT:  0x" << hex << failsBDT << dec
177             << "\tscEt: " << ele->scEt
178 <           << "\tscEta: " << ele->scEta
178 >           << "\tscEta: " << ele->scEta
179 >           << "\tncluster: " << ele->ncluster
180             << endl;
181      }
182 <    if ( !failsCIC && !isMuonOverlap ) {
182 >    if ( !FAIL && !isMuonOverlap ) {
183        SimpleLepton tmplep;
184        tmplep.vec.SetPtEtaPhiM( ele->pt,
185                                 ele->eta,
# Line 214 | Line 243 | unsigned fails_HZZ4L_selection(ControlFl
243        }
244        
245        float tmpZ1Mass = (leptonPlus+leptonMinus).M();
246 <      cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
246 >      if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
247        if( tmpZ1Mass > 60 ) {
248          if (fabs(tmpZ1Mass - 91.1876) < fabs(BestZ1Mass - 91.1876)) {
249            BestZ1Mass = tmpZ1Mass;
250 <          cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
250 >          if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
251                 << "\tdM: " << fabs(BestZ1Mass - 91.1876)
252                 << endl;
253            if (lepvec[i].charge > 0) {
# Line 237 | Line 266 | unsigned fails_HZZ4L_selection(ControlFl
266      evtfail |= (1<<EVTFAIL_Z1);
267      return evtfail;
268    }
269 <  cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum  << endl;
270 <  cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
269 >  if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum  << endl;
270 >  if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
271    TLorentzVector Z1LeptonPlus  = lepvec[Z1LeptonPlusIndex].vec;
272    TLorentzVector Z1LeptonMinus = lepvec[Z1LeptonMinusIndex].vec;
273    TLorentzVector Z1Candidate   =  Z1LeptonPlus + Z1LeptonMinus;
# Line 262 | Line 291 | unsigned fails_HZZ4L_selection(ControlFl
291    Int_t Z2LeptonPlusIndex = -1;
292    Int_t Z2LeptonMinusIndex = -1;
293    Double_t BestZ2Mass = -1;
294 <  cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
294 >  if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
295    for(int i = 0; i < lepvec.size(); ++i) {
296      for(int j = i+1; j < lepvec.size(); ++j) {
297        //            cout << "i: " << i << "\tj: " << j << endl;
# Line 298 | Line 327 | unsigned fails_HZZ4L_selection(ControlFl
327              TLorentzVector dilepton = leptonPlus+leptonMinus;
328              TLorentzVector fourLepton = Z1Candidate + dilepton;
329  
330 <            cout << "dilepton.M() : " << dilepton.M() << endl;
331 <            cout << "fourLepton.M() : " << fourLepton.M() << endl;
330 >            if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl;
331 >            if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl;
332  
333              if (!(dilepton.M() > 12.0)) continue;
334              if (!(fourLepton.M() > 100.0)) continue;
# Line 309 | Line 338 | unsigned fails_HZZ4L_selection(ControlFl
338              if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
339                TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
340                TLorentzVector pair2 = Z1LeptonMinus+leptonPlus;
341 <              cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
341 >              if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
342                if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
343              }
344              
# Line 368 | Line 397 | unsigned fails_HZZ4L_selection(ControlFl
397            //      cout << "evtfail: " << hex << evtfail << dec << endl;
398            //      continue;
399          }
400 <        cout << "\tgot a Z2 ..." << endl;
401 <        cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex << "\tminusindex: " << Z2LeptonMinusIndex << endl;
400 >        if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl;
401 >        if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex
402 >                              << "\tminusindex: " << Z2LeptonMinusIndex << endl;
403          TLorentzVector  Z2LeptonPlus  = lepvec[Z2LeptonPlusIndex].vec;
404          TLorentzVector  Z2LeptonMinus = lepvec[Z2LeptonMinusIndex].vec;
405          TLorentzVector  Z2Candidate   = Z2LeptonPlus+Z2LeptonMinus;
# Line 480 | Line 510 | unsigned fails_HZZ4L_selection(ControlFl
510                  cout.flush();
511                }
512                if( comboIso > 0.35 ) {
513 <                cout << "combo failing for indices: " << i << "," << j << endl;
513 >                if( ctrl.debug ) cout << "combo failing for indices: " << i << "," << j << endl;
514                  failiso = true;
515                  //            break;
516                }
# Line 518 | Line 548 | unsigned fails_HZZ4L_selection(ControlFl
548          //***************************************************************
549          // remaining kinematic cuts
550          //***************************************************************
551 <        if ( Z1Candidate.M() > 120 ||
552 <             Z2Candidate.M() < 20  ||
553 <             Z2Candidate.M() > 120 ||
551 >        double Z2massCut=0;
552 >        if      ( ctrl.kinematics == "loose" ) Z2massCut = 12;
553 >        else if ( ctrl.kinematics == "tight" ) Z2massCut = 20;
554 >        else { cout <<  "error! kinematic tightness not defined!" << endl; assert(0); }
555 >
556 >        if ( Z1Candidate.M() > 120        ||
557 >             Z2Candidate.M() < Z2massCut  ||
558 >             Z2Candidate.M() > 120        ||
559               !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec.Pt() > 20.0) ||
560               !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec.Pt() > 10.0)
561               ) {
# Line 539 | Line 574 | unsigned fails_HZZ4L_selection(ControlFl
574              (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
575          
576  
577 <        
577 >
578          if( passtuple != NULL ) {
579 <          passtuple->Fill( info->runNum,
580 <                           info->evtNum,
581 <                           info->lumiSec,
582 <                           channel,
583 <                           Z1Candidate.M(),
584 <                           Z2Candidate.M(),
585 <                           ZZSystem.M(),
586 <                           ZZSystem.Pt(),
587 <                           eventweight);
579 >          unsigned run   = info->runNum;
580 >          unsigned evt   = info->evtNum;
581 >          unsigned lumi  = info->lumiSec;
582 >          unsigned chan  = channel;
583 >          float mZ1      = Z1Candidate.M() ;
584 >          float mZ2      = Z2Candidate.M() ;
585 >          float m4l      = ZZSystem.M() ;
586 >          float pt4l     = ZZSystem.Pt() ;
587 >          passtuple->SetBranchAddress("run",  &run);
588 >          passtuple->SetBranchAddress("evt",  &evt);
589 >          passtuple->SetBranchAddress("lumi", &lumi);
590 >          passtuple->SetBranchAddress("mZ1",  &mZ1);
591 >          passtuple->SetBranchAddress("mZ2",  &mZ2);
592 >          passtuple->SetBranchAddress("m4l",  &m4l);
593 >          passtuple->SetBranchAddress("pt4l", &pt4l);
594 >          passtuple->SetBranchAddress("w",    &eventweight);
595 >          passtuple->Fill( );
596          }
597  
598 <        cout  << "run: " << info->runNum  
598 >        if( ctrl.debug ) cout  << "run: " << info->runNum  
599                << "\tevt: " << info->evtNum
600                << "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type
601                << "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines