28 {
29
30 const unsigned int schema_version_with_zb_fields = 9;
31
32 TRG_MSG_DEBUG(
"TriggerThresholdLoader loading threshold with ID = "
33 << ttTarget.id() << " for MenuId = "
36
37 try {
39
40 {
41 unique_ptr<coral::IQuery>
query(
m_session.nominalSchema().tableHandle(
"L1_TRIGGER_THRESHOLD").newQuery());
42 query->setRowCacheSize( 5 );
43
44
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 );
50
51
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" );
62 }
64
66
68 TRG_MSG_ERROR(
"No TriggerThreshold exists with ID " << ttTarget.id());
70 throw std::runtime_error( "TriggerThresholdLoader >> TriggerThreshold not available" );
71 }
72
73 const coral::AttributeList&
row =
cursor.currentRow();
74
75 std::string
name =
row[
"L1TT_NAME"].data<std::string>();
77 std::string
type =
row[
"L1TT_TYPE"].data<std::string>();
78 int active =
row[
"L1TT_ACTIVE"].data<
int>();
80
81
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>();
88 }
89
90 TRG_MSG_DEBUG(name <<
" " << version <<
" " << type <<
" " << active <<
" " << mapping);
91
92
93 ttTarget.setName ( name );
94 ttTarget.setVersion( version );
95 ttTarget.setType ( type );
96 ttTarget.setInput ( (type=="TOPO" || type=="ALFA") ? "ctpcore" : "ctpin" );
97 ttTarget.setActive ( active );
98
99 ttTarget.setZBSeedingThresholdName(seed);
100 ttTarget.setZBSeedingThresholdMulti(seed_multi);
101 ttTarget.setBCDelay(bcdelay);
102
103 if(ttTarget.isInternal()) {
104 string::size_type
pos =
name.find_first_of(
"0123456789");
106 }
107 ttTarget.setMapping( mapping );
108 }
109
110
111
112
114
115 unique_ptr<coral::IQuery>
query(
m_session.nominalSchema().tableHandle(
"L1_TM_TO_TT").newQuery());
116 query->setRowCacheSize( 5 );
117
118
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 );
127
128
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" );
136
138
140 TRG_MSG_ERROR(
"No such combination in L1_TM_TO_TT: TT ID "<< ttTarget.id() <<
", menu ID " <<
m_MenuId);
142 throw std::runtime_error( "TriggerThresholdLoader >> "
143 "TMTI combination not availbale in TM_TT" );
144 }
145
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>();
152
153 ttTarget.setCableName(cable_name);
154 ttTarget.setCableCtpin(cable_ctpin);
155 ttTarget.setCableConnector(cable_connector);
156 ttTarget.setCableStart(cable_start);
157 ttTarget.setCableEnd(cable_end);
158
159 }
160
161 if( ! ttTarget.isInternal() ) {
162
163
164
165 coral::ITable&
table =
m_session.nominalSchema().tableHandle(
"L1_TT_TO_TTV");
167 query->setRowCacheSize(5);
168
169
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 );
175
176
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" );
181
183
184 std::vector<long> vec_ttv_id;
186 const coral::AttributeList&
row =
cursor.currentRow();
187 vec_ttv_id.push_back((
long)row[
"L1TT2TTV_TRIG_THRES_VALUE_ID"].
data<long>());
188 }
189
190 unsigned int numberofvalues = vec_ttv_id.size();
191
192 TriggerThresholdValueLoader& ttvldr = dynamic_cast<TriggerThresholdValueLoader&>
193 ((
dynamic_cast<StorageMgr&
>(
m_storageMgr)).triggerThresholdValueLoader());
195 for (
unsigned int i=0;
i<numberofvalues; ++
i) {
196 TriggerThresholdValue* ttv = 0;
198 ttv = new MuonThresholdValue();
201 ttv = new ClusterThresholdValue();
205 ttv = new JetThresholdValue();
209 ttv = new EtThresholdValue();
211 ttv = new XsThresholdValue();
222 ttv = new NimThresholdValue();
223 } else {
224 msg() <<
"TriggerThresholdLoader: not supported type "
225 << ttTarget.id() << " type is " << ttTarget.type() << std::endl;
227 delete ttv;
229 throw std::runtime_error("TriggerThresholdLoader: not supported type" );
230 }
231 ttv->setId(vec_ttv_id[i]);
232 if ( !ttvldr.load( *ttv ) ) {
233 msg() <<
"TriggerThresholdLoader: Error loading TriggerThreshodValue "
234 << ttv->id() << std::endl;
235 delete ttv;
236 ttv = 0;
239 throw std::runtime_error("TriggerThresholdLoader: Error loading TriggerThreshodValue " );
240 } else {
241
242 ttTarget.addThresholdValue(ttv);
243 }
244 }
245 }
246
248 return true;
249 } catch( const coral::SchemaException& e ) {
250 msg() <<
"TriggerThresholdLoader: SchemaException: "
251 <<
e.what() << std::endl;
253 return false;
254 } catch( const std::exception& e ) {
255 msg() <<
"TriggerThresholdLoader >> Standard C++ exception: " <<
e.what() << std::endl;
256
258 return false;
259 } catch( ... ) {
260 msg() <<
"TriggerThresholdLoader >> unknown C++ exception" << std::endl;
261
263 return false;
264 }
265}
char data[hepevt_bytes_allocation_ATLAS]
virtual int verbose() const override
StorageMgr & m_storageMgr
reference to the storage manager
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)
MsgStreamTC & msg() const
The standard message stream.
row
Appending html table to final .html summary file.
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)