45 {
46
48
49
52
53
54
55
58
59
65 }
66
69
70
73
74
78 }
79
80
81
82
83
85 if (scalel1trigrate != 1.) {
87 }
88
89
91 if (online) {
93 }
94
95
97 if (online) {
99 } else {
101 }
102
103
106 if (uselar) {
107 logger <<
Root::kINFO <<
"LAr noise burst inefficiency will be calculated from " << lartag << Root::GEndl;
108 }
109
110
113 if (usebeamspot) {
115 }
116
117
118
119
120 std::string lumimethod;
121 int lumichannel = -1;
122
123
125 logger <<
Root::kERROR <<
"Sorry, the online database doesn't have luminosity method names, use --lumichannel instead!" << Root::GEndl;
127 }
128
137 logger <<
Root::kINFO <<
"Both lumimethod and lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
139 if (online) {
141 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
142 } else {
144 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumimethod: " << lumimethod << Root::GEndl;
145 }
146 }
147
148
149
150
152 logger <<
Root::kINFO <<
"No trigger specified, proceeding with --trigger=None" << Root::GEndl;
154 } else {
157 } else {
159 }
160
164 }
166 }
167
168
169
170 bool uselivetrigger = false;
172
174
175 uselivetrigger = true;
177 } else {
178
179 logger <<
Root::kINFO <<
"Prescale trigger chains will be used for livetime " << Root::GEndl;
180 }
181
182
183
184
185
186
187 std::list<std::pair<unsigned int, unsigned int> > runList;
188 runList.clear();
189
190
192
193
195
197
199 if (found != std::string::npos) {
201 val2 =
atoi(
full.substr(found+1, std::string::npos).c_str());
202 } else {
205 }
208
209
210 runList.push_back( std::pair<unsigned int, unsigned int>(val1, val2) );
211 }
212
213
214
215
216
217
218
219
220
221 unsigned int runtype = 0;
222
223
224
226 runtype = 1;
227 std::cout << args_info.
tag_given <<
" TAG file(s) is given..." << std::endl;
228 for(
unsigned int i = 0;
i < args_info.
tag_given; ++
i){
230 }
231
232 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
234 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
235 }
236 }
237
238
239 }
240
241
242
244 runtype = 3;
245 for(
unsigned int i = 0;
i < args_info.
xml_given; ++
i){
247 }
248
249 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
251 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
252 }
253 }
254
255 }
256
257
258
261 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --tree=\"mytreename\" OR --d3pd_dir=\"mydirname\" options " << Root::GEndl;
263 }
264
265 runtype = 4;
268 }
271 }else{
272 logger <<
Root::kERROR <<
"In Root file mode Tree name (--d3p_dir=\"mytreename\") must also be provided" << Root::GEndl;
273 }
274 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
276 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
277 }
278 }
279 }
280
281
282
285 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --d3pd_dir=\"myd3pddirname\" options" << Root::GEndl;
287 }
288
289 runtype = 5;
292 }
295 }else{
296 logger <<
Root::kWARNING <<
"In D3PD Root file mode Directory name (--d3pd_dir=\"mylumidir\") must also be provided" << Root::GEndl;
299 }
300
301 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
303 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
304 }
305 }
306 }
307
308
309
310 if (runtype == 0) {
311
312
316 }
317
318 std::list<std::pair<unsigned int, unsigned int> >
::iterator itr = runList.begin();
319
320
321 for (; itr != runList.end(); ++itr) {
322
324 logger <<
Root::kERROR <<
"Can't use open-ended run ranges to specify sample!" << Root::GEndl;
326 }
327
328 for (unsigned int runnum = itr->first; runnum <= itr->second; runnum++)
330
331 }
332
333
337 }
338 } else {
341 }
342 }
343
347 }
348 } else {
351 }
352 }
353
354 }
355
356
357
358
360
361
362
363
364 std::vector< xAOD::LumiBlockRangeContainer* > iovcVec;
365 std::vector< std::vector<std::string> > triggerchainVec;
369
370
371
372 if (runtype == 0) {
373
376 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match!" << Root::GEndl;
378 }
379
381 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match number of runs with multiple runs specified!" << Root::GEndl;
383 }
384
385
386
387
388
389
390
391
394
397 iovc->setStore( iovcAux );
398
399 std::vector<uint32_t>::iterator itstart;
400 std::vector<uint32_t>::iterator itend;
401 std::vector<uint32_t>::iterator itrun;
402
404
407 itstart !=
lbstart.end() && itend !=
lbend.end(); ++itstart,++itend) {
408 lbstart_val = (*itstart);
409 lbend_val = (*itend);
410 logger <<
Root::kINFO <<
"lbstart-lbend [" << lbstart_val <<
"-" << lbend_val <<
"]" << Root::GEndl;
411 if (lbstart_val > lbend_val) {
412 logger <<
Root::kERROR <<
"lbstart > lbend! Should be: lbstart < = lbend" << Root::GEndl;
414 } else {
421 }
422 }
423
425
428 ++itrun, ++itstart, ++itend) {
430 logger <<
Root::kINFO <<
"lbstart-lbend [" << *itstart <<
"-" << *itend <<
"]" << Root::GEndl;
437 }
438 }
439
440 iovcVec.push_back(iovc);
444 metadata[Form(
"TriggerName%d",j)] = TString(
triggerchain[j]);
445 grlcollection.push_back( *converter.
GetGRLObject(*iovc,metadata,version) );
446 }
447
448
449
450
451 if (runtype == 1) {
452
454
456 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
458 int n = (*it).find(
".root");
459 std::string tagfilename = (*it).substr(0,n);
460
461
463 if(collection == NULL) {
466 }
467 }
468
470 grlcollection =
reader.GetMergedGRLCollection();
471
472 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
474
475 if ( grlcollection[j].HasTriggerInfo() ) {
476 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
479 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
480 } else {
483 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
484 }
485 }
486 }
487
488
489
490 if(runtype == 3){
491
494
495 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
498 }
500 grlcollection =
reader.GetMergedGRLCollection();
501
502 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
504
505 if ( grlcollection[j].HasTriggerInfo() ) {
506 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
509 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
510 } else {
513 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
514 }
515 }
516 }
517
518
519
520
521 if(runtype == 4){
522
524
526
527 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
528 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
532 TList * list = NULL;
537 }else{
538 list =
tree->GetUserInfo() ;
539
540
541 for(
int j=0;
j<list->GetEntries();++
j) {
542 TObjString* objstr = dynamic_cast<TObjString*>(list->At(j));
543 if (objstr==0) continue;
544 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
545 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") )
546 reader.AddXMLString(objstr->GetString());
547 }
548 }
550 }
551
552
554 grlcollection =
reader.GetMergedGRLCollection();
555
556 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
558
559 if ( grlcollection[j].HasTriggerInfo() ) {
560 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
563 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
564 } else {
567 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
568 }
569 }
570 }
571
572
573
574 if(runtype == 5){
575
576 logger <<
Root::kINFO <<
"Being in ROOT D3PD ntuple file mode..." << Root::GEndl;
577
579
580 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
581 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
583 TList* list = NULL;
585 TDirectoryFile *
dir = NULL;
588 if(!dir){
589
592 }else{
593 TObjString* objstr = 0;
594 std::map<TString,int> keymap;
595 list =
dir->GetListOfKeys();
596
597 for(
int j=0;
j<list->GetEntries();
j++) {
598 if ( keymap.find(list->At(j)->GetName())==keymap.end() ) { keymap[list->At(j)->GetName()] = 1; }
599 else { keymap[list->At(j)->GetName()] = keymap[list->At(j)->GetName()]+1; }
600 if(
verbose)
logger <<
Root::kINFO <<
"Found obj key: \"" << Form(
"%s;%d",list->At(j)->GetName(),keymap[list->At(j)->GetName()]) <<
"\"" << Root::GEndl;
601 objstr =
dynamic_cast<TObjString*
>(
dir->Get( Form(
"%s;%d",list->At(j)->GetName(),keymap[list->At(j)->GetName()]) ));
602 if (objstr!=0){
604 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
605 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") ){
606 reader.AddXMLString(objstr->GetString());
607 }else{
608 logger <<
Root::kERROR <<
"XML string is not in expected format: " << objstr->GetString() <<
". Skipped." << Root::GEndl;
609
610 }
611 }else{
612 logger <<
Root::kERROR <<
"No obj found with key \"" << list->At(j)->GetName() <<
"\"" << Root::GEndl;
614 }
615 }
616 }
618 }
619
620
622 grlcollection =
reader.GetMergedGRLCollection();
623 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
625
626 if ( grlcollection[j].HasTriggerInfo() ) {
627 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
630 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
631 } else {
634 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
635 }
636 }
637 }
638
639
640
641 if(runtype != 999){
642
643
644
645
646 if (runtype != 0 && runList.size() > 0) {
647 std::vector<xAOD::LumiBlockRangeContainer*>::iterator iovIt = iovcVec.begin();
648 for (;iovIt != iovcVec.end(); ++iovIt) {
649
651 while (it != (*iovIt)->end()) {
652
653 unsigned int runnum = (*it)->startRunNumber() ;
654
656 std::list<std::pair<unsigned int, unsigned int> >
::iterator runIt = runList.begin();
657 for (; runIt != runList.end(); ++runIt) {
658 if (runnum < runIt->first) continue;
659 if (runnum > runIt->second) continue;
661 break;
662 }
663
664 if (!found) {
665 logger <<
Root::kDEBUG <<
"Skipping run " << (*it)->startRunNumber() <<
" LB [" << (*it)->startLumiBlockNumber() <<
"-" << (*it)->stopLumiBlockNumber() <<
"] due to command-line run range" << Root::GEndl;
666 (*iovIt)->erase(it);
667
668 it = (*iovIt)->begin();
669
670 } else {
671
673 }
674 }
675
676 }
677
678 }
679
680
682 for (
unsigned int j=0;
j<iovcVec.size(); ++
j) {
685
688 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
689 TTree
tree(
"LumiMetaData",
"LumiMetaData");
694 lumicalc.
UseMC(
false);
703 lumicalc.IntegrateLumi(iovc, (*it));
704 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
705
706
709 }
710 }
711 }
712 }
713
714
715
717 if(!grlcollection.empty()){
718 TString
xmlfile =
"ilumicalc_merged_";
720 if (grlcollection.size()==1) {
xmlfile += grlcollection[0].GetSuggestedName() +
".xml"; }
721 else {
xmlfile +=
"grls.xml"; }
724 }
725 }
726
727
728
732
733 return 0;
734
735}
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)
static ICollection * open(const std::string &name, const std::string &connection="", ISession *session=0)
Opens an existing collection for reading.
An interface to a storage technology specific collection of event references and attributes.
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.