49 {
50
52
53
56
57
58
59
62
63
69 }
70
73
74
77
78
82 }
83
84
85
86
87
89 if (scalel1trigrate != 1.) {
91 }
92
93
95 if (online) {
97 }
98
99
101 if (online) {
103 } else {
105 }
106
107
110 if (uselar) {
111 logger <<
Root::kINFO <<
"LAr noise burst inefficiency will be calculated from " << lartag << Root::GEndl;
112 }
113
114
117 if (usebeamspot) {
119 }
120
121
122
123
124 std::string lumimethod;
125 int lumichannel = -1;
126
127
129 logger <<
Root::kERROR <<
"Sorry, the online database doesn't have luminosity method names, use --lumichannel instead!" << Root::GEndl;
131 }
132
141 logger <<
Root::kINFO <<
"Both lumimethod and lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
143 if (online) {
145 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumichannel: " << lumichannel << Root::GEndl;
146 } else {
148 logger <<
Root::kINFO <<
"No lumimethod or lumichannel is given, defaulting to Lumimethod: " << lumimethod << Root::GEndl;
149 }
150 }
151
152
153
154
156 logger <<
Root::kINFO <<
"No trigger specified, proceeding with --trigger=None" << Root::GEndl;
158 } else {
161 } else {
163 }
164
168 }
170 }
171
172
173
174 bool uselivetrigger = false;
176
178
179 uselivetrigger = true;
181 } else {
182
183 logger <<
Root::kINFO <<
"Prescale trigger chains will be used for livetime " << Root::GEndl;
184 }
185
186
187
188
189
190
191 std::list<std::pair<unsigned int, unsigned int> > runList;
192 runList.clear();
193
194
196
197
199
201
203 if (found != std::string::npos) {
205 val2 =
atoi(
full.substr(found+1, std::string::npos).c_str());
206 } else {
209 }
212
213
214 runList.push_back( std::pair<unsigned int, unsigned int>(val1, val2) );
215 }
216
217
218
219
220
221
222
223
224
225 unsigned int runtype = 0;
226
227
228
230 runtype = 1;
231 std::cout << args_info.
tag_given <<
" TAG file(s) is given..." << std::endl;
232 for(
unsigned int i = 0;
i < args_info.
tag_given; ++
i){
234 }
235
236 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
238 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
239 }
240 }
241
242
243 }
244
245
246
248 runtype = 3;
249 for(
unsigned int i = 0;
i < args_info.
xml_given; ++
i){
251 }
252
253 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
255 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
256 }
257 }
258
259 }
260
261
262
265 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --tree=\"mytreename\" OR --d3pd_dir=\"mydirname\" options " << Root::GEndl;
267 }
268
269 runtype = 4;
272 }
275 }else{
276 logger <<
Root::kERROR <<
"In Root file mode Tree name (--d3p_dir=\"mytreename\") must also be provided" << Root::GEndl;
277 }
278 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
280 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
281 }
282 }
283 }
284
285
286
289 logger <<
Root::kERROR <<
"Please provide BOTH --root=\"myfile.root\" AND --d3pd_dir=\"myd3pddirname\" options" << Root::GEndl;
291 }
292
293 runtype = 5;
296 }
299 }else{
300 logger <<
Root::kWARNING <<
"In D3PD Root file mode Directory name (--d3pd_dir=\"mylumidir\") must also be provided" << Root::GEndl;
303 }
304
305 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
307 logger <<
Root::kWARNING <<
"Problem: file ["<< (*it) <<
"] may not exist. Will try anyways..." << Root::GEndl;
308 }
309 }
310 }
311
312
313
314 if (runtype == 0) {
315
316
320 }
321
322 std::list<std::pair<unsigned int, unsigned int> >
::iterator itr = runList.begin();
323
324
325 for (; itr != runList.end(); ++itr) {
326
328 logger <<
Root::kERROR <<
"Can't use open-ended run ranges to specify sample!" << Root::GEndl;
330 }
331
332 for (unsigned int runnum = itr->first; runnum <= itr->second; runnum++)
334
335 }
336
337
341 }
342 } else {
345 }
346 }
347
351 }
352 } else {
355 }
356 }
357
358 }
359
360
361
362
364
365
366
367
368 std::vector< xAOD::LumiBlockRangeContainer* > iovcVec;
369 std::vector< std::vector<std::string> > triggerchainVec;
373
374
375
376 if (runtype == 0) {
377
380 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match!" << Root::GEndl;
382 }
383
385 logger <<
Root::kERROR <<
"number of lbstart and lbend values must match number of runs with multiple runs specified!" << Root::GEndl;
387 }
388
389
390
391
392
393
394
395
398
401 iovc->setStore( iovcAux );
402
403 std::vector<uint32_t>::iterator itstart;
404 std::vector<uint32_t>::iterator itend;
405 std::vector<uint32_t>::iterator itrun;
406
408
411 itstart !=
lbstart.end() && itend !=
lbend.end(); ++itstart,++itend) {
412 lbstart_val = (*itstart);
413 lbend_val = (*itend);
414 logger <<
Root::kINFO <<
"lbstart-lbend [" << lbstart_val <<
"-" << lbend_val <<
"]" << Root::GEndl;
415 if (lbstart_val > lbend_val) {
416 logger <<
Root::kERROR <<
"lbstart > lbend! Should be: lbstart < = lbend" << Root::GEndl;
418 } else {
425 }
426 }
427
429
432 ++itrun, ++itstart, ++itend) {
434 logger <<
Root::kINFO <<
"lbstart-lbend [" << *itstart <<
"-" << *itend <<
"]" << Root::GEndl;
441 }
442 }
443
444 iovcVec.push_back(iovc);
448 metadata[Form(
"TriggerName%d",j)] = TString(
triggerchain[j]);
449 grlcollection.push_back( *converter.
GetGRLObject(*iovc,metadata,version) );
450 }
451
452
453
454
455 if (runtype == 1) {
456
458
460 for(std::vector<std::string>::iterator it =
tagfile.begin(); it !=
tagfile.end(); ++it){
462 int n = (*it).find(
".root");
463 std::string tagfilename = (*it).substr(0,n);
464
465
468 if(collection == NULL) {
471 }
472 }
473
475 grlcollection =
reader.GetMergedGRLCollection();
476
477 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
479
480 if ( grlcollection[j].HasTriggerInfo() ) {
481 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
484 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
485 } else {
488 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
489 }
490 }
491 }
492
493
494
495 if(runtype == 3){
496
499
500 for(std::vector<std::string>::iterator it =
xmlfile.begin(); it !=
xmlfile.end(); ++it){
503 }
505 grlcollection =
reader.GetMergedGRLCollection();
506
507 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
509
510 if ( grlcollection[j].HasTriggerInfo() ) {
511 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
514 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
515 } else {
518 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
519 }
520 }
521 }
522
523
524
525
526 if(runtype == 4){
527
529
531
532 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
533 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
542 }else{
544
545
546 for(
int j=0;
j<
list->GetEntries();++
j) {
547 TObjString* objstr =
dynamic_cast<TObjString*
>(
list->At(j));
548 if (objstr==0) continue;
549 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
550 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") )
551 reader.AddXMLString(objstr->GetString());
552 }
553 }
555 }
556
557
559 grlcollection =
reader.GetMergedGRLCollection();
560
561 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
563
564 if ( grlcollection[j].HasTriggerInfo() ) {
565 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
568 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
569 } else {
572 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
573 }
574 }
575 }
576
577
578
579 if(runtype == 5){
580
581 logger <<
Root::kINFO <<
"Being in ROOT D3PD ntuple file mode..." << Root::GEndl;
582
584
585 for(std::vector<std::string>::iterator it =
rootfile.begin(); it !=
rootfile.end(); ++it){
586 logger <<
Root::kINFO <<
"Processing root file: <" << (*it) <<
">" << Root::GEndl;
590 TDirectoryFile *
dir = NULL;
593 if(!dir){
594
597 }else{
598 TObjString* objstr = 0;
599 std::map<TString,int> keymap;
601
602 for(
int j=0;
j<
list->GetEntries();
j++) {
603 if ( keymap.find(
list->At(j)->GetName())==keymap.end() ) { keymap[
list->At(j)->GetName()] = 1; }
604 else { keymap[
list->At(j)->GetName()] = keymap[
list->At(j)->GetName()]+1; }
606 objstr =
dynamic_cast<TObjString*
>(
dir->Get( Form(
"%s;%d",
list->At(j)->GetName(),keymap[
list->At(j)->GetName()]) ));
607 if (objstr!=0){
609 if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
610 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") ){
611 reader.AddXMLString(objstr->GetString());
612 }else{
613 logger <<
Root::kERROR <<
"XML string is not in expected format: " << objstr->GetString() <<
". Skipped." << Root::GEndl;
614
615 }
616 }else{
619 }
620 }
621 }
623 }
624
625
627 grlcollection =
reader.GetMergedGRLCollection();
628 for (
unsigned int j=0;
j<grlcollection.size(); ++
j) {
630
631 if ( grlcollection[j].HasTriggerInfo() ) {
632 triggerchainVec.push_back(grlcollection[j].GetTriggerList());
635 << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
636 } else {
639 grlcollection[j].AddMetaData( Form(
"TriggerName%d",k),TString(
triggerchain[k]) );
640 }
641 }
642 }
643
644
645
646 if(runtype != 999){
647
648
649
650
651 if (runtype != 0 && runList.size() > 0) {
652 std::vector<xAOD::LumiBlockRangeContainer*>::iterator iovIt = iovcVec.begin();
653 for (;iovIt != iovcVec.end(); ++iovIt) {
654
656 while (it != (*iovIt)->end()) {
657
658 unsigned int runnum = (*it)->startRunNumber() ;
659
661 std::list<std::pair<unsigned int, unsigned int> >
::iterator runIt = runList.begin();
662 for (; runIt != runList.end(); ++runIt) {
663 if (runnum < runIt->first) continue;
664 if (runnum > runIt->second) continue;
666 break;
667 }
668
669 if (!found) {
670 logger <<
Root::kDEBUG <<
"Skipping run " << (*it)->startRunNumber() <<
" LB [" << (*it)->startLumiBlockNumber() <<
"-" << (*it)->stopLumiBlockNumber() <<
"] due to command-line run range" << Root::GEndl;
671 (*iovIt)->erase(it);
672
673 it = (*iovIt)->begin();
674
675 } else {
676
678 }
679 }
680
681 }
682
683 }
684
685
687 for (
unsigned int j=0;
j<iovcVec.size(); ++
j) {
690
693 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
694 TTree
tree(
"LumiMetaData",
"LumiMetaData");
699 lumicalc.
UseMC(
false);
708 lumicalc.IntegrateLumi(iovc, (*it));
709 logger <<
Root::kINFO <<
"--------------------------------------------" << Root::GEndl;
710
711
714 }
715 }
716 }
717 }
718
719
720
722 if(!grlcollection.empty()){
723 TString
xmlfile =
"ilumicalc_merged_";
725 if (grlcollection.size()==1) {
xmlfile += grlcollection[0].GetSuggestedName() +
".xml"; }
726 else {
xmlfile +=
"grls.xml"; }
729 }
730 }
731
732
733
737
738 return 0;
739
740}
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 * open(const std::string &name, const DbType &type, const std::string &connection="", 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...
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.