66 {
68
69
70 TriggerThresholdLoader& ttldr =
dynamic_cast<TriggerThresholdLoader&
>( (
dynamic_cast<StorageMgr&
>(
m_storageMgr))
71 .triggerThresholdLoader() );
72 ttldr.setMenuId(
menu.id());
73 ttldr.setLoadCableInfo(false);
74
75
76
77 std::map<int,TriggerThreshold*> thresholdNotFoundCache;
78
79 unique_ptr< coral::IQuery >
query(
m_session.nominalSchema().newQuery() );
80 query->addToTableList (
"L1_TM_TO_TI",
"TM2TI" );
81 query->addToTableList (
"L1_TRIGGER_ITEM",
"TI" );
82 query->addToTableList (
"L1_TI_TO_TT",
"TI2TT" );
83
84
85 coral::AttributeList bindList;
86 bindList.extend<int>("menuId");
87 bindList[0].data<
int>() =
menu.id();
88
89 std::string theCondition = "";
90 theCondition += std::string( " TM2TI.L1TM2TI_TRIGGER_MENU_ID = :menuId" );
91 theCondition += std::string( " AND TM2TI.L1TM2TI_TRIGGER_ITEM_ID = TI.L1TI_ID" );
92 theCondition += std::string( " AND TI2TT.L1TI2TT_TRIGGER_ITEM_ID = TI.L1TI_ID" );
93
94 query->setCondition( theCondition, bindList );
95
96
97 coral::AttributeList attList;
98 attList.extend<int> ( "TI.L1TI_ID" );
99 attList.extend<std::string>( "TI.L1TI_NAME" );
100 attList.extend<int> ( "TI.L1TI_VERSION" );
102 attList.extend<int> ( "TI.L1TI_PARTITION" );
103 attList.extend<string> ( "TI.L1TI_MONITOR" );
104 }
105 attList.extend<int> ( "TI.L1TI_CTP_ID" );
106 attList.extend<std::string>( "TI.L1TI_PRIORITY" );
107 attList.extend<std::string>( "TI.L1TI_DEFINITION" );
108 attList.extend<int> ( "TI.L1TI_TRIGGER_TYPE" );
109 attList.extend<int> ( "TI2TT.L1TI2TT_TRIGGER_THRESHOLD_ID" );
110 attList.extend<int> ( "TI2TT.L1TI2TT_POSITION" );
111 attList.extend<int> ( "TI2TT.L1TI2TT_MULTIPLICITY" );
113
114
115 std::string theOrder = "";
116
117 theOrder += " TI.L1TI_CTP_ID ASC";
118
119 theOrder += ", TI2TT.L1TI2TT_POSITION ASC";
120 query->addToOrderList( theOrder );
121
122
123 query->setRowCacheSize(500);
124
125 query->setDistinct();
126
128
129
130 vector<int> ctpIDs;
131 map<int,vector<ThrInfo> > item_thrInfo;
132
133
135
136 const coral::AttributeList&
row =
cursor.currentRow();
137 int ctpid =
row[
"TI.L1TI_CTP_ID"].data<
int>();
138 TriggerItem* item =
menu.item(ctpid);
139 if(! item) {
140 item = new TriggerItem();
141 item->setCtpId (ctpid);
142 item->setId (row["TI.L1TI_ID"].data<int>());
143 item->setName (row["TI.L1TI_NAME"].data<string>());
144 item->setVersion (row["TI.L1TI_VERSION"].data<int>());
146 item->setPartition (row["TI.L1TI_PARTITION"].data<int>());
147 string mon =
row[
"TI.L1TI_MONITOR"].data<
string>();
148 unsigned short monMask = 0;
149
150 const short TBP = 0x1;
151 const short TAP = 0x2;
152 const short TAV = 0x4;
153
155
156
157 if(monLfHf.size()==4 && monLfHf[0]=="LF" && monLfHf[2]=="HF" && monLfHf[1].size()==3 && monLfHf[3].size()==3) {
158
159 if( monLfHf[1][2]=='1' ) monMask |= TBP;
160 if( monLfHf[1][1]=='1' ) monMask |= TAP;
161 if( monLfHf[1][0]=='1' ) monMask |= TAV;
162
163 if( monLfHf[3][2]=='1' ) monMask |= TBP << 3;
164 if( monLfHf[3][1]=='1' ) monMask |= TAP << 3;
165 if( monLfHf[3][0]=='1' ) monMask |= TAV << 3;
166 } else {
167
168 if(
mon.find(
"TBP") != string::npos) monMask |= TBP;
169 if(
mon.find(
"TAP") != string::npos) monMask |= TAP;
170 if(
mon.find(
"TAV") != string::npos) monMask |= TAV;
171 }
172 item->setMonitor( monMask );
173 }
174
175 string priority =
row[
"TI.L1TI_PRIORITY"].data<
string>();
176 if(priority=="0" || priority=="HIGH") {
177 item->setComplexDeadtime(0);
178 } else if(priority=="1" || priority=="LOW") {
179 item->setComplexDeadtime(1);
180 }
181 item->setDefinition (row["TI.L1TI_DEFINITION"].data<string>());
182 item->setTriggerType(row["TI.L1TI_TRIGGER_TYPE"].data<int>());
183 menu.addTriggerItem(item);
185 msg() <<
"MenuLoader: Created Item " << item->name() <<
" with CTPID " << item->ctpId() << endl;
186 item_thrInfo[ctpid] = vector<ThrInfo>();
187 ctpIDs.push_back(ctpid);
188 }
189
191 thr_info.
thrId =
row[
"TI2TT.L1TI2TT_TRIGGER_THRESHOLD_ID"].data<
int>();
192 thr_info.thrPos =
row[
"TI2TT.L1TI2TT_POSITION"].data<
int>();
193 thr_info.thrMult =
row[
"TI2TT.L1TI2TT_MULTIPLICITY"].data<
int>();
194 thr_info.thr =
menu.thresholdConfig().findTriggerThreshold(thr_info.thrId);
195 if(thr_info.thr==0) {
196
197 thr_info.thr = new TriggerThreshold();
198 thr_info.thr->setId(thr_info.thrId);
199 if ( ! ttldr.load( *thr_info.thr ) ) {
200 msg() <<
"MenuLoader: Error loading TriggerThreshold " << thr_info.thrId << endl;
201 throw runtime_error( "MenuLoader::loadItems: error loading TriggerThreshold " );
202 }
203 menu.thresholdConfig().addTriggerThreshold(thr_info.thr);
204 }
205 item_thrInfo[ctpid].push_back(thr_info);
206 }
207
208
209 for(int ctpid : ctpIDs) {
210 TriggerItem* titem =
menu.findTriggerItem( ctpid );
212 msg() <<
"MenuLoader: Number of thresholds for item " << titem->name()
213 << ": " << item_thrInfo[ctpid].size() << " - definition: " << titem->definition() << endl;
214 }
215
216
217
218 std::unique_ptr<TriggerItemNode> topNode (
constructTree(titem->definition(), item_thrInfo[ctpid]));
219 titem->setTopNode( std::move(topNode) );
220 }
221}
virtual int verbose() const override
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
row
Appending html table to final .html summary file.
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)