432 std::cout<<
"writeAllLumiDataToSchema2"<<std::endl;
433 coral::AttributeList summaryData;
434 summaryData.extend(
"DATA_ID",
typeid(
unsigned long long));
435 summaryData.extend(
"RUNNUM",
typeid(
unsigned int));
436 summaryData.extend(
"LUMILSNUM",
typeid(
unsigned int));
437 summaryData.extend(
"CMSLSNUM",
typeid(
unsigned int));
438 summaryData.extend(
"INSTLUMI",
typeid(
float));
439 summaryData.extend(
"INSTLUMIERROR",
typeid(
float));
440 summaryData.extend(
"INSTLUMIQUALITY",
typeid(
short));
441 summaryData.extend(
"BEAMSTATUS",
typeid(
std::string));
442 summaryData.extend(
"BEAMENERGY",
typeid(
float));
443 summaryData.extend(
"NUMORBIT",
typeid(
unsigned int));
444 summaryData.extend(
"STARTORBIT",
typeid(
unsigned int));
445 summaryData.extend(
"CMSBXINDEXBLOB",
typeid(coral::Blob));
446 summaryData.extend(
"BEAMINTENSITYBLOB_1",
typeid(coral::Blob));
447 summaryData.extend(
"BEAMINTENSITYBLOB_2",
typeid(coral::Blob));
448 summaryData.extend(
"BXLUMIVALUE_OCC1",
typeid(coral::Blob));
449 summaryData.extend(
"BXLUMIERROR_OCC1",
typeid(coral::Blob));
450 summaryData.extend(
"BXLUMIQUALITY_OCC1",
typeid(coral::Blob));
451 summaryData.extend(
"BXLUMIVALUE_OCC2",
typeid(coral::Blob));
452 summaryData.extend(
"BXLUMIERROR_OCC2",
typeid(coral::Blob));
453 summaryData.extend(
"BXLUMIQUALITY_OCC2",
typeid(coral::Blob));
454 summaryData.extend(
"BXLUMIVALUE_ET",
typeid(coral::Blob));
455 summaryData.extend(
"BXLUMIERROR_ET",
typeid(coral::Blob));
456 summaryData.extend(
"BXLUMIQUALITY_ET",
typeid(coral::Blob));
458 unsigned long long& data_id=summaryData[
"DATA_ID"].data<
unsigned long long>();
459 unsigned int& lumirunnum = summaryData[
"RUNNUM"].data<
unsigned int>();
460 unsigned int& lumilsnr = summaryData[
"LUMILSNUM"].data<
unsigned int>();
461 unsigned int& cmslsnr = summaryData[
"CMSLSNUM"].data<
unsigned int>();
462 float& instlumi = summaryData[
"INSTLUMI"].data<
float>();
463 float& instlumierror = summaryData[
"INSTLUMIERROR"].data<
float>();
464 short& instlumiquality = summaryData[
"INSTLUMIQUALITY"].data<
short>();
466 float& beamenergy = summaryData[
"BEAMENERGY"].data<
float>();
467 unsigned int& numorbit = summaryData[
"NUMORBIT"].data<
unsigned int>();
468 unsigned int& startorbit = summaryData[
"STARTORBIT"].data<
unsigned int>();
469 coral::Blob& bxindex = summaryData[
"CMSBXINDEXBLOB"].data<coral::Blob>();
470 coral::Blob& beamintensity_1 = summaryData[
"BEAMINTENSITYBLOB_1"].data<coral::Blob>();
471 coral::Blob& beamintensity_2 = summaryData[
"BEAMINTENSITYBLOB_2"].data<coral::Blob>();
472 coral::Blob& bxlumivalue_et=summaryData[
"BXLUMIVALUE_ET"].data<coral::Blob>();
473 coral::Blob& bxlumierror_et=summaryData[
"BXLUMIERROR_ET"].data<coral::Blob>();
474 coral::Blob& bxlumiquality_et=summaryData[
"BXLUMIQUALITY_ET"].data<coral::Blob>();
475 coral::Blob& bxlumivalue_occ1=summaryData[
"BXLUMIVALUE_OCC1"].data<coral::Blob>();
476 coral::Blob& bxlumierror_occ1=summaryData[
"BXLUMIERROR_OCC1"].data<coral::Blob>();
477 coral::Blob& bxlumiquality_occ1=summaryData[
"BXLUMIQUALITY_OCC1"].data<coral::Blob>();
478 coral::Blob& bxlumivalue_occ2=summaryData[
"BXLUMIVALUE_OCC2"].data<coral::Blob>();
479 coral::Blob& bxlumierror_occ2=summaryData[
"BXLUMIERROR_OCC2"].data<coral::Blob>();
480 coral::Blob& bxlumiquality_occ2=summaryData[
"BXLUMIQUALITY_OCC2"].data<coral::Blob>();
482 lumi::Lumi2DB::LumiResult::const_iterator lumiIt;
483 coral::IBulkOperation* summaryInserter=0;
486 unsigned int lumiindx=0;
487 unsigned int comittedls=0;
489 unsigned long long branch_id=3;
493 std::stringstream op;
496 session->transaction().start(
false);
500 lumirundata.
bgev=bgev;
516 for(lumiIt=lumiBeg;lumiIt!=lumiEnd;++lumiIt,++lumiindx){
517 if(!
session->transaction().isActive()){
518 session->transaction().start(
false);
520 summaryInserter=summarytable.dataEditor().bulkInsert(summaryData,totallumils);
524 summaryInserter=summarytable.dataEditor().bulkInsert(summaryData,totallumils);
528 lumirunnum = irunnumber;
529 lumilsnr = lumiIt->lumilsnr;
530 cmslsnr = lumiIt->cmslsnr;
531 instlumi = lumiIt->instlumi;
532 instlumierror = lumiIt->instlumierror;
533 instlumiquality = lumiIt->instlumiquality;
534 beamstatus = lumiIt->beammode;
535 beamenergy = lumiIt->beamenergy;
536 numorbit = lumiIt->numorbit;
537 startorbit = lumiIt->startorbit;
538 short nlivebx=lumiIt->nlivebx;
541 bxindex.resize(
sizeof(
short)*nlivebx);
542 beamintensity_1.resize(
sizeof(
float)*nlivebx);
543 beamintensity_2.resize(
sizeof(
float)*nlivebx);
544 void* bxindex_StartAddress = bxindex.startingAddress();
545 void* beamIntensity1_StartAddress = beamintensity_1.startingAddress();
546 void* beamIntensity2_StartAddress = beamintensity_2.startingAddress();
547 std::memmove(bxindex_StartAddress,lumiIt->bxindex,
sizeof(
short)*nlivebx);
548 std::memmove(beamIntensity1_StartAddress,lumiIt->beamintensity_1,
sizeof(
float)*nlivebx);
549 std::memmove(beamIntensity2_StartAddress,lumiIt->beamintensity_2,
sizeof(
float)*nlivebx);
555 beamintensity_1.resize(0);
556 beamintensity_2.resize(0);
559 std::vector<PerBXData>::const_iterator bxIt;
560 std::vector<PerBXData>::const_iterator bxBeg;
561 std::vector<PerBXData>::const_iterator bxEnd;
564 bxBeg=lumiIt->bxET.begin();
565 bxEnd=lumiIt->bxET.end();
569 bxlumivalue_et.resize(
sizeof(
float)*
lumi::N_BX);
570 bxlumierror_et.resize(
sizeof(
float)*lumi::N_BX);
571 bxlumiquality_et.resize(
sizeof(
short)*lumi::N_BX);
572 void* bxlumivalueStartAddress=bxlumivalue_et.startingAddress();
573 void* bxlumierrorStartAddress=bxlumierror_et.startingAddress();
574 void* bxlumiqualityStartAddress=bxlumiquality_et.startingAddress();
576 for( bxIt=bxBeg;bxIt!=bxEnd;++bxIt,++
k ){
577 lumivalue[
k]=bxIt->lumivalue;
578 lumierror[
k]=bxIt->lumierr;
579 lumiquality[
k]=bxIt->lumiquality;
581 std::memmove(bxlumivalueStartAddress,lumivalue,
sizeof(
float)*lumi::N_BX);
582 std::memmove(bxlumierrorStartAddress,lumierror,
sizeof(
float)*lumi::N_BX);
583 std::memmove(bxlumiqualityStartAddress,lumiquality,
sizeof(
short)*lumi::N_BX);
587 bxBeg=lumiIt->bxOCC1.begin();
588 bxEnd=lumiIt->bxOCC1.end();
592 bxlumivalue_occ1.resize(
sizeof(
float)*lumi::N_BX);
593 bxlumierror_occ1.resize(
sizeof(
float)*lumi::N_BX);
594 bxlumiquality_occ1.resize(
sizeof(
short)*lumi::N_BX);
595 void* bxlumivalueStartAddress=bxlumivalue_occ1.startingAddress();
596 void* bxlumierrorStartAddress=bxlumierror_occ1.startingAddress();
597 void* bxlumiqualityStartAddress=bxlumiquality_occ1.startingAddress();
599 for( bxIt=bxBeg;bxIt!=bxEnd;++bxIt,++
k ){
600 lumivalue[
k]=bxIt->lumivalue;
601 lumierror[
k]=bxIt->lumierr;
602 lumiquality[
k]=bxIt->lumiquality;
604 std::memmove(bxlumivalueStartAddress,lumivalue,
sizeof(
float)*lumi::N_BX);
605 std::memmove(bxlumierrorStartAddress,lumierror,
sizeof(
float)*lumi::N_BX);
606 std::memmove(bxlumiqualityStartAddress,lumiquality,
sizeof(
short)*lumi::N_BX);
610 bxBeg=lumiIt->bxOCC2.begin();
611 bxEnd=lumiIt->bxOCC2.end();
615 bxlumivalue_occ2.resize(
sizeof(
float)*lumi::N_BX);
616 bxlumierror_occ2.resize(
sizeof(
float)*lumi::N_BX);
617 bxlumiquality_occ2.resize(
sizeof(
short)*lumi::N_BX);
618 void* bxlumivalueStartAddress=bxlumivalue_occ2.startingAddress();
619 void* bxlumierrorStartAddress=bxlumierror_occ2.startingAddress();
620 void* bxlumiqualityStartAddress=bxlumiquality_occ2.startingAddress();
622 for( bxIt=bxBeg;bxIt!=bxEnd;++bxIt,++
k ){
623 lumivalue[
k]=bxIt->lumivalue;
624 lumierror[
k]=bxIt->lumierr;
625 lumiquality[
k]=bxIt->lumiquality;
627 std::memmove(bxlumivalueStartAddress,lumivalue,
sizeof(
float)*lumi::N_BX);
628 std::memmove(bxlumierrorStartAddress,lumierror,
sizeof(
float)*lumi::N_BX);
629 std::memmove(bxlumiqualityStartAddress,lumiquality,
sizeof(
short)*lumi::N_BX);
632 summaryInserter->processNextIteration();
633 summaryInserter->flush();
636 std::cout<<
"\t committing in LS chunck "<<comittedls<<std::endl;
637 delete summaryInserter;
639 session->transaction().commit();
642 }
else if( lumiindx==(totallumils-1) ){
643 std::cout<<
"\t committing at the end"<<std::endl;
644 delete summaryInserter; summaryInserter=0;
645 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)