446 std::cout <<
"writeAllLumiDataToSchema2" << std::endl;
447 coral::AttributeList summaryData;
448 summaryData.extend(
"DATA_ID",
typeid(
unsigned long long));
449 summaryData.extend(
"RUNNUM",
typeid(
unsigned int));
450 summaryData.extend(
"LUMILSNUM",
typeid(
unsigned int));
451 summaryData.extend(
"CMSLSNUM",
typeid(
unsigned int));
452 summaryData.extend(
"INSTLUMI",
typeid(
float));
453 summaryData.extend(
"INSTLUMIERROR",
typeid(
float));
454 summaryData.extend(
"INSTLUMIQUALITY",
typeid(
short));
455 summaryData.extend(
"BEAMSTATUS",
typeid(
std::string));
456 summaryData.extend(
"BEAMENERGY",
typeid(
float));
457 summaryData.extend(
"NUMORBIT",
typeid(
unsigned int));
458 summaryData.extend(
"STARTORBIT",
typeid(
unsigned int));
459 summaryData.extend(
"CMSBXINDEXBLOB",
typeid(coral::Blob));
460 summaryData.extend(
"BEAMINTENSITYBLOB_1",
typeid(coral::Blob));
461 summaryData.extend(
"BEAMINTENSITYBLOB_2",
typeid(coral::Blob));
462 summaryData.extend(
"BXLUMIVALUE_OCC1",
typeid(coral::Blob));
463 summaryData.extend(
"BXLUMIERROR_OCC1",
typeid(coral::Blob));
464 summaryData.extend(
"BXLUMIQUALITY_OCC1",
typeid(coral::Blob));
465 summaryData.extend(
"BXLUMIVALUE_OCC2",
typeid(coral::Blob));
466 summaryData.extend(
"BXLUMIERROR_OCC2",
typeid(coral::Blob));
467 summaryData.extend(
"BXLUMIQUALITY_OCC2",
typeid(coral::Blob));
468 summaryData.extend(
"BXLUMIVALUE_ET",
typeid(coral::Blob));
469 summaryData.extend(
"BXLUMIERROR_ET",
typeid(coral::Blob));
470 summaryData.extend(
"BXLUMIQUALITY_ET",
typeid(coral::Blob));
472 unsigned long long& data_id = summaryData[
"DATA_ID"].data<
unsigned long long>();
473 unsigned int& lumirunnum = summaryData[
"RUNNUM"].data<
unsigned int>();
474 unsigned int& lumilsnr = summaryData[
"LUMILSNUM"].data<
unsigned int>();
475 unsigned int& cmslsnr = summaryData[
"CMSLSNUM"].data<
unsigned int>();
476 float& instlumi = summaryData[
"INSTLUMI"].data<
float>();
477 float& instlumierror = summaryData[
"INSTLUMIERROR"].data<
float>();
478 short& instlumiquality = summaryData[
"INSTLUMIQUALITY"].data<
short>();
480 float& beamenergy = summaryData[
"BEAMENERGY"].data<
float>();
481 unsigned int& numorbit = summaryData[
"NUMORBIT"].data<
unsigned int>();
482 unsigned int& startorbit = summaryData[
"STARTORBIT"].data<
unsigned int>();
483 coral::Blob& bxindex = summaryData[
"CMSBXINDEXBLOB"].data<coral::Blob>();
484 coral::Blob& beamintensity_1 = summaryData[
"BEAMINTENSITYBLOB_1"].data<coral::Blob>();
485 coral::Blob& beamintensity_2 = summaryData[
"BEAMINTENSITYBLOB_2"].data<coral::Blob>();
486 coral::Blob& bxlumivalue_et = summaryData[
"BXLUMIVALUE_ET"].data<coral::Blob>();
487 coral::Blob& bxlumierror_et = summaryData[
"BXLUMIERROR_ET"].data<coral::Blob>();
488 coral::Blob& bxlumiquality_et = summaryData[
"BXLUMIQUALITY_ET"].data<coral::Blob>();
489 coral::Blob& bxlumivalue_occ1 = summaryData[
"BXLUMIVALUE_OCC1"].data<coral::Blob>();
490 coral::Blob& bxlumierror_occ1 = summaryData[
"BXLUMIERROR_OCC1"].data<coral::Blob>();
491 coral::Blob& bxlumiquality_occ1 = summaryData[
"BXLUMIQUALITY_OCC1"].data<coral::Blob>();
492 coral::Blob& bxlumivalue_occ2 = summaryData[
"BXLUMIVALUE_OCC2"].data<coral::Blob>();
493 coral::Blob& bxlumierror_occ2 = summaryData[
"BXLUMIERROR_OCC2"].data<coral::Blob>();
494 coral::Blob& bxlumiquality_occ2 = summaryData[
"BXLUMIQUALITY_OCC2"].data<coral::Blob>();
496 lumi::Lumi2DB::LumiResult::const_iterator lumiIt;
497 coral::IBulkOperation* summaryInserter =
nullptr;
500 unsigned int lumiindx = 0;
501 unsigned int comittedls = 0;
503 unsigned long long branch_id = 3;
507 std::stringstream
op;
510 session->transaction().start(
false);
514 lumirundata.
bgev = bgev;
522 std::cout <<
"it's a new run lumirundata revision_id " << lumirundata.
revision_id <<
" entry_id " 523 << lumirundata.
entry_id <<
" data_id " << lumirundata.
data_id << std::endl;
525 std::cout <<
"added entry " << std::endl;
529 <<
" data_id " << lumirundata.
data_id << std::endl;
534 for (lumiIt = lumiBeg; lumiIt != lumiEnd; ++lumiIt, ++lumiindx) {
535 if (!session->transaction().isActive()) {
536 session->transaction().start(
false);
538 summaryInserter = summarytable.dataEditor().bulkInsert(summaryData, totallumils);
540 if (lumiIt == lumiBeg) {
542 summaryInserter = summarytable.dataEditor().bulkInsert(summaryData, totallumils);
546 lumirunnum = irunnumber;
547 lumilsnr = lumiIt->lumilsnr;
548 cmslsnr = lumiIt->cmslsnr;
549 instlumi = lumiIt->instlumi;
550 instlumierror = lumiIt->instlumierror;
551 instlumiquality = lumiIt->instlumiquality;
552 beamstatus = lumiIt->beammode;
553 beamenergy = lumiIt->beamenergy;
554 numorbit = lumiIt->numorbit;
555 startorbit = lumiIt->startorbit;
556 short nlivebx = lumiIt->nlivebx;
559 bxindex.resize(
sizeof(
short) * nlivebx);
560 beamintensity_1.resize(
sizeof(
float) * nlivebx);
561 beamintensity_2.resize(
sizeof(
float) * nlivebx);
562 void* bxindex_StartAddress = bxindex.startingAddress();
563 void* beamIntensity1_StartAddress = beamintensity_1.startingAddress();
564 void* beamIntensity2_StartAddress = beamintensity_2.startingAddress();
565 std::memmove(bxindex_StartAddress, lumiIt->bxindex,
sizeof(
short) * nlivebx);
566 std::memmove(beamIntensity1_StartAddress, lumiIt->beamintensity_1,
sizeof(
float) * nlivebx);
567 std::memmove(beamIntensity2_StartAddress, lumiIt->beamintensity_2,
sizeof(
float) * nlivebx);
573 beamintensity_1.resize(0);
574 beamintensity_2.resize(0);
577 std::vector<PerBXData>::const_iterator bxIt;
578 std::vector<PerBXData>::const_iterator bxBeg;
579 std::vector<PerBXData>::const_iterator bxEnd;
582 bxBeg = lumiIt->bxET.begin();
583 bxEnd = lumiIt->bxET.end();
587 bxlumivalue_et.resize(
sizeof(
float) *
lumi::N_BX);
588 bxlumierror_et.resize(
sizeof(
float) *
lumi::N_BX);
589 bxlumiquality_et.resize(
sizeof(
short) *
lumi::N_BX);
590 void* bxlumivalueStartAddress = bxlumivalue_et.startingAddress();
591 void* bxlumierrorStartAddress = bxlumierror_et.startingAddress();
592 void* bxlumiqualityStartAddress = bxlumiquality_et.startingAddress();
594 for (bxIt = bxBeg; bxIt != bxEnd; ++bxIt, ++
k) {
595 lumivalue[
k] = bxIt->lumivalue;
596 lumierror[
k] = bxIt->lumierr;
597 lumiquality[
k] = bxIt->lumiquality;
599 std::memmove(bxlumivalueStartAddress, lumivalue,
sizeof(
float) *
lumi::N_BX);
600 std::memmove(bxlumierrorStartAddress, lumierror,
sizeof(
float) *
lumi::N_BX);
601 std::memmove(bxlumiqualityStartAddress, lumiquality,
sizeof(
short) *
lumi::N_BX);
605 bxBeg = lumiIt->bxOCC1.begin();
606 bxEnd = lumiIt->bxOCC1.end();
610 bxlumivalue_occ1.resize(
sizeof(
float) *
lumi::N_BX);
611 bxlumierror_occ1.resize(
sizeof(
float) *
lumi::N_BX);
612 bxlumiquality_occ1.resize(
sizeof(
short) *
lumi::N_BX);
613 void* bxlumivalueStartAddress = bxlumivalue_occ1.startingAddress();
614 void* bxlumierrorStartAddress = bxlumierror_occ1.startingAddress();
615 void* bxlumiqualityStartAddress = bxlumiquality_occ1.startingAddress();
617 for (bxIt = bxBeg; bxIt != bxEnd; ++bxIt, ++
k) {
618 lumivalue[
k] = bxIt->lumivalue;
619 lumierror[
k] = bxIt->lumierr;
620 lumiquality[
k] = bxIt->lumiquality;
622 std::memmove(bxlumivalueStartAddress, lumivalue,
sizeof(
float) *
lumi::N_BX);
623 std::memmove(bxlumierrorStartAddress, lumierror,
sizeof(
float) *
lumi::N_BX);
624 std::memmove(bxlumiqualityStartAddress, lumiquality,
sizeof(
short) *
lumi::N_BX);
628 bxBeg = lumiIt->bxOCC2.begin();
629 bxEnd = lumiIt->bxOCC2.end();
633 bxlumivalue_occ2.resize(
sizeof(
float) *
lumi::N_BX);
634 bxlumierror_occ2.resize(
sizeof(
float) *
lumi::N_BX);
635 bxlumiquality_occ2.resize(
sizeof(
short) *
lumi::N_BX);
636 void* bxlumivalueStartAddress = bxlumivalue_occ2.startingAddress();
637 void* bxlumierrorStartAddress = bxlumierror_occ2.startingAddress();
638 void* bxlumiqualityStartAddress = bxlumiquality_occ2.startingAddress();
640 for (bxIt = bxBeg; bxIt != bxEnd; ++bxIt, ++
k) {
641 lumivalue[
k] = bxIt->lumivalue;
642 lumierror[
k] = bxIt->lumierr;
643 lumiquality[
k] = bxIt->lumiquality;
645 std::memmove(bxlumivalueStartAddress, lumivalue,
sizeof(
float) *
lumi::N_BX);
646 std::memmove(bxlumierrorStartAddress, lumierror,
sizeof(
float) *
lumi::N_BX);
647 std::memmove(bxlumiqualityStartAddress, lumiquality,
sizeof(
short) *
lumi::N_BX);
650 summaryInserter->processNextIteration();
651 summaryInserter->flush();
654 std::cout <<
"\t committing in LS chunck " << comittedls << std::endl;
655 delete summaryInserter;
656 summaryInserter =
nullptr;
657 session->transaction().commit();
659 std::cout <<
"\t committed " << std::endl;
660 }
else if (lumiindx == (totallumils - 1)) {
661 std::cout <<
"\t committing at the end" << std::endl;
662 delete summaryInserter;
663 summaryInserter =
nullptr;
664 session->transaction().commit();
void addEntry(coral::ISchema &schema, const std::string &datatableName, const Entry &entry, unsigned long long branch_id, const std::string &branchname)
const unsigned int N_LUMIALGO
static const unsigned int COMMITLSINTERVAL
void insertLumiRunData(coral::ISchema &schema, const LumiEntry &lumientry)
unsigned long long data_id
unsigned long long getEntryInBranchByName(coral::ISchema &schema, const std::string &datatableName, const std::string &entryname, const std::string &branchname)
unsigned long long revision_id
static const std::string lumidataTableName()
unsigned long long entry_id
void bookNewEntry(coral::ISchema &schema, const std::string &datatableName, Entry &entry)
unsigned int ncollidingbunches
static const std::string lumisummaryv2TableName()
void addRevision(coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
static std::string const source
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)