40 |
|
#include "MCParticle.h" |
41 |
|
#include "TriggerMask.h" |
42 |
|
#include "TriggerTable.h" |
43 |
+ |
#include "TriggerObject.h" |
44 |
+ |
#include "TriggerObjectRel.h" |
45 |
|
#include "Names.h" |
46 |
|
#include "BaseMod.h" |
47 |
< |
|
47 |
> |
#include "MitAna/TreeMod/interface/HLTFwkMod.h" |
48 |
|
// |
49 |
|
// our headers |
50 |
|
// |
98 |
|
void initPUWeights(); |
99 |
|
double getPUWeight(unsigned npu); |
100 |
|
void initRunLumiRangeMap(); |
101 |
+ |
void setHLTObjectRelations( mithep::Array<mithep::TriggerObject> *hltObjArr, |
102 |
+ |
mithep::Array<mithep::TriggerObjectRel> *hltRelsArr, |
103 |
+ |
vector<string> * fHLTTab, |
104 |
+ |
vector<string> * fHLTLab ) |
105 |
+ |
{ |
106 |
+ |
|
107 |
+ |
const int n = hltRelsArr->GetEntries(); |
108 |
+ |
for (int i=0; i<n; ++i) { |
109 |
+ |
const TriggerObjectRel *rel = hltRelsArr->At(i); |
110 |
+ |
if (!rel) continue; |
111 |
+ |
|
112 |
+ |
const TriggerObjectBase *ob = hltObjArr->At(rel->ObjInd()); |
113 |
+ |
if (!ob) continue; |
114 |
+ |
|
115 |
+ |
hltObjArr->At(rel->ObjInd())->SetTrigName(fHLTTab->at(rel->TrgId()).c_str()); |
116 |
+ |
hltObjArr->At(rel->ObjInd())->SetModuleName(fHLTLab->at(rel->ModInd()).c_str()); |
117 |
+ |
hltObjArr->At(rel->ObjInd())->SetFilterName(fHLTLab->at(rel->FilterInd()).c_str()); |
118 |
+ |
if (hltObjArr->At(rel->ObjInd())->TagInd()>=0) |
119 |
+ |
hltObjArr->At(rel->ObjInd())->SetTagName(fHLTLab->at(hltObjArr->At(rel->ObjInd())->TagInd()).c_str()); |
120 |
+ |
else |
121 |
+ |
hltObjArr->At(rel->ObjInd())->SetTagName("Unknown"); |
122 |
+ |
} |
123 |
+ |
}; |
124 |
+ |
|
125 |
|
//---------------------------------------------------------------------------- |
126 |
|
|
127 |
|
|
247 |
|
if(ctrl.mc) { |
248 |
|
nt.makeWeightBranch(weights); |
249 |
|
if(ctrl.fillGen ) nt.makeGenInfoBranch(geninfo); |
250 |
< |
initEfficiencyWeights(); |
250 |
> |
if(ctrl.efftype != string("WTF?")) initEfficiencyWeights(); |
251 |
|
initPUWeights(); |
252 |
|
|
253 |
|
// Higgs only, pt reweighting |
289 |
|
mithep::TriggerMask *trigMask = new mithep::TriggerMask(); |
290 |
|
mithep::TriggerTable *hltTable = new mithep::TriggerTable(); |
291 |
|
vector<string> *hltTableStrings = new vector<string>(); |
292 |
+ |
vector<string> *hltLabelStrings = new vector<string>(); |
293 |
+ |
mithep::Array<mithep::TriggerObject> *hltObjArr = new mithep::Array<mithep::TriggerObject>(); |
294 |
+ |
mithep::Array<mithep::TriggerObjectRel> *hltRelsArr = new mithep::Array<mithep::TriggerObjectRel>(); |
295 |
+ |
std::vector<std::string> *hltTab = new vector<string>(); |
296 |
+ |
std::vector<std::string> *hltLab = new vector<string>(); |
297 |
+ |
|
298 |
|
|
299 |
|
TString fElectronName(Names::gkElectronBrn); |
300 |
|
TString fMuonName(Names::gkMuonBrn); |
308 |
|
TString fMCEvtInfoName(Names::gkMCEvtInfoBrn); |
309 |
|
TString fTriggerMaskName(Names::gkHltBitBrn); |
310 |
|
TString fTriggerTableName(Names::gkHltTableBrn); |
311 |
< |
|
311 |
> |
TString fTriggerLabelName(Names::gkHltLabelBrn); |
312 |
> |
TString fTriggerObjectName(Names::gkHltObjBrn); |
313 |
> |
TString fTriggerObjectRelsName(Form("HLTObjectsRelation")); |
314 |
> |
|
315 |
> |
TString fHLTLabName(Names::gkHltLabelBrn); |
316 |
> |
TString fHLTTabName(Names::gkHltTableBrn); |
317 |
> |
TString fHLTTabNamePub(Form("%sFwk",fHLTTabName.Data())); |
318 |
> |
TString fHLTLabNamePub(Form("%sFwk",fHLTLabName.Data())); |
319 |
> |
TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data())); |
320 |
> |
|
321 |
> |
|
322 |
> |
|
323 |
|
chain->SetBranchAddress(fInfoName, &info); |
324 |
|
chain->SetBranchAddress(fElectronName, &electronArr); |
325 |
|
chain->SetBranchAddress(fMuonName, &muonArr); |
333 |
|
chain->SetBranchAddress(fPileupEnergyDensityName, &puDArr); |
334 |
|
chain->SetBranchAddress(fTrackName, &trkArr); |
335 |
|
chain->SetBranchAddress(fTriggerMaskName, &trigMask); |
336 |
+ |
chain->SetBranchAddress(fTriggerObjectName, &hltObjArr); |
337 |
+ |
chain->SetBranchAddress(fTriggerObjectRelsName, &hltRelsArr); |
338 |
+ |
chain->SetBranchAddress(fHLTTabNamePub, &hltTab); |
339 |
+ |
chain->SetBranchAddress(fHLTLabNamePub, &hltLab); |
340 |
+ |
|
341 |
|
cout << "hlttable: " << fTriggerTableName << endl; |
342 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
343 |
+ |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
344 |
|
|
345 |
|
mithep::Vertex vtx; // best primary vertex in the event |
346 |
|
|
360 |
|
int imax = chain->GetEntries(); |
361 |
|
cout << "nEntries: " << imax << endl; |
362 |
|
|
363 |
+ |
HLTFwkMod stupid; |
364 |
|
|
365 |
|
// |
366 |
|
// Loop !!!!!!!!! |
369 |
|
{ |
370 |
|
chain->GetEntry(ientry); |
371 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
372 |
+ |
|
373 |
+ |
if( ctrl.debug ) { |
374 |
+ |
cout << "-----------------------------------------------------------------" << endl; |
375 |
+ |
cout << "-----------------------------------------------------------------" << endl; |
376 |
+ |
cout << "Run: " << info->RunNum() |
377 |
+ |
<< "\tEvt: " << info->EvtNum() |
378 |
+ |
<< "\tLumi: " << info->LumiSec() |
379 |
+ |
<< endl; |
380 |
+ |
cout << "-----------------------------------------------------------------" << endl; |
381 |
+ |
} |
382 |
+ |
|
383 |
|
|
384 |
|
string fname = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
385 |
|
setEra( fname, ctrl ); |
386 |
|
|
387 |
|
|
388 |
+ |
|
389 |
|
// |
390 |
|
// pfNoPU |
391 |
|
// |
435 |
|
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
436 |
|
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
437 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
438 |
+ |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
439 |
|
hltchain->GetEntry(0); |
440 |
|
hltTable->Clear(); |
441 |
|
fillTriggerNames(hltTable, hltTableStrings ); |
446 |
|
if( !passHLTMC(triggerBits, info->RunNum(), info->EvtNum(), k2012_MC ) ) { |
447 |
|
passes_HLT_MC = false; |
448 |
|
} |
449 |
+ |
|
450 |
+ |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings ); |
451 |
+ |
for( int i=0; i<hltObjArr->GetEntries(); i++ ) { |
452 |
+ |
const mithep::TriggerObject *to = (*hltObjArr)[i]; |
453 |
+ |
to->Print(); |
454 |
+ |
} |
455 |
+ |
|
456 |
+ |
|
457 |
|
} else { |
458 |
|
// |
459 |
|
// JSON |
461 |
|
if(!(ctrl.noJSON) ) { |
462 |
|
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
463 |
|
if( !(rlrm.HasRunLumi(rl)) ) { |
464 |
< |
if( ctrl.debug ) cout << "\tfails JSON" << endl; |
464 |
> |
if( ctrl.debug ) cout << "fails JSON" << endl; |
465 |
|
continue; |
466 |
|
} |
467 |
|
} |
472 |
|
if( string(chain->GetFile()->GetEndpointUrl()->GetFile()) != currentFile ) { |
473 |
|
currentFile = string(chain->GetFile()->GetEndpointUrl()->GetFile()); |
474 |
|
hltchain->SetBranchAddress(fTriggerTableName, &hltTableStrings); |
475 |
+ |
hltchain->SetBranchAddress(fTriggerLabelName, &hltLabelStrings); |
476 |
|
hltchain->GetEntry(0); |
477 |
|
hltTable->Clear(); |
478 |
|
fillTriggerNames(hltTable, hltTableStrings ); |
479 |
|
} |
480 |
+ |
|
481 |
+ |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings ); |
482 |
+ |
for( int i=0; i<hltObjArr->GetEntries(); i++ ) { |
483 |
+ |
const mithep::TriggerObject *to = (*hltObjArr)[i]; |
484 |
+ |
to->Print(); |
485 |
+ |
} |
486 |
+ |
|
487 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
488 |
|
/* |
489 |
|
fillTriggerBits( hltTable, trigMask, triggerBits ); |
542 |
|
fillMassErrors(ret4l,muonArr,electronArr,kinematics); |
543 |
|
fillEventInfo(info,evtinfo); |
544 |
|
if( ctrl.mc) { |
545 |
+ |
if( std::string(ctrl.efftype) != std::string("WTF?")) { |
546 |
|
setEffiencyWeights(ret4l, weights); |
547 |
+ |
} else { |
548 |
+ |
weights.won = weights.woff = 1.; |
549 |
+ |
} |
550 |
|
if(ctrl.debug) |
551 |
|
cout << "w: " << weights.w << "\t" |
552 |
|
<< "won: " << weights.won << "\t" |