ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrigConf::JobOptionsSvc Class Reference

JobOptionsSvc for the HLT. More...

#include <TrigConfJobOptionsSvc.h>

Inheritance diagram for TrigConf::JobOptionsSvc:
Collaboration diagram for TrigConf::JobOptionsSvc:

Public Member Functions

 JobOptionsSvc (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual StatusCode initialize () override
 
virtual StatusCode start () override
 
TrigConf::IJobOptionsSvc interface

Configuration keys as provided during the job initialization

virtual const std::string & server () const override
 DB connection alias. More...
 
virtual int superMasterKey () const override
 Return SMK (-1 if not set) More...
 
virtual int l1PrescaleKey () const override
 Return L1PSK (-1 if not set) More...
 
virtual int hltPrescaleKey () const override
 Return HLTPSK (-1 if not set) More...
 

Private Member Functions

StatusCode dumpOptions (const std::string &file)
 This is mainly for debugging purposes and to compare the JobOptions as seen by the JobOptionSvc to the ones extracted directly in Python. More...
 
StatusCode readOptionsJson (const std::string &file)
 
StatusCode readOptionsDB (const std::string &db_server, int smk)
 
void parseDBString (const std::string &s)
 Parse DB connection string and fill private members. More...
 

Private Attributes

int m_smk {-1}
 SuperMasterKey. More...
 
int m_l1psk {-1}
 L1 prescale key. More...
 
int m_hltpsk {-1}
 HLT prescale key. More...
 
std::string m_server
 DB connection alias. More...
 
Gaudi::Property< std::string > m_sourceType {this, "TYPE", "NONE", "Configuration type (NONE, FILE, DB)"}
 
Gaudi::Property< std::string > m_sourcePath {this, "PATH", {}, "Path for NONE/FILE, connection string for DB"}
 
Gaudi::Property< std::string > m_searchPath {this, "SEARCHPATH", {}, "NOT SUPPORTED"}
 
Gaudi::Property< std::string > m_dump {this, "DUMPFILE", {}, "Dump job properties into JSON file"}
 
ServiceHandle< Gaudi::Interfaces::IOptionsSvc > m_optsvc
 handle to the "real" IOptionsSvc More...
 

IOptionsSvc interface

using OnlyDefaults = Gaudi::Interfaces::IOptionsSvc::OnlyDefaults
 
virtual void set (const std::string &key, const std::string &value) override
 
virtual std::string get (const std::string &key, const std::string &default_={}) const override
 
virtual std::string pop (const std::string &key, const std::string &default_={}) override
 
virtual bool has (const std::string &key) const override
 
virtual bool isSet (const std::string &key) const override
 
virtual std::vector< std::tuple< std::string, std::string > > items () const override
 
virtual void bind (const std::string &prefix, Gaudi::Details::PropertyBase *property) override
 
virtual void broadcast (const std::regex &filter, const std::string &value, OnlyDefaults defaults=OnlyDefaults{true}) override
 
virtual StatusCode readOptions (std::string_view, std::string_view) override
 

Detailed Description

JobOptionsSvc for the HLT.

This implementation of IJobOptionSvc wraps the regular JobOptionSvc and forwards most of the calls directly to it. Beyond this it provides the ability to read the job configuration from JSON (file or DB) and create a JSON dump of all configured properties when running from Python.

The job property source is specified by the TYPE property:

Definition at line 33 of file TrigConfJobOptionsSvc.h.

Member Typedef Documentation

◆ OnlyDefaults

using TrigConf::JobOptionsSvc::OnlyDefaults = Gaudi::Interfaces::IOptionsSvc::OnlyDefaults

Definition at line 79 of file TrigConfJobOptionsSvc.h.

Constructor & Destructor Documentation

◆ JobOptionsSvc()

TrigConf::JobOptionsSvc::JobOptionsSvc ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 17 of file TrigConfJobOptionsSvc.cxx.

17  :
18  base_class(name, pSvcLocator),
19  m_optsvc("JobOptionsSvc/TrigConfWrapped_JobOptionsSvc", name)
20 {}

Member Function Documentation

◆ bind()

virtual void TrigConf::JobOptionsSvc::bind ( const std::string &  prefix,
Gaudi::Details::PropertyBase *  property 
)
inlineoverridevirtual

Definition at line 74 of file TrigConfJobOptionsSvc.h.

75  {
76  return m_optsvc->bind(prefix,property);
77  }

◆ broadcast()

virtual void TrigConf::JobOptionsSvc::broadcast ( const std::regex &  filter,
const std::string &  value,
OnlyDefaults  defaults = OnlyDefaults{true} 
)
inlineoverridevirtual

Definition at line 80 of file TrigConfJobOptionsSvc.h.

81  {true} ) override
82  {
83  return m_optsvc->broadcast(filter, value, defaults);
84  }

