Loader of trigger configurations from Json files.
More...
#include <TrigDBL1PrescalesSetLoader.h>
|
| bool | useCrest () const |
| std::string | getTrigDataCrest (const std::string &type, int key) const |
| | Get trigger configuration from the TriggerDB through Crest.
|
| std::unique_ptr< coral::ISessionProxy > | createDBSession () const |
| | create (if needed) DB session and return the session proxy
|
| QueryDefinition | getQueryDefinition (size_t schemaVersion, const std::map< size_t, QueryDefinition > &queries) const |
| | return query for given schemaVersion from possible queries
|
| void | loadFromCrest (unsigned int key, boost::property_tree::ptree &pt, const std::string &outFileName, const std::string &description, const std::string &query_type) const |
| void | loadFromOracle (unsigned int key, boost::property_tree::ptree &pt, const std::string &outFileName, const std::string &description, const std::map< size_t, QueryDefinition > &queries) const |
Loader of trigger configurations from Json files.
Definition at line 24 of file TrigDBL1PrescalesSetLoader.h.
◆ TrigDBL1PrescalesSetLoader()
| TrigConf::TrigDBL1PrescalesSetLoader::TrigDBL1PrescalesSetLoader |
( |
const std::string & | connection | ) |
|
Constructor.
Definition at line 6 of file TrigDBL1PrescalesSetLoader.cxx.
6 :
8{
9 {
11
12 q.addToTableList (
"L1_PRESCALE_SET" );
13
14 q.extendBinding<
int>(
"key");
15
16 q.extendCondition(
"L1PS_ID = :key");
17
18 q.extendOutput<coral::Blob>(
"L1PS_DATA" );
19
20 q.setDataName(
"L1PS_DATA");
21 }
22}
std::map< size_t, QueryDefinition > m_queries
TrigDBLoader(const std::string &loaderName, const std::string &connection)
Constructor.
◆ ~TrigDBL1PrescalesSetLoader()
| TrigConf::TrigDBL1PrescalesSetLoader::~TrigDBL1PrescalesSetLoader |
( |
| ) |
|
|
overridevirtualdefault |
Destructor - cannot be defined here because QueryDefinition is an incomplete type.
◆ createDBSession()
| std::unique_ptr< coral::ISessionProxy > TrigConf::TrigDBLoader::createDBSession |
( |
| ) |
const |
|
protectedinherited |
create (if needed) DB session and return the session proxy
Definition at line 107 of file TrigDBLoader.cxx.
107 {
108
109 coral::ConnectionService connSvc;
110 coral::IConnectionServiceConfiguration& csc = connSvc.configuration();
114
115
116
117
118
119
120
121
122
124
125 auto proxy = std::unique_ptr<coral::ISessionProxy>( connSvc.connect(
m_connection, coral::AccessMode::ReadOnly) );
126
129
131}
◆ getName()
| const std::string & TrigConf::TrigConfMessaging::getName |
( |
| ) |
const |
|
inlineinherited |
◆ getQueryDefinition()
return query for given schemaVersion from possible queries
Definition at line 174 of file TrigDBLoader.cxx.
176{
177
178 size_t maxDefVersion = 0;
179 for(auto & entry : queries) {
180 size_t vkey =
entry.first;
182 maxDefVersion = vkey;
183 }
184 }
185
186 if( maxDefVersion==0 ) {
188 throw TrigConf::NoQueryException(std::format(
"No query available for schema version {}",
schemaVersion));
189 }
190 return queries.at(maxDefVersion);
191}
size_t schemaVersion(coral::ISessionProxy *session) const
access to TriggerDB schema version
◆ getTrigDataCrest()
| std::string TrigConf::TrigDBLoader::getTrigDataCrest |
( |
const std::string & | type, |
|
|
int | key ) const |
|
protectedinherited |
Get trigger configuration from the TriggerDB through Crest.
- Parameters
-
| type | The type of trigger configuration data to access
- L1PS => L1 prescale (with L1PS key)
- HLTPS => HLT prescale (with HLTPS key)
- L1M => L1 menu (with SMK)
- HLTM => HLT menu (with SMK)
- JO => Job options (with SMK)
- BGS => bunch group set (with BGS key)
- MGS => monitoring group (with SMK)
|
| key | The trigger key |
Definition at line 134 of file TrigDBLoader.cxx.
134 {
135
136
137
138
139
140
141
142
143
144
147
148#if 0
149
150
151
152
153
154
155 Crest::CrestApi capi = Crest::CrestApi(url);
156 std::string
payload = capi.getPayload(query);
157#else
158
159
160
161
162
163 Crest::CrestRequest request = Crest::CrestRequest();
164 request.setUrl(url);
165 std::string current_path =
"payloads/data?format=BLOB&hash=" +
query;
166 nlohmann::json
js =
nullptr;
167 std::string
payload = request.performRequest(current_path, Crest::Action::GET, js,
"TrigDbLoader");
168#endif
169
171}
std::string m_crestVersion
std::string m_crestTrigDb
std::string m_crestServer
◆ loadFromCrest()
| void TrigConf::TrigDBLoader::loadFromCrest |
( |
unsigned int | key, |
|
|
boost::property_tree::ptree & | pt, |
|
|
const std::string & | outFileName, |
|
|
const std::string & | description, |
|
|
const std::string & | query_type ) const |
|
protectedinherited |
Definition at line 194 of file TrigDBLoader.cxx.
197{
199 try {
201 }
202 catch(Crest::CrestException & ex) {
203 TRG_MSG_ERROR(
"When reading " <<
description <<
" for key " << key <<
" from crest a CrestException was caught ( " << ex.what() <<
" )" );
204 throw TrigConf::CrestLoadingException(std::format(
"{}: {}",
getName(), ex.what()));
205 }
209 }
210 try {
212 }
213 catch(boost::property_tree::json_parser_error & ex) {
214 TRG_MSG_ERROR(
"When reading " <<
description <<
" for key " << key <<
" from crest a ptree json parser error was caught ( " << ex.what() <<
" )" );
215 throw TrigConf::JsonParsingException(std::format(
"{}: {}",
getName(), ex.what()));
216 }
217}
const std::string & getName() const
name accessor
std::string getTrigDataCrest(const std::string &type, int key) const
Get trigger configuration from the TriggerDB through Crest.
std::string description
glabal timer - how long have I taken so far?
void stringToPtree(const std::string &json_string, boost::property_tree::ptree &pt)
void writeRawFile(const coral::Blob &data, const std::string &outFileName)
write coral data blob to file
◆ loadFromOracle()
| void TrigConf::TrigDBLoader::loadFromOracle |
( |
unsigned int | key, |
|
|
boost::property_tree::ptree & | pt, |
|
|
const std::string & | outFileName, |
|
|
const std::string & | description, |
|
|
const std::map< size_t, QueryDefinition > & | queries ) const |
|
protectedinherited |
Definition at line 220 of file TrigDBLoader.cxx.
223{
225 session->transaction().start( true);
228 try {
229 qdef.setBoundValue<
int>(
"key",
key);
230 auto q = qdef.createQuery( session.get() );
234 throw TrigConf::NoKeyException(std::format(
"{}: key {} not available",
getName(), key));
235 }
236 const coral::AttributeList&
row =
cursor.currentRow();
237 const coral::Blob& dataBlob =
row[qdef.dataName()].data<coral::Blob>();
238
242 }
244 }
245 catch(coral::QueryException & ex) {
246 TRG_MSG_ERROR(
"When reading " <<
description <<
" for key " << key <<
" a coral::QueryException was caught ( " << ex.what() <<
" )" );
247 throw TrigConf::QueryException(std::format(
"{}: {}",
getName(), ex.what()));
248 }
249 catch(boost::property_tree::json_parser_error & ex) {
250 TRG_MSG_ERROR(
"When reading " <<
description <<
" for key " << key <<
" a ptree json parser error was caught ( " << ex.what() <<
" )" );
251 throw TrigConf::JsonParsingException(std::format(
"{}: {}",
getName(), ex.what()));
252 }
253}
std::unique_ptr< coral::ISessionProxy > createDBSession() const
create (if needed) DB session and return the session proxy
QueryDefinition getQueryDefinition(size_t schemaVersion, const std::map< size_t, QueryDefinition > &queries) const
return query for given schemaVersion from possible queries
row
Appending html table to final .html summary file.
void blobToPtree(const coral::Blob &blob, boost::property_tree::ptree &pt)
◆ loadL1Prescales()
| bool TrigConf::TrigDBL1PrescalesSetLoader::loadL1Prescales |
( |
unsigned int | l1psk, |
|
|
TrigConf::L1PrescalesSet & | pss, |
|
|
const std::string & | outFileName = "" ) const |
Load content from the Trigger DB into an L1PrescalesSet for a given L1PrescaleKey (L1PSK)
- Parameters
-
| l1psk | [in] the L1PSK that should be loaded |
| l1pss | [out] the loaded L1PrescalesSet |
| outFileName | [in] name of file to write out the loaded data (optional, by default no file will be written) |
- Returns
- true if loading (and optional writing) was successfull
Definition at line 28 of file TrigDBL1PrescalesSetLoader.cxx.
30{
31
32 boost::property_tree::ptree
pt;
35 } else {
37 }
38
39
40 try {
43 }
44 catch(std::exception & ex) {
46 TRG_MSG_ERROR(
"When reading L1 prescales for L1 PSK " << psk <<
" a parsing error occured ( " << ex.what() <<
" )" );
47 throw TrigConf::ParsingException("TrigDBL1PrescalesSetLoader: parsing error " + std::string(ex.what()));
48 }
49
50 return true;
51}
void setData(const ptree &data)
Setting the configuration data.
virtual void clear() override
Clearing the configuration data.
void setPSK(unsigned int psk)
void loadFromOracle(unsigned int key, boost::property_tree::ptree &pt, const std::string &outFileName, const std::string &description, const std::map< size_t, QueryDefinition > &queries) const
void loadFromCrest(unsigned int key, boost::property_tree::ptree &pt, const std::string &outFileName, const std::string &description, const std::string &query_type) const
◆ msg() [1/2]
| MsgStreamTC & TrigConf::TrigConfMessaging::msg |
( |
| ) |
const |
|
inlineinherited |
The standard message stream.
Returns a reference to the message stream May not be invoked before sysInitialize() has been invoked.
Definition at line 86 of file TrigConfMessaging.h.
87 {
89 if (!ms) {
92 }
94 }
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)
◆ msg() [2/2]
The standard message stream.
Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.
Definition at line 96 of file TrigConfMessaging.h.
97 {
99 }
MsgStreamTC & msg() const
The standard message stream.
◆ msgLvl()
| bool TrigConf::TrigConfMessaging::msgLvl |
( |
const MSGTC::Level | lvl | ) |
const |
|
inlineinherited |
Test the output level.
- Parameters
-
| lvl | The message level to test against |
- Returns
- boolean Indicting if messages at given level will be printed
- Return values
-
| true | Messages at level "lvl" will be printed |
Definition at line 75 of file TrigConfMessaging.h.
76 {
79 return true;
80 }
81 else {
82 return false;
83 }
84 }
◆ outputLevel()
Definition at line 70 of file TrigDBLoader.h.
MSGTC::Level level()
Return message level of stream.
◆ schemaVersion()
| size_t TrigConf::TrigDBLoader::schemaVersion |
( |
coral::ISessionProxy * | session | ) |
const |
|
inherited |
access to TriggerDB schema version
- Returns
- version of the DB schema (0 - no version, >0 - schema version)
Definition at line 38 of file TrigDBLoader.cxx.
38 {
39
40 static const std::string versionTagPrefix("Trigger-Run3-Schema-v");
41
42
43 if(! session->nominalSchema().existsTable("TRIGGER_SCHEMA") ) {
44 throw std::runtime_error( "Trigger schema has no schema version table" );
45 }
46
47 TrigConf::QueryDefinition qdef;
48
50
52
56 throw std::runtime_error( "Trigger schema has schema version table but it is empty" );
57 }
58
59 const coral::AttributeList&
row =
cursor.currentRow();
60 std::string versionTag =
row[
"TS_TAG"].data<std::string>();
61 if( ! versionTag.starts_with(versionTagPrefix)) {
62 throw std::runtime_error(std::format("Tag format error: Trigger schema version tag {} does not start with {}", versionTag, versionTagPrefix));
63 }
64
65 std::string vstr = versionTag.substr(versionTagPrefix.size());
67 try {
69 }
70 catch (const std::invalid_argument& ia) {
71 TRG_MSG_ERROR(
"Invalid argument when interpreting the version part " << vstr <<
" of schema tag " << versionTag <<
". " << ia.what());
72 throw;
73 }
74
77}
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
void extendOutput(const std::string &fieldName)
void addToTableList(const std::string &table, const std::string &table_short="")
◆ setCrestConnection()
| void TrigConf::TrigDBLoader::setCrestConnection |
( |
const std::string & | server, |
|
|
const std::string & | version = "" ) |
|
inherited |
declare CREST as the source of the configuration An empty crest server makes it use Oracle
- Parameters
-
| server | The crest server. An empty string disables Crest and enables Oracle (the default) |
| version | The version of the crest api. Usually not needed. If not given, it defaults to the default API version (see CrestApi/CrestApiBase.h) |
Definition at line 80 of file TrigDBLoader.cxx.
80 {
81
85 }
86
87
89
90
93 } else {
95 }
98 }
99}
◆ setCrestTrigDB()
| void TrigConf::TrigDBLoader::setCrestTrigDB |
( |
const std::string & | crestTrigDB | ) |
|
|
inherited |
set trigger db for the crest connection
- Parameters
-
| crestTrigDB | the source trigger DB. Possible values currently
- CONF_DATA_RUN3 => ATLAS_CONF_TRIGGER_RUN3
- CONF_MC_RUN3 => ATLAS_CONF_TRIGGER_MC_RUN3
- CONF_REPR_RUN3 => ATLAS_CONF_TRIGGER_REPR_RUN3
|
Definition at line 102 of file TrigDBLoader.cxx.
◆ setLevel()
Definition at line 68 of file TrigDBLoader.h.
void setLevel(MSGTC::Level lvl)
Set message level of stream.
◆ useCrest()
| bool TrigConf::TrigDBLoader::useCrest |
( |
| ) |
const |
|
inlineprotectedinherited |
◆ m_connection
| std::string TrigConf::TrigDBLoader::m_connection {""} |
|
privateinherited |
◆ m_connectionTimeout
| int TrigConf::TrigDBLoader::m_connectionTimeout {0} |
|
privateinherited |
◆ m_crestServer
| std::string TrigConf::TrigDBLoader::m_crestServer {""} |
|
privateinherited |
◆ m_crestTrigDb
| std::string TrigConf::TrigDBLoader::m_crestTrigDb {""} |
|
privateinherited |
◆ m_crestVersion
| std::string TrigConf::TrigDBLoader::m_crestVersion {""} |
|
privateinherited |
◆ m_msg_tls
| boost::thread_specific_ptr<MsgStreamTC> TrigConf::TrigConfMessaging::m_msg_tls |
|
mutableprivateinherited |
◆ m_name
| std::string TrigConf::TrigConfMessaging::m_name |
|
privateinherited |
◆ m_queries
| std::map<size_t, QueryDefinition> TrigConf::TrigDBL1PrescalesSetLoader::m_queries |
|
private |
◆ m_retrialPeriod
| int TrigConf::TrigDBLoader::m_retrialPeriod {0} |
|
privateinherited |
◆ m_retrialTimeout
| int TrigConf::TrigDBLoader::m_retrialTimeout {0} |
|
privateinherited |
◆ m_useCrest
| bool TrigConf::TrigDBLoader::m_useCrest {false} |
|
privateinherited |
The documentation for this class was generated from the following files: