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

TriggerDB loader of the LVL1 LUT and CAM tables. More...

#include <CTPFilesLoader.h>

Inheritance diagram for TrigConf::CTPFilesLoader:
Collaboration diagram for TrigConf::CTPFilesLoader:

Public Member Functions

 CTPFilesLoader (StorageMgr &sm, coral::ISessionProxy &session)
 constructor
virtual ~CTPFilesLoader () override=default
 destructor
virtual bool load (CTPFiles &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

bool loadCtpcoreData (CTPFiles &)
bool loadCtpinData (CTPFiles &)
bool loadCtpmonData (CTPFiles &)
int getMenuIdFromMaster (int mid)
long getFilesIdFromMenu (int mid)
long getSmxIdFromMenu (int mid)
void parseHexString (std::vector< u_int > &vec, const std::string &str, bool verbose=false)
template<class T>
bool convert_hex_string (T &t, const std::string &s)
template<class T>
bool convert_string (T &t, const std::string &s)
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 LUT and CAM tables.

Definition at line 33 of file CTPFilesLoader.h.

Constructor & Destructor Documentation

◆ CTPFilesLoader()

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

constructor

Parameters
smreference to storage manager
sessionreference to the database session

Definition at line 42 of file CTPFilesLoader.h.

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

◆ ~CTPFilesLoader()

virtual TrigConf::CTPFilesLoader::~CTPFilesLoader ( )
overridevirtualdefault

destructor

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

◆ convert_hex_string()

template<class T>
bool TrigConf::CTPFilesLoader::convert_hex_string ( T & t,
const std::string & s )
inlineprivate

Definition at line 63 of file CTPFilesLoader.h.

64 {
65 std::istringstream iss(s);
66 return !(iss >> std::hex >> t).fail();
67 }
fail(message)

◆ convert_string()

template<class T>
bool TrigConf::CTPFilesLoader::convert_string ( T & t,
const std::string & s )
inlineprivate

Definition at line 71 of file CTPFilesLoader.h.

72 {
73 std::istringstream iss(s);
74 return !(iss >> t).fail();
75 }

◆ getFilesIdFromMenu()

long TrigConf::CTPFilesLoader::getFilesIdFromMenu ( int mid)
private

Definition at line 97 of file CTPFilesLoader.cxx.

97 {
98 coral::ITable& table = m_session.nominalSchema().tableHandle( "L1_TRIGGER_MENU");
99 coral::IQuery* query = table.newQuery();
100 query->setRowCacheSize( 5 );
101
102 //Binding
103 coral::AttributeList emptyBindVariableList0;
104 std::string condition = "L1TM_ID = :tmId";
105 emptyBindVariableList0.extend<int>("tmId");
106 emptyBindVariableList0[0].data<int>() = mid;
107 query->setCondition( condition, emptyBindVariableList0 );
108
109 coral::AttributeList attList;
110 attList.extend<int>( "L1TM_CTP_FILES_ID" );
111 query->defineOutput(attList);
112 query->addToOutputList( "L1TM_CTP_FILES_ID" );
113
114 coral::ICursor& cursor = query->execute();
115 if ( ! cursor.next() ) {
116 TRG_MSG_ERROR("No such Trigger_Menu exists " << mid);
117 delete query;
119 throw std::runtime_error( "CTPFilesLoader" );
120 }
121 const coral::AttributeList& row = cursor.currentRow();
122 return static_cast<long>(row["L1TM_CTP_FILES_ID"].data<int>());
123}
void commitSession()
commit session if not already done
Definition DBLoader.cxx:45
row
Appending html table to final .html summary file.
query
Definition index.py:72

◆ getMenuIdFromMaster()

int TrigConf::CTPFilesLoader::getMenuIdFromMaster ( int mid)
private

Definition at line 63 of file CTPFilesLoader.cxx.

63 {
64
65 unique_ptr<coral::IQuery> query( m_session.nominalSchema().tableHandle( "L1_MASTER_TABLE").newQuery() );
66 query->setRowCacheSize( 5 );
67
68 //Binding
69 coral::AttributeList emptyBindVariableList0;
70 std::string condition = "L1MT_ID = :mtId";
71 emptyBindVariableList0.extend<int>("mtId");
72 emptyBindVariableList0[0].data<int>() = mid;
73 query->setCondition( condition, emptyBindVariableList0 );
74
75 coral::AttributeList attList;
76 attList.extend<int>( "L1MT_TRIGGER_MENU_ID" );
77 fillQuery(query.get(),attList);
78
79 coral::ICursor& cursor = query->execute();
80 if ( ! cursor.next() ) {
81 TRG_MSG_ERROR("No such Master_Table exists " << mid);
83 throw std::runtime_error( "CTPFilesLoader" );
84 }
85 const coral::AttributeList& row = cursor.currentRow();
86 int menuid = row["L1MT_TRIGGER_MENU_ID"].data<int>();
87 if ( cursor.next() ) {
88 TRG_MSG_ERROR("More than one Master_Table exists " << mid);
90 throw std::runtime_error( "CTPFilesLoader >> Master_Table not available" );
91 }
92 return menuid;
93}
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition DBHelper.cxx:13

◆ 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 }

◆ getSmxIdFromMenu()

long TrigConf::CTPFilesLoader::getSmxIdFromMenu ( int mid)
private

Definition at line 127 of file CTPFilesLoader.cxx.

127 {
128 coral::ITable& table = m_session.nominalSchema().tableHandle( "L1_TRIGGER_MENU");
129 coral::IQuery* query = table.newQuery();
130 query->setRowCacheSize( 5 );
131
132 //Binding
133 coral::AttributeList emptyBindVariableList0;
134 std::string condition = "L1TM_ID = :tmId";
135 emptyBindVariableList0.extend<int>("tmId");
136 emptyBindVariableList0[0].data<int>() = mid;
137 query->setCondition( condition, emptyBindVariableList0 );
138
139 coral::AttributeList attList;
140 attList.extend<int>( "L1TM_CTP_SMX_ID" );
141 query->defineOutput(attList);
142 query->addToOutputList( "L1TM_CTP_SMX_ID" );
143
144 coral::ICursor& cursor = query->execute();
145 if ( ! cursor.next() ) {
146 TRG_MSG_ERROR("No such Trigger_Menu exists " << mid);
147 delete query;
149 throw std::runtime_error( "CTPFilesLoader" );
150 }
151 const coral::AttributeList& row = cursor.currentRow();
152 return static_cast<long>(row["L1TM_CTP_SMX_ID"].data<int>());
153}

◆ 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::CTPFilesLoader::load ( CTPFiles & data)
overridevirtual

Implements TrigConf::ICTPFilesLoader.

Definition at line 46 of file CTPFilesLoader.cxx.

46 {
47 bool retVal = true;
49 if(isRun1()) {
50 data.setFileSizes(1);
51 } else {
52 data.setFileSizes(2);
53 }
54
55 if( data.loadCtpcoreFiles() ) retVal &= loadCtpcoreData(data);
56 if( data.loadCtpinFiles() ) retVal &= loadCtpinData(data);
57 if( data.loadCtpmonFiles() ) retVal &= loadCtpmonData(data);
58 return retVal;
59}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
bool loadCtpcoreData(CTPFiles &)
bool loadCtpinData(CTPFiles &)
bool loadCtpmonData(CTPFiles &)
unsigned int triggerDBSchemaVersion()
Definition DBLoader.cxx:76

◆ loadCtpcoreData()

bool TrigConf::CTPFilesLoader::loadCtpcoreData ( CTPFiles & ctpFiles)
private

Definition at line 158 of file CTPFilesLoader.cxx.

