|
ATLAS Offline Software
|
Go to the documentation of this file.
29 std::vector<std::string> knownParameters {
30 "file",
"f",
"smk",
"l1psk",
"hltpsk",
"bgsk",
"db",
"write",
"w",
31 "Write",
"W",
"help",
"h",
"detail",
"d",
"ctp",
"c"
37 unsigned int smk { 0 };
39 unsigned int hltpsk { 0 };
40 unsigned int bgsk { 0 };
46 bool writeFromDataStructure {
false };
56 void parseProgramOptions(
int argc,
char*
argv[]);
66 cout <<
"The program needs to be run with the following specifications:\n\n";
67 cout <<
"TriggerMenuRW <options>\n";
69 cout <<
"[Input options]\n";
70 cout <<
" -f|--file file1 [file2 [file3 ...]] ... one or multiple json files\n";
71 cout <<
" --smk smk ... smk \n";
72 cout <<
" --l1psk l1psk ... the L1 prescale key \n";
73 cout <<
" --hltpsk hltpsk ... the HLT prescale key \n";
74 cout <<
" --bgsk bgsk ... the bunchgroup key \n";
75 cout <<
" --db dbalias ... dbalias (default " <<
dbalias <<
") \n";
76 cout <<
" -c|--ctp ... if provided together with the SMK and DB then will read only CTP files from the DB and not the rest of the menu\n";
77 cout <<
"[Output options]\n";
78 cout <<
" -w|--write [base] ... to write out json files, e.g. L1menu[_<base>].json. base is optional.\n";
79 cout <<
" -W|--Write [base] ... to write out json files from the internal structure (only for L1Menu), e.g. L1menu[_<base>].json. base is optional.\n";
80 cout <<
"[Other options]\n";
81 cout <<
" -h|--help ... this help\n";
82 cout <<
" -d|--detail ... prints detailed job options\n";
85 cout <<
" --file L1menu.json HLTMenu.json ... read L1Menu.json and HLTMenu.json and show some basic statistics\n";
86 cout <<
" --db TRIGGERDB_RUN3 --smk 3205 ... read the L1 menu, HLT menu, HLT job options, and HLT monitoring groups for SMK 3205\n";
87 cout <<
" --db TRIGGERDB_RUN3 --smk 3205 -w ... read the information and write DB content directly as json files\n";
93 std::string currentParameter(
"");
94 std::string listofUnknownParameters =
"";
98 std::string currentWord(
argv[
i]);
99 bool isParam = currentWord[0]==
'-';
102 int firstChar = currentWord.find_first_not_of(
'-');
103 string paramName = currentWord.substr(firstChar);
106 if ( isParam &&
std::find(knownParameters.begin(), knownParameters.end(), paramName) == knownParameters.end() ) {
107 listofUnknownParameters +=
" " + currentWord;
112 currentParameter =
"";
114 if(paramName ==
"h" || paramName ==
"help" ) {
help =
true;
continue; }
115 if(paramName ==
"d" || paramName ==
"detail" ) {
detail =
true;
continue; }
116 if(paramName ==
"w" || paramName ==
"write" ) {
write =
true; }
117 if(paramName ==
"W" || paramName ==
"Write" ) { writeFromDataStructure =
true; }
118 if(paramName ==
"c" || paramName ==
"ctp" ) { doCtp =
true; }
119 currentParameter = paramName;
126 if(currentParameter ==
"file" || currentParameter ==
"f") {
130 if(currentParameter ==
"smk") {
131 smk = stoul(currentWord);
134 if(currentParameter ==
"l1psk") {
135 l1psk = stoul(currentWord);
138 if(currentParameter ==
"hltpsk") {
139 hltpsk = stoul(currentWord);
142 if(currentParameter ==
"bgsk") {
143 bgsk = stoul(currentWord);
146 if(currentParameter ==
"db") {
152 if(currentParameter ==
"write" || currentParameter ==
"w" || currentParameter ==
"Write" || currentParameter ==
"W") {
160 if (
inputFiles.size() == 0 and
smk == 0 and
l1psk == 0 and hltpsk == 0 and bgsk == 0 ) {
161 error.push_back(
"No input specified! Please provide either one of the following: input file(s), smk, l1psk, hltpsk, or bgsk");
164 if ( listofUnknownParameters.size() > 0 ) {
165 error.push_back(
string(
"Unknown parameter(s):") + listofUnknownParameters);
175 if (
cfg.base !=
"" ) {
181 }
else if (
cfg.writeFromDataStructure ) {
183 if (
cfg.base !=
"" ) {
187 if ( kind==
"L1Menu" ) {
191 }
else if ( kind ==
"HLTMenu") {
205 if (
cfg.base !=
"" ) {
223 if(
cfg.error.size()!=0) {
224 for(
const string &
e:
cfg.error)
230 if(
cfg.inputFiles.size()>0 ) {
233 for (
const std::string &
fn :
cfg.inputFiles) {
236 if(filetype ==
"l1menu") {
239 cout <<
"Loaded L1 menu " <<
l1menu.name() <<
" with " <<
l1menu.size() <<
" items from " <<
fn << endl;
242 }
else if(filetype ==
"hltmenu" ) {
245 cout <<
"Loaded HLT menu " << hltmenu.
name() <<
" with " << hltmenu.
size() <<
" chains from " <<
fn << endl;
247 writeJsonFile(hltmenu,
"HLTMenu",
cfg);
248 }
else if(filetype ==
"l1prescale" ) {
251 cout <<
"Loaded L1 prescales set file " <<
fn <<
" with " << l1pss.
size() <<
" prescales from " <<
fn << endl;
252 writeJsonFile(l1pss,
"L1PrescalesSet",
cfg);
253 }
else if(filetype ==
"hltprescale" ) {
256 cout <<
"Loaded HLT prescales set file " <<
fn <<
" with " << hltpss.
size() <<
" prescales from " <<
fn << endl;
258 writeJsonFile(hltpss,
"HLTPrescalesSet",
cfg);
259 }
else if(filetype ==
"bunchgroupset" ) {
262 cout <<
"Loaded L1 BunchGroup set file " <<
fn <<
" with " << bgs.
sizeNonEmpty() <<
" non-empty bunchgroups from " <<
fn << endl;
264 writeJsonFile(bgs,
"BunchGroupSet",
cfg);
265 }
else if(filetype ==
"joboptions" ) {
268 cout <<
"Loaded job options with " << jo.
getObject(
"properties").
getKeys().size() <<
" properties from " <<
fn << endl;
271 for(
const auto&
alg :
ds.data()) {
272 std::cout <<
alg.first << std::endl;
273 for(
const auto& prop :
alg.second ) {
274 std::cout <<
" " << prop.first <<
" -> " << prop.second.data() << std::endl;
278 writeJsonFile(jo,
"HLTJobOptions",
cfg);
279 }
else if(filetype ==
"hltmonitoringsummary" ) {
282 cout <<
"Loaded HLT monnitoring with " <<
mon.size() <<
" signatures from " <<
fn << endl;
283 mon.printMonConfig(
cfg.detail);
284 writeJsonFile(
mon,
"HLTMonitoring",
cfg);
286 cerr <<
"File " <<
fn <<
" not recognized as being an L1 or HLT menu or prescale set or bunchgroup set" << endl;
291 if(
cfg.smk != 0 && !
cfg.doCtp ) {
304 cout <<
"Could not load L1 menu. An exception occurred: " << ex.
what() << endl;
307 cout <<
"Loaded L1 menu " <<
l1menu.name() <<
" with " <<
l1menu.size() <<
" items from " <<
cfg.dbalias <<
" with SMK " <<
cfg.smk << endl;
322 cout <<
"Could not load HLT menu. An exception occurred: " << ex.
what() << endl;
325 cout <<
"Loaded HLT menu " << hltmenu.
name() <<
" with " << hltmenu.
size() <<
" chains from " <<
cfg.dbalias <<
" with SMK " <<
cfg.smk << endl;
341 cout <<
"Could not load HLT job options. An exception occurred: " << ex.
what() << endl;
344 cout <<
"Loaded job options with " << jo.
getObject(
"properties").
getKeys().size() <<
" entries from " <<
cfg.dbalias <<
" with SMK " <<
cfg.smk << endl;
347 for(
const auto&
alg :
ds.data()) {
348 std::cout <<
alg.first << std::endl;
349 for(
const auto& prop :
alg.second ) {
350 std::cout <<
" " << prop.first <<
" -> " << prop.second.data() << std::endl;
366 cout <<
"Could not load HLT monitoring. An exception occurred: " << ex.
what() << endl;
369 cout <<
"Loaded HLT monitoring with " << hltmon.
size() <<
" signatures rom " <<
cfg.dbalias <<
" with SMK " <<
cfg.smk << endl;
379 if(
cfg.smk != 0 &&
cfg.doCtp ) {
386 if(
cfg.l1psk != 0 ) {
394 cout <<
"Could not load L1 prescales. An exception occurred: " << ex.
what() << endl;
397 cout <<
"Loaded L1 prescales set " << l1pss.
name() <<
" with " << l1pss.
size() <<
" prescales from " <<
cfg.dbalias <<
" with L1 PSK " <<
cfg.l1psk << endl;
401 if(
cfg.hltpsk != 0 ) {
409 cout <<
"Could not load HLT prescales. An exception occurred: " << ex.
what() << endl;
412 cout <<
"Loaded HLT prescales set " << hltpss.
name() <<
" with " << hltpss.
size() <<
" prescales from " <<
cfg.dbalias <<
" with HLT PSK " <<
cfg.hltpsk << endl;
416 if(
cfg.bgsk != 0 ) {
424 cout <<
"Could not load bunchgroup set. An exception occurred: " << ex.
what() << endl;
427 cout <<
"Loaded L1 bunchgroup set " << bgs.
name() <<
" with " << bgs.
size() <<
" bunchgroups from " <<
cfg.dbalias <<
" with BGSK " <<
cfg.bgsk << endl;
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.
Loader class for Trigger configuration (L1 hardware files) from the Trigger DB.
Loader of trigger configurations from Json files.
bool loadL1Prescales(unsigned int l1psk, L1PrescalesSet &l1pss, const std::string &outFileName="") const
Load content from the Trigger DB into an L1PrescalesSet for a given L1PrescaleKey (L1PSK)
Loader class for Trigger configuration (L1 prescales set) from the Trigger DB.
std::string find(const std::string &s)
return a remapped string
bool loadFile(const std::string &filename, boost::property_tree::ptree &data, const std::string &pathToChild="") const
Load content of json file into a ptree.
Loader class for Trigger configuration from the Trigger DB.
std::size_t size() const
Accessor to the number of HLT monitoring chains.
std::vector< std::string > getKeys() const
Access to the keys of an DataStructure which presents a dictionary.
virtual const std::string & name() const final
bool loadHLTPrescales(unsigned int hltpsk, HLTPrescalesSet &hltpss, const std::string &outFileName="") const
Load content from the Trigger DB into an HLTPrescalesSet for a given HLTPrescaleKey (HLTPSK)
bool writeJsonFile(const std::string &filename, const L1Menu &l1menu) const
std::size_t size() const
number of HLT prescales
void parseProgramOptions(int argc, char *argv[])
bool saveFile(const std::string &filename, const DataStructure &data) const
Save content of DataStructure (underlying ptree) to a file.
Loader class for Trigger configuration (L1 prescales set) from the Trigger DB.
std::size_t size() const
Accessor to the number of defined bunchgroups.
Loader class for Trigger configuration (HLT prescales set) from the Trigger DB.
std::size_t sizeNonEmpty() const
Accessor to the number of non-empty bunchgroups.
bool writeJsonFile(const std::string &filename, const HLTMenu &menu) const
std::string getFileType(const std::string &filename) const
Checks the trigger level of a given json file.
Loader of trigger menu configurations from the database.
void printSummary(bool detailed=false) const
print a more or less detailed summary
void printPrescaleSet(bool full) const
Loader of trigger configurations from Json files.
bool loadBunchGroupSet(unsigned int bgsk, L1BunchGroupSet &bgs, const std::string &outFileName="") const
Load content from the Trigger DB into an L1PrescalesSet for a given L1PrescaleKey (L1PSK)
Loader of trigger configurations from Json files.
Base class for Trigger configuration data and wrapper around underlying representation.
bool loadHardwareFiles(unsigned int smk, L1CTPFiles &ctpfiles, uint8_t loadMask=0x0F, const std::string &outFileName="") const
Load content from the Trigger DB into an L1CTPFiles object for a given super master key (SMK)
HLT monitoring configuration.
Loader of trigger configurations from Json files.
bool loadHLTMonitoring(unsigned int smk, boost::property_tree::ptree &hltmonitoring, const std::string &outFileName="") const
Load HLT menu content from the Trigger DB into two ptrees for a given SuperMasterKey (SMK)
bool loadJobOptions(unsigned int smk, boost::property_tree::ptree &jobOptions, const std::string &outFileName="") const
Load content from the Trigger DB into two ptrees for a given SuperMasterKey (SMK)
void printMonConfig(bool full=false) const
print overview of L1 Menu
std::size_t size() const
number of L1 prescales
virtual const char * what() const noexcept
Loader class for Trigger configuration from Json.
Loader of trigger configurations from Json files.
Loader of trigger configurations from Json files.
Loader of trigger configurations from Json files.
Loader of trigger configurations from Json files.