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.7 by khahn, Fri Oct 14 11:20:25 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;
# Line 17 | Line 22 | unsigned fails_HZZ4L_selection(ControlFl
22                                 TClonesArray *electronArr,    // input electrons
23                                 TClonesArray *muonArr,        // input muons
24                                 double eventweight,           // weight
25 <                               TNtuple * passtuple ) {
25 >                               TTree * passtuple ) {
26  
27    fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL );
28  
# Line 40 | Line 45 | unsigned fails_HZZ4L_selection(ControlFl
45                                 TClonesArray *electronArr,    // input electrons
46                                 TClonesArray *muonArr,        // input muons
47                                 double eventweight,           // weight
48 <                               TNtuple * passtuple,
49 <                               LabVectors * l ) {       // output ntuple
48 >                               TTree * passtuple,
49 >                               LabVectors * l) {       // output ntuple
50  
51    unsigned evtfail = 0x0;
52  
53 +
54 +  if( ctrl.debug ) {
55 +    cout << "Run: " << info->runNum
56 +         << "\tEvt: " << info->evtNum
57 +         << "\tLumi: " << info->lumiSec
58 +         << endl;
59 +  }
60 +
61    if( !ctrl.mc ) {
62      // not accounting for overlap atm
63      RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);      
64      if( !(rlrm.HasRunLumi(rl)) )  {
65 +      if( ctrl.debug ) cout << "\tfails JSON" << endl;
66        evtfail |= (1<<EVTFAIL_JSON);
67        return evtfail;
68      }
69    }
70    
71    
72 <  if( ctrl.debug ) {
59 <    cout << "Run: " << info->runNum
60 <         << "\tEvt: " << info->evtNum
61 <         << "\tLumi: " << info->lumiSec
62 <         << endl;
63 <  }
72 >
73    
74    
75    //********************************************************
# Line 93 | Line 102 | unsigned fails_HZZ4L_selection(ControlFl
102    vector<SimpleLepton> lepvec;
103    
104    //    
105 <  cout << "\tnMuons: " << muonArr->GetEntries() << endl;
105 >  if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl;
106    //----------------------------------------------------
107    for(Int_t i=0; i<muonArr->GetEntries(); i++) {
108      const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]);      
# Line 124 | Line 133 | unsigned fails_HZZ4L_selection(ControlFl
133      }
134    }
135    
127  //
136    if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; }
137 +
138    //----------------------------------------------------
139    for(Int_t i=0; i<electronArr->GetEntries(); i++) {
140      const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]);
# Line 135 | Line 144 | unsigned fails_HZZ4L_selection(ControlFl
144        TVector3 tmplep;
145        tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi);
146        if ( lepvec[k].type == 13 && lepvec[k].vec.Vect().DrEtaPhi(tmplep) < 0.1 ) {
147 <        cout << "-----> isMuonOverlap! " << endl;
147 >        if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl;
148          isMuonOverlap = kTRUE;
149          break;
150        }
151      }
152  
153 <    CICStruct tightcuts = getTightCuts();
154 <    unsigned failsCIC = failsCicSelection(ele, tightcuts);
153 >    unsigned FAIL=0;
154 >    CICStruct ciccuts = getCiCCuts(ctrl.eleSeleScheme);
155 >    unsigned  failsCIC=0;
156 >    if(ctrl.eleSele=="cic") {
157 >      failsCIC = failsCicSelection(ctrl, ele, ciccuts, ctrl.kinematics);
158 >      FAIL = failsCIC;
159 >    }
160 >    LikStruct likcuts;
161 >    unsigned failsLike=0;
162 >    if(ctrl.eleSele=="lik") {
163 >      likcuts = getLikCuts(ctrl.eleSeleScheme);
164 >      failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics);
165 >      FAIL = failsLike;
166 >    }
167 >    unsigned  failsBDT=0;
168 >    if(ctrl.eleSele=="bdt") {
169 >      failsBDT = failsBDTSelection(ctrl,ele);
170 >      FAIL = failsBDT;
171 >    }
172 >    unsigned  failsSi=0;
173 >    if(ctrl.eleSele=="si") {
174 >      failsSi = failsSiMVAElectronSelection(ctrl, ele, 0.95, ctrl.kinematics);
175 >      FAIL = failsSi;
176 >    }
177 >
178 >
179 >
180 >
181      if( ctrl.debug ){
182        cout << "CIC category: " << cicCategory(ele)
183 <           << "\tfailmask : 0x" << hex << failsCIC  << dec
183 >           << "\tlikelihood: " << ele->likelihood
184 >           << "\tFAIL:  0x"     << hex << FAIL      << dec
185 >           << "\tfailsCIC:  0x" << hex << failsCIC  << dec
186 >           << "\tfailsLike: 0x" << hex << failsLike << dec
187 >           << "\tfailsBDT:  0x" << hex << failsBDT << dec
188             << "\tscEt: " << ele->scEt
189 <           << "\tscEta: " << ele->scEta
189 >           << "\tscEta: " << ele->scEta
190 >           << "\tncluster: " << ele->ncluster
191             << endl;
192      }
193 <    if ( !failsCIC && !isMuonOverlap ) {
193 >    if ( !FAIL && !isMuonOverlap ) {
194        SimpleLepton tmplep;
195        tmplep.vec.SetPtEtaPhiM( ele->pt,
196                                 ele->eta,
# Line 214 | Line 254 | unsigned fails_HZZ4L_selection(ControlFl
254        }
255        
256        float tmpZ1Mass = (leptonPlus+leptonMinus).M();
257 <      cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
257 >      if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl;
258        if( tmpZ1Mass > 60 ) {
259          if (fabs(tmpZ1Mass - 91.1876) < fabs(BestZ1Mass - 91.1876)) {
260            BestZ1Mass = tmpZ1Mass;
261 <          cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
261 >          if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass
262                 << "\tdM: " << fabs(BestZ1Mass - 91.1876)
263                 << endl;
264            if (lepvec[i].charge > 0) {
# Line 237 | Line 277 | unsigned fails_HZZ4L_selection(ControlFl
277      evtfail |= (1<<EVTFAIL_Z1);
278      return evtfail;
279    }
280 <  cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum  << endl;
281 <  cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
280 >  if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum  << endl;
281 >  if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl;
282    TLorentzVector Z1LeptonPlus  = lepvec[Z1LeptonPlusIndex].vec;
283    TLorentzVector Z1LeptonMinus = lepvec[Z1LeptonMinusIndex].vec;
284    TLorentzVector Z1Candidate   =  Z1LeptonPlus + Z1LeptonMinus;
# Line 262 | Line 302 | unsigned fails_HZZ4L_selection(ControlFl
302    Int_t Z2LeptonPlusIndex = -1;
303    Int_t Z2LeptonMinusIndex = -1;
304    Double_t BestZ2Mass = -1;
305 <  cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
305 >  if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl;
306    for(int i = 0; i < lepvec.size(); ++i) {
307      for(int j = i+1; j < lepvec.size(); ++j) {
308        //            cout << "i: " << i << "\tj: " << j << endl;
# Line 298 | Line 338 | unsigned fails_HZZ4L_selection(ControlFl
338              TLorentzVector dilepton = leptonPlus+leptonMinus;
339              TLorentzVector fourLepton = Z1Candidate + dilepton;
340  
341 <            cout << "dilepton.M() : " << dilepton.M() << endl;
342 <            cout << "fourLepton.M() : " << fourLepton.M() << endl;
341 >            if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl;
342 >            if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl;
343  
344              if (!(dilepton.M() > 12.0)) continue;
345              if (!(fourLepton.M() > 100.0)) continue;
# Line 309 | Line 349 | unsigned fails_HZZ4L_selection(ControlFl
349              if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) {
350                TLorentzVector pair1 = Z1LeptonPlus+leptonMinus;
351                TLorentzVector pair2 = Z1LeptonMinus+leptonPlus;
352 <              cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
352 >              if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl;
353                if (!(pair1.M() > 12 || pair2.M() > 12)) continue;
354              }
355              
# Line 368 | Line 408 | unsigned fails_HZZ4L_selection(ControlFl
408            //      cout << "evtfail: " << hex << evtfail << dec << endl;
409            //      continue;
410          }
411 <        cout << "\tgot a Z2 ..." << endl;
412 <        cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex << "\tminusindex: " << Z2LeptonMinusIndex << endl;
411 >        if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl;
412 >        if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex
413 >                              << "\tminusindex: " << Z2LeptonMinusIndex << endl;
414          TLorentzVector  Z2LeptonPlus  = lepvec[Z2LeptonPlusIndex].vec;
415          TLorentzVector  Z2LeptonMinus = lepvec[Z2LeptonMinusIndex].vec;
416          TLorentzVector  Z2Candidate   = Z2LeptonPlus+Z2LeptonMinus;
# Line 480 | Line 521 | unsigned fails_HZZ4L_selection(ControlFl
521                  cout.flush();
522                }
523                if( comboIso > 0.35 ) {
524 <                cout << "combo failing for indices: " << i << "," << j << endl;
524 >                if( ctrl.debug ) cout << "combo failing for indices: " << i << "," << j << endl;
525                  failiso = true;
526                  //            break;
527                }
# Line 518 | Line 559 | unsigned fails_HZZ4L_selection(ControlFl
559          //***************************************************************
560          // remaining kinematic cuts
561          //***************************************************************
562 <        if ( Z1Candidate.M() > 120 ||
563 <             Z2Candidate.M() < 20  ||
564 <             Z2Candidate.M() > 120 ||
562 >        double Z2massCut=0;
563 >        if      ( ctrl.kinematics == "loose" ) Z2massCut = 12;
564 >        else if ( ctrl.kinematics == "tight" ) Z2massCut = 20;
565 >        else { cout <<  "error! kinematic tightness not defined!" << endl; assert(0); }
566 >
567 >        if ( Z1Candidate.M() > 120        ||
568 >             Z2Candidate.M() < Z2massCut  ||
569 >             Z2Candidate.M() > 120        ||
570               !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec.Pt() > 20.0) ||
571               !(lepvec[Z1LeptonPlusIndex].vec.Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec.Pt() > 10.0)
572               ) {
# Line 539 | Line 585 | unsigned fails_HZZ4L_selection(ControlFl
585              (lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2;
586          
587  
588 <        
588 >
589          if( passtuple != NULL ) {
590 <          passtuple->Fill( info->runNum,
591 <                           info->evtNum,
592 <                           info->lumiSec,
593 <                           channel,
594 <                           Z1Candidate.M(),
595 <                           Z2Candidate.M(),
596 <                           ZZSystem.M(),
597 <                           ZZSystem.Pt(),
598 <                           eventweight);
590 >          unsigned run   = info->runNum;
591 >          unsigned evt   = info->evtNum;
592 >          unsigned lumi  = info->lumiSec;
593 >          unsigned chan  = channel;
594 >          double   w     = eventweight;
595 >          float mZ1      = Z1Candidate.M() ;
596 >          float mZ2      = Z2Candidate.M() ;
597 >          float m4l      = ZZSystem.M() ;
598 >          float pt4l     = ZZSystem.Pt() ;
599 >          passtuple->SetBranchAddress("run",  &run);
600 >          passtuple->SetBranchAddress("evt",  &evt);
601 >          passtuple->SetBranchAddress("lumi", &lumi);
602 >          passtuple->SetBranchAddress("mZ1",  &mZ1);
603 >          passtuple->SetBranchAddress("mZ2",  &mZ2);
604 >          passtuple->SetBranchAddress("m4l",  &m4l);
605 >          passtuple->SetBranchAddress("pt4l", &pt4l);
606 >          passtuple->SetBranchAddress("w",    &w);
607 >          passtuple->Fill( );
608          }
609  
610 <        cout  << "run: " << info->runNum  
610 >        if( ctrl.debug ) cout  << "run: " << info->runNum  
611                << "\tevt: " << info->evtNum
612                << "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type
613                << "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines