550 l.hltdata.reserve(250);
551 l.l1data.reserve(192);
552 l.bunchlumivalue.reserve(5);
553 l.bunchlumierror.reserve(5);
554 l.bunchlumiquality.reserve(5);
555 l.beam1intensity.resize(3564,0.0);
556 l.beam2intensity.resize(3564,0.0);
565 throw cms::Exception(
"Non existing service lumi::service::DBService");
569 session->transaction().start(
true);
570 coral::ISchema&
schema=session->nominalSchema();
571 coral::AttributeList lumisummaryBindVariables;
572 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
573 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
574 lumisummaryBindVariables.extend(
"lumidataid",
typeid(
unsigned long long));
576 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
577 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
578 coral::AttributeList lumisummaryOutput;
579 lumisummaryOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
580 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
581 lumisummaryOutput.extend(
"STARTORBIT",
typeid(
unsigned int));
582 lumisummaryOutput.extend(
"NUMORBIT",
typeid(
unsigned int));
583 lumisummaryOutput.extend(
"CMSBXINDEXBLOB",
typeid(coral::Blob));
584 lumisummaryOutput.extend(
"BEAMINTENSITYBLOB_1",
typeid(coral::Blob));
585 lumisummaryOutput.extend(
"BEAMINTENSITYBLOB_2",
typeid(coral::Blob));
586 lumisummaryOutput.extend(
"BXLUMIVALUE_OCC1",
typeid(coral::Blob));
587 lumisummaryOutput.extend(
"BXLUMIVALUE_OCC2",
typeid(coral::Blob));
588 lumisummaryOutput.extend(
"BXLUMIVALUE_ET",
typeid(coral::Blob));
589 coral::IQuery* lumisummaryQuery=schema.newQuery();
591 lumisummaryQuery->addToOutputList(
"CMSLSNUM");
592 lumisummaryQuery->addToOutputList(
"INSTLUMI");
593 lumisummaryQuery->addToOutputList(
"STARTORBIT");
594 lumisummaryQuery->addToOutputList(
"NUMORBIT");
595 lumisummaryQuery->addToOutputList(
"CMSBXINDEXBLOB");
596 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_1");
597 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_2");
598 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_OCC1");
599 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_OCC2");
600 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_ET");
601 lumisummaryQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:lumidataid",lumisummaryBindVariables);
602 lumisummaryQuery->defineOutput(lumisummaryOutput);
603 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
604 unsigned int rowcounter=0;
605 while( lumisummarycursor.next() ){
606 const coral::AttributeList& row=lumisummarycursor.currentRow();
607 unsigned int cmslsnum=row[
"CMSLSNUM"].data<
unsigned int>();
610 lsdata.lumivalue=row[
"INSTLUMI"].data<
float>();
611 lsdata.lumierror=0.0;
612 lsdata.lumiquality=0;
613 lsdata.startorbit=row[
"STARTORBIT"].data<
unsigned int>();
614 lsdata.numorbit=row[
"NUMORBIT"].data<
unsigned int>();
616 if(!row[
"CMSBXINDEXBLOB"].isNull() && !row[
"BXLUMIVALUE_OCC1"].isNull() ){
617 const coral::Blob& bxindexBlob=row[
"CMSBXINDEXBLOB"].data<coral::Blob>();
618 const void* bxindex_StartAddress=bxindexBlob.startingAddress();
619 short* bxindex=(
short*)::malloc(bxindexBlob.size());
620 const coral::Blob& beam1intensityBlob=row[
"BEAMINTENSITYBLOB_1"].data<coral::Blob>();
621 const void* beam1intensityBlob_StartAddress=beam1intensityBlob.startingAddress();
622 float* beam1intensity=(
float*)::malloc(beam1intensityBlob.size());
623 const coral::Blob& beam2intensityBlob=row[
"BEAMINTENSITYBLOB_2"].data<coral::Blob>();
624 const void* beam2intensityBlob_StartAddress=beam2intensityBlob.startingAddress();
625 float* beam2intensity=(
float*)::malloc(beam2intensityBlob.size());
626 std::memmove(bxindex,bxindex_StartAddress,bxindexBlob.size());
627 std::memmove(beam1intensity,beam1intensityBlob_StartAddress,beam1intensityBlob.size());
628 std::memmove(beam2intensity,beam2intensityBlob_StartAddress,beam2intensityBlob.size());
630 unsigned int iMax = bxindexBlob.size()/
sizeof(short);
631 unsigned int lsb1Max = lsdata.beam1intensity.size();
632 unsigned int lsb2Max = lsdata.beam2intensity.size();
633 unsigned int ib1Max = beam1intensityBlob.size()/
sizeof(float);
634 unsigned int ib2Max = beam2intensityBlob.size()/
sizeof(float);
635 for(
unsigned int i=0;
i<iMax;++
i){
636 unsigned int idx=bxindex[
i];
637 if(ib1Max>
i && lsb1Max>idx){
638 lsdata.beam1intensity.at(idx)=beam1intensity[
i];
640 if(ib2Max>
i && lsb2Max>idx){
641 lsdata.beam2intensity.at(idx)=beam2intensity[
i];
645 ::free(beam1intensity);
646 ::free(beam2intensity);
648 const coral::Blob& bxlumivalBlob_occ1=row[
"BXLUMIVALUE_OCC1"].data<coral::Blob>();
649 const void* bxlumival_occ1_StartAddress=bxlumivalBlob_occ1.startingAddress();
650 float* bxlumival_occ1=(
float*)::malloc(bxlumivalBlob_occ1.size());
651 std::memmove(bxlumival_occ1,bxlumival_occ1_StartAddress,bxlumivalBlob_occ1.size());
652 std::vector<float> bxlumivalVec_occ1(bxlumival_occ1,bxlumival_occ1+bxlumivalBlob_occ1.size()/
sizeof(float));
653 ::free(bxlumival_occ1);
654 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"OCC1"),bxlumivalVec_occ1));
655 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"OCC1"),std::vector<float>(3564)));
656 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"OCC1"),std::vector<short>(3564)));
657 const coral::Blob& bxlumivalBlob_occ2=row[
"BXLUMIVALUE_OCC2"].data<coral::Blob>();
658 const void* bxlumival_occ2_StartAddress=bxlumivalBlob_occ2.startingAddress();
659 float* bxlumival_occ2=(
float*)::malloc(bxlumivalBlob_occ2.size());
660 std::memmove(bxlumival_occ2,bxlumival_occ2_StartAddress,bxlumivalBlob_occ2.size());
661 std::vector<float> bxlumivalVec_occ2(bxlumival_occ2,bxlumival_occ2+bxlumivalBlob_occ1.size()/
sizeof(float));
662 ::free(bxlumival_occ2);
663 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"OCC2"),bxlumivalVec_occ2));
664 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"OCC2"),std::vector<float>(3564)));
665 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"OCC2"),std::vector<short>(3564)));
667 const coral::Blob& bxlumivalBlob_et=row[
"BXLUMIVALUE_ET"].data<coral::Blob>();
668 const void* bxlumival_et_StartAddress=bxlumivalBlob_et.startingAddress();
669 float* bxlumival_et=(
float*)::malloc(bxlumivalBlob_et.size());
670 std::memmove(bxlumival_et,bxlumival_et_StartAddress,bxlumivalBlob_et.size());
671 std::vector<float> bxlumivalVec_et(bxlumival_et,bxlumival_et+bxlumivalBlob_et.size()/
sizeof(float));
672 ::free(bxlumival_et);
673 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"ET"),bxlumivalVec_et));
674 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"ET"),std::vector<float>(3564)));
675 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"ET"),std::vector<short>(3564)));
683 delete lumisummaryQuery;
688 coral::AttributeList trgBindVariables;
689 trgBindVariables.extend(
"lsmin",
typeid(
unsigned int));
690 trgBindVariables.extend(
"lsmax",
typeid(
unsigned int));
691 trgBindVariables.extend(
"trgdataid",
typeid(
unsigned long long));
692 trgBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
693 trgBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
695 coral::AttributeList trgOutput;
696 trgOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
697 trgOutput.extend(
"DEADTIMECOUNT",
typeid(
unsigned long long));
698 trgOutput.extend(
"BITZEROCOUNT",
typeid(
unsigned int));
699 trgOutput.extend(
"BITZEROPRESCALE",
typeid(
unsigned int));
700 trgOutput.extend(
"PRESCALEBLOB",
typeid(coral::Blob));
701 trgOutput.extend(
"TRGCOUNTBLOB",
typeid(coral::Blob));
703 coral::IQuery* trgQuery=schema.newQuery();
705 trgQuery->addToOutputList(
"CMSLSNUM");
706 trgQuery->addToOutputList(
"DEADTIMECOUNT");
707 trgQuery->addToOutputList(
"BITZEROCOUNT");
708 trgQuery->addToOutputList(
"BITZEROPRESCALE");
709 trgQuery->addToOutputList(
"PRESCALEBLOB");
710 trgQuery->addToOutputList(
"TRGCOUNTBLOB");
711 trgQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:trgdataid",trgBindVariables);
712 trgQuery->defineOutput(trgOutput);
713 coral::ICursor& trgcursor=trgQuery->execute();
714 while( trgcursor.next() ){
715 const coral::AttributeList& row=trgcursor.currentRow();
716 unsigned int cmslsnum=row[
"CMSLSNUM"].data<
unsigned int>();
718 lsdata.deadcount=row[
"DEADTIMECOUNT"].data<
unsigned long long>();
719 lsdata.bitzerocount=row[
"BITZEROCOUNT"].data<
unsigned int>();
720 lsdata.bitzeroprescale=row[
"BITZEROPRESCALE"].data<
unsigned int>();
721 if(!row[
"PRESCALEBLOB"].isNull()){
722 const coral::Blob& prescaleblob=row[
"PRESCALEBLOB"].data<coral::Blob>();
723 const void* prescaleblob_StartAddress=prescaleblob.startingAddress();
724 unsigned int*
prescales=(
unsigned int*)::malloc(prescaleblob.size());
725 std::memmove(prescales,prescaleblob_StartAddress,prescaleblob.size());
726 const coral::Blob& trgcountblob=row[
"TRGCOUNTBLOB"].data<coral::Blob>();
727 const void* trgcountblob_StartAddress=trgcountblob.startingAddress();
728 unsigned int* trgcounts=(
unsigned int*)::malloc(trgcountblob.size());
729 std::memmove(trgcounts,trgcountblob_StartAddress,trgcountblob.size());
730 for(
unsigned int i=0;
i<
sizeof(trgcounts)/
sizeof(
unsigned int);++
i){
733 l1tmp.prescale=prescales[
i];
734 l1tmp.ratecount=trgcounts[
i];
735 lsdata.l1data.push_back(l1tmp);
745 coral::AttributeList hltBindVariables;
746 hltBindVariables.extend(
"lsmin",
typeid(
unsigned int));
747 hltBindVariables.extend(
"lsmax",
typeid(
unsigned int));
748 hltBindVariables.extend(
"hltdataid",
typeid(
unsigned long long));
749 hltBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
750 hltBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
752 coral::AttributeList hltOutput;
753 hltOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
754 hltOutput.extend(
"HLTCOUNTBLOB",
typeid(coral::Blob));
755 hltOutput.extend(
"HLTACCEPTBLOB",
typeid(coral::Blob));
756 hltOutput.extend(
"PRESCALEBLOB",
typeid(coral::Blob));
757 coral::IQuery* hltQuery=schema.newQuery();
759 hltQuery->addToOutputList(
"CMSLSNUM");
760 hltQuery->addToOutputList(
"HLTCOUNTBLOB");
761 hltQuery->addToOutputList(
"HLTACCEPTBLOB");
762 hltQuery->addToOutputList(
"PRESCALEBLOB");
763 hltQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:hltdataid",hltBindVariables);
764 hltQuery->defineOutput(hltOutput);
765 coral::ICursor& hltcursor=hltQuery->execute();
766 while( hltcursor.next() ){
767 const coral::AttributeList& row=hltcursor.currentRow();
768 unsigned int cmslsnum=row[
"CMSLSNUM"].data<
unsigned int>();
770 if(!row[
"PRESCALEBLOB"].isNull()){
771 const coral::Blob& hltprescaleblob=row[
"PRESCALEBLOB"].data<coral::Blob>();
772 const void* hltprescaleblob_StartAddress=hltprescaleblob.startingAddress();
773 unsigned int* hltprescales=(
unsigned int*)::malloc(hltprescaleblob.size());
774 std::memmove(hltprescales,hltprescaleblob_StartAddress,hltprescaleblob.size());
775 const coral::Blob& hltcountblob=row[
"HLTCOUNTBLOB"].data<coral::Blob>();
776 const void* hltcountblob_StartAddress=hltcountblob.startingAddress();
777 unsigned int* hltcounts=(
unsigned int*)::malloc(hltcountblob.size());
778 std::memmove(hltcounts,hltcountblob_StartAddress,hltcountblob.size());
779 const coral::Blob& hltacceptblob=row[
"HLTACCEPTBLOB"].data<coral::Blob>();
780 const void* hltacceptblob_StartAddress=hltacceptblob.startingAddress();
781 unsigned int* hltaccepts=(
unsigned int*)::malloc(hltacceptblob.size());
782 std::memmove(hltaccepts,hltacceptblob_StartAddress,hltacceptblob.size());
783 unsigned int nhltaccepts =
sizeof(hltaccepts)/
sizeof(
unsigned int);
786 <<
" hltaccepts, but the run chache is empty. hltdata will not be written";
790 for(
unsigned int i=0;
i<
sizeof(hltaccepts)/
sizeof(
unsigned int);++
i){
793 hlttmp.prescale=hltprescales[
i];
794 hlttmp.l1passcount=hltcounts[
i];
795 hlttmp.acceptcount=hltaccepts[
i];
796 lsdata.hltdata.push_back(hlttmp);
798 ::free(hltprescales);
804 session->transaction().commit();
806 session->transaction().rollback();
static const std::string lshltTableName()
unsigned long long m_cachedhltdataid
static const std::string lstrgTableName()
unsigned long long m_cachedtrgdataid
void disconnect(coral::ISessionProxy *session)
unsigned long long m_cachedlumidataid
std::map< unsigned int, PerLSData > m_lscache
std::vector< std::string > TRGBitNames
static const std::string lumisummaryv2TableName()
coral::ISessionProxy * connectReadOnly(const std::string &connectstring)
std::vector< std::string > HLTPathNames