ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConf::ThresholdConfigLoader Class Reference

TriggerDB loader of the LVL1 trigger threshold configuration. More...

#include <ThresholdConfigLoader.h>

Inheritance diagram for TrigConf::ThresholdConfigLoader:
Collaboration diagram for TrigConf::ThresholdConfigLoader:

Public Member Functions

 ThresholdConfigLoader (StorageMgr &sm, coral::ISessionProxy &session)
 constructor
virtual ~ThresholdConfigLoader () override=default
virtual bool load (ThresholdConfig &data) override
virtual void setLevel (MSGTC::Level lvl) override
 access to output stream
virtual MSGTC::Level outputLevel () const override
void startSession ()
 start session if not already active
void commitSession ()
 commit session if not already done
bool loadL1MasterKey (int SuperMasterKey, int &Lvl1MasterKey)
 get l1 master from super master
bool loadL1MenuKey (int SuperMasterKey, int &Lvl1MenuKey)
 get l1 menu id from super master
unsigned int triggerDBSchemaVersion ()
virtual int verbose () const override
virtual void setVerbose (int v) override
bool isRun1 ()
bool isRun2 ()
bool msgLvl (const MSGTC::Level lvl) const
 Test the output level.
MsgStreamTCmsg () const
 The standard message stream.
MsgStreamTCmsg (const MSGTC::Level lvl) const
 The standard message stream.
const std::string & getName () const
 name accessor

Protected Attributes

StorageMgrm_storageMgr
 reference to the storage manager
coral::ISessionProxy & m_session
 CORAL interface to database session.
bool m_sessionOwner {false}
 remember if the loader started the session in the first place

Private Member Functions

void loadCaloInfo (ThresholdConfig &thrConfig, long caloInfoId)
std::tuple< unsigned int, unsigned int > loadSchemaVersion () const
 get DB schema version and run number

Private Attributes

int m_verbose {1}
boost::thread_specific_ptr< MsgStreamTCm_msg_tls
 MsgStreamTC instance (a std::cout like with print-out levels)
std::string m_name

Detailed Description

TriggerDB loader of the LVL1 trigger threshold configuration.

Definition at line 26 of file ThresholdConfigLoader.h.

Constructor & Destructor Documentation

◆ ThresholdConfigLoader()

TrigConf::ThresholdConfigLoader::ThresholdConfigLoader ( StorageMgr & sm,
coral::ISessionProxy & session )
inline

constructor

Parameters
smreference to storage manager
sessionreference to the database session

Definition at line 35 of file ThresholdConfigLoader.h.

36 : DBLoader("ThresholdConfigLoader", sm, session) {}
DBLoader(StorageMgr &sm, coral::ISessionProxy &session)
constructor
Definition DBLoader.cxx:30

◆ ~ThresholdConfigLoader()

virtual TrigConf::ThresholdConfigLoader::~ThresholdConfigLoader ( )
overridevirtualdefault

Member Function Documentation

◆ commitSession()

void TrigConf::DBLoader::commitSession ( )
inherited

commit session if not already done

Definition at line 45 of file DBLoader.cxx.

46{
47 if ( m_session.transaction().isActive() && m_sessionOwner) {
48 m_session.transaction().commit();
49 }
50}
bool m_sessionOwner
remember if the loader started the session in the first place
Definition DBLoader.h:69
coral::ISessionProxy & m_session
CORAL interface to database session.
Definition DBLoader.h:68

◆ getName()

const std::string & TrigConf::TrigConfMessaging::getName ( ) const
inlineinherited

name accessor

Returns
the name

Definition at line 101 of file TrigConfMessaging.h.

101 {
102 return m_name;
103 }

◆ isRun1()

bool TrigConf::DBLoader::isRun1 ( )
inlineinherited

Definition at line 60 of file DBLoader.h.

60{ return ! isRun2(); }

◆ isRun2()

bool DBLoader::isRun2 ( )
inherited

Definition at line 54 of file DBLoader.cxx.

54 {
55 const static unsigned int run = std::get<1>(loadSchemaVersion());
56 return run == 2;
57}
std::tuple< unsigned int, unsigned int > loadSchemaVersion() const
get DB schema version and run number
Definition DBLoader.cxx:81

◆ load()

bool TrigConf::ThresholdConfigLoader::load ( ThresholdConfig & data)
overridevirtual

Implements TrigConf::IThresholdConfigLoader.

Definition at line 41 of file ThresholdConfigLoader.cxx.

