47 {
48
50
51
54
55
56
57
60
61
67 }
68
71
72
75
76
80 }
81
82
83
84
85
87 if (scalel1trigrate != 1.) {
89 }
90
91
93 if (online) {
95 }
96
97
99 if (online) {
101 } else {
103 }
104
105
108 if (uselar) {
109 logger <<
Root::kINFO <<
"LAr noise burst inefficiency will be calculated from " << lartag << Root::GEndl;
110 }
111
112
115 if (usebeamspot) {
117 }
118
119
120
121
122 std::string lumimethod;
123 int lumichannel = -1;
124
125
127 logger <<
Root::kERROR <<
"Sorry, the online database doesn't have luminosity method names, use --lumichannel instead!" << Root::GEndl;
129 }
130
139 logger <<
Root::kINFO <<
"Both lumimethod and lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
141 if (online) {
143 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
144 } else {
146 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumimethod: " << lumimethod << Root::GEndl;
147 }
148 }
149
150
151
152
154 logger <<
Root::kINFO <<
"No trigger specified, proceeding with --trigger=None" << Root::GEndl;
156 } else {
159 } else {
161 }
162
166 }
168 }
169
170
171
172 bool uselivetrigger = false;
174
176
177 uselivetrigger = true;
179 } else {
180
181 logger <<
Root::kINFO <<
"Prescale trigger chains will be used for livetime " << Root::GEndl;
182 }
183
184
185
186
187
188
189 std::list<std::pair<unsigned int, unsigned int> > runList;
190 runList.clear();
191
192
194
195
197
199
201 if (found != std::string::npos) {
203 val2 =
atoi(
full.substr(found+1, std::string::npos).c_str());
204 } else {
207 }
210
211
212 runList.push_back( std::pair<unsigned int, unsigned int>(val1, val2) );
213 }
214
215
216
217
218
219
220
221
222
223 unsigned int runtype = 0;
224
225
226
228 runtype = 1;
229 std::cout << args_info.
tag_given <<
" TAG file(s) is given..." << std::endl;
230 for(
unsigned int i = 0;
i < args_info.
tag_given; ++
i){
232 }
233
234 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
236 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
237 }
238 }
239
240
241 }
242
243
244
246 runtype = 3;
247 for(
unsigned int i = 0;
i < args_info.
xml_given; ++
i){
249 }
250
251 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
253 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
254 }
255 }
256
257 }
258
259
260
263 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --tree=\"mytreename\" OR --d3pd_dir=\"mydirname\" options " << Root::GEndl;
265 }
266
267 runtype = 4;
270 }
273 }else{
274 logger <<
Root::kERROR <<
"In Root file mode Tree name (--d3p_dir=\"mytreename\") must also be provided" << Root::GEndl;
275 }
276 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
278 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
279 }
280 }
281 }
282
283
284
287 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --d3pd_dir=\"myd3pddirname\" options" << Root::GEndl;
289 }
290
291 runtype = 5;
294 }
297 }else{
298 logger <<
Root::kWARNING <<
"In D3PD Root file mode Directory name (--d3pd_dir=\"mylumidir\") must also be provided" << Root::GEndl;
301 }
302
303 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
305 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
306 }
307 }
308 }
309
310
311
312 if (runtype == 0) {
313
314
318 }
319
320 std::list<std::pair<unsigned int, unsigned int> >
::iterator itr = runList.begin();
321
322
323 for (; itr != runList.end(); ++itr) {
324
326 logger <<
Root::kERROR <<
"Can't use open-ended run ranges to specify sample!" << Root::GEndl;
328 }
329
330 for (unsigned int runnum = itr->first; runnum <= itr->second; runnum++)
332
333 }
334
335
339 }
340 } else {
343 }
344 }
345
349 }
350 } else {
353 }
354 }
355
356 }
357
358
359
360
362
363
364
365
366 std::vector< xAOD::LumiBlockRangeContainer* > iovcVec;
367 std::vector< std::vector<std::string> > triggerchainVec;
371
372
373
374 if (runtype == 0) {
375
378 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match!" << Root::GEndl;
380 }
381
383 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match number of runs with multiple runs specified!" << Root::GEndl;
385 }
386
387
388
389
390
391
392
393
396
399 iovc->setStore( iovcAux );
400
401 std::vector<uint32_t>::iterator itstart;
402 std::vector<uint32_t>::iterator itend;
403 std::vector<uint32_t>::iterator itrun;
404
406
409 itstart !=
lbstart.end() && itend !=
lbend.end(); ++itstart,++itend) {
410 lbstart_val = (*itstart);
411 lbend_val = (*itend);
412 logger <<
Root::kINFO <<
"lbstart-lbend [" << lbstart_val <<
"-" << lbend_val <<
"]" << Root::GEndl;
413 if (lbstart_val > lbend_val) {
414 logger <<
Root::kERROR <<
"lbstart > lbend! Should be: lbstart < = lbend" << Root::GEndl;
416 } else {
423 }
424 }
425
427
430 ++itrun, ++itstart, ++itend) {
432 logger <<
Root::kINFO <<
"lbstart-lbend [" << *itstart <<
"-" << *itend <<
"]" << Root::GEndl;
439 }
440 }
441
442 iovcVec.push_back(iovc);
446 metadata[Form(
"TriggerName%d",j)] = TString(
triggerchain[j]);
447 grlcollection.push_back( *converter.
GetGRLObject(*iovc,metadata,version) );
448 }
449
450
451
452
453 if (runtype == 1) {
454
456
458 std::string connection ="";
459 std::string
type =
"RootCollection";
460 bool readOnly(true);
461 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
463 int n = (*it).find(
".root");
464 std::string tagfilename = (*it).substr(0,n);
465
466
469 if(collection == NULL) {
472 }
473 }
474
476 grlcollection =
reader.GetMergedGRLCollection();
477
478 for (unsigned int j=0; j<grlcollection.size(); ++j) {
480
481 if ( grlcollection[j].HasTriggerInfo() ) {
482 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
485 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
486 } else {
489 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
490 }
491 }
492 }
493
494
495
496 if(runtype == 3){
497
500
501 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
504 }
506 grlcollection =
reader.GetMergedGRLCollection();
507
508 for (unsigned int j=0; j<grlcollection.size(); ++j) {
510
511 if ( grlcollection[j].HasTriggerInfo() ) {
512 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
515 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
516 } else {
519 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
520 }
521 }
522 }
523
524
525
526
527 if(runtype == 4){
528
530
532
533 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
534 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
543 }else{
545
546
547 for(
int j=0; j<
list->GetEntries();++j) {
548 TObjString* objstr =
dynamic_cast<TObjString*
>(
list->At(j));
549 if (objstr==0) continue;
550 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
551 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") )
552 reader.AddXMLString(objstr->GetString());
553 }
554 }
556 }
557
558
560 grlcollection =
reader.GetMergedGRLCollection();
561
562 for (unsigned int j=0; j<grlcollection.size(); ++j) {
564
565 if ( grlcollection[j].HasTriggerInfo() ) {
566 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
569 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
570 } else {
573 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
574 }
575 }
576 }
577
578
579
580 if(runtype == 5){
581
582 logger <<
Root::kINFO <<
"Being in ROOT D3PD ntuple file mode..." << Root::GEndl;
583
585
586 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
587 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
591 TDirectoryFile *
dir = NULL;
594 if(!dir){
595
598 }else{
599 TObjString* objstr = 0;
600 std::map<TString,int> keymap;
602
603 for(
int j=0; j<
list->GetEntries();j++) {
604 if ( keymap.find(
list->At(j)->GetName())==keymap.end() ) { keymap[
list->At(j)->GetName()] = 1; }
605 else { keymap[
list->At(j)->GetName()] = keymap[
list->At(j)->GetName()]+1; }
607 objstr =
dynamic_cast<TObjString*
>(
dir->Get( Form(
"%s;%d",
list->At(j)->GetName(),keymap[
list->At(j)->GetName()]) ));
608 if (objstr!=0){
610 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
611 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") ){
612 reader.AddXMLString(objstr->GetString());
613 }else{
614 logger <<
Root::kERROR <<
"XML string is not in expected format: " << objstr->GetString() <<
". Skipped." << Root::GEndl;
615
616 }
617 }else{
620 }
621 }
622 }
624 }
625
626
628 grlcollection =
reader.GetMergedGRLCollection();
629 for (unsigned int j=0; j<grlcollection.size(); ++j) {
631
632 if ( grlcollection[j].HasTriggerInfo() ) {
633 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
636 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
637 } else {
640 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
641 }
642 }
643 }
644
645
646
647 if(runtype != 999){
648
649
650
651
652 if (runtype != 0 && runList.size() > 0) {
653 std::vector<xAOD::LumiBlockRangeContainer*>::iterator iovIt = iovcVec.begin();
654 for (;iovIt != iovcVec.end(); ++iovIt) {
655
657 while (it != (*iovIt)->end()) {
658
659 unsigned int runnum = (*it)->startRunNumber() ;
660
662 std::list<std::pair<unsigned int, unsigned int> >
::iterator runIt = runList.begin();
663 for (; runIt != runList.end(); ++runIt) {
664 if (runnum < runIt->first) continue;
665 if (runnum > runIt->second) continue;
667 break;
668 }
669
670 if (!found) {
671 logger <<
Root::kDEBUG <<
"Skipping run " << (*it)->startRunNumber() <<
" LB [" << (*it)->startLumiBlockNumber() <<
"-" << (*it)->stopLumiBlockNumber() <<
"] due to command-line run range" << Root::GEndl;
672 (*iovIt)->erase(it);
673
674 it = (*iovIt)->begin();
675
676 } else {
677
679 }
680 }
681
682 }
683
684 }
685
686
688 for (unsigned int j=0; j<iovcVec.size(); ++j) {
691
694 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
695 TTree
tree(
"LumiMetaData",
"LumiMetaData");
700 lumicalc.
UseMC(
false);
709 lumicalc.IntegrateLumi(iovc, (*it));
710 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
711
712
715 }
716 }
717 }
718 }
719
720
721
723 if(!grlcollection.empty()){
724 TString
xmlfile =
"ilumicalc_merged_";
726 if (grlcollection.size()==1) {
xmlfile += grlcollection[0].GetSuggestedName() +
".xml"; }
727 else {
xmlfile +=
"grls.xml"; }
730 }
731 }
732
733
734
738
739 return 0;
740
741}
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)
A service for creating, accessing and managing an ensemble of collections of event references.
virtual ICollection * handle(const std::string &name, const std::string &type, const std::string &connection="", bool readOnly=true, ISession *session=0) const
Retrieves a handle to an existing collection or collection fragment for read or update transactions,...
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...
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.