ATLAS Offline Software
Classes | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
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 More...
 
virtual ~JobOptionTableLoader () override=default
 destructor More...
 
virtual bool load (TrigConfData &data)
 
void defineQueries ()
 
MsgStreamTCmsg () const
 The standard message stream. More...
 
MsgStreamTCmsg (const MSGTC::Level lvl) const
 The standard message stream. More...
 
virtual void setLevel (MSGTC::Level lvl) override
 access to output stream More...
 
virtual MSGTC::Level outputLevel () const override
 
void startSession ()
 start session if not already active More...
 
void commitSession ()
 commit session if not already done More...
 
bool loadL1MasterKey (int SuperMasterKey, int &Lvl1MasterKey)
 get l1 master from super master More...
 
bool loadL1MenuKey (int SuperMasterKey, int &Lvl1MenuKey)
 get l1 menu id from super master More...
 
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. More...
 
MsgStreamTCmsg () const
 The standard message stream. More...
 
MsgStreamTCmsg (const MSGTC::Level lvl) const
 The standard message stream. More...
 

Protected Attributes

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

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 More...
 

Private Attributes

int m_verbose {1}
 
boost::thread_specific_ptr< MsgStreamTCm_msg_tls
 MsgStreamTC instance (a std::cout like with print-out levels) More...
 
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  {}

◆ ~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 411 of file JobOptionTableLoader.cxx.

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

◆ assembleSplitParameters2()

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

Definition at line 506 of file JobOptionTableLoader.cxx.

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

◆ 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 268 of file JobOptionTableLoader.cxx.

268  {
269 
270  std::stringstream ss;
271  ss << "(" << field << " IN (";
272 
273  unsigned int count(0), totalCount(0);
274  set<int>::iterator last = IDs.end(); --last;
275  for(; current!=last && totalCount!=batchSize-1; ++current) {
276  totalCount++;
277  ss << *current;
278  if(++count==1000) {
279  ss << ") OR " << field << " IN (";
280  count=0;
281  } else {
282  ss << ",";
283  }
284  }
285  ss << *current++ << "))";
286 
287  return ss.str();
288 }

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

◆ defineQueries()

void TrigConf::JobOptionTableLoader::defineQueries ( )

◆ getChildCompIDs()

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

Definition at line 335 of file JobOptionTableLoader.cxx.

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

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

◆ load() [1/2]

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

Implements TrigConf::IJobOptionTableLoader.

Definition at line 549 of file JobOptionTableLoader.cxx.

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

◆ load() [2/2]

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

Definition at line 391 of file JobOptionTableLoader.cxx.

391  {
392 
393  JobOptionTable& jot = dynamic_cast<JobOptionTable&>(data);
394  try {
395  return load(jot);
396  }
397  catch( const std::exception& e ) {
398  TRG_MSG_FATAL("std::exception: " << e.what());
399  throw;
400  }
401  return false;
402 }

◆ loadComponentIDsFromMenu()

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

Definition at line 206 of file JobOptionTableLoader.cxx.

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

◆ loadComponentIDsFromSetup()

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

Definition at line 168 of file JobOptionTableLoader.cxx.

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

◆ loadComponentNamesAndParameters() [1/2]

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

Definition at line 91 of file JobOptionTableLoader.cxx.

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

◆ loadComponentNamesAndParameters() [2/2]

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

Definition at line 112 of file JobOptionTableLoader.cxx.

116  {
117 
118  unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
119  q->setRowCacheSize( 500 );
120 
121  q->addToTableList ( "HLT_COMPONENT", "CP" );
122  q->addToTableList ( "HLT_CP_TO_PA", "CP2PA" );
123  q->addToTableList ( "HLT_PARAMETER", "PA" );
124 
125 
126  // bind
128 
129  std::string cond( buildCond_IN_("CP.HCP_ID", compIDsToLoad, current, batchSize) );
130  cond += " AND CP2PA.HCP2PA_COMPONENT_ID = CP.HCP_ID";
131  cond += " AND CP2PA.HCP2PA_PARAMETER_ID = PA.HPA_ID";
132  q->setCondition( cond , bind );
133 
134  // output and their types
135  coral::AttributeList attList;
136  attList.extend<std::string>( "CP.HCP_ALIAS" );
137  attList.extend<std::string>( "CP.HCP_TYPE" );
138  attList.extend<std::string>( "PA.HPA_NAME" );
139  attList.extend<std::string>( "PA.HPA_VALUE" );
140  fillQuery(q.get(),attList);
141 
142  coral::ICursor& cursor = q->execute();
143 
144  while( cursor.next() ) {
145 
146  const coral::AttributeList& row = cursor.currentRow();
147 
148  string alias = row["CP.HCP_ALIAS"].data<std::string>();
149  string type = "type"; //row["CP.HCP_TYPE"].data<std::string>();
150  string name = row["PA.HPA_NAME"].data<std::string>();
151  string value = row["PA.HPA_VALUE"].data<std::string>();
152 
153  if( value == "~" ) value = "";
154 
155  //if the parameter contains __ipc__ then its split - need to merge (after finding what to merge it with!)
156  if(name.find("__IPC__",0) != string::npos){
157  splitparams.push_back( SplitParam(alias, name, type, "set", value) );
158  } else {
159  JOTable.addJobOption( JobOption( alias, name, type, "set", value) );
160  }
161  }
162 
163  return true;
164 }