◆ dumpOptions()

StatusCode TrigConf::JobOptionsSvc::dumpOptions ( const std::string &  file)
private

This is mainly for debugging purposes and to compare the JobOptions as seen by the JobOptionSvc to the ones extracted directly in Python.

Definition at line 132 of file TrigConfJobOptionsSvc.cxx.

133 {
134  // JSON filetype identifier
135  nlohmann::json json_file;
136  json_file["filetype"] = "joboptions";
137 
138  // Properties
139  auto& json = json_file["properties"] = {};
140  for (const auto& [name, value] : items()) {
141  const size_t idot = name.rfind('.');
142  const std::string client = name.substr(0, idot);
143  const std::string propname = name.substr(idot+1);
144  json[client][propname] = value;
145  }
146 
147  // Write JSON to file
148  std::ofstream o(file);
149  if (!o) {
150  ATH_MSG_ERROR("Cannot write to file " << file);
151  return StatusCode::FAILURE;
152  }
153  o << std::setw(4) << json_file << std::endl;
154 
155  return StatusCode::SUCCESS;
156 }

◆ get()

virtual std::string TrigConf::JobOptionsSvc::get ( const std::string &  key,
const std::string &  default_ = {} 
) const
inlineoverridevirtual

Definition at line 49 of file TrigConfJobOptionsSvc.h.

49  {} ) const override
50  {
51  return m_optsvc->get(key,default_);
52  }

◆ has()

virtual bool TrigConf::JobOptionsSvc::has ( const std::string &  key) const
inlineoverridevirtual

Definition at line 59 of file TrigConfJobOptionsSvc.h.

60  {
61  return m_optsvc->has(key);
62  }

◆ hltPrescaleKey()

virtual int TrigConf::JobOptionsSvc::hltPrescaleKey ( ) const
inlineoverridevirtual

Return HLTPSK (-1 if not set)

Definition at line 97 of file TrigConfJobOptionsSvc.h.

◆ initialize()

StatusCode TrigConf::JobOptionsSvc::initialize ( )
overridevirtual

Definition at line 22 of file TrigConfJobOptionsSvc.cxx.

23 {
24  ATH_MSG_INFO("Initializing TrigConf::JobOptionsSvc");
25 
26  // Configure the wrapped JobOptionsSvc
27  ATH_CHECK(m_optsvc.retrieve());
28  m_optsvc->set( m_optsvc.name() + ".TYPE", "NONE" );
29 
30  if (m_sourceType == "FILE") {
31  ATH_MSG_INFO("Reading joboptions from " << m_sourcePath.value());
33  }
34  else if (m_sourceType == "DB") {
36  ATH_MSG_INFO("Reading SMK " << m_smk << " from '" << m_server << "'");
38  }
39  else if (m_sourceType == "PYTHON") {
40  /* "PYTHON" refers to loading properties directly from Python files
41  which we do not use in ATLAS. Configuration via athena.py is of
42  course supported by the default "NONE" mode. */
43  ATH_MSG_ERROR("Not supported " << m_sourceType);
44  return StatusCode::FAILURE;
45  }
46 
47  return StatusCode::SUCCESS;
48 }

◆ isSet()

virtual bool TrigConf::JobOptionsSvc::isSet ( const std::string &  key) const
inlineoverridevirtual

Definition at line 64 of file TrigConfJobOptionsSvc.h.

65  {
66  return m_optsvc->isSet(key);
67  }

◆ items()

virtual std::vector<std::tuple<std::string, std::string> > TrigConf::JobOptionsSvc::items ( ) const
inlineoverridevirtual

Definition at line 69 of file TrigConfJobOptionsSvc.h.

70  {
71  return m_optsvc->items();
72  }

◆ l1PrescaleKey()

virtual int TrigConf::JobOptionsSvc::l1PrescaleKey ( ) const
inlineoverridevirtual

Return L1PSK (-1 if not set)

Definition at line 96 of file TrigConfJobOptionsSvc.h.

◆ parseDBString()

void TrigConf::JobOptionsSvc::parseDBString ( const std::string &  s)
private

Parse DB connection string and fill private members.

Format: server=TRIGGERDB;smkey=42;lvl1key=43;hltkey=44

Definition at line 54 of file TrigConfJobOptionsSvc.cxx.

55 {
56  std::string key, val;
57  std::istringstream iss(s);
58  while (std::getline(std::getline(iss, key, '='), val, ';')) {
61  if (key == "smkey")
62  m_smk = std::stoi(val);
63  else if (key == "server")
64  m_server = val;
65  else if (key == "lvl1key")
66  m_l1psk = std::stoi(val);
67  else if (key == "hltkey")
68  m_hltpsk = std::stoi(val);
69  }
70 }