41 {
42
43 const unsigned int schema_version_with_zb_fields = 9;
44
45 TRG_MSG_DEBUG("Loading ThresholdConfig object attached to Lvl1 master ID " << thrConfig.lvl1MasterTableId());
46 TRG_MSG_DEBUG("Current number of thresholds: " << thrConfig.size());
47
48 long caloinfoid = 0;
49
50 try {
52 // get menu id and caloinfo id from thrConfig.m_MasterTableId and the table L1_MASTER_TABLE
53 int menuid = 0;
54
55 unique_ptr<coral::IQuery> query0(m_session.nominalSchema().tableHandle( "L1_MASTER_TABLE").newQuery());
56 query0->setRowCacheSize( 5 );
57
58 //Bind list
59 coral::AttributeList bindList0;
60 bindList0.extend<int>("mtId");
61 std::string cond0 = "L1MT_ID = :mtId";
62 bindList0[0].data<int>() = thrConfig.lvl1MasterTableId();
63 query0->setCondition( cond0, bindList0 );
64
65 //Output and types
66 coral::AttributeList attList0;
67 attList0.extend<int>( "L1MT_TRIGGER_MENU_ID" );
68 attList0.extend<long>( "L1MT_CALO_INFO_ID" );
69 query0->defineOutput(attList0);
70 query0->addToOutputList( "L1MT_TRIGGER_MENU_ID" );
71 query0->addToOutputList( "L1MT_CALO_INFO_ID" );
72 coral::ICursor& cursor0 = query0->execute();
73
74 if ( ! cursor0.next() ) {
75 TRG_MSG_ERROR("ThresholdConfigLoader >> No such Master_Table exists " << thrConfig.lvl1MasterTableId());
77 throw std::runtime_error( "ThresholdConfigLoader >> ThresholdConfig not available" );
78 }
79
80 const coral::AttributeList& row0 = cursor0.currentRow();
81 menuid = row0["L1MT_TRIGGER_MENU_ID"].data<int>();
82 caloinfoid = row0["L1MT_CALO_INFO_ID"].data<long>();
83
84 if ( cursor0.next() ) {
85
86 TRG_MSG_ERROR("ThresholdConfigLoader >> More than one Master_Table exists "
87 << thrConfig.lvl1MasterTableId());
89 throw std::runtime_error( "ThresholdConfigLoader >> Master_Table not available" );
90 }
91
92 //=====================================================
93 // get Thresholds WITH trigger threshold values
94
95 coral::AttributeList emptyBindVariableList;
96
97 unique_ptr<coral::IQuery> query(m_session.nominalSchema().newQuery());
98
99 // Set the tables that are used
100 query->addToTableList ( "L1_TM_TO_TT", "TM2TT" );
101 query->addToTableList ( "L1_TRIGGER_THRESHOLD", "TT" );
102 query->addToTableList ( "L1_TT_TO_TTV", "TT2TTV" );
103 query->addToTableList ( "L1_TRIGGER_THRESHOLD_VALUE", "TTV" );
104
105 // Bind list
106 coral::AttributeList bindList;
107 bindList.extend<int>("menuId");
108 bindList[0].data<int>() = menuid;
109 std::string theCondition = "";
110 theCondition += std::string( " TM2TT.L1TM2TT_TRIGGER_MENU_ID = :menuId" );
111 theCondition += std::string( " AND TM2TT.L1TM2TT_TRIGGER_THRESHOLD_ID = TT.L1TT_ID" );
112 theCondition += std::string( " AND TT2TTV.L1TT2TTV_TRIGGER_THRESHOLD_ID = TT.L1TT_ID" );
113 theCondition += std::string( " AND TT2TTV.L1TT2TTV_TRIG_THRES_VALUE_ID = TTV.L1TTV_ID" );
114 query->setCondition( theCondition, bindList );
115
116 // Output data and types
117 coral::AttributeList attList;
118 attList.extend<std::string>( "TM2TT.L1TM2TT_CABLE_NAME" );
119 attList.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CTPIN" );
120 attList.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CONNECTOR" );
121 attList.extend<int> ( "TM2TT.L1TM2TT_CABLE_START" );
122 attList.extend<int> ( "TM2TT.L1TM2TT_CABLE_END" );
123 if(isRun2()) {
124 attList.extend<int> ( "TM2TT.L1TM2TT_CABLE_CLOCK" );
125 }
126 attList.extend<int> ( "TT.L1TT_ID" );
127 attList.extend<std::string>( "TT.L1TT_NAME" );
128 attList.extend<int> ( "TT.L1TT_VERSION" );
129 attList.extend<std::string>( "TT.L1TT_TYPE" );
130 attList.extend<int> ( "TT.L1TT_ACTIVE" );
131 attList.extend<int> ( "TT.L1TT_MAPPING" );
132 attList.extend<int> ( "TT.L1TT_BITNUM" );
133 attList.extend<int> ( "TTV.L1TTV_ID" );
134 attList.extend<std::string>( "TTV.L1TTV_NAME" );
135 attList.extend<int> ( "TTV.L1TTV_VERSION" );
136 attList.extend<std::string>( "TTV.L1TTV_TYPE" );
137 attList.extend<std::string>( "TTV.L1TTV_PT_CUT" );
138 attList.extend<int> ( "TTV.L1TTV_ETA_MIN" );
139 attList.extend<int> ( "TTV.L1TTV_ETA_MAX" );
140 attList.extend<int> ( "TTV.L1TTV_PHI_MIN" );
141 attList.extend<int> ( "TTV.L1TTV_PHI_MAX" );
142 attList.extend<std::string>( "TTV.L1TTV_EM_ISOLATION" );
143 attList.extend<std::string>( "TTV.L1TTV_HAD_ISOLATION" );
144 attList.extend<std::string>( "TTV.L1TTV_HAD_VETO" );
145 attList.extend<int> ( "TTV.L1TTV_WINDOW" );
146 attList.extend<std::string>( "TTV.L1TTV_PRIORITY" );
147 fillQuery(query.get(), attList);
148
149 // the ordering
150 std::string theOrder = "";
151 theOrder += " TT.L1TT_MAPPING ASC";
152 theOrder += ", TT.L1TT_ID ASC";
153 theOrder += ", TTV.L1TTV_PRIORITY ASC";
154 theOrder += ", TTV.L1TTV_ETA_MAX ASC";
155 query->addToOrderList( theOrder );
156
157 //query->setRowCacheSize(1000);
158 query->setRowCacheSize(500);
159
160 coral::ICursor& cursor = query->execute();
161
162 unsigned int schema_version = triggerDBSchemaVersion();
163 //unsigned int numberofvalues = 0;
164 TriggerThreshold* tt = 0;
165 int nRowsLoop1 = -2009;
166 int nRowsLoop2 = -2010;
167
168 while (cursor.next()) {
169
170 const coral::AttributeList& row = cursor.currentRow();
171
172 nRowsLoop1 = row["TT.L1TT_ID"].data<int>();
173 if (nRowsLoop1 != nRowsLoop2) {
174
175 if (tt != 0) {
176 // trigger thresholds sorted by type
177 thrConfig.addTriggerThreshold(tt);
178 tt = new TriggerThreshold();
179 //numberofvalues = 0;
180 } else {
181 tt = new TriggerThreshold();
182 //numberofvalues = 0;
183 }
184
185 //==================================================
186 // now get the cable info from TM_TT
187
188 string cableName = row["TM2TT.L1TM2TT_CABLE_NAME"].data<std::string>();
189 tt->setCableName (cableName);
190 tt->setCableCtpin (row["TM2TT.L1TM2TT_CABLE_CTPIN"].data<std::string>());
191 tt->setCableConnector(row["TM2TT.L1TM2TT_CABLE_CONNECTOR"].data<std::string>());
192 tt->setCableStart (row["TM2TT.L1TM2TT_CABLE_START"].data<int>());
193 tt->setCableEnd (row["TM2TT.L1TM2TT_CABLE_END"].data<int>());
194
195 int clock = 0;
196 if(isRun2()) {
197 clock = row["TM2TT.L1TM2TT_CABLE_CLOCK"].data<int>();
198 }
199 if(clock >= 0) {
200 tt->setClock(clock);
201 }
202 tt->setId (row["TT.L1TT_ID"].data<int>());
203 tt->setName (row["TT.L1TT_NAME"].data<std::string>());
204 tt->setVersion(row["TT.L1TT_VERSION"].data<int>());
205 string thrtype(row["TT.L1TT_TYPE"].data<std::string>());
206 tt->setType (thrtype);
207 tt->setActive (row["TT.L1TT_ACTIVE"].data<int>());
208 tt->setMapping(row["TT.L1TT_MAPPING"].data<int>());
209 tt->setBitnum(row["TT.L1TT_BITNUM"].data<int>());
210 tt->setInput ( (thrtype=="TOPO" || thrtype=="ALFA") ? "ctpcore" : "ctpin" );
211
212 TRG_MSG_VERBOSE("ThresholdConfigLoader loading threshold with ID = " << tt->id() << " for MenuId = " << menuid << ": ");
213 }
214
218 } else {
219
220 TriggerThresholdValue* ttv = tt->createThresholdValue(row["TT.L1TT_TYPE"].data<std::string>());
221
222 ttv->setId (row["TTV.L1TTV_ID"].data<int>());
223
224 // Fill the value common for all threshold_value
225 ttv->setName (row["TTV.L1TTV_NAME"].data<std::string>());
226 ttv->setVersion (row["TTV.L1TTV_VERSION"].data<int>());
227 ttv->setType (row["TTV.L1TTV_TYPE"].data<std::string>());
228 float ptcut = std::stof(row["TTV.L1TTV_PT_CUT"].data<std::string>());
229 string emisolation = row["TTV.L1TTV_EM_ISOLATION"].data<std::string>();
230 string hadisolation = row["TTV.L1TTV_HAD_ISOLATION"].data<std::string>();
231 string hadveto = row["TTV.L1TTV_HAD_VETO"].data<std::string>();
232 float priority = std::stof(row["TTV.L1TTV_PRIORITY"].data<std::string>());
233 ttv->setPtcut (ptcut);
234 ttv->setPriority (priority);
235
236 //is it a cluster_threshold_value?
237 try {
238 ClusterThresholdValue& ctv = dynamic_cast<ClusterThresholdValue&>(*ttv);
239 if (ttv->type() != L1DataDef::typeAsString(L1DataDef::EM) &&
240 ttv->type() != L1DataDef::typeAsString(L1DataDef::TAU)) {
241 msg() << "ThresholdConfigLoader >> No type match for ttv_id = "
242 << ctv.id() << " " << ttv->type() << std::endl;
243 throw std::runtime_error( "ThresholdConfigLoader >> ClusterThresholdValue not available" );
244 }
245
246 if(hadveto=="USEISOBITS" || std::stoi(hadveto)==99 ) {
247 ctv.setEmIsolation( 63 );
248 ctv.setHadIsolation( 63 );
249 ctv.setHadVeto( 99 );
250 ctv.setIsolationMask( TrigConf::bin2uint(emisolation) );
251 ctv.setUseIsolationMask();
252 } else {
253 ctv.setEmIsolation( std::stof(emisolation) );
254 ctv.setHadIsolation( std::stof(hadisolation) );
255 ctv.setHadVeto( std::stof(hadveto) );
256 ctv.setUseIsolationMask( false );
257 }
258
259 } catch (std::bad_cast& ex) { }
260
261 //is it a jet_threshold_value?
262 try {
263 JetThresholdValue& jtv = dynamic_cast<JetThresholdValue&>(*ttv);
264 if (ttv->type() != L1DataDef::typeAsString(L1DataDef::JET) &&
265 ttv->type() != L1DataDef::typeAsString(L1DataDef::JB) &&
266 ttv->type() != L1DataDef::typeAsString(L1DataDef::JF)) {
267 TRG_MSG_ERROR("No type match for ttv_id = " << jtv.id() << ttv->type());
268 throw std::runtime_error( "ThresholdConfigLoader >> TriggerThresholdValue not available" );
269 }
270 // jtv.setPhiMin(row["TTV.L1TTV_PHI_MIN"].data<int>());
271 // jtv.setPhiMax(row["TTV.L1TTV_PHI_MAX"].data<int>());
272 // jtv.setEtaMin(row["TTV.L1TTV_ETA_MIN"].data<int>());
273 // jtv.setEtaMax(row["TTV.L1TTV_ETA_MAX"].data<int>());
274 // jtv.setWindow(row["TTV.L1TTV_WINDOW"].data<int>());
275 } catch (std::bad_cast& ex) { }
276
277 ttv->setPhiMin(row["TTV.L1TTV_PHI_MIN"].data<int>());
278 ttv->setPhiMax(row["TTV.L1TTV_PHI_MAX"].data<int>());
279 ttv->setEtaMin(row["TTV.L1TTV_ETA_MIN"].data<int>());
280 ttv->setEtaMax(row["TTV.L1TTV_ETA_MAX"].data<int>());
281 ttv->setWindow(row["TTV.L1TTV_WINDOW"].data<int>());
282 tt->addThresholdValue(ttv);
283 //++numberofvalues;
284 TRG_MSG_DEBUG("ThresholdConfigLoader loading thresholdvalue with ID = " << ttv->id() << ": " << ttv->name());
285 }
286
287 nRowsLoop2 = row["TT.L1TT_ID"].data<int>();
288
289 }
290
291 // trigger thresholds sorted by type
292 thrConfig.addTriggerThreshold(tt);
293
294 //===========================================
295 // now get the Thresholds WITHOUT trigger threshold values
296 // we are aware that some code is duplicated below
297 // it is done this way because most Thresholds are WITH trigger threshold values
298
299 if (!m_session.transaction().isActive()) m_session.transaction().start();
300 unique_ptr<coral::IQuery> query1(m_session.nominalSchema().newQuery());
301
302 // Set the tables that are used
303 query1->addToTableList ( "L1_TM_TO_TT", "TM2TT" );
304 query1->addToTableList ( "L1_TRIGGER_THRESHOLD", "TT" );
305
306 // Bind list
307 coral::AttributeList bindList1;
308 bindList1.extend<int>("menuId");
309 bindList1[0].data<int>() = menuid;
310 std::string theCondition1 = "";
311 theCondition1 += std::string( " TM2TT.L1TM2TT_TRIGGER_MENU_ID = :menuId" );
312 theCondition1 += std::string( " AND TM2TT.L1TM2TT_TRIGGER_THRESHOLD_ID = TT.L1TT_ID" );
313 query1->setCondition( theCondition1, bindList1 );
314
315 // Output data and types
316 coral::AttributeList attList1;
317 attList1.extend<std::string>( "TM2TT.L1TM2TT_CABLE_NAME" );
318 attList1.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CTPIN" );
319 attList1.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CONNECTOR" );
320 attList1.extend<int> ( "TM2TT.L1TM2TT_CABLE_START" );
321 attList1.extend<int> ( "TM2TT.L1TM2TT_CABLE_END" );
322 if(isRun2()) {
323 attList1.extend<int> ( "TM2TT.L1TM2TT_CABLE_CLOCK" );
324 }
325 attList1.extend<int> ( "TT.L1TT_ID" );
326 attList1.extend<std::string>( "TT.L1TT_NAME" );
327 attList1.extend<int> ( "TT.L1TT_VERSION" );
328 attList1.extend<std::string>( "TT.L1TT_TYPE" );
329 attList1.extend<int> ( "TT.L1TT_ACTIVE" );
330 attList1.extend<int> ( "TT.L1TT_MAPPING" );
331 if( isRun2() || (schema_version >= schema_version_with_zb_fields) ) {
332 attList1.extend<int> ( "TT.L1TT_BCDELAY" );
333 attList1.extend<std::string>( "TT.L1TT_SEED" );
334 attList1.extend<int> ( "TT.L1TT_SEED_MULTI" );
335 }
336 fillQuery(query1.get(), attList1);
337
338 // the ordering
339 std::string theOrder1 = "";
340 theOrder1 += " TT.L1TT_ID ASC";
341 query1->addToOrderList( theOrder1 );
342
343 //query->setRowCacheSize(1000);
344 query1->setRowCacheSize(500);
345
346 coral::ICursor& cursor1 = query1->execute();
347
348 //numberofvalues = 0;
349 tt = 0;
350 nRowsLoop1 = -2009;
351 nRowsLoop2 = -2010;
352
353 while (cursor1.next()) {
354
355 const coral::AttributeList& row = cursor1.currentRow();
356
357 nRowsLoop1 = row["TT.L1TT_ID"].data<int>();
358 tt = thrConfig.findTriggerThreshold(nRowsLoop1);
359 if (tt) continue;
360 if (nRowsLoop1 != nRowsLoop2) {
361
362 if (tt != 0) {
363 //tt->setNumberofValues(numberofvalues);
364 // trigger thresholds sorted by type
365 thrConfig.addTriggerThreshold(tt);
366 tt = new TriggerThreshold();
367 //numberofvalues = 0;
368 } else {
369 tt = new TriggerThreshold();
370 //numberofvalues = 0;
371 }
372
373 //==================================================
374 // now get the cable info from TM_TT
375
376 // ttldr.setLoadCableInfo(true); will be moved from tt to thrcfg loader
377
378 string cableName = row["TM2TT.L1TM2TT_CABLE_NAME"].data<std::string>();
379 tt->setCableName(cableName);
380 tt->setCableCtpin (row["TM2TT.L1TM2TT_CABLE_CTPIN"].data<std::string>());
381 tt->setCableConnector(row["TM2TT.L1TM2TT_CABLE_CONNECTOR"].data<std::string>());
382 tt->setCableStart (row["TM2TT.L1TM2TT_CABLE_START"].data<int>());
383 tt->setCableEnd (row["TM2TT.L1TM2TT_CABLE_END"].data<int>());
384
385 int clock = 0;
386 if(isRun2()) {
387 clock = row["TM2TT.L1TM2TT_CABLE_CLOCK"].data<int>();
388 }
389 if(clock >= 0) {
390 tt->setClock(clock);
391 }
392 tt->setId (row["TT.L1TT_ID"].data<int>());
393 tt->setName (row["TT.L1TT_NAME"].data<std::string>());
394 tt->setVersion(row["TT.L1TT_VERSION"].data<int>());
395 string thrtype(row["TT.L1TT_TYPE"].data<std::string>());
396 tt->setType (thrtype);
397 tt->setActive (row["TT.L1TT_ACTIVE"].data<int>());
398 tt->setMapping(row["TT.L1TT_MAPPING"].data<int>());
399 tt->setInput ( (thrtype=="TOPO" || thrtype=="ALFA") ? "ctpcore" : "ctpin" );
400
401
402 // zero bias related
403 int bcdelay(-1), seed_multi(-1);
404 std::string seed("");
405 if( isRun2() || (schema_version >= schema_version_with_zb_fields) ) {
406 bcdelay = row["TT.L1TT_BCDELAY"].data<int>();
407 seed = row["TT.L1TT_SEED"].data<std::string>();
408 seed_multi = row["TT.L1TT_SEED_MULTI"].data<int>();
409 }
410 tt->setBCDelay (bcdelay);
411 tt->setZBSeedingThresholdName (seed);
412 tt->setZBSeedingThresholdMulti(seed_multi);
413
414 TRG_MSG_VERBOSE("ThresholdConfigLoader loading threshold with ID = " << tt->id() << " for MenuId = " << menuid << ": ");
415 //tt->setNumberofValues(numberofvalues);
416 // trigger thresholds sorted by type
417 thrConfig.addTriggerThreshold(tt);
418 tt = nullptr;
419 }
420
421 nRowsLoop2 = row["TT.L1TT_ID"].data<int>();
422
423 }
425 }
426 catch( const coral::Exception& e ) {
427 TRG_MSG_ERROR("Caught coral exception: " << e.what() );
428 throw;
429 }
430 catch( const std::exception& e ) {
431 TRG_MSG_ERROR("Caught standard exception: " << e.what() );
432 throw;
433 }
434
435 loadCaloInfo(thrConfig, caloinfoid);
436
437 // create TIPs from TOPO and ALFA TriggerThresholds
438
439 return true;
440
441}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
void commitSession()
commit session if not already done
Definition DBLoader.cxx:45
unsigned int triggerDBSchemaVersion()
Definition DBLoader.cxx:76
void startSession()
start session if not already active
Definition DBLoader.cxx:35
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
void loadCaloInfo(ThresholdConfig &thrConfig, long caloInfoId)
MsgStreamTC & msg() const
The standard message stream.
row
Appending html table to final .html summary file.
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition DBHelper.cxx:13
query
Definition index.py:72

