ATLAS Offline Software
Loading...
Searching...
No Matches
TrigDBMenuLoader.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3#include "./TrigDBHelper.h"
5
6TrigConf::TrigDBMenuLoader::TrigDBMenuLoader(const std::string & connection) :
7 TrigDBLoader("TrigDBMenuLoader", connection)
8{
9 /*
10 L1 menu queries
11 */
12 { // for schema version 1
13 auto & q = m_l1queries[1];
14 // tables
15 q.addToTableList ( "SUPER_MASTER_TABLE", "SMT" );
16 q.addToTableList ( "L1_MASTER_TABLE", "L1MT" );
17 // bind vars
18 q.extendBinding<int>("key");
19 // conditions
20 q.extendCondition("SMT.SMT_ID = :key");
21 q.extendCondition(" AND SMT.SMT_L1_MASTER_TABLE_ID = L1MT.L1MT_ID");
22 // attributes
23 q.extendOutput<std::string>( "SMT.SMT_NAME" );
24 q.extendOutput<int> ( "SMT.SMT_L1_MASTER_TABLE_ID" );
25 q.extendOutput<coral::Blob>( "L1MT.L1MT_MENU" );
26 // the field with the data
27 q.setDataName("L1MT.L1MT_MENU");
28 }
29 { // for schema version 2
30 auto & q = m_l1queries[2];
31 // tables
32 q.addToTableList ( "SUPER_MASTER_TABLE", "SMT" );
33 q.addToTableList ( "L1_MENU", "L1TM" );
34 // bind vars
35 q.extendBinding<int>("key");
36 // conditions
37 q.extendCondition("SMT.SMT_ID = :key");
38 q.extendCondition(" AND SMT.SMT_L1_MENU_ID = L1TM.L1TM_ID");
39 // attributes
40 q.extendOutput<std::string>( "SMT.SMT_NAME" );
41 q.extendOutput<int> ( "SMT.SMT_VERSION" );
42 q.extendOutput<int> ( "SMT.SMT_L1_MENU_ID" );
43 q.extendOutput<coral::Blob>( "L1TM.L1TM_DATA" );
44 // the field with the data
45 q.setDataName("L1TM.L1TM_DATA");
46 }
47
48 /*
49 HLT menu queries
50 */
51 { // for schema version 1
52 auto & q = m_hltqueries[1];
53 // tables
54 q.addToTableList ( "SUPER_MASTER_TABLE", "SMT" );
55 q.addToTableList ( "HLT_MASTER_TABLE", "HMT" );
56 // bind vars
57 q.extendBinding<int>("key");
58 // conditions
59 q.extendCondition("SMT.SMT_ID = :key");
60 q.extendCondition(" AND SMT.SMT_HLT_MASTER_TABLE_ID = HMT.HMT_ID");
61 // attributes
62 q.extendOutput<std::string>( "SMT.SMT_NAME" );
63 q.extendOutput<int> ( "SMT.SMT_HLT_MASTER_TABLE_ID" );
64 q.extendOutput<coral::Blob>( "HMT.HMT_MENU" );
65 // the field with the data
66 q.setDataName("HMT.HMT_MENU");
67 }
68 { // for schema version 2
69 auto & q = m_hltqueries[2];
70 // tables
71 q.addToTableList ( "SUPER_MASTER_TABLE", "SMT" );
72 q.addToTableList ( "HLT_MENU", "HTM" );
73 // bind vars
74 q.extendBinding<int>("key");
75 // conditions
76 q.extendCondition("SMT.SMT_ID = :key");
77 q.extendCondition(" AND SMT.SMT_HLT_MENU_ID = HTM.HTM_ID");
78 // attributes
79 q.extendOutput<std::string>( "SMT.SMT_NAME" );
80 q.extendOutput<int> ( "SMT.SMT_VERSION" );
81 q.extendOutput<int> ( "SMT.SMT_HLT_MENU_ID" );
82 q.extendOutput<coral::Blob>( "HTM.HTM_DATA" );
83 // the field with the data
84 q.setDataName("HTM.HTM_DATA");
85 }
86}
87
88
89// Destructor defined here because QueryDefinition is an incomplete type in the header
91
92bool
94 boost::property_tree::ptree & l1menu,
95 const std::string & outFileName ) const
96{
97 if(useCrest()) {
98 loadFromCrest(smk, l1menu, outFileName, "L1 Menu", "L1M");
99 } else {
100 loadFromOracle(smk, l1menu, outFileName, "L1 menu", m_l1queries);
101 }
102 return true;
103}
104
105bool
107 boost::property_tree::ptree & hltmenu,
108 const std::string & outFileName ) const
109{
110 if(useCrest()) {
111 loadFromCrest(smk, hltmenu, outFileName, "HLT Menu", "HLTM");
112 } else {
113 loadFromOracle(smk, hltmenu, outFileName, "HLT menu", m_hltqueries);
114 }
115 return true;
116}
117
118bool
120 const std::string & outFileName ) const
121{
122 boost::property_tree::ptree ptl1;
123 loadL1Menu( smk, ptl1, outFileName );
124 try {
125 l1menu.setData(std::move(ptl1));
126 l1menu.setSMK(smk);
127 }
128 catch(std::exception & ex) {
129 l1menu.clear();
130 TRG_MSG_ERROR("When reading L1 menu for SMK " << smk << " a parsing error occured ( " << ex.what() <<" )" );
131 throw TrigConf::ParsingException("TrigDBMenuLoader: parsing error " + std::string(ex.what()));
132 }
133 return true;
134}
135
136
137bool
139 const std::string & outFileName ) const
140{
141 boost::property_tree::ptree pthlt;
142 loadHLTMenu( smk, pthlt, outFileName );
143 try {
144 hltmenu.setData(std::move(pthlt));
145 hltmenu.setSMK(smk);
146 }
147 catch(std::exception & ex) {
148 hltmenu.clear();
149 TRG_MSG_ERROR("When reading HLT menu for SMK " << smk << " a parsing error occured ( " << ex.what() <<" )" );
150 throw TrigConf::ParsingException("TrigDBMenuLoader: parsing error " + std::string(ex.what()));
151 }
152 return true;
153}
void setData(const ptree &data)
Setting the configuration data.
HLT menu configuration.
Definition HLTMenu.h:21
void setSMK(unsigned int psk)
Definition HLTMenu.cxx:46
virtual void clear() override
Clearing the configuration data.
Definition HLTMenu.cxx:29
L1 menu configuration.
Definition L1Menu.h:28
TrigDBLoader(const std::string &loaderName, const std::string &connection)
Constructor.
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
TrigDBMenuLoader(const std::string &connection)
Constructor.
bool loadHLTMenu(unsigned int smk, boost::property_tree::ptree &hltmenu, const std::string &outFileName="") const
Load HLT menu content from the Trigger DB into two ptrees for a given SuperMasterKey (SMK)
std::map< size_t, QueryDefinition > m_hltqueries
bool loadL1Menu(unsigned int smk, boost::property_tree::ptree &l1menu, const std::string &outFileName="") const
Load L1 menu content from the Trigger DB into a ptree for a given SuperMasterKey (SMK)
std::map< size_t, QueryDefinition > m_l1queries
virtual ~TrigDBMenuLoader() override
Destructor - cannot be defined here because QueryDefinition is an incomplete type.