ATLAS Offline Software
Classes | Functions
TriggerMenuRW.cxx File Reference
#include "TrigConfIO/JsonFileLoader.h"
#include "TrigConfIO/JsonFileWriterL1.h"
#include "TrigConfIO/JsonFileWriterHLT.h"
#include "TrigConfIO/TrigDBMenuLoader.h"
#include "TrigConfIO/TrigDBJobOptionsLoader.h"
#include "TrigConfIO/TrigDBL1PrescalesSetLoader.h"
#include "TrigConfIO/TrigDBHLTPrescalesSetLoader.h"
#include "TrigConfIO/TrigDBL1BunchGroupSetLoader.h"
#include "TrigConfIO/TrigDBMonitoringLoader.h"
#include "TrigConfIO/TrigDBCTPFilesLoader.h"
#include "TrigConfData/HLTMenu.h"
#include "TrigConfData/L1Menu.h"
#include "TrigConfData/L1PrescalesSet.h"
#include "TrigConfData/HLTPrescalesSet.h"
#include "TrigConfData/L1BunchGroupSet.h"
#include <cstdlib>
#include <vector>
#include <format>

Go to the source code of this file.

Classes

struct  Config
 

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 237 of file TriggerMenuRW.cxx.

237  {
238 
239  Config cfg;
240  cfg.parseProgramOptions(argc, argv);
241  if(cfg.help) {
242  cfg.usage();
243  return 0;
244  }
245 
246  if(cfg.error.size()!=0) {
247  for(const string & e: cfg.error)
248  cerr << e << endl;
249  cfg.usage();
250  return 1;
251  }
252 
253  if( cfg.inputFiles.size()>0 ) {
254  // load config from files
255  TrigConf::JsonFileLoader fileLoader;
256  for (const std::string & fn : cfg.inputFiles) {
257  // check if the file is L1 or HLT
258  std::string filetype = fileLoader.getFileType( fn );
259  if(filetype == "l1menu") {
261  fileLoader.loadFile( fn, l1menu);
262  cout << "Loaded L1 menu " << l1menu.name() << " with " << l1menu.size() << " items from " << fn << endl;
263  l1menu.printMenu(cfg.detail);
264  writeJsonFile(l1menu, "L1Menu", cfg);
265  } else if(filetype == "hltmenu" ) {
266  TrigConf::HLTMenu hltmenu;
267  fileLoader.loadFile( fn, hltmenu);
268  cout << "Loaded HLT menu " << hltmenu.name() << " with " << hltmenu.size() << " chains from " << fn << endl;
269  hltmenu.printMenu(cfg.detail);
270  writeJsonFile(hltmenu, "HLTMenu", cfg);
271  } else if(filetype == "l1prescale" ) {
273  fileLoader.loadFile( fn, l1pss);
274  cout << "Loaded L1 prescales set file " << fn << " with " << l1pss.size() << " prescales from " << fn << endl;
275  writeJsonFile(l1pss, "L1PrescalesSet", cfg);
276  } else if(filetype == "hltprescale" ) {
278  fileLoader.loadFile( fn, hltpss);
279  cout << "Loaded HLT prescales set file " << fn << " with " << hltpss.size() << " prescales from " << fn << endl;
280  hltpss.printPrescaleSet(cfg.detail);
281  writeJsonFile(hltpss, "HLTPrescalesSet", cfg);
282  } else if(filetype == "bunchgroupset" ) {
284  fileLoader.loadFile( fn, bgs);
285  cout << "Loaded L1 BunchGroup set file " << fn << " with " << bgs.sizeNonEmpty() << " non-empty bunchgroups from " << fn << endl;
286  bgs.printSummary(cfg.detail);
287  writeJsonFile(bgs, "BunchGroupSet", cfg);
288  } else if(filetype == "joboptions" ) {
290  fileLoader.loadFile( fn, jo);
291  cout << "Loaded job options with " << jo.getObject("properties").getKeys().size() << " properties from " << fn << endl;
292  if( cfg.detail ) {
293  TrigConf::DataStructure ds = jo.getObject("properties");
294  for( const auto& alg : ds.data()) {
295  std::cout << alg.first << std::endl;
296  for( const auto& prop : alg.second ) {
297  std::cout << " " << prop.first << " -> " << prop.second.data() << std::endl;
298  }
299  }
300  }
301  writeJsonFile(jo, "HLTJobOptions", cfg);
302  } else if(filetype == "hltmonitoringsummary" ) {
304  fileLoader.loadFile( fn, mon);
305  cout << "Loaded HLT monnitoring with " << mon.size() << " signatures from " << fn << endl;
306  mon.printMonConfig(cfg.detail);
307  writeJsonFile(mon, "HLTMonitoring", cfg);
308  } else {
309  cerr << "File " << fn << " not recognized as being an L1 or HLT menu or prescale set or bunchgroup set" << endl;
310  }
311  }
312  }
313 
314  if( cfg.smk != 0 && !cfg.doCtp ) {
315  // load config from DB
316  {
317  // db menu loader
318  TrigConf::TrigDBMenuLoader dbloader(cfg.dbalias);
319  if(!cfg.crestDb.empty()) {
320  dbloader.setCrestTrigDB(cfg.crestDb);
321  dbloader.setCrestConnection(cfg.crestServer, cfg.crestApi);
322  }
323 
324  // L1 menu
325  {
327  try {
328  dbloader.loadL1Menu( cfg.smk, l1menu, outputFileName("L1Menu", cfg) );
329  }
330  catch(TrigConf::IOException & ex) {
331  cout << "Could not load L1 menu. An exception occurred: " << ex.what() << endl;
332  }
333  if(l1menu) {
334  cout << "Loaded L1 menu " << l1menu.name() << " with " << l1menu.size() << " items from " << cfg.dbalias << " with SMK " << cfg.smk << endl;
335  if( cfg.detail ) {
336  l1menu.printMenu(true);
337  }
338  }
339  cout << endl;
340  }
341 
342  // HLT menu
343  {
344  TrigConf::HLTMenu hltmenu;
345  try {
346  dbloader.loadHLTMenu( cfg.smk, hltmenu, outputFileName("HLTMenu", cfg));
347  }
348  catch(TrigConf::IOException & ex) {
349  cout << "Could not load HLT menu. An exception occurred: " << ex.what() << endl;
350  }
351  if (hltmenu) {
352  cout << "Loaded HLT menu " << hltmenu.name() << " with " << hltmenu.size() << " chains from " << cfg.dbalias << " with SMK " << cfg.smk << endl;
353  if( cfg.detail ) {
354  hltmenu.printMenu(true);
355  }
356  }
357  cout << endl;
358  }
359  }
360 
361  // Job options
362  {
363  TrigConf::TrigDBJobOptionsLoader dbloader(cfg.dbalias);
364  if(!cfg.crestDb.empty()) {
365  dbloader.setCrestTrigDB(cfg.crestDb);
366  dbloader.setCrestConnection(cfg.crestServer, cfg.crestApi);
367  }
369  try {
370  dbloader.loadJobOptions( cfg.smk, jo, outputFileName("HLTJobOptions", cfg) );
371  }
372  catch(TrigConf::IOException & ex) {
373  cout << "Could not load HLT job options. An exception occurred: " << ex.what() << endl;
374  }
375  if (jo) {
376  cout << "Loaded job options with " << jo.getObject("properties").getKeys().size() << " entries from " << cfg.dbalias << " with SMK " << cfg.smk << endl;
377  if( cfg.detail ) {
378  TrigConf::DataStructure ds = jo.getObject("properties");
379  for( const auto& alg : ds.data()) {
380  std::cout << alg.first << std::endl;
381  for( const auto& prop : alg.second ) {
382  std::cout << " " << prop.first << " -> " << prop.second.data() << std::endl;
383  }
384  }
385  }
386  }
387  cout << endl;
388  }
389 
390  // HLT monitoring groups
391  {
392  TrigConf::TrigDBMonitoringLoader dbloader(cfg.dbalias);
393  if(!cfg.crestDb.empty()) {
394  dbloader.setCrestTrigDB(cfg.crestDb);
395  dbloader.setCrestConnection(cfg.crestServer, cfg.crestApi);
396  }
398  try {
399  dbloader.loadHLTMonitoring( cfg.smk, hltmon, outputFileName("HLTMonitoring", cfg));
400  }
401  catch(TrigConf::IOException & ex) {
402  cout << "Could not load HLT monitoring. An exception occurred: " << ex.what() << endl;
403  }
404  if (hltmon) {
405  cout << "Loaded HLT monitoring with " << hltmon.size() << " signatures rom " << cfg.dbalias << " with SMK " << cfg.smk << endl;
406  if( cfg.detail ) {
407  hltmon.printMonConfig(true);
408  }
409  }
410  cout << endl;
411  }
412 
413  }
414 
415  if( cfg.smk != 0 && cfg.doCtp ) {
416  TrigConf::TrigDBCTPFilesLoader dbloader(cfg.dbalias);
417  TrigConf::L1CTPFiles ctpfiles;
418  try{
419  dbloader.loadHardwareFiles(cfg.smk, ctpfiles, 0x0F, outputFileName("CTPFiles", cfg));
420  } catch (std::format_error & e){
421  cout << " format_error "<<e.what()<<" thrown in TriggerMenuRW.\n";
422  return 1;
423  }
424  ctpfiles.print();
425  }
426 
427  if( cfg.l1psk != 0 ) {
428  // load L1 prescales set from DB
429  TrigConf::TrigDBL1PrescalesSetLoader dbloader(cfg.dbalias);
430  if(!cfg.crestDb.empty()) {
431  dbloader.setCrestTrigDB(cfg.crestDb);
432  dbloader.setCrestConnection(cfg.crestServer, cfg.crestApi);
433  }
435  try {
436  dbloader.loadL1Prescales( cfg.l1psk, l1pss, outputFileName("L1PrescalesSet", cfg) );
437  }
438  catch(TrigConf::IOException & ex) {
439  cout << "Could not load L1 prescales. An exception occurred: " << ex.what() << endl;
440  }
441  if (l1pss) {
442  cout << "Loaded L1 prescales set " << l1pss.name() << " with " << l1pss.size() << " prescales from " << cfg.dbalias << " with L1 PSK " << cfg.l1psk << endl;
443  }
444  }
445 
446  if( cfg.hltpsk != 0 ) {
447  // load L1 prescales set from DB
448  TrigConf::TrigDBHLTPrescalesSetLoader dbloader(cfg.dbalias);
449  if(!cfg.crestDb.empty()) {
450  dbloader.setCrestTrigDB(cfg.crestDb);
451  dbloader.setCrestConnection(cfg.crestServer, cfg.crestApi);
452  }
454  try {
455  dbloader.loadHLTPrescales( cfg.hltpsk, hltpss, outputFileName("HLTPrescalesSet", cfg) );
456  }
457  catch(TrigConf::IOException & ex) {
458  cout << "Could not load HLT prescales. An exception occurred: " << ex.what() << endl;
459  }
460  if (hltpss) {
461  cout << "Loaded HLT prescales set " << hltpss.name() << " with " << hltpss.size() << " prescales from " << cfg.dbalias << " with HLT PSK " << cfg.hltpsk << endl;
462  }
463  }
464 
465  if( cfg.bgsk != 0 ) {
466  // load L1 prescales set from DB
467  TrigConf::TrigDBL1BunchGroupSetLoader dbloader(cfg.dbalias);
468  if(!cfg.crestDb.empty()) {
469  dbloader.setCrestTrigDB(cfg.crestDb);
470  dbloader.setCrestConnection(cfg.crestServer, cfg.crestApi);
471  }
473  try {
474  dbloader.loadBunchGroupSet( cfg.bgsk, bgs, outputFileName("BunchGroupSet", cfg) );
475  }
476  catch(TrigConf::IOException & ex) {
477  cout << "Could not load bunchgroup set. An exception occurred: " << ex.what() << endl;
478  }
479  if (bgs) {
480  cout << "Loaded L1 bunchgroup set " << bgs.name() << " with " << bgs.size() << " bunchgroups from " << cfg.dbalias << " with BGSK " << cfg.bgsk << endl;
481  if( cfg.detail ) {
482  bgs.printSummary(true);
483  }
484  }
485  }
486 
487  return 0;
488 }
TrigConf::DataStructure::getObject
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.
Definition: DataStructure.cxx:207
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
checkxAOD.ds
ds
Definition: Tools/PyUtils/bin/checkxAOD.py:260
TrigConf::HLTMenu::printMenu
void printMenu(bool full=false) const
print overview of L1 Menu
Definition: HLTMenu.cxx:96
TrigConf::HLTMenu
HLT menu configuration.
Definition: HLTMenu.h:21
TrigConf::JsonFileLoader::loadFile
bool loadFile(const std::string &filename, boost::property_tree::ptree &data, const std::string &pathToChild="") const
Load content of json file into a ptree.
Definition: JsonFileLoader.cxx:45
TrigConf::HLTMonitoring::size
std::size_t size() const
Accessor to the number of HLT monitoring chains.
Definition: HLTMonitoring.cxx:82
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
TrigConf::DataStructure::getKeys
std::vector< std::string > getKeys() const
Access to the keys of an DataStructure which presents a dictionary.
Definition: DataStructure.cxx:250
TrigConf::DataStructure::name
virtual const std::string & name() const final
Definition: DataStructure.cxx:109
TrigConf::L1CTPFiles
L1 menu configuration.
Definition: L1CTPFiles.h:29
TrigConf::HLTPrescalesSet::size
std::size_t size() const
number of HLT prescales
Definition: HLTPrescalesSet.cxx:69
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:79
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
TrigConf::L1BunchGroupSet::size
std::size_t size() const
Accessor to the number of defined bunchgroups.
Definition: L1BunchGroupSet.cxx:128
TrigConf::L1BunchGroupSet::sizeNonEmpty
std::size_t sizeNonEmpty() const
Accessor to the number of non-empty bunchgroups.
Definition: L1BunchGroupSet.cxx:133
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:19
TrigConf::JsonFileLoader::getFileType
std::string getFileType(const std::string &filename) const
Checks the trigger level of a given json file.
Definition: JsonFileLoader.cxx:114
TrigConf::L1BunchGroupSet
L1 board configuration.
Definition: L1BunchGroupSet.h:71
TrigConf::TrigDBMonitoringLoader
Loader of trigger menu configurations from the database.
Definition: TrigDBMonitoringLoader.h:25
TrigConf::L1PrescalesSet
L1 menu configuration.
Definition: L1PrescalesSet.h:19
TrigConf::L1BunchGroupSet::printSummary
void printSummary(bool detailed=false) const
print a more or less detailed summary
Definition: L1BunchGroupSet.cxx:150
TrigConf::HLTMenu::size
std::size_t size() const
Accessor to the number of HLT chains.
Definition: HLTMenu.cxx:35
TrigConf::HLTPrescalesSet::printPrescaleSet
void printPrescaleSet(bool full) const
Definition: HLTPrescalesSet.cxx:116
TrigConf::TrigDBJobOptionsLoader
Loader of trigger configurations from Json files.
Definition: TrigDBJobOptionsLoader.h:28
TrigConf::TrigDBCTPFilesLoader
Loader of trigger configurations from Json files.
Definition: TrigDBCTPFilesLoader.h:30
RegSelToolConfig.alg
alg
Definition: RegSelToolConfig.py:332
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
TrigConf::DataStructure
Base class for Trigger configuration data and wrapper around underlying representation.
Definition: DataStructure.h:37
TrigConf::HLTMonitoring
HLT monitoring configuration.
Definition: HLTMonitoring.h:27
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:66
TrigConf::HLTMonitoring::printMonConfig
void printMonConfig(bool full=false) const
print overview of L1 Menu
Definition: HLTMonitoring.cxx:104
TrigConf::L1PrescalesSet::size
std::size_t size() const
number of L1 prescales
Definition: L1PrescalesSet.cxx:38
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
TrigConf::IOException::what
virtual const char * what() const noexcept
Definition: Trigger/TrigConfiguration/TrigConfIO/src/Exceptions.cxx:7
TrigConf::TrigDBHLTPrescalesSetLoader
Loader of trigger configurations from Json files.
Definition: TrigDBHLTPrescalesSetLoader.h:23
TrigConf::JsonFileLoader
Loader of trigger configurations from Json files.
Definition: JsonFileLoader.h:25
TrigConf::IOException
Definition: Trigger/TrigConfiguration/TrigConfIO/TrigConfIO/Exceptions.h:13
TrigConf::TrigDBMenuLoader
Loader of trigger menu configurations from the database.
Definition: TrigDBMenuLoader.h:30
TrigConf::HLTPrescalesSet
HLT menu configuration.
Definition: HLTPrescalesSet.h:19
AthenaPoolExample_Copy.outputFileName
string outputFileName
Definition: AthenaPoolExample_Copy.py:40
TrigConf::TrigDBL1PrescalesSetLoader
Loader of trigger configurations from Json files.
Definition: TrigDBL1PrescalesSetLoader.h:24
TrigConf::TrigDBL1BunchGroupSetLoader
Loader of trigger configurations from Json files.
Definition: TrigDBL1BunchGroupSetLoader.h:24
TrigConf::L1CTPFiles::print
void print() const
Definition: L1CTPFiles.cxx:25