20 #include "boost/lexical_cast.hpp"
32 const unsigned int schema_version_with_zb_fields = 9;
34 TRG_MSG_DEBUG(
"TriggerThresholdLoader loading threshold with ID = "
35 << ttTarget.
id() <<
" for MenuId = "
37 unsigned int schema_version = triggerDBSchemaVersion();
43 unique_ptr<coral::IQuery>
query(m_session.nominalSchema().tableHandle(
"L1_TRIGGER_THRESHOLD").newQuery());
44 query->setRowCacheSize( 5 );
48 bindList.extend<
long>(
"ttId");
49 std::string cond=
"L1TT_ID = :ttId";
50 bindList[0].data<
long>() = ttTarget.
id();
51 query->setCondition( cond, bindList );
55 attList.extend<std::string>(
"L1TT_NAME" );
56 attList.extend<
int>(
"L1TT_VERSION" );
57 attList.extend<std::string>(
"L1TT_TYPE" );
58 attList.extend<
int>(
"L1TT_ACTIVE" );
59 attList.extend<
int>(
"L1TT_MAPPING" );
60 if( (isRun1() && schema_version >= schema_version_with_zb_fields) ||
isRun2() ) {
61 attList.extend<
int>(
"L1TT_BCDELAY" );
62 attList.extend<std::string>(
"L1TT_SEED" );
63 attList.extend<
int>(
"L1TT_SEED_MULTI" );
72 throw std::runtime_error(
"TriggerThresholdLoader >> TriggerThreshold not available" );
77 std::string
name =
row[
"L1TT_NAME"].data<std::string>();
79 std::string
type =
row[
"L1TT_TYPE"].data<std::string>();
80 int active =
row[
"L1TT_ACTIVE"].data<
int>();
84 int bcdelay(-1), seed_multi(-1);
86 if( (isRun1() && schema_version >= schema_version_with_zb_fields) ||
isRun2() ) {
87 bcdelay =
row[
"L1TT_BCDELAY"].data<
int>();
88 seed =
row[
"L1TT_SEED"].data<std::string>();
89 seed_multi =
row[
"L1TT_SEED_MULTI"].data<
int>();
106 string::size_type
pos =
name.find_first_of(
"0123456789");
115 if(loadCableInfo()) {
117 unique_ptr<coral::IQuery>
query(m_session.nominalSchema().tableHandle(
"L1_TM_TO_TT").newQuery());
118 query->setRowCacheSize( 5 );
122 std::string cond =
"L1TM2TT_TRIGGER_THRESHOLD_ID = :ttId";
123 cond +=
" AND L1TM2TT_TRIGGER_MENU_ID = :menuId";
124 bindList.extend<
long>(
"ttId");
125 bindList.extend<
int>(
"menuId");
126 bindList[0].data<
long>() = ttTarget.
id();
127 bindList[1].data<
int>() = m_MenuId;
128 query->setCondition( cond, bindList );
132 attList.extend<std::string>(
"L1TM2TT_CABLE_NAME" );
133 attList.extend<std::string>(
"L1TM2TT_CABLE_CTPIN" );
134 attList.extend<std::string>(
"L1TM2TT_CABLE_CONNECTOR" );
135 attList.extend<
int>(
"L1TM2TT_CABLE_START" );
136 attList.extend<
int>(
"L1TM2TT_CABLE_END" );
142 TRG_MSG_ERROR(
"No such combination in L1_TM_TO_TT: TT ID "<< ttTarget.
id() <<
", menu ID " << m_MenuId);
144 throw std::runtime_error(
"TriggerThresholdLoader >> "
145 "TMTI combination not availbale in TM_TT" );
149 std::string cable_name =
row[
"L1TM2TT_CABLE_NAME"].data<std::string>();
150 std::string cable_ctpin =
row[
"L1TM2TT_CABLE_CTPIN"].data<std::string>();
151 std::string cable_connector =
row[
"L1TM2TT_CABLE_CONNECTOR"].data<std::string>();
152 int cable_start =
row[
"L1TM2TT_CABLE_START"].data<
int>();
153 int cable_end =
row[
"L1TM2TT_CABLE_END"].data<
int>();
167 coral::ITable&
table = m_session.nominalSchema().tableHandle(
"L1_TT_TO_TTV");
169 query->setRowCacheSize(5);
173 bindList.extend<
long>(
"ttId");
174 std::string cond =
"L1TT2TTV_TRIGGER_THRESHOLD_ID = :ttId";
175 bindList[0].data<
long>() = ttTarget.
id();
176 query->setCondition( cond, bindList );
180 attList.extend<
long>(
"L1TT2TTV_TRIG_THRES_VALUE_ID" );
181 query->defineOutput(attList);
182 query->addToOutputList(
"L1TT2TTV_TRIG_THRES_VALUE_ID" );
186 std::vector<long> vec_ttv_id;
189 vec_ttv_id.push_back((
long)
row[
"L1TT2TTV_TRIG_THRES_VALUE_ID"].data<
long>());
192 unsigned int numberofvalues = vec_ttv_id.size();
195 ((
dynamic_cast<StorageMgr&
>(m_storageMgr)).triggerThresholdValueLoader());
197 for (
unsigned int i=0;
i<numberofvalues; ++
i) {
200 if ( ttTarget.
type() == L1DataDef::emType() ||
201 ttTarget.
type() == L1DataDef::tauType() ) {
204 ttTarget.
type()==L1DataDef::jbType() ||
205 ttTarget.
type()==L1DataDef::jfType()) {
207 }
else if (ttTarget.
type() ==L1DataDef::muonType()) {
209 }
else if (ttTarget.
type() == L1DataDef::jeType() ||
210 ttTarget.
type() == L1DataDef::xeType() ||
211 ttTarget.
type() == L1DataDef::teType()) {
213 }
else if (ttTarget.
type() == L1DataDef::xsType()) {
215 }
else if (ttTarget.
type() == L1DataDef::nimType() ||
216 ttTarget.
type() == L1DataDef::mbtsType() ||
217 ttTarget.
type() == L1DataDef::mbtssiType() ||
218 ttTarget.
type() == L1DataDef::calreqType() ||
219 ttTarget.
type() == L1DataDef::zdcType() ||
220 ttTarget.
type() == L1DataDef::trtType() ||
221 ttTarget.
type() == L1DataDef::bcmType() ||
222 ttTarget.
type() == L1DataDef::bcmcmbType() ||
223 ttTarget.
type() == L1DataDef::lucidType()) {
226 msg() <<
"TriggerThresholdLoader: not supported type "
227 << ttTarget.
id() <<
" type is " << ttTarget.
type() << std::endl;
231 throw std::runtime_error(
"TriggerThresholdLoader: not supported type" );
233 ttv->
setId(vec_ttv_id[
i]);
234 if ( !ttvldr.
load( *ttv ) ) {
235 msg() <<
"TriggerThresholdLoader: Error loading TriggerThreshodValue "
236 << ttv->
id() << std::endl;
241 throw std::runtime_error(
"TriggerThresholdLoader: Error loading TriggerThreshodValue " );
251 }
catch(
const coral::SchemaException&
e ) {
252 msg() <<
"TriggerThresholdLoader: SchemaException: "
253 <<
e.what() << std::endl;
254 m_session.transaction().rollback();
257 msg() <<
"TriggerThresholdLoader >> Standard C++ exception: " <<
e.what() << std::endl;
259 m_session.transaction().rollback();
262 msg() <<
"TriggerThresholdLoader >> unknown C++ exception" << std::endl;
264 m_session.transaction().rollback();