158 {
159
160 TRG_MSG_INFO("start loading CTPCORE data");
161 try {
162 startSession();
163 // first check if we need to obtain the CTP files ID, or if it
164 // was passed in
165 if(ctpFiles.id() <= 0) {
166 int l1id = ctpFiles.lvl1MasterTableId();
167 int menuid = getMenuIdFromMaster(l1id);
168 long filesid = getFilesIdFromMenu(menuid);
169 ctpFiles.setId(filesid);
170 }
171
172 unique_ptr<coral::IQuery> query( m_session.nominalSchema().tableHandle( "L1_CTP_FILES").newQuery() );
173 query->setRowCacheSize( 10 );
174
175 //Binding
176 coral::AttributeList emptyBindVariableList0;
177 emptyBindVariableList0.extend<long>("fId");
178 emptyBindVariableList0[0].data<long>() = ctpFiles.id();
179 query->setCondition( "L1CF_ID = :fId", emptyBindVariableList0 );
180
181 coral::AttributeList attList;
182 attList.extend<std::string>( "L1CF_NAME" );
183 attList.extend<int>( "L1CF_VERSION" );
184 attList.extend<std::string>( "L1CF_LUT" );
185 attList.extend<std::string>( "L1CF_CAM" );
186 fillQuery(query.get(),attList);
187
188 coral::ICursor& cursor = query->execute();
189
190 if ( ! cursor.next() ) {
191 TRG_MSG_ERROR("No such L1_CTP_Files exists " << ctpFiles.id());
193 throw std::runtime_error( "CTPFilesLoader >> CTPFiles not available" );
194 }
195
196 const coral::AttributeList& row = cursor.currentRow();
197 std::string name = row["L1CF_NAME"].data<std::string>();
198 int version = row["L1CF_VERSION"].data<int>();
199 std::string ctpcoreLUT_str = row["L1CF_LUT"].data<std::string>();
200 std::string ctpcoreCAM_str = row["L1CF_CAM"].data<std::string>();
201
202 if ( cursor.next() ) {
203 TRG_MSG_ERROR("More than one GetFile exists " << ctpFiles.id());
205 throw std::runtime_error( "CTPFilesLoader >> CTPFiles not available" );
206 }
207
208 std::vector<u_int> lutVec(CTPFiles::ALL_CTPCORELUT_SIZE);
209 TRG_MSG_INFO("Loading LUT of size " << lutVec.size());
210 parseHexString(lutVec, ctpcoreLUT_str, true);
211
212 std::vector<u_int> camVec(CTPFiles::ALL_CTPCORECAM_SIZE);
213 TRG_MSG_INFO("Loading CAM of size " << camVec.size());
214 parseHexString(camVec,ctpcoreCAM_str);
215
216 // Fill the object with data
217 ctpFiles.setName( name );
218 ctpFiles.setVersion( version );
219 ctpFiles.setCtpcoreLUT(lutVec);
220 ctpFiles.setCtpcoreCAM(camVec);
221
223 } catch( const coral::Exception& e ) {
224 TRG_MSG_ERROR("coral::Exception: " << e.what());
226 throw;
227 }
228 return true;
229}
void parseHexString(std::vector< u_int > &vec, const std::string &str, bool verbose=false)
void startSession()
start session if not already active
Definition DBLoader.cxx:35

◆ loadCtpinData()

bool TrigConf::CTPFilesLoader::loadCtpinData ( CTPFiles & ctpFiles)
private

Definition at line 231 of file CTPFilesLoader.cxx.

231 {
232 TRG_MSG_INFO("start loading CTPIN data");
233 try {
234 startSession();
235 // first check if we need to obtain the CTP files ID, or if it
236 // was passed in
237 if(ctpFiles.id() <= 0 || ctpFiles.smxId() <= 0) {
238 int l1id = ctpFiles.lvl1MasterTableId();
239 int menuid = getMenuIdFromMaster(l1id);
240 if(ctpFiles.id() <= 0) {
241 long filesid = getFilesIdFromMenu(menuid);
242 ctpFiles.setId(filesid);
243 }
244 if(ctpFiles.smxId() <= 0) {
245 long id = getSmxIdFromMenu(menuid);
246 ctpFiles.setSmxId(id);
247 }
248 }
249
250 { // restrict scope to re-use variables
251 unique_ptr<coral::IQuery> query( m_session.nominalSchema().tableHandle( "L1_CTP_FILES").newQuery() );
252 query->setRowCacheSize( 13 );
253
254 //Binding
255 coral::AttributeList emptyBindVariableList0;
256 std::string condition = "L1CF_ID = :fId";
257 emptyBindVariableList0.extend<long>("fId");
258 emptyBindVariableList0[0].data<long>() = ctpFiles.id();
259 query->setCondition( condition, emptyBindVariableList0 );
260
261 coral::AttributeList attList;
262 attList.extend<std::string>( "L1CF_NAME" );
263 attList.extend<int>( "L1CF_VERSION" );
264 attList.extend<std::string>( "L1CF_MON_SEL_SLOT7" );
265 attList.extend<std::string>( "L1CF_MON_SEL_SLOT8" );
266 attList.extend<std::string>( "L1CF_MON_SEL_SLOT9" );
267 attList.extend<std::string>( "L1CF_MON_DEC_SLOT7" );
268 attList.extend<std::string>( "L1CF_MON_DEC_SLOT8" );
269 attList.extend<std::string>( "L1CF_MON_DEC_SLOT9" );
270 fillQuery(query.get(),attList);
271
272 coral::ICursor& cursor = query->execute();
273 if ( ! cursor.next() ) {
274 TRG_MSG_ERROR("No such L1_CTP_Files exists " << ctpFiles.id());
276 throw std::runtime_error( "CTPFilesLoader >> CTPFiles not available" );
277 }
278
279 const coral::AttributeList& row = cursor.currentRow();
280 std::string name = row["L1CF_NAME"].data<std::string>();
281 int version = row["L1CF_VERSION"].data<int>();
282 std::string strMonSel7 = row["L1CF_MON_SEL_SLOT7"].data<std::string>();
283 std::string strMonSel8 = row["L1CF_MON_SEL_SLOT8"].data<std::string>();
284 std::string strMonSel9 = row["L1CF_MON_SEL_SLOT9"].data<std::string>();
285 std::string strMonDec7 = row["L1CF_MON_DEC_SLOT7"].data<std::string>();
286 std::string strMonDec8 = row["L1CF_MON_DEC_SLOT8"].data<std::string>();
287 std::string strMonDec9 = row["L1CF_MON_DEC_SLOT9"].data<std::string>();
288
289 if ( cursor.next() ) {
290 TRG_MSG_ERROR("More than one GetFile exists " << ctpFiles.id());
292 throw std::runtime_error( "CTPFilesLoader >> CTPFiles not available" );
293 }
294
295 std::vector<u_int> monDecSlot7(CTPFiles::ALL_CTPINMONDEC_SIZE);
296 TRG_MSG_INFO("Loading MON Slot7 of size " << monDecSlot7.size());
297 parseHexString(monDecSlot7,strMonDec7);
298 std::vector<u_int> monDecSlot8(CTPFiles::ALL_CTPINMONDEC_SIZE);
299 TRG_MSG_INFO("Loading MON Slot8 of size " << monDecSlot8.size());
300 parseHexString(monDecSlot8,strMonDec8);
301 std::vector<u_int> monDecSlot9(CTPFiles::ALL_CTPINMONDEC_SIZE);
302 TRG_MSG_INFO("Loading MON Slot9 of size " << monDecSlot9.size());
303 parseHexString(monDecSlot9,strMonDec9);
304
305 std::vector<u_int> monSelSlot7(CTPFiles::ALL_CTPINMONSEL_SIZE);
306 TRG_MSG_INFO("Loading MON SEL Slot7 of size " << monSelSlot7.size());
307 parseHexString(monSelSlot7,strMonSel7);
308 std::vector<u_int> monSelSlot8(CTPFiles::ALL_CTPINMONSEL_SIZE);
309 TRG_MSG_INFO("Loading MON SEL Slot8 of size " << monSelSlot8.size());
310 parseHexString(monSelSlot8,strMonSel8);
311 std::vector<u_int> monSelSlot9(CTPFiles::ALL_CTPINMONSEL_SIZE);
312 TRG_MSG_INFO("Loading MON SEL Slot9 of size " << monSelSlot9.size());
313 parseHexString(monSelSlot9,strMonSel9);
314
315 // Fill the object with data
316 ctpFiles.setName( name );
317 ctpFiles.setVersion( version );
318 ctpFiles.setCtpinMonDecoderSlot7(monDecSlot7);
319 ctpFiles.setCtpinMonDecoderSlot8(monDecSlot8);
320 ctpFiles.setCtpinMonDecoderSlot9(monDecSlot9);
321 ctpFiles.setCtpinMonSelectorSlot7(monSelSlot7);
322 ctpFiles.setCtpinMonSelectorSlot8(monSelSlot8);
323 ctpFiles.setCtpinMonSelectorSlot9(monSelSlot9);
324 }
325
326 {
327 unique_ptr<coral::IQuery> query( m_session.nominalSchema().tableHandle( "L1_CTP_SMX").newQuery() );
328 query->setRowCacheSize( 13 );
329
330 //Binding
331 coral::AttributeList emptyBindVariableList0;
332 std::string condition = "L1SMX_ID = :sId";
333 emptyBindVariableList0.extend<long>("sId");
334 emptyBindVariableList0[0].data<long>() = ctpFiles.smxId();
335 query->setCondition( condition, emptyBindVariableList0 );
336
337 coral::AttributeList attList;
338 attList.extend<std::string>( "L1SMX_NAME" );
339 attList.extend<std::string>( "L1SMX_OUTPUT" );
340 attList.extend<std::string>( "L1SMX_VHDL_SLOT7" );
341 attList.extend<std::string>( "L1SMX_VHDL_SLOT8" );
342 attList.extend<std::string>( "L1SMX_VHDL_SLOT9" );
343 attList.extend<std::string>( "L1SMX_SVFI_SLOT7" );
344 attList.extend<std::string>( "L1SMX_SVFI_SLOT8" );
345 attList.extend<std::string>( "L1SMX_SVFI_SLOT9" );
346 fillQuery(query.get(),attList);
347
348 coral::ICursor& cursor = query->execute();
349 if ( ! cursor.next() ) {
350 TRG_MSG_ERROR("No such L1_CTP_SMX entry " << ctpFiles.smxId() << " exists");
352 throw std::runtime_error( "CTPFilesLoader >> CTPFiles not available" );
353 }
354
355 const coral::AttributeList& row = cursor.currentRow();
356 ctpFiles.setSmxName(row["L1SMX_NAME"].data<std::string>());
357 ctpFiles.setCtpinSmxOutput(row["L1SMX_OUTPUT"].data<std::string>());
358
359 ctpFiles.setCtpinSmxVhdlSlot7(row["L1SMX_VHDL_SLOT7"].data<std::string>());
360 ctpFiles.setCtpinSmxVhdlSlot8(row["L1SMX_VHDL_SLOT8"].data<std::string>());
361 ctpFiles.setCtpinSmxVhdlSlot9(row["L1SMX_VHDL_SLOT9"].data<std::string>());
362 ctpFiles.setCtpinSmxSvfiSlot7(row["L1SMX_SVFI_SLOT7"].data<std::string>());
363 ctpFiles.setCtpinSmxSvfiSlot8(row["L1SMX_SVFI_SLOT8"].data<std::string>());
364 ctpFiles.setCtpinSmxSvfiSlot9(row["L1SMX_SVFI_SLOT9"].data<std::string>());
365 }
366
368 }
369 catch( const coral::Exception& e ) {
370 TRG_MSG_ERROR("coral::Exception: " << e.what());
372 throw;
373 }
374 return true;
375}

◆ loadCtpmonData()

bool TrigConf::CTPFilesLoader::loadCtpmonData ( CTPFiles & ctpFiles)
private

Definition at line 379 of file CTPFilesLoader.cxx.

379 {
380 TRG_MSG_INFO("start loading CTPMON data");
381 try {
382 startSession();
383 // first check if we need to obtain the CTP files ID, or if it
384 // was passed in
385 if(ctpFiles.id() <= 0) {
386 int l1id = ctpFiles.lvl1MasterTableId();
387 int menuid = getMenuIdFromMaster(l1id);
388 long filesid = getFilesIdFromMenu(menuid);
389 ctpFiles.setId(filesid);
390 }
391
392 unique_ptr<coral::IQuery> query( m_session.nominalSchema().tableHandle( "L1_CTP_FILES").newQuery() );
393 query->setRowCacheSize( 13 );
394
395 //Binding
396 coral::AttributeList emptyBindVariableList0;
397 std::string condition = "L1CF_ID = :fId";
398 emptyBindVariableList0.extend<long>("fId");
399 emptyBindVariableList0[0].data<long>() = ctpFiles.id();
400 query->setCondition( condition, emptyBindVariableList0 );
401
402 coral::AttributeList attList;
403 attList.extend<std::string>( "L1CF_NAME" );
404 attList.extend<int>( "L1CF_VERSION" );
405 attList.extend<std::string>( "L1CF_MON_SEL_CTPMON" );
406 attList.extend<std::string>( "L1CF_MON_DEC_CTPMON" );
407 fillQuery(query.get(),attList);
408
409
410 coral::ICursor& cursor = query->execute();
411 if ( ! cursor.next() ) {
412 TRG_MSG_ERROR("No such L1_CTP_Files exists " << ctpFiles.id());
414 throw std::runtime_error( "CTPFilesLoader >> CTPFiles not available" );
415 }
416
417 const coral::AttributeList& row = cursor.currentRow();
418
419 std::string name = row["L1CF_NAME"].data<std::string>();
420 int version = row["L1CF_VERSION"].data<int>();
421 std::string ctpmonSelector_str = row["L1CF_MON_SEL_CTPMON"].data<std::string>();
422 std::string ctpmonDecoder_str = row["L1CF_MON_DEC_CTPMON"].data<std::string>();
423
424 if ( cursor.next() ) {
425 TRG_MSG_ERROR("More than one GetFile exists " << ctpFiles.id());
427 throw std::runtime_error( "CTPFilesLoader >> CTPFiles not available" );
428 }
429
430 std::vector<u_int> monDecVec(CTPFiles::ALL_CTPMONDECODER_SIZE);
431 TRG_MSG_INFO("Loading MON DEC vec of size " << monDecVec.size());
432 parseHexString(monDecVec,ctpmonDecoder_str);
433
434 //Selector for CTPMON - note the different format requires
435 //different parsing here!
436 std::vector<u_int> monSelVec(CTPFiles::ALL_CTPMONSELECTOR_SIZE);
437 std::stringstream stream(ctpmonSelector_str);
438 std::string val;
439 u_int index = 0;
440 u_int data = 0;
441 while(stream >> val) {
442 // get rid of possible '0x'
443 std::string::size_type loc = val.find("0x");
444 if(loc != std::string::npos) val.replace(loc,2,"");
445 if(!convert_string<u_int>(data, val)) {
446 TRG_MSG_ERROR("Conversion of CTPMONSELECTOR no" << index << " failed!");
448 throw std::runtime_error( "CTPFilesLoader >> CTPMONSELECTOR conversion failed." );
449 }
450 if( index >= CTPFiles::ALL_CTPMONSELECTOR_SIZE) {
451 TRG_MSG_ERROR("CTPMON selector word no" << index << " out of bounds");
453 throw std::runtime_error( "CTPFilesLoader >> CTPMONSELECTOR conversion failed." );
454 }
455 monSelVec[index] = data;
456 ++index;
457 }
458
459 // Fill the object with data
460 ctpFiles.setName( name );
461 ctpFiles.setVersion( version );
462 ctpFiles.setCtpmonDecoder(monDecVec);
463 ctpFiles.setCtpmonSelector(monSelVec);
464
466 }
467 catch( const coral::Exception& e ) {
468 TRG_MSG_ERROR("coral::Exception: " << e.what());
470 throw;
471 }
472 return true;
473}
bool convert_string(T &t, const std::string &s)
str index
Definition DeMoScan.py:362

◆ 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}
MsgStreamTC & msg() const
The standard message stream.

◆ 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(); }

◆ parseHexString()

void TrigConf::CTPFilesLoader::parseHexString ( std::vector< u_int > & vec,
const std::string & str,
bool verbose = false )
private

Definition at line 476 of file CTPFilesLoader.cxx.

476 {
477 u_int data;
478 const static u_int significantBits = 8;
479 const static u_int preFix = 2;
480 const static u_int postFix = 1;
481 const static u_int wordsize = (preFix + significantBits + postFix);
482
483 if(str.size() != 0) {
484 if(str.size() != wordsize * vec.size()) {
485 TRG_MSG_ERROR("File content from DB of size " << str.size() << ", but expects " << wordsize * vec.size() << " [11 * " << vec.size() << "]");
486 throw std::runtime_error( "CTPFilesLoader: file of unexpected size" );
487 }
488 } else {
489 TRG_MSG_INFO("DB File content is 0, which is expected for MC, Reprocessing, and ATN databases");
490 return;
491 }
492
493 for(u_int i=0; i < vec.size(); ++i) {
494 if( ! convert_hex_string<u_int>(data, str.substr(i*wordsize+preFix,significantBits))) {
495 TRG_MSG_ERROR("Conversion no " << i << " failed!");
497 throw std::runtime_error( "CTPFilesLoader >> Conversion failed." );
498 }
499 if(verbose) {
500 //cout << "joerg " << str.substr(i*wordsize+preFix,significantBits) << " -----> " << i << " " << data << endl;
501 }
502 vec[i] = data;
503 }
504}
std::vector< size_t > vec
bool convert_hex_string(T &t, const std::string &s)
virtual int verbose() const override
Definition DBLoader.h:57

◆ 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: