 |
ATLAS Offline Software
|
Go to the documentation of this file.
7 #include "GaudiKernel/IProperty.h"
8 #include "Gaudi/Property.h"
13 #include <nlohmann/json.hpp>
20 void trim_inplace(std::string&
s) {
21 auto start = std::find_if_not(
s.begin(),
s.end(), ::isspace);
22 auto end = std::find_if_not(
s.rbegin(),
s.rend(), ::isspace).base();
28 base_class(
name, pSvcLocator),
29 m_optsvc(
"JobOptionsSvc/TrigConfWrapped_JobOptionsSvc",
name)
38 m_optsvc->set( m_optsvc.name() +
".TYPE",
"NONE" );
40 if (m_sourceType ==
"FILE") {
41 ATH_MSG_INFO(
"Reading joboptions from " << m_sourcePath.value());
44 else if (m_sourceType ==
"DB") {
45 parseDBString(m_sourcePath);
46 ATH_MSG_INFO(
"Reading SMK " << m_smk <<
" from '" << m_server <<
"'");
47 ATH_CHECK(readOptionsDB(m_server, m_smk));
49 else if (m_sourceType ==
"PYTHON") {
54 return StatusCode::FAILURE;
57 return StatusCode::SUCCESS;
68 std::istringstream iss(
s);
69 while (std::getline(std::getline(iss,
key,
'='),
val,
';')) {
73 m_smk = std::stoi(
val);
74 else if (
key ==
"server")
76 else if (
key ==
"lvl1key")
77 m_l1psk = std::stoi(
val);
78 else if (
key ==
"hltkey")
79 m_hltpsk = std::stoi(
val);
86 if (!m_dump.empty()) {
87 ATH_MSG_INFO(
"Writing job options to " << m_dump.value());
88 dumpOptions(m_dump).ignore();
90 return StatusCode::SUCCESS;
95 std::ifstream
f(
file);
98 return StatusCode::FAILURE;
105 for (
const auto& [
name,
value] : props.items()) {
110 return StatusCode::SUCCESS;
118 std::string crest_api(
"");
128 unsigned int nClients(0), nProps(0);
130 for(
const auto &
client :
ds.data()) {
132 for(
const auto & property :
client.second ) {
134 set(
client.first +
"." + property.first, property.second.data());
137 ATH_MSG_INFO(
"Loaded job options from " << nClients <<
" clients with " << nProps <<
" in total");
139 ATH_MSG_FATAL(
"Could not load job options from database " << db_server <<
" with SMK " <<
smk);
140 return StatusCode::FAILURE;
142 return StatusCode::SUCCESS;
154 json_file[
"filetype"] =
"joboptions";
157 auto&
json = json_file[
"properties"] = {};
159 const size_t idot =
name.rfind(
'.');
160 const std::string
client =
name.substr(0, idot);
161 const std::string propname =
name.substr(idot+1);
166 std::ofstream o(
file);
169 return StatusCode::FAILURE;
171 o << std::setw(4) << json_file << std::endl;
173 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.
void setCrestConnection(const std::string &server, const std::string &version="")
declare CREST as the source of the configuration An empty crest server makes it use Oracle
JobOptionsSvc(const std::string &name, ISvcLocator *pSvcLocator)
::StatusCode StatusCode
StatusCode definition for legacy code.
void setCrestTrigDB(const std::string &crestTrigDB)
set trigger db for the crest connection
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 job options from the Trigger DB into a ptree for a given SuperMasterKey (SMK)
bool isCrestConnection(const std::string &db_connection_string, std::string &crest_server, std::string &crest_api, std::string &dbname)
Function to interpret the trigger connection string for CREST connections Format of the connections s...
void parseDBString(const std::string &s)
Parse DB connection string and fill private members.