◆ loadCaloInfo()

void TrigConf::ThresholdConfigLoader::loadCaloInfo ( ThresholdConfig & thrConfig,
long caloInfoId )
private

Definition at line 446 of file ThresholdConfigLoader.cxx.

446 {
447 //============================================
448 // get CaloInfo
449 //============================================
450 try {
451 startSession();
452 CaloInfoLoader& cildr = dynamic_cast<CaloInfoLoader&>
453 ((dynamic_cast<StorageMgr&>(m_storageMgr)).caloInfoLoader());
454 cildr.setLevel(outputLevel());
455 CaloInfo ci;
456 ci.setId(caloInfoId);
457 if ( !cildr.load( ci )) {
458 TRG_MSG_ERROR("loading CaloInfo " << ci.id());
459 throw runtime_error( "ThresholdConfigLoader: Error loading CaloInfo" );
460 }
461 thrConfig.setCaloInfo(ci);
464 }
465 catch( const coral::Exception& e ) {
466 TRG_MSG_ERROR("Caught coral exception: " << e.what() );
467 throw;
468 }
469 catch( const std::exception& e ) {
470 TRG_MSG_ERROR("Caught standard exception: " << e.what() );
471 throw;
472 }
473}
StorageMgr & m_storageMgr
reference to the storage manager
Definition DBLoader.h:67
virtual MSGTC::Level outputLevel() const override
Definition DBLoader.h:40
static void setCaloInfo(const CaloInfo &ci)