◆ loadHLTMasterTable()

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

Definition at line 35 of file JobOptionTableLoader.cxx.

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

◆ 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 ) {
156  commitSession();
157  msg() << "DBLoader: C++ exception: " << e.what() << std::endl;
158  throw;
159  }
160  commitSession();
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" );
194  commitSession();
195  }
196 
197  const coral::AttributeList& row = cursor.currentRow();
198  Lvl1MenuKey = row["L1MT_TRIGGER_MENU_ID"].data<int>();
199 
200  commitSession();
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 }

◆ 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/4]

MsgStreamTC & TrigConf::TrigConfMessaging::msg
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.

82  {
83  MsgStreamTC* ms = m_msg_tls.get();
84  if (!ms) {
85  ms = new MsgStreamTC(m_name);
86  m_msg_tls.reset(ms);
87  }
88  return *ms;
89  }

◆ msg() [2/4]

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 81 of file TrigConfMessaging.h.

82  {
83  MsgStreamTC* ms = m_msg_tls.get();
84  if (!ms) {
85  ms = new MsgStreamTC(m_name);
86  m_msg_tls.reset(ms);
87  }
88  return *ms;
89  }

◆ msg() [3/4]

MsgStreamTC & TrigConf::TrigConfMessaging::msg
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.

92  {
93  return msg() << lvl;
94  }

◆ msg() [4/4]

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 91 of file TrigConfMessaging.h.

92  {
93  return msg() << lvl;
94  }

◆ 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 70 of file TrigConfMessaging.h.

71  {
72  if (msg().level() <= lvl) {
73  msg() << lvl;
74  return true;
75  }
76  else {
77  return false;
78  }
79  }

◆ 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

access to output stream

Implements TrigConf::ILoader.

Definition at line 60 of file DBLoader.cxx.

60  {
61  msg().setLevel(lvl);
62 
63  switch(lvl) {
64  case MSGTC::ALWAYS: m_verbose = 5; break;
65  case MSGTC::VERBOSE: m_verbose = 4; break;
66  case MSGTC::DEBUG: m_verbose = 3; break;
67  case MSGTC::INFO: m_verbose = 2; break;
68  case MSGTC::WARNING:
69  case MSGTC::ERROR:
70  case MSGTC::FATAL: m_verbose = 0; break;
71  default: m_verbose = 0;
72  }
73 }

◆ setVerbose()

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

Implements TrigConf::ILoader.

Definition at line 58 of file DBLoader.h.

58 { m_verbose=v; }

◆ 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 66 of file TrigConfMessaging.h.

◆ m_name

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

Definition at line 67 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.

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


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TRG_MSG_FATAL
#define TRG_MSG_FATAL(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:30
TrigConf::JobOptionTableLoader::loadComponentNamesAndParameters
bool loadComponentNamesAndParameters(TrigConf::JobOptionTable &JOTable, const std::set< int > &compIDsToLoad)
Definition: JobOptionTableLoader.cxx:91
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
query_example.row
row
Definition: query_example.py:24
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TrigConf::JobOptionTableLoader::getChildCompIDs
std::set< int > getChildCompIDs(const std::set< int > &compIDs)
Definition: JobOptionTableLoader.cxx:335
TrigConf::JobOptionTable::jobOptionVector
std::vector< JobOption > & jobOptionVector()
accessor to the vector of job options
Definition: JobOptionTable.h:43
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TrigConf::TrigConfMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)
Definition: TrigConfMessaging.h:66
RunEBWeightsComputation.smk
smk
Definition: RunEBWeightsComputation.py:87
TrigConf::MSGTC::DEBUG
@ DEBUG
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:24
TRG_MSG_VERBOSE
#define TRG_MSG_VERBOSE(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:24
TrigConf::JobOptionTable::hltMasterTableId
int hltMasterTableId() const
accessor to the HLT master table configuration key
Definition: JobOptionTable.h:29
TrigConf::fillQuery
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition: DBHelper.cxx:13
athena.value
value
Definition: athena.py:122
TrigConf::DBLoader::triggerDBSchemaVersion
unsigned int triggerDBSchemaVersion()
Definition: DBLoader.cxx:76
TrigConf::MSGTC::ERROR
@ ERROR
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:27
TrigConf::MSGTC::FATAL
@ FATAL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:28
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
TrigConf::DBLoader::isRun2
bool isRun2()
Definition: DBLoader.cxx:54
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::DBLoader::m_session
coral::ISessionProxy & m_session
CORAL interface to database session.
Definition: DBLoader.h:68
TrigConf::JobOptionTable
table to hold the complete list of JobOption entries for a single configuration, from which the JobOp...
Definition: JobOptionTable.h:20
TrigConf::DBLoader::m_verbose
int m_verbose
Definition: DBLoader.h:64
TrigConf::DBLoader::DBLoader
DBLoader(StorageMgr &sm, coral::ISessionProxy &session)
constructor
Definition: DBLoader.cxx:30
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
TrigConf::TrigConfMessaging::m_name
std::string m_name
Definition: TrigConfMessaging.h:67
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
TrigConf::MSGTC::VERBOSE
@ VERBOSE
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:23
TrigConf::JobOptionTable::setHltMasterTableId
void setHltMasterTableId(int id)
setter of the HLT master table configuration key
Definition: JobOptionTable.h:33
TrigConf::DBLoader::m_sessionOwner
bool m_sessionOwner
remember if the loader started the session in the first place
Definition: DBLoader.h:69
TrigConf::TrigConfMessaging::msg
MsgStreamTC & msg() const
The standard message stream.
Definition: TrigConfMessaging.h:81
TrigConf::JobOptionTableLoader::loadComponentIDsFromSetup
std::set< int > loadComponentIDsFromSetup(const int setup_id)
Definition: JobOptionTableLoader.cxx:168
COOLRates.alias
alias
Definition: COOLRates.py:1172
TrigConf::MSGTC::INFO
@ INFO
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:25
calibdata.exception
exception
Definition: calibdata.py:496
TrigConf::MsgStreamTC::level
MSGTC::Level level()
Return message level of stream.
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:53
run
Definition: run.py:1
TrigConf::name
Definition: HLTChainList.h:35
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TrigConf::TrigConfData::smk
unsigned int smk() const
Definition: TrigConfData.h:20
TrigConf::JobOptionTable::triggerLevel
int triggerLevel() const
accessor to the trigger level
Definition: JobOptionTable.h:31
TrigConf::JobOption
hold a single job option (parameter and value)
Definition: JobOption.h:32
TrigConf::JobOptionTableLoader::loadHLTMasterTable
bool loadHLTMasterTable(int SuperMasterKey, int &masterTableID, int &triggerMenuID, int &l2SetupID, int &efSetupID)
Definition: JobOptionTableLoader.cxx:35
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
python.ext.table_printer.table
list table
Definition: table_printer.py:81
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
TrigConf::JobOptionTable::sort
void sort()
sort alphabetically by component and property name
Definition: JobOptionTable.cxx:67
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TrigConf::DBLoader::commitSession
void commitSession()
commit session if not already done
Definition: DBLoader.cxx:45
python.PyAthena.v
v
Definition: PyAthena.py:157
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
query_example.cursor
cursor
Definition: query_example.py:21
TrigConf::JobOptionTable::addJobOption
void addJobOption(const JobOption &jo)
adds a job option to the table
Definition: JobOptionTable.cxx:19
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DeMoScan.first
bool first
Definition: DeMoScan.py:534
TrigConf::JobOptionTableLoader::load
virtual bool load(TrigConfData &data)
Definition: JobOptionTableLoader.cxx:391
TrigConf::JobOptionTableLoader::assembleSplitParameters2
unsigned int assembleSplitParameters2(JobOptionTable &jot, const std::vector< SplitParam > &splitparams)
Definition: JobOptionTableLoader.cxx:506
TrigConf::DBLoader::loadSchemaVersion
std::tuple< unsigned int, unsigned int > loadSchemaVersion() const
get DB schema version and run number
Definition: DBLoader.cxx:81
TrigConf::DBLoader::startSession
void startSession()
start session if not already active
Definition: DBLoader.cxx:35
extractSporadic.q
list q
Definition: extractSporadic.py:98
calibdata.copy
bool copy
Definition: calibdata.py:27
TrigConf::MsgStreamTC::setLevel
void setLevel(MSGTC::Level lvl)
Set message level of stream.
Definition: Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx:52
TrigConf::JobOptionTableLoader::buildCond_IN_
std::string buildCond_IN_(const std::string &field, const std::set< int > &IDs, std::set< int >::const_iterator &current, unsigned int batchSize)
Definition: JobOptionTableLoader.cxx:268
TrigConf::DBLoader::isRun1
bool isRun1()
Definition: DBLoader.h:60
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TrigConf::DBLoader::loadL1MasterKey
bool loadL1MasterKey(int SuperMasterKey, int &Lvl1MasterKey)
get l1 master from super master
Definition: DBLoader.cxx:128
TrigConf::MSGTC::WARNING
@ WARNING
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:26