194 throw cms::Exception(
"Non existing service lumi::service::DBService");
197 coral::ITypeConverter& tconverter = session->typeConverter();
201 unsigned int lsmin = 1;
202 unsigned int lsmax = currentlsnum;
204 session->transaction().start(
true);
205 coral::ISchema& schema = session->nominalSchema();
207 if (maxavailableLS != 0 && maxavailableLS < currentlsnum) {
208 lsmax = maxavailableLS;
209 }
else if (maxavailableLS == 0) {
211 session->transaction().commit();
219 std::vector<float> mytmp(3564, 0.0);
220 l.bunchlumivalue.swap(mytmp);
221 std::vector<float> myerrtmp(3564, 0.0);
222 l.bunchlumierror.swap(myerrtmp);
223 std::vector<short> myqtmp(3564, 0);
224 l.bunchlumiquality.swap(myqtmp);
228 coral::AttributeList lumisummaryBindVariables;
229 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
230 lumisummaryBindVariables.extend(
"runnumber",
typeid(
unsigned int));
231 lumisummaryBindVariables[
"runnumber"].data<
unsigned int>() =
m_cachedrun;
232 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>() =
lsmin;
233 std::string conditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin ");
234 coral::AttributeList lumisummaryOutput;
235 lumisummaryOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
236 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
237 lumisummaryOutput.extend(
"DELIVLUMISECTION",
typeid(
float));
238 lumisummaryOutput.extend(
"LIVELUMISECTION",
typeid(
float));
239 lumisummaryOutput.extend(
"STARTORBIT",
typeid(
unsigned long long));
241 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
242 conditionStr = conditionStr +
"AND LUMISECTION<=:lsmax";
243 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>() =
lsmax;
245 coral::IQuery* lumisummaryQuery = schema.newQuery();
246 lumisummaryQuery->addToTableList(
std::string(
"LUMI_SECTIONS"));
247 lumisummaryQuery->addToOutputList(
"LUMISECTION");
248 lumisummaryQuery->addToOutputList(
"INSTLUMI");
249 lumisummaryQuery->addToOutputList(
"DELIVLUMISECTION");
250 lumisummaryQuery->addToOutputList(
"LIVELUMISECTION");
251 lumisummaryQuery->addToOutputList(
"STARTORBIT");
252 lumisummaryQuery->setCondition(conditionStr, lumisummaryBindVariables);
253 lumisummaryQuery->defineOutput(lumisummaryOutput);
254 coral::ICursor& lumisummarycursor = lumisummaryQuery->execute();
255 unsigned int rowcounter = 0;
256 while (lumisummarycursor.next()) {
257 const coral::AttributeList& row = lumisummarycursor.currentRow();
258 unsigned int lsnum = row[
"LUMISECTION"].data<
unsigned int>();
259 float instlumi = 0.0;
260 if (!row[
"INSTLUMI"].isNull()) {
261 instlumi = row[
"INSTLUMI"].data<
float>();
263 float deadfrac = 1.0;
264 float intgdellumi = 0.0;
265 float intgreclumi = 0.0;
266 unsigned long long startorbit = 0;
267 if (!row[
"DELIVLUMISECTION"].isNull()) {
268 intgdellumi = row[
"DELIVLUMISECTION"].data<
float>() * 1000.0;
270 if (!row[
"LIVELUMISECTION"].isNull()) {
271 intgreclumi = row[
"LIVELUMISECTION"].data<
float>() * 1000.0;
273 if (intgdellumi > 0) {
274 deadfrac = 1.0 - intgreclumi / intgdellumi;
276 if (!row[
"STARTORBIT"].isNull()) {
277 startorbit = row[
"STARTORBIT"].data<
unsigned long long>();
279 unsigned long long deadcount = deadfrac * 10000.0;
280 unsigned long long bitzerocount = 10000.0;
282 lsdata.lsnum = lsnum;
283 lsdata.lumivalue = instlumi;
284 lsdata.deadcount = deadcount;
285 lsdata.bitzerocount = bitzerocount;
286 lsdata.startorbit = startorbit;
287 lsdata.numorbit = 262144;
290 if (rowcounter == 0) {
293 delete lumisummaryQuery;
301 coral::AttributeList lumidetailBindVariables;
302 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
303 lumidetailBindVariables.extend(
"runnumber",
typeid(
unsigned int));
304 lumidetailBindVariables[
"runnumber"].data<
unsigned int>() =
m_cachedrun;
305 lumidetailBindVariables[
"lsmin"].data<
unsigned int>() =
lsmin;
306 std::string detailconditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND BUNCHLUMI>0 ");
307 coral::AttributeList lumidetailOutput;
308 lumidetailOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
309 lumidetailOutput.extend(
"BUNCH",
typeid(
unsigned int));
310 lumidetailOutput.extend(
"BUNCHLUMI",
typeid(
float));
312 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
313 detailconditionStr = detailconditionStr +
"AND LUMISECTION<=:lsmax";
314 lumidetailBindVariables[
"lsmax"].data<
unsigned int>() =
lsmax;
316 coral::IQuery* lumidetailQuery = schema.newQuery();
317 lumidetailQuery->addToTableList(
std::string(
"BUNCH_LUMI_SECTIONS"));
318 lumidetailQuery->addToOutputList(
"LUMISECTION");
319 lumidetailQuery->addToOutputList(
"BUNCH");
320 lumidetailQuery->addToOutputList(
"BUNCHLUMI");
321 lumidetailQuery->setCondition(detailconditionStr, lumidetailBindVariables);
322 lumidetailQuery->defineOutput(lumidetailOutput);
323 coral::ICursor& lumidetailcursor = lumidetailQuery->execute();
324 while (lumidetailcursor.next()) {
325 const coral::AttributeList& row = lumidetailcursor.currentRow();
326 unsigned int lsnum = row[
"LUMISECTION"].data<
unsigned int>();
327 unsigned int bxidx = row[
"BUNCH"].data<
unsigned int>();
328 float bxlumi = row[
"BUNCHLUMI"].data<
float>();
329 m_lscache[lsnum].bunchlumivalue[bxidx] = bxlumi;
331 delete lumidetailQuery;
332 session->transaction().commit();
334 session->transaction().rollback();