525 l.hltdata.reserve(250);
526 l.l1data.reserve(192);
527 l.bunchlumivalue.reserve(5);
528 l.bunchlumierror.reserve(5);
529 l.bunchlumiquality.reserve(5);
530 l.beam1intensity.resize(3564, 0.0);
531 l.beam2intensity.resize(3564, 0.0);
540 throw cms::Exception(
"Non existing service lumi::service::DBService");
544 session->transaction().start(
true);
545 coral::ISchema& schema =
session->nominalSchema();
546 coral::AttributeList lumisummaryBindVariables;
547 lumisummaryBindVariables.extend(
"lsmin",
typeid(
unsigned int));
548 lumisummaryBindVariables.extend(
"lsmax",
typeid(
unsigned int));
549 lumisummaryBindVariables.extend(
"lumidataid",
typeid(
unsigned long long));
550 lumisummaryBindVariables[
"lumidataid"].data<
unsigned long long>() =
m_cachedlumidataid;
551 lumisummaryBindVariables[
"lsmin"].data<
unsigned int>() = luminum;
552 lumisummaryBindVariables[
"lsmax"].data<
unsigned int>() = luminum + m_cachesize;
553 coral::AttributeList lumisummaryOutput;
554 lumisummaryOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
555 lumisummaryOutput.extend(
"INSTLUMI",
typeid(
float));
556 lumisummaryOutput.extend(
"STARTORBIT",
typeid(
unsigned int));
557 lumisummaryOutput.extend(
"NUMORBIT",
typeid(
unsigned int));
558 lumisummaryOutput.extend(
"CMSBXINDEXBLOB",
typeid(coral::Blob));
559 lumisummaryOutput.extend(
"BEAMINTENSITYBLOB_1",
typeid(coral::Blob));
560 lumisummaryOutput.extend(
"BEAMINTENSITYBLOB_2",
typeid(coral::Blob));
561 lumisummaryOutput.extend(
"BXLUMIVALUE_OCC1",
typeid(coral::Blob));
562 lumisummaryOutput.extend(
"BXLUMIVALUE_OCC2",
typeid(coral::Blob));
563 lumisummaryOutput.extend(
"BXLUMIVALUE_ET",
typeid(coral::Blob));
564 coral::IQuery* lumisummaryQuery = schema.newQuery();
566 lumisummaryQuery->addToOutputList(
"CMSLSNUM");
567 lumisummaryQuery->addToOutputList(
"INSTLUMI");
568 lumisummaryQuery->addToOutputList(
"STARTORBIT");
569 lumisummaryQuery->addToOutputList(
"NUMORBIT");
570 lumisummaryQuery->addToOutputList(
"CMSBXINDEXBLOB");
571 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_1");
572 lumisummaryQuery->addToOutputList(
"BEAMINTENSITYBLOB_2");
573 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_OCC1");
574 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_OCC2");
575 lumisummaryQuery->addToOutputList(
"BXLUMIVALUE_ET");
576 lumisummaryQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:lumidataid",
577 lumisummaryBindVariables);
578 lumisummaryQuery->defineOutput(lumisummaryOutput);
579 coral::ICursor& lumisummarycursor = lumisummaryQuery->execute();
580 unsigned int rowcounter = 0;
581 while (lumisummarycursor.next()) {
582 const coral::AttributeList& row = lumisummarycursor.currentRow();
583 unsigned int cmslsnum = row[
"CMSLSNUM"].data<
unsigned int>();
586 lsdata.lumivalue = row[
"INSTLUMI"].data<
float>();
587 lsdata.lumierror = 0.0;
588 lsdata.lumiquality = 0;
589 lsdata.startorbit = row[
"STARTORBIT"].data<
unsigned int>();
590 lsdata.numorbit = row[
"NUMORBIT"].data<
unsigned int>();
592 if (!row[
"CMSBXINDEXBLOB"].isNull() && !row[
"BXLUMIVALUE_OCC1"].isNull()) {
593 const coral::Blob& bxindexBlob = row[
"CMSBXINDEXBLOB"].data<coral::Blob>();
594 const void* bxindex_StartAddress = bxindexBlob.startingAddress();
595 short* bxindex = (
short*)::malloc(bxindexBlob.size());
596 const coral::Blob& beam1intensityBlob = row[
"BEAMINTENSITYBLOB_1"].data<coral::Blob>();
597 const void* beam1intensityBlob_StartAddress = beam1intensityBlob.startingAddress();
598 float* beam1intensity = (
float*)::malloc(beam1intensityBlob.size());
599 const coral::Blob& beam2intensityBlob = row[
"BEAMINTENSITYBLOB_2"].data<coral::Blob>();
600 const void* beam2intensityBlob_StartAddress = beam2intensityBlob.startingAddress();
601 float* beam2intensity = (
float*)::malloc(beam2intensityBlob.size());
602 std::memmove(bxindex, bxindex_StartAddress, bxindexBlob.size());
603 std::memmove(beam1intensity, beam1intensityBlob_StartAddress, beam1intensityBlob.size());
604 std::memmove(beam2intensity, beam2intensityBlob_StartAddress, beam2intensityBlob.size());
606 unsigned int iMax = bxindexBlob.size() /
sizeof(short);
607 unsigned int lsb1Max = lsdata.beam1intensity.size();
608 unsigned int lsb2Max = lsdata.beam2intensity.size();
609 unsigned int ib1Max = beam1intensityBlob.size() /
sizeof(float);
610 unsigned int ib2Max = beam2intensityBlob.size() /
sizeof(float);
611 for (
unsigned int i = 0;
i < iMax; ++
i) {
612 unsigned int idx = bxindex[
i];
613 if (ib1Max >
i && lsb1Max > idx) {
614 lsdata.beam1intensity.at(idx) = beam1intensity[
i];
616 if (ib2Max >
i && lsb2Max > idx) {
617 lsdata.beam2intensity.at(idx) = beam2intensity[
i];
621 ::free(beam1intensity);
622 ::free(beam2intensity);
624 const coral::Blob& bxlumivalBlob_occ1 = row[
"BXLUMIVALUE_OCC1"].data<coral::Blob>();
625 const void* bxlumival_occ1_StartAddress = bxlumivalBlob_occ1.startingAddress();
626 float* bxlumival_occ1 = (
float*)::malloc(bxlumivalBlob_occ1.size());
627 std::memmove(bxlumival_occ1, bxlumival_occ1_StartAddress, bxlumivalBlob_occ1.size());
628 std::vector<float> bxlumivalVec_occ1(bxlumival_occ1,
629 bxlumival_occ1 + bxlumivalBlob_occ1.size() /
sizeof(float));
630 ::free(bxlumival_occ1);
631 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"OCC1"), bxlumivalVec_occ1));
632 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"OCC1"), std::vector<float>(3564)));
633 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"OCC1"), std::vector<short>(3564)));
634 const coral::Blob& bxlumivalBlob_occ2 = row[
"BXLUMIVALUE_OCC2"].data<coral::Blob>();
635 const void* bxlumival_occ2_StartAddress = bxlumivalBlob_occ2.startingAddress();
636 float* bxlumival_occ2 = (
float*)::malloc(bxlumivalBlob_occ2.size());
637 std::memmove(bxlumival_occ2, bxlumival_occ2_StartAddress, bxlumivalBlob_occ2.size());
638 std::vector<float> bxlumivalVec_occ2(bxlumival_occ2,
639 bxlumival_occ2 + bxlumivalBlob_occ1.size() /
sizeof(float));
640 ::free(bxlumival_occ2);
641 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"OCC2"), bxlumivalVec_occ2));
642 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"OCC2"), std::vector<float>(3564)));
643 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"OCC2"), std::vector<short>(3564)));
645 const coral::Blob& bxlumivalBlob_et = row[
"BXLUMIVALUE_ET"].data<coral::Blob>();
646 const void* bxlumival_et_StartAddress = bxlumivalBlob_et.startingAddress();
647 float* bxlumival_et = (
float*)::malloc(bxlumivalBlob_et.size());
648 std::memmove(bxlumival_et, bxlumival_et_StartAddress, bxlumivalBlob_et.size());
649 std::vector<float> bxlumivalVec_et(bxlumival_et, bxlumival_et + bxlumivalBlob_et.size() /
sizeof(float));
650 ::free(bxlumival_et);
651 lsdata.bunchlumivalue.push_back(std::make_pair(
std::string(
"ET"), bxlumivalVec_et));
652 lsdata.bunchlumierror.push_back(std::make_pair(
std::string(
"ET"), std::vector<float>(3564)));
653 lsdata.bunchlumiquality.push_back(std::make_pair(
std::string(
"ET"), std::vector<short>(3564)));
657 if (rowcounter == 0) {
661 delete lumisummaryQuery;
666 coral::AttributeList trgBindVariables;
667 trgBindVariables.extend(
"lsmin",
typeid(
unsigned int));
668 trgBindVariables.extend(
"lsmax",
typeid(
unsigned int));
669 trgBindVariables.extend(
"trgdataid",
typeid(
unsigned long long));
670 trgBindVariables[
"lsmin"].data<
unsigned int>() = luminum;
671 trgBindVariables[
"lsmax"].data<
unsigned int>() = luminum + m_cachesize;
673 coral::AttributeList trgOutput;
674 trgOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
675 trgOutput.extend(
"DEADTIMECOUNT",
typeid(
unsigned long long));
676 trgOutput.extend(
"BITZEROCOUNT",
typeid(
unsigned int));
677 trgOutput.extend(
"BITZEROPRESCALE",
typeid(
unsigned int));
678 trgOutput.extend(
"PRESCALEBLOB",
typeid(coral::Blob));
679 trgOutput.extend(
"TRGCOUNTBLOB",
typeid(coral::Blob));
681 coral::IQuery* trgQuery = schema.newQuery();
683 trgQuery->addToOutputList(
"CMSLSNUM");
684 trgQuery->addToOutputList(
"DEADTIMECOUNT");
685 trgQuery->addToOutputList(
"BITZEROCOUNT");
686 trgQuery->addToOutputList(
"BITZEROPRESCALE");
687 trgQuery->addToOutputList(
"PRESCALEBLOB");
688 trgQuery->addToOutputList(
"TRGCOUNTBLOB");
689 trgQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:trgdataid", trgBindVariables);
690 trgQuery->defineOutput(trgOutput);
691 coral::ICursor& trgcursor = trgQuery->execute();
692 while (trgcursor.next()) {
693 const coral::AttributeList& row = trgcursor.currentRow();
694 unsigned int cmslsnum = row[
"CMSLSNUM"].data<
unsigned int>();
696 lsdata.deadcount = row[
"DEADTIMECOUNT"].data<
unsigned long long>();
697 lsdata.bitzerocount = row[
"BITZEROCOUNT"].data<
unsigned int>();
698 lsdata.bitzeroprescale = row[
"BITZEROPRESCALE"].data<
unsigned int>();
699 if (!row[
"PRESCALEBLOB"].isNull()) {
700 const coral::Blob& prescaleblob = row[
"PRESCALEBLOB"].data<coral::Blob>();
701 const void* prescaleblob_StartAddress = prescaleblob.startingAddress();
702 unsigned int*
prescales = (
unsigned int*)::malloc(prescaleblob.size());
703 std::memmove(prescales, prescaleblob_StartAddress, prescaleblob.size());
704 const coral::Blob& trgcountblob = row[
"TRGCOUNTBLOB"].data<coral::Blob>();
705 const void* trgcountblob_StartAddress = trgcountblob.startingAddress();
706 unsigned int* trgcounts = (
unsigned int*)::malloc(trgcountblob.size());
707 std::memmove(trgcounts, trgcountblob_StartAddress, trgcountblob.size());
708 for (
unsigned int i = 0;
i < trgcountblob.size() /
sizeof(
unsigned int); ++
i) {
711 l1tmp.prescale = prescales[
i];
712 l1tmp.ratecount = trgcounts[
i];
713 lsdata.l1data.push_back(l1tmp);
723 coral::AttributeList hltBindVariables;
724 hltBindVariables.extend(
"lsmin",
typeid(
unsigned int));
725 hltBindVariables.extend(
"lsmax",
typeid(
unsigned int));
726 hltBindVariables.extend(
"hltdataid",
typeid(
unsigned long long));
727 hltBindVariables[
"lsmin"].data<
unsigned int>() = luminum;
728 hltBindVariables[
"lsmax"].data<
unsigned int>() = luminum + m_cachesize;
730 coral::AttributeList hltOutput;
731 hltOutput.extend(
"CMSLSNUM",
typeid(
unsigned int));
732 hltOutput.extend(
"HLTCOUNTBLOB",
typeid(coral::Blob));
733 hltOutput.extend(
"HLTACCEPTBLOB",
typeid(coral::Blob));
734 hltOutput.extend(
"PRESCALEBLOB",
typeid(coral::Blob));
735 coral::IQuery* hltQuery = schema.newQuery();
737 hltQuery->addToOutputList(
"CMSLSNUM");
738 hltQuery->addToOutputList(
"HLTCOUNTBLOB");
739 hltQuery->addToOutputList(
"HLTACCEPTBLOB");
740 hltQuery->addToOutputList(
"PRESCALEBLOB");
741 hltQuery->setCondition(
"CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:hltdataid", hltBindVariables);
742 hltQuery->defineOutput(hltOutput);
743 coral::ICursor& hltcursor = hltQuery->execute();
744 while (hltcursor.next()) {
745 const coral::AttributeList& row = hltcursor.currentRow();
746 unsigned int cmslsnum = row[
"CMSLSNUM"].data<
unsigned int>();
748 if (!row[
"PRESCALEBLOB"].isNull()) {
749 const coral::Blob& hltprescaleblob = row[
"PRESCALEBLOB"].data<coral::Blob>();
750 const void* hltprescaleblob_StartAddress = hltprescaleblob.startingAddress();
751 unsigned int* hltprescales = (
unsigned int*)::malloc(hltprescaleblob.size());
752 std::memmove(hltprescales, hltprescaleblob_StartAddress, hltprescaleblob.size());
753 const coral::Blob& hltcountblob = row[
"HLTCOUNTBLOB"].data<coral::Blob>();
754 const void* hltcountblob_StartAddress = hltcountblob.startingAddress();
755 unsigned int* hltcounts = (
unsigned int*)::malloc(hltcountblob.size());
756 std::memmove(hltcounts, hltcountblob_StartAddress, hltcountblob.size());
757 const coral::Blob& hltacceptblob = row[
"HLTACCEPTBLOB"].data<coral::Blob>();
758 const void* hltacceptblob_StartAddress = hltacceptblob.startingAddress();
759 unsigned int* hltaccepts = (
unsigned int*)::malloc(hltacceptblob.size());
760 std::memmove(hltaccepts, hltacceptblob_StartAddress, hltacceptblob.size());
761 unsigned int nhltaccepts = hltacceptblob.size() /
sizeof(
unsigned int);
764 <<
"Got " << nhltaccepts <<
" hltaccepts, but the run chache is empty. hltdata will not be written";
768 for (
unsigned int i = 0;
i < hltacceptblob.size() /
sizeof(
unsigned int); ++
i) {
771 hlttmp.prescale = hltprescales[
i];
772 hlttmp.l1passcount = hltcounts[
i];
773 hlttmp.acceptcount = hltaccepts[
i];
774 lsdata.hltdata.push_back(hlttmp);
776 ::free(hltprescales);
782 session->transaction().commit();
784 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::vector< std::string > TRGBitNames
static const std::string lumisummaryv2TableName()
std::map< unsigned int, PerLSData > m_lscache
Log< level::Warning, false > LogWarning
std::vector< std::string > HLTPathNames