41 {
42
43 const unsigned int schema_version_with_zb_fields = 9;
44
45 TRG_MSG_DEBUG(
"Loading ThresholdConfig object attached to Lvl1 master ID " << thrConfig.lvl1MasterTableId());
46 TRG_MSG_DEBUG(
"Current number of thresholds: " << thrConfig.size());
47
48 long caloinfoid = 0;
49
50 try {
52
53 int menuid = 0;
54
55 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().tableHandle(
"L1_MASTER_TABLE").newQuery());
56 query0->setRowCacheSize( 5 );
57
58
59 coral::AttributeList bindList0;
60 bindList0.extend<int>("mtId");
61 std::string cond0 = "L1MT_ID = :mtId";
62 bindList0[0].data<int>() = thrConfig.lvl1MasterTableId();
63 query0->setCondition( cond0, bindList0 );
64
65
66 coral::AttributeList attList0;
67 attList0.extend<int>( "L1MT_TRIGGER_MENU_ID" );
68 attList0.extend<long>( "L1MT_CALO_INFO_ID" );
69 query0->defineOutput(attList0);
70 query0->addToOutputList( "L1MT_TRIGGER_MENU_ID" );
71 query0->addToOutputList( "L1MT_CALO_INFO_ID" );
72 coral::ICursor& cursor0 = query0->execute();
73
74 if ( ! cursor0.next() ) {
75 TRG_MSG_ERROR(
"ThresholdConfigLoader >> No such Master_Table exists " << thrConfig.lvl1MasterTableId());
77 throw std::runtime_error( "ThresholdConfigLoader >> ThresholdConfig not available" );
78 }
79
80 const coral::AttributeList& row0 = cursor0.currentRow();
81 menuid = row0["L1MT_TRIGGER_MENU_ID"].data<int>();
82 caloinfoid = row0["L1MT_CALO_INFO_ID"].data<long>();
83
84 if ( cursor0.next() ) {
85
86 TRG_MSG_ERROR(
"ThresholdConfigLoader >> More than one Master_Table exists "
87 << thrConfig.lvl1MasterTableId());
89 throw std::runtime_error( "ThresholdConfigLoader >> Master_Table not available" );
90 }
91
92
93
94
95 coral::AttributeList emptyBindVariableList;
96
97 unique_ptr<coral::IQuery>
query(
m_session.nominalSchema().newQuery());
98
99
100 query->addToTableList (
"L1_TM_TO_TT",
"TM2TT" );
101 query->addToTableList (
"L1_TRIGGER_THRESHOLD",
"TT" );
102 query->addToTableList (
"L1_TT_TO_TTV",
"TT2TTV" );
103 query->addToTableList (
"L1_TRIGGER_THRESHOLD_VALUE",
"TTV" );
104
105
106 coral::AttributeList bindList;
107 bindList.extend<int>("menuId");
108 bindList[0].data<int>() = menuid;
109 std::string theCondition = "";
110 theCondition += std::string( " TM2TT.L1TM2TT_TRIGGER_MENU_ID = :menuId" );
111 theCondition += std::string( " AND TM2TT.L1TM2TT_TRIGGER_THRESHOLD_ID = TT.L1TT_ID" );
112 theCondition += std::string( " AND TT2TTV.L1TT2TTV_TRIGGER_THRESHOLD_ID = TT.L1TT_ID" );
113 theCondition += std::string( " AND TT2TTV.L1TT2TTV_TRIG_THRES_VALUE_ID = TTV.L1TTV_ID" );
114 query->setCondition( theCondition, bindList );
115
116
117 coral::AttributeList attList;
118 attList.extend<std::string>( "TM2TT.L1TM2TT_CABLE_NAME" );
119 attList.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CTPIN" );
120 attList.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CONNECTOR" );
121 attList.extend<int> ( "TM2TT.L1TM2TT_CABLE_START" );
122 attList.extend<int> ( "TM2TT.L1TM2TT_CABLE_END" );
124 attList.extend<int> ( "TM2TT.L1TM2TT_CABLE_CLOCK" );
125 }
126 attList.extend<int> ( "TT.L1TT_ID" );
127 attList.extend<std::string>( "TT.L1TT_NAME" );
128 attList.extend<int> ( "TT.L1TT_VERSION" );
129 attList.extend<std::string>( "TT.L1TT_TYPE" );
130 attList.extend<int> ( "TT.L1TT_ACTIVE" );
131 attList.extend<int> ( "TT.L1TT_MAPPING" );
132 attList.extend<int> ( "TT.L1TT_BITNUM" );
133 attList.extend<int> ( "TTV.L1TTV_ID" );
134 attList.extend<std::string>( "TTV.L1TTV_NAME" );
135 attList.extend<int> ( "TTV.L1TTV_VERSION" );
136 attList.extend<std::string>( "TTV.L1TTV_TYPE" );
137 attList.extend<std::string>( "TTV.L1TTV_PT_CUT" );
138 attList.extend<int> ( "TTV.L1TTV_ETA_MIN" );
139 attList.extend<int> ( "TTV.L1TTV_ETA_MAX" );
140 attList.extend<int> ( "TTV.L1TTV_PHI_MIN" );
141 attList.extend<int> ( "TTV.L1TTV_PHI_MAX" );
142 attList.extend<std::string>( "TTV.L1TTV_EM_ISOLATION" );
143 attList.extend<std::string>( "TTV.L1TTV_HAD_ISOLATION" );
144 attList.extend<std::string>( "TTV.L1TTV_HAD_VETO" );
145 attList.extend<int> ( "TTV.L1TTV_WINDOW" );
146 attList.extend<std::string>( "TTV.L1TTV_PRIORITY" );
148
149
150 std::string theOrder = "";
151 theOrder += " TT.L1TT_MAPPING ASC";
152 theOrder += ", TT.L1TT_ID ASC";
153 theOrder += ", TTV.L1TTV_PRIORITY ASC";
154 theOrder += ", TTV.L1TTV_ETA_MAX ASC";
155 query->addToOrderList( theOrder );
156
157
158 query->setRowCacheSize(500);
159
161
163
164 TriggerThreshold*
tt = 0;
165 int nRowsLoop1 = -2009;
166 int nRowsLoop2 = -2010;
167
169
170 const coral::AttributeList&
row =
cursor.currentRow();
171
172 nRowsLoop1 =
row[
"TT.L1TT_ID"].data<
int>();
173 if (nRowsLoop1 != nRowsLoop2) {
174
175 if (tt != 0) {
176
177 thrConfig.addTriggerThreshold(tt);
178 tt =
new TriggerThreshold();
179
180 } else {
181 tt =
new TriggerThreshold();
182
183 }
184
185
186
187
188 string cableName =
row[
"TM2TT.L1TM2TT_CABLE_NAME"].data<std::string>();
189 tt->setCableName (cableName);
192 tt->setCableStart (row[
"TM2TT.L1TM2TT_CABLE_START"].
data<int>());
193 tt->setCableEnd (row[
"TM2TT.L1TM2TT_CABLE_END"].
data<int>());
194
195 int clock = 0;
197 clock =
row[
"TM2TT.L1TM2TT_CABLE_CLOCK"].data<
int>();
198 }
199 if(clock >= 0) {
201 }
204 tt->setVersion(row[
"TT.L1TT_VERSION"].
data<int>());
206 tt->setType (thrtype);
208 tt->setMapping(row[
"TT.L1TT_MAPPING"].
data<int>());
210 tt->setInput ( (thrtype==
"TOPO" || thrtype==
"ALFA") ?
"ctpcore" :
"ctpin" );
211
212 TRG_MSG_VERBOSE(
"ThresholdConfigLoader loading threshold with ID = " <<
tt->id() <<
" for MenuId = " << menuid <<
": ");
213 }
214
218 } else {
219
220 TriggerThresholdValue* ttv =
tt->createThresholdValue(row[
"TT.L1TT_TYPE"].
data<std::string>());
221
222 ttv->setId (row[
"TTV.L1TTV_ID"].
data<int>());
223
224
226 ttv->setVersion (row[
"TTV.L1TTV_VERSION"].
data<int>());
229 string emisolation =
row[
"TTV.L1TTV_EM_ISOLATION"].data<std::string>();
230 string hadisolation =
row[
"TTV.L1TTV_HAD_ISOLATION"].data<std::string>();
231 string hadveto =
row[
"TTV.L1TTV_HAD_VETO"].data<std::string>();
233 ttv->setPtcut (ptcut);
234 ttv->setPriority (priority);
235
236
237 try {
238 ClusterThresholdValue& ctv = dynamic_cast<ClusterThresholdValue&>(*ttv);
241 msg() <<
"ThresholdConfigLoader >> No type match for ttv_id = "
242 << ctv.id() << " " << ttv->type() << std::endl;
243 throw std::runtime_error( "ThresholdConfigLoader >> ClusterThresholdValue not available" );
244 }
245
246 if(hadveto=="USEISOBITS" || std::stoi(hadveto)==99 ) {
247 ctv.setEmIsolation( 63 );
248 ctv.setHadIsolation( 63 );
249 ctv.setHadVeto( 99 );
251 ctv.setUseIsolationMask();
252 } else {
253 ctv.setEmIsolation( std::stof(emisolation) );
254 ctv.setHadIsolation( std::stof(hadisolation) );
255 ctv.setHadVeto( std::stof(hadveto) );
256 ctv.setUseIsolationMask( false );
257 }
258
259 } catch (std::bad_cast& ex) { }
260
261
262 try {
263 JetThresholdValue& jtv = dynamic_cast<JetThresholdValue&>(*ttv);
267 TRG_MSG_ERROR(
"No type match for ttv_id = " << jtv.id() << ttv->type());
268 throw std::runtime_error( "ThresholdConfigLoader >> TriggerThresholdValue not available" );
269 }
270
271
272
273
274
275 } catch (std::bad_cast& ex) { }
276
277 ttv->setPhiMin(row[
"TTV.L1TTV_PHI_MIN"].
data<int>());
278 ttv->setPhiMax(row[
"TTV.L1TTV_PHI_MAX"].
data<int>());
279 ttv->setEtaMin(row[
"TTV.L1TTV_ETA_MIN"].
data<int>());
280 ttv->setEtaMax(row[
"TTV.L1TTV_ETA_MAX"].
data<int>());
281 ttv->setWindow(row[
"TTV.L1TTV_WINDOW"].
data<int>());
282 tt->addThresholdValue(ttv);
283
284 TRG_MSG_DEBUG(
"ThresholdConfigLoader loading thresholdvalue with ID = " << ttv->id() <<
": " << ttv->name());
285 }
286
287 nRowsLoop2 =
row[
"TT.L1TT_ID"].data<
int>();
288
289 }
290
291
292 thrConfig.addTriggerThreshold(tt);
293
294
295
296
297
298
300 unique_ptr<coral::IQuery> query1(
m_session.nominalSchema().newQuery());
301
302
303 query1->addToTableList ( "L1_TM_TO_TT", "TM2TT" );
304 query1->addToTableList ( "L1_TRIGGER_THRESHOLD", "TT" );
305
306
307 coral::AttributeList bindList1;
308 bindList1.extend<int>("menuId");
309 bindList1[0].data<int>() = menuid;
310 std::string theCondition1 = "";
311 theCondition1 += std::string( " TM2TT.L1TM2TT_TRIGGER_MENU_ID = :menuId" );
312 theCondition1 += std::string( " AND TM2TT.L1TM2TT_TRIGGER_THRESHOLD_ID = TT.L1TT_ID" );
313 query1->setCondition( theCondition1, bindList1 );
314
315
316 coral::AttributeList attList1;
317 attList1.extend<std::string>( "TM2TT.L1TM2TT_CABLE_NAME" );
318 attList1.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CTPIN" );
319 attList1.extend<std::string>( "TM2TT.L1TM2TT_CABLE_CONNECTOR" );
320 attList1.extend<int> ( "TM2TT.L1TM2TT_CABLE_START" );
321 attList1.extend<int> ( "TM2TT.L1TM2TT_CABLE_END" );
323 attList1.extend<int> ( "TM2TT.L1TM2TT_CABLE_CLOCK" );
324 }
325 attList1.extend<int> ( "TT.L1TT_ID" );
326 attList1.extend<std::string>( "TT.L1TT_NAME" );
327 attList1.extend<int> ( "TT.L1TT_VERSION" );
328 attList1.extend<std::string>( "TT.L1TT_TYPE" );
329 attList1.extend<int> ( "TT.L1TT_ACTIVE" );
330 attList1.extend<int> ( "TT.L1TT_MAPPING" );
331 if(
isRun2() || (schema_version >= schema_version_with_zb_fields) ) {
332 attList1.extend<int> ( "TT.L1TT_BCDELAY" );
333 attList1.extend<std::string>( "TT.L1TT_SEED" );
334 attList1.extend<int> ( "TT.L1TT_SEED_MULTI" );
335 }
337
338
339 std::string theOrder1 = "";
340 theOrder1 += " TT.L1TT_ID ASC";
341 query1->addToOrderList( theOrder1 );
342
343
344 query1->setRowCacheSize(500);
345
346 coral::ICursor& cursor1 = query1->execute();
347
348
350 nRowsLoop1 = -2009;
351 nRowsLoop2 = -2010;
352
353 while (cursor1.next()) {
354
355 const coral::AttributeList&
row = cursor1.currentRow();
356
357 nRowsLoop1 =
row[
"TT.L1TT_ID"].data<
int>();
358 tt = thrConfig.findTriggerThreshold(nRowsLoop1);
359 if (tt) continue;
360 if (nRowsLoop1 != nRowsLoop2) {
361
362 if (tt != 0) {
363
364
365 thrConfig.addTriggerThreshold(tt);
366 tt =
new TriggerThreshold();
367
368 } else {
369 tt =
new TriggerThreshold();
370
371 }
372
373
374
375
376
377
378 string cableName =
row[
"TM2TT.L1TM2TT_CABLE_NAME"].data<std::string>();
379 tt->setCableName(cableName);
382 tt->setCableStart (row[
"TM2TT.L1TM2TT_CABLE_START"].
data<int>());
383 tt->setCableEnd (row[
"TM2TT.L1TM2TT_CABLE_END"].
data<int>());
384
385 int clock = 0;
387 clock =
row[
"TM2TT.L1TM2TT_CABLE_CLOCK"].data<
int>();
388 }
389 if(clock >= 0) {
391 }
394 tt->setVersion(row[
"TT.L1TT_VERSION"].
data<int>());
396 tt->setType (thrtype);
398 tt->setMapping(row[
"TT.L1TT_MAPPING"].
data<int>());
399 tt->setInput ( (thrtype==
"TOPO" || thrtype==
"ALFA") ?
"ctpcore" :
"ctpin" );
400
401
402
403 int bcdelay(-1), seed_multi(-1);
404 std::string
seed(
"");
405 if(
isRun2() || (schema_version >= schema_version_with_zb_fields) ) {
406 bcdelay =
row[
"TT.L1TT_BCDELAY"].data<
int>();
407 seed =
row[
"TT.L1TT_SEED"].data<std::string>();
408 seed_multi =
row[
"TT.L1TT_SEED_MULTI"].data<
int>();
409 }
410 tt->setBCDelay (bcdelay);
411 tt->setZBSeedingThresholdName (seed);
412 tt->setZBSeedingThresholdMulti(seed_multi);
413
414 TRG_MSG_VERBOSE(
"ThresholdConfigLoader loading threshold with ID = " <<
tt->id() <<
" for MenuId = " << menuid <<
": ");
415
416
417 thrConfig.addTriggerThreshold(tt);
419 }
420
421 nRowsLoop2 =
row[
"TT.L1TT_ID"].data<
int>();
422
423 }
425 }
426 catch( const coral::Exception& e ) {
428 throw;
429 }
430 catch( const std::exception& e ) {
432 throw;
433 }
434
436
437
438
439 return true;
440
441}
char data[hepevt_bytes_allocation_ATLAS]
#define TRG_MSG_VERBOSE(x)
void commitSession()
commit session if not already done
unsigned int triggerDBSchemaVersion()
void startSession()
start session if not already active
static std::string & typeAsString(TriggerType tt)
void loadCaloInfo(ThresholdConfig &thrConfig, long caloInfoId)
MsgStreamTC & msg() const
The standard message stream.
row
Appending html table to final .html summary file.
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
uint32_t bin2uint(const std::string &binary)