◆ pop()

virtual std::string TrigConf::JobOptionsSvc::pop ( const std::string &  key,
const std::string &  default_ = {} 
)
inlineoverridevirtual

Definition at line 54 of file TrigConfJobOptionsSvc.h.

54  {} ) override
55  {
56  return m_optsvc->pop(key,default_);
57  }

◆ readOptions()

virtual StatusCode TrigConf::JobOptionsSvc::readOptions ( std::string_view  ,
std::string_view   
)
inlineoverridevirtual

Definition at line 86 of file TrigConfJobOptionsSvc.h.

87  {
88  throw std::runtime_error("TrigConf::JobOptionsSvc::readOptions() is not supported");
89  }

◆ readOptionsDB()

StatusCode TrigConf::JobOptionsSvc::readOptionsDB ( const std::string &  db_server,
int  smk 
)
private

Definition at line 102 of file TrigConfJobOptionsSvc.cxx.

103 {
104  // db job options loader
105  TrigConf::TrigDBJobOptionsLoader jodbloader(db_server);
106 
108  jodbloader.loadJobOptions( smk, jo );
109  if (jo) {
110  unsigned int nClients(0), nProps(0);
111  TrigConf::DataStructure ds = jo.getObject("properties");
112  for( const auto & client : ds.data()) {
113  nClients++;
114  for( const auto & property : client.second ) {
115  nProps++;
116  set(client.first + "." + property.first, property.second.data());
117  }
118  }
119  ATH_MSG_INFO("Loaded job options from " << nClients << " clients with " << nProps << " in total");
120  } else {
121  ATH_MSG_FATAL("Could not load job options from database " << db_server << " with SMK " << smk);
122  return StatusCode::FAILURE;
123  }
124  return StatusCode::SUCCESS;
125 }

◆ readOptionsJson()

StatusCode TrigConf::JobOptionsSvc::readOptionsJson ( const std::string &  file)
private

Definition at line 82 of file TrigConfJobOptionsSvc.cxx.

83 {
84  std::ifstream f(file);
85  if (!f) {
86  ATH_MSG_ERROR("Cannot open file " << file);
87  return StatusCode::FAILURE;
88  }
89 
91  f >> json;
92 
93  for (const auto& [client, props] : json["properties"].items()) {
94  for (const auto& [name, value] : props.items()) {
95  set(client + "." + name, value.get<std::string>());
96  }
97  }
98 
99  return StatusCode::SUCCESS;
100 }

◆ server()

virtual const std::string& TrigConf::JobOptionsSvc::server ( ) const
inlineoverridevirtual

DB connection alias.

Definition at line 94 of file TrigConfJobOptionsSvc.h.

◆ set()

virtual void TrigConf::JobOptionsSvc::set ( const std::string &  key,
const std::string &  value 
)
inlineoverridevirtual

Definition at line 44 of file TrigConfJobOptionsSvc.h.

45  {
46  return m_optsvc->set(key,value);
47  }

◆ start()

StatusCode TrigConf::JobOptionsSvc::start ( )
overridevirtual

Definition at line 72 of file TrigConfJobOptionsSvc.cxx.

73 {
74  // Dump job options to JSON file if configured (for debugging only!)
75  if (!m_dump.empty()) {
76  ATH_MSG_INFO("Writing job options to " << m_dump.value());
77  dumpOptions(m_dump).ignore();
78  }
79  return StatusCode::SUCCESS;
80 }

◆ superMasterKey()

virtual int TrigConf::JobOptionsSvc::superMasterKey ( ) const
inlineoverridevirtual

Return SMK (-1 if not set)

Definition at line 95 of file TrigConfJobOptionsSvc.h.

Member Data Documentation

◆ m_dump

Gaudi::Property<std::string> TrigConf::JobOptionsSvc::m_dump {this, "DUMPFILE", {}, "Dump job properties into JSON file"}
private

Definition at line 115 of file TrigConfJobOptionsSvc.h.

◆ m_hltpsk

int TrigConf::JobOptionsSvc::m_hltpsk {-1}
private

HLT prescale key.

Definition at line 108 of file TrigConfJobOptionsSvc.h.

◆ m_l1psk

int TrigConf::JobOptionsSvc::m_l1psk {-1}
private

L1 prescale key.

Definition at line 107 of file TrigConfJobOptionsSvc.h.

◆ m_optsvc

ServiceHandle<Gaudi::Interfaces::IOptionsSvc> TrigConf::JobOptionsSvc::m_optsvc
private

handle to the "real" IOptionsSvc

Definition at line 118 of file TrigConfJobOptionsSvc.h.

◆ m_searchPath

Gaudi::Property<std::string> TrigConf::JobOptionsSvc::m_searchPath {this, "SEARCHPATH", {}, "NOT SUPPORTED"}
private

