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" |
41 |
|
#include "MCParticle.h" |
42 |
|
#include "TriggerMask.h" |
43 |
|
#include "TriggerTable.h" |
44 |
+ |
#include "TriggerObject.h" |
45 |
+ |
#include "TriggerObjectRel.h" |
46 |
|
#include "Names.h" |
47 |
|
#include "BaseMod.h" |
48 |
+ |
#include "TriggerObjectsTable.h" |
49 |
|
|
50 |
|
// |
51 |
|
// our headers |
69 |
|
#include "RunLumiRangeMap.h" |
70 |
|
#include "SampleWeight.h" |
71 |
|
#include "EfficiencyWeightsInterface.h" |
72 |
+ |
#include "SelectionFuncs.h" |
73 |
|
|
74 |
|
#include "SimpleLepton.h" |
75 |
|
|
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 |
97 |
|
// |
98 |
|
// prototypes |
99 |
|
//---------------------------------------------------------------------------- |
100 |
< |
void initPUWeights(); |
96 |
< |
double getPUWeight(unsigned npu); |
97 |
< |
void setEra(string, ControlFlags&); |
98 |
< |
void setEffiencyWeights(EventData&, WeightStruct& ); |
99 |
< |
void initRunLumiRangeMap(); |
100 |
< |
void initEvtRhoMap(map<unsigned,float> &); |
101 |
< |
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
102 |
< |
vector<bool> &pfNoPileUpFlag, |
103 |
< |
const mithep::Array<mithep::Vertex> * vtxArr ); |
100 |
> |
void initRunLumiRangeMap(ControlFlags &ctrl); |
101 |
|
//---------------------------------------------------------------------------- |
102 |
|
|
103 |
|
|
168 |
|
TChain * hltchain = new TChain("HLT"); |
169 |
|
|
170 |
|
string fname; |
171 |
+ |
unsigned total_unskimmed=0; |
172 |
|
if( !ctrl.inputfiles.empty() ) { |
173 |
|
ifstream f(ctrl.inputfiles.c_str()); |
174 |
|
while (f >> fname) { |
176 |
|
cout << "adding inputfile : " << fname.c_str() << endl; |
177 |
|
entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str()); |
178 |
|
cout << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl; |
179 |
+ |
total_unskimmed += entrymap[string(fname.c_str())]; |
180 |
|
chain->AddFile(fname.c_str()); |
181 |
|
hltchain->AddFile(fname.c_str()); |
182 |
|
} |
183 |
|
} else { |
184 |
|
cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl; |
185 |
< |
unsigned tmpent = unskimmedEntries(ctrl.inputfile.c_str()); |
186 |
< |
cout << "tmpent: " << tmpent << endl; |
187 |
< |
entrymap[string(ctrl.inputfile.c_str())] = unskimmedEntries(ctrl.inputfile.c_str()); |
188 |
< |
cout << "unskimmed entries: " << entrymap[string(ctrl.inputfile.c_str())] << endl; |
185 |
> |
unsigned unsk_ents = unskimmedEntries(ctrl.inputfile.c_str()); |
186 |
> |
entrymap[string(ctrl.inputfile.c_str())] = unsk_ents; |
187 |
> |
cout << "unskimmed entries: " << unsk_ents << endl; |
188 |
> |
total_unskimmed += unsk_ents; |
189 |
|
chain->AddFile(ctrl.inputfile.c_str()); |
190 |
|
hltchain->AddFile(ctrl.inputfile.c_str()); |
191 |
|
} |
192 |
+ |
// // write the total number of unskimmed events that went into making this output file to a text file |
193 |
+ |
// writeEntries(ctrl,total_unskimmed); |
194 |
|
|
195 |
|
const char * ofname; |
196 |
|
if( strcmp( ctrl.outputfile.c_str(), "") ) { |
204 |
|
SimpleTable xstab(xspath.c_str()); |
205 |
|
|
206 |
|
|
207 |
+ |
|
208 |
|
// |
209 |
|
// Setup |
210 |
|
//-------------------------------------------------------------------------------------------------------------- |
227 |
|
TH1F * h_wf11_hpt; |
228 |
|
if(ctrl.mc) { |
229 |
|
nt.makeWeightBranch(weights); |
230 |
< |
// nt.makeGenInfoBranch(geninfo); |
230 |
> |
if(ctrl.fillGen ) nt.makeGenInfoBranch(geninfo); |
231 |
|
initEfficiencyWeights(); |
232 |
|
initPUWeights(); |
233 |
|
|
249 |
|
initElectronIDMVAV1(); |
250 |
|
initTrigger(); |
251 |
|
|
250 |
– |
// hack |
251 |
– |
initEvtRhoMap(evtrhoMap); |
252 |
– |
|
253 |
– |
|
252 |
|
// |
253 |
|
// Setup tree I/O |
254 |
|
//-------------------------------------------------------------------------------------------------------------- |
256 |
|
TTree *eventTree=0; |
257 |
|
string currentFile(""); |
258 |
|
|
259 |
+ |
UInt_t fNMaxTriggers = 1024; |
260 |
|
mithep::EventHeader *info = new mithep::EventHeader(); |
261 |
+ |
mithep::Array<mithep::PFMet> *metArr = new mithep::Array<mithep::PFMet>(); |
262 |
|
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
263 |
|
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
264 |
|
mithep::Array<mithep::Vertex> *vtxArr = new mithep::Array<mithep::Vertex>(); |
269 |
|
mithep::Array<mithep::MCParticle> *mcArr = new mithep::Array<mithep::MCParticle>(); |
270 |
|
mithep::MCEventInfo *mcEvtInfo = new mithep::MCEventInfo(); |
271 |
|
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
272 |
< |
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
272 |
> |
mithep::TriggerTable *hltTable = new mithep::TriggerTable(fNMaxTriggers); |
273 |
|
vector<string> *hltTableStrings = new vector<string>(); |
274 |
+ |
vector<string> *hltLabelStrings = new vector<string>(); |
275 |
+ |
mithep::Array<mithep::TriggerObject> *hltObjArr = new mithep::Array<mithep::TriggerObject>(); |
276 |
+ |
mithep::Array<mithep::TriggerObjectRel> *hltRelsArr = new mithep::Array<mithep::TriggerObjectRel>(); |
277 |
+ |
std::vector<std::string> *hltTab = new vector<string>(); |
278 |
+ |
std::vector<std::string> *hltLab = new vector<string>(); |
279 |
+ |
TriggerObjectsTable *fTrigObjs = new TriggerObjectsTable(hltTable,fNMaxTriggers); |
280 |
+ |
|
281 |
|
|
282 |
|
TString fElectronName(Names::gkElectronBrn); |
283 |
|
TString fMuonName(Names::gkMuonBrn); |
284 |
|
TString fInfoName(Names::gkEvtHeaderBrn); |
285 |
+ |
TString fPFMetName("PFMet"); |
286 |
|
TString fPrimVtxName(Names::gkPVBrn); |
287 |
|
TString fPFCandidateName(Names::gkPFCandidatesBrn); |
288 |
|
TString fPileupInfoName(Names::gkPileupInfoBrn); |
292 |
|
TString fMCEvtInfoName(Names::gkMCEvtInfoBrn); |
293 |
|
TString fTriggerMaskName(Names::gkHltBitBrn); |
294 |
|
TString fTriggerTableName(Names::gkHltTableBrn); |
295 |
+ |
TString fTriggerLabelName(Names::gkHltLabelBrn); |
296 |
+ |
TString fTriggerObjectName(Names::gkHltObjBrn); |
297 |
+ |
TString fTriggerObjectRelsName(Form("HLTObjectsRelation")); |
298 |
+ |
|
299 |
+ |
// TString fHLTLabName(Names::gkHltLabelBrn); |
300 |
+ |
// TString fHLTTabName(Names::gkHltTableBrn); |
301 |
+ |
// TString fHLTTabNamePub(Form("%sFwk",fHLTTabName.Data())); |
302 |
+ |
// TString fHLTLabNamePub(Form("%sFwk",fHLTLabName.Data())); |
303 |
+ |
// TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data())); |
304 |
+ |
|
305 |
+ |
|
306 |
|
|
307 |
|
chain->SetBranchAddress(fInfoName, &info); |
308 |
+ |
chain->SetBranchAddress(fPFMetName, &metArr); |
309 |
|
chain->SetBranchAddress(fElectronName, &electronArr); |
310 |
|
chain->SetBranchAddress(fMuonName, &muonArr); |
311 |
|
chain->SetBranchAddress(fPrimVtxName, &vtxArr); |
318 |
|
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
319 |
|
chain->SetBranchAddress(fTrackName, &trkArr); |
320 |
|
chain->SetBranchAddress(fTriggerMaskName, &trigMask); |
321 |
+ |
chain->SetBranchAddress(fTriggerObjectName, &hltObjArr); |
322 |
+ |
chain->SetBranchAddress(fTriggerObjectRelsName, &hltRelsArr); |
323 |
+ |
// chain->SetBranchAddress(fHLTTabNamePub, &hltTab); |
324 |
+ |
// chain->SetBranchAddress(fHLTLabNamePub, &hltLab); |
325 |
+ |
|
326 |
|
cout << "hlttable: " << fTriggerTableName << endl; |
327 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
328 |
+ |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
329 |
|
|
330 |
|
mithep::Vertex vtx; // best primary vertex in the event |
331 |
|
|
340 |
|
|
341 |
|
// only 1 HLT table / file ??? |
342 |
|
hltchain->GetEntry(0); |
317 |
– |
cerr << "here... " << endl; |
343 |
|
|
344 |
|
int imax = chain->GetEntries(); |
345 |
|
cout << "nEntries: " << imax << endl; |
346 |
|
|
322 |
– |
|
347 |
|
// |
348 |
|
// Loop !!!!!!!!! |
349 |
|
//-------------------------------------------------------------------------------------------------------------- |
352 |
|
chain->GetEntry(ientry); |
353 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
354 |
|
|
355 |
< |
#ifdef HACKED_RHOS |
356 |
< |
float rho = evtrhoMap[info->EvtNum()]; |
357 |
< |
#endif |
358 |
< |
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
359 |
< |
setEra( fname, ctrl ); |
355 |
> |
if( ctrl.debug ) { |
356 |
> |
cout << "-----------------------------------------------------------------" << endl; |
357 |
> |
cout << "-----------------------------------------------------------------" << endl; |
358 |
> |
cout << "Run: " << info->RunNum() |
359 |
> |
<< "\tEvt: " << info->EvtNum() |
360 |
> |
<< "\tLumi: " << info->LumiSec() |
361 |
> |
<< endl; |
362 |
> |
cout << "-----------------------------------------------------------------" << endl; |
363 |
> |
} |
364 |
|
|
365 |
|
|
366 |
+ |
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
367 |
+ |
if(ctrl.debug) cout << "era is " << ctrl.era << endl; |
368 |
+ |
if( ctrl.era == 0 ) { |
369 |
+ |
setEra( fname, ctrl ); |
370 |
+ |
if(ctrl.debug) cout << "era is now " << ctrl.era << endl; |
371 |
+ |
} |
372 |
+ |
|
373 |
|
// |
374 |
|
// pfNoPU |
375 |
|
// |
393 |
|
// |
394 |
|
weights.w = getWeight(xstab,entrymap,chain)/ctrl.totalMC; |
395 |
|
cout << "xsec weight: " << weights.w << endl; |
396 |
< |
int npu = -1; |
397 |
< |
for(int i=0;i<puArr->GetEntries();i++) { |
398 |
< |
if(puArr->At(i)->GetBunchCrossing() == 0) |
399 |
< |
npu = puArr->At(i)->GetPU_NumInteractions(); |
400 |
< |
} |
401 |
< |
assert(npu>=0); |
367 |
< |
evtinfo.npu; |
368 |
< |
weights.npuw = getPUWeight(evtinfo.npu); |
369 |
< |
|
396 |
> |
|
397 |
> |
unsigned npu = getNPU(puArr, 0); |
398 |
> |
weights.npu = npu; |
399 |
> |
weights.npuw = getPUWeight(ctrl.era,npu); |
400 |
> |
cerr << "weights.npuw: " << weights.npuw << endl; |
401 |
> |
|
402 |
|
// |
403 |
|
// pt reweighting for Higgs < 140, F11 |
404 |
|
// |
416 |
|
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
417 |
|
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
418 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
419 |
+ |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
420 |
|
hltchain->GetEntry(0); |
421 |
|
hltTable->Clear(); |
422 |
|
fillTriggerNames(hltTable, hltTableStrings ); |
423 |
|
} |
424 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
425 |
< |
fillTriggerNames( hltTable, trigMask, triggerBits ); |
425 |
> |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
426 |
|
passes_HLT_MC = true; // passed to apply as extern global, just for sync |
427 |
|
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) { |
428 |
|
passes_HLT_MC = false; |
429 |
|
} |
430 |
+ |
|
431 |
+ |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs ); |
432 |
+ |
|
433 |
|
} else { |
434 |
|
// |
435 |
|
// JSON |
436 |
|
// |
437 |
< |
/* |
438 |
< |
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
439 |
< |
if( !(rlrm.HasRunLumi(rl)) ) { |
440 |
< |
if( ctrl.debug ) cout << "\tfails JSON" << endl; |
441 |
< |
continue; |
437 |
> |
if(!(ctrl.noJSON) ) { |
438 |
> |
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
439 |
> |
if( !(rlrm.HasRunLumi(rl)) ) { |
440 |
> |
if( ctrl.debug ) cout << "fails JSON" << endl; |
441 |
> |
continue; |
442 |
> |
} |
443 |
|
} |
444 |
< |
*/ |
444 |
> |
|
445 |
|
// |
446 |
|
// trigger |
447 |
|
// |
448 |
|
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
449 |
|
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
450 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
451 |
+ |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
452 |
|
hltchain->GetEntry(0); |
453 |
|
hltTable->Clear(); |
454 |
|
fillTriggerNames(hltTable, hltTableStrings ); |
455 |
|
} |
456 |
+ |
|
457 |
+ |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs ); |
458 |
+ |
|
459 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
460 |
|
/* |
461 |
< |
fillTriggerNames( hltTable, trigMask, triggerBits ); |
461 |
> |
fillTriggerBits( hltTable, trigMask, triggerBits ); |
462 |
|
if( !passHLT(triggerBits, info->RunNum(), info->EvtNum() ) ) { |
463 |
|
if( ctrl.debug ) cout << "\tfails trigger ... " << endl; |
464 |
|
continue; |
478 |
|
apply_HZZ4L_reference_selection(ctrl, info, |
479 |
|
vtxArr, |
480 |
|
pfArr, |
440 |
– |
#ifdef HACKED_RHOS |
441 |
– |
rho, |
442 |
– |
#else |
481 |
|
puDArr, |
444 |
– |
#endif |
482 |
|
electronArr, |
483 |
|
&electronReferencePreSelection, |
484 |
|
&electronReferenceIDMVASelectionV1, |
502 |
|
} |
503 |
|
|
504 |
|
#ifdef SYNC |
505 |
< |
cout << "bits: " << ret4l.status.selectionBits << "\t" |
506 |
< |
<< "Z1: " << Z1type << "\t" |
507 |
< |
<< "Z2: " << Z2type << endl; |
508 |
< |
cout << endl; |
505 |
> |
if(ctrl.debug) |
506 |
> |
cout << "bits: " << ret4l.status.selectionBits << "\t" |
507 |
> |
<< "Z1: " << Z1type << "\t" |
508 |
> |
<< "Z2: " << Z2type << endl << endl; |
509 |
|
#endif |
510 |
|
|
511 |
|
if( ret4l.status.pass() ) { |
512 |
|
fillAngles(ret4l,angles); |
513 |
|
fillKinematics(ret4l,kinematics); |
514 |
|
fillMassErrors(ret4l,muonArr,electronArr,kinematics); |
515 |
< |
fillEventInfo(info,evtinfo); |
515 |
> |
TLorentzVector pfmet; pfmet.SetPxPyPzE(metArr->At(0)->Mex(),metArr->At(0)->Mey(),0,0); |
516 |
> |
fillEventInfo( info, pfmet, evtinfo, ctrl.mc ? getNPU(puArr) : 0); |
517 |
|
if( ctrl.mc) { |
518 |
< |
setEffiencyWeights(ret4l, weights); |
519 |
< |
if(ctrl.debug) |
520 |
< |
cout << "w: " << weights.w << "\t" |
521 |
< |
<< "won: " << weights.won << "\t" |
522 |
< |
<< "woff: " << weights.woff << endl; |
518 |
> |
// if( std::string(ctrl.efftype) != std::string("WTF?")) { |
519 |
> |
setEffiencyWeights(ctrl.era, ret4l, weights); |
520 |
> |
// } else { |
521 |
> |
// weights.won = weights.woff = 1.; |
522 |
> |
// } |
523 |
> |
if(ctrl.debug) |
524 |
> |
cout << "w: " << weights.w << "\t" |
525 |
> |
<< "npuw: " << weights.npuw << "\t" |
526 |
> |
<< "won: " << weights.won << "\t" |
527 |
> |
<< "woff: " << weights.woff << endl; |
528 |
|
} |
529 |
|
|
530 |
|
|
534 |
|
<< "\trun: " << evtinfo.run |
535 |
|
<< "\tevt: " << evtinfo.evt |
536 |
|
<< "\tlumi: " << evtinfo.lumi |
537 |
< |
<< "\tcostheta1: " << angles.costheta1 |
538 |
< |
<< "\tcostheta2: " << angles.costheta2 |
539 |
< |
<< "\tcostheta*: " << angles.costhetastar |
540 |
< |
<< "\tbdt: " << angles.bdt |
537 |
> |
<< "\tchannel: " << kinematics.channel |
538 |
> |
<< "\tm4l: " << kinematics.m4l |
539 |
> |
<< "\tmZ1: " << kinematics.mZ1 |
540 |
> |
<< "\tmZ2: " << kinematics.mZ2 |
541 |
|
<< endl; |
542 |
|
pass++; |
543 |
|
// if( pass > 3 ) break; |
544 |
|
|
545 |
|
} else if( ret4l.status.selectionBits.test(PASS_GOODZ1) && |
546 |
< |
ret4l.status.selectionBits.to_ulong() < PASS_4L) { // save for fakes ... |
547 |
< |
// if(ctrl.debug) { |
546 |
> |
ret4l.status.selectionBits.to_ulong() < (1UL<<PASS_4L)) { // save for fakes ... |
547 |
> |
if(ctrl.debug) { |
548 |
|
cout << "failingLeptons : " << failingLeptons.size() << endl; |
549 |
|
for( int f=0; f<failingLeptons.size(); f++ ) { |
550 |
|
SimpleLepton l = failingLeptons[f]; |
553 |
|
<< "pT: " << l.vec.Pt() << "\t" |
554 |
|
<< "eta: " << l.vec.Eta() |
555 |
|
<< endl; |
556 |
< |
// } |
556 |
> |
} |
557 |
|
} |
558 |
|
foTree.Fill(); |
559 |
+ |
} else { |
560 |
+ |
if(ctrl.debug) |
561 |
+ |
cout << "failing with some other code : " << ret4l.status.selectionBits << endl; |
562 |
|
} |
563 |
|
} |
564 |
|
|
567 |
|
foTree.getTree()->Write(); |
568 |
|
nt.WriteClose(); |
569 |
|
|
570 |
< |
cout << endl; |
571 |
< |
cout << endl; |
570 |
> |
if(ctrl.debug) |
571 |
> |
cout << endl << endl; |
572 |
|
for( int i=0; i<cutvec.size(); i++ ) { |
573 |
|
cout << "cut: " << i << "\t" |
574 |
|
<< "pass: " << cutvec[i]; |
590 |
|
} |
591 |
|
|
592 |
|
|
547 |
– |
|
593 |
|
//---------------------------------------------------------------------------- |
594 |
< |
void setEffiencyWeights(EventData & evtdat, WeightStruct & weights ) |
550 |
< |
//---------------------------------------------------------------------------- |
551 |
< |
{ |
552 |
< |
vector<SimpleLepton> lepvec = evtdat.Z1leptons; |
553 |
< |
lepvec.insert(lepvec.end(), evtdat.Z2leptons.begin(), evtdat.Z2leptons.end()); |
554 |
< |
double w_offline=-1, werr_offline=0; |
555 |
< |
double w_online=-1, werr_online=0; |
556 |
< |
|
557 |
< |
vector< pair <double,double> > wlegs; // pair here is eff & err |
558 |
< |
vector< pair <float,float> > mvec; // pair here is eta & pt |
559 |
< |
|
560 |
< |
// vector< pair <float,float> > evec; // pair here is eta & pt |
561 |
< |
// now deal with medium vs loose |
562 |
< |
vector< pair< bool, pair <float,float> > > evec; // pair here is eta & pt |
563 |
< |
|
564 |
< |
for( int k=0; k<lepvec.size(); k++ ) { |
565 |
< |
if( abs(lepvec[k].type) == 13 ) { |
566 |
< |
mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) ); |
567 |
< |
wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
568 |
< |
lepvec[k].vec.Pt() ) ); |
569 |
< |
} else { |
570 |
< |
|
571 |
< |
// now deal with medium vs loose |
572 |
< |
// evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) ); |
573 |
< |
|
574 |
< |
std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()); |
575 |
< |
evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) ); |
576 |
< |
|
577 |
< |
// wlegs.push_back( elePerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
578 |
< |
// lepvec[k].vec.Pt() ) ); |
579 |
< |
|
580 |
< |
wlegs.push_back( elePerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
581 |
< |
lepvec[k].vec.Pt(), |
582 |
< |
lepvec[k].isTight ) ); |
583 |
< |
|
584 |
< |
} |
585 |
< |
} |
586 |
< |
|
587 |
< |
pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs ); |
588 |
< |
weights.woff = offpair.first; |
589 |
< |
weights.werroff = offpair.second; |
590 |
< |
|
591 |
< |
pair<double,double> onpair = getOnlineEfficiencyWeight( mvec, evec ); |
592 |
< |
weights.won = onpair.first; |
593 |
< |
weights.werron = onpair.second; |
594 |
< |
} |
595 |
< |
|
596 |
< |
|
597 |
< |
//---------------------------------------------------------------------------- |
598 |
< |
void initRunLumiRangeMap() |
594 |
> |
void initRunLumiRangeMap(ControlFlags &ctrl) |
595 |
|
//---------------------------------------------------------------------------- |
596 |
|
{ |
597 |
|
/* |
603 |
|
// r11b |
604 |
|
rlrm.AddJSONFile(std::string("./data/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt")); |
605 |
|
*/ |
610 |
– |
}; |
611 |
– |
|
612 |
– |
|
613 |
– |
//---------------------------------------------------------------------------- |
614 |
– |
void initPUWeights() |
615 |
– |
//---------------------------------------------------------------------------- |
616 |
– |
{ |
617 |
– |
TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Full2011.root"); |
618 |
– |
hpu = (TH1D*)(puf->Get("puWeights")); |
619 |
– |
} |
620 |
– |
|
621 |
– |
//---------------------------------------------------------------------------- |
622 |
– |
double getPUWeight(unsigned npu) |
623 |
– |
//---------------------------------------------------------------------------- |
624 |
– |
{ |
625 |
– |
return hpu->GetBinContent(hpu->FindBin(npu)); |
626 |
– |
} |
606 |
|
|
607 |
< |
//---------------------------------------------------------------------------- |
608 |
< |
void initEvtRhoMap( map<unsigned, float> & evtrhoMap ) |
609 |
< |
//---------------------------------------------------------------------------- |
610 |
< |
{ |
611 |
< |
unsigned evt; |
612 |
< |
float rho; |
613 |
< |
|
614 |
< |
cout << "initialzing EvtRhoMap "; |
636 |
< |
//FILE * f = fopen("evtrho.dat", "r"); |
637 |
< |
// FILE * f = fopen("allrho.cali.uniq.dat", "r"); |
638 |
< |
FILE * f = fopen("/data/blue/khahn/CMSSW_4_4_2/src/MitHzz4l/allrhoAA.cali.uniq.dat", "r"); |
639 |
< |
int lcount=0; |
640 |
< |
while( fscanf( f, "%u:%f", &evt, &rho ) ) { |
641 |
< |
if( feof(f) ) break; |
642 |
< |
evtrhoMap[evt] = rho; |
643 |
< |
lcount++; |
644 |
< |
if( !(lcount%1000) ) cout << "."; flush(cout); |
645 |
< |
} |
646 |
< |
cout << " done" << endl; |
647 |
< |
} |
648 |
< |
|
649 |
< |
//---------------------------------------------------------------------------- |
650 |
< |
unsigned makePFnoPUArray(mithep::Array<PFCandidate> * fPFCandidates, |
651 |
< |
vector<bool> &pfNoPileUpflag, |
652 |
< |
const mithep::Array<mithep::Vertex> * vtxArr ) |
653 |
< |
//---------------------------------------------------------------------------- |
654 |
< |
{ |
655 |
< |
for(UInt_t i = 0; i < fPFCandidates->GetEntries(); i++) { |
656 |
< |
const PFCandidate *pf = fPFCandidates->At(i); |
657 |
< |
assert(pf); |
658 |
< |
|
659 |
< |
if(pf->PFType() == PFCandidate::eHadron) { |
660 |
< |
if(pf->HasTrackerTrk() && |
661 |
< |
vtxArr->At(0)->HasTrack(pf->TrackerTrk()) && |
662 |
< |
vtxArr->At(0)->TrackWeight(pf->TrackerTrk()) > 0) { |
663 |
< |
|
664 |
< |
pfNoPileUpflag.push_back(1); |
665 |
< |
|
666 |
< |
} else { |
667 |
< |
|
668 |
< |
Bool_t vertexFound = kFALSE; |
669 |
< |
const Vertex *closestVtx = 0; |
670 |
< |
Double_t dzmin = 10000; |
671 |
< |
|
672 |
< |
// loop over vertices |
673 |
< |
for(UInt_t j = 0; j < vtxArr->GetEntries(); j++) { |
674 |
< |
const Vertex *vtx = vtxArr->At(j); |
675 |
< |
assert(vtx); |
676 |
< |
|
677 |
< |
if(pf->HasTrackerTrk() && |
678 |
< |
vtx->HasTrack(pf->TrackerTrk()) && |
679 |
< |
vtx->TrackWeight(pf->TrackerTrk()) > 0) { |
680 |
< |
vertexFound = kTRUE; |
681 |
< |
closestVtx = vtx; |
682 |
< |
break; |
683 |
< |
} |
684 |
< |
Double_t dz = fabs(pf->SourceVertex().Z() - vtx->Z()); |
685 |
< |
if(dz < dzmin) { |
686 |
< |
closestVtx = vtx; |
687 |
< |
dzmin = dz; |
688 |
< |
} |
689 |
< |
} |
690 |
< |
|
691 |
< |
// if(fCheckClosestZVertex) { |
692 |
< |
if(1) { |
693 |
< |
// Fallback: if track is not associated with any vertex, |
694 |
< |
// associate it with the vertex closest in z |
695 |
< |
if(vertexFound || closestVtx != vtxArr->At(0)) { |
696 |
< |
// pfPileUp->Add(pf); |
697 |
< |
pfNoPileUpflag.push_back(0); |
698 |
< |
} else { |
699 |
< |
pfNoPileUpflag.push_back(1); |
700 |
< |
} |
701 |
< |
} else { |
702 |
< |
if(vertexFound && closestVtx != vtxArr->At(0)) { |
703 |
< |
// pfPileUp->Add(pf); |
704 |
< |
pfNoPileUpflag.push_back(0); |
705 |
< |
} else { |
706 |
< |
// PFCandidate * pfNoPileUp->AddNew(); // Ridiculous but that's how it is |
707 |
< |
pfNoPileUpflag.push_back(1); |
708 |
< |
} |
709 |
< |
} |
710 |
< |
} //hadron & trk stuff |
711 |
< |
} else { // hadron |
712 |
< |
// PFCandidate * ptr = pfNoPileUp->AddNew(); |
713 |
< |
pfNoPileUpflag.push_back(1); |
714 |
< |
} |
715 |
< |
} // Loop over PF candidates |
716 |
< |
|
717 |
< |
return pfNoPileUpflag.size(); |
718 |
< |
} |
719 |
< |
|
720 |
< |
void setEra(string fname, ControlFlags &ctrl) |
721 |
< |
{ |
722 |
< |
if( ctrl.mc && (fname.find("f11-") != string::npos) ) ctrl.era=2011 ; |
723 |
< |
if( ctrl.mc && (fname.find("s12-") != string::npos) ) ctrl.era=2012 ; |
724 |
< |
if( !ctrl.mc && (fname.find("r11-") != string::npos) ) ctrl.era=2011 ; |
725 |
< |
if( !ctrl.mc && (fname.find("r12-") != string::npos) ) ctrl.era=2012 ; |
726 |
< |
} |
607 |
> |
// 2012 only for now ... |
608 |
> |
std::string jsonFile; |
609 |
> |
if(ctrl.jsonFile=="") |
610 |
> |
jsonFile = "./data/Cert_190456-194479_8TeV_PromptReco_Collisions12_JSON.txt"; |
611 |
> |
else |
612 |
> |
jsonFile = ctrl.jsonFile; |
613 |
> |
rlrm.AddJSONFile(jsonFile); |
614 |
> |
}; |