|
ATLAS Offline Software
|
Loader of trigger configurations from Json files.
More...
#include <TrigDBCTPFilesLoader.h>
|
void | loadCTPFiles (L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const |
|
void | loadCTPSMX (L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const |
|
void | loadTMC (L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const |
|
void | loadMUCTPI (L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const |
|
std::vector< uint32_t > | loadDBFieldIntoVector (const coral::AttributeList &row, const std::string &field, size_t size) const |
|
std::string | loadDBFieldIntoString (const coral::AttributeList &row, const std::string &field) const |
|
Loader of trigger configurations from Json files.
Definition at line 30 of file TrigDBCTPFilesLoader.h.
◆ TrigDBCTPFilesLoader()
TrigConf::TrigDBCTPFilesLoader::TrigDBCTPFilesLoader |
( |
const std::string & |
connection | ) |
|
Constructor.
Definition at line 8 of file TrigDBCTPFilesLoader.cxx.
16 q.addToTableList (
"SUPER_MASTER_TABLE",
"SMT" );
17 q.addToTableList (
"L1_MENU",
"L1TM" );
19 q.extendBinding<
unsigned int>(
"smk");
21 q.extendCondition(
"SMT.SMT_ID = :smk AND SMT.SMT_L1_MENU_ID = L1TM.L1TM_ID");
23 q.extendOutput<
unsigned int>(
"L1TM.L1TM_CTP_FILES_ID");
24 q.extendOutput<
unsigned int>(
"L1TM.L1TM_CTP_SMX_ID");
25 q.extendOutput<
unsigned int>(
"L1TM.L1TM_MUCTPI_FILES_ID");
26 q.extendOutput<
unsigned int>(
"L1TM.L1TM_TMC_SIGNALS_ID");
32 q.addToTableList (
"L1_CTP_FILES" );
34 q.extendBinding<
unsigned int>(
"id");
36 q.extendCondition(
"L1CF_ID = :id");
62 q.addToTableList (
"L1_CTP_SMX" );
64 q.extendBinding<
unsigned int>(
"id");
66 q.extendCondition(
"L1SMX_ID = :id");
80 q.addToTableList (
"L1_MUCTPI_FILES" );
82 q.extendBinding<
unsigned int>(
"id");
84 q.extendCondition(
"L1MF_ID = :id");
92 q.addToTableList (
"L1_TMC_SIGNALS" );
94 q.extendBinding<
unsigned int>(
"id");
96 q.extendCondition(
"L1TMC_ID = :id");
◆ ~TrigDBCTPFilesLoader()
TrigConf::TrigDBCTPFilesLoader::~TrigDBCTPFilesLoader |
( |
| ) |
|
|
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 94 of file TrigDBLoader.cxx.
96 coral::ConnectionService connSvc;
97 coral::IConnectionServiceConfiguration& csc = connSvc.configuration();
112 auto proxy = std::unique_ptr<coral::ISessionProxy>( connSvc.connect(
m_connection, coral::AccessMode::ReadOnly) );
◆ getQueryDefinition()
return query for given schemaVersion from possible queries
Definition at line 122 of file TrigDBLoader.cxx.
126 size_t maxDefVersion = 0;
127 for(
auto &
entry : queries) {
128 size_t vkey =
entry.first;
130 maxDefVersion = vkey;
134 if( maxDefVersion==0 ) {
138 return queries.at(maxDefVersion);
◆ loadCTPFiles()
void TrigConf::TrigDBCTPFilesLoader::loadCTPFiles |
( |
L1CTPFiles & |
ctpfiles, |
|
|
std::unique_ptr< coral::IQuery > |
query, |
|
|
size_t |
schemaVersion |
|
) |
| const |
|
private |
Definition at line 188 of file TrigDBCTPFilesLoader.cxx.
197 ctpfiles.set_Ctpcore_LUT(
202 ctpfiles.set_Ctpcore_CAM(
207 ctpfiles.set_Ctpcore_SMX(
213 ctpfiles.set_Ctpin_MonSelector_Slot7(
218 ctpfiles.set_Ctpin_MonSelector_Slot8(
223 ctpfiles.set_Ctpin_MonSelector_Slot9(
228 ctpfiles.set_Ctpin_MonDecoder_Slot7(
233 ctpfiles.set_Ctpin_MonDecoder_Slot8(
238 ctpfiles.set_Ctpin_MonDecoder_Slot9(
243 ctpfiles.set_Ctpmon_MonSelector(
248 ctpfiles.set_Ctpmon_MonDecoder(
253 ctpfiles.set_Ctpmon_DMX(
257 ctpfiles.set_HasCompleteCtpData(
true);
259 catch(coral::QueryException & ex) {
260 TRG_MSG_ERROR(
"When reading the L1CTPFiles a coral::QueryException was caught ( " << ex.what() <<
" )" );
◆ loadCTPSMX()
void TrigConf::TrigDBCTPFilesLoader::loadCTPSMX |
( |
L1CTPFiles & |
ctpfiles, |
|
|
std::unique_ptr< coral::IQuery > |
query, |
|
|
size_t |
schemaVersion |
|
) |
| const |
|
private |
Definition at line 266 of file TrigDBCTPFilesLoader.cxx.
281 ctpfiles.set_HasCompleteSmxData(
true);
283 catch(coral::QueryException & ex) {
284 TRG_MSG_ERROR(
"When reading the L1CTPFiles a coral::QueryException was caught ( " << ex.what() <<
" )" );
◆ loadDBFieldIntoString()
std::string TrigConf::TrigDBCTPFilesLoader::loadDBFieldIntoString |
( |
const coral::AttributeList & |
row, |
|
|
const std::string & |
field |
|
) |
| const |
|
private |
Definition at line 504 of file TrigDBCTPFilesLoader.cxx.
508 boost::iostreams::stream<boost::iostreams::array_source>
stream(
509 static_cast<const char*
> (
blob.startingAddress()),
513 std::istreambuf_iterator<char>(
stream.rdbuf()),
514 std::istreambuf_iterator<char>()
518 catch(
const coral::AttributeException &
e) {}
521 throw std::runtime_error(
"CTPFilesLoader: field " +
field +
" in DB is empty" );
◆ loadDBFieldIntoVector()
std::vector< uint32_t > TrigConf::TrigDBCTPFilesLoader::loadDBFieldIntoVector |
( |
const coral::AttributeList & |
row, |
|
|
const std::string & |
field, |
|
|
size_t |
size |
|
) |
| const |
|
private |
Definition at line 476 of file TrigDBCTPFilesLoader.cxx.
477 std::vector<uint32_t>
vec;
484 boost::iostreams::stream<boost::iostreams::array_source>
stream(
485 static_cast<const char*
> (
blob.startingAddress()),
488 std::string word{
""};
490 vec.push_back(std::stoul(word,
nullptr, 0));
493 catch(
const coral::AttributeException &
e) {}
497 throw std::runtime_error(
"CTPFilesLoader: file of unexpected size" );
◆ loadHardwareFiles()
bool TrigConf::TrigDBCTPFilesLoader::loadHardwareFiles |
( |
unsigned int |
smk, |
|
|
TrigConf::L1CTPFiles & |
ctpfiles, |
|
|
uint8_t |
loadMask = 0x0F , |
|
|
const std::string & |
outFileName = "" |
|
) |
| const |
Load content from the Trigger DB into an L1CTPFiles object for a given super master key (SMK)
- Parameters
-
smk | [in] the SMK that should be loaded |
ctpfiles | [out] the loaded L1CTPFiles |
loadMask | [in] bit mask which specifies which content should be loaded (default is 0x0F which loads all content) 0x01 - CTPFiles, 0x02 - SMX files, 0x04 - TMC, 0x08 - MUCTPI |
outFileName | [in] if set, an outputfile with the raw data blob is written |
Definition at line 106 of file TrigDBCTPFilesLoader.cxx.
111 unsigned int ctpFilesID{0};
112 unsigned int ctpSmxID{0};
113 unsigned int muctpiID{0};
114 unsigned int tmcSignalsID{0};
117 session->transaction().start(
true);
121 qdef.setBoundValue<
unsigned int>(
"smk",
smk);
122 auto q = qdef.createQuery( session.get() );
125 TRG_MSG_ERROR(
"Tried reading L1 CTPFiles, but super master key " <<
smk <<
" is not available" );
130 ctpFilesID =
row[
"L1TM.L1TM_CTP_FILES_ID"].data<
unsigned int>();
132 catch(
const coral::AttributeException &
e)
135 ctpSmxID =
row[
"L1TM.L1TM_CTP_SMX_ID"].data<
unsigned int>();
137 catch(
const coral::AttributeException &
e)
140 muctpiID =
row[
"L1TM.L1TM_MUCTPI_FILES_ID"].data<
unsigned int>();
142 catch(
const coral::AttributeException &
e)
145 tmcSignalsID =
row[
"L1TM.L1TM_TMC_SIGNALS_ID"].data<
unsigned int>();
147 catch(
const coral::AttributeException &
e)
150 TRG_MSG_INFO(
"ID of table L1_CTP_FILES : " << ctpFilesID);
152 TRG_MSG_INFO(
"ID of table L1_MUCTPI_FILES : " << muctpiID);
153 TRG_MSG_INFO(
"ID of table L1_TMC_SIGNALS : " << tmcSignalsID);
155 catch(coral::QueryException & ex) {
156 TRG_MSG_ERROR(
"When reading the files table links for super master key " <<
smk <<
" a coral::QueryException was caught ( " << ex.what() <<
" )" );
160 if(ctpFilesID>0 && (loadMask & 0x01)!=0 ) {
162 qdef.setBoundValue<
unsigned int>(
"id", ctpFilesID);
166 if(ctpSmxID>0 && (loadMask & 0x02)!=0) {
168 qdef.setBoundValue<
unsigned int>(
"id", ctpSmxID);
169 loadCTPSMX(ctpfiles, qdef.createQuery( session.get() ),
sv );
172 if(tmcSignalsID>0 && (loadMask & 0x04)!=0) {
174 qdef.setBoundValue<
unsigned int>(
"id", tmcSignalsID);
175 loadTMC(ctpfiles, qdef.createQuery( session.get() ),
sv );
178 if(muctpiID>0 && (loadMask & 0x08)!=0) {
180 qdef.setBoundValue<
unsigned int>(
"id", muctpiID);
181 loadMUCTPI(ctpfiles, qdef.createQuery( session.get() ),
sv );
◆ loadMUCTPI()
void TrigConf::TrigDBCTPFilesLoader::loadMUCTPI |
( |
L1CTPFiles & |
ctpfiles, |
|
|
std::unique_ptr< coral::IQuery > |
query, |
|
|
size_t |
schemaVersion |
|
) |
| const |
|
private |
Definition at line 290 of file TrigDBCTPFilesLoader.cxx.
291 TRG_MSG_INFO(
"Loading data from table L1_MUCTPI_FILES");
303 catch(coral::QueryException & ex) {
304 TRG_MSG_ERROR(
"When reading the L1CTPFiles a coral::QueryException was caught ( " << ex.what() <<
" )" );
307 DataStructure
ds(
"L1_MUCTPI_FILES", std::move(
pt));
308 std::vector<std::string>
keys =
ds.getKeys();
312 std::vector<uint32_t>
v;
314 for(
const auto &
x : *
dv ) {
315 v.push_back(std::stoul(
x.getValue<std::string>(),
nullptr, 0));
317 ctpfiles.set_Muctpi(
k, std::move(
v));
322 for(
const std::string &
k :
keys) {
328 auto sopt =
ds.getAttribute_optional<std::string>(
k);
329 if(
k.compare(0, 6,
"pt_lut") == 0) {
330 auto dv =
ds.getList(
k);
331 std::vector<uint32_t>
v;
334 v.push_back(std::stoul(
x.getValue<std::string>(),
nullptr, 0));
336 ctpfiles.set_Muctpi_Extra_Ptlut(
k, std::move(
v));
337 }
else if(
k==
"multiplicities_nbits") {
338 auto dv =
ds.getList(
k);
339 std::vector<uint32_t>
v;
341 v.push_back(std::stoul(
x.getValue<std::string>(),
nullptr, 0));
343 ctpfiles.set_Muctpi_Nbits(std::move(
v));
346 ctpfiles.set_HasCompleteMuctpiData(!
incomplete);
◆ loadTMC()
void TrigConf::TrigDBCTPFilesLoader::loadTMC |
( |
L1CTPFiles & |
ctpfiles, |
|
|
std::unique_ptr< coral::IQuery > |
query, |
|
|
size_t |
schemaVersion |
|
) |
| const |
|
private |
Definition at line 350 of file TrigDBCTPFilesLoader.cxx.
361 catch(coral::QueryException & ex) {
362 TRG_MSG_ERROR(
"When reading the L1CTPFiles a coral::QueryException was caught ( " << ex.what() <<
" )" );
366 DataStructure
ds(
"L1_TMC", std::move(
pt));
369 if(
auto ft =
ds.getAttribute<std::string>(
"filetype");
ft !=
"tmcresult" ) {
370 throw TrigConf::ParsingException(
"TrigDBCTPFilesLoader::loadTMC: json structure of unexpected file type found. Expected 'tmcresult', but found " +
ft);
374 if (
auto dv =
ds.getObject_optional(
"CTPCORE.TriggerInputs"))
376 std::vector<TrigConf::L1CTPFiles::CTPCoreInput> ctpcoreInputs;
377 for (
const std::string &
k :
dv->getKeys())
380 const std::string &
inputType = inp[
"type"];
394 ctpcoreInputs.push_back(
400 TRG_MSG_INFO(
"Loading ctpcore inputs " << ctpcoreInputs.size());
401 ctpfiles.set_Tmc_CtpcoreInputs(std::move(ctpcoreInputs));
405 if (
auto dv =
ds.getObject_optional(
"CTPCORE.TriggerInputs"))
407 std::vector<TrigConf::L1CTPFiles::CTPCoreCTPXInput> ctpcoreCTPXInputs;
408 for (
const std::string &
k :
dv->getKeys())
411 const std::string &
inputType = inp[
"type"];
421 ctpcoreCTPXInputs.push_back(
427 TRG_MSG_INFO(
"Loading ctpcore CTPX inputs " << ctpcoreCTPXInputs.size());
428 ctpfiles.set_Tmc_CtpcoreCTPXInputs(std::move(ctpcoreCTPXInputs));
432 std::vector<TrigConf::L1CTPFiles::CTPInCounter> ctpinCounters;
433 for (
size_t slot : {7, 8, 9})
435 for (
size_t conn : {0, 1, 2, 3})
438 if (
auto dv =
ds.getObject_optional(
path))
440 if (
auto ov =
dv->getList_optional(
"outputs"))
442 for (
const DataStructure &
output : *
ov)
444 ctpinCounters.push_back(
446 output.getAttribute<std::string>(
"TriggerCounter"), slot,
conn,
output.getAttribute<
size_t>(
"number")));
452 TRG_MSG_INFO(
"Loading ctpin counters " << ctpinCounters.size());
453 ctpfiles.set_Tmc_CtpinCounters(std::move(ctpinCounters));
456 std::vector<TrigConf::L1CTPFiles::CTPMonCounter> ctpmonCounters;
457 if(
auto dv =
ds.getObject_optional(
"CTPMON.Monitoring") ) {
458 if (
auto ov =
dv->getList_optional(
"outputs"))
460 for (
const DataStructure &
output : *
ov)
462 ctpmonCounters.push_back(
464 output.getAttribute<std::string>(
"TriggerCounter"),
output.getAttribute<
size_t>(
"number")));
468 TRG_MSG_INFO(
"Loading ctpmon counters " << ctpmonCounters.size());
469 ctpfiles.set_Tmc_CtpmonCounters(std::move(ctpmonCounters));
471 ctpfiles.set_Tmc_Data(std::move(
ds));
472 ctpfiles.set_HasCompleteTmcData(
true);
◆ 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 81 of file TrigConfMessaging.h.
◆ 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 91 of file TrigConfMessaging.h.
◆ msgLvl()
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 70 of file TrigConfMessaging.h.
◆ outputLevel()
◆ 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.
40 static const std::string versionTagPrefix(
"Trigger-Run3-Schema-v");
43 if(! session->nominalSchema().existsTable(
"TRIGGER_SCHEMA") ) {
44 throw std::runtime_error(
"Trigger schema has no schema version table" );
56 throw std::runtime_error(
"Trigger schema has schema version table but it is empty" );
60 std::string versionTag =
row[
"TS_TAG"].data<std::string>();
61 if( ! startswith(versionTag, versionTagPrefix)) {
62 throw std::runtime_error(
"Tag format error: Trigger schema version tag " + versionTag +
"does not start with " + versionTagPrefix);
65 std::string vstr = versionTag.substr(versionTagPrefix.size());
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());
◆ setLevel()
◆ writeRawFile()
bool TrigConf::TrigDBLoader::writeRawFile |
( |
const coral::Blob & |
data, |
|
|
const std::string & |
outFileName |
|
) |
| const |
|
inherited |
write data blob into file This can be used to write the DB content to file without going through a ptree
Definition at line 80 of file TrigDBLoader.cxx.
87 outFile.write(
static_cast<const char*
> (
data.startingAddress()),
data.size() );
◆ m_connection
std::string TrigConf::TrigDBLoader::m_connection {"TRIGGERDB"} |
|
privateinherited |
◆ m_connectionTimeout
int TrigConf::TrigDBLoader::m_connectionTimeout {0} |
|
privateinherited |
◆ m_ctpfiles_queries
std::map<size_t, QueryDefinition> TrigConf::TrigDBCTPFilesLoader::m_ctpfiles_queries |
|
private |
◆ m_ctpsmx_queries
std::map<size_t, QueryDefinition> TrigConf::TrigDBCTPFilesLoader::m_ctpsmx_queries |
|
private |
◆ m_link_queries
std::map<size_t, QueryDefinition> TrigConf::TrigDBCTPFilesLoader::m_link_queries |
|
private |
◆ m_msg_tls
boost::thread_specific_ptr<MsgStreamTC> TrigConf::TrigConfMessaging::m_msg_tls |
|
mutableprivateinherited |
◆ m_muctpi_queries
std::map<size_t, QueryDefinition> TrigConf::TrigDBCTPFilesLoader::m_muctpi_queries |
|
private |
◆ m_name
std::string TrigConf::TrigConfMessaging::m_name |
|
privateinherited |
◆ m_retrialPeriod
int TrigConf::TrigDBLoader::m_retrialPeriod {0} |
|
privateinherited |
◆ m_retrialTimeout
int TrigConf::TrigDBLoader::m_retrialTimeout {0} |
|
privateinherited |
◆ m_tmcsig_queries
std::map<size_t, QueryDefinition> TrigConf::TrigDBCTPFilesLoader::m_tmcsig_queries |
|
private |
The documentation for this class was generated from the following files:
char data[hepevt_bytes_allocation_ATLAS]
path
python interpreter configuration --------------------------------------—
void loadTMC(L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const
std::string find(const std::string &s)
return a remapped string
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)
static const size_t CTPMON_DECODER_SIZE
std::map< size_t, QueryDefinition > m_link_queries
static const std::map< MuctpiAccess, std::string > s_keyMap
std::map< size_t, QueryDefinition > m_muctpi_queries
size_t schemaVersion(coral::ISessionProxy *session) const
access to TriggerDB schema version
T getAttribute(const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
Access to simple attribute.
std::vector< size_t > vec
std::map< size_t, QueryDefinition > m_tmcsig_queries
static const size_t CTPCORE_LUT_SIZE
void extendOutput(const std::string &fieldName)
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
static const size_t CTPIN_MONDEC_SIZE
MsgStreamTC & msg() const
The standard message stream.
static const size_t CTPMON_SELECTOR_SIZE
MSGTC::Level level()
Return message level of stream.
std::string loadDBFieldIntoString(const coral::AttributeList &row, const std::string &field) const
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
static const size_t CTPCORE_CAM_SIZE
std::map< size_t, QueryDefinition > m_ctpfiles_queries
outFile
Comment Out Those You do not wish to run.
boost::property_tree::ptree ptree
std::string to_string(const DetectorType &type)
static const size_t CTPMON_DMX_SIZE
void loadCTPFiles(L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const
Base class for Trigger configuration data and wrapper around underlying representation.
std::map< size_t, QueryDefinition > m_ctpsmx_queries
void blobToPtree(const coral::Blob &blob, boost::property_tree::ptree &pt)
std::vector< uint32_t > loadDBFieldIntoVector(const coral::AttributeList &row, const std::string &field, size_t size) const
void setLevel(MSGTC::Level lvl)
Set message level of stream.
void loadCTPSMX(L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const
void loadMUCTPI(L1CTPFiles &ctpfiles, std::unique_ptr< coral::IQuery > query, size_t schemaVersion) const
std::unique_ptr< coral::ISessionProxy > createDBSession() const
create (if needed) DB session and return the session proxy
static const size_t CTPIN_MONSEL_SIZE
static const size_t CTPCORE_SMX_SIZE
void addToTableList(const std::string &table, const std::string &table_short="")
QueryDefinition getQueryDefinition(size_t schemaVersion, const std::map< size_t, QueryDefinition > &queries) const
return query for given schemaVersion from possible queries
TrigDBLoader(const std::string &loaderName, const std::string &connection)
Constructor.