Definition at line 114 of file TrigConfJobOptionsSvc.h.

◆ m_server

std::string TrigConf::JobOptionsSvc::m_server
private

DB connection alias.

Definition at line 109 of file TrigConfJobOptionsSvc.h.

◆ m_smk

int TrigConf::JobOptionsSvc::m_smk {-1}
private

SuperMasterKey.

Definition at line 106 of file TrigConfJobOptionsSvc.h.

◆ m_sourcePath

Gaudi::Property<std::string> TrigConf::JobOptionsSvc::m_sourcePath {this, "PATH", {}, "Path for NONE/FILE, connection string for DB"}
private

Definition at line 113 of file TrigConfJobOptionsSvc.h.

◆ m_sourceType

Gaudi::Property<std::string> TrigConf::JobOptionsSvc::m_sourceType {this, "TYPE", "NONE", "Configuration type (NONE, FILE, DB)"}
private

Definition at line 112 of file TrigConfJobOptionsSvc.h.


The documentation for this class was generated from the following files:
TrigConf::DataStructure::getObject
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.
Definition: DataStructure.cxx:207
TrigConf::JobOptionsSvc::items
virtual std::vector< std::tuple< std::string, std::string > > items() const override
Definition: TrigConfJobOptionsSvc.h:69
checkxAOD.ds
ds
Definition: Tools/PyUtils/bin/checkxAOD.py:260
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
json
nlohmann::json json
Definition: HistogramDef.cxx:9
RunEBWeightsComputation.smk
smk
Definition: RunEBWeightsComputation.py:87
TrigConf::JobOptionsSvc::readOptionsJson
StatusCode readOptionsJson(const std::string &file)
Definition: TrigConfJobOptionsSvc.cxx:82
TrigConf::JobOptionsSvc::readOptionsDB
StatusCode readOptionsDB(const std::string &db_server, int smk)
Definition: TrigConfJobOptionsSvc.cxx:102
TrigConf::JobOptionsSvc::m_dump
Gaudi::Property< std::string > m_dump
Definition: TrigConfJobOptionsSvc.h:115
TrigConf::JobOptionsSvc::m_smk
int m_smk
SuperMasterKey.
Definition: TrigConfJobOptionsSvc.h:106
TrigConf::JobOptionsSvc::m_sourcePath
Gaudi::Property< std::string > m_sourcePath
Definition: TrigConfJobOptionsSvc.h:113
athena.value
value
Definition: athena.py:124
TrigConf::JobOptionsSvc::m_sourceType
Gaudi::Property< std::string > m_sourceType
Definition: TrigConfJobOptionsSvc.h:112
TrigConf::JobOptionsSvc::m_l1psk
int m_l1psk
L1 prescale key.
Definition: TrigConfJobOptionsSvc.h:107
rerun_display.client
client
Definition: rerun_display.py:31
covarianceTool.filter
filter
Definition: covarianceTool.py:514
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigConf::JobOptionsSvc::set
virtual void set(const std::string &key, const std::string &value) override
Definition: TrigConfJobOptionsSvc.h:44
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
file
TFile * file
Definition: tile_monitor.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:135
TrigConf::JobOptionsSvc::m_server
std::string m_server
DB connection alias.
Definition: TrigConfJobOptionsSvc.h:109
TrigConf::TrigDBJobOptionsLoader
Loader of trigger configurations from Json files.
Definition: TrigDBJobOptionsLoader.h:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigConf::JobOptionsSvc::dumpOptions
StatusCode dumpOptions(const std::string &file)
This is mainly for debugging purposes and to compare the JobOptions as seen by the JobOptionSvc to th...
Definition: TrigConfJobOptionsSvc.cxx:132
Base_Fragment.defaults
dictionary defaults
This includes now the top quark, the leptons and the bosons.
Definition: GeneratorFilters/share/common/Base_Fragment.py:79
TrigConf::DataStructure
Base class for Trigger configuration data and wrapper around underlying representation.
Definition: DataStructure.h:37
TrigConf::JobOptionsSvc::m_hltpsk
int m_hltpsk
HLT prescale key.
Definition: TrigConfJobOptionsSvc.h:108
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
GRLStrUtil::trim
void trim(std::string &input)
Definition: StrUtil.cxx:12
TrigConf::JobOptionsSvc::m_optsvc
ServiceHandle< Gaudi::Interfaces::IOptionsSvc > m_optsvc
handle to the "real" IOptionsSvc
Definition: TrigConfJobOptionsSvc.h:118
TrigConf::JobOptionsSvc::parseDBString
void parseDBString(const std::string &s)
Parse DB connection string and fill private members.
Definition: TrigConfJobOptionsSvc.cxx:54
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37