◆ loadL1MasterKey()

bool TrigConf::DBLoader::loadL1MasterKey ( int SuperMasterKey,
int & Lvl1MasterKey )
inherited

get l1 master from super master

Definition at line 128 of file DBLoader.cxx.

128 {
129 try {
130 startSession();
131
132 unique_ptr< coral::IQuery > q( m_session.nominalSchema().tableHandle( "SUPER_MASTER_TABLE").newQuery() );
133 q->setRowCacheSize( 5 );
134
135 //Bind list
136 coral::AttributeList bindings;
137 bindings.extend<int>("smtid");
138 bindings[0].data<int>() = smk;
139 q->setCondition( "SMT_ID = :smtid", bindings );
140
141 //Output data and types
142 coral::AttributeList attList;
143 attList.extend<int>( "SMT_L1_MASTER_TABLE_ID" );
144 fillQuery(q.get(), attList);
145
146 coral::ICursor& cursor = q->execute();
147 if ( ! cursor.next() ) {
148 msg() << "DBLoader: No such SuperMaster key exists " << smk << endl;
149 throw runtime_error( "DBLoader: SuperMasterKey not available" );
150 }
151
152 const coral::AttributeList& row = cursor.currentRow();
153 Lvl1MasterKey = row["SMT_L1_MASTER_TABLE_ID"].data<int>();
154 }
155 catch( const std::exception& e ) {
157 msg() << "DBLoader: C++ exception: " << e.what() << std::endl;
158 throw;
159 }
161 return true;
162}

