400 l.hltdata.reserve(250);
401 l.l1data.reserve(192);
402 l.bunchlumivalue.reserve(5);
403 l.bunchlumierror.reserve(5);
404 l.bunchlumiquality.reserve(5);
405 l.beam1intensity.resize(3564,0.0);
406 l.beam2intensity.resize(3564,0.0);
415 throw cms::Exception(
"Non existing service lumi::service::DBService");
419 session->transaction().start(
true);
420 coral::ISchema&
schema=session->nominalSchema();
421 coral::AttributeList lumisummaryBindVariables;
422 lumisummaryBindVariables.extend(
"runnum",
typeid(
unsigned int));
423 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
424 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
426 lumisummaryBindVariables[
"runnum"].data<
unsigned int>()=
m_cachedrun;
427 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
428 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
429 coral::AttributeList lumisummaryOutput;
430 lumisummaryOutput.extend(
"cmslsnum",
typeid(
unsigned int));
431 lumisummaryOutput.extend(
"instlumi",
typeid(
float));
432 lumisummaryOutput.extend(
"instlumierror",
typeid(
float));
433 lumisummaryOutput.extend(
"instlumiquality",
typeid(
short));
434 lumisummaryOutput.extend(
"startorbit",
typeid(
unsigned int));
435 lumisummaryOutput.extend(
"numorbit",
typeid(
unsigned int));
436 lumisummaryOutput.extend(
"bxindexBlob",
typeid(coral::Blob));
437 lumisummaryOutput.extend(
"beam1intensityBlob",
typeid(coral::Blob));
438 lumisummaryOutput.extend(
"beam2intensityBlob",
typeid(coral::Blob));
440 coral::IQuery* lumisummaryQuery=schema.newQuery();
442 lumisummaryQuery->addToOutputList(
"CMSLSNUM",
"cmslsnum");
443 lumisummaryQuery->addToOutputList(
"INSTLUMI",
"instlumi");
444 lumisummaryQuery->addToOutputList(
"INSTLUMIERROR",
"instlumierror");
445 lumisummaryQuery->addToOutputList(
"INSTLUMIQUALITY",
"instlumiquality");
446 lumisummaryQuery->addToOutputList(
"STARTORBIT",
"startorbit");
447 lumisummaryQuery->addToOutputList(
"NUMORBIT",
"numorbit");
448 lumisummaryQuery->addToOutputList(
"CMSBXINDEXBLOB",
"bxindexBlob");
449 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_1",
"beam1intensityBlob");
450 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_2",
"beam2intensityBlob");
451 lumisummaryQuery->setCondition(
"RUNNUM=:runnum AND CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax",lumisummaryBindVariables);
452 lumisummaryQuery->defineOutput(lumisummaryOutput);
453 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
454 unsigned int rowcounter=0;
455 while( lumisummarycursor.next() ){
456 const coral::AttributeList& row=lumisummarycursor.currentRow();
457 unsigned int cmslsnum=row[
"cmslsnum"].data<
unsigned int>();
460 lsdata.lumivalue=row[
"instlumi"].data<
float>();
461 lsdata.lumierror=row[
"instlumierror"].data<
float>();
462 lsdata.lumiquality=row[
"instlumiquality"].data<
short>();
463 lsdata.startorbit=row[
"startorbit"].data<
unsigned int>();
464 lsdata.numorbit=row[
"numorbit"].data<
unsigned int>();
466 if(!row[
"bxindexBlob"].isNull()){
467 const coral::Blob& bxindexBlob=row[
"bxindexBlob"].data<coral::Blob>();
468 const void* bxindex_StartAddress=bxindexBlob.startingAddress();
469 short* bxindex=(
short*)::malloc(bxindexBlob.size());
470 const coral::Blob& beam1intensityBlob=row[
"beam1intensityBlob"].data<coral::Blob>();
471 const void* beam1intensityBlob_StartAddress=beam1intensityBlob.startingAddress();
472 float* beam1intensity=(
float*)::malloc(beam1intensityBlob.size());
473 const coral::Blob& beam2intensityBlob=row[
"beam2intensityBlob"].data<coral::Blob>();
474 const void* beam2intensityBlob_StartAddress=beam2intensityBlob.startingAddress();
475 float* beam2intensity=(
float*)::malloc(beam2intensityBlob.size());
476 std::memmove(bxindex,bxindex_StartAddress,bxindexBlob.size());
477 std::memmove(beam1intensity,beam1intensityBlob_StartAddress,beam1intensityBlob.size());
478 std::memmove(beam2intensity,beam2intensityBlob_StartAddress,beam2intensityBlob.size());
480 for(
unsigned int i=0;
i<bxindexBlob.size()/
sizeof(short);++
i){
481 unsigned int idx=bxindex[
i];
482 lsdata.beam1intensity.at(idx)=beam1intensity[
i];
483 lsdata.beam2intensity.at(idx)=beam2intensity[
i];
487 ::free(beam1intensity);
488 ::free(beam2intensity);
496 delete lumisummaryQuery;
501 coral::AttributeList lumidetailBindVariables;
502 lumidetailBindVariables.extend(
"runnum",
typeid(
unsigned int));
503 lumidetailBindVariables.extend(
"lsmin",
typeid(
unsigned int));
504 lumidetailBindVariables.extend(
"lsmax",
typeid(
unsigned int));
506 lumidetailBindVariables[
"runnum"].data<
unsigned int>()=
m_cachedrun;
507 lumidetailBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
508 lumidetailBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
509 coral::AttributeList lumidetailOutput;
511 lumidetailOutput.extend(
"cmslsnum",
typeid(
unsigned int));
512 lumidetailOutput.extend(
"bxlumivalue",
typeid(coral::Blob));
513 lumidetailOutput.extend(
"bxlumierror",
typeid(coral::Blob));
514 lumidetailOutput.extend(
"bxlumiquality",
typeid(coral::Blob));
515 lumidetailOutput.extend(
"algoname",
typeid(std::string));
517 coral::IQuery* lumidetailQuery=schema.newQuery();
528 lumidetailQuery->defineOutput(lumidetailOutput);
529 coral::ICursor& lumidetailcursor=lumidetailQuery->execute();
530 while( lumidetailcursor.next() ){
531 const coral::AttributeList& row=lumidetailcursor.currentRow();
532 unsigned int cmslsnum=row[
"cmslsnum"].data<
unsigned int>();
533 std::string algoname=row[
"algoname"].data<std::string>();
536 if( !row[
"bxlumivalue"].isNull() && !row[
"bxlumierror"].isNull() && !row[
"bxlumiquality"].isNull() ){
537 const coral::Blob& bxlumivalueBlob=row[
"bxlumivalue"].data<coral::Blob>();
538 const coral::Blob& bxlumierrorBlob=row[
"bxlumierror"].data<coral::Blob>();
539 const coral::Blob& bxlumiqualityBlob=row[
"bxlumiquality"].data<coral::Blob>();
540 const void* bxlumivalueBlob_StartAddress=bxlumivalueBlob.startingAddress();
541 const void* bxlumierrorBlob_StartAddress=bxlumierrorBlob.startingAddress();
542 const void* bxlumiqualityBlob_StartAddress=bxlumiqualityBlob.startingAddress();
543 float* bxlumivalue=(
float*)::malloc(bxlumivalueBlob.size());
544 float* bxlumierror=(
float*)::malloc(bxlumierrorBlob.size());
545 short* bxlumiquality=(
short*)::malloc(bxlumiqualityBlob.size());
546 std::memmove(bxlumivalue,bxlumivalueBlob_StartAddress,bxlumivalueBlob.size());
547 std::memmove(bxlumierror,bxlumierrorBlob_StartAddress,bxlumierrorBlob.size());
548 std::memmove(bxlumiquality,bxlumiqualityBlob_StartAddress,bxlumiqualityBlob.size());
549 std::vector<float> bxlumivalueVec(bxlumivalue,bxlumivalue+bxlumivalueBlob.size()/
sizeof(float));
551 lsdata.bunchlumivalue.push_back(std::make_pair(algoname,bxlumivalueVec));
552 std::vector<float> bxlumierrorVec(bxlumierror,bxlumierror+bxlumierrorBlob.size()/
sizeof(float));
554 lsdata.bunchlumierror.push_back(std::make_pair(algoname,bxlumierrorVec));
555 std::vector<short> bxlumiqualityVec(bxlumiquality,bxlumiquality+bxlumiqualityBlob.size()/
sizeof(short));
556 lsdata.bunchlumiquality.push_back(std::make_pair(algoname,bxlumiqualityVec));
557 ::free(bxlumiquality);
560 delete lumidetailQuery;
564 coral::AttributeList trgBindVariables;
565 trgBindVariables.extend(
"runnum",
typeid(
unsigned int));
566 trgBindVariables.extend(
"lsmin",
typeid(
unsigned int));
567 trgBindVariables.extend(
"lsmax",
typeid(
unsigned int));
568 trgBindVariables[
"runnum"].data<
unsigned int>()=
m_cachedrun;
569 trgBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
570 trgBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
571 coral::AttributeList trgOutput;
572 trgOutput.extend(
"cmslsnum",
typeid(
unsigned int));
573 trgOutput.extend(
"bitnum",
typeid(
unsigned int));
574 trgOutput.extend(
"deadtime",
typeid(
unsigned long long));
575 trgOutput.extend(
"prescale",
typeid(
unsigned int));
576 trgOutput.extend(
"trgcount",
typeid(
unsigned int));
578 coral::IQuery* trgQuery=schema.newQuery();
580 trgQuery->addToOutputList(
"CMSLSNUM",
"cmslsnum");
581 trgQuery->addToOutputList(
"BITNUM",
"bitnum");
582 trgQuery->addToOutputList(
"DEADTIME",
"deadtime");
583 trgQuery->addToOutputList(
"PRESCALE",
"prescale");
584 trgQuery->addToOutputList(
"TRGCOUNT",
"trgcount");
585 trgQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND RUNNUM=:runnum ",trgBindVariables);
586 trgQuery->addToOrderList(
"CMSLSNUM");
587 trgQuery->addToOrderList(
"BITNUM");
588 trgQuery->defineOutput(trgOutput);
589 coral::ICursor& trgcursor=trgQuery->execute();
590 while( trgcursor.next() ){
591 const coral::AttributeList& row=trgcursor.currentRow();
592 unsigned int cmslsnum=row[
"cmslsnum"].data<
unsigned int>();
594 lsdata.deadcount=row[
"deadtime"].data<
unsigned long long>();
596 l1tmp.bitnum=row[
"bitnum"].data<
unsigned int>();
597 l1tmp.prescale=row[
"prescale"].data<
unsigned int>();
598 l1tmp.ratecount=row[
"trgcount"].data<
unsigned int>();
599 lsdata.l1data.push_back(l1tmp);
605 coral::AttributeList hltBindVariables;
606 hltBindVariables.extend(
"runnum",
typeid(
unsigned int));
607 hltBindVariables.extend(
"lsmin",
typeid(
unsigned int));
608 hltBindVariables.extend(
"lsmax",
typeid(
unsigned int));
609 hltBindVariables[
"runnum"].data<
unsigned int>()=
m_cachedrun;
610 hltBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
611 hltBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
612 coral::AttributeList hltOutput;
613 hltOutput.extend(
"cmslsnum",
typeid(
unsigned int));
614 hltOutput.extend(
"inputcount",
typeid(
unsigned int));
615 hltOutput.extend(
"acceptcount",
typeid(
unsigned int));
616 hltOutput.extend(
"prescale",
typeid(
unsigned int));
617 coral::IQuery* hltQuery=schema.newQuery();
619 hltQuery->addToOutputList(
"CMSLSNUM",
"cmslsnum");
620 hltQuery->addToOutputList(
"INPUTCOUNT",
"inputcount");
621 hltQuery->addToOutputList(
"ACCEPTCOUNT",
"acceptcount");
622 hltQuery->addToOutputList(
"PRESCALE",
"prescale");
623 hltQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND RUNNUM=:runnum",hltBindVariables);
624 hltQuery->addToOrderList(
"CMSLSNUM");
625 hltQuery->addToOrderList(
"PATHNAME");
626 hltQuery->defineOutput(hltOutput);
627 coral::ICursor& hltcursor=hltQuery->execute();
629 unsigned int pathcount=0;
630 while( hltcursor.next() ){
631 const coral::AttributeList& row=hltcursor.currentRow();
632 unsigned int cmslsnum=row[
"cmslsnum"].data<
unsigned int>();
635 hlttmp.pathnum=pathcount;
636 hlttmp.prescale=row[
"prescale"].data<
unsigned int>();
637 hlttmp.l1passcount=row[
"inputcount"].data<
unsigned int>();
638 hlttmp.acceptcount=row[
"acceptcount"].data<
unsigned int>();
639 lsdata.hltdata.push_back(hlttmp);
640 if(pathcount!=npaths){
647 session->transaction().commit();
649 session->transaction().rollback();
static const std::string trgTableName()
std::map< unsigned int, std::string > HLTPathNames
static const std::string lumisummaryTableName()
void disconnect(coral::ISessionProxy *session)
static const std::string hltTableName()
std::map< unsigned int, PerLSData > m_lscache
static const std::string lumidetailTableName()
coral::ISessionProxy * connectReadOnly(const std::string &connectstring)