43 const unsigned int schema_version_with_zb_fields = 9;
55 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().tableHandle(
"L1_MASTER_TABLE").newQuery());
56 query0->setRowCacheSize( 5 );
59 coral::AttributeList bindList0;
60 bindList0.extend<
int>(
"mtId");
61 std::string cond0 =
"L1MT_ID = :mtId";
63 query0->setCondition( cond0, bindList0 );
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();
74 if ( ! cursor0.next() ) {
77 throw std::runtime_error(
"ThresholdConfigLoader >> ThresholdConfig not available" );
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>();
84 if ( cursor0.next() ) {
86 TRG_MSG_ERROR(
"ThresholdConfigLoader >> More than one Master_Table exists "
89 throw std::runtime_error(
"ThresholdConfigLoader >> Master_Table not available" );
95 coral::AttributeList emptyBindVariableList;
97 unique_ptr<coral::IQuery>
query(
m_session.nominalSchema().newQuery());
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" );
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 );
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" );
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" );
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 );
158 query->setRowCacheSize(500);
160 coral::ICursor& cursor =
query->execute();
165 int nRowsLoop1 = -2009;
166 int nRowsLoop2 = -2010;
168 while (cursor.next()) {
170 const coral::AttributeList& row = cursor.currentRow();
172 nRowsLoop1 = row[
"TT.L1TT_ID"].data<
int>();
173 if (nRowsLoop1 != nRowsLoop2) {
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>());
197 clock = row[
"TM2TT.L1TM2TT_CABLE_CLOCK"].data<
int>();
202 tt->setId (row[
"TT.L1TT_ID"].
data<int>());
204 tt->setVersion(row[
"TT.L1TT_VERSION"].
data<int>());
206 tt->setType (thrtype);
207 tt->setActive (row[
"TT.L1TT_ACTIVE"].
data<int>());
208 tt->setMapping(row[
"TT.L1TT_MAPPING"].
data<int>());
209 tt->setBitnum(row[
"TT.L1TT_BITNUM"].
data<int>());
210 tt->setInput ( (thrtype==
"TOPO" || thrtype==
"ALFA") ?
"ctpcore" :
"ctpin" );
212 TRG_MSG_VERBOSE(
"ThresholdConfigLoader loading threshold with ID = " << tt->id() <<
" for MenuId = " << menuid <<
": ");
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>();
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" );
246 if(hadveto==
"USEISOBITS" || std::stoi(hadveto)==99 ) {
259 }
catch (std::bad_cast& ex) { }
268 throw std::runtime_error(
"ThresholdConfigLoader >> TriggerThresholdValue not available" );
275 }
catch (std::bad_cast& ex) { }
282 tt->addThresholdValue(ttv);
284 TRG_MSG_DEBUG(
"ThresholdConfigLoader loading thresholdvalue with ID = " << ttv->
id() <<
": " << ttv->
name());
287 nRowsLoop2 = row[
"TT.L1TT_ID"].data<
int>();
300 unique_ptr<coral::IQuery> query1(
m_session.nominalSchema().newQuery());
303 query1->addToTableList (
"L1_TM_TO_TT",
"TM2TT" );
304 query1->addToTableList (
"L1_TRIGGER_THRESHOLD",
"TT" );
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 );
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" );
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" );
339 std::string theOrder1 =
"";
340 theOrder1 +=
" TT.L1TT_ID ASC";
341 query1->addToOrderList( theOrder1 );
344 query1->setRowCacheSize(500);
346 coral::ICursor& cursor1 = query1->execute();
353 while (cursor1.next()) {
355 const coral::AttributeList& row = cursor1.currentRow();
357 nRowsLoop1 = row[
"TT.L1TT_ID"].data<
int>();
360 if (nRowsLoop1 != nRowsLoop2) {
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>());
387 clock = row[
"TM2TT.L1TM2TT_CABLE_CLOCK"].data<
int>();
392 tt->setId (row[
"TT.L1TT_ID"].
data<int>());
394 tt->setVersion(row[
"TT.L1TT_VERSION"].
data<int>());
396 tt->setType (thrtype);
397 tt->setActive (row[
"TT.L1TT_ACTIVE"].
data<int>());
398 tt->setMapping(row[
"TT.L1TT_MAPPING"].
data<int>());
399 tt->setInput ( (thrtype==
"TOPO" || thrtype==
"ALFA") ?
"ctpcore" :
"ctpin" );
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>();
410 tt->setBCDelay (bcdelay);
411 tt->setZBSeedingThresholdName (seed);
412 tt->setZBSeedingThresholdMulti(seed_multi);
414 TRG_MSG_VERBOSE(
"ThresholdConfigLoader loading threshold with ID = " << tt->id() <<
" for MenuId = " << menuid <<
": ");
421 nRowsLoop2 = row[
"TT.L1TT_ID"].data<
int>();
426 catch(
const coral::Exception& e ) {
430 catch(
const std::exception& e ) {