◆ loadL1MenuKey()

bool TrigConf::DBLoader::loadL1MenuKey ( int SuperMasterKey,
int & Lvl1MenuKey )
inherited

get l1 menu id from super master

Definition at line 167 of file DBLoader.cxx.

167 {
168 try {
169
170 int l1Master = 0;
171 loadL1MasterKey(SuperMasterKey, l1Master);
172
173 startSession();
174
175 unique_ptr< coral::IQuery > q( m_session.nominalSchema().tableHandle( "L1_MASTER_TABLE").newQuery() );
176 q->setRowCacheSize( 5 );
177
178 //Bind list
179 coral::AttributeList bindings;
180 bindings.extend<int>("l1mtid");
181 bindings[0].data<int>() = l1Master;
182 q->setCondition( "L1MT_ID = :l1mtid" , bindings );
183
184 //Output data and types
185 coral::AttributeList attList;
186 attList.extend<int>( "L1MT_TRIGGER_MENU_ID" );
187 q->defineOutput(attList);
188 q->addToOutputList( "L1MT_TRIGGER_MENU_ID" );
189
190 coral::ICursor& cursor = q->execute();
191 if ( ! cursor.next() ) {
192 msg() << "DBLoader >> No such L1 Master key exists " << l1Master << std::endl;
193 throw std::runtime_error( "DBLoader >> L1MasterKey not available" );
195 }
196
197 const coral::AttributeList& row = cursor.currentRow();
198 Lvl1MenuKey = row["L1MT_TRIGGER_MENU_ID"].data<int>();
199
201
202 }
203 catch( const std::exception& e ) {
204 msg() << "DBLoader >> Standard C++ exception: " << e.what() << std::endl;
205 m_session.transaction().rollback();
206 throw;
207 }
208 return true;
209}
bool loadL1MasterKey(int SuperMasterKey, int &Lvl1MasterKey)
get l1 master from super master
Definition DBLoader.cxx:128

