204 throw cms::Exception(
"Non existing service lumi::service::DBService");
207 coral::ITypeConverter& tconverter=
session->typeConverter();
211 unsigned int lsmin=1;
212 unsigned int lsmax=currentlsnum;
214 session->transaction().start(
true);
217 if(maxavailableLS!=0 && maxavailableLS<currentlsnum){
218 lsmax=maxavailableLS;
219 }
else if(maxavailableLS==0){
221 session->transaction().commit();
227 for(
unsigned int n=lsmin;
n<=lsmax;++
n){
229 std::vector<float> mytmp(3564,0.0);
230 l.bunchlumivalue.swap(mytmp);
231 std::vector<float> myerrtmp(3564,0.0);
232 l.bunchlumierror.swap(myerrtmp);
233 std::vector<short> myqtmp(3564,0);
234 l.bunchlumiquality.swap(myqtmp);
238 coral::AttributeList lumisummaryBindVariables;
239 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
240 lumisummaryBindVariables.extend(
"runnumber",
typeid(
unsigned int));
241 lumisummaryBindVariables[
"runnumber"].data<
unsigned int>()=
m_cachedrun;
242 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
243 std::string conditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin ");
244 coral::AttributeList lumisummaryOutput;
245 lumisummaryOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
246 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
247 lumisummaryOutput.extend(
"DELIVLUMISECTION",
typeid(
float));
248 lumisummaryOutput.extend(
"LIVELUMISECTION",
typeid(
float));
249 lumisummaryOutput.extend(
"STARTORBIT",
typeid(
unsigned long long));
251 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
252 conditionStr=conditionStr+
"AND LUMISECTION<=:lsmax";
253 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
255 coral::IQuery* lumisummaryQuery=schema.newQuery();
256 lumisummaryQuery->addToTableList(
std::string(
"LUMI_SECTIONS"));
257 lumisummaryQuery->addToOutputList(
"LUMISECTION");
258 lumisummaryQuery->addToOutputList(
"INSTLUMI");
259 lumisummaryQuery->addToOutputList(
"DELIVLUMISECTION");
260 lumisummaryQuery->addToOutputList(
"LIVELUMISECTION");
261 lumisummaryQuery->addToOutputList(
"STARTORBIT");
262 lumisummaryQuery->setCondition(conditionStr,lumisummaryBindVariables);
263 lumisummaryQuery->defineOutput(lumisummaryOutput);
264 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
265 unsigned int rowcounter=0;
266 while( lumisummarycursor.next() ){
267 const coral::AttributeList& row=lumisummarycursor.currentRow();
268 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
270 if(!row[
"INSTLUMI"].isNull()){
271 instlumi=row[
"INSTLUMI"].data<
float>();
274 float intgdellumi=0.0;
275 float intgreclumi=0.0;
276 unsigned long long startorbit=0;
277 if(!row[
"DELIVLUMISECTION"].isNull()){
278 intgdellumi=row[
"DELIVLUMISECTION"].data<
float>()*1000.0;
280 if(!row[
"LIVELUMISECTION"].isNull()){
281 intgreclumi=row[
"LIVELUMISECTION"].data<
float>()*1000.0;
284 deadfrac=1.0-intgreclumi/intgdellumi;
286 if(!row[
"STARTORBIT"].isNull()){
287 startorbit=row[
"STARTORBIT"].data<
unsigned long long>();
289 unsigned long long deadcount=deadfrac*10000.0;
290 unsigned long long bitzerocount=10000.0;
293 lsdata.lumivalue=instlumi;
294 lsdata.deadcount=deadcount;
295 lsdata.bitzerocount=bitzerocount;
296 lsdata.startorbit=startorbit;
297 lsdata.numorbit=262144;
303 delete lumisummaryQuery;
310 coral::AttributeList lumidetailBindVariables;
311 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
312 lumidetailBindVariables.extend(
"runnumber",
typeid(
unsigned int));
313 lumidetailBindVariables[
"runnumber"].data<
unsigned int>()=
m_cachedrun;
314 lumidetailBindVariables[
"lsmin"].data<
unsigned int>()=lsmin;
315 std::string detailconditionStr(
" RUNNUMBER=:runnumber AND LUMISECTION>=:lsmin AND BUNCHLUMI>0 ");
316 coral::AttributeList lumidetailOutput;
317 lumidetailOutput.extend(
"LUMISECTION",
typeid(
unsigned int));
318 lumidetailOutput.extend(
"BUNCH",
typeid(
unsigned int));
319 lumidetailOutput.extend(
"BUNCHLUMI",
typeid(
float));
321 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
322 detailconditionStr=detailconditionStr+
"AND LUMISECTION<=:lsmax";
323 lumidetailBindVariables[
"lsmax"].data<
unsigned int>()=lsmax;
325 coral::IQuery* lumidetailQuery=schema.newQuery();
326 lumidetailQuery->addToTableList(
std::string(
"BUNCH_LUMI_SECTIONS"));
327 lumidetailQuery->addToOutputList(
"LUMISECTION");
328 lumidetailQuery->addToOutputList(
"BUNCH");
329 lumidetailQuery->addToOutputList(
"BUNCHLUMI");
330 lumidetailQuery->setCondition(detailconditionStr,lumidetailBindVariables);
331 lumidetailQuery->defineOutput(lumidetailOutput);
332 coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
333 while( lumidetailcursor.next() ){
334 const coral::AttributeList& row=lumidetailcursor.currentRow();
335 unsigned int lsnum=row[
"LUMISECTION"].data<
unsigned int>();
336 unsigned int bxidx=row[
"BUNCH"].data<
unsigned int>();
337 float bxlumi=row[
"BUNCHLUMI"].data<
float>();
338 m_lscache[lsnum].bunchlumivalue[bxidx]=bxlumi;
340 delete lumidetailQuery;
341 session->transaction().commit();
343 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)