30 const unsigned int schema_version_with_zb_fields = 9;
32 TRG_MSG_DEBUG(
"TriggerThresholdLoader loading threshold with ID = "
33 << ttTarget.
id() <<
" for MenuId = "
41 unique_ptr<coral::IQuery>
query(
m_session.nominalSchema().tableHandle(
"L1_TRIGGER_THRESHOLD").newQuery());
42 query->setRowCacheSize( 5 );
45 coral::AttributeList bindList;
46 bindList.extend<
long>(
"ttId");
47 std::string cond=
"L1TT_ID = :ttId";
48 bindList[0].data<
long>() = ttTarget.
id();
49 query->setCondition( cond, bindList );
52 coral::AttributeList attList;
53 attList.extend<std::string>(
"L1TT_NAME" );
54 attList.extend<
int>(
"L1TT_VERSION" );
55 attList.extend<std::string>(
"L1TT_TYPE" );
56 attList.extend<
int>(
"L1TT_ACTIVE" );
57 attList.extend<
int>(
"L1TT_MAPPING" );
58 if( (
isRun1() && schema_version >= schema_version_with_zb_fields) ||
isRun2() ) {
59 attList.extend<
int>(
"L1TT_BCDELAY" );
60 attList.extend<std::string>(
"L1TT_SEED" );
61 attList.extend<
int>(
"L1TT_SEED_MULTI" );
65 coral::ICursor& cursor =
query->execute();
67 if ( ! cursor.next() ) {
70 throw std::runtime_error(
"TriggerThresholdLoader >> TriggerThreshold not available" );
73 const coral::AttributeList& row = cursor.currentRow();
75 std::string
name = row[
"L1TT_NAME"].data<std::string>();
76 int version = row[
"L1TT_VERSION"].data<
int>();
77 std::string
type = row[
"L1TT_TYPE"].data<std::string>();
78 int active = row[
"L1TT_ACTIVE"].data<
int>();
79 int mapping = row[
"L1TT_MAPPING"].data<
int>();
82 int bcdelay(-1), seed_multi(-1);
84 if( (
isRun1() && schema_version >= schema_version_with_zb_fields) ||
isRun2() ) {
85 bcdelay = row[
"L1TT_BCDELAY"].data<
int>();
86 seed = row[
"L1TT_SEED"].data<std::string>();
87 seed_multi = row[
"L1TT_SEED_MULTI"].data<
int>();
104 string::size_type pos =
name.find_first_of(
"0123456789");
105 mapping = std::stoi(
name.substr(pos));
115 unique_ptr<coral::IQuery>
query(
m_session.nominalSchema().tableHandle(
"L1_TM_TO_TT").newQuery());
116 query->setRowCacheSize( 5 );
119 coral::AttributeList bindList;
120 std::string cond =
"L1TM2TT_TRIGGER_THRESHOLD_ID = :ttId";
121 cond +=
" AND L1TM2TT_TRIGGER_MENU_ID = :menuId";
122 bindList.extend<
long>(
"ttId");
123 bindList.extend<
int>(
"menuId");
124 bindList[0].data<
long>() = ttTarget.
id();
126 query->setCondition( cond, bindList );
129 coral::AttributeList attList;
130 attList.extend<std::string>(
"L1TM2TT_CABLE_NAME" );
131 attList.extend<std::string>(
"L1TM2TT_CABLE_CTPIN" );
132 attList.extend<std::string>(
"L1TM2TT_CABLE_CONNECTOR" );
133 attList.extend<
int>(
"L1TM2TT_CABLE_START" );
134 attList.extend<
int>(
"L1TM2TT_CABLE_END" );
137 coral::ICursor& cursor =
query->execute();
139 if ( ! cursor.next() ) {
142 throw std::runtime_error(
"TriggerThresholdLoader >> "
143 "TMTI combination not availbale in TM_TT" );
146 const coral::AttributeList& row = cursor.currentRow();
147 std::string cable_name = row[
"L1TM2TT_CABLE_NAME"].data<std::string>();
148 std::string cable_ctpin = row[
"L1TM2TT_CABLE_CTPIN"].data<std::string>();
149 std::string cable_connector = row[
"L1TM2TT_CABLE_CONNECTOR"].data<std::string>();
150 int cable_start = row[
"L1TM2TT_CABLE_START"].data<
int>();
151 int cable_end = row[
"L1TM2TT_CABLE_END"].data<
int>();
165 coral::ITable& table =
m_session.nominalSchema().tableHandle(
"L1_TT_TO_TTV");
166 coral::IQuery*
query = table.newQuery();
167 query->setRowCacheSize(5);
170 coral::AttributeList bindList;
171 bindList.extend<
long>(
"ttId");
172 std::string cond =
"L1TT2TTV_TRIGGER_THRESHOLD_ID = :ttId";
173 bindList[0].data<
long>() = ttTarget.
id();
174 query->setCondition( cond, bindList );
177 coral::AttributeList attList;
178 attList.extend<
long>(
"L1TT2TTV_TRIG_THRES_VALUE_ID" );
179 query->defineOutput(attList);
180 query->addToOutputList(
"L1TT2TTV_TRIG_THRES_VALUE_ID" );
182 coral::ICursor& cursor =
query->execute();
184 std::vector<long> vec_ttv_id;
185 while( cursor.next() ) {
186 const coral::AttributeList& row = cursor.currentRow();
187 vec_ttv_id.push_back((
long)row[
"L1TT2TTV_TRIG_THRES_VALUE_ID"].
data<long>());
190 unsigned int numberofvalues = vec_ttv_id.size();
195 for (
unsigned int i=0; i<numberofvalues; ++i) {
224 msg() <<
"TriggerThresholdLoader: not supported type "
225 << ttTarget.
id() <<
" type is " << ttTarget.
type() << std::endl;
229 throw std::runtime_error(
"TriggerThresholdLoader: not supported type" );
231 ttv->
setId(vec_ttv_id[i]);
232 if ( !ttvldr.
load( *ttv ) ) {
233 msg() <<
"TriggerThresholdLoader: Error loading TriggerThreshodValue "
234 << ttv->
id() << std::endl;
239 throw std::runtime_error(
"TriggerThresholdLoader: Error loading TriggerThreshodValue " );
249 }
catch(
const coral::SchemaException& e ) {
250 msg() <<
"TriggerThresholdLoader: SchemaException: "
251 << e.what() << std::endl;
254 }
catch(
const std::exception& e ) {
255 msg() <<
"TriggerThresholdLoader >> Standard C++ exception: " << e.what() << std::endl;
260 msg() <<
"TriggerThresholdLoader >> unknown C++ exception" << std::endl;