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