ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/applySelection.cc
(Generate patch)

Comparing UserCode/MitHzz4l/Selection/src/applySelection.cc (file contents):
Revision 1.46 by khahn, Wed Jun 20 17:40:22 2012 UTC vs.
Revision 1.52 by khahn, Wed Jul 11 18:24:39 2012 UTC

# Line 33 | Line 33 | using namespace std;
33   #include "Electron.h"
34   #include "Muon.h"
35   #include "Vertex.h"
36 + #include "PFMet.h"
37   #include "PFCandidate.h"
38   #include "PFCandidateCol.h"
39   #include "PileupInfoCol.h"
# Line 81 | Line 82 | using namespace mithep;
82   //
83   // globals
84   //----------------------------------------------------------------------------
85 < TH1D * hpu;
85 > TH1D *hpu_2011, *hpu_2012;
86   RunLumiRangeMap rlrm;
87   vector<SimpleLepton> failingLeptons ; // for fake estimation
88   vector<SimpleLepton> passingLeptons;      // for fake estimation
# Line 96 | Line 97 | vector<bool>   PFnoPUflag;;
97   //
98   // prototypes
99   //----------------------------------------------------------------------------
100 < void initPUWeights();
100 < double getPUWeight(unsigned npu);
101 < void initRunLumiRangeMap();
100 > void initRunLumiRangeMap(ControlFlags &ctrl);
101   //----------------------------------------------------------------------------
102  
103  
# Line 222 | Line 221 | int main(int argc, char** argv)
221  
222    
223    FOTuple foTree( nt.getFile(), (const char*)"FOtree");
224 +  foTree.makeInfoBranch(evtinfo);
225    foTree.makeFailedLeptonBranch(failingLeptons);
226    foTree.makePassedLeptonBranch(passingLeptons);
227  
# Line 229 | Line 229 | int main(int argc, char** argv)
229    if(ctrl.mc) {
230      nt.makeWeightBranch(weights);
231      if(ctrl.fillGen ) nt.makeGenInfoBranch(geninfo);
232 <    if(ctrl.efftype != string("WTF?")) initEfficiencyWeights();
232 >    initEfficiencyWeights();
233      initPUWeights();
234  
235      // Higgs only, pt reweighting
# Line 243 | Line 243 | int main(int argc, char** argv)
243      }
244  
245    } else {
246 <    initRunLumiRangeMap();
246 >    initRunLumiRangeMap(ctrl);
247    }
248  
249    //  initMuonIDMVA();
# Line 259 | Line 259 | int main(int argc, char** argv)
259  
260    UInt_t fNMaxTriggers = 1024;
261    mithep::EventHeader *info    = new mithep::EventHeader();
262 +  mithep::Array<mithep::PFMet>                *metArr        = new mithep::Array<mithep::PFMet>();
263    mithep::Array<mithep::Electron>             *electronArr   = new mithep::Array<mithep::Electron>();
264    mithep::Array<mithep::Muon>                 *muonArr       = new mithep::Array<mithep::Muon>();
265    mithep::Array<mithep::Vertex>               *vtxArr        = new mithep::Array<mithep::Vertex>();
# Line 282 | Line 283 | int main(int argc, char** argv)
283    TString fElectronName(Names::gkElectronBrn);
284    TString fMuonName(Names::gkMuonBrn);
285    TString fInfoName(Names::gkEvtHeaderBrn);
286 +  TString fPFMetName("PFMet");
287    TString fPrimVtxName(Names::gkPVBrn);
288    TString fPFCandidateName(Names::gkPFCandidatesBrn);
289    TString fPileupInfoName(Names::gkPileupInfoBrn);
# Line 304 | Line 306 | int main(int argc, char** argv)
306  
307    
308    chain->SetBranchAddress(fInfoName,        &info);
309 +  chain->SetBranchAddress(fPFMetName,       &metArr);
310    chain->SetBranchAddress(fElectronName,    &electronArr);
311    chain->SetBranchAddress(fMuonName,        &muonArr);
312    chain->SetBranchAddress(fPrimVtxName,     &vtxArr);
# Line 338 | Line 341 | int main(int argc, char** argv)
341  
342    // only 1 HLT table / file ???
343    hltchain->GetEntry(0);
341  cerr << "here... " << endl;
344  
345    int imax = chain->GetEntries();
346    cout << "nEntries: " << imax << endl;
# Line 363 | Line 365 | int main(int argc, char** argv)
365  
366  
367        string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile());
368 <      setEra( fname, ctrl );
369 <
370 <
368 >      if(ctrl.debug) cout << "era is " << ctrl.era << endl;
369 >      if( ctrl.era == 0  ) {
370 >        setEra( fname, ctrl );
371 >        if(ctrl.debug) cout << "era is now " << ctrl.era << endl;
372 >      }
373  
374        //
375        // pfNoPU
# Line 390 | Line 394 | int main(int argc, char** argv)
394          //
395          weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC;
396          cout << "xsec weight: " << weights.w << endl;
397 <        int npu = -1;
398 <        for(int i=0;i<puArr->GetEntries();i++) {
399 <          if(puArr->At(i)->GetBunchCrossing() == 0)
400 <            npu = puArr->At(i)->GetPU_NumInteractions();
401 <        }
402 <        assert(npu>=0);
399 <        evtinfo.npu;
400 <        weights.npuw = getPUWeight(evtinfo.npu);
401 <        
397 >
398 >        unsigned npu = getNPU(puArr, 0);
399 >        weights.npu  = npu;
400 >        weights.npuw = getPUWeight(ctrl.era,npu);
401 >        cerr << "weights.npuw: " <<  weights.npuw << endl;
402 >
403          //
404          // pt reweighting for Higgs < 140, F11
405          //
# Line 420 | Line 421 | int main(int argc, char** argv)
421            hltchain->GetEntry(0);
422            hltTable->Clear();
423            fillTriggerNames(hltTable, hltTableStrings );
424 +          hltTable->Print();
425          }
426          if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
427          fillTriggerBits( hltTable, trigMask, triggerBits );
# Line 454 | Line 456 | int main(int argc, char** argv)
456            fillTriggerNames(hltTable, hltTableStrings );
457          }
458  
459 <        setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
458 <        printTriggerObjs( hltTable, fTrigObjs );
459 >      setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs );
460  
461          if( ctrl.debug ) cout << "file is : " << currentFile  << endl;
462          /*
# Line 502 | Line 503 | int main(int argc, char** argv)
503          if( abs(ret4l.Z2leptons[0].type) == 13  ) Z2type = 13;
504        }  
505        
505 #ifdef SYNC
506      cout  << "bits: " << ret4l.status.selectionBits  << "\t"
507            << "Z1: " << Z1type << "\t"
508            << "Z2: " << Z2type << endl;
509      cout << endl;
510 #endif      
511      
506        if( ret4l.status.pass() ) {
507          fillAngles(ret4l,angles);
508          fillKinematics(ret4l,kinematics);
509          fillMassErrors(ret4l,muonArr,electronArr,kinematics);
510 <        fillEventInfo(info,evtinfo);
510 >        TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
511 >        fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0);
512          if( ctrl.mc) {
513 <          if( std::string(ctrl.efftype) != std::string("WTF?")) {
519 <            setEffiencyWeights(ctrl.era, ret4l, weights);
520 <          } else {
521 <            weights.won = weights.woff = 1.;
522 <          }
513 >          setEffiencyWeights(ctrl.era, ret4l, triggerBits, hltTable, hltObjArr, fTrigObjs, weights);
514            if(ctrl.debug)
515              cout << "w: " << weights.w << "\t"
516 +                 << "npuw: " << weights.npuw << "\t"
517                   << "won: " << weights.won << "\t"
518                   << "woff: " << weights.woff << endl;
519          }
# Line 554 | Line 546 | int main(int argc, char** argv)
546                   << endl;
547            }
548          }
549 +        TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
550 +        fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0);
551          foTree.Fill();
552        } else {
553 <        cout << "failing with some other code : " << ret4l.status.selectionBits << endl;
553 >        if(ctrl.debug)
554 >          cout << "failing with some other code : " << ret4l.status.selectionBits << endl;
555        }
556      }  
557  
# Line 565 | Line 560 | int main(int argc, char** argv)
560    foTree.getTree()->Write();
561    nt.WriteClose();
562  
563 <  cout << endl;
564 <  cout << endl;
563 >  if(ctrl.debug)
564 >    cout << endl << endl;
565    for( int i=0; i<cutvec.size(); i++ ) {
566      cout << "cut: " << i << "\t"
567           << "pass: " << cutvec[i];
# Line 589 | Line 584 | int main(int argc, char** argv)
584  
585  
586   //----------------------------------------------------------------------------
587 < void initRunLumiRangeMap()
587 > void initRunLumiRangeMap(ControlFlags &ctrl)
588   //----------------------------------------------------------------------------
589   {
590    /*
# Line 603 | Line 598 | void initRunLumiRangeMap()
598    */
599  
600    // 2012 only for now ...
601 <  rlrm.AddJSONFile(std::string("./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt"));  
602 <
601 >  std::string jsonFile;
602 >  if(ctrl.jsonFile=="")
603 >    jsonFile = "./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt";
604 >  else
605 >    jsonFile = ctrl.jsonFile;
606 >  rlrm.AddJSONFile(jsonFile);  
607   };
609
610
611 //----------------------------------------------------------------------------
612 void initPUWeights()
613 //----------------------------------------------------------------------------
614 {
615  TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Full2011.root");
616  hpu = (TH1D*)(puf->Get("puWeights"));
617 }
618
619 //----------------------------------------------------------------------------
620 double getPUWeight(unsigned npu)
621 //----------------------------------------------------------------------------
622 {
623  return hpu->GetBinContent(hpu->FindBin(npu));
624 }
625

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines