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

TriggerDB loader of the HLT job options. More...

#include <JobOptionTableLoader.h>

Inheritance diagram for TrigConf::JobOptionTableLoader:
Collaboration diagram for TrigConf::JobOptionTableLoader:

Classes

class  SplitParam

Public Member Functions

 JobOptionTableLoader (StorageMgr &sm, coral::ISessionProxy &session)
 constructor
virtual ~JobOptionTableLoader () override=default
 destructor
virtual bool load (TrigConfData &data)
void defineQueries ()
MsgStreamTCmsg () const
 The standard message stream.
MsgStreamTCmsg (const MSGTC::Level lvl) const
 The standard message stream.
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.
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 load (JobOptionTable &jot) override
bool loadHLTMasterTable (int SuperMasterKey, int &masterTableID, int &triggerMenuID, int &l2SetupID, int &efSetupID)
bool loadComponentNamesAndParameters (TrigConf::JobOptionTable &JOTable, const std::set< int > &compIDsToLoad)
bool loadComponentNamesAndParameters (TrigConf::JobOptionTable &JOTable, const std::set< int > &compIDsToLoad, std::vector< SplitParam > &splitparams, std::set< int >::const_iterator &current, unsigned int batchSize)
std::set< int > loadComponentIDsFromSetup (const int setup_id)
std::set< int > loadComponentIDsFromMenu (const int menu_id, int triggerLevel)
std::set< int > getChildCompIDs (const std::set< int > &compIDs)
std::string buildCond_IN_ (const std::string &field, const std::set< int > &IDs, std::set< int >::const_iterator &current, unsigned int batchSize)
unsigned int assembleSplitParameters (JobOptionTable &jot, const std::vector< SplitParam > &splitparams)
unsigned int assembleSplitParameters2 (JobOptionTable &jot, const std::vector< SplitParam > &splitparams)
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 HLT job options.

Definition at line 35 of file JobOptionTableLoader.h.

Constructor & Destructor Documentation

◆ JobOptionTableLoader()

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

constructor

Parameters
smreference to storage manager
sessionreference to the database session

Definition at line 48 of file JobOptionTableLoader.h.

49 : DBLoader("JobOptionTableLoader", sm, session)
50 {}
DBLoader(StorageMgr &sm, coral::ISessionProxy &session)
constructor
Definition DBLoader.cxx:30

◆ ~JobOptionTableLoader()

virtual TrigConf::JobOptionTableLoader::~JobOptionTableLoader ( )
overridevirtualdefault

destructor

Member Function Documentation

◆ assembleSplitParameters()

unsigned int TrigConf::JobOptionTableLoader::assembleSplitParameters ( JobOptionTable & jot,
const std::vector< SplitParam > & splitparams )
private

Definition at line 410 of file JobOptionTableLoader.cxx.

410 {
411
412 unsigned int paramCount = 0;
413
414 // Loop over the vectors and match the alias and parameter names (excluding the __IPC__)
415 std::string mergedvalue ="";
416 std::string aliasname ="";
417 std::string paraname ="";
418
419
420 //ignore those we have already matched
421 vector< SplitParam > alreadymatched_v;
422
423 for (unsigned int sit=0; sit<splitparams.size(); sit++) {
424
425 const SplitParam & splitpar = splitparams.at(sit);
426
427 std::string actualname = splitpar.actualname;
428 // std::cout << splitpar.alias << " " << splitpar.name << std::endl;
429
430 // see if already matched - paraname and the alias!
431 bool matched = false;
432 for (unsigned int mit=0; mit<alreadymatched_v.size(); mit++){
433 SplitParam matchtemp = alreadymatched_v.at(mit);
434 matched = ( matchtemp.actualname==actualname && matchtemp.alias == splitpar.alias );
435 if(matched) break;
436 }
437
438
439 if(!matched) {
440 //have we gone on to the next name - if so, we have a merged parameter now
441 if( paraname!=actualname || aliasname!=splitpar.alias ){
442
443 if(aliasname!=""){
444 //MAKE THE NEW JOBOPTION!
445 JobOption jo( aliasname, paraname, "type", "set", mergedvalue);
446 jot.addJobOption(jo);
447 paramCount++;
448 }
449 aliasname = splitpar.alias;
450 paraname = actualname;
451 mergedvalue="";
452 }
453
454 alreadymatched_v.push_back( splitpar );
455 mergedvalue = splitpar.value;
456
457 //now look for a match here
458 for (unsigned int sit2=sit+1; sit2<splitparams.size(); sit2++){
459 const SplitParam& newtemp2 = splitparams.at(sit2);
460 std::string actualname2 = newtemp2.actualname;
461
462 if(actualname2==actualname && splitpar.alias==newtemp2.alias ){
463 mergedvalue+= newtemp2.value;
464 TRG_MSG_VERBOSE("Found split parameters " << splitpar.alias << " : " << splitpar.name << " - " << newtemp2.name);
465 TRG_MSG_VERBOSE(splitpar.value << " - " << newtemp2.value);
466 }
467 }
468 }
469 }
470
471 if(aliasname!=""){
472 //have to take care of the last one!
473 //MAKE THE NEW JOBOPTION!
474 JobOption jo( aliasname, paraname, "type", "set", mergedvalue);
475 jot.addJobOption(jo);
476 paramCount++;
477 }
478 return paramCount;
479
480}
void addJobOption(const JobOption &jo)
adds a job option to the table

◆ assembleSplitParameters2()

unsigned int TrigConf::JobOptionTableLoader::assembleSplitParameters2 ( JobOptionTable & jot,
const std::vector< SplitParam > & splitparams )
private

Definition at line 505 of file JobOptionTableLoader.cxx.

505 {
506
507 std::map<AssembledPar, std::vector<std::string>, APlessthan > assembled_params;
508
509 boost::regex pname_exp("(.*)__IPC__(\\d+)");
510 boost::cmatch matches;
511
512 // for(unsigned int i=0; i<splitparams.size(); ++i) {
513 for(const SplitParam & splitpar: splitparams ) {
514 //const SplitParam & splitpar = splitparams[i];
515
516 if(boost::regex_match(splitpar.name.c_str(), matches, pname_exp)) {
517
518 const std::string& comp_alias = splitpar.alias;
519 std::string par_name(matches[1].first, matches[1].second);
520 unsigned int pos = static_cast<unsigned int>(std::stoul(std::string(matches[2].first, matches[2].second))) - 1; // start with __IPC__01
521
522 std::vector<std::string>& values = assembled_params[ AssembledPar(comp_alias, par_name) ];
523
524 if(values.size()<=pos) values.resize(pos+1);
525 values[pos]= splitpar.value;
526
527 } else {
528 std::cout << "ERROR, can't parse " << splitpar.name << std::endl;
529 }
530
531 }
532
533 for(auto par: assembled_params) {
534
535 const string& comp_alias = par.first.comp_alias;
536 const string& par_name = par.first.par_name;
537 vector<string>& values = par.second;
538 stringstream ss;
539 copy(values.begin(), values.end(), std::ostream_iterator<std::string>(ss));
540 jot.addJobOption( JobOption( comp_alias, par_name, "type", "set", ss.str()) );
541 }
542
543 return assembled_params.size();
544}
static Double_t ss
bool copy
Definition calibdata.py:26

◆ buildCond_IN_()

std::string TrigConf::JobOptionTableLoader::buildCond_IN_ ( const std::string & field,
const std::set< int > & IDs,
std::set< int >::const_iterator & current,
unsigned int batchSize )
private

Definition at line 267 of file JobOptionTableLoader.cxx.

267 {
268
269 std::stringstream ss;
270 ss << "(" << field << " IN (";
271
272 unsigned int count(0), totalCount(0);
273 set<int>::iterator last = IDs.end(); --last;
274 for(; current!=last && totalCount!=batchSize-1; ++current) {
275 totalCount++;
276 ss << *current;
277 if(++count==1000) {
278 ss << ") OR " << field << " IN (";
279 count=0;
280 } else {
281 ss << ",";
282 }
283 }
284 ss << *current++ << "))";
285
286 return ss.str();
287}
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146

◆ 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

◆ defineQueries()

void TrigConf::JobOptionTableLoader::defineQueries ( )

◆ getChildCompIDs()

std::set< int > TrigConf::JobOptionTableLoader::getChildCompIDs ( const std::set< int > & compIDs)
private

Definition at line 334 of file JobOptionTableLoader.cxx.

334 {
335
336 std::set<int> childCompIDs; // the children IDs
337
338 TRG_MSG_DEBUG("Number of parents " << compIDs.size());
339
340 vector<int> sortedParentIDs = createSortedVector(compIDs);
341
342 vector<string> splitParentIDs = concatAndSplit(sortedParentIDs, 7500);
343
344 for(const string& idList : splitParentIDs) {
345
346 // condition
347 string cond = "HCP2CP_PARENT_COMP_ID IN (" + idList + ")";
348
349 coral::ITable& table = m_session.nominalSchema().tableHandle("HLT_CP_TO_CP");
350 std::unique_ptr< coral::IQuery > q( table.newQuery() );
351
352 coral::AttributeList bind;
353 q->setCondition( cond, bind );
354
355 // output
356 coral::AttributeList attList;
357 attList.extend<int>( "HCP2CP_CHILD_COMP_ID" );
358 fillQuery(q.get(),attList);
359
360 // distinct
361 q->setDistinct();
362
363 // execute
364 coral::ICursor& cursor = q->execute();
365
366 // fill output
367 while( cursor.next() ) {
368 const coral::AttributeList& row = cursor.currentRow();
369 int id = row["HCP2CP_CHILD_COMP_ID"].data<int>();
370 childCompIDs.insert(id);
371 }
372
373 }
374
375 // no more children, can stop recursion
376 if(childCompIDs.size()==0)
377 return childCompIDs;
378
379 // get all children recursively
380 set<int> allSubChildrenIDs = getChildCompIDs(childCompIDs);
381
382 // add to set of all children
383 childCompIDs.insert(allSubChildrenIDs.begin(),allSubChildrenIDs.end());
384
385 return childCompIDs;
386}
std::set< int > getChildCompIDs(const std::set< int > &compIDs)
row
Appending html table to final .html summary file.
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 }

◆ 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() [1/2]

bool TrigConf::JobOptionTableLoader::load ( JobOptionTable & jot)
overrideprivatevirtual

Implements TrigConf::IJobOptionTableLoader.

Definition at line 548 of file JobOptionTableLoader.cxx.

548 {
549
550 if(jot.smk()==0) {
551 TRG_MSG_ERROR("requested SMK is 0");
552 return false;
553 }
554
556
557 TRG_MSG_INFO("Start loading job options with smk " << jot.smk());
558
559 startSession();
560
561 int masterTableID(0);
562 int triggerMenuID(0);
563 int l2SetupID(0);
564 int efSetupID(0);
565 if( ! loadHLTMasterTable( jot.smk(),
566 masterTableID,
567 triggerMenuID,
568 l2SetupID,
569 efSetupID ) )
570 {
571 TRG_MSG_ERROR("Could not load menu and setup IDs for SMK " << jot.smk());
572 return false;
573 }
574
575 jot.setHltMasterTableId( masterTableID );
576 TRG_MSG_INFO("HLT masterkey: " << jot.hltMasterTableId());
577 TRG_MSG_INFO("Menu ID : " << triggerMenuID);
578 if(l2SetupID==efSetupID) {
579 TRG_MSG_INFO("Setup ID : " << l2SetupID);
580 } else {
581 TRG_MSG_INFO("L2 Setup ID : " << l2SetupID);
582 TRG_MSG_INFO("EF Setup ID : " << efSetupID);
583 }
584
585 int level = jot.triggerLevel()==0; // triggerLevel: 0 - L2, 1 - EF, 2 - HLT(combined L2+EF)
586 if( l2SetupID == efSetupID ||
587 (l2SetupID != 0 && efSetupID==0) )
588 level=2; // combined
589
590 int setupId = (level==0 || level==2) ? l2SetupID : efSetupID;
591
592 std::set<int> compIDsToLoad = loadComponentIDsFromSetup(setupId);
593
594
595 TRG_MSG_INFO("Direct components => " << compIDsToLoad.size());
596
597 std::set<int> childCompIDs = getChildCompIDs( compIDsToLoad );
598
599 TRG_MSG_INFO("All children => " << childCompIDs.size());
600
601 compIDsToLoad.insert(childCompIDs.begin(), childCompIDs.end());
602
603 TRG_MSG_INFO("All components => " << compIDsToLoad.size());
604
605 loadComponentNamesAndParameters(jot, compIDsToLoad);
606
607 jot.sort();
608
610
611 // some stats:
612 TRG_MSG_INFO("JobOptionTableLoader: Total parameters : " << jot.jobOptionVector().size());
613
614 return true;
615}
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
bool loadComponentNamesAndParameters(TrigConf::JobOptionTable &JOTable, const std::set< int > &compIDsToLoad)
std::set< int > loadComponentIDsFromSetup(const int setup_id)
bool loadHLTMasterTable(int SuperMasterKey, int &masterTableID, int &triggerMenuID, int &l2SetupID, int &efSetupID)
void setHltMasterTableId(int id)
setter of the HLT master table configuration key
int triggerLevel() const
accessor to the trigger level
std::vector< JobOption > & jobOptionVector()
accessor to the vector of job options
void sort()
sort alphabetically by component and property name
int hltMasterTableId() const
accessor to the HLT master table configuration key
unsigned int smk() const

◆ load() [2/2]

bool TrigConf::JobOptionTableLoader::load ( TrigConfData & data)
virtual

Definition at line 390 of file JobOptionTableLoader.cxx.

390 {
391
392 JobOptionTable& jot = dynamic_cast<JobOptionTable&>(data);
393 try {
394 return load(jot);
395 }
396 catch( const std::exception& e ) {
397 TRG_MSG_FATAL("std::exception: " << e.what());
398 throw;
399 }
400 return false;
401}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual bool load(TrigConfData &data)

◆ loadComponentIDsFromMenu()

std::set< int > TrigConf::JobOptionTableLoader::loadComponentIDsFromMenu ( const int menu_id,
int triggerLevel )
private

Definition at line 205 of file JobOptionTableLoader.cxx.

205 {
206
207 std::set<int> compIDs;
208
209 std::unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
210 q->setRowCacheSize( 1000 );
211
212 q->addToTableList( "HLT_TM_TO_TC", "TM2TC" );
213 q->addToTableList( "HLT_TRIGGER_CHAIN", "TC" );
214 q->addToTableList( "HLT_TC_TO_TS", "TC2TS" );
215 q->addToTableList( "HLT_TS_TO_TE", "TS2TE" );
216 q->addToTableList( "HLT_TE_TO_CP", "TE2CP" );
217
218 // bind menu ID
219 coral::AttributeList bind;
220 bind.extend<int>("menuid");
221 bind[0].data<int>() = menu_id;
222
223
224 // condition
225 std::string cond("TM2TC.HTM2TC_TRIGGER_MENU_ID = :menuid");
226 cond += " AND TM2TC.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID";
227 cond += " AND TM2TC.HTM2TC_TRIGGER_CHAIN_ID = TC2TS.HTC2TS_TRIGGER_CHAIN_ID";
228 cond += " AND TC2TS.HTC2TS_TRIGGER_SIGNATURE_ID = TS2TE.HTS2TE_TRIGGER_SIGNATURE_ID";
229 cond += " AND TS2TE.HTS2TE_TRIGGER_ELEMENT_ID = TE2CP.HTE2CP_TRIGGER_ELEMENT_ID";
230
231 // triggerLevel
232 if(triggerLevel!=2) { // 2 means combined
233 cond += " AND TC.HTC_L2_OR_EF = ";
234 cond += ( triggerLevel==0 ? "'L2'" : "'EF'" );
235 }
236
237 q->setCondition( cond , bind );
238
239 // output
240 coral::AttributeList attList;
241 attList.extend<int>( "TE2CP.HTE2CP_COMPONENT_ID" );
242 fillQuery(q.get(),attList);
243
244 // execute
245 coral::ICursor& cursor = q->execute();
246 while( cursor.next() ) {
247 const coral::AttributeList& row = cursor.currentRow();
248 int id = row["TE2CP.HTE2CP_COMPONENT_ID"].data<int>();
249 compIDs.insert(id);
250 }
251
252 TRG_MSG_INFO("Loaded M-Components => " << compIDs.size());
253
254 return compIDs;
255}

◆ loadComponentIDsFromSetup()

std::set< int > TrigConf::JobOptionTableLoader::loadComponentIDsFromSetup ( const int setup_id)
private

Definition at line 167 of file JobOptionTableLoader.cxx.

167 {
168
169 std::set<int> compIDs;
170
171 std::unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
172 q->setRowCacheSize( 1000 );
173
174 // tables
175 q->addToTableList ( "HLT_ST_TO_CP", "ST2CP" );
176
177 // bind setup id
178 coral::AttributeList bind;
179 bind.extend<int>("setupid");
180 bind[0].data<int>() = setup_id;
181
182 std::string cond("ST2CP.HST2CP_SETUP_ID = :setupid");
183 q->setCondition( cond , bind );
184
185 // output and their types
186 coral::AttributeList attList;
187 attList.extend<int>( "ST2CP.HST2CP_COMPONENT_ID" );
188 fillQuery(q.get(),attList);
189
190 // execute
191 coral::ICursor& cursor = q->execute();
192 while( cursor.next() ) {
193 const coral::AttributeList& row = cursor.currentRow();
194 int id = row["ST2CP.HST2CP_COMPONENT_ID"].data<int>();
195 compIDs.insert(id);
196 }
197
198 TRG_MSG_INFO("Loaded I-Components => " << compIDs.size());
199 return compIDs;
200}

