ATLAS Offline Software
HLTSequenceLoader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "./HLTSequenceLoader.h"
6 
7 #include "RelationalAccess/IColumn.h"
8 #include "RelationalAccess/ITableDescription.h"
9 
13 
14 #include "./DBHelper.h"
15 
16 using namespace std;
17 
18 bool
20  m_smk=frame.smk();
21 
22  m_schemaversion = triggerDBSchemaVersion();
23 
24  TRG_MSG_INFO("Loading HLT sequences");
25 
26  HLTSequenceList& sequences = frame.theHLTSequenceList();
27 
28  try {
29  startSession ();
30  loadSequences( sequences );
31  commitSession();
32  }
33  catch (const std::exception& e) {
34  TRG_MSG_ERROR("exception caught and rethrown : " << e.what());
35  throw;
36  }
37  return true;
38 }
39 
40 
41 void
43 
44  TRG_MSG_INFO("Start loading sequences with SMK " << m_smk);
45 
46  coral::ITable & teTable = m_session.nominalSchema().tableHandle( "HLT_TRIGGER_ELEMENT");
47 
48  const coral::ITableDescription & desc = teTable.description();
49 
50  bool hasTopoStartsFrom = false;
51  try {
52  desc.columnDescription("HTE_TOPO_START_FROM");
53  hasTopoStartsFrom = true;
54  }
55  catch(coral::InvalidColumnNameException & ex) { }
56 
57  // for(int i=0; i<desc.numberOfColumns(); ++i) {
58  // const coral::IColumn & col = desc.columnDescription(i);
59  // cout << " " << col.name() << endl;
60  // }
61  TRG_MSG_INFO("Found HTE_TOPO_START_FROM : " << (hasTopoStartsFrom ? "true" : "false") );
62 
63  unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
64 
65  q->addToTableList ( "SUPER_MASTER_TABLE" , "SM");
66  q->addToTableList ( "HLT_MASTER_TABLE" , "HM");
67  q->addToTableList ( "HLT_TM_TO_TC" , "M2C");
68  q->addToTableList ( "HLT_TC_TO_TS" , "TC2TS");
69  q->addToTableList ( "HLT_TS_TO_TE" , "S2TE");
70  q->addToTableList ( "HLT_TRIGGER_ELEMENT" , "TE");
71  q->addToTableList ( "HLT_TE_TO_CP" , "TE2CP");
72  q->addToTableList ( "HLT_TE_TO_TE" , "TE2TE");
73  q->addToTableList ( "HLT_COMPONENT" , "CP");
74 
75  //Bind list
76  coral::AttributeList bindings;
77  bindings.extend<int>("smid");
78  bindings[0].data<int>() = (int)m_smk;
79 
80  string theCondition = "";
81  theCondition += " SM.SMT_ID = :smid";
82  theCondition += " AND HM.HMT_ID = SM.SMT_HLT_MASTER_TABLE_ID";
83  theCondition += " AND HM.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID";
84  theCondition += " AND M2C.HTM2TC_TRIGGER_CHAIN_ID = TC2TS.HTC2TS_TRIGGER_CHAIN_ID";
85  theCondition += " AND TC2TS.HTC2TS_TRIGGER_SIGNATURE_ID = S2TE.HTS2TE_TRIGGER_SIGNATURE_ID";
86  theCondition += " AND TE.HTE_ID = S2TE.HTS2TE_TRIGGER_ELEMENT_ID";
87  theCondition += " AND TE.HTE_ID = TE2CP.HTE2CP_TRIGGER_ELEMENT_ID";
88  theCondition += " AND TE.HTE_ID = TE2TE.HTE2TE_TE_ID";
89  theCondition += " AND CP.HCP_ID = TE2CP.HTE2CP_COMPONENT_ID";
90 
91  q->setCondition( theCondition, bindings );
92 
93  //Output data and types
94  coral::AttributeList attList;
95  attList.extend<int> ( "TE.HTE_ID" );
96  attList.extend<string>( "TE.HTE_NAME" );
97  if(hasTopoStartsFrom)
98  attList.extend<string>( "TE.HTE_TOPO_START_FROM" );
99  attList.extend<string>( "CP.HCP_NAME" );
100  attList.extend<string>( "CP.HCP_ALIAS" );
101  attList.extend<int> ( "TE2CP.HTE2CP_ALGORITHM_COUNTER" );
102  attList.extend<string>( "TE2TE.HTE2TE_TE_INP_ID" );
103  attList.extend<string>( "TE2TE.HTE2TE_TE_INP_TYPE" );
104  attList.extend<int> ( "TE2TE.HTE2TE_TE_COUNTER" );
105  fillQuery(q.get(),attList);
106 
107  // the ordering
108  q->addToOrderList( "TE.HTE_ID ASC, TE2CP.HTE2CP_ALGORITHM_COUNTER DESC, TE2TE.HTE2TE_TE_COUNTER DESC" );
109 
110  // process the query
111  q->setDistinct();
112  coral::ICursor& cursor = q->execute();
113 
114 // TRG_MSG_DEBUG("Query SELECT "
115 // << "TE.HTE_ID, TE.HTE_NAME, CP.HCP_NAME, CP.HCP_ALIAS, TE2CP.HTE2CP_ALGORITHM_COUNTER, TE2TE.HTE2TE_TE_INP_ID, TE2TE.HTE2TE_TE_INP_TYPE, TE2TE.HTE2TE_TE_COUNTER"
116 // << " FROM "
117 // << "SUPER_MASTER_TABLE SM, HLT_MASTER_TABLE HM, HLT_TM_TO_TC M2C, HLT_TC_TO_TS TC2TS,HLT_TS_TO_TE S2TE, HLT_TRIGGER_ELEMENT TE, HLT_TE_TO_CP TE2CP, HLT_TE_TO_TE TE2TE, HLT_COMPONENT CP"
118 // << " WHERE "
119 // << theCondition << ";");
120 
121  while ( cursor.next() ) {
122  const coral::AttributeList& row = cursor.currentRow();
123  string te_name = rmtilde(row["TE.HTE_NAME"].data<string>());
124  HLTSequence* seq = seqlist.getSequence(te_name);
125  if(seq==0) {
126  seq = new HLTSequence( vector<HLTTriggerElement*>(), new HLTTriggerElement(te_name), vector<string>() );
127  seqlist.addHLTSequence(seq);
128  if(hasTopoStartsFrom) {
129  string topo_start_from = rmtilde(row["TE.HTE_TOPO_START_FROM"].data<string>());
130  if( !topo_start_from.empty())
131  seq->set_topoStartTE(new HLTTriggerElement(topo_start_from));
132  }
133  }
134 
135 
136  string alg_name = row["CP.HCP_NAME"].data<string>() + "/" + row["CP.HCP_ALIAS"].data<string>();
137  unsigned int alg_pos = row["TE2CP.HTE2CP_ALGORITHM_COUNTER"].data<int>();
138 
139  vector<string>& alg_list = seq->algorithms();
140  if( alg_list.size() < alg_pos+1 )
141  alg_list.resize( alg_pos+1, "" );
142 
143  if(auto &algitem = alg_list[alg_pos]; algitem.empty()) {
144  algitem = alg_name;
145  } else {
146  if(algitem != alg_name) {
147  cerr << "Two different algs in the same position " << alg_pos << endl;
148  }
149  }
150 
151  string input_te = rmtilde(row["TE2TE.HTE2TE_TE_INP_ID"].data<string>());
152  if(!input_te.empty()) {
153  unsigned int input_te_pos = row["TE2TE.HTE2TE_TE_COUNTER"].data<int>();
154 
155  vector<HLTTriggerElement*>& inp_list = seq->inputTEs();
156  if( inp_list.size() < input_te_pos+1 )
157  inp_list.resize( input_te_pos+1, (HLTTriggerElement*)0 );
158 
159  if(auto &item = inp_list[input_te_pos]; item == 0) {
160  item = new HLTTriggerElement(input_te);
161  } else {
162  if(item->name() != input_te ) {
163  cerr << "Two different input TE's at the same position " << input_te_pos << endl;
164  }
165  }
166  }
167  }
168  cursor.close();
169 
170  TRG_MSG_INFO("Loading " << seqlist.size() << " sequences");
171 }
172 
173 
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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
TrigConf::HLTSequenceList::addHLTSequence
void addHLTSequence(HLTSequence *sequence)
adds an HLTSequence to the menu
Definition: HLTSequenceList.cxx:30
TrigConf::HLTSequenceList::getSequence
HLTSequence * getSequence(unsigned int id) const
counts the number of sequences in the menu
Definition: HLTSequenceList.cxx:45
run_gep.alg_name
alg_name
Definition: run_gep.py:308
DBHelper.h
TrigConf::fillQuery
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition: DBHelper.cxx:13
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
HLTSequenceLoader.h
TrigConf::HLTFrame::theHLTSequenceList
HLTSequenceList & theHLTSequenceList()
accessor to the list of HLT sequences
Definition: HLTFrame.h:45
TrigConf::HLTSequenceLoader::loadSequences
void loadSequences(HLTSequenceList &seqlist)
Definition: HLTSequenceLoader.cxx:42
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
calibdata.exception
exception
Definition: calibdata.py:496
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
HLTFrame.h
TrigConf::HLTTriggerElement
HLT trigger element configuration information.
Definition: HLTTriggerElement.h:26
HLTTriggerElement.h
item
Definition: ItemListSvc.h:43
TrigConf::rmtilde
std::string rmtilde(const std::string &input)
Definition: DBHelper.h:24
TrigConf::HLTFrame
The HLT trigger menu,.
Definition: HLTFrame.h:33
query_example.cursor
cursor
Definition: query_example.py:21
HLTSequenceList.h
extractSporadic.q
list q
Definition: extractSporadic.py:98
TrigConf::HLTSequenceLoader::load
virtual bool load(HLTFrame &frame)
Definition: HLTSequenceLoader.cxx:19
TrigConf::HLTSequence
HLT sequence configuration information.
Definition: HLTSequence.h:28
TrigConf::HLTSequenceList
list of HLT sequences
Definition: HLTSequenceList.h:40