32 const unsigned int schema_version_with_zb_fields = 9;
34 TRG_MSG_DEBUG(
"TriggerThresholdLoader loading threshold with ID = "
35 << ttTarget.id() <<
" for MenuId = "
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" );
70 TRG_MSG_ERROR(
"No TriggerThreshold exists with ID " << ttTarget.id());
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>();
95 ttTarget.setName (
name );
97 ttTarget.setType (
type );
98 ttTarget.setInput ( (
type==
"TOPO" ||
type==
"ALFA") ?
"ctpcore" :
"ctpin" );
99 ttTarget.setActive (
active );
101 ttTarget.setZBSeedingThresholdName(seed);
102 ttTarget.setZBSeedingThresholdMulti(seed_multi);
103 ttTarget.setBCDelay(bcdelay);
105 if(ttTarget.isInternal()) {
106 string::size_type
pos =
name.find_first_of(
"0123456789");
109 ttTarget.setMapping(
mapping );
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();
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>();
155 ttTarget.setCableName(cable_name);
156 ttTarget.setCableCtpin(cable_ctpin);
157 ttTarget.setCableConnector(cable_connector);
158 ttTarget.setCableStart(cable_start);
159 ttTarget.setCableEnd(cable_end);
163 if( ! ttTarget.isInternal() ) {
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();
194 TriggerThresholdValueLoader& ttvldr =
dynamic_cast<TriggerThresholdValueLoader&
>
195 ((
dynamic_cast<StorageMgr&
>(
m_storageMgr)).triggerThresholdValueLoader());
197 for (
unsigned int i=0;
i<numberofvalues; ++
i) {
199 TriggerThresholdValue* ttv = 0;
200 if ( ttTarget.type() == L1DataDef::emType() ||
201 ttTarget.type() == L1DataDef::tauType() ) {
202 ttv =
new ClusterThresholdValue();
204 ttTarget.type()==L1DataDef::jbType() ||
205 ttTarget.type()==L1DataDef::jfType()) {
206 ttv =
new JetThresholdValue();
207 }
else if (ttTarget.type() ==L1DataDef::muonType()) {
208 ttv =
new MuonThresholdValue();
209 }
else if (ttTarget.type() == L1DataDef::jeType() ||
210 ttTarget.type() == L1DataDef::xeType() ||
211 ttTarget.type() == L1DataDef::teType()) {
212 ttv =
new EtThresholdValue();
213 }
else if (ttTarget.type() == L1DataDef::xsType()) {
214 ttv =
new XsThresholdValue();
215 }
else if (ttTarget.type() == L1DataDef::nimType() ||
216 ttTarget.type() == L1DataDef::mbtsType() ||
219 ttTarget.type() == L1DataDef::zdcType() ||
220 ttTarget.type() == L1DataDef::trtType() ||
221 ttTarget.type() == L1DataDef::bcmType() ||
223 ttTarget.type() == L1DataDef::lucidType()) {
224 ttv =
new NimThresholdValue();
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 " );
244 ttTarget.addThresholdValue(ttv);
251 }
catch(
const coral::SchemaException&
e ) {
252 msg() <<
"TriggerThresholdLoader: SchemaException: "
253 <<
e.what() << std::endl;
257 msg() <<
"TriggerThresholdLoader >> Standard C++ exception: " <<
e.what() << std::endl;
262 msg() <<
"TriggerThresholdLoader >> unknown C++ exception" << std::endl;