429 std::cout<<
"writeAllLumiDataToSchema2"<<std::endl;
430 coral::AttributeList summaryData;
431 summaryData.extend(
"DATA_ID",
typeid(
unsigned long long));
432 summaryData.extend(
"RUNNUM",
typeid(
unsigned int));
433 summaryData.extend(
"LUMILSNUM",
typeid(
unsigned int));
434 summaryData.extend(
"CMSLSNUM",
typeid(
unsigned int));
435 summaryData.extend(
"INSTLUMI",
typeid(
float));
436 summaryData.extend(
"INSTLUMIERROR",
typeid(
float));
437 summaryData.extend(
"INSTLUMIQUALITY",
typeid(
short));
438 summaryData.extend(
"BEAMSTATUS",
typeid(std::string));
439 summaryData.extend(
"BEAMENERGY",
typeid(
float));
440 summaryData.extend(
"NUMORBIT",
typeid(
unsigned int));
441 summaryData.extend(
"STARTORBIT",
typeid(
unsigned int));
442 summaryData.extend(
"CMSBXINDEXBLOB",
typeid(coral::Blob));
443 summaryData.extend(
"BEAMINTENSITYBLOB_1",
typeid(coral::Blob));
444 summaryData.extend(
"BEAMINTENSITYBLOB_2",
typeid(coral::Blob));
445 summaryData.extend(
"BXLUMIVALUE_OCC1",
typeid(coral::Blob));
446 summaryData.extend(
"BXLUMIERROR_OCC1",
typeid(coral::Blob));
447 summaryData.extend(
"BXLUMIQUALITY_OCC1",
typeid(coral::Blob));
448 summaryData.extend(
"BXLUMIVALUE_OCC2",
typeid(coral::Blob));
449 summaryData.extend(
"BXLUMIERROR_OCC2",
typeid(coral::Blob));
450 summaryData.extend(
"BXLUMIQUALITY_OCC2",
typeid(coral::Blob));
451 summaryData.extend(
"BXLUMIVALUE_ET",
typeid(coral::Blob));
452 summaryData.extend(
"BXLUMIERROR_ET",
typeid(coral::Blob));
453 summaryData.extend(
"BXLUMIQUALITY_ET",
typeid(coral::Blob));
455 unsigned long long& data_id=summaryData[
"DATA_ID"].data<
unsigned long long>();
456 unsigned int& lumirunnum = summaryData[
"RUNNUM"].data<
unsigned int>();
457 unsigned int& lumilsnr = summaryData[
"LUMILSNUM"].data<
unsigned int>();
458 unsigned int& cmslsnr = summaryData[
"CMSLSNUM"].data<
unsigned int>();
459 float& instlumi = summaryData[
"INSTLUMI"].data<
float>();
460 float& instlumierror = summaryData[
"INSTLUMIERROR"].data<
float>();
461 short& instlumiquality = summaryData[
"INSTLUMIQUALITY"].data<
short>();
462 std::string& beamstatus = summaryData[
"BEAMSTATUS"].data<std::string>();
463 float& beamenergy = summaryData[
"BEAMENERGY"].data<
float>();
464 unsigned int& numorbit = summaryData[
"NUMORBIT"].data<
unsigned int>();
465 unsigned int& startorbit = summaryData[
"STARTORBIT"].data<
unsigned int>();
466 coral::Blob& bxindex = summaryData[
"CMSBXINDEXBLOB"].data<coral::Blob>();
467 coral::Blob& beamintensity_1 = summaryData[
"BEAMINTENSITYBLOB_1"].data<coral::Blob>();
468 coral::Blob& beamintensity_2 = summaryData[
"BEAMINTENSITYBLOB_2"].data<coral::Blob>();
469 coral::Blob& bxlumivalue_et=summaryData[
"BXLUMIVALUE_ET"].data<coral::Blob>();
470 coral::Blob& bxlumierror_et=summaryData[
"BXLUMIERROR_ET"].data<coral::Blob>();
471 coral::Blob& bxlumiquality_et=summaryData[
"BXLUMIQUALITY_ET"].data<coral::Blob>();
472 coral::Blob& bxlumivalue_occ1=summaryData[
"BXLUMIVALUE_OCC1"].data<coral::Blob>();
473 coral::Blob& bxlumierror_occ1=summaryData[
"BXLUMIERROR_OCC1"].data<coral::Blob>();
474 coral::Blob& bxlumiquality_occ1=summaryData[
"BXLUMIQUALITY_OCC1"].data<coral::Blob>();
475 coral::Blob& bxlumivalue_occ2=summaryData[
"BXLUMIVALUE_OCC2"].data<coral::Blob>();
476 coral::Blob& bxlumierror_occ2=summaryData[
"BXLUMIERROR_OCC2"].data<coral::Blob>();
477 coral::Blob& bxlumiquality_occ2=summaryData[
"BXLUMIQUALITY_OCC2"].data<coral::Blob>();
479 lumi::Lumi2DB::LumiResult::const_iterator lumiIt;
480 coral::IBulkOperation* summaryInserter=0;
482 unsigned int totallumils=std::distance(lumiBeg,lumiEnd);
483 unsigned int lumiindx=0;
484 unsigned int comittedls=0;
486 unsigned long long branch_id=3;
487 std::string branch_name(
"DATA");
490 std::stringstream op;
492 std::string runnumberStr=op.str();
493 session->transaction().start(
false);
497 lumirundata.
bgev=bgev;
512 for(lumiIt=lumiBeg;lumiIt!=lumiEnd;++lumiIt,++lumiindx){
513 if(!
session->transaction().isActive()){
514 session->transaction().start(
false);
516 summaryInserter=summarytable.dataEditor().bulkInsert(summaryData,totallumils);
520 summaryInserter=summarytable.dataEditor().bulkInsert(summaryData,totallumils);
524 lumirunnum = irunnumber;
525 lumilsnr = lumiIt->lumilsnr;
526 cmslsnr = lumiIt->cmslsnr;
527 instlumi = lumiIt->instlumi;
528 instlumierror = lumiIt->instlumierror;
529 instlumiquality = lumiIt->instlumiquality;
530 beamstatus = lumiIt->beammode;
531 beamenergy = lumiIt->beamenergy;
532 numorbit = lumiIt->numorbit;
533 startorbit = lumiIt->startorbit;
534 short nlivebx=lumiIt->nlivebx;
537 bxindex.resize(
sizeof(
short)*nlivebx);
538 beamintensity_1.resize(
sizeof(
float)*nlivebx);
539 beamintensity_2.resize(
sizeof(
float)*nlivebx);
540 void* bxindex_StartAddress = bxindex.startingAddress();
541 void* beamIntensity1_StartAddress = beamintensity_1.startingAddress();
542 void* beamIntensity2_StartAddress = beamintensity_2.startingAddress();
543 std::memmove(bxindex_StartAddress,lumiIt->bxindex,
sizeof(
short)*nlivebx);
544 std::memmove(beamIntensity1_StartAddress,lumiIt->beamintensity_1,
sizeof(
float)*nlivebx);
545 std::memmove(beamIntensity2_StartAddress,lumiIt->beamintensity_2,
sizeof(
float)*nlivebx);
551 beamintensity_1.resize(0);
552 beamintensity_2.resize(0);
555 std::vector<PerBXData>::const_iterator bxIt;
556 std::vector<PerBXData>::const_iterator bxBeg;
557 std::vector<PerBXData>::const_iterator bxEnd;
560 bxBeg=lumiIt->bxET.begin();
561 bxEnd=lumiIt->bxET.end();
565 bxlumivalue_et.resize(
sizeof(
float)*
lumi::N_BX);
566 bxlumierror_et.resize(
sizeof(
float)*lumi::N_BX);
567 bxlumiquality_et.resize(
sizeof(
short)*lumi::N_BX);
568 void* bxlumivalueStartAddress=bxlumivalue_et.startingAddress();
569 void* bxlumierrorStartAddress=bxlumierror_et.startingAddress();
570 void* bxlumiqualityStartAddress=bxlumiquality_et.startingAddress();
572 for( bxIt=bxBeg;bxIt!=bxEnd;++bxIt,++
k ){
573 lumivalue[
k]=bxIt->lumivalue;
574 lumierror[
k]=bxIt->lumierr;
575 lumiquality[
k]=bxIt->lumiquality;
577 std::memmove(bxlumivalueStartAddress,lumivalue,
sizeof(
float)*lumi::N_BX);
578 std::memmove(bxlumierrorStartAddress,lumierror,
sizeof(
float)*lumi::N_BX);
579 std::memmove(bxlumiqualityStartAddress,lumiquality,
sizeof(
short)*lumi::N_BX);
583 bxBeg=lumiIt->bxOCC1.begin();
584 bxEnd=lumiIt->bxOCC1.end();
588 bxlumivalue_occ1.resize(
sizeof(
float)*lumi::N_BX);
589 bxlumierror_occ1.resize(
sizeof(
float)*lumi::N_BX);
590 bxlumiquality_occ1.resize(
sizeof(
short)*lumi::N_BX);
591 void* bxlumivalueStartAddress=bxlumivalue_occ1.startingAddress();
592 void* bxlumierrorStartAddress=bxlumierror_occ1.startingAddress();
593 void* bxlumiqualityStartAddress=bxlumiquality_occ1.startingAddress();
595 for( bxIt=bxBeg;bxIt!=bxEnd;++bxIt,++
k ){
596 lumivalue[
k]=bxIt->lumivalue;
597 lumierror[
k]=bxIt->lumierr;
598 lumiquality[
k]=bxIt->lumiquality;
600 std::memmove(bxlumivalueStartAddress,lumivalue,
sizeof(
float)*lumi::N_BX);
601 std::memmove(bxlumierrorStartAddress,lumierror,
sizeof(
float)*lumi::N_BX);
602 std::memmove(bxlumiqualityStartAddress,lumiquality,
sizeof(
short)*lumi::N_BX);
606 bxBeg=lumiIt->bxOCC2.begin();
607 bxEnd=lumiIt->bxOCC2.end();
611 bxlumivalue_occ2.resize(
sizeof(
float)*lumi::N_BX);
612 bxlumierror_occ2.resize(
sizeof(
float)*lumi::N_BX);
613 bxlumiquality_occ2.resize(
sizeof(
short)*lumi::N_BX);
614 void* bxlumivalueStartAddress=bxlumivalue_occ2.startingAddress();
615 void* bxlumierrorStartAddress=bxlumierror_occ2.startingAddress();
616 void* bxlumiqualityStartAddress=bxlumiquality_occ2.startingAddress();
618 for( bxIt=bxBeg;bxIt!=bxEnd;++bxIt,++
k ){
619 lumivalue[
k]=bxIt->lumivalue;
620 lumierror[
k]=bxIt->lumierr;
621 lumiquality[
k]=bxIt->lumiquality;
623 std::memmove(bxlumivalueStartAddress,lumivalue,
sizeof(
float)*lumi::N_BX);
624 std::memmove(bxlumierrorStartAddress,lumierror,
sizeof(
float)*lumi::N_BX);
625 std::memmove(bxlumiqualityStartAddress,lumiquality,
sizeof(
short)*lumi::N_BX);
628 summaryInserter->processNextIteration();
629 summaryInserter->flush();
632 std::cout<<
"\t committing in LS chunck "<<comittedls<<std::endl;
633 delete summaryInserter;
635 session->transaction().commit();
638 }
else if( lumiindx==(totallumils-1) ){
639 std::cout<<
"\t committing at the end"<<std::endl;
640 delete summaryInserter; summaryInserter=0;
641 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)
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)
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)