◆ loadSchemaVersion()

std::tuple< unsigned int, unsigned int > DBLoader::loadSchemaVersion ( ) const
privateinherited

get DB schema version and run number

Definition at line 81 of file DBLoader.cxx.

82{
83 const static auto versions = [&]() -> std::tuple<unsigned int,unsigned int> {
84 bool mySession = false;
85 if ( ! m_session.transaction().isActive() ) {
86 m_session.transaction().start(true);
87 mySession = true;
88 }
89
90 std::unique_ptr< coral::IQuery > q( m_session.nominalSchema().tableHandle( "TRIGGER_SCHEMA").newQuery() );
91 q->setRowCacheSize( 1 );
92
93 //Output data and types
94 coral::AttributeList attList;
95 attList.extend<int>( "TS_ID" );
96 q->defineOutput(attList);
97 q->addToOutputList( "TS_ID" );
98
99 q->addToOrderList("TS_ID desc");
100 coral::ICursor& cursor = q->execute();
101
102 if ( ! cursor.next() ) {
103 TRG_MSG_ERROR("Table TRIGGER_SCHEMA is not filled");
104 if ( mySession ) m_session.transaction().commit();
105 throw std::runtime_error( "DBLoader::loadSchemaVersion() >> Table TRIGGER_SCHEMA is not filled" );
106 }
107
108 const coral::AttributeList& row = cursor.currentRow();
109 const unsigned int triggerDBSchemaVersion = row["TS_ID"].data<int>();
110
111 TRG_MSG_INFO("TriggerDB schema version: " << triggerDBSchemaVersion);
112
113 const unsigned int run = m_session.nominalSchema().existsTable( "ACTIVE_MASTERS" ) ? 2 : 1;
114
115 TRG_MSG_INFO("Database has Run " << run << " schema");
116 TRG_MSG_INFO("Total number of tables : " << m_session.nominalSchema().listTables().size());
117
118 //commitSession();
119 if ( mySession ) m_session.transaction().commit();
120
121 return {triggerDBSchemaVersion, run};
122 }();
123
124 return versions;
125}

