42 {
43
45
46
49
50
51
52
55
56
62 }
63
66
67
70
71
75 }
76
77
78
79
80
82 if (scalel1trigrate != 1.) {
84 }
85
86
88 if (online) {
90 }
91
92
94 if (online) {
96 } else {
98 }
99
100
103 if (uselar) {
104 logger <<
Root::kINFO <<
"LAr noise burst inefficiency will be calculated from " << lartag << Root::GEndl;
105 }
106
107
110 if (usebeamspot) {
112 }
113
114
115
116
117 std::string lumimethod;
118 int lumichannel = -1;
119
120
122 logger <<
Root::kERROR <<
"Sorry, the online database doesn't have luminosity method names, use --lumichannel instead!" << Root::GEndl;
124 }
125
134 logger <<
Root::kINFO <<
"Both lumimethod and lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
136 if (online) {
138 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
139 } else {
141 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumimethod: " << lumimethod << Root::GEndl;
142 }
143 }
144
145
146
147
149 logger <<
Root::kINFO <<
"No trigger specified, proceeding with --trigger=None" << Root::GEndl;
151 } else {
154 } else {
156 }
157
161 }
163 }
164
165
166
167 bool uselivetrigger = false;
169
171
172 uselivetrigger = true;
174 } else {
175
176 logger <<
Root::kINFO <<
"Prescale trigger chains will be used for livetime " << Root::GEndl;
177 }
178
179
180
181
182
183
184 std::list<std::pair<unsigned int, unsigned int> > runList;
185 runList.clear();
186
187
189
190
192
194
196 if (found != std::string::npos) {
198 val2 =
atoi(
full.substr(found+1, std::string::npos).c_str());
199 } else {
202 }
205
206
207 runList.push_back( std::pair<unsigned int, unsigned int>(val1, val2) );
208 }
209
210
211
212
213
214
215
216
217
218 unsigned int runtype = 0;
219
220
221
223 runtype = 1;
224 std::cout << args_info.
tag_given <<
" TAG file(s) is given..." << std::endl;
225 for(
unsigned int i = 0;
i < args_info.
tag_given; ++
i){
227 }
228
229 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
231 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
232 }
233 }
234
235
236 }
237
238
239
241 runtype = 3;
242 for(
unsigned int i = 0;
i < args_info.
xml_given; ++
i){
244 }
245
246 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
248 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
249 }
250 }
251
252 }
253
254
255
258 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --tree=\"mytreename\" OR --d3pd_dir=\"mydirname\" options " << Root::GEndl;
260 }
261
262 runtype = 4;
265 }
268 }else{
269 logger <<
Root::kERROR <<
"In Root file mode Tree name (--d3p_dir=\"mytreename\") must also be provided" << Root::GEndl;
270 }
271 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
273 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
274 }
275 }
276 }
277
278
279
282 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --d3pd_dir=\"myd3pddirname\" options" << Root::GEndl;
284 }
285
286 runtype = 5;
289 }
292 }else{
293 logger <<
Root::kWARNING <<
"In D3PD Root file mode Directory name (--d3pd_dir=\"mylumidir\") must also be provided" << Root::GEndl;
296 }
297
298 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
300 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
301 }
302 }
303 }
304
305
306
307 if (runtype == 0) {
308
309
313 }
314
315 std::list<std::pair<unsigned int, unsigned int> >
::iterator itr = runList.begin();
316
317
318 for (; itr != runList.end(); ++itr) {
319
321 logger <<
Root::kERROR <<
"Can't use open-ended run ranges to specify sample!" << Root::GEndl;
323 }
324
325 for (unsigned int runnum = itr->first; runnum <= itr->second; runnum++)
327
328 }
329
330
334 }
335 } else {
338 }
339 }
340
344 }
345 } else {
348 }
349 }
350
351 }
352
353
354
355
357
358
359
360
361 std::vector< xAOD::LumiBlockRangeContainer* > iovcVec;
362 std::vector< std::vector<std::string> > triggerchainVec;
366
367
368
369 if (runtype == 0) {
370
373 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match!" << Root::GEndl;
375 }
376
378 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match number of runs with multiple runs specified!" << Root::GEndl;
380 }
381
382
383
384
385
386
387
388
391
394 iovc->setStore( iovcAux );
395
396 std::vector<uint32_t>::iterator itstart;
397 std::vector<uint32_t>::iterator itend;
398 std::vector<uint32_t>::iterator itrun;
399
401
404 itstart !=
lbstart.end() && itend !=
lbend.end(); ++itstart,++itend) {
405 lbstart_val = (*itstart);
406 lbend_val = (*itend);
407 logger <<
Root::kINFO <<
"lbstart-lbend [" << lbstart_val <<
"-" << lbend_val <<
"]" << Root::GEndl;
408 if (lbstart_val > lbend_val) {
409 logger <<
Root::kERROR <<
"lbstart > lbend! Should be: lbstart < = lbend" << Root::GEndl;
411 } else {
418 }
419 }
420
422
425 ++itrun, ++itstart, ++itend) {
427 logger <<
Root::kINFO <<
"lbstart-lbend [" << *itstart <<
"-" << *itend <<
"]" << Root::GEndl;
434 }
435 }
436
437 iovcVec.push_back(iovc);
441 metadata[Form(
"TriggerName%d",j)] = TString(
triggerchain[j]);
442 grlcollection.push_back( *converter.
GetGRLObject(*iovc,metadata,version) );
443 }
444
445
446
447
448 if (runtype == 1) {
449
451
453
455 grlcollection =
reader.GetMergedGRLCollection();
456
457 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
459
460 if ( grlcollection[j].HasTriggerInfo() ) {
461 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
464 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
465 } else {
468 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
469 }
470 }
471 }
472
473
474
475 if(runtype == 3){
476
479
480 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
483 }
485 grlcollection =
reader.GetMergedGRLCollection();
486
487 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
489
490 if ( grlcollection[j].HasTriggerInfo() ) {
491 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
494 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
495 } else {
498 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
499 }
500 }
501 }
502
503
504
505
506 if(runtype == 4){
507
509
511
512 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
513 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
517 TList * list = NULL;
522 }else{
523 list =
tree->GetUserInfo() ;
524
525
526 for(
int j=0;
j<list->GetEntries();++
j) {
527 TObjString* objstr = dynamic_cast<TObjString*>(list->At(j));
528 if (objstr==0) continue;
529 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
530 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") )
531 reader.AddXMLString(objstr->GetString());
532 }
533 }
535 }
536
537
539 grlcollection =
reader.GetMergedGRLCollection();
540
541 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
543
544 if ( grlcollection[j].HasTriggerInfo() ) {
545 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
548 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
549 } else {
552 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
553 }
554 }
555 }
556
557
558
559 if(runtype == 5){
560
561 logger <<
Root::kINFO <<
"Being in ROOT D3PD ntuple file mode..." << Root::GEndl;
562
564
565 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
566 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
568 TList* list = NULL;
570 TDirectoryFile *
dir = NULL;
573 if(!dir){
574
577 }else{
578 TObjString* objstr = 0;
579 std::map<TString,int> keymap;
580 list =
dir->GetListOfKeys();
581
582 for(
int j=0;
j<list->GetEntries();
j++) {
583 if ( keymap.find(list->At(j)->GetName())==keymap.end() ) { keymap[list->At(j)->GetName()] = 1; }
584 else { keymap[list->At(j)->GetName()] = keymap[list->At(j)->GetName()]+1; }
585 if(
verbose)
logger <<
Root::kINFO <<
"Found obj key: \"" << Form(
"%s;%d",list->At(j)->GetName(),keymap[list->At(j)->GetName()]) <<
"\"" << Root::GEndl;
586 objstr =
dynamic_cast<TObjString*
>(
dir->Get( Form(
"%s;%d",list->At(j)->GetName(),keymap[list->At(j)->GetName()]) ));
587 if (objstr!=0){
589 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
590 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") ){
591 reader.AddXMLString(objstr->GetString());
592 }else{
593 logger <<
Root::kERROR <<
"XML string is not in expected format: " << objstr->GetString() <<
". Skipped." << Root::GEndl;
594
595 }
596 }else{
597 logger <<
Root::kERROR <<
"No obj found with key \"" << list->At(j)->GetName() <<
"\"" << Root::GEndl;
599 }
600 }
601 }
603 }
604
605
607 grlcollection =
reader.GetMergedGRLCollection();
608 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
610
611 if ( grlcollection[j].HasTriggerInfo() ) {
612 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
615 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
616 } else {
619 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
620 }
621 }
622 }
623
624
625
626 if(runtype != 999){
627
628
629
630
631 if (runtype != 0 && runList.size() > 0) {
632 std::vector<xAOD::LumiBlockRangeContainer*>::iterator iovIt = iovcVec.begin();
633 for (;iovIt != iovcVec.end(); ++iovIt) {
634
636 while (it != (*iovIt)->end()) {
637
638 unsigned int runnum = (*it)->startRunNumber() ;
639
641 std::list<std::pair<unsigned int, unsigned int> >
::iterator runIt = runList.begin();
642 for (; runIt != runList.end(); ++runIt) {
643 if (runnum < runIt->first) continue;
644 if (runnum > runIt->second) continue;
646 break;
647 }
648
649 if (!found) {
650 logger <<
Root::kDEBUG <<
"Skipping run " << (*it)->startRunNumber() <<
" LB [" << (*it)->startLumiBlockNumber() <<
"-" << (*it)->stopLumiBlockNumber() <<
"] due to command-line run range" << Root::GEndl;
651 (*iovIt)->erase(it);
652
653 it = (*iovIt)->begin();
654
655 } else {
656
658 }
659 }
660
661 }
662
663 }
664
665
667 for (
unsigned int j=0;
j<iovcVec.size(); ++
j) {
670
673 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
674 TTree
tree(
"LumiMetaData",
"LumiMetaData");
679 lumicalc.
UseMC(
false);
688 lumicalc.IntegrateLumi(iovc, (*it));
689 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
690
691
694 }
695 }
696 }
697 }
698
699
700
702 if(!grlcollection.empty()){
703 TString
xmlfile =
"ilumicalc_merged_";
705 if (grlcollection.size()==1) {
xmlfile += grlcollection[0].GetSuggestedName() +
".xml"; }
706 else {
xmlfile +=
"grls.xml"; }
709 }
710 }
711
712
713
717
718 return 0;
719
720}
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
bool empty() const noexcept
Returns true if the collection is empty.
Root::TGoodRunsList * GetGRLObject(const xAOD::LumiBlockRangeContainer &lbc, const grlmetadatamap &metadata=grlmetadatamap(), const char *version="") const
xAOD::LumiBlockRangeContainer * GetLumiBlockRangeContainer(const Root::TGoodRunsList &grl, std::map< TString, TString > &metadata, TString &version)
void CreateXMLFile(const Root::TGoodRunsList &grl, const TString &xmlfilename="", const TString &prefix="")
void UseOnlineLumi(bool online)
void UseLumiChannel(int chan)
void UseLumiMethod(const std::string &method)
void setTree(TTree *tree=0)
void UseLArNoiseDB(bool lar, const std::string &lardb)
void ScaleL1TrigRate(const float &rate)
void UseLiveTrigger(bool live, std::string &livetrigger)
void printSummary(std::ostream &os)
void Verbose(bool verbose=true)
void UseBeamspot(bool bs, const std::string &bstag)
void MakePlots(bool plots)
void MakeCollList(bool collList)
void UseLumiTag(const std::string &tag)
void SetVersion(const TString &version)
static void SetMinLevel(TMsgLevel minLevel)
void setStopRunNumber(uint32_t value)
Set the run number of the stop time of the range.
void setStartRunNumber(uint32_t value)
Set the run number of the start time of the range.
void setStartLumiBlockNumber(uint32_t value)
Set the luminosity block of the start time of the range.
void setStopLumiBlockNumber(uint32_t value)
Set the luminosity block of the stop time of the range.
int cmdline_parser(int argc, char **argv, struct gengetopt_args_info *args_info)
The command line parser.
void cmdline_parser_free(struct gengetopt_args_info *args_info)
Deallocates the string fields of the gengetopt_args_info structure (but does not deallocate the struc...
static uint32_t minlbstart
bool FileExists(const std::string &strFilename)
static std::vector< std::string > triggerchain
static std::vector< uint32_t > lbstart
static std::vector< uint32_t > runnumber
static std::vector< std::string > tagfile
static std::vector< std::string > xmlfile
static std::vector< std::string > rootfile
static uint32_t maxrunnum
static uint32_t minrunnum
static Root::TMsgLogger logger("iLumiCalc")
static std::string livetrigger
static std::vector< uint32_t > lbend
static std::string d3pddirname
static std::string treename
static std::string xmloutfile
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
reader
read the goodrunslist xml file(s)
timer(name, disabled=False)
LumiBlockRange_v1 LumiBlockRange
Declare the latest version of the class.
LumiBlockRangeContainer_v1 LumiBlockRangeContainer
Declare the latest version of the container.
LumiBlockRangeAuxContainer_v1 LumiBlockRangeAuxContainer
Declare the latest version of the auxiliary container.
Where the command line options are stored.
char * lumimethod_arg
Luminosity estimate method by string (default='ATLAS_PREFERRED').
int lar_flag
Calculate LAr defect fraction (default=off).
char ** runnumber_arg
Run number, range, or comma separated list, e.g.
char * lumitag_arg
Offline luminosity database tag (default='OflLumi-8TeV-002').
int online_flag
Use online luminosity estimates instead of offline database (default=off).
char ** root_arg
Input ROOT file name.
char * tree_arg
Name of TTree in input ROOT file to which Lumi string is attached.
int quiet_flag
Quiet output level (default=off).
char ** xml_arg
Input XML file name.
unsigned int root_given
Whether root was given.
char * d3pd_dir_arg
Name of TDirectory in input ROOT file where Lumi string is stored.
unsigned int xml_out_given
Whether xml_out was given.
unsigned int tree_given
Whether tree was given.
char * lartag_arg
LAr noise burst database tag (default='LARBadChannelsOflEventVeto-UPD4-01').
double scale_lumi_arg
Scale luminosity with a constant value (default='1.0').
int * lbstart_arg
LumiBlock number begin.
char * xml_out_arg
Output XML file name.
unsigned int lbend_given
Whether lbend was given.
unsigned int livetrigger_given
Whether livetrigger was given.
int lumichannel_arg
Luminosity estimate method by value (default='0').
unsigned int xml_given
Whether xml was given.
unsigned int lumimethod_given
Whether lumimethod was given.
int * lbend_arg
LumiBlock number end.
char ** trigger_arg
Trigger chain name used for prescale calculation.
char ** tag_arg
Input TAG file name.
int verbose_flag
Verbose output level (default=off).
unsigned int lumichannel_given
Whether lumichannel was given.
char * beamspottag_arg
Online beamspot database tag (default='IndetBeamposOnl-HLT-UPD1-001-00').
unsigned int trigger_given
Whether trigger was given.
unsigned int lbstart_given
Whether lbstart was given.
unsigned int runnumber_given
Whether runnumber was given.
char * livetrigger_arg
L1 Trigger used for livetime calculation (default='L1_EM30').
int xml_collisionlist_flag
Output XML file of lists of collision candidates (default=off).
int plots_flag
Create some plots on demand (default=off).
unsigned int tag_given
Whether tag was given.
int beamspot_flag
Require online beamspot valid in trigger livefraction (default=off).
unsigned int d3pd_dir_given
Whether d3pd_dir was given.