|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #include <boost/algorithm/string.hpp>
7 #include <nlohmann/json.hpp>
9 #include "GaudiKernel/IProperty.h"
10 #include "Gaudi/Property.h"
18 base_class(
name, pSvcLocator),
19 m_optsvc(
"JobOptionsSvc/TrigConfWrapped_JobOptionsSvc",
name)
28 m_optsvc->set( m_optsvc.name() +
".TYPE",
"NONE" );
30 if (m_sourceType ==
"FILE") {
31 ATH_MSG_INFO(
"Reading joboptions from " << m_sourcePath.value());
34 else if (m_sourceType ==
"DB") {
35 parseDBString(m_sourcePath);
36 ATH_MSG_INFO(
"Reading SMK " << m_smk <<
" from '" << m_server <<
"'");
37 ATH_CHECK(readOptionsDB(m_server, m_smk));
39 else if (m_sourceType ==
"PYTHON") {
44 return StatusCode::FAILURE;
47 return StatusCode::SUCCESS;
57 std::istringstream iss(
s);
58 while (std::getline(std::getline(iss,
key,
'='),
val,
';')) {
62 m_smk = std::stoi(
val);
63 else if (
key ==
"server")
65 else if (
key ==
"lvl1key")
66 m_l1psk = std::stoi(
val);
67 else if (
key ==
"hltkey")
68 m_hltpsk = std::stoi(
val);
75 if (!m_dump.empty()) {
76 ATH_MSG_INFO(
"Writing job options to " << m_dump.value());
77 dumpOptions(m_dump).ignore();
79 return StatusCode::SUCCESS;
84 std::ifstream
f(
file);
87 return StatusCode::FAILURE;
94 for (
const auto& [
name,
value] : props.items()) {
99 return StatusCode::SUCCESS;
110 unsigned int nClients(0), nProps(0);
112 for(
const auto &
client :
ds.data()) {
114 for(
const auto & property :
client.second ) {
116 set(
client.first +
"." + property.first, property.second.data());
119 ATH_MSG_INFO(
"Loaded job options from " << nClients <<
" clients with " << nProps <<
" in total");
121 ATH_MSG_FATAL(
"Could not load job options from database " << db_server <<
" with SMK " <<
smk);
122 return StatusCode::FAILURE;
124 return StatusCode::SUCCESS;
136 json_file[
"filetype"] =
"joboptions";
139 auto&
json = json_file[
"properties"] = {};
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);
148 std::ofstream o(
file);
151 return StatusCode::FAILURE;
153 o << std::setw(4) << json_file << std::endl;
155 return StatusCode::SUCCESS;
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.
StatusCode readOptionsJson(const std::string &file)
virtual StatusCode initialize() override
StatusCode readOptionsDB(const std::string &db_server, int smk)
Loader class for Trigger configuration from the Trigger DB.
JobOptionsSvc(const std::string &name, ISvcLocator *pSvcLocator)
::StatusCode StatusCode
StatusCode definition for legacy code.
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Loader of trigger configurations from Json files.
virtual StatusCode start() override
StatusCode dumpOptions(const std::string &file)
This is mainly for debugging purposes and to compare the JobOptions as seen by the JobOptionSvc to th...
Base class for Trigger configuration data and wrapper around underlying representation.
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 parseDBString(const std::string &s)
Parse DB connection string and fill private members.