205 throw cms::Exception(
"Non existing service lumi::service::DBService");
208 coral::ITypeConverter& tconverter=
session->typeConverter();
212 unsigned int lsmin=1;
213 unsigned int lsmax=currentlsnum;
215 session->transaction().start(
true);
218 if(maxavailableLS!=0 && maxavailableLS<currentlsnum){
219 lsmax=maxavailableLS;
220 }
else if(maxavailableLS==0){
222 session->transaction().commit();
228 for(
unsigned int n=lsmin;
n<=lsmax;++
n){
230 std::vector<float> mytmp(3564,0.0);
231 l.bunchlumivalue.swap(mytmp);
232 std::vector<float> myerrtmp(3564,0.0);
233 l.bunchlumierror.swap(myerrtmp);
234 std::vector<short> myqtmp(3564,0);
235 l.bunchlumiquality.swap(myqtmp);
239 coral::AttributeList lumisummaryBindVariables;
240 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
241 lumisummaryBindVariables.extend(
"runnumber",
typeid(
unsigned int));
242 lumisummaryBindVariables[
"runnumber"].data<
unsigned int>()=
m_cachedrun;
243 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
244 std::string conditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin ");
245 coral::AttributeList lumisummaryOutput;
246 lumisummaryOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
247 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
248 lumisummaryOutput.extend(
"DELIVLUMISECTION",
typeid(
float));
249 lumisummaryOutput.extend(
"LIVELUMISECTION",
typeid(
float));
250 lumisummaryOutput.extend(
"STARTORBIT",
typeid(
unsigned long long));
252 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
253 conditionStr=conditionStr+
"AND LUMISECTION<=:lsmax";
254 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
256 coral::IQuery* lumisummaryQuery=schema.newQuery();
257 lumisummaryQuery->addToTableList(
std::string(
"LUMI_SECTIONS"));
258 lumisummaryQuery->addToOutputList(
"LUMISECTION");
259 lumisummaryQuery->addToOutputList(
"INSTLUMI");
260 lumisummaryQuery->addToOutputList(
"DELIVLUMISECTION");
261 lumisummaryQuery->addToOutputList(
"LIVELUMISECTION");
262 lumisummaryQuery->addToOutputList(
"STARTORBIT");
263 lumisummaryQuery->setCondition(conditionStr,lumisummaryBindVariables);
264 lumisummaryQuery->defineOutput(lumisummaryOutput);
265 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
266 unsigned int rowcounter=0;
267 while( lumisummarycursor.next() ){
268 const coral::AttributeList& row=lumisummarycursor.currentRow();
269 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
271 if(!row[
"INSTLUMI"].isNull()){
272 instlumi=row[
"INSTLUMI"].data<
float>();
275 float intgdellumi=0.0;
276 float intgreclumi=0.0;
277 unsigned long long startorbit=0;
278 if(!row[
"DELIVLUMISECTION"].isNull()){
279 intgdellumi=row[
"DELIVLUMISECTION"].data<
float>()*1000.0;
281 if(!row[
"LIVELUMISECTION"].isNull()){
282 intgreclumi=row[
"LIVELUMISECTION"].data<
float>()*1000.0;
285 deadfrac=1.0-intgreclumi/intgdellumi;
287 if(!row[
"STARTORBIT"].isNull()){
288 startorbit=row[
"STARTORBIT"].data<
unsigned long long>();
290 unsigned long long deadcount=deadfrac*10000.0;
291 unsigned long long bitzerocount=10000.0;
294 lsdata.lumivalue=instlumi;
295 lsdata.deadcount=deadcount;
296 lsdata.bitzerocount=bitzerocount;
297 lsdata.startorbit=startorbit;
298 lsdata.numorbit=262144;
304 delete lumisummaryQuery;
311 coral::AttributeList lumidetailBindVariables;
312 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
313 lumidetailBindVariables.extend(
"runnumber",
typeid(
unsigned int));
314 lumidetailBindVariables[
"runnumber"].data<
unsigned int>()=
m_cachedrun;
315 lumidetailBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
316 std::string detailconditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND BUNCHLUMI>0 ");
317 coral::AttributeList lumidetailOutput;
318 lumidetailOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
319 lumidetailOutput.extend(
"BUNCH",
typeid(
unsigned int));
320 lumidetailOutput.extend(
"BUNCHLUMI",
typeid(
float));
322 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
323 detailconditionStr=detailconditionStr+
"AND LUMISECTION<=:lsmax";
324 lumidetailBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
326 coral::IQuery* lumidetailQuery=schema.newQuery();
327 lumidetailQuery->addToTableList(
std::string(
"BUNCH_LUMI_SECTIONS"));
328 lumidetailQuery->addToOutputList(
"LUMISECTION");
329 lumidetailQuery->addToOutputList(
"BUNCH");
330 lumidetailQuery->addToOutputList(
"BUNCHLUMI");
331 lumidetailQuery->setCondition(detailconditionStr,lumidetailBindVariables);
332 lumidetailQuery->defineOutput(lumidetailOutput);
333 coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
334 while( lumidetailcursor.next() ){
335 const coral::AttributeList& row=lumidetailcursor.currentRow();
336 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
337 unsigned int bxidx=row[
"BUNCH"].data<
unsigned int>();
338 float bxlumi=row[
"BUNCHLUMI"].data<
float>();
339 m_lscache[lsnum].bunchlumivalue[bxidx]=bxlumi;
341 delete lumidetailQuery;
342 session->transaction().commit();
344 session->transaction().rollback();
ISessionProxyPtr connectReadOnly(const std::string &connectstring)
std::map< unsigned int, PerLSData > m_lscache
unsigned int maxavailableLSforRun(coral::ISchema &schema, const std::string &tablename, unsigned int runnumber)