72 TriggerThresholdLoader& ttldr =
dynamic_cast<TriggerThresholdLoader&
>( (
dynamic_cast<StorageMgr&
>(
m_storageMgr))
73 .triggerThresholdLoader() );
74 ttldr.setMenuId(
menu.id());
75 ttldr.setLoadCableInfo(
false);
79 std::map<int,TriggerThreshold*> thresholdNotFoundCache;
81 unique_ptr< coral::IQuery >
query(
m_session.nominalSchema().newQuery() );
82 query->addToTableList (
"L1_TM_TO_TI",
"TM2TI" );
83 query->addToTableList (
"L1_TRIGGER_ITEM",
"TI" );
84 query->addToTableList (
"L1_TI_TO_TT",
"TI2TT" );
88 bindList.extend<
int>(
"menuId");
89 bindList[0].data<
int>() =
menu.id();
91 std::string theCondition =
"";
92 theCondition += std::string(
" TM2TI.L1TM2TI_TRIGGER_MENU_ID = :menuId" );
93 theCondition += std::string(
" AND TM2TI.L1TM2TI_TRIGGER_ITEM_ID = TI.L1TI_ID" );
94 theCondition += std::string(
" AND TI2TT.L1TI2TT_TRIGGER_ITEM_ID = TI.L1TI_ID" );
96 query->setCondition( theCondition, bindList );
100 attList.extend<
int> (
"TI.L1TI_ID" );
101 attList.extend<std::string>(
"TI.L1TI_NAME" );
102 attList.extend<
int> (
"TI.L1TI_VERSION" );
104 attList.extend<
int> (
"TI.L1TI_PARTITION" );
105 attList.extend<
string> (
"TI.L1TI_MONITOR" );
107 attList.extend<
int> (
"TI.L1TI_CTP_ID" );
108 attList.extend<std::string>(
"TI.L1TI_PRIORITY" );
109 attList.extend<std::string>(
"TI.L1TI_DEFINITION" );
110 attList.extend<
int> (
"TI.L1TI_TRIGGER_TYPE" );
111 attList.extend<
int> (
"TI2TT.L1TI2TT_TRIGGER_THRESHOLD_ID" );
112 attList.extend<
int> (
"TI2TT.L1TI2TT_POSITION" );
113 attList.extend<
int> (
"TI2TT.L1TI2TT_MULTIPLICITY" );
117 std::string theOrder =
"";
119 theOrder +=
" TI.L1TI_CTP_ID ASC";
121 theOrder +=
", TI2TT.L1TI2TT_POSITION ASC";
122 query->addToOrderList( theOrder );
125 query->setRowCacheSize(500);
127 query->setDistinct();
133 map<int,vector<ThrInfo> > item_thrInfo;
139 int ctpid =
row[
"TI.L1TI_CTP_ID"].data<
int>();
140 TriggerItem*
item =
menu.item(ctpid);
142 item =
new TriggerItem();
143 item->setCtpId (ctpid);
144 item->setId (
row[
"TI.L1TI_ID"].data<int>());
145 item->setName (
row[
"TI.L1TI_NAME"].data<string>());
146 item->setVersion (
row[
"TI.L1TI_VERSION"].data<int>());
148 item->setPartition (
row[
"TI.L1TI_PARTITION"].data<int>());
149 string mon =
row[
"TI.L1TI_MONITOR"].data<
string>();
150 unsigned short monMask = 0;
152 const short TBP = 0x1;
153 const short TAP = 0x2;
154 const short TAV = 0x4;
156 vector<string> monLfHf;
160 if(monLfHf.size()==4 && monLfHf[0]==
"LF" && monLfHf[2]==
"HF" && monLfHf[1].size()==3 && monLfHf[3].size()==3) {
162 if( monLfHf[1][2]==
'1' ) monMask |= TBP;
163 if( monLfHf[1][1]==
'1' ) monMask |= TAP;
164 if( monLfHf[1][0]==
'1' ) monMask |= TAV;
166 if( monLfHf[3][2]==
'1' ) monMask |= TBP << 3;
167 if( monLfHf[3][1]==
'1' ) monMask |= TAP << 3;
168 if( monLfHf[3][0]==
'1' ) monMask |= TAV << 3;
171 if(
mon.find(
"TBP") != string::npos) monMask |= TBP;
172 if(
mon.find(
"TAP") != string::npos) monMask |= TAP;
173 if(
mon.find(
"TAV") != string::npos) monMask |= TAV;
175 item->setMonitor( monMask );
178 string priority =
row[
"TI.L1TI_PRIORITY"].data<
string>();
180 item->setComplexDeadtime(0);
182 item->setComplexDeadtime(1);
184 item->setDefinition (
row[
"TI.L1TI_DEFINITION"].data<string>());
185 item->setTriggerType(
row[
"TI.L1TI_TRIGGER_TYPE"].data<int>());
188 msg() <<
"MenuLoader: Created Item " <<
item->name() <<
" with CTPID " <<
item->ctpId() << endl;
189 item_thrInfo[ctpid] = vector<ThrInfo>();
190 ctpIDs.push_back(ctpid);
194 thr_info.thrId =
row[
"TI2TT.L1TI2TT_TRIGGER_THRESHOLD_ID"].data<
int>();
195 thr_info.thrPos =
row[
"TI2TT.L1TI2TT_POSITION"].data<
int>();
196 thr_info.thrMult =
row[
"TI2TT.L1TI2TT_MULTIPLICITY"].data<
int>();
197 thr_info.thr =
menu.thresholdConfig().findTriggerThreshold(thr_info.thrId);
198 if(thr_info.thr==0) {
200 thr_info.thr =
new TriggerThreshold();
201 thr_info.thr->setId(thr_info.thrId);
202 if ( ! ttldr.load( *thr_info.thr ) ) {
203 msg() <<
"MenuLoader: Error loading TriggerThreshold " << thr_info.thrId << endl;
204 throw runtime_error(
"MenuLoader::loadItems: error loading TriggerThreshold " );
206 menu.thresholdConfig().addTriggerThreshold(thr_info.thr);
208 item_thrInfo[ctpid].push_back(thr_info);
212 for(
int ctpid : ctpIDs) {
213 TriggerItem* titem =
menu.findTriggerItem( ctpid );
215 msg() <<
"MenuLoader: Number of thresholds for item " << titem->name()
216 <<
": " << item_thrInfo[ctpid].size() <<
" - definition: " << titem->definition() << endl;
221 titem->setTopNode(
constructTree(titem->definition(), item_thrInfo[ctpid]) );