◆ loadComponentNamesAndParameters() [1/2]

bool TrigConf::JobOptionTableLoader::loadComponentNamesAndParameters ( TrigConf::JobOptionTable & JOTable,
const std::set< int > & compIDsToLoad )
private

Definition at line 90 of file JobOptionTableLoader.cxx.

90 {
91
92 unsigned int batchSize = 500;
93 set<int>::const_iterator current = compIDsToLoad.begin();
94 vector< SplitParam > splitparams;
95
96
97 while(current!=compIDsToLoad.end()) {
98 loadComponentNamesAndParameters(JOTable, compIDsToLoad, splitparams, current, batchSize);
99 }
100
101
102 TRG_MSG_INFO("Split parameters => " << splitparams.size());
103 TRG_MSG_INFO("Non-split parameters => " << JOTable.jobOptionVector().size());
104 unsigned int countSplitParam = assembleSplitParameters2(JOTable, splitparams);
105 TRG_MSG_INFO("Assembled split parameters => " << countSplitParam);
106
107 return true;
108}
unsigned int assembleSplitParameters2(JobOptionTable &jot, const std::vector< SplitParam > &splitparams)

◆ loadComponentNamesAndParameters() [2/2]

bool TrigConf::JobOptionTableLoader::loadComponentNamesAndParameters ( TrigConf::JobOptionTable & JOTable,
const std::set< int > & compIDsToLoad,
std::vector< SplitParam > & splitparams,
std::set< int >::const_iterator & current,
unsigned int batchSize )
private

◆ loadHLTMasterTable()

bool TrigConf::JobOptionTableLoader::loadHLTMasterTable ( int SuperMasterKey,
int & masterTableID,
int & triggerMenuID,
int & l2SetupID,
int & efSetupID )
private

Definition at line 34 of file JobOptionTableLoader.cxx.

38 {
39
40 unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
41
42 // tables
43 q->addToTableList ( "SUPER_MASTER_TABLE", "SM" );
44 q->addToTableList ( "HLT_MASTER_TABLE", "HM" );
45
46 // Bind variables
47 coral::AttributeList bindList;
48 bindList.extend<int>("smid");
49 bindList[0].data<int>() = SuperMasterKey;
50
51 // the select condition
52 string theCondition = "SM.SMT_HLT_MASTER_TABLE_ID = HM.HMT_ID AND SM.SMT_ID = :smid";
53
54 q->setCondition( theCondition, bindList );
55
56 // output fields
57 coral::AttributeList attList;
58 attList.extend<int> ( "HM.HMT_ID" );
59 attList.extend<int> ( "HM.HMT_TRIGGER_MENU_ID" );
60 if(isRun1()) {
61 attList.extend<int> ( "HM.HMT_L2_SETUP_ID" );
62 attList.extend<int> ( "HM.HMT_EF_SETUP_ID" );
63 } else {
64 attList.extend<int> ( "HM.HMT_SETUP_ID" );
65 }
66 fillQuery(q.get(),attList);
67
68 // query
69 coral::ICursor& cursor = q->execute();
70
71 // get the HLT master-table id
72 if( ! cursor.next() )
73 return false;
74
75 const coral::AttributeList& row = cursor.currentRow();
76
77 masterTableID = row["HM.HMT_ID"].data<int>();
78 triggerMenuID = row["HM.HMT_TRIGGER_MENU_ID"].data<int>();
79 if(isRun1()) {
80 l2SetupID = row["HM.HMT_L2_SETUP_ID"].data<int>();
81 efSetupID = row["HM.HMT_EF_SETUP_ID"].data<int>();
82 } else {
83 l2SetupID = efSetupID = row["HM.HMT_SETUP_ID"].data<int>();
84 }
85 return true;
86}

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

The standard message stream.

Returns a reference to the message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 52 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
inline

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 58 of file TrigConfMessaging.h.

97 {
98 return msg() << lvl;
99 }
MsgStreamTC & msg() const
The standard message stream.

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