15 #include <string_view>
25 m_schemaversion = triggerDBSchemaVersion();
39 catch(
const coral::Exception&
e ) {
41 m_session.transaction().rollback();
45 chains.setEFLowerChainCounter();
56 std::unique_ptr< coral::IQuery >
q( m_session.nominalSchema().newQuery() );
59 q->addToTableList (
"SUPER_MASTER_TABLE",
"SM" );
60 q->addToTableList (
"HLT_MASTER_TABLE",
"HM" );
61 q->addToTableList (
"HLT_TRIGGER_MENU",
"TM" );
62 q->addToTableList (
"HLT_TM_TO_TC",
"TM2TC" );
63 q->addToTableList (
"HLT_TRIGGER_CHAIN",
"TC" );
67 bindList.extend<
int>(
"smid");
68 bindList[0].data<
int>() = (
int)m_smk;
70 string theCondition =
"";
71 theCondition += string(
" SM.SMT_ID = :smid");
72 theCondition += string(
" AND HM.HMT_ID = SM.SMT_HLT_MASTER_TABLE_ID" );
73 theCondition += string(
" AND TM.HTM_ID = HM.HMT_TRIGGER_MENU_ID" );
74 theCondition += string(
" AND TM.HTM_ID = TM2TC.HTM2TC_TRIGGER_MENU_ID " );
75 theCondition += string(
" AND TC.HTC_ID = TM2TC.HTM2TC_TRIGGER_CHAIN_ID" );
77 q->setCondition( theCondition, bindList );
81 attList.extend<
long> (
"TC.HTC_ID" );
82 attList.extend<
string>(
"TC.HTC_NAME" );
83 attList.extend<
string>(
"TC.HTC_LOWER_CHAIN_NAME" );
85 attList.extend<
string>(
"TC.HTC_L2_OR_EF" );
86 attList.extend<
string>(
"TC.HTC_RERUN_PRESCALE" );
88 attList.extend<
int> (
"TC.HTC_CHAIN_COUNTER" );
89 attList.extend<
int> (
"TC.HTC_VERSION" );
95 theOrder +=
" TC.HTC_L2_OR_EF DESC, ";
97 theOrder +=
" TC.HTC_CHAIN_COUNTER ASC";
98 q->addToOrderList( theOrder );
102 coral::ICursor&
cursor =
q->execute();
107 long chainId =
row[
"TC.HTC_ID"].data<
long>();
108 int counter =
row[
"TC.HTC_CHAIN_COUNTER"].data<
int>();
109 int version =
row[
"TC.HTC_VERSION"].data<
int>();
111 string lower_chain_name =
rmtilde(
row[
"TC.HTC_LOWER_CHAIN_NAME"].data<string>());
114 string level =
"HLT";
125 string rerunps_s =
rmtilde(
row[
"TC.HTC_RERUN_PRESCALE"].data<string>());
126 std::string_view rerunps_sv = rerunps_s;
127 auto [
ptr, ec] = std::from_chars(rerunps_sv.data(), rerunps_sv.data() + rerunps_sv.size(), rerunps, std::chars_format::general);
128 if (ec != std::errc()) {
132 ch->set_rerun_prescale(rerunps);
140 TRG_MSG_INFO(
"Loaded " << chainlist.size() <<
" chains");
149 q->addToTableList (
"SUPER_MASTER_TABLE",
"SM" );
150 q->addToTableList (
"HLT_MASTER_TABLE",
"HM" );
151 q->addToTableList (
"HLT_TM_TO_TC",
"TM2TC" );
152 q->addToTableList (
"HLT_TRIGGER_CHAIN",
"TC" );
154 theCondition += string(
" SM.SMT_ID = :smid" );
155 theCondition += string(
" AND SM.SMT_HLT_MASTER_TABLE_ID = HM.HMT_ID" );
156 theCondition += string(
" AND HM.HMT_TRIGGER_MENU_ID = TM2TC.HTM2TC_TRIGGER_MENU_ID " );
157 theCondition += string(
" AND TC.HTC_ID = TM2TC.HTM2TC_TRIGGER_CHAIN_ID" );
159 bindings.extend<
int>(
"smid");
160 bindings[0].data<
int>() =
smk;
162 output.extend<
string>(
"TC.HTC_NAME" );
171 std::unique_ptr< coral::IQuery >
q( m_session.nominalSchema().newQuery() );
172 string theCondition(
"");
175 defineChainSubQuery(
q.get(), theCondition, bindings, m_smk,
output);
177 q->addToTableList (
"HLT_TRIGGER_GROUP",
"GR" );
179 theCondition += string(
" AND GR.HTG_TRIGGER_CHAIN_ID = TM2TC.HTM2TC_TRIGGER_CHAIN_ID" );
181 q->setCondition( theCondition, bindings );
183 output.extend<
string>(
"GR.HTG_NAME" );
188 coral::ICursor&
cursor =
q->execute();
195 string grname =
rmtilde(
row[
"GR.HTG_NAME"].data<string>());
210 std::unique_ptr< coral::IQuery >
q( m_session.nominalSchema().newQuery() );
211 string theCondition(
"");
214 defineChainSubQuery(
q.get(), theCondition, bindings, m_smk,
output);
216 q->addToTableList (
"HLT_TRIGGER_TYPE",
"TT" );
218 theCondition += string(
" AND TT.HTT_TRIGGER_CHAIN_ID = TM2TC.HTM2TC_TRIGGER_CHAIN_ID" );
220 q->setCondition( theCondition, bindings );
222 output.extend<
int>(
"TT.HTT_TYPEBIT" );
227 coral::ICursor&
cursor =
q->execute();
234 int triggertype =
row[
"TT.HTT_TYPEBIT"].data<
int>();
246 std::unique_ptr< coral::IQuery >
q( m_session.nominalSchema().newQuery() );
247 string theCondition(
"");
250 defineChainSubQuery(
q.get(), theCondition, bindings, m_smk,
output);
252 q->addToTableList (
"HLT_TC_TO_TR",
"TC2TR" );
253 q->addToTableList (
"HLT_TRIGGER_STREAM",
"TR" );
255 theCondition += string(
" AND TC2TR.HTC2TR_TRIGGER_CHAIN_ID = TC.HTC_ID" );
256 theCondition += string(
" AND TC2TR.HTC2TR_TRIGGER_STREAM_ID = TR.HTR_ID" );
258 output.extend<
string>(
"TC2TR.HTC2TR_TRIGGER_STREAM_PRESCALE");
259 output.extend<
string>(
"TR.HTR_NAME" );
260 output.extend<
string>(
"TR.HTR_TYPE" );
261 output.extend<
int>(
"TR.HTR_OBEYLB" );
265 q->setCondition( theCondition, bindings );
268 coral::ICursor&
cursor =
q->execute();
274 string chainname =
rmtilde(
row[
"TC.HTC_NAME"].data<string>());
275 string prescale_str =
rmtilde(
row[
"TC2TR.HTC2TR_TRIGGER_STREAM_PRESCALE"].data<string>());
276 string streamname =
rmtilde(
row[
"TR.HTR_NAME"].data<string>());
278 bool obeyLB =
row[
"TR.HTR_OBEYLB"].data<
int>();
280 std::string_view prescale_str_view = prescale_str;
281 auto [
ptr, ec] = std::from_chars(prescale_str_view.data(), prescale_str_view.data() + prescale_str_view.size(), prescale);
282 if (ec != std::errc()) {
296 std::unique_ptr< coral::IQuery >
q( m_session.nominalSchema().newQuery() );
297 string theCondition(
"");
300 defineChainSubQuery(
q.get(), theCondition, bindings, m_smk,
output);
302 q->addToTableList (
"HLT_TC_TO_TS",
"TC2TS" );
303 q->addToTableList (
"HLT_TRIGGER_SIGNATURE",
"TS" );
304 q->addToTableList (
"HLT_TS_TO_TE",
"TS2TE" );
305 q->addToTableList (
"HLT_TRIGGER_ELEMENT",
"TE" );
308 theCondition += string(
" AND TC2TS.HTC2TS_TRIGGER_CHAIN_ID = TC.HTC_ID" );
309 theCondition += string(
" AND TC2TS.HTC2TS_TRIGGER_SIGNATURE_ID = TS.HTS_ID" );
310 theCondition += string(
" AND TC2TS.HTC2TS_TRIGGER_SIGNATURE_ID = TS2TE.HTS2TE_TRIGGER_SIGNATURE_ID" );
311 theCondition += string(
" AND TE.HTE_ID = TS2TE.HTS2TE_TRIGGER_ELEMENT_ID" );
312 theCondition += string(
" AND TS2TE.HTS2TE_ELEMENT_COUNTER>=0" );
314 output.extend<
int>(
"TC2TS.HTC2TS_SIGNATURE_COUNTER" );
315 output.extend<
int>(
"TS2TE.HTS2TE_ELEMENT_COUNTER" );
316 output.extend<
int>(
"TS.HTS_LOGIC" );
317 output.extend<
int>(
"TE.HTE_ID" );
318 output.extend<
string>(
"TE.HTE_NAME" );
321 q->setCondition( theCondition, bindings );
325 q->addToOrderList(
"TC.HTC_NAME" );
326 q->addToOrderList(
"TC2TS.HTC2TS_SIGNATURE_COUNTER" );
327 q->addToOrderList(
"TS2TE.HTS2TE_ELEMENT_COUNTER" );
329 coral::ICursor&
cursor =
q->execute();
337 string chainname =
rmtilde(
row[
"TC.HTC_NAME"].data<string>());
340 unsigned int sig_counter = (
unsigned int)
row[
"TC2TS.HTC2TS_SIGNATURE_COUNTER"].data<int>();
341 if( sig_list.size() < sig_counter+1 )
342 sig_list.resize( sig_counter+1, 0 );
344 if( sig_list[sig_counter] == 0) {
345 int logic =
row[
"TS.HTS_LOGIC"].data<
int>();
346 sig_list[sig_counter] =
new HLTSignature(sig_counter, logic, std::vector<HLTTriggerElement*>());
347 sig_list[sig_counter]->set_label( chainname +
"_" +
std::to_string(sig_counter) );
351 vector<HLTTriggerElement*>& te_list =
sig->outputTEs();
353 unsigned int te_counter = (
unsigned int)
row[
"TS2TE.HTS2TE_ELEMENT_COUNTER"].data<int>();
354 if( te_list.size() < te_counter+1 )
355 te_list.resize( te_counter+1, 0 );
357 if( te_list[te_counter] == 0) {
358 int te_id =
row[
"TE.HTE_ID"].data<
int>();
359 string te_name =
row[
"TE.HTE_NAME"].data<
string>();
372 vector<HLTSignature*>&
s =
ch->signatureList();