ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/NonMCBackground/src/select_fakes.cc
Revision: 1.2
Committed: Tue Jun 12 22:04:06 2012 UTC (12 years, 11 months ago) by dkralph
Content type: text/plain
Branch: MAIN
Changes since 1.1: +470 -122 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 dkralph 1.2 //
2     // System headers
3     //
4     #include <vector> // STL vector class
5     #include <iostream> // standard I/O
6     #include <iomanip> // functions to format standard I/O
7     #include <bitset>
8     #include <map>
9     using namespace std;
10    
11     //
12     // root headers
13     //
14     #include <TFile.h>
15     #include <TTree.h>
16     #include <TChain.h>
17     #include <TBranch.h>
18     #include <TClonesArray.h>
19    
20     //
21     // TMVA
22     //
23     #include "TMVA/Reader.h"
24     #include "TMVA/Tools.h"
25     #include "TMVA/Config.h"
26     #include "TMVA/MethodBDT.h"
27    
28     //
29     // ntuple format headers
30     //
31     #include "EventHeader.h"
32     #include "PFMet.h"
33     #include "Electron.h"
34     #include "Muon.h"
35     #include "Vertex.h"
36     #include "PFCandidate.h"
37     #include "PFCandidateCol.h"
38     #include "PileupInfoCol.h"
39     #include "PileupEnergyDensity.h"
40     #include "MCParticle.h"
41     #include "MCEventInfo.h"
42     #include "TriggerMask.h"
43     #include "TriggerTable.h"
44     #include "Names.h"
45     #include "BaseMod.h"
46    
47     //
48     // our headers
49     //
50     #include "ParseArgs.h"
51     #include "MuonSelection.h"
52     #include "ElectronSelection.h"
53     #include "IsolationSelection.h"
54     #include "UtilFuncs.h"
55    
56     #include "TriggerUtils.h"
57     #include "PassHLT.h"
58     #include "RunLumiRangeMap.h"
59     #include "fake_defs.hh"
60     #include "CommonDefs.h"
61    
62     #ifndef CMSSW_BASE
63     #define CMSSW_BASE "../"
64     #endif
65    
66     using namespace mithep;
67     //
68     // globals
69     //----------------------------------------------------------------------------
70     TH1D * hpu;
71     mithep::RunLumiRangeMap rlrm;
72     vector<SimpleLepton> failingLeptons ; // for fake estimation
73     vector<SimpleLepton> passingLeptons; // for fake estimation
74     vector<unsigned> cutvec;
75     vector<vector<unsigned> > zcutvec;
76     vector<vector<unsigned> > zzcutvec;
77     map<unsigned,float> evtrhoMap;
78     vector<string> cutstrs;
79     bool passes_HLT_MC;
80     vector<bool> PFnoPUflag;;
81    
82     //
83     // prototypes
84     //----------------------------------------------------------------------------
85     void initRunLumiRangeMap();
86    
87     mithep::MuonTools::EMuonEffectiveAreaTarget eraMu;
88     mithep::ElectronTools::EElectronEffectiveAreaTarget eraEle;
89     vector<const mithep::PFCandidate*> photonsToVeto;
90     //
91     // globals
92     //----------------------------------------------------------------------------
93    
94     void fill_muon_fakes(ControlFlags &ctrl,
95     mithep::Array<mithep::Muon> *muonArr,
96     mithep::Array<mithep::PFJet> *jetArr,
97     mithep::Array<mithep::PFCandidate> *pfArr,
98     mithep::Array<mithep::PileupEnergyDensity> *puDArr,
99     const mithep::Vertex *vtx,
100     foinfo &foi,
101     const mithep::Muon *zmu1,
102     const mithep::Muon *zmu2,
103     const mithep::Electron *zele1,
104     const mithep::Electron *zele2);
105     void fill_electron_fakes(ControlFlags &ctrl,
106     mithep::Array<mithep::Electron> *electronArr,
107     mithep::Array<mithep::PFJet> *jetArr,
108     mithep::Array<mithep::PFCandidate> *pfArr,
109     mithep::Array<mithep::PileupEnergyDensity> *puDArr,
110     const mithep::Vertex *vtx,
111     foinfo &foi,
112     const mithep::Muon *zmu1,
113     const mithep::Muon *zmu2,
114     const mithep::Electron *zele1,
115     const mithep::Electron *zele2);
116 dkralph 1.1
117     //=== MAIN =================================================================================================
118     int main(int argc, char** argv)
119     {
120 dkralph 1.2
121     string cmsswpath(CMSSW_BASE);
122     cmsswpath.append("/src");
123     std::bitset<1024> triggerBits;
124 dkralph 1.1 vector<vector<string> > inputFiles;
125     inputFiles.push_back(vector<string>());
126 dkralph 1.2 map<string,unsigned> entrymap; // number of unskimmed entries in each file
127 dkralph 1.1
128     //
129     // args
130     //--------------------------------------------------------------------------------------------------------------
131     ControlFlags ctrl;
132     parse_args( argc, argv, ctrl );
133     ctrl.dump();
134    
135     //
136     // File I/O
137     //--------------------------------------------------------------------------------------------------------------
138     TChain * chain = new TChain("Events");
139 dkralph 1.2 TChain * hltchain = new TChain("HLT");
140    
141 dkralph 1.1 string fname;
142 dkralph 1.2 unsigned total_unskimmed=0;
143     if( !ctrl.inputfiles.empty() ) {
144     ifstream f(ctrl.inputfiles.c_str());
145     while (f >> fname) {
146     if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines
147     cout << "adding inputfile : " << fname.c_str() << endl;
148     entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str());
149     total_unskimmed += entrymap[string(fname.c_str())];
150     chain->AddFile(fname.c_str());
151     hltchain->AddFile(fname.c_str());
152     }
153     } else {
154     cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl;
155     unsigned unsk_ents = unskimmedEntries(ctrl.inputfile.c_str());
156     entrymap[string(ctrl.inputfile.c_str())] = unsk_ents;
157     total_unskimmed += unsk_ents;
158     chain->AddFile(ctrl.inputfile.c_str());
159     hltchain->AddFile(ctrl.inputfile.c_str());
160 dkralph 1.1 }
161 dkralph 1.2 // write the total number of unskimmed events that went into making this output file to a text file
162     writeEntries(ctrl,total_unskimmed);
163 dkralph 1.1
164 dkralph 1.2 foinfo foi;
165     foi.nEvents=0;
166     foi.nDenom=0;
167     foi.nNumer=0;
168 dkralph 1.1
169 dkralph 1.2 double metMax = 25;
170 dkralph 1.1
171     //
172     // Setup
173     //--------------------------------------------------------------------------------------------------------------
174     const char * ofname;
175     if( strcmp( ctrl.outputfile.c_str(), "") ) {
176     ofname = ctrl.outputfile.c_str();
177     } else {
178     ofname = "fo.root";
179     }
180    
181     TFile *outFile = new TFile(ofname, "RECREATE");
182     TTree *outTree = new TTree("FO","FO");
183 dkralph 1.2 foi.outTree = outTree;
184     outTree->Branch("pt", &foi.fopt, "pt/F");
185     outTree->Branch("eta", &foi.foeta, "eta/F");
186     outTree->Branch("phi", &foi.fophi, "phi/F");
187     outTree->Branch("pass", &foi.fopass,"pass/F");
188     outTree->Branch("jpt", &foi.jpt,"jpt/F");
189    
190     // initMuonIDMVA();
191     getEATargets(ctrl,eraMu,eraEle);
192     initElectronIDMVAV1();
193     initMuonIsoMVA();
194     initElectronIDMVA();
195     initElectronIsoMVA();
196     initTrigger();
197     if(!ctrl.mc)
198     initRunLumiRangeMap();
199 dkralph 1.1
200     //
201     // Access samples and fill histograms
202     TFile *inputFile=0;
203     TTree *eventTree=0;
204 dkralph 1.2 string currentFile("");
205 dkralph 1.1
206 dkralph 1.2 mithep::EventHeader *info = new mithep::EventHeader();
207     mithep::Array<mithep::PFMet> *metArr = new mithep::Array<mithep::PFMet>();
208     mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>();
209     mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>();
210     mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>();
211     mithep::Array<mithep::PFCandidate> *pfArr = new mithep::Array<mithep::PFCandidate>();
212     mithep::Array<mithep::PFJet> *jetArr = new mithep::Array<mithep::PFJet>();
213     mithep::Array<mithep::PileupInfo> *puArr = new mithep::Array<mithep::PileupInfo>();
214     mithep::Array<mithep::PileupEnergyDensity> *puDArr = new mithep::Array<mithep::PileupEnergyDensity>();
215     mithep::Array<mithep::Track> *trkArr = new mithep::Array<mithep::Track>();
216     mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>();
217     mithep::MCEventInfo *mcEvtInfo = new mithep::MCEventInfo();
218     mithep::TriggerMask *trigMask = new mithep::TriggerMask();
219     mithep::TriggerTable *hltTable = new mithep::TriggerTable();
220     vector<string> *hltTableStrings = new vector<string>();
221    
222     TString fElectronName(Names::gkElectronBrn);
223     TString fMuonName(Names::gkMuonBrn);
224     TString fInfoName(Names::gkEvtHeaderBrn);
225     TString fPFMetName("PFMet");
226     TString fPrimVtxName(Names::gkPVBrn);
227     TString fPFCandidateName(Names::gkPFCandidatesBrn);
228     TString fPFJetName(Names::gkPFJetBrn);
229     TString fPileupInfoName(Names::gkPileupInfoBrn);
230     TString fPileupEnergyDensityName(Names::gkPileupEnergyDensityBrn);
231     TString fTrackName(Names::gkTrackBrn);
232     TString fMCParticleName(Names::gkMCPartBrn);
233     TString fMCEvtInfoName(Names::gkMCEvtInfoBrn);
234     TString fTriggerMaskName(Names::gkHltBitBrn);
235     TString fTriggerTableName(Names::gkHltTableBrn);
236    
237     chain->SetBranchAddress(fInfoName, &info);
238     chain->SetBranchAddress(fPFMetName, &metArr);
239     chain->SetBranchAddress(fElectronName, &electronArr);
240     chain->SetBranchAddress(fMuonName, &muonArr);
241     chain->SetBranchAddress(fPrimVtxName, &vtxArr);
242     chain->SetBranchAddress(fPFCandidateName, &pfArr);
243     chain->SetBranchAddress(fPFJetName, &jetArr);
244     if( ctrl.mc ) {
245     chain->SetBranchAddress(fPileupInfoName, &puArr);
246     chain->SetBranchAddress(fMCParticleName, &mcArr);
247     chain->SetBranchAddress(fMCEvtInfoName, &mcEvtInfo);
248     }
249     chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr);
250     chain->SetBranchAddress(fTrackName, &trkArr);
251     chain->SetBranchAddress(fTriggerMaskName, &trigMask);
252     cout << "hlttable: " << fTriggerTableName << endl;
253     hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings);
254    
255     const mithep::Vertex *vtx; // best primary vertex in the event
256 dkralph 1.1
257 dkralph 1.2 // ginfo = NULL;
258     // if( ctrl.mc ) { chain->SetBranchAddress("Gen", &ginfo);}
259    
260     // only 1 HLT table / file ???
261     hltchain->GetEntry(0);
262    
263     int imax = chain->GetEntries();
264     cout << "nEntries: " << imax << endl;
265 dkralph 1.1 for(UInt_t ientry=0; ientry<imax; ientry++) {
266     chain->GetEntry(ientry);
267 dkralph 1.2 if(!(ientry%10000)) cout << "entry: " << ientry << "\tfrac: " << setw(15) << float(ientry)/chain->GetEntries() << endl;
268    
269     // pfNoPU
270     PFnoPUflag.clear();
271     int pfnopu_size = makePFnoPUArray( pfArr, PFnoPUflag, vtxArr );
272     assert(pfnopu_size == pfArr->GetEntries());
273    
274     // // check for certified runs
275     // mithep::RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec);
276     // if(!rlrm.HasRunLumi(rl)) { if(ctrl.debug) cout << "\tfailing rlrm..." << endl; continue; }
277    
278     foi.nEvents++;
279 dkralph 1.1
280 dkralph 1.2 setPV( ctrl, vtxArr, vtx);
281 dkralph 1.1
282 dkralph 1.2 TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0);
283     if(pfmet.Pt() > metMax) continue;
284 dkralph 1.1
285 dkralph 1.2 // good lepton selection
286     vector<const mithep::Muon*> goodMuons;
287     vector<const mithep::Electron*> goodElectrons;
288     for(int imu=0; imu<muonArr->GetEntries(); imu++) {
289     const mithep::Muon *mu = (*muonArr)[imu];
290     SelectionStatus status = muonReferencePreSelection(ctrl,mu,vtx,pfArr);
291     if( !status.passPre() ) continue;
292     goodMuons.push_back(mu);
293     }
294     int NElectrons=0;
295 dkralph 1.1 for(Int_t i=0; i<electronArr->GetEntries(); i++) {
296 dkralph 1.2 const mithep::Electron *ele = (*electronArr)[i];
297     if(ele->Pt() > 5) NElectrons++;
298     SelectionStatus status = electronReferencePreSelection(ctrl,ele,vtx);
299     if( !status.passPre() ) continue;
300     //????????????????????????????????????????????????????????????????????????????????????????
301     // add in iso here?
302     //????????????????????????????????????????????????????????????????????????????????????????
303     goodElectrons.push_back(ele);
304 dkralph 1.1 }
305    
306 dkralph 1.2 // look for z pairs
307     int NZCandidates=0;
308     const mithep::Muon *zmu1=0,*zmu2=0;
309     const mithep::Electron *zele1=0,*zele2=0;
310     for(unsigned imu=0; imu<goodMuons.size(); imu++) {
311     TLorentzVector mu1;
312     mu1.SetPtEtaPhiM(goodMuons[imu]->Pt(),goodMuons[imu]->Eta(),goodMuons[imu]->Phi(),MUON_MASS);
313     for(unsigned jmu=imu+1; jmu<goodMuons.size(); jmu++) {
314     TLorentzVector mu2;
315     mu2.SetPtEtaPhiM(goodMuons[jmu]->Pt(),goodMuons[jmu]->Eta(),goodMuons[jmu]->Phi(),MUON_MASS);
316     TLorentzVector dimu(mu1+mu2);
317     if(dimu.M() < 75 || dimu.M() > 105) continue;
318     if(goodMuons[imu]->Charge() == goodMuons[jmu]->Charge()) continue;
319    
320     zmu1 = goodMuons[imu];
321     zmu2 = goodMuons[jmu];
322     NZCandidates++;
323     }
324     }
325     for(unsigned iele=0; iele<goodElectrons.size(); iele++) {
326     TLorentzVector ele1;
327     ele1.SetPtEtaPhiM(goodElectrons[iele]->Pt(),goodElectrons[iele]->Eta(),goodElectrons[iele]->Phi(),ELECTRON_MASS);
328     for(unsigned jele=iele+1; jele<goodElectrons.size(); jele++) {
329     TLorentzVector ele2;
330     ele2.SetPtEtaPhiM(goodElectrons[jele]->Pt(),goodElectrons[jele]->Eta(),goodElectrons[jele]->Phi(),ELECTRON_MASS);
331     TLorentzVector diele(ele1+ele2);
332     if(diele.M() < 75 || diele.M() > 105) continue;
333     if(goodElectrons[iele]->Charge() == goodElectrons[jele]->Charge()) continue;
334    
335     zele1 = goodElectrons[iele];
336     zele2 = goodElectrons[jele];
337     NZCandidates++;
338 dkralph 1.1 }
339 dkralph 1.2 }
340    
341     if(NZCandidates!=1) continue;
342     int ZDecayType = (zmu1 && zmu2) ? 13 : 11;
343    
344     // we want only one jet...
345     if(ZDecayType==11 && NElectrons > 3) continue;
346     if(ZDecayType==13 && NElectrons > 1) continue;
347    
348     // pointless...
349     if(zele1) assert(zele2 && !zmu1 && !zmu2);
350     if(zele2) assert(zele1 && !zmu1 && !zmu2);
351     if(zmu1) assert(zmu2 && !zele1 && !zele2);
352     if(zmu2) assert(zmu1 && !zele1 && !zele2);
353    
354     cout << "trying to fill" << endl;
355     if(ctrl.fakeScheme.Contains("mu_")) {
356     cout << "filling mu" << endl;
357     fill_muon_fakes(ctrl,muonArr,jetArr,pfArr,puDArr,vtx,foi,zmu1,zmu2,zele1,zele2);
358     } else if(ctrl.fakeScheme.Contains("ele_")) {
359     cout << "filling el" << endl;
360     fill_electron_fakes(ctrl,electronArr,jetArr,pfArr,puDArr,vtx,foi,zmu1,zmu2,zele1,zele2);
361     } else assert(0);
362 dkralph 1.1
363    
364 dkralph 1.2 }
365    
366 dkralph 1.1 outFile->Write();
367     outFile->Close();
368 dkralph 1.2
369 dkralph 1.1 //--------------------------------------------------------------------------------------------------------------
370     // Summary print out
371     //==============================================================================================================
372     cout << endl;
373     cout << "*" << endl;
374     cout << "* SUMMARY" << endl;
375     cout << "*--------------------------------------------------" << endl;
376     cout << endl;
377    
378 dkralph 1.2 cout << " >>> No. of events processed: " << foi.nEvents << endl;
379     cout << " >>> No. of denominator objects: " << foi.nDenom << endl;
380     cout << " >>> No. of numerator objects: " << foi.nNumer << endl;
381     cout << " >>> ratio: " << float(foi.nNumer)/foi.nDenom << endl;
382 dkralph 1.1 cout << endl;
383    
384 dkralph 1.2 TString outputDir(ofname);
385     outputDir = outputDir(0,outputDir.Last('/'));
386 dkralph 1.1 ofstream txtfile;
387     char txtfname[100];
388 dkralph 1.2 TString txtname(ctrl.outputfile);
389     txtname.ReplaceAll(".root",".txt");
390     cout << "writing text to: " << txtname << endl;
391     txtfile.open(txtname);
392 dkralph 1.1 txtfile << "*" << endl;
393     txtfile << "* SUMMARY" << endl;
394     txtfile << "*--------------------------------------------------" << endl;
395     txtfile << endl;
396    
397 dkralph 1.2 txtfile << " >>> No. of events processed: " << foi.nEvents << endl;
398     txtfile << " >>> No. of denominator objects: " << foi.nDenom << endl;
399     txtfile << " >>> No. of numerator objects: " << foi.nNumer << endl;
400     txtfile << " >>> ratio: " << float(foi.nNumer)/foi.nDenom << endl;
401 dkralph 1.1 txtfile << endl;
402     txtfile.close();
403    
404     cout << " <> Output saved in " << outputDir << "/" << endl;
405     cout << endl;
406    
407     cout << "done!" << endl;
408 dkralph 1.2 }
409     //----------------------------------------------------------------------------------------
410     void fill_muon_fakes(ControlFlags &ctrl,
411     mithep::Array<mithep::Muon> *muonArr,
412     mithep::Array<mithep::PFJet> *jetArr,
413     mithep::Array<mithep::PFCandidate> *pfArr,
414     mithep::Array<mithep::PileupEnergyDensity> *puDArr,
415     const mithep::Vertex *vtx,
416     foinfo &foi,
417     const mithep::Muon *zmu1,
418     const mithep::Muon *zmu2,
419     const mithep::Electron *zele1,
420     const mithep::Electron *zele2)
421     {
422    
423     // count denominator and numerator objects
424     for(Int_t imu=0; imu<muonArr->GetEntries(); imu++) {
425     const mithep::Muon* mu = (*muonArr)[imu];
426     if(ctrl.debug) cout << "\t\timu: " << imu << endl;
427    
428     if(mu==zmu1 || mu==zmu2) { if(ctrl.debug) cout << "\t\tdecayed from the z..." << endl; continue; }
429     if(zele1 && dr(mu,zele1) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zele1" << endl; continue; }
430     if(zele2 && dr(mu,zele2) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zele2" << endl; continue; }
431     if(zmu1 && dr(mu,zmu1) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zmu1" << endl; continue; }
432     if(zmu2 && dr(mu,zmu2) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zmu2" << endl; continue; }
433    
434     //find leading jet in the event
435     Double_t leadingJetPt = -1;
436     for(Int_t j=0; j<jetArr->GetEntries(); j++) {
437     const mithep::PFJet *jet = (*jetArr)[j];
438     if (jet->Pt() > leadingJetPt && dr(jet,mu) > 1) {
439     leadingJetPt = jet->Pt();
440     }
441     }
442 dkralph 1.1
443 dkralph 1.2 // denominator definition
444     if(mu->Pt() < 5 || mu->Pt() > 35) { if(ctrl.debug) cout << "\t\tfails pt: " << mu->Pt() << endl; continue; }
445     SelectionStatus musel;
446     musel |= muonReferencePreSelection(ctrl,mu,vtx,pfArr);;
447     if( !musel.passPre() ) { if(ctrl.debug) cout << "\t\tfails mu presection..." << endl; continue; }
448    
449     foi.nDenom++;
450     if(ctrl.debug) cout << "\t\tdenominator: " << foi.nDenom << endl;
451    
452     // numerator definition
453     musel |= muonIDPFSelection(ctrl,mu,vtx,pfArr);
454     musel |= muonReferenceIsoSelection(ctrl,mu,vtx,pfArr,puDArr,eraMu,photonsToVeto);
455    
456     // bool pass = passSelection(ctrl,musel);
457     bool pass = musel.loose();
458    
459     if(pass) {
460     foi.nNumer++;
461     if(ctrl.debug) cout << "\t\tnumerator: " << foi.nNumer << endl;
462     }
463     // fill output TTree
464     foi.fopt = mu->Pt();
465     foi.foeta = mu->Eta();
466     foi.fophi = mu->Phi();
467     foi.fopass = pass ? 1 : 0;
468     foi.jpt = leadingJetPt;
469     foi.outTree->Fill();
470     }
471     }
472     //----------------------------------------------------------------------------------------
473     void fill_electron_fakes(ControlFlags &ctrl,
474     mithep::Array<mithep::Electron> *electronArr,
475     mithep::Array<mithep::PFJet> *jetArr,
476     mithep::Array<mithep::PFCandidate> *pfArr,
477     mithep::Array<mithep::PileupEnergyDensity> *puDArr,
478     const mithep::Vertex *vtx,
479     foinfo &foi,
480     const mithep::Muon *zmu1,
481     const mithep::Muon *zmu2,
482     const mithep::Electron *zele1,
483     const mithep::Electron *zele2)
484     {
485    
486     // count denominator and numerator objects
487     for(Int_t iele=0; iele<electronArr->GetEntries(); iele++) {
488     const mithep::Electron* ele = (*electronArr)[iele];
489    
490     if(ele==zele1 || ele==zele2) { if(ctrl.debug) cout << "\t\tdecayed from the z..." << endl; continue; }
491     if(zele1 && dr(ele,zele1) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zele1" << endl; continue; }
492     if(zele2 && dr(ele,zele2) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zele2" << endl; continue; }
493     if(zmu1 && dr(zmu1,ele) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zmu1" << endl; continue; }
494     if(zmu2 && dr(zmu2,ele) < 0.3) { if(ctrl.debug) cout << "\t\tdr-matched to zmu2" << endl; continue; }
495    
496     //find leading jet in the event
497     Double_t leadingJetPt = -1;
498     for(Int_t j=0; j<jetArr->GetEntries(); j++) {
499     const mithep::PFJet *jet = (*jetArr)[j];
500     if (jet->Pt() > leadingJetPt && dr(jet,ele) > 1) {
501     leadingJetPt = jet->Pt();
502     }
503     }
504    
505     // denominator definition
506     if(ele->Pt() < 5 || ele->Pt() > 35) { if(ctrl.debug) cout << "\t\tfails pt: " << ele->Pt() << endl; continue; }
507     SelectionStatus elsel;
508     elsel |= electronReferencePreSelection(ctrl,ele,vtx);
509     if( !elsel.passPre() ) { if(ctrl.debug) cout << "\t\tfails ele presection..." << endl; continue; }
510    
511     foi.nDenom++;
512     if(ctrl.debug) cout << "\t\tdenominator: " << foi.nDenom << endl;
513    
514     // numerator definition
515     elsel |= electronReferenceIDMVASelectionV1(ctrl,ele,vtx);
516     elsel |= electronReferenceIsoSelection(ctrl,ele,vtx,pfArr,puDArr,eraEle,photonsToVeto);
517    
518     // status |= eleSele(ctrl,ele,iele,brs);
519     // bool pass = passSelection(ctrl,status);
520     bool pass = elsel.loose();
521    
522     if(pass) {
523     foi.nNumer++;
524     if(ctrl.debug) cout << "\t\tnumerator: " << foi.nNumer << endl;
525     }
526     // fill output TTree
527     foi.fopt = ele->Pt();
528     foi.foeta = ele->Eta();
529     foi.fophi = ele->Phi();
530     foi.fopass = pass ? 1 : 0;
531     foi.jpt = leadingJetPt;
532     foi.outTree->Fill();
533     }
534 dkralph 1.1 }
535 dkralph 1.2 //----------------------------------------------------------------------------
536     void initRunLumiRangeMap()
537     //----------------------------------------------------------------------------
538     {
539     /*
540     rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt"));
541     // rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt"));
542     rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt"));
543     rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt"));
544     rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt"));
545     // r11b
546     rlrm.AddJSONFile(std::string("./data/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt"));
547     */
548    
549     // 2012 only for now ...
550     rlrm.AddJSONFile(std::string("./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt"));
551    
552     };