◆ 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 {
88 MsgStreamTC* ms = m_msg_tls.get();
89 if (!ms) {
90 ms = new MsgStreamTC(m_name);
91 m_msg_tls.reset(ms);
92 }
93 return *ms;
94 }
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)

◆ msg() [2/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( const MSGTC::Level lvl) const
inlineinherited

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 {
98 return msg() << lvl;
99 }

◆ msgLvl()

bool TrigConf::TrigConfMessaging::msgLvl ( const MSGTC::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 75 of file TrigConfMessaging.h.

76 {
77 if (msg().level() <= lvl) {
78 msg() << lvl;
79 return true;
80 }
81 else {
82 return false;
83 }
84 }

◆ outputLevel()

virtual MSGTC::Level TrigConf::DBLoader::outputLevel ( ) const
inlineoverridevirtualinherited

Implements TrigConf::ILoader.

Definition at line 40 of file DBLoader.h.

40{ return msg().level(); }

◆ setLevel()

void DBLoader::setLevel ( MSGTC::Level lvl)
overridevirtualinherited

◆ setVerbose()

virtual void TrigConf::DBLoader::setVerbose ( int v)
inlineoverridevirtualinherited

Implements TrigConf::ILoader.

Definition at line 58 of file DBLoader.h.

◆ startSession()

void TrigConf::DBLoader::startSession ( )
inherited

start session if not already active

Definition at line 35 of file DBLoader.cxx.

36{
37 if ( ! m_session.transaction().isActive() ) {
38 //std::cout << "DBLoader: startSession(readonly=true)" << std::endl;
39 bool readOnly = true;
40 m_session.transaction().start(readOnly);
41 m_sessionOwner = true;
42 }
43}

◆ triggerDBSchemaVersion()

unsigned int DBLoader::triggerDBSchemaVersion ( )
inherited

Definition at line 76 of file DBLoader.cxx.

76 {
77 return std::get<0>(loadSchemaVersion());
78}

◆ verbose()

virtual int TrigConf::DBLoader::verbose ( ) const
inlineoverridevirtualinherited

Implements TrigConf::ILoader.

Definition at line 57 of file DBLoader.h.

57{ return m_verbose; }

Member Data Documentation

◆ m_msg_tls

boost::thread_specific_ptr<MsgStreamTC> TrigConf::TrigConfMessaging::m_msg_tls
mutableprivateinherited

MsgStreamTC instance (a std::cout like with print-out levels)

Definition at line 71 of file TrigConfMessaging.h.

◆ m_name

std::string TrigConf::TrigConfMessaging::m_name
privateinherited

Definition at line 72 of file TrigConfMessaging.h.

◆ m_session

coral::ISessionProxy& TrigConf::DBLoader::m_session
protectedinherited

CORAL interface to database session.

Definition at line 68 of file DBLoader.h.

◆ m_sessionOwner

bool TrigConf::DBLoader::m_sessionOwner {false}
protectedinherited

remember if the loader started the session in the first place

Definition at line 69 of file DBLoader.h.

69{false};

◆ m_storageMgr

StorageMgr& TrigConf::DBLoader::m_storageMgr
protectedinherited

reference to the storage manager

Definition at line 67 of file DBLoader.h.

◆ m_verbose

int TrigConf::DBLoader::m_verbose {1}
privateinherited

Definition at line 64 of file DBLoader.h.

64{1};

The documentation for this class was generated from the following files: