48 {
49
51
52
55
56
57
58
61
62
68 }
69
72
73
76
77
81 }
82
83
84
85
86
88 if (scalel1trigrate != 1.) {
90 }
91
92
94 if (online) {
96 }
97
98
100 if (online) {
102 } else {
104 }
105
106
109 if (uselar) {
110 logger <<
Root::kINFO <<
"LAr noise burst inefficiency will be calculated from " << lartag << Root::GEndl;
111 }
112
113
116 if (usebeamspot) {
118 }
119
120
121
122
123 std::string lumimethod;
124 int lumichannel = -1;
125
126
128 logger <<
Root::kERROR <<
"Sorry, the online database doesn't have luminosity method names, use --lumichannel instead!" << Root::GEndl;
130 }
131
140 logger <<
Root::kINFO <<
"Both lumimethod and lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
142 if (online) {
144 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
145 } else {
147 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumimethod: " << lumimethod << Root::GEndl;
148 }
149 }
150
151
152
153
155 logger <<
Root::kINFO <<
"No trigger specified, proceeding with --trigger=None" << Root::GEndl;
157 } else {
160 } else {
162 }
163
167 }
169 }
170
171
172
173 bool uselivetrigger = false;
175
177
178 uselivetrigger = true;
180 } else {
181
182 logger <<
Root::kINFO <<
"Prescale trigger chains will be used for livetime " << Root::GEndl;
183 }
184
185
186
187
188
189
190 std::list<std::pair<unsigned int, unsigned int> > runList;
191 runList.clear();
192
193
195
196
198
200
202 if (found != std::string::npos) {
204 val2 =
atoi(
full.substr(found+1, std::string::npos).c_str());
205 } else {
208 }
211
212
213 runList.push_back( std::pair<unsigned int, unsigned int>(val1, val2) );
214 }
215
216
217
218
219
220
221
222
223
224 unsigned int runtype = 0;
225
226
227
229 runtype = 1;
230 std::cout << args_info.
tag_given <<
" TAG file(s) is given..." << std::endl;
231 for(
unsigned int i = 0;
i < args_info.
tag_given; ++
i){
233 }
234
235 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
237 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
238 }
239 }
240
241
242 }
243
244
245
247 runtype = 3;
248 for(
unsigned int i = 0;
i < args_info.
xml_given; ++
i){
250 }
251
252 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
254 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
255 }
256 }
257
258 }
259
260
261
264 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --tree=\"mytreename\" OR --d3pd_dir=\"mydirname\" options " << Root::GEndl;
266 }
267
268 runtype = 4;
271 }
274 }else{
275 logger <<
Root::kERROR <<
"In Root file mode Tree name (--d3p_dir=\"mytreename\") must also be provided" << Root::GEndl;
276 }
277 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
279 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
280 }
281 }
282 }
283
284
285
288 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --d3pd_dir=\"myd3pddirname\" options" << Root::GEndl;
290 }
291
292 runtype = 5;
295 }
298 }else{
299 logger <<
Root::kWARNING <<
"In D3PD Root file mode Directory name (--d3pd_dir=\"mylumidir\") must also be provided" << Root::GEndl;
302 }
303
304 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
306 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
307 }
308 }
309 }
310
311
312
313 if (runtype == 0) {
314
315
319 }
320
321 std::list<std::pair<unsigned int, unsigned int> >
::iterator itr = runList.begin();
322
323
324 for (; itr != runList.end(); ++itr) {
325
327 logger <<
Root::kERROR <<
"Can't use open-ended run ranges to specify sample!" << Root::GEndl;
329 }
330
331 for (unsigned int runnum = itr->first; runnum <= itr->second; runnum++)
333
334 }
335
336
340 }
341 } else {
344 }
345 }
346
350 }
351 } else {
354 }
355 }
356
357 }
358
359
360
361
363
364
365
366
367 std::vector< xAOD::LumiBlockRangeContainer* > iovcVec;
368 std::vector< std::vector<std::string> > triggerchainVec;
372
373
374
375 if (runtype == 0) {
376
379 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match!" << Root::GEndl;
381 }
382
384 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match number of runs with multiple runs specified!" << Root::GEndl;
386 }
387
388
389
390
391
392
393
394
397
400 iovc->setStore( iovcAux );
401
402 std::vector<uint32_t>::iterator itstart;
403 std::vector<uint32_t>::iterator itend;
404 std::vector<uint32_t>::iterator itrun;
405
407
410 itstart !=
lbstart.end() && itend !=
lbend.end(); ++itstart,++itend) {
411 lbstart_val = (*itstart);
412 lbend_val = (*itend);
413 logger <<
Root::kINFO <<
"lbstart-lbend [" << lbstart_val <<
"-" << lbend_val <<
"]" << Root::GEndl;
414 if (lbstart_val > lbend_val) {
415 logger <<
Root::kERROR <<
"lbstart > lbend! Should be: lbstart < = lbend" << Root::GEndl;
417 } else {
424 }
425 }
426
428
431 ++itrun, ++itstart, ++itend) {
433 logger <<
Root::kINFO <<
"lbstart-lbend [" << *itstart <<
"-" << *itend <<
"]" << Root::GEndl;
440 }
441 }
442
443 iovcVec.push_back(iovc);
447 metadata[Form(
"TriggerName%d",j)] = TString(
triggerchain[j]);
448 grlcollection.push_back( *converter.
GetGRLObject(*iovc,metadata,version) );
449 }
450
451
452
453
454 if (runtype == 1) {
455
457
459 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
461 int n = (*it).find(
".root");
462 std::string tagfilename = (*it).substr(0,n);
463
464
467 if(collection == NULL) {
470 }
471 }
472
474 grlcollection =
reader.GetMergedGRLCollection();
475
476 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
478
479 if ( grlcollection[j].HasTriggerInfo() ) {
480 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
483 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
484 } else {
487 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
488 }
489 }
490 }
491
492
493
494 if(runtype == 3){
495
498
499 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
502 }
504 grlcollection =
reader.GetMergedGRLCollection();
505
506 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
508
509 if ( grlcollection[j].HasTriggerInfo() ) {
510 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
513 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
514 } else {
517 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
518 }
519 }
520 }
521
522
523
524
525 if(runtype == 4){
526
528
530
531 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
532 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
541 }else{
543
544
545 for(
int j=0;
j<
list->GetEntries();++
j) {
546 TObjString* objstr =
dynamic_cast<TObjString*
>(
list->At(j));
547 if (objstr==0) continue;
548 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
549 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") )
550 reader.AddXMLString(objstr->GetString());
551 }
552 }
554 }
555
556
558 grlcollection =
reader.GetMergedGRLCollection();
559
560 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
562
563 if ( grlcollection[j].HasTriggerInfo() ) {
564 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
567 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
568 } else {
571 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
572 }
573 }
574 }
575
576
577
578 if(runtype == 5){
579
580 logger <<
Root::kINFO <<
"Being in ROOT D3PD ntuple file mode..." << Root::GEndl;
581
583
584 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
585 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
589 TDirectoryFile *
dir = NULL;
592 if(!dir){
593
596 }else{
597 TObjString* objstr = 0;
598 std::map<TString,int> keymap;
600
601 for(
int j=0;
j<
list->GetEntries();
j++) {
602 if ( keymap.find(
list->At(j)->GetName())==keymap.end() ) { keymap[
list->At(j)->GetName()] = 1; }
603 else { keymap[
list->At(j)->GetName()] = keymap[
list->At(j)->GetName()]+1; }
605 objstr =
dynamic_cast<TObjString*
>(
dir->Get( Form(
"%s;%d",
list->At(j)->GetName(),keymap[
list->At(j)->GetName()]) ));
606 if (objstr!=0){
608 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
609 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") ){
610 reader.AddXMLString(objstr->GetString());
611 }else{
612 logger <<
Root::kERROR <<
"XML string is not in expected format: " << objstr->GetString() <<
". Skipped." << Root::GEndl;
613
614 }
615 }else{
618 }
619 }
620 }
622 }
623
624
626 grlcollection =
reader.GetMergedGRLCollection();
627 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
629
630 if ( grlcollection[j].HasTriggerInfo() ) {
631 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
634 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
635 } else {
638 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
639 }
640 }
641 }
642
643
644
645 if(runtype != 999){
646
647
648
649
650 if (runtype != 0 && runList.size() > 0) {
651 std::vector<xAOD::LumiBlockRangeContainer*>::iterator iovIt = iovcVec.begin();
652 for (;iovIt != iovcVec.end(); ++iovIt) {
653
655 while (it != (*iovIt)->end()) {
656
657 unsigned int runnum = (*it)->startRunNumber() ;
658
660 std::list<std::pair<unsigned int, unsigned int> >
::iterator runIt = runList.begin();
661 for (; runIt != runList.end(); ++runIt) {
662 if (runnum < runIt->first) continue;
663 if (runnum > runIt->second) continue;
665 break;
666 }
667
668 if (!found) {
669 logger <<
Root::kDEBUG <<
"Skipping run " << (*it)->startRunNumber() <<
" LB [" << (*it)->startLumiBlockNumber() <<
"-" << (*it)->stopLumiBlockNumber() <<
"] due to command-line run range" << Root::GEndl;
670 (*iovIt)->erase(it);
671
672 it = (*iovIt)->begin();
673
674 } else {
675
677 }
678 }
679
680 }
681
682 }
683
684
686 for (
unsigned int j=0;
j<iovcVec.size(); ++
j) {
689
692 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
693 TTree
tree(
"LumiMetaData",
"LumiMetaData");
698 lumicalc.
UseMC(
false);
707 lumicalc.IntegrateLumi(iovc, (*it));
708 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
709
710
713 }
714 }
715 }
716 }
717
718
719
721 if(!grlcollection.empty()){
722 TString
xmlfile =
"ilumicalc_merged_";
724 if (grlcollection.size()==1) {
xmlfile += grlcollection[0].GetSuggestedName() +
".xml"; }
725 else {
xmlfile +=
"grls.xml"; }
728 }
729 }
730
731
732
736
737 return 0;
738
739}
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.
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)
static const DbType ROOT_StorageType
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.