44 |
|
#include "TriggerObjectRel.h" |
45 |
|
#include "Names.h" |
46 |
|
#include "BaseMod.h" |
47 |
+ |
#include "TriggerObjectsTable.h" |
48 |
|
|
49 |
|
// |
50 |
|
// our headers |
99 |
|
void initPUWeights(); |
100 |
|
double getPUWeight(unsigned npu); |
101 |
|
void initRunLumiRangeMap(); |
101 |
– |
void setHLTObjectRelations( mithep::Array<mithep::TriggerObject> *hltObjArr, |
102 |
– |
mithep::Array<mithep::TriggerObjectRel> *hltRelsArr, |
103 |
– |
vector<string> * fHLTTab, |
104 |
– |
vector<string> * fHLTLab ); |
102 |
|
//---------------------------------------------------------------------------- |
103 |
|
|
104 |
|
|
169 |
|
TChain * hltchain = new TChain("HLT"); |
170 |
|
|
171 |
|
string fname; |
172 |
+ |
unsigned total_unskimmed=0; |
173 |
|
if( !ctrl.inputfiles.empty() ) { |
174 |
|
ifstream f(ctrl.inputfiles.c_str()); |
175 |
|
while (f >> fname) { |
177 |
|
cout << "adding inputfile : " << fname.c_str() << endl; |
178 |
|
entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str()); |
179 |
|
cout << "unskimmed entries: " << entrymap[string(fname.c_str())] << endl; |
180 |
+ |
total_unskimmed += entrymap[string(fname.c_str())]; |
181 |
|
chain->AddFile(fname.c_str()); |
182 |
|
hltchain->AddFile(fname.c_str()); |
183 |
|
} |
184 |
|
} else { |
185 |
|
cout << "adding inputfile : " << ctrl.inputfile.c_str() << endl; |
186 |
< |
unsigned tmpent = unskimmedEntries(ctrl.inputfile.c_str()); |
187 |
< |
cout << "tmpent: " << tmpent << endl; |
188 |
< |
entrymap[string(ctrl.inputfile.c_str())] = unskimmedEntries(ctrl.inputfile.c_str()); |
189 |
< |
cout << "unskimmed entries: " << entrymap[string(ctrl.inputfile.c_str())] << endl; |
186 |
> |
unsigned unsk_ents = unskimmedEntries(ctrl.inputfile.c_str()); |
187 |
> |
entrymap[string(ctrl.inputfile.c_str())] = unsk_ents; |
188 |
> |
cout << "unskimmed entries: " << unsk_ents << endl; |
189 |
> |
total_unskimmed += unsk_ents; |
190 |
|
chain->AddFile(ctrl.inputfile.c_str()); |
191 |
|
hltchain->AddFile(ctrl.inputfile.c_str()); |
192 |
|
} |
193 |
+ |
// // write the total number of unskimmed events that went into making this output file to a text file |
194 |
+ |
// writeEntries(ctrl,total_unskimmed); |
195 |
|
|
196 |
|
const char * ofname; |
197 |
|
if( strcmp( ctrl.outputfile.c_str(), "") ) { |
205 |
|
SimpleTable xstab(xspath.c_str()); |
206 |
|
|
207 |
|
|
208 |
+ |
|
209 |
|
// |
210 |
|
// Setup |
211 |
|
//-------------------------------------------------------------------------------------------------------------- |
250 |
|
initElectronIDMVAV1(); |
251 |
|
initTrigger(); |
252 |
|
|
251 |
– |
|
253 |
|
// |
254 |
|
// Setup tree I/O |
255 |
|
//-------------------------------------------------------------------------------------------------------------- |
257 |
|
TTree *eventTree=0; |
258 |
|
string currentFile(""); |
259 |
|
|
260 |
+ |
UInt_t fNMaxTriggers = 1024; |
261 |
|
mithep::EventHeader *info = new mithep::EventHeader(); |
262 |
|
mithep::Array<mithep::Electron> *electronArr = new mithep::Array<mithep::Electron>(); |
263 |
|
mithep::Array<mithep::Muon> *muonArr = new mithep::Array<mithep::Muon>(); |
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>(); |
278 |
> |
std::vector<std::string> *hltLab = new vector<string>(); |
279 |
> |
TriggerObjectsTable *fTrigObjs = new TriggerObjectsTable(hltTable,fNMaxTriggers); |
280 |
|
|
281 |
|
|
282 |
|
TString fElectronName(Names::gkElectronBrn); |
302 |
|
// TString fObjsNamePub(Form("%sFwk",fTriggerObjectName.Data())); |
303 |
|
|
304 |
|
|
305 |
< |
|
305 |
> |
|
306 |
|
chain->SetBranchAddress(fInfoName, &info); |
307 |
|
chain->SetBranchAddress(fElectronName, &electronArr); |
308 |
|
chain->SetBranchAddress(fMuonName, &muonArr); |
350 |
|
{ |
351 |
|
chain->GetEntry(ientry); |
352 |
|
if(!(ientry%1000)) cerr << "entry: " << ientry << endl; |
353 |
< |
|
353 |
> |
|
354 |
|
if( ctrl.debug ) { |
355 |
|
cout << "-----------------------------------------------------------------" << endl; |
356 |
|
cout << "-----------------------------------------------------------------" << endl; |
428 |
|
passes_HLT_MC = false; |
429 |
|
} |
430 |
|
|
431 |
< |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings ); |
429 |
< |
for( int i=0; i<hltObjArr->GetEntries(); i++ ) { |
430 |
< |
const mithep::TriggerObject *to = (*hltObjArr)[i]; |
431 |
< |
to->Print(); |
432 |
< |
} |
433 |
< |
|
431 |
> |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs ); |
432 |
|
|
433 |
|
} else { |
434 |
|
// |
441 |
|
continue; |
442 |
|
} |
443 |
|
} |
444 |
< |
|
444 |
> |
|
445 |
|
// |
446 |
|
// trigger |
447 |
|
// |
454 |
|
fillTriggerNames(hltTable, hltTableStrings ); |
455 |
|
} |
456 |
|
|
457 |
< |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings ); |
458 |
< |
for( int i=0; i<hltObjArr->GetEntries(); i++ ) { |
461 |
< |
const mithep::TriggerObject *to = (*hltObjArr)[i]; |
462 |
< |
to->Print(); |
463 |
< |
} |
457 |
> |
setHLTObjectRelations( hltObjArr, hltRelsArr, hltTableStrings, hltLabelStrings, fTrigObjs ); |
458 |
> |
printTriggerObjs( hltTable, fTrigObjs ); |
459 |
|
|
460 |
|
if( ctrl.debug ) cout << "file is : " << currentFile << endl; |
461 |
|
/* |
516 |
|
fillEventInfo(info,evtinfo); |
517 |
|
if( ctrl.mc) { |
518 |
|
if( std::string(ctrl.efftype) != std::string("WTF?")) { |
519 |
< |
setEffiencyWeights(ret4l, weights); |
519 |
> |
setEffiencyWeights(ret4l, weights); |
520 |
|
} else { |
521 |
|
weights.won = weights.woff = 1.; |
522 |
|
} |
523 |
< |
if(ctrl.debug) |
524 |
< |
cout << "w: " << weights.w << "\t" |
525 |
< |
<< "won: " << weights.won << "\t" |
526 |
< |
<< "woff: " << weights.woff << endl; |
523 |
> |
if(ctrl.debug) |
524 |
> |
cout << "w: " << weights.w << "\t" |
525 |
> |
<< "won: " << weights.won << "\t" |
526 |
> |
<< "woff: " << weights.woff << endl; |
527 |
|
} |
528 |
|
|
529 |
|
|
622 |
|
{ |
623 |
|
return hpu->GetBinContent(hpu->FindBin(npu)); |
624 |
|
} |
630 |
– |
|
631 |
– |
//---------------------------------------------------------------------------- |
632 |
– |
void setHLTObjectRelations( mithep::Array<mithep::TriggerObject> *hltObjArr, |
633 |
– |
mithep::Array<mithep::TriggerObjectRel> *hltRelsArr, |
634 |
– |
vector<string> * fHLTTab, |
635 |
– |
vector<string> * fHLTLab ) |
636 |
– |
//---------------------------------------------------------------------------- |
637 |
– |
{ |
638 |
– |
|
639 |
– |
const int n = hltRelsArr->GetEntries(); |
640 |
– |
for (int i=0; i<n; ++i) { |
641 |
– |
const TriggerObjectRel *rel = hltRelsArr->At(i); |
642 |
– |
if (!rel) continue; |
643 |
– |
|
644 |
– |
// const TriggerObjectBase *ob = hltObjArr->At(rel->ObjInd()); |
645 |
– |
// if (!ob) continue; |
646 |
– |
|
647 |
– |
hltObjArr->At(rel->ObjInd())->SetTrigName(fHLTTab->at(rel->TrgId()).c_str()); |
648 |
– |
hltObjArr->At(rel->ObjInd())->SetModuleName(fHLTLab->at(rel->ModInd()).c_str()); |
649 |
– |
hltObjArr->At(rel->ObjInd())->SetFilterName(fHLTLab->at(rel->FilterInd()).c_str()); |
650 |
– |
if (hltObjArr->At(rel->ObjInd())->TagInd()>=0) |
651 |
– |
hltObjArr->At(rel->ObjInd())->SetTagName(fHLTLab->at(hltObjArr->At(rel->ObjInd())->TagInd()).c_str()); |
652 |
– |
else |
653 |
– |
hltObjArr->At(rel->ObjInd())->SetTagName("Unknown"); |
654 |
– |
} |
655 |
– |
}; |