556 l.hltdata.reserve(250);
557 l.l1data.reserve(192);
558 l.bunchlumivalue.reserve(5);
559 l.bunchlumierror.reserve(5);
560 l.bunchlumiquality.reserve(5);
561 l.beam1intensity.resize(3564,0.0);
562 l.beam2intensity.resize(3564,0.0);
571 throw cms::Exception(
"Non existing service lumi::service::DBService");
575 session->transaction().start(
true);
576 coral::ISchema&
schema=session->nominalSchema();
577 coral::AttributeList lumisummaryBindVariables;
578 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
579 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
580 lumisummaryBindVariables.extend(
"lumidataid",
typeid(
unsigned long long));
582 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
583 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
584 coral::AttributeList lumisummaryOutput;
585 lumisummaryOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
586 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
587 lumisummaryOutput.extend(
"STARTORBIT",
typeid(
unsigned int));
588 lumisummaryOutput.extend(
"NUMORBIT",
typeid(
unsigned int));
589 lumisummaryOutput.extend(
"CMSBXINDEXBLOB",
typeid(coral::Blob));
590 lumisummaryOutput.extend(
"BEAMINTENSITYBLOB_1",
typeid(coral::Blob));
591 lumisummaryOutput.extend(
"BEAMINTENSITYBLOB_2",
typeid(coral::Blob));
592 lumisummaryOutput.extend(
"BXLUMIVALUE_OCC1",
typeid(coral::Blob));
593 lumisummaryOutput.extend(
"BXLUMIVALUE_OCC2",
typeid(coral::Blob));
594 lumisummaryOutput.extend(
"BXLUMIVALUE_ET",
typeid(coral::Blob));
595 coral::IQuery* lumisummaryQuery=schema.newQuery();
597 lumisummaryQuery->addToOutputList(
"CMSLSNUM");
598 lumisummaryQuery->addToOutputList(
"INSTLUMI");
599 lumisummaryQuery->addToOutputList(
"STARTORBIT");
600 lumisummaryQuery->addToOutputList(
"NUMORBIT");
601 lumisummaryQuery->addToOutputList(
"CMSBXINDEXBLOB");
602 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_1");
603 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_2");
604 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_OCC1");
605 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_OCC2");
606 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_ET");
607 lumisummaryQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:lumidataid",lumisummaryBindVariables);
608 lumisummaryQuery->defineOutput(lumisummaryOutput);
609 coral::ICursor& lumisummarycursor=lumisummaryQuery->execute();
610 unsigned int rowcounter=0;
611 while( lumisummarycursor.next() ){
612 const coral::AttributeList& row=lumisummarycursor.currentRow();
613 unsigned int cmslsnum=row[
"CMSLSNUM"].data<
unsigned int>();
616 lsdata.lumivalue=row[
"INSTLUMI"].data<
float>();
617 lsdata.lumierror=0.0;
618 lsdata.lumiquality=0;
619 lsdata.startorbit=row[
"STARTORBIT"].data<
unsigned int>();
620 lsdata.numorbit=row[
"NUMORBIT"].data<
unsigned int>();
622 if(!row[
"CMSBXINDEXBLOB"].isNull() && !row[
"BXLUMIVALUE_OCC1"].isNull() ){
623 const coral::Blob& bxindexBlob=row[
"CMSBXINDEXBLOB"].data<coral::Blob>();
624 const void* bxindex_StartAddress=bxindexBlob.startingAddress();
625 short* bxindex=(
short*)::malloc(bxindexBlob.size());
626 const coral::Blob& beam1intensityBlob=row[
"BEAMINTENSITYBLOB_1"].data<coral::Blob>();
627 const void* beam1intensityBlob_StartAddress=beam1intensityBlob.startingAddress();
628 float* beam1intensity=(
float*)::malloc(beam1intensityBlob.size());
629 const coral::Blob& beam2intensityBlob=row[
"BEAMINTENSITYBLOB_2"].data<coral::Blob>();
630 const void* beam2intensityBlob_StartAddress=beam2intensityBlob.startingAddress();
631 float* beam2intensity=(
float*)::malloc(beam2intensityBlob.size());
632 std::memmove(bxindex,bxindex_StartAddress,bxindexBlob.size());
633 std::memmove(beam1intensity,beam1intensityBlob_StartAddress,beam1intensityBlob.size());
634 std::memmove(beam2intensity,beam2intensityBlob_StartAddress,beam2intensityBlob.size());
636 unsigned int iMax = bxindexBlob.size()/
sizeof(short);
637 unsigned int lsb1Max = lsdata.beam1intensity.size();
638 unsigned int lsb2Max = lsdata.beam2intensity.size();
639 unsigned int ib1Max = beam1intensityBlob.size()/
sizeof(float);
640 unsigned int ib2Max = beam2intensityBlob.size()/
sizeof(float);
641 for(
unsigned int i=0;
i<iMax;++
i){
642 unsigned int idx=bxindex[
i];
643 if(ib1Max>
i && lsb1Max>idx){
644 lsdata.beam1intensity.at(idx)=beam1intensity[
i];
646 if(ib2Max>
i && lsb2Max>idx){
647 lsdata.beam2intensity.at(idx)=beam2intensity[
i];
651 ::free(beam1intensity);
652 ::free(beam2intensity);
654 const coral::Blob& bxlumivalBlob_occ1=row[
"BXLUMIVALUE_OCC1"].data<coral::Blob>();
655 const void* bxlumival_occ1_StartAddress=bxlumivalBlob_occ1.startingAddress();
656 float* bxlumival_occ1=(
float*)::malloc(bxlumivalBlob_occ1.size());
657 std::memmove(bxlumival_occ1,bxlumival_occ1_StartAddress,bxlumivalBlob_occ1.size());
658 std::vector<float> bxlumivalVec_occ1(bxlumival_occ1,bxlumival_occ1+bxlumivalBlob_occ1.size()/
sizeof(float));
659 ::free(bxlumival_occ1);
660 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"OCC1"),bxlumivalVec_occ1));
661 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"OCC1"),std::vector<float>(3564)));
662 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"OCC1"),std::vector<short>(3564)));
663 const coral::Blob& bxlumivalBlob_occ2=row[
"BXLUMIVALUE_OCC2"].data<coral::Blob>();
664 const void* bxlumival_occ2_StartAddress=bxlumivalBlob_occ2.startingAddress();
665 float* bxlumival_occ2=(
float*)::malloc(bxlumivalBlob_occ2.size());
666 std::memmove(bxlumival_occ2,bxlumival_occ2_StartAddress,bxlumivalBlob_occ2.size());
667 std::vector<float> bxlumivalVec_occ2(bxlumival_occ2,bxlumival_occ2+bxlumivalBlob_occ1.size()/
sizeof(float));
668 ::free(bxlumival_occ2);
669 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"OCC2"),bxlumivalVec_occ2));
670 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"OCC2"),std::vector<float>(3564)));
671 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"OCC2"),std::vector<short>(3564)));
673 const coral::Blob& bxlumivalBlob_et=row[
"BXLUMIVALUE_ET"].data<coral::Blob>();
674 const void* bxlumival_et_StartAddress=bxlumivalBlob_et.startingAddress();
675 float* bxlumival_et=(
float*)::malloc(bxlumivalBlob_et.size());
676 std::memmove(bxlumival_et,bxlumival_et_StartAddress,bxlumivalBlob_et.size());
677 std::vector<float> bxlumivalVec_et(bxlumival_et,bxlumival_et+bxlumivalBlob_et.size()/
sizeof(float));
678 ::free(bxlumival_et);
679 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"ET"),bxlumivalVec_et));
680 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"ET"),std::vector<float>(3564)));
681 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"ET"),std::vector<short>(3564)));
689 delete lumisummaryQuery;
694 coral::AttributeList trgBindVariables;
695 trgBindVariables.extend(
"lsmin",
typeid(
unsigned int));
696 trgBindVariables.extend(
"lsmax",
typeid(
unsigned int));
697 trgBindVariables.extend(
"trgdataid",
typeid(
unsigned long long));
698 trgBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
699 trgBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
701 coral::AttributeList trgOutput;
702 trgOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
703 trgOutput.extend(
"DEADTIMECOUNT",
typeid(
unsigned long long));
704 trgOutput.extend(
"BITZEROCOUNT",
typeid(
unsigned int));
705 trgOutput.extend(
"BITZEROPRESCALE",
typeid(
unsigned int));
706 trgOutput.extend(
"PRESCALEBLOB",
typeid(coral::Blob));
707 trgOutput.extend(
"TRGCOUNTBLOB",
typeid(coral::Blob));
709 coral::IQuery* trgQuery=schema.newQuery();
711 trgQuery->addToOutputList(
"CMSLSNUM");
712 trgQuery->addToOutputList(
"DEADTIMECOUNT");
713 trgQuery->addToOutputList(
"BITZEROCOUNT");
714 trgQuery->addToOutputList(
"BITZEROPRESCALE");
715 trgQuery->addToOutputList(
"PRESCALEBLOB");
716 trgQuery->addToOutputList(
"TRGCOUNTBLOB");
717 trgQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:trgdataid",trgBindVariables);
718 trgQuery->defineOutput(trgOutput);
719 coral::ICursor& trgcursor=trgQuery->execute();
720 while( trgcursor.next() ){
721 const coral::AttributeList& row=trgcursor.currentRow();
722 unsigned int cmslsnum=row[
"CMSLSNUM"].data<
unsigned int>();
724 lsdata.deadcount=row[
"DEADTIMECOUNT"].data<
unsigned long long>();
725 lsdata.bitzerocount=row[
"BITZEROCOUNT"].data<
unsigned int>();
726 lsdata.bitzeroprescale=row[
"BITZEROPRESCALE"].data<
unsigned int>();
727 if(!row[
"PRESCALEBLOB"].isNull()){
728 const coral::Blob& prescaleblob=row[
"PRESCALEBLOB"].data<coral::Blob>();
729 const void* prescaleblob_StartAddress=prescaleblob.startingAddress();
730 unsigned int*
prescales=(
unsigned int*)::malloc(prescaleblob.size());
731 std::memmove(prescales,prescaleblob_StartAddress,prescaleblob.size());
732 const coral::Blob& trgcountblob=row[
"TRGCOUNTBLOB"].data<coral::Blob>();
733 const void* trgcountblob_StartAddress=trgcountblob.startingAddress();
734 unsigned int* trgcounts=(
unsigned int*)::malloc(trgcountblob.size());
735 std::memmove(trgcounts,trgcountblob_StartAddress,trgcountblob.size());
736 for(
unsigned int i=0;
i<
sizeof(trgcounts)/
sizeof(
unsigned int);++
i){
739 l1tmp.prescale=prescales[
i];
740 l1tmp.ratecount=trgcounts[
i];
741 lsdata.l1data.push_back(l1tmp);
751 coral::AttributeList hltBindVariables;
752 hltBindVariables.extend(
"lsmin",
typeid(
unsigned int));
753 hltBindVariables.extend(
"lsmax",
typeid(
unsigned int));
754 hltBindVariables.extend(
"hltdataid",
typeid(
unsigned long long));
755 hltBindVariables[
"lsmin"].data<
unsigned int>()=luminum;
756 hltBindVariables[
"lsmax"].data<
unsigned int>()=luminum+m_cachesize;
758 coral::AttributeList hltOutput;
759 hltOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
760 hltOutput.extend(
"HLTCOUNTBLOB",
typeid(coral::Blob));
761 hltOutput.extend(
"HLTACCEPTBLOB",
typeid(coral::Blob));
762 hltOutput.extend(
"PRESCALEBLOB",
typeid(coral::Blob));
763 coral::IQuery* hltQuery=schema.newQuery();
765 hltQuery->addToOutputList(
"CMSLSNUM");
766 hltQuery->addToOutputList(
"HLTCOUNTBLOB");
767 hltQuery->addToOutputList(
"HLTACCEPTBLOB");
768 hltQuery->addToOutputList(
"PRESCALEBLOB");
769 hltQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:hltdataid",hltBindVariables);
770 hltQuery->defineOutput(hltOutput);
771 coral::ICursor& hltcursor=hltQuery->execute();
772 while( hltcursor.next() ){
773 const coral::AttributeList& row=hltcursor.currentRow();
774 unsigned int cmslsnum=row[
"CMSLSNUM"].data<
unsigned int>();
776 if(!row[
"PRESCALEBLOB"].isNull()){
777 const coral::Blob& hltprescaleblob=row[
"PRESCALEBLOB"].data<coral::Blob>();
778 const void* hltprescaleblob_StartAddress=hltprescaleblob.startingAddress();
779 unsigned int* hltprescales=(
unsigned int*)::malloc(hltprescaleblob.size());
780 std::memmove(hltprescales,hltprescaleblob_StartAddress,hltprescaleblob.size());
781 const coral::Blob& hltcountblob=row[
"HLTCOUNTBLOB"].data<coral::Blob>();
782 const void* hltcountblob_StartAddress=hltcountblob.startingAddress();
783 unsigned int* hltcounts=(
unsigned int*)::malloc(hltcountblob.size());
784 std::memmove(hltcounts,hltcountblob_StartAddress,hltcountblob.size());
785 const coral::Blob& hltacceptblob=row[
"HLTACCEPTBLOB"].data<coral::Blob>();
786 const void* hltacceptblob_StartAddress=hltacceptblob.startingAddress();
787 unsigned int* hltaccepts=(
unsigned int*)::malloc(hltacceptblob.size());
788 std::memmove(hltaccepts,hltacceptblob_StartAddress,hltacceptblob.size());
789 unsigned int nhltaccepts =
sizeof(hltaccepts)/
sizeof(
unsigned int);
792 <<
" hltaccepts, but the run chache is empty. hltdata will not be written";
796 for(
unsigned int i=0;
i<
sizeof(hltaccepts)/
sizeof(
unsigned int);++
i){
799 hlttmp.prescale=hltprescales[
i];
800 hlttmp.l1passcount=hltcounts[
i];
801 hlttmp.acceptcount=hltaccepts[
i];
802 lsdata.hltdata.push_back(hlttmp);
804 ::free(hltprescales);
810 session->transaction().commit();
812 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
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
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