ATLAS Offline Software
L1TopoMenuLoader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "L1TopoMenuLoader.h"
6 
7 #include <CoralBase/Attribute.h>
8 #include <CoralBase/AttributeList.h>
9 
10 #include "RelationalAccess/SchemaException.h"
11 #include "RelationalAccess/ITransaction.h"
12 #include "RelationalAccess/ITable.h"
13 #include "RelationalAccess/ISchema.h"
14 #include "RelationalAccess/ICursor.h"
15 #include "RelationalAccess/IQuery.h"
16 
17 #include "DBHelper.h"
20 
21 #include <iostream>
22 #include <stdexcept>
23 #include <typeinfo>
24 
25 using namespace std;
27  try {
28  unsigned int schema = triggerDBSchemaVersion();
29  TRG_MSG_DEBUG("L1TopoMenuLoader Run " << (isRun1()? 1 : 2) << ", schema version " << schema);
30  if(isRun1()) {
31  TRG_MSG_INFO("Not loading L1 TopoMenu from a run 1 database");
32  return true;
33  }
34  TRG_MSG_INFO("Loading L1 TopoMenu with SMK " << tcaTarget.getSMK());
35  startSession();
36  loadTopoAlgos(tcaTarget);
37  commitSession();
39  tcaTarget.print();
40  } catch( const std::exception& e ) {
41  TRG_MSG_ERROR("L1TopoMenuLoader::load >> Standard C++ exception: " << e.what());
42  } catch( ... ) {
43  TRG_MSG_ERROR("L1TopoMenuLoader::load >> ... caught ");
44  }
45  TRG_MSG_INFO( "Loaded L1 TopoMenu with " << tcaTarget.getL1TopoConfigAlgs().size() << " algorithms and "
46  << tcaTarget.getL1TopoConfigOutputList().getTriggerLines().size() << " trigger lines");
47  return true;
48 }
49 
50 
52 
53  TRG_MSG_VERBOSE("Calling loadTopoAlgos for SMK " << tcaTarget.getSMK());
54 
55  try {
56  startSession();
57 
58  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
59  query0->addToTableList("SUPER_MASTER_TABLE","SM");
60  query0->addToTableList("TOPO_MASTER_TABLE","TMT");
61  query0->addToTableList("TOPO_TRIGGER_MENU","TTM");
62  query0->addToTableList("TTM_TO_TA","TTM2TA");
63  query0->addToTableList("TOPO_ALGO","TA");
64  query0->setRowCacheSize(1000);
65 
66  //Bind list
67  coral::AttributeList bindList0;
68  bindList0.extend<unsigned int>("tmtId");
69  std::string cond = "TMT_ID = :tmtId";
70  bindList0[0].data<unsigned int>() = tcaTarget.getSMK();
71 
72  string theCondition0 = "";
73  theCondition0 += string(" SM.SMT_ID = :tmtId");
74  theCondition0 += string(" AND TMT.TMT_ID = SM.SMT_TOPO_MASTER_TABLE_ID ");
75  theCondition0 += string(" AND TTM.TTM_ID = TMT.TMT_TRIGGER_MENU_ID ");
76  theCondition0 += string(" AND TTM2TA.TTM2TA_MENU_ID = TTM.TTM_ID ");
77  theCondition0 += string(" AND TA.TA_ID = TTM2TA.TTM2TA_ALGO_ID ");
78  query0->setCondition( theCondition0, bindList0 );
79 
80  coral::AttributeList attList0;
81 
82  //TMT.TMT_TRIGGER_MENU_ID, TMT.TMT_VERSION,TTM.TTM_NAME,TTM.TTM_VERSION,TTM.TTM_CTPLINK_ID,TA.TA_ID,TA.TA_NAME,TA.TA_OUTPUT,TA.TA_TYPE,TA.TA_BITS,TA.TA_SORT_DECI,TA.TA_ALGO_ID
83  //attList0.extend<int>( "TMT.TMT_TRIGGER_MENU_ID" );
84  //attList0.extend<long>( "TMT.TMT_VERSION" );
85  attList0.extend<string>( "TTM.TTM_NAME" );
86  //attList0.extend<int>( "TTM.TTM_VERSION" );
87  attList0.extend<int>( "TTM.TTM_CTPLINK_ID" );
88  attList0.extend<int>( "TA.TA_ID" );
89  attList0.extend<string>( "TA.TA_NAME" );
90  attList0.extend<string>( "TA.TA_OUTPUT" );
91  attList0.extend<string>( "TA.TA_TYPE" );
92  attList0.extend<int>( "TA.TA_BITS" );
93  attList0.extend<string>( "TA.TA_SORT_DECI" );
94  attList0.extend<int>( "TA.TA_ALGO_ID" );
95  query0->defineOutput(attList0);
96  fillQuery(query0.get(), attList0);
97  TRG_MSG_VERBOSE("Executing loadTopoAlgos query ");
98  coral::ICursor& cursor0 = query0->execute();
99 
100  int ctplinkid = 0;
101 
102  std::map<uint, TXC::L1TopoConfigAlg> idToAlgMap; // map of id -> alg for later bulk loading of inputs, outputs, etc.
103 
104  while(cursor0.next()){
105  const coral::AttributeList& row0 = cursor0.currentRow();
106  int ta_id = row0["TA.TA_ID"].data<int>();
107  string ta_name = row0["TA.TA_NAME"].data<string>();
108  string ta_output = row0["TA.TA_OUTPUT"].data<string>();
109  string ta_type = row0["TA.TA_TYPE"].data<string>();
110  //int ta_bits = row0["TA.TA_BITS"].data<int>();
111  string ta_sort_deci = row0["TA.TA_SORT_DECI"].data<string>();
112  int ta_algo_id = row0["TA.TA_ALGO_ID"].data<int>();
113  ctplinkid = row0["TTM.TTM_CTPLINK_ID"].data<int>();
114  tcaTarget.setName(row0["TTM.TTM_NAME"].data<string>());
115  tcaTarget.setVersion(std::to_string(ta_id));
116 
117 
118  TXC::L1TopoConfigAlg alg(ta_name,ta_type);
119  if(ta_sort_deci=="Decision") alg.setAlgKind(TXC::L1TopoConfigAlg::DECISION);
120  else if(ta_sort_deci=="Sort") alg.setAlgKind(TXC::L1TopoConfigAlg::SORT);
121  else alg.setAlgKind(TXC::L1TopoConfigAlg::NONE);
122  alg.setAlgOutput(ta_output);
123  alg.setAlgoID(ta_algo_id);
124  // loadAlgInput(alg,ta_id);
125  // loadAlgOutput(alg,ta_id,ta_bits);
126  // loadAlgRegister(alg, ta_id);
127  // loadAlgFixed(alg, ta_id);
128  idToAlgMap.emplace(ta_id,std::move(alg));
129  // tcaTarget.addAlgorithm(alg);
130  }
131 
132  loadAllAlgsInput(idToAlgMap);
133  loadAllAlgsOutput(idToAlgMap);
134  loadAllAlgsRegister(idToAlgMap);
135  loadAllAlgsFixed(idToAlgMap);
136 
137  for( auto & e : idToAlgMap ) {
138  tcaTarget.addAlgorithm(std::move(e.second));
139  }
140  idToAlgMap.clear();//invalid aftermove
141  loadTopoConfig(tcaTarget);
142  loadOutputList(tcaTarget,ctplinkid);
143  } catch( const std::exception& e ) {
144  TRG_MSG_ERROR("loadTopoAlgos >> Standard C++ exception: " << e.what());
145  commitSession();
146  throw;
147  }
148  return true;
149 }
150 
151 
152 bool TrigConf::L1TopoMenuLoader::loadAllAlgsInput( std::map<uint, TXC::L1TopoConfigAlg>& idToAlgMap ) {
153 
154  TRG_MSG_VERBOSE("Calling loadAllAlgsInput");
155 
156  set<uint> algIds;
157  for( auto & e : idToAlgMap ) {
158  algIds.insert(e.first);
159  }
160 
161  string algIdsConc = "(";
162  bool first = true;
163  for( int id : algIds ) {
164  if(first) { first = false; } else { algIdsConc += ","; }
165  algIdsConc += to_string(id);
166  }
167  algIdsConc+=")";
168 
169  TRG_MSG_DEBUG("" << algIds.size() << " algorithms ");
170  TRG_MSG_VERBOSE("Alg IDs : " << algIdsConc);
171 
172  try {
173  startSession();
174 
175  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
176  query0->addToTableList("TA_TO_TI","TA2TI");
177  query0->addToTableList("TOPO_ALGO_INPUT","TAI");
178  coral::AttributeList bindList0;
179 
180  string theCondition0 = "";
181  theCondition0 += " TA2TI.TA2TI_ALGO_ID IN " + algIdsConc;
182  theCondition0 += string(" AND TA2TI.TA2TI_INPUT_ID = TAI.TAI_ID");
183  query0->setCondition( theCondition0, bindList0 );
184 
185  coral::AttributeList attList0;
186  attList0.extend<int>( "TA2TI.TA2TI_ALGO_ID" );
187  attList0.extend<string>( "TAI.TAI_NAME" );
188  attList0.extend<string>( "TAI.TAI_VALUE" );
189  attList0.extend<int>( "TAI.TAI_POSITION" );
190  query0->defineOutput(attList0);
191  fillQuery(query0.get(), attList0);
192  //std::cout << "Executing loadAlgInput query " << std::endl;
193  coral::ICursor& cursor0 = query0->execute();
194 
195  uint inputCount = 0;
196  while(cursor0.next()){
197  inputCount ++;
198 
199  const coral::AttributeList& row0 = cursor0.currentRow();
200 
201  //std::cout << "loadAlgInput my row " << row0 << std::endl;
202  string tai_name = row0["TAI.TAI_NAME"].data<string>();
203  string tai_value = row0["TAI.TAI_VALUE"].data<string>();
204  int tai_pos = row0["TAI.TAI_POSITION"].data<int>();
205  if(tai_pos<0) tai_pos=0; // when position is missing in XML, currently the TT uploads -1 instead of 0
206 
207  // fill the alg
208  int algoId = row0["TA2TI.TA2TI_ALGO_ID"].data<int>();
209  auto match = idToAlgMap.find(algoId);
210  TXC::L1TopoConfigAlg & alg = match->second;
211  alg.addInput(tai_name,tai_value,tai_pos);
212  }
213 
214  TRG_MSG_DEBUG("" << inputCount << " inputs found");
215 
216  } catch (const exception& e){
217  TRG_MSG_ERROR("loadAlgInput >> Standard C++ exception: " << e.what());
218  throw;
219  }
220  return true;
221 }
222 
223 
224 bool
225 TrigConf::L1TopoMenuLoader::loadAllAlgsOutput( std::map<uint, TXC::L1TopoConfigAlg> & idToAlgMap ) {
226  TRG_MSG_VERBOSE("Calling loadAllAlgsOutput");
227 
228  set<uint> algIds;
229  for( auto & e : idToAlgMap ) {
230  algIds.insert(e.first);
231  }
232 
233  string algIdsConc = "(";
234  bool first = true;
235  for( int id : algIds ) {
236  if(first) { first = false; } else { algIdsConc += ","; }
237  algIdsConc += to_string(id);
238  }
239  algIdsConc+=")";
240 
241  try {
242  startSession();
243  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
244  query0->addToTableList("TOPO_ALGO","TA");
245  query0->addToTableList("TA_TO_TO","TA2TO");
246  query0->addToTableList("TOPO_ALGO_OUTPUT","TAO");
247  //Bind list
248  coral::AttributeList bindList0;
249 // bindList0.extend<int>("taId");
250 // bindList0[0].data<int>() = ta_id;
251 
252  string theCondition0 = "";
253  theCondition0 += " TA.TA_ID IN " + algIdsConc;
254  theCondition0 += " AND TA.TA_ID = TA2TO.TA2TO_ALGO_ID";
255  theCondition0 += " AND TA2TO.TA2TO_OUTPUT_ID = TAO.TAO_ID";
256  query0->setCondition( theCondition0, bindList0 );
257 
258  coral::AttributeList attList0;
259  attList0.extend<int>( "TA2TO.TA2TO_ALGO_ID" );
260  attList0.extend<string>( "TAO.TAO_NAME" );
261  attList0.extend<string>( "TAO.TAO_VALUE" );
262  attList0.extend<string>( "TAO.TAO_BITNAME" );
263  attList0.extend<int>( "TAO.TAO_SELECTION" );
264  attList0.extend<int>( "TA.TA_BITS" );
265  query0->defineOutput(attList0);
266  fillQuery(query0.get(), attList0);
267  //std::cout << "Executing loadAlgOutput query " << std::endl;
268  coral::ICursor& cursor0 = query0->execute();
269 
270 
271  uint outputCount = 0;
272  while(cursor0.next()){
273  outputCount ++;
274 
275  const coral::AttributeList& row0 = cursor0.currentRow();
276  //std::cout << "loadAlgOutput my row " << row0 << std::endl;
277  string tao_name = row0["TAO.TAO_NAME"].data<string>();
278  string tao_value = row0["TAO.TAO_VALUE"].data<string>();
279  string tao_bitname = row0["TAO.TAO_BITNAME"].data<string>();
280  int tao_sel = row0["TAO.TAO_SELECTION"].data<int>();
281  int ta_bits = row0["TA.TA_BITS"].data<int>();
282 
283  // fill the alg
284  int algoId = row0["TA2TO.TA2TO_ALGO_ID"].data<int>();
285  auto match = idToAlgMap.find(algoId);
286  TXC::L1TopoConfigAlg & alg = match->second;
287  alg.addOutput(tao_name,tao_value,ta_bits,tao_bitname, tao_sel);
288  }
289 
290  TRG_MSG_DEBUG("" << outputCount << " outputs found");
291 
292  } catch (const exception& e){
293  TRG_MSG_ERROR("loadAlgOutput >> Standard C++ exception: " << e.what());
294  throw;
295  }
296  return true;
297 }
298 
299 
300 
301 bool
302 TrigConf::L1TopoMenuLoader::loadAllAlgsRegister( std::map<uint, TXC::L1TopoConfigAlg> & idToAlgMap ) {
303 
304  TRG_MSG_VERBOSE("Calling loadAllAlgsRegister");
305 
306  set<uint> algIds;
307  for( auto & e : idToAlgMap ) {
308  algIds.insert(e.first);
309  }
310 
311  string algIdsConc = "(";
312  bool first = true;
313  for( int id : algIds ) {
314  if(first) { first = false; } else { algIdsConc += ","; }
315  algIdsConc += to_string(id);
316  }
317  algIdsConc+=")";
318 
319  try {
320  startSession();
321 
322  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
323  query0->addToTableList("TA_TO_TP","TA2TP");
324  query0->addToTableList("TOPO_PARAMETER","TP");
325  //Bind list
326  coral::AttributeList bindList0;
327 // bindList0.extend<int>("taId");
328 // bindList0[0].data<int>() = ta_id;
329 
330  string theCondition0 = "";
331  theCondition0 += " TA2TP.TA2TP_ALGO_ID IN " + algIdsConc;
332  theCondition0 += " AND TA2TP.TA2TP_PARAM_ID = TP.TP_ID";
333  query0->setCondition( theCondition0, bindList0 );
334 
335  coral::AttributeList attList0;
336  attList0.extend<int>( "TA2TP.TA2TP_ALGO_ID" );
337  attList0.extend<string>( "TP.TP_NAME" );
338  attList0.extend<long>( "TP.TP_VALUE" );
339  attList0.extend<int>( "TP.TP_POSITION" );
340  attList0.extend<int>( "TP.TP_SELECTION" );
341  query0->defineOutput(attList0);
342  fillQuery(query0.get(), attList0);
343  //std::cout << "Executing loadAlgRegister query " << std::endl;
344  coral::ICursor& cursor0 = query0->execute();
345 
346  uint registerCount(0);
347  while(cursor0.next()){
348  registerCount++;
349  const coral::AttributeList& row0 = cursor0.currentRow();
350  //std::cout << "loadAlgRegister my row " << row0 << std::endl;
351  string tp_name = row0["TP.TP_NAME"].data<string>();
352  long tp_value = row0["TP.TP_VALUE"].data<long>();
353  int tp_pos = row0["TP.TP_POSITION"].data<int>();
354  int tp_sel = row0["TP.TP_SELECTION"].data<int>();
355  if(tp_pos<0) tp_pos=0;
356  if(tp_sel<0) tp_sel=0;
357 
358 
359  // fill the alg
360  int algoId = row0["TA2TP.TA2TP_ALGO_ID"].data<int>();
361  auto match = idToAlgMap.find(algoId);
362  TXC::L1TopoConfigAlg & alg = match->second;
363  alg.addParameter(tp_name,to_string(tp_value),tp_pos, tp_sel);
364  }
365 
366  TRG_MSG_DEBUG("" << registerCount << " registers found");
367 
368  } catch (const exception& e){
369  TRG_MSG_ERROR("loadAlgRegister >> Standard C++ exception: " << e.what());
370  throw;
371  }
372  return true;
373 }
374 
375 
376 
377 
378 bool
379 TrigConf::L1TopoMenuLoader::loadAllAlgsFixed( std::map<uint, TXC::L1TopoConfigAlg> & idToAlgMap ) {
380  TRG_MSG_VERBOSE("Calling loadAllAlgsFixed");
381 
382  set<uint> algIds;
383  for( auto & e : idToAlgMap ) {
384  algIds.insert(e.first);
385  }
386 
387  string algIdsConc = "(";
388  bool first = true;
389  for( int id : algIds ) {
390  if(first) { first = false; } else { algIdsConc += ","; }
391  algIdsConc += to_string(id);
392  }
393  algIdsConc+=")";
394 
395  try {
396  startSession();
397 
398  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
399  query0->addToTableList("TA_TO_TG","TA2TG");
400  query0->addToTableList("TOPO_GENERIC","TG");
401  //Bind list
402  coral::AttributeList bindList0;
403 // bindList0.extend<int>("taId");
404 // bindList0[0].data<int>() = ta_id;
405 
406  string theCondition0 = "";
407  theCondition0 += string(" TA2TG.TA2TG_ALGO_ID IN " + algIdsConc);
408  theCondition0 += string(" AND TA2TG.TA2TG_GENERIC_ID = TG.TG_ID");
409  query0->setCondition( theCondition0, bindList0 );
410 
411  query0->addToOrderList("TG.TG_NAME");
412 
413  coral::AttributeList attList0;
414  attList0.extend<int>( "TA2TG.TA2TG_ALGO_ID" );
415  attList0.extend<string>( "TG.TG_NAME" );
416  attList0.extend<string>( "TG.TG_VALUE" );
417  query0->defineOutput(attList0);
418  fillQuery(query0.get(), attList0);
419  //std::cout << "Executing loadAlgFiexed query " << std::endl;
420  coral::ICursor& cursor0 = query0->execute();
421 
422  uint fixedCount(0);
423  while(cursor0.next()){
424  fixedCount++;
425  const coral::AttributeList& row0 = cursor0.currentRow();
426  //std::cout << "loadAlgFixed my row " << row0 << std::endl;
427  string tg_name = row0["TG.TG_NAME"].data<string>();
428  string tg_value = row0["TG.TG_VALUE"].data<string>();
429 
430  // fill the alg
431  int algoId = row0["TA2TG.TA2TG_ALGO_ID"].data<int>();
432  auto match = idToAlgMap.find(algoId);
433  TXC::L1TopoConfigAlg & alg = match->second;
434  alg.addFixedParameter(tg_name,tg_value);
435  }
436 
437  TRG_MSG_DEBUG("" << fixedCount << " Fixed found");
438 
439  } catch (const exception& e){
440  TRG_MSG_ERROR("loadAlgFixed >> Standard C++ exception: " << e.what());
441  return false;
442  }
443  return true;
444 
445 }
446 
447 
448 
449 
450 /*
451 bool TrigConf::L1TopoMenuLoader::loadAlgInput( TXC::L1TopoConfigAlg& tcaTarget, const int& ta_id ) {
452  try {
453  TRG_MSG_VERBOSE("Calling loadAlgInput");
454  startSession();
455 
456  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
457  query0->addToTableList("TA_TO_TI","TA2TI");
458  query0->addToTableList("TOPO_ALGO_INPUT","TAI");
459  //Bind list
460  coral::AttributeList bindList0;
461  bindList0.extend<int>("taId");
462  bindList0[0].data<int>() = ta_id;
463 
464  string theCondition0 = "";
465  theCondition0 += string(" TA2TI.TA2TI_ALGO_ID = :taId" );
466  theCondition0 += string(" AND TA2TI.TA2TI_INPUT_ID = TAI.TAI_ID");
467  query0->setCondition( theCondition0, bindList0 );
468 
469  coral::AttributeList attList0;
470  attList0.extend<string>( "TAI.TAI_NAME" );
471  attList0.extend<string>( "TAI.TAI_VALUE" );
472  attList0.extend<int>( "TAI.TAI_POSITION" );
473  query0->defineOutput(attList0);
474  fillQuery(query0.get(), attList0);
475  //std::cout << "Executing loadAlgInput query " << std::endl;
476  coral::ICursor& cursor0 = query0->execute();
477  while(cursor0.next()){
478  const coral::AttributeList& row0 = cursor0.currentRow();
479  //std::cout << "loadAlgInput my row " << row0 << std::endl;
480  string tai_name = row0["TAI.TAI_NAME"].data<string>();
481  string tai_value = row0["TAI.TAI_VALUE"].data<string>();
482  int tai_pos = row0["TAI.TAI_POSITION"].data<int>();
483  if(tai_pos<0) tai_pos=0; // when position is missing in XML, currently the TT uploads -1 instead of 0
484  tcaTarget.addInput(tai_name,tai_value,tai_pos);
485  }
486  } catch (const exception& e){
487  TRG_MSG_ERROR("loadAlgInput >> Standard C++ exception: " << e.what());
488  throw;
489  }
490  return true;
491 }
492 
493 bool TrigConf::L1TopoMenuLoader::loadAlgRegister( TXC::L1TopoConfigAlg& tcaTarget, const int& ta_id ) {
494  try {
495  TRG_MSG_VERBOSE("Calling loadAlgRegister");
496  startSession();
497 
498  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
499  query0->addToTableList("TA_TO_TP","TA2TP");
500  query0->addToTableList("TOPO_PARAMETER","TP");
501  //Bind list
502  coral::AttributeList bindList0;
503  bindList0.extend<int>("taId");
504  bindList0[0].data<int>() = ta_id;
505 
506  string theCondition0 = "";
507  theCondition0 += string(" TA2TP.TA2TP_ALGO_ID = :taId" );
508  theCondition0 += string(" AND TA2TP.TA2TP_PARAM_ID = TP.TP_ID");
509  query0->setCondition( theCondition0, bindList0 );
510 
511  coral::AttributeList attList0;
512  attList0.extend<string>( "TP.TP_NAME" );
513  attList0.extend<long>( "TP.TP_VALUE" );
514  attList0.extend<int>( "TP.TP_POSITION" );
515  attList0.extend<int>( "TP.TP_SELECTION" );
516  query0->defineOutput(attList0);
517  fillQuery(query0.get(), attList0);
518  //std::cout << "Executing loadAlgRegister query " << std::endl;
519  coral::ICursor& cursor0 = query0->execute();
520  while(cursor0.next()){
521  const coral::AttributeList& row0 = cursor0.currentRow();
522  //std::cout << "loadAlgRegister my row " << row0 << std::endl;
523  string tp_name = row0["TP.TP_NAME"].data<string>();
524  long tp_value = row0["TP.TP_VALUE"].data<long>();
525  int tp_pos = row0["TP.TP_POSITION"].data<int>();
526  int tp_sel = row0["TP.TP_SELECTION"].data<int>();
527  if(tp_pos<0) tp_pos=0;
528  if(tp_sel<0) tp_sel=0;
529  tcaTarget.addParameter(tp_name,to_string(tp_value),tp_pos, tp_sel);
530  }
531  } catch (const exception& e){
532  TRG_MSG_ERROR("loadAlgRegister >> Standard C++ exception: " << e.what());
533  throw;
534  }
535  return true;
536 }
537 
538 bool TrigConf::L1TopoMenuLoader::loadAlgOutput( TXC::L1TopoConfigAlg& tcaTarget, const int& ta_id, const int& ta_bits ) {
539  try {
540  TRG_MSG_VERBOSE("Calling loadAlgOutput");
541  startSession();
542  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
543  query0->addToTableList("TA_TO_TO","TA2TO");
544  query0->addToTableList("TOPO_ALGO_OUTPUT","TAO");
545  //Bind list
546  coral::AttributeList bindList0;
547  bindList0.extend<int>("taId");
548  bindList0[0].data<int>() = ta_id;
549 
550  string theCondition0 = "";
551  theCondition0 += string(" TA2TO.TA2TO_ALGO_ID = :taId" );
552  theCondition0 += string(" AND TA2TO.TA2TO_OUTPUT_ID = TAO.TAO_ID");
553  query0->setCondition( theCondition0, bindList0 );
554 
555  coral::AttributeList attList0;
556  attList0.extend<string>( "TAO.TAO_NAME" );
557  attList0.extend<string>( "TAO.TAO_VALUE" );
558  attList0.extend<string>( "TAO.TAO_BITNAME" );
559  attList0.extend<int>( "TAO.TAO_SELECTION" );
560  query0->defineOutput(attList0);
561  fillQuery(query0.get(), attList0);
562  //std::cout << "Executing loadAlgOutput query " << std::endl;
563  coral::ICursor& cursor0 = query0->execute();
564  while(cursor0.next()){
565  const coral::AttributeList& row0 = cursor0.currentRow();
566  //std::cout << "loadAlgOutput my row " << row0 << std::endl;
567  string tao_name = row0["TAO.TAO_NAME"].data<string>();
568  string tao_value = row0["TAO.TAO_VALUE"].data<string>();
569  string tao_bitname = row0["TAO.TAO_BITNAME"].data<string>();
570  int tao_sel = row0["TAO.TAO_SELECTION"].data<int>();
571  tcaTarget.addOutput(tao_name,tao_value,ta_bits,tao_bitname, tao_sel);
572  }
573  } catch (const exception& e){
574  TRG_MSG_ERROR("loadAlgOutput >> Standard C++ exception: " << e.what());
575  throw;
576  }
577  return true;
578 }
579 
580 bool TrigConf::L1TopoMenuLoader::loadAlgFixed( TXC::L1TopoConfigAlg& tcaTarget, const int& ta_id ) {
581  try {
582  TRG_MSG_VERBOSE("Calling loadAlgFixed");
583  startSession();
584 
585  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
586  query0->addToTableList("TA_TO_TG","TA2TG");
587  query0->addToTableList("TOPO_GENERIC","TG");
588  //Bind list
589  coral::AttributeList bindList0;
590  bindList0.extend<int>("taId");
591  bindList0[0].data<int>() = ta_id;
592 
593  string theCondition0 = "";
594  theCondition0 += string(" TA2TG.TA2TG_ALGO_ID = :taId" );
595  theCondition0 += string(" AND TA2TG.TA2TG_GENERIC_ID = TG.TG_ID");
596  query0->setCondition( theCondition0, bindList0 );
597 
598  coral::AttributeList attList0;
599  attList0.extend<string>( "TG.TG_NAME" );
600  attList0.extend<string>( "TG.TG_VALUE" );
601  query0->defineOutput(attList0);
602  fillQuery(query0.get(), attList0);
603  //std::cout << "Executing loadAlgFiexed query " << std::endl;
604  coral::ICursor& cursor0 = query0->execute();
605  while(cursor0.next()){
606  const coral::AttributeList& row0 = cursor0.currentRow();
607  //std::cout << "loadAlgFixed my row " << row0 << std::endl;
608  string tg_name = row0["TG.TG_NAME"].data<string>();
609  string tg_value = row0["TG.TG_VALUE"].data<string>();
610  tcaTarget.addFixedParameter(tg_name,tg_value);
611  }
612  } catch (const exception& e){
613  TRG_MSG_ERROR("loadAlgFixed >> Standard C++ exception: " << e.what());
614  return false;
615  }
616  return true;
617 }
618 */
619 
620 bool TrigConf::L1TopoMenuLoader::loadOutputList( TXC::L1TopoMenu& tcaTarget, const int& ctplinkid) {
621  try {
622  TRG_MSG_VERBOSE("Calling loadOutputList");
623  startSession();
624 
625  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
626  query0->addToTableList("TOPO_OUTPUT_LIST","TOL");
627  query0->addToTableList("TOPO_OUTPUT_LINK","TOLK");
628  query0->addToTableList("TOPO_OUTPUT_LINE","TOLINE");
629  //Bind list
630  coral::AttributeList bindList0;
631  bindList0.extend<int>("ctpLId");
632  bindList0[0].data<int>() = ctplinkid;
633 
634  string theCondition0 = "";
635  theCondition0 += string(" TOL.OL_ID = :ctpLId" );
636  theCondition0 += string(" AND TOLK.TL_LINK_ID = TOL.OL_ID");
637  theCondition0 += string(" AND TOLK.TL_OUTPUT_ID = TOLINE.TOL_ID");
638  query0->setCondition( theCondition0, bindList0 );
639 
640  coral::AttributeList attList0;
641  attList0.extend<int>( "TOLINE.TOL_ID" );
642  attList0.extend<string>( "TOLINE.TOL_ALGO_NAME" );
643  attList0.extend<string>( "TOLINE.TOL_TRIGGERLINE" );
644  attList0.extend<unsigned int>( "TOLINE.TOL_ALGO_ID" );
645  attList0.extend<unsigned int>( "TOLINE.TOL_MODULE" );
646  attList0.extend<unsigned int>( "TOLINE.TOL_FPGA" );
647  attList0.extend<unsigned int>( "TOLINE.TOL_FIRST_BIT" );
648  attList0.extend<unsigned int>( "TOLINE.TOL_CLOCK" );
649  query0->defineOutput(attList0);
650  fillQuery(query0.get(), attList0);
651  //std::cout << "Executing loadAlgFiexed query " << std::endl;
652  coral::ICursor& cursor0 = query0->execute();
653  while(cursor0.next()){
654  const coral::AttributeList& row0 = cursor0.currentRow();
655  //std::cout << "loadOutputList my row " << row0 << std::endl;
656  string tol_name = row0["TOLINE.TOL_ALGO_NAME"].data<string>();
657  unsigned int tol_algoId = row0["TOLINE.TOL_ALGO_ID"].data<unsigned int>();
658  unsigned int tol_module = row0["TOLINE.TOL_MODULE"].data<unsigned int>();
659  unsigned int tol_fpga = row0["TOLINE.TOL_FPGA"].data<unsigned int>();
660  unsigned int tol_clock = row0["TOLINE.TOL_CLOCK"].data<unsigned int>();
661  unsigned int tol_firstbit = row0["TOLINE.TOL_FIRST_BIT"].data<unsigned int>();
662  tcaTarget.addL1TopoXMLOutput(TXC::OutputListElement( tol_name, tol_algoId, tol_module, tol_fpga, tol_clock, tol_firstbit));
663  }
664  tcaTarget.setTriggerList();
665  } catch (const exception& e){
666  TRG_MSG_ERROR("loadOutputList >> Standard C++ exception: " << e.what());
667  throw;
668  }
669  return true;
670 }
671 
673 
674  try {
675  TRG_MSG_VERBOSE("Calling loadTopoConfig");
676  startSession();
677 
678  unique_ptr<coral::IQuery> query0(m_session.nominalSchema().newQuery());
679  query0->addToTableList("SUPER_MASTER_TABLE","SM");
680  query0->addToTableList("TOPO_MASTER_TABLE","TMT");
681  query0->addToTableList("TOPO_TRIGGER_MENU","TTM");
682  query0->addToTableList("TTM_TO_TC","TTM2TC");
683  query0->addToTableList("TOPO_CONFIG","TC");
684  query0->setRowCacheSize(5);
685 
686  //Bind list
687  coral::AttributeList bindList0;
688  bindList0.extend<unsigned int>("tmtId");
689  std::string cond = "TMT_ID = :tmtId";
690  bindList0[0].data<unsigned int>() = tcaTarget.getSMK();
691 
692  string theCondition0 = "";
693  theCondition0 += string(" SM.SMT_ID = :tmtId");
694  theCondition0 += string(" AND TMT.TMT_ID = SM.SMT_TOPO_MASTER_TABLE_ID ");
695  theCondition0 += string(" AND TTM.TTM_ID = TMT.TMT_TRIGGER_MENU_ID ");
696  theCondition0 += string(" AND TTM2TC.TTM2TC_ID = TTM.TTM_ID ");
697  theCondition0 += string(" AND TC.TC_ID = TTM2TC.TTM2TC_CONFIG_ID ");
698  query0->setCondition( theCondition0, bindList0 );
699 
700  coral::AttributeList attList0;
701  attList0.extend<string>( "TC.TC_NAME" );
702  attList0.extend<string>( "TC.TC_VALUE" );
703  query0->defineOutput(attList0);
704  fillQuery(query0.get(), attList0);
705  coral::ICursor& cursor0 = query0->execute();
706 
707  while(cursor0.next()){
708  const coral::AttributeList& row0 = cursor0.currentRow();
709 
710  string tc_name = row0["TC.TC_NAME"].data<string>();
711  string tc_value = row0["TC.TC_VALUE"].data<string>();
712 
713  tcaTarget.addL1TopoConfigGlobal(TXC::TopoConfigElement(tc_name,tc_value));
714  }
715 
716  } catch( const std::exception& e ) {
717  TRG_MSG_ERROR("loadTopoConfig >> Standard C++ exception: " << e.what());
718  commitSession();
719  throw;
720  }
721  return true;
722 }
723 
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
TXC::L1TopoConfigOutputList::getTriggerLines
const std::vector< TriggerLine > & getTriggerLines() const
Definition: L1TopoConfigOutputList.h:105
L1TopoConfigAlg.h
SGout2dot.alg
alg
Definition: SGout2dot.py:243
TrigConf::L1TopoMenuLoader::loadTopoConfig
bool loadTopoConfig(TXC::L1TopoMenu &tcaTarget)
Definition: L1TopoMenuLoader.cxx:672
L1TopoMenu.h
TRG_MSG_VERBOSE
#define TRG_MSG_VERBOSE(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:24
DBHelper.h
TrigConf::L1TopoMenuLoader::loadAllAlgsInput
bool loadAllAlgsInput(std::map< uint, TXC::L1TopoConfigAlg > &idToAlgMap)
Definition: L1TopoMenuLoader.cxx:152
TrigConf::fillQuery
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition: DBHelper.cxx:13
TrigConf::DBLoader::triggerDBSchemaVersion
unsigned int triggerDBSchemaVersion()
Definition: DBLoader.cxx:76
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
TXC::L1TopoConfigAlg::NONE
@ NONE
Definition: L1TopoConfigAlg.h:59
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
CheckTagAssociation.schema
schema
Definition: CheckTagAssociation.py:22
TrigConf::L1TopoMenuLoader::loadAllAlgsOutput
bool loadAllAlgsOutput(std::map< uint, TXC::L1TopoConfigAlg > &idToAlgMap)
Definition: L1TopoMenuLoader.cxx:225
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
TrigConf::L1TopoMenuLoader::loadOutputList
bool loadOutputList(TXC::L1TopoMenu &tcaTarget, const int &ctplinkid)
Definition: L1TopoMenuLoader.cxx:620
TXC::L1TopoMenu::print
void print() const
print menu
Definition: L1TopoMenu.cxx:64
TXC::L1TopoMenu::addL1TopoXMLOutput
void addL1TopoXMLOutput(const TXC::OutputListElement &output)
add output
Definition: L1TopoMenu.h:69
TXC::OutputListElement
Definition: L1TopoConfigOutputList.h:57
TrigConf::L1TopoMenuLoader::loadAllAlgsRegister
bool loadAllAlgsRegister(std::map< uint, TXC::L1TopoConfigAlg > &idToAlgMap)
Definition: L1TopoMenuLoader.cxx:302
TrigConf::MSGTC::INFO
@ INFO
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:25
calibdata.exception
exception
Definition: calibdata.py:496
TXC::L1TopoConfigAlg::DECISION
@ DECISION
Definition: L1TopoConfigAlg.h:59
TXC::L1TopoMenu::setVersion
void setVersion(const std::string &version)
Definition: L1TopoMenu.h:62
TXC::L1TopoMenu::getSMK
const unsigned int & getSMK() const
Definition: L1TopoMenu.h:48
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
L1TopoMenuLoader.h
TXC::L1TopoMenu::addAlgorithm
void addAlgorithm(TXC::L1TopoConfigAlg &&alg)
add algorithm
Definition: L1TopoMenu.cxx:27
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TrigConf::L1TopoMenuLoader::loadAllAlgsFixed
bool loadAllAlgsFixed(std::map< uint, TXC::L1TopoConfigAlg > &idToAlgMap)
Definition: L1TopoMenuLoader.cxx:379
TXC::L1TopoMenu::addL1TopoConfigGlobal
void addL1TopoConfigGlobal(const TXC::TopoConfigElement &topoconfig)
add config
Definition: L1TopoMenu.h:72
TXC::L1TopoConfigAlg
Definition: L1TopoConfigAlg.h:56
TrigConf::DBLoader::commitSession
void commitSession()
commit session if not already done
Definition: DBLoader.cxx:45
TXC::L1TopoMenu::getL1TopoConfigAlgs
const std::vector< TXC::L1TopoConfigAlg > & getL1TopoConfigAlgs() const
Definition: L1TopoMenu.h:53
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
TrigConf::L1TopoMenuLoader::load
virtual bool load(TXC::L1TopoMenu &) override
Definition: L1TopoMenuLoader.cxx:26
DeMoScan.first
bool first
Definition: DeMoScan.py:534
TrigConf::DBLoader::startSession
void startSession()
start session if not already active
Definition: DBLoader.cxx:35
TXC::L1TopoConfigAlg::SORT
@ SORT
Definition: L1TopoConfigAlg.h:59
TXC::L1TopoMenu::setTriggerList
TCS::StatusCode setTriggerList()
Definition: L1TopoMenu.cxx:40
TrigConf::L1TopoMenuLoader::loadTopoAlgos
bool loadTopoAlgos(TXC::L1TopoMenu &tcaTarget)
Definition: L1TopoMenuLoader.cxx:51
TXC::L1TopoMenu
Definition: L1TopoMenu.h:25
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TrigConf::DBLoader::isRun1
bool isRun1()
Definition: DBLoader.h:60
TXC::L1TopoMenu::getL1TopoConfigOutputList
const L1TopoConfigOutputList & getL1TopoConfigOutputList() const
Definition: L1TopoMenu.h:55
TXC::L1TopoMenu::setName
void setName(const std::string &name)
setter methods
Definition: L1TopoMenu.h:61
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TXC::TopoConfigElement
Definition: L1TopoConfigGlobal.h:13