BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
CalibMySQLCnvSvc Class Reference

#include <CalibMySQLCnvSvc.h>

+ Inheritance diagram for CalibMySQLCnvSvc:

Public Member Functions

virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Create a transient representation from another rep of this object.
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the created transient object.
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *pObject)
 Update a transient representation from another rep of this object.
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an updated transient object.
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert a transient object to a requested representation.
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of a converted object.
 
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Update a converted representation of a transient object.
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an already converted object.
 
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
 Create an address using explicit arguments to identify a single object.
 
virtual StatusCode createCalib (DataObject *&refpObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)
 
virtual StatusCode updateCalib (DataObject *pObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)
 
virtual StatusCode decodeDescription (const std::string &description, unsigned char &type)
 Decode the string storage type to enumerated storage type.
 
virtual calibUtil::MetadatagetMeta ()
 Handle to the MySQL metadata database.
 
StatusCode getSftParVer (std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
 
virtual StatusCode createCalib (DataObject *&refpObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)=0
 
virtual StatusCode updateCalib (DataObject *pObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)=0
 
virtual calibUtil::MetadatagetMeta ()=0
 

Protected Member Functions

 CalibMySQLCnvSvc (const std::string &name, ISvcLocator *svc)
 
virtual ~CalibMySQLCnvSvc ()
 

Friends

class SvcFactory< CalibMySQLCnvSvc >
 Only factories can access protected constructors.
 

Additional Inherited Members

- Static Public Member Functions inherited from ICalibMetaCnvSvc
static const InterfaceID & interfaceID ()
 Interface ID of this class.
 

Detailed Description


A conversion service for GLAST calibration metadata database persistency. Allows to create and update condition data objects (i.e. DataObjects implementing IValidity).

Adapted from LHCb class DetCond/ConditionsDBCnvSvc by Andrea Valassi

Author
J. Bogart
Date
November 2002

Definition at line 33 of file CalibMySQLCnvSvc.h.

Constructor & Destructor Documentation

◆ CalibMySQLCnvSvc()

CalibMySQLCnvSvc::CalibMySQLCnvSvc ( const std::string &  name,
ISvcLocator *  svc 
)
protected

Definition at line 65 of file CalibMySQLCnvSvc.cxx.

66 : ConversionSvc (name, svc, MYSQL_StorageType)
67 , m_meta(0), m_useEventTime(true),m_enterTimeStart(0), m_enterTimeEnd(0),
68 m_qualityMask(0)
69{
70 // declareProperty("Host", m_host = "202.122.37.69");
71 declareProperty("Host", m_host = "bes3db2.ihep.ac.cn");
72 declareProperty("UseEventTime", m_useEventTime = true);
73 declareProperty("EnterTimeEnd", m_enterTimeEndString = std::string("") );
74 declareProperty("EnterTimeStart", m_enterTimeStartString = std::string("") );
75 // declareProperty("DbName", m_dbName = std::string("calib") );
76 declareProperty("DbName", m_dbName = std::string("offlinedb") );
77 declareProperty("QualityList", m_qualityList);
78 declareProperty("CrashOnError", m_crash = true);
79 declareProperty("Sft_Ver",sft_ver);
80 declareProperty("Cal_Ver",cal_ver);
81 declareProperty("MdcFlag",m_flag[0]="default");
82 declareProperty("DeDxFlag",m_flag[1]="default");
83 declareProperty("EmcFlag",m_flag[2]="default");
84 declareProperty("TofFlag",m_flag[3]="default");
85 declareProperty("MucFlag",m_flag[4]="default");
86 declareProperty("EsTimeFlag",m_flag[5]="default");
87 declareProperty("EstTofFlag",m_flag[6]="default");
88 declareProperty("MdcAlignFlag",m_flag[7]="default");
89 declareProperty("TofQElecFlag",m_flag[8]="default");
90 declareProperty("TofSimPFlag",m_flag[9]="default");
91 declareProperty("DedxSimFlag",m_flag[10]="default");
92 declareProperty("MdcDataFlag",m_flag[11]="default");
93 declareProperty("MdcCalPar",m_calPar[0]="default");
94 declareProperty("DeDxCalPar",m_calPar[1]="default");
95 declareProperty("EmcCalPar",m_calPar[2]="default");
96 declareProperty("TofCalPar",m_calPar[3]="default");
97 declareProperty("MucCalPar",m_calPar[4]="default");
98 declareProperty("EsTimeCalPar",m_calPar[5]="default");
99 declareProperty("EstTofCalPar",m_calPar[6]="default");
100 declareProperty("MdcAlignPar",m_calPar[7]="default");
101 declareProperty("TofQElecPar",m_calPar[8]="default");
102 declareProperty("TofSimPar",m_calPar[9]="default");
103 declareProperty("DedxSimPar",m_calPar[10]="default");
104 declareProperty("MdcDataConstVer",m_calPar[11]="default");
105 declareProperty("MdcBossVer",m_bossver[0]="default");
106 declareProperty("DeDxBossVer",m_bossver[1]="default");
107 declareProperty("EmcBossVer",m_bossver[2]="default");
108 declareProperty("TofBossVer",m_bossver[3]="default");
109 declareProperty("MucBossVer",m_bossver[4]="default");
110 declareProperty("EsTimeBossVer",m_bossver[5]="default");
111 declareProperty("EstTofBossVer",m_bossver[6]="default");
112 declareProperty("MdcAlignBossVer",m_bossver[7]="default");
113 declareProperty("TofQElecBossVer",m_bossver[8]="default");
114 declareProperty("TofSimBossVer",m_bossver[9]="default");
115 declareProperty("DedxSimBossVer",m_bossver[10]="default");
116 declareProperty("MdcDataConstBossVer",m_bossver[11]="default");
117 declareProperty("Align_RunNo",m_MdcAlign_No=8093);
118 declareProperty("Db_Status",m_dbStatus="OK");
119 declareProperty("BossRelease",m_bossRelease="default");
120}

◆ ~CalibMySQLCnvSvc()

CalibMySQLCnvSvc::~CalibMySQLCnvSvc ( )
protectedvirtual

Definition at line 122 of file CalibMySQLCnvSvc.cxx.

122{ }

Member Function Documentation

◆ createAddress()

StatusCode CalibMySQLCnvSvc::createAddress ( long  svc_type,
const CLID &  clid,
const std::string *  par,
const unsigned long *  ip,
IOpaqueAddress *&  refpAddress 
)
virtual

Create an address using explicit arguments to identify a single object.

Overload ConversionSvc implementation of createAddress.
Create an address using explicit arguments to identify a single object. Par[0] is full path in calibration TDS

Definition at line 367 of file CalibMySQLCnvSvc.cxx.

371 {
372 // First check that requested address is of type MYSQL_StorageType
373 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
374 if ( svc_type!= MYSQL_StorageType ) {
375 log << MSG::ERROR
376 << "Cannot create addresses of type " << (int)svc_type
377 << " which is different from " << (int)MYSQL_StorageType
378 << endreq;
379 return StatusCode::FAILURE;
380 }
381 log << MSG::INFO
382 << " create address in CalibMySQLCnvSvc "
383 << endreq;
384
385 refpAddress = new GenericAddress( MYSQL_StorageType,
386 clid,
387 par[0]);
388
389 return StatusCode::SUCCESS;
390}
IMessageSvc * msgSvc()

◆ createCalib()

StatusCode CalibMySQLCnvSvc::createCalib ( DataObject *&  refpObject,
const std::string &  fullpath,
const CLID &  classID,
IRegistry *  entry = 0 
)
virtual

Create a calib DataObject by calib type name, flavor and time. This method does not register DataObject in the transient data store. The string storage type is discovered at runtime in the Metadata dbs.

Create a calib DataObject by calib type, flavor, time and instrument. This method does not register DataObject in the transient data store, [but may register TDS addresses for its children if needed (e.g. Catalog).

  • what's all this about? ] The string storage type is discovered at runtime in the metadata dbs The entry name identifies a condition amongst the many in the string. Implementation:

create a temporary address containing storage type and classID;

  • dispatch to appropriate conversion service according to storage type;
  • this will dispatch to appropriate converter according to CLID (CalibMySQLCnvSvc has no converters of its own).

Implements ICalibMetaCnvSvc.

Definition at line 453 of file CalibMySQLCnvSvc.cxx.

457{
458 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
459
460 // Look up calib object in the Metadata database
461 std::string cType = CalibData::CalibModelSvc::getCalibType(fullpath);
462
463 // ..and extra special munging for test
464 if (std::string("Test") == cType.substr(0, 4)) {
465 cType = std::string("Test_Gen");
466 }
467
468 std::string testfile = std::string(getenv("CALIBMYSQLCNVROOT"))+"/share/test.root";
469 TFile *f1=new TFile(testfile.c_str(),"read");
470 unsigned int ser = 0;
471 //runfrm,runto are the value from the table ***CalConst;runfrm1,runto1 are the value from the table CalVtxLumVer
472 int runfrm,runfrm1;
473 int runto,runto1;
474 std::string flag="default";
476
477 MSG::Level msgLevel = MSG::DEBUG;
478
479 std::string physFmt = "UNK";
480 std::string fmtVersion;
481 std::string dataIdent;
482
483 // Get the runNo of current event:
484 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event/EventHeader");
485 int runNo=0;
486 if( !evt ){
487 log << MSG::WARNING << "Unable to read the Event for TDS" << endreq;
488 // return StatusCode::FAILURE;
489 }
490 if( evt ){
491 if(cType!="TofCal"&&cType!="EstTofCal"&&cType!="TofSim"&&cType!="DedxSim") runNo = fabs(evt -> runNumber());
492 if(cType=="TofCal"||cType=="EstTofCal"||cType=="TofSim"||cType=="DedxSim") runNo = evt -> runNumber();
493 }
495
496 StatusCode st1;
497
498 //TofCalConst
499 if((cType=="TofCal")&&(m_bossver[3]== "default" ))
500 {
501 std::string cType="Tof";
502 if(m_bossRelease=="default")
503 {
504 log << MSG::FATAL << " Boss Release for TofCal not set!" << endreq;
505 exit(1);
506
507 }
508 else
509 {
510 st1=getSftParVer(m_bossver[3],m_calPar[3],runfrm1,runto1,runNo,m_bossRelease,cType);
511 //cout<<cType<<" runfrm1,runto1 is:"<<runfrm1<<"::"<<runto1<<endl;
512 if (st1 .isFailure() )
513 {
514 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
515 return st1;
516 }
517 //cout<<"SftVer and CalParVer are:"<<sft_ver<<";"<<cal_ver<<endl;
518 ret = m_meta->getReadTOFInfo(ser,&runfrm,&runto,m_calPar[3],res,runNo,m_bossver[3]);
519
520 }
521 }
522 else if ((cType=="TofCal")&&(m_bossver[3]!= "default" ))
523 {
524 m_flag[3]="set";
525 flag=m_flag[3];
526 //cout<<"flag @create Tof is:"<<m_flag[3]<<endl;
527 ret = m_meta->getReadTOFInfo(ser,&runfrm,&runto,m_calPar[3],res,runNo,m_bossver[3]);
528 }
529
530
531 //EmcCalConst
532 if((cType=="EmcCal")&&(m_bossver[2]== "default" ))
533 {
534 std::string cType="Emc";
535 if(m_bossRelease=="default")
536 {
537 log << MSG::FATAL << " Boss Release for EmcCal not set!" << endreq;
538 exit(1);
539 }
540 else{
541
542 st1=getSftParVer(m_bossver[2],m_calPar[2],runfrm1,runto1,runNo,m_bossRelease,cType);
543 //cout<<cType<<" runfrm1,runto1 is:"<<runfrm1<<"::"<<runto1<<endl;
544 //cout<<"flag @create Emc is:"<<flag<<endl;
545 if (st1 .isFailure() )
546 {
547 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
548 return st1;
549 }
550 ret = m_meta->getReadEMCInfo(ser,&runfrm,&runto, m_calPar[2], res,runNo,m_bossver[2]);
551 }
552 }
553 else if((cType=="EmcCal")&&(m_bossver[2]!= "default" ))
554 {
555 m_flag[2]="set";
556 flag=m_flag[2];
557 //cout<<"flag @create Emc is:"<<m_flag[2]<<endl;
558 ret = m_meta->getReadEMCInfo(ser,&runfrm,&runto, m_calPar[2], res,runNo,m_bossver[2]);
559 }
560
561 //DedxCalConst
562 if((cType=="DedxCal")&&(m_bossver[1]== "default" ))
563 {
564 std::string cType="Dedx";
565 if(m_bossRelease=="default")
566 {
567 log << MSG::FATAL << " Boss Release for DedxCal not set!" << endreq;
568 exit(1);
569 }
570 else
571 {
572 st1=getSftParVer(m_bossver[1],m_calPar[1],runfrm1,runto1,runNo,m_bossRelease,cType);
573 //cout<<cType<<" runfrm1,runto1 is:"<<runfrm1<<"::"<<runto1<<endl;
574 if (st1 .isFailure() )
575 {
576 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
577 return st1;
578 }
579 ret = m_meta->getReadDedxInfo(ser,&runfrm,&runto, m_calPar[1], res,runNo,m_bossver[1]);
580 }
581 }
582 else if((cType=="DedxCal")&&(m_bossver[1]!= "default" ))
583 {
584 m_flag[1]="set";
585 flag=m_flag[1];
586 //cout<<"flag @create Dedx is:"<<m_flag[1]<<endl;
587 ret = m_meta->getReadDedxInfo(ser,&runfrm,&runto, m_calPar[1], res,runNo,m_bossver[1]);
588 }
589
590 //MdcCalConst
591 if((cType=="MdcCal")&&(m_bossver[0]== "default" ))
592 {
593 std::string cType="Mdc";
594 //cout<<"cType is"<<cType<<"m_bossver[0] is:"<<m_bossver[0]<<endl;
595 if(m_bossRelease=="default")
596 {
597 log << MSG::FATAL << " Boss Release for MdcCal not set!" << endreq;
598 exit(1);
599 }
600 else
601 {
602 st1=getSftParVer(m_bossver[0],m_calPar[0],runfrm1,runto1,runNo,m_bossRelease,cType);
603 //cout<<cType<<" runfrm1,runto1 is:"<<runfrm1<<"::"<<runto1<<endl;
604 if (st1 .isFailure() )
605 {
606 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
607 return st1;
608 }
609 ret = m_meta->getReadMDCInfo(ser,&runfrm,&runto,m_calPar[0],res,runNo,m_bossver[0]);
610 }
611 }
612 else if((cType=="MdcCal")&&(m_bossver[0]!= "default"))
613 {
614 m_flag[0]="set";
615 flag=m_flag[0];
616 //cout<<"flag @create Mdc is:"<<m_flag[0]<<endl;
617 ret = m_meta->getReadMDCInfo(ser,&runfrm,&runto, m_calPar[0], res,runNo,m_bossver[0]);
618
619 }
620
621 //MucCalConst
622 if((cType=="MucCal")&&(m_bossver[4]== "default" ))
623 {
624 std::string cType="Muc";
625 if(m_bossRelease=="default")
626 {
627 log << MSG::FATAL << " Boss Release for MucCal not set!" << endreq;
628 exit(1);
629 }
630 else
631 {
632 st1=getSftParVer(m_bossver[4],m_calPar[4],runfrm1,runto1,runNo,m_bossRelease,cType);
633 if (st1 .isFailure() )
634 {
635 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
636 return st1;
637 }
638 ret = m_meta->getReadMUCInfo(ser,&runfrm,&runto, m_calPar[4], res,runNo,m_bossver[4]);
639 }
640 }
641 else if((cType=="MucCal")&&(m_bossver[4]!= "default" ))
642 {
643 m_flag[4]="set";
644 flag=m_flag[4];
645 //cout<<"flag @create Muc is:"<<m_flag[4]<<endl;
646 ret = m_meta->getReadMUCInfo(ser,&runfrm,&runto, m_calPar[4], res,runNo,m_bossver[4]);
647 }
648
649 //EsTimeCal
650 if((cType=="EsTimeCal")&&(m_bossver[5]== "default" ))
651 {
652 std::string cType="EsTime";
653 if(m_bossRelease=="default")
654 {
655 log << MSG::FATAL << " Boss Release for EsTimeCal not set!" << endreq;
656 exit(1);
657 }
658 else
659 {
660 st1=getSftParVer(m_bossver[5],m_calPar[5],runfrm1,runto1,runNo,m_bossRelease,cType);
661 if (st1 .isFailure() )
662 {
663 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
664 return st1;
665 }
666 ret = m_meta->getReadEsTimeInfo(ser,&runfrm,&runto,m_calPar[5], res,runNo,m_bossver[5]);
667 }
668 }
669 else if((cType=="EsTimeCal")&&(m_bossver[5]!= "default" ))
670 {
671 m_flag[5]="set";
672 flag=m_flag[5];
673 //cout<<"flag @create EsTime is:"<<m_flag[5]<<endl;
674 ret = m_meta->getReadEsTimeInfo(ser,&runfrm,&runto, m_calPar[5], res,runNo,m_bossver[5]);
675 }
676
677 //MdcAlign
678 if((cType=="MdcAlign")&&(m_bossver[7]== "default" ))
679 {
680 std::string cType="MdcAlign";
681 if(m_bossRelease=="default") {
682 log << MSG::FATAL << " Boss Release for MdcAlignCal not set!" << endreq;
683 exit(1);
684 }
685 else {
686 st1=getSftParVer(m_bossver[7],m_calPar[7],runfrm1,runto1,runNo,m_bossRelease,cType);
687 if (st1 .isFailure() ) {
688 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
689 return st1;
690 }
691 ret = m_meta->getReadMdcAlignInfo(ser,&runfrm,&runto,m_calPar[7], res,runNo,m_bossver[7]);
692 }
693 }
694 else if((cType=="MdcAlign")&&(m_bossver[7]!= "default" ))
695 {
696 m_flag[7]="set";
697 flag=m_flag[7];
698 //cout<<"flag @create MdcAlign is:"<<m_flag[7]<<endl;
699 ret = m_meta->getReadMdcAlignInfo(ser,&runfrm,&runto, m_calPar[7], res,runNo,m_bossver[7]);
700 }
701
702 //TofQElec
703 if((cType=="TofQElec")&&(m_bossver[8]== "default" ))
704 {
705 std::string cType="TofQElec";
706 if(m_bossRelease=="default") {
707 log << MSG::FATAL << " Boss Release for TofQElecCal not set!" << endreq;
708 exit(1);
709 }
710 else {
711 //cout<<"TofQElec @create"<<endl;
712 st1=getSftParVer(m_bossver[8],m_calPar[8],runfrm1,runto1,runNo,m_bossRelease,cType);
713 if (st1 .isFailure() ) {
714 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
715 return st1;
716 }
717 ret = m_meta->getReadTofQElecInfo(ser,&runfrm,&runto,m_calPar[8],res,runNo,m_bossver[8]);
718 }
719 }
720 else if((cType=="TofQElec")&&(m_bossver[8]!= "default" ))
721 {
722 m_flag[8]="set";
723 flag=m_flag[8];
724 //cout<<"flag @create TofQElec is:"<<flag<<endl;
725 ret = m_meta->getReadTofQElecInfo(ser,&runfrm,&runto, m_calPar[8], res,runNo,m_bossver[8]);
726 }
727
728 //TofSim
729 if((cType=="TofSim")&&(m_bossver[9]== "default" ))
730 {
731 std::string cType="TofSim";
732 if(m_bossRelease=="default") {
733 log << MSG::FATAL << " Boss Release for TofSimCal not set!" << endreq;
734 exit(1);
735 }
736 else {
737 st1=getSftParVer(m_bossver[9],m_calPar[9],runfrm1,runto1,runNo,m_bossRelease,cType);
738 if (st1 .isFailure() ) {
739 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
740 return st1;
741 }
742 ret = m_meta->getReadTofSimInfo(ser,&runfrm,&runto, m_calPar[9], res,runNo,m_bossver[9]);
743 }
744 }
745 else if((cType=="TofSim")&&(m_bossver[9]!= "default" ))
746 {
747 m_flag[9]="set";
748 flag=m_flag[9];
749 //cout<<"flag @create TofSim is:"<<m_flag[9]<<endl;
750 ret = m_meta->getReadTofSimInfo(ser,&runfrm,&runto, m_calPar[9], res,runNo,m_bossver[9]);
751 }
752
753 //DedxSim
754 if((cType=="DedxSim")&&(m_bossver[10]== "default" ))
755 {
756 std::string cType="DedxSim";
757 if(m_bossRelease=="default") {
758 log << MSG::FATAL << " Boss Release for DedxSimCal not set!" << endreq;
759 exit(1);
760 }
761 else {
762 st1=getSftParVer(m_bossver[10],m_calPar[10],runfrm1,runto1,runNo,m_bossRelease,cType);
763 if (st1 .isFailure() ) {
764 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
765 return st1;
766 }
767 ret = m_meta->getReadDedxSimInfo(ser,&runfrm,&runto,m_calPar[10], res,runNo,m_bossver[10]);
768 }
769 }
770 else if((cType=="DedxSim")&&(m_bossver[10]!= "default" ))
771 {
772 m_flag[10]="set";
773 flag=m_flag[10];
774 //cout<<"flag @create DedxSim is:"<<m_flag[10]<<endl;
775 ret = m_meta->getReadDedxSimInfo(ser,&runfrm,&runto, m_calPar[10], res,runNo,m_bossver[10]);
776 }
777
778 //MdcDataConst
779 if((cType=="MdcDataConst")&&(m_bossver[11]== "default" ))
780 {
781 std::string cType="MdcData";
782 if(m_bossRelease=="default") {
783 log << MSG::FATAL << " Boss Release for MdcDataConst not set!" << endreq;
784 exit(1);
785 }
786 else {
787 st1=getSftParVer(m_bossver[11],m_calPar[11],runfrm1,runto1,runNo,m_bossRelease,cType);
788 if (st1 .isFailure() ) {
789 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
790 return st1;
791 }
792 ret = m_meta->getReadMdcDataConstInfo(ser,&runfrm,&runto,m_calPar[11], res,runNo,m_bossver[11]);
793 }
794 }
795 else if((cType=="MdcDataConst")&&(m_bossver[11]!= "default" ))
796 {
797 m_flag[11]="set";
798 flag=m_flag[11];
799 //cout<<"flag @create MdcData is:"<<m_flag[11]<<endl;
800 ret = m_meta->getReadMdcDataConstInfo(ser,&runfrm,&runto, m_calPar[11], res,runNo,m_bossver[11]);
801 }
802
803 //EstTofCalConst
804 if((cType=="EstTofCal")&&(m_bossver[6]== "default" ))
805 {
806 std::string cType="EsTof";
807 if(m_bossRelease=="default") {
808 log << MSG::FATAL << " Boss Release for EstTofCal not set!" << endreq;
809 exit(1);
810 }
811 else {
812 st1=getSftParVer(m_bossver[6],m_calPar[6],runfrm1,runto1,runNo,m_bossRelease,cType);
813 if (st1 .isFailure() ) {
814 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
815 return st1;
816 }
817 ret = m_meta->getReadEstTofInfo(ser,&runfrm,&runto,m_calPar[6],res,runNo,m_bossver[6]);
818 }
819 }
820 else if((cType=="EstTofCal")&&(m_bossver[6]!= "default" ))
821 {
822 m_flag[6]="set";
823 flag=m_flag[6];
824 //cout<<"flag @create EstTof is:"<<m_flag[6]<<endl;
825 ret = m_meta->getReadEstTofInfo(ser,&runfrm,&runto, m_calPar[6], res,runNo,m_bossver[6]);
826 }
827
829 log << MSG::ERROR << "no record in the database" << endreq;
830 exit(1);
831 }
832 int sz=res.size();
833 DatabaseRecord* records1 = res[0];
834// DatabaseRecord* records2 = res1[0];
835 // runfrm1=records1->GetInt("RunFrom");
836 // runto1=records1->GetInt("RunTo");
837 // cout<<cType<<" runfrm1,runto1 is:"<<runfrm3<<":::"<<runto3<<endl;
838 if(m_dbStatus=="OK"){
839 if(std::string((*records1)["Status"])!="OK") {
840 log<<MSG::FATAL<<"Status of type "<<cType<<" is "<< (*records1)["Status"]<<" your setting is OK"<<endreq;
841 exit(1);
842 }
843 }
844
845 log << MSG::DEBUG << "dataIdent is:"<<dataIdent<< endreq;
846 unsigned char storageType;
847 physFmt="TREE";
848 StatusCode sc = decodeDescription(physFmt, storageType);
849
850
851 // Depending on value of eDataFmt, figure out which private
852 // conversion service to invoke. Pass dataIdent and fmtVersion
853 // as part of the opaque address.
854 // Create temporary address for the relevant type and classID
855 log << MSG::DEBUG << "Creating an address of type "
856 << (int)storageType << " for class " << classID << endreq;
857
858 IOpaqueAddress* tmpAddress;
859 const std::string par[3] = {dataIdent, fullpath, fmtVersion};
860 //const unsigned long ipar[2] = {int(runfrm),int(runto)};
861 //log << MSG::DEBUG << "ipar is:"<<ipar[0]<<":"<<ipar[1]<<"ipar[1]"<<endreq;
862 const unsigned long ipar[2] = {0,0};//yzhang fix unsigned bug for runfrom runto
863
864 // sc = addressCreator()->createAddress(storageType, classID,
865 // par, ipar, tmpAddress);
866
867 tmpAddress = new TreeAddress(storageType, classID,*records1,ipar);
868 //sscanf((*records2)["RunFrom"], "%d", &runfrm1);
869 //sscanf((*records2)["RunTo"], "%d", &runto1);
870
871 cout<<cType<<" runfrm,runto @CalVtxLumVer is:"<<runfrm1<<":::"<<runto1<<endl;
872 sscanf((*records1)["RunFrom"], "%d", &runfrm);
873 sscanf((*records1)["RunTo"], "%d", &runto);
874 log << MSG::DEBUG << __LINE__<<" records @ runfrm is:"<<(*records1)["RunFrom"]<<" runto is:"<<(*records1)["RunTo"]<<" ser_no is:"<<ser<<endreq;
875 //log << MSG::DEBUG <<__LINE__<< " runfrm is:"<<runfrm<<" runto is:"<<runto<<" ser_no is:"<<ser<<endreq;
876 if(flag=="default")
877 {
878 if(runfrm1>runfrm)
879 {
880 runfrm=runfrm1;
881 }
882 if(runto1<runto)
883 {
884 runto=runto1;
885 }
886 }
887 if(flag=="set")
888 {
889 flag="default";
890 }
891 log << MSG::DEBUG <<__LINE__<< " runfrm of max is:"<<runfrm<<" runto min is:"<<runto<<endreq;
892 TreeAddress* treeAddress = dynamic_cast <TreeAddress*> (tmpAddress);
893 treeAddress->setRunFrom(runfrm);
894 treeAddress->setRunTo(runto);
895// log << MSG::DEBUG << __LINE__<<" records @ runfrm is:"<<(*records1)["RunFrom"]<<" runto is:"<<(*records1)["RunTo"]<<" ser_no is:"<<ser<<endreq;
896// log << MSG::DEBUG <<__LINE__<< " runfrm is:"<<runfrm<<" runto is:"<<runto<<" ser_no is:"<<ser<<endreq;
897 /*
898 if ( !sc.isSuccess() ) {
899 log << msgLevel << "Persistency service could not create a new address" << endreq;
900 if (m_crash) {
901 log << msgLevel << std::endl << "Exiting... " << std::endl << endreq;
902 exit(1);
903 }
904 return sc;
905 }
906 */
907 tmpAddress->addRef();
908
909 // Set the transient store registry for the object associated to this address
910 tmpAddress->setRegistry(entry);
911
912 // Now create the object
913 sc = m_detPersSvc->createObj(tmpAddress, refpObject);
914 tmpAddress->release();
915 if ( !sc.isSuccess() ) {
916 log << msgLevel
917 << "Persistency service could not create a new object" << endreq;
918 if (m_crash) {
919 log << msgLevel << std::endl << "Exiting... " << std::endl << endreq;
920 exit(1);
921 }
922 return sc;
923 }
924 // std::cout<<" CalibMySQLCnvSvc res.size()=="<<res.size()<<std::endl;
925 res.clear();
926 log << MSG::DEBUG << "New object successfully created" << endreq;
927 return StatusCode::SUCCESS;
928 f1->Close();
929 delete f1;
930}
TFile * f1
int runNo
static std::string getCalibType(const std::string &fullpath)
Return calibration type name, extracted from full path name in TCDS.
virtual StatusCode decodeDescription(const std::string &description, unsigned char &type)
Decode the string storage type to enumerated storage type.
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
void setRunFrom(int runFrom)
set run from
Definition: TreeAddress.h:140
void setRunTo(int runTo)
set run to
Definition: TreeAddress.h:144
eRet getReadMdcDataConstInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:719
eRet getReadEsTimeInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:551
eRet getReadTOFInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:376
eRet getReadDedxSimInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:653
eRet getReadMUCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:409
eRet getReadEstTofInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:585
eRet getReadTofSimInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:618
eRet getReadDedxInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:517
eRet getReadMdcAlignInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:686
eRet getReadMDCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:446
eRet getReadTofQElecInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:751
eRet getReadEMCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition: Metadata.cxx:483

Referenced by createObj().

◆ createObj()

StatusCode CalibMySQLCnvSvc::createObj ( IOpaqueAddress *  pAddress,
DataObject *&  refpObject 
)
virtual

Create a transient representation from another rep of this object.

Create a transient representation from another representation of an object. Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters. (The typical conversion service delegates this to an appropriate converter)

Definition at line 248 of file CalibMySQLCnvSvc.cxx.

249 {
250
251 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
252
253
254 // Create the object according to calib type, flavor, time, instrument, clid.
255 // Notice that the CalibMySQLCnvSvc has no converters of its own:
256 // object creation is delegated to another CnvSvc via a temporary address
257 // The IOpaqueAddress specifies calibration type and specific flavor.
258 // The secondary storage type is always discovered dynamically
259 StatusCode sc;
260
261 sc = createCalib(refpObject,
262 pAddress->par()[0],
263 pAddress->clID(),
264 pAddress->registry() );
265
266
267 if ( !sc.isSuccess() ) {
268 log << MSG::ERROR << "Could not create calib DataObject" << endreq;
269 }
270 log << MSG::DEBUG << "Method createObj exiting" << endreq;
271 return sc;
272}
virtual StatusCode createCalib(DataObject *&refpObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)

◆ createRep()

StatusCode CalibMySQLCnvSvc::createRep ( DataObject *  pObject,
IOpaqueAddress *&  refpAddress 
)
virtual

Convert a transient object to a requested representation.

Convert a transient object to a requested representation. Not implemented. Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.

Definition at line 324 of file CalibMySQLCnvSvc.cxx.

325 {
326
327 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
328 // log << MSG::WARNING << "Method createRep is not implemented" << endreq;
329 return StatusCode::SUCCESS;
330}

◆ decodeDescription()

StatusCode CalibMySQLCnvSvc::decodeDescription ( const std::string &  description,
unsigned char &  type 
)
virtual

Decode the string storage type to enumerated storage type.

Definition at line 1352 of file CalibMySQLCnvSvc.cxx.

1354{
1355 MsgStream log(msgSvc(), "CalibMySQLCnvSvc");
1356
1357 // description ="ROOT";
1358 if (description == std::string("XML")) {
1359 type = XML_StorageType;
1360 }
1361 else if (description == std::string("ROOT")) {
1362 type = CALIBROOT_StorageType;
1363 }
1364 else if (description == std::string("TREE")) {
1365 type = CALIBTREE_StorageType;
1366 }
1367 else { // unsupported
1368 log << MSG::ERROR << "unsupported storage type " << description << endreq;
1369 return StatusCode::FAILURE;
1370 }
1371 return StatusCode::SUCCESS;
1372}
unsigned const char CALIBROOT_StorageType
Definition: ICalibRootSvc.h:20
unsigned const char CALIBTREE_StorageType
Definition: ICalibTreeSvc.h:20

Referenced by createCalib(), and updateCalib().

◆ fillObjRefs()

StatusCode CalibMySQLCnvSvc::fillObjRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
)
virtual

Resolve the references of the created transient object.

Resolve the references of the created transient object. (Actually, don't, because this operation isn't supported, nor is it needed for the conversion service.) Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.

Definition at line 278 of file CalibMySQLCnvSvc.cxx.

279 {
280 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
281 return StatusCode::SUCCESS;
282}

◆ fillRepRefs()

StatusCode CalibMySQLCnvSvc::fillRepRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
)
virtual

Resolve the references of a converted object.

Resolve the references of a converted object. [actually, don't. Calib data doesn't have any inter-object references.] Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.

Definition at line 336 of file CalibMySQLCnvSvc.cxx.

337 {
338 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
339 // log << MSG::WARNING << "Method fillRepRefs is not implemented" << endreq;
340 return StatusCode::SUCCESS;
341}

◆ finalize()

StatusCode CalibMySQLCnvSvc::finalize ( )
virtual

Definition at line 220 of file CalibMySQLCnvSvc.cxx.

221{
222 MsgStream log(msgSvc(), "CalibMySQLCnvSvc");
223 log << MSG::DEBUG << "Finalizing" << endreq;
224 delete m_meta;
225 m_meta = 0;
226 return ConversionSvc::finalize();
227}

◆ getMeta()

calibUtil::Metadata * CalibMySQLCnvSvc::getMeta ( )
virtual

Handle to the MySQL metadata database.

Implements ICalibMetaCnvSvc.

Definition at line 1376 of file CalibMySQLCnvSvc.cxx.

1376 {
1377 return m_meta;
1378}

◆ getSftParVer()

StatusCode CalibMySQLCnvSvc::getSftParVer ( std::string &  SftVer,
std::string &  CalParVer,
int &  runfrm,
int &  runto,
int  RunNo,
std::string  BossRelease,
std::string  DataType 
)

Definition at line 393 of file CalibMySQLCnvSvc.cxx.

401{
402 using namespace rdbModel;
403 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
404 char stmt[300];
405 int run_No =RunNo;
406 MYSQL_RES *res_set;
407 IDatabaseSvc* m_dbsvc;
409 StatusCode sc=serviceLocator()->service("DatabaseSvc",m_dbsvc,true);
410 if (sc .isFailure() ) {
411 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
412 return sc;
413 }
414
415 const char* bossRelease = BossRelease.c_str();
416 const char* dataType = DataType.c_str();
417
418 sprintf(stmt,"select RunFrom,RunTo,SftVer,ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType='%s' ",bossRelease,run_No,run_No,dataType);
419
420 int row_no = m_dbsvc->query("offlinedb",stmt,res);
421 if(row_no<1){
422 std::cout<<"ERROR:error searching with:"<<stmt<<std::endl;
423 exit(1);
424 }
425 if(row_no=1){
426 DatabaseRecord* records1 = res[0];
427 runfrm=records1->GetInt("RunFrom");
428 runto=records1->GetInt("RunTo");
429 //cout<<dataType<<" runfrm,runto in getSftParVer is:"<<runfrm<<"::::"<<runto<<endl;
430 SftVer=records1->GetString("SftVer");
431 CalParVer=records1->GetString("ParVer");
432 }
433 if(row_no>1){
434 cout<<"ERROR: "<<dataType<<" set overlapped run number in the table CalVtxLumVer"<<endl;
435 exit(1);
436 }
437 return StatusCode::SUCCESS;
438}
struct st_mysql_res MYSQL_RES
int GetInt(std::string key)
std::string GetString(std::string key)
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

Referenced by createCalib(), and updateCalib().

◆ initialize()

StatusCode CalibMySQLCnvSvc::initialize ( )
virtual

Definition at line 124 of file CalibMySQLCnvSvc.cxx.

125{
126 // Initialize base class
127 StatusCode sc = ConversionSvc::initialize();
128 if ( !sc.isSuccess() ) return sc;
129
130 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
131 log << MSG::INFO << "Specific initialization starting" << endreq;
132
133 IDataProviderSvc* pCDS = 0;
134 sc = serviceLocator()->getService ("CalibDataSvc", IDataProviderSvc::interfaceID(), (IInterface*&)pCDS);
135
136 if ( !sc.isSuccess() ) {
137 log << MSG::ERROR << "Could not locate CalibDataSvc" << endreq;
138 return sc;
139 }
140
141 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
142 if (sc .isFailure() ) {
143 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
144 return sc;
145 }
146
147 // Set the CalibDataSvc as data provider service
148 sc = setDataProvider(pCDS);
149 if ( !sc.isSuccess() ) {
150 log << MSG::ERROR << "Could not set data provider" << endreq;
151 return sc;
152 }
153
154 // Query the IAddressCreator interface of the detector persistency service
155
156 sc = serviceLocator()->service
157 ("DetectorPersistencySvc", m_detPersSvc, true);
158 if ( !sc.isSuccess() ) {
159 log << MSG::ERROR
160 << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
161 << endreq;
162 return sc;
163 } else {
164 log << MSG::DEBUG
165 << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
166 << endreq;
167 }
168
169 IAddressCreator* iAddrCreator;
170 sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(),(void**) &iAddrCreator);
171 // sc = m_detPersSvc->queryInterface(IID_IAddressCreator,(void**) &iAddrCreator);
172 if ( !sc.isSuccess() ) {
173 log << MSG::ERROR << "Could not locate CalibDataSvc" << endreq;
174 return sc;
175 }
176
177 sc = setAddressCreator(iAddrCreator);
178 if ( !sc.isSuccess() ) {
179 log << MSG::ERROR << "Cannot set the address creator" << endreq;
180 return sc;
181 }
182
183 // Get properties from the JobOptionsSvc
184 sc = setProperties();
185 if ( !sc.isSuccess() ) {
186 log << MSG::ERROR << "Could not set jobOptions properties" << endreq;
187 return sc;
188 }
189 log << MSG::DEBUG << "Properties were read from jobOptions" << endreq;
190
191 // Translate list of calibration quality names to bit mask form used
192 // by calibUtil::Metadata::findBest Defaults to PROD + DEV for now
193 // (that was old fixed value)
194 m_qualityMask = toQualityMask(m_qualityList);
195 if (!m_qualityMask) {
196 m_qualityMask = calibUtil::Metadata::LEVELProd |
198 }
199
200 // Make a calibUtil::Metadata instance
201 // Conceivably, could start up a different conversion service, depending
202 // on job options parameters, which would look very much like this one
203 // except for having a different way to access metadata.
204 m_meta = new calibUtil::Metadata(m_host, "*", m_dbName);
205
206 if (!m_meta) {
207 log << MSG::ERROR << "Could not open connection to metadata dbs" << endreq;
208 return MSG::ERROR;
209 }
210 // Probably should get this value from job options.
211 // Now we do. See m_qualityMask, m_qualityList
212 // m_calibLevelMask = calibUtil::Metadata::LEVELProd +
213 // calibUtil::Metadata::LEVELDev;
214
215 log << MSG::INFO << "Specific initialization completed" << endreq;
216 return sc;
217}

◆ queryInterface()

StatusCode CalibMySQLCnvSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Definition at line 230 of file CalibMySQLCnvSvc.cxx.

232{
233 if ( IID_ICalibMetaCnvSvc == riid ) {
234 // With the highest priority return the specific interface of this service
235 *ppvInterface = (ICalibMetaCnvSvc*)this;
236 } else {
237 // Interface is not directly available: try out a base class
238 return ConversionSvc::queryInterface(riid, ppvInterface);
239 }
240 addRef();
241 return StatusCode::SUCCESS;
242}

◆ updateCalib()

StatusCode CalibMySQLCnvSvc::updateCalib ( DataObject *  pObject,
const std::string &  fullpath,
const CLID &  classID,
IRegistry *  entry = 0 
)
virtual

Update a condition DataObject by This method does not register DataObject in the transient data store. The string storage type is discovered at runtime in the metadata dbs.

Update a calib DataObject by calib type, flavor,and instrument if necessary. This method does not register DataObject in the transient data store, The string storage type is discovered at runtime in the MySQL dbs. Implementation:

  • create a temporary address containing storage type and classID;
  • dispatch to appropriate conversion service according to storage type;
  • this will dispatch to appropriate converter according to CLID (the CalibMySQLCnvSvc has no converters of its own).

Implements ICalibMetaCnvSvc.

Definition at line 943 of file CalibMySQLCnvSvc.cxx.

947{
949
950 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
951 StatusCode status;
952
953 std::string testfile = std::string(getenv("CALIBMYSQLCNVROOT"))+"/share/test.root";
954 TFile *f1=new TFile(testfile.c_str(),"read");
955
956
957 // Look up calib object in the Metadata database
958 //std::string flavor = CalibData::CalibModelSvc::getFlavor(fullpath);
959 std::string cType = CalibData::CalibModelSvc::getCalibType(fullpath);
960
961 // ..and extra special munging for test
962 if (std::string("Test") == cType.substr(0, 4)) {
963 cType = std::string("Test_Gen");
964 }
965
966 if (0 == pObject) {
967 log << MSG::ERROR << "There is no DataObject to update" << endreq;
968 return StatusCode::FAILURE;
969 }
970 // Is object an instance of the specified class?
971 if(pObject->clID()!=6411&& classID!=6411){
972 if ( classID != pObject->clID() ) {
973 log << MSG::ERROR << "Update requested for clID " << classID
974 << " while DataObject is of clID "
975 << pObject->clID() << endreq;
976 exit(1);
977 return StatusCode::FAILURE;
978 }
979 }
980
981 // check if already valid. If so, we're done.
982 // Need access to IValidity interface
983 CalibBase1* pBase = dynamic_cast<CalibBase1*>(pObject);
984 if (pBase == 0) {
985 log << MSG::WARNING
986 << "Object to be updated is not a calib object! " << endreq;
987 return StatusCode::FAILURE;
988 }
989
990 // Following comes from createCalib. Perhaps create and update
991 // should be calling common utility since much of what they do is identical.
992 unsigned int ser;
993 int runfrm,runfrm1;
994 int runto,runto1;
996
997 // calibUtil::Metadata::eDataFmt physFmt = calibUtil::Metadata::FMTUnknown;
998 std::string physFmt;
999 std::string fmtVersion;
1000 std::string dataIdent;
1001 std::string flag="default";
1002 // Get the information needed to find and interpret the bulk data:
1003 // * physical storage type
1004 // * version of the physical format
1005 // * pathname or similar identifying information so the data can be found
1006 // maqm comment remove fmtversion :
1007 // ret = m_meta->getReadInfo(ser, physFmt, fmtVersion, dataIdent);
1008
1009 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event/EventHeader");
1010 int runNo=0;
1011 if( !evt ){
1012 log << MSG::WARNING << "Unable to read the Event for TDS" << endreq;
1013 // return StatusCode::FAILURE;
1014 }
1015
1016 // eRet ret;
1017
1019 StatusCode st1;
1020 if( evt ){
1021 if(cType!="TofCal"&&cType!="EstTofCal"&&cType!="TofSim"&&cType!="DedxSim") runNo = fabs(evt -> runNumber());
1022 if(cType=="TofCal"||cType=="EstTofCal"||cType=="TofSim"||cType=="DedxSim") runNo = evt -> runNumber();
1023 }
1024
1025 //TofCalConst
1026 if((cType=="TofCal"))
1027 {
1028 std::string cType="Tof";
1029 if(m_flag[3]=="default")
1030 {
1031 st1=getSftParVer(m_bossver[3],m_calPar[3],runfrm1,runto1,runNo,m_bossRelease,cType);
1032 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1033 if (st1 .isFailure() )
1034 {
1035 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1036 return st1;
1037 }
1038 }
1039
1040 flag=m_flag[3];
1041
1042 //cout<<"flag @update Tof is:"<<flag<<endl;
1043 //cout<<"SftVer and CalParVer are:"<<sft_ver<<";"<<cal_ver<<endl;
1044 ret = m_meta->getReadTOFInfo(ser,&runfrm,&runto,m_calPar[3],res,runNo,m_bossver[3]);
1045 }
1046
1047 //EmcCalConst
1048 if((cType=="EmcCal"))
1049 {
1050 std::string cType="Emc";
1051 if(m_flag[2]=="default")
1052 {
1053 st1=getSftParVer(m_bossver[2],m_calPar[2],runfrm1,runto1,runNo,m_bossRelease,cType);
1054 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1055 if (st1 .isFailure() )
1056 {
1057 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1058 return st1;
1059 }
1060 }
1061 flag=m_flag[2];
1062 //cout<<"flag @update Emc is:"<<m_flag[2]<<endl;
1063 ret = m_meta->getReadEMCInfo(ser,&runfrm,&runto, m_calPar[2], res,runNo,m_bossver[2]);
1064 }
1065
1066
1067
1068 //DedxCalConst
1069 if((cType=="DedxCal"))
1070 {
1071 std::string cType="Dedx";
1072 if(m_flag[1]=="default")
1073 {
1074 st1=getSftParVer(m_bossver[1],m_calPar[1],runfrm1,runto1,runNo,m_bossRelease,cType);
1075 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1076 if (st1 .isFailure() )
1077 {
1078 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1079 return st1;
1080 }
1081 }
1082 flag=m_flag[1];
1083 //cout<<"flag @update Dedx is:"<<m_flag[1]<<endl;
1084 ret = m_meta->getReadDedxInfo(ser,&runfrm,&runto, m_calPar[1], res,runNo,m_bossver[1]);
1085 }
1086
1087 //MdcCalConst
1088 if((cType=="MdcCal"))
1089 {
1090 std::string cType="Mdc";
1091 if(m_flag[0]=="default")
1092 {
1093 //cout<<"cType is"<<cType<<"m_bossver[0] is:"<<m_bossver[0]<<endl;
1094 st1=getSftParVer(m_bossver[0],m_calPar[0],runfrm1,runto1,runNo,m_bossRelease,cType);
1095 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1096 if (st1 .isFailure() )
1097 {
1098 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1099 return st1;
1100 }
1101 }
1102 flag=m_flag[0];
1103 //cout<<"flag @update Mdc is:"<<m_flag[0]<<endl;
1104 ret = m_meta->getReadMDCInfo(ser,&runfrm,&runto,m_calPar[0],res,runNo,m_bossver[0]);
1105 }
1106
1107 //MucCalConst
1108 if((cType=="MucCal"))
1109 {
1110 std::string cType="Muc";
1111 if(m_flag[4]=="default")
1112 {
1113 st1=getSftParVer(m_bossver[4],m_calPar[4],runfrm1,runto1,runNo,m_bossRelease,cType);
1114 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1115 if (st1 .isFailure() )
1116 {
1117 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1118 return st1;
1119 }
1120 }
1121 flag=m_flag[4];
1122 //cout<<"flag @update Muc is:"<<m_flag[4]<<endl;
1123 ret = m_meta->getReadMUCInfo(ser,&runfrm,&runto, m_calPar[4], res,runNo,m_bossver[4]);
1124 }
1125
1126 //EsTimeCal
1127 if((cType=="EsTimeCal"))
1128 {
1129 std::string cType="EsTime";
1130 if(m_flag[5]=="default")
1131 {
1132 st1=getSftParVer(m_bossver[5],m_calPar[5],runfrm1,runto1,runNo,m_bossRelease,cType);
1133 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1134 if (st1 .isFailure() )
1135 {
1136 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1137 return st1;
1138 }
1139 }
1140 flag=m_flag[5];
1141 //cout<<"flag @update EsTime is:"<<m_flag[5]<<endl;
1142 ret = m_meta->getReadEsTimeInfo(ser,&runfrm,&runto,m_calPar[5], res,runNo,m_bossver[5]);
1143 }
1144
1145 //MdcAlign
1146 if((cType=="MdcAlign"))
1147 {
1148 std::string cType="MdcAlign";
1149 if(m_flag[7]=="default")
1150 {
1151 st1=getSftParVer(m_bossver[7],m_calPar[7],runfrm1,runto1,runNo,m_bossRelease,cType);
1152 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1153 if (st1 .isFailure() ) {
1154 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1155 return st1;
1156 }
1157 }
1158 flag=m_flag[7];
1159 //cout<<"flag @update MdcAlign is:"<<m_flag[7]<<endl;
1160 ret = m_meta->getReadMdcAlignInfo(ser,&runfrm,&runto,m_calPar[7], res,runNo,m_bossver[7]);
1161 }
1162
1163 //TofQElec
1164 if((cType=="TofQElec"))
1165 {
1166 std::string cType="TofQElec";
1167 if(m_flag[8]=="default")
1168 {
1169 //cout<<"TofQElec @update"<<endl;
1170 st1=getSftParVer(m_bossver[8],m_calPar[8],runfrm1,runto1,runNo,m_bossRelease,cType);
1171 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1172 }
1173 flag=m_flag[8];
1174 //cout<<"flag @update TofQElec is:"<<m_flag[8]<<endl;
1175 ret = m_meta->getReadTofQElecInfo(ser,&runfrm,&runto,m_calPar[8],res,runNo,m_bossver[8]);
1176 }
1177
1178 //TofSim
1179 if((cType=="TofSim"))
1180 {
1181 std::string cType="TofSim";
1182 if(m_flag[9]=="default")
1183 {
1184 st1=getSftParVer(m_bossver[9],m_calPar[9],runfrm1,runto1,runNo,m_bossRelease,cType);
1185 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1186 if (st1 .isFailure() ) {
1187 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1188 return st1;
1189 }
1190 }
1191 flag=m_flag[9];
1192 //cout<<"flag @update TofSim is:"<<m_flag[9]<<endl;
1193 ret = m_meta->getReadTofSimInfo(ser,&runfrm,&runto, m_calPar[9], res,runNo,m_bossver[9]);
1194 }
1195
1196 //DedxSim
1197 if((cType=="DedxSim"))
1198 {
1199 std::string cType="DedxSim";
1200 if(m_flag[10]=="default")
1201 {
1202 st1=getSftParVer(m_bossver[10],m_calPar[10],runfrm1,runto1,runNo,m_bossRelease,cType);
1203 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1204 if (st1 .isFailure() ) {
1205 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1206 return st1;
1207 }
1208 }
1209 flag=m_flag[10];
1210 //cout<<"flag @update DedxSim is:"<<m_flag[10]<<endl;
1211 ret = m_meta->getReadDedxSimInfo(ser,&runfrm,&runto,m_calPar[10], res,runNo,m_bossver[10]);
1212 }
1213
1214 //MdcDataConst
1215 if((cType=="MdcDataConst"))
1216 {
1217 std::string cType="MdcData";
1218 if(m_flag[11]=="default")
1219 {
1220 st1=getSftParVer(m_bossver[11],m_calPar[11],runfrm1,runto1,runNo,m_bossRelease,cType);
1221 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1222 if (st1 .isFailure() ) {
1223 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1224 return st1;
1225 }
1226 }
1227 flag=m_flag[11];
1228 //cout<<"flag @update MdcData is:"<<m_flag[11]<<endl;
1229 ret = m_meta->getReadMdcDataConstInfo(ser,&runfrm,&runto,m_calPar[11], res,runNo,m_bossver[11]);
1230 }
1231
1232 //EstTofCalConst
1233 if((cType=="EstTofCal"))
1234 {
1235 std::string cType="EsTof";
1236 if(m_flag[6]=="default")
1237 {
1238 st1=getSftParVer(m_bossver[6],m_calPar[6],runfrm1,runto1,runNo,m_bossRelease,cType);
1239 //cout<<cType<<" runfrm1,runto1 @update is:"<<runfrm1<<":::"<<runto1<<endl;
1240 if (st1 .isFailure() ) {
1241 log << MSG::ERROR << " Unable to find DatabaseSvc " << endreq;
1242 return st1;
1243 }
1244 }
1245 flag=m_flag[6];
1246 //cout<<"flag @update EstTof is:"<<m_flag[6]<<endl;
1247 ret = m_meta->getReadEstTofInfo(ser,&runfrm,&runto,m_calPar[6],res,runNo,m_bossver[6]);
1248 }
1249
1251 log << MSG::ERROR << "Error searching in the database" << endreq;
1252 exit(1);
1253 }
1254
1255 physFmt="TREE";
1256 unsigned char storageType;
1257 status = decodeDescription(physFmt, storageType);
1258
1259 // Depending on value of eDataFmt, figure out which private
1260 // conversion service to invoke. Pass dataIdent and fmtVersion
1261 // as part of the opaque address.
1262 // Create temporary address for the relevant type and classID
1263 log << MSG::DEBUG << "Creating an address of type "
1264 << (int)storageType << " for class " << classID << endreq;
1265
1266 // int sz=res.size();
1267 DatabaseRecord* records1 = res[0];
1268
1269 if(m_dbStatus=="OK"){
1270 if(std::string((*records1)["Status"])!="OK") {
1271 log<<MSG::FATAL<<"the status of type "<<cType<<" is "<< (*records1)["Status"]<<" your setting is OK"<<endreq;
1272 exit(1);
1273 }
1274 }
1275
1276
1277 IOpaqueAddress* tmpAddress;
1278 //const unsigned long ipar[2] = {runfrm,runto};
1279 const unsigned long ipar[2] = {0,0};//yzhang fix unsigned bug for runfrom runto
1280
1281 tmpAddress = new TreeAddress(storageType, classID,*records1,ipar);
1282 log << MSG::DEBUG <<__LINE__<<cType<<" runfrm,runto @CalVtxLumVer/update is:"<<runfrm1<<":::"<<runto1<<endreq;
1283 sscanf((*records1)["RunFrom"], "%d", &runfrm);
1284 sscanf((*records1)["RunTo"], "%d", &runto);
1285 log << MSG::DEBUG << __LINE__<<" records @update runfrm is:"<<(*records1)["RunFrom"]<<" runto is:"<<(*records1)["RunTo"]<<" ser_no is:"<<ser<<endreq;
1286 if(flag=="default")
1287 {
1288 if(runfrm1>runfrm)
1289 {
1290 runfrm=runfrm1;
1291 }
1292 if(runto1<runto)
1293 {
1294 runto=runto1;
1295 }
1296 }
1297 if(flag=="set")
1298 {
1299 flag=="default";
1300 }
1301
1302 log << MSG::DEBUG <<__LINE__<< " runfrm of max is:"<<runfrm<<" runto min is:"<<runto<<endreq;
1303 TreeAddress* treeAddress = dynamic_cast <TreeAddress*> (tmpAddress);
1304 treeAddress->setRunFrom(runfrm);
1305 treeAddress->setRunTo(runto);
1306 //log << MSG::DEBUG << __LINE__<<" records runfrm is:"<<(*records1)["RunFrom"]<<" runto is:"<<(*records1)["RunTo"]<<" ser_no is:"<<ser<<endreq;
1307 //log << MSG::DEBUG <<__LINE__<< " runfrm is:"<<runfrm<<" runto is:"<<runto<<" ser_no is:"<<ser<<endreq;
1308
1309 log << MSG::DEBUG << "Temporary address successfully created" << endreq;
1310 tmpAddress->addRef();
1311
1312 // Set the transient store registry for the object associated to this address
1313 tmpAddress->setRegistry(entry);
1314
1315 // Now update the object
1316 DataObject* pNewObject;
1317 status = m_detPersSvc->createObj(tmpAddress, pNewObject);
1318 tmpAddress->release();
1319 if ( !status.isSuccess() ) {
1320 log << MSG::ERROR
1321 << "Persistency service could not create object" << endreq;
1322 return status;
1323 }
1324
1325 // Since DataObject::operator= operator is not virtual, dynamic cast first!
1326 // Overloaded virtual method Condition::update() must be properly defined!
1327 // The memory pointed to by the old pointer must contain the new object
1328 // Note this dynamic cast only gets us part-way. The object is
1329 // actually of some type derived from CalibBase.
1330 CalibBase1* pNewBase = dynamic_cast<CalibBase1*>(pNewObject);
1331 if (0 == pNewBase) {
1332 log << MSG::ERROR
1333 << "Cannot update objects other than Calib objects: "
1334 << "update() must be defined!"
1335 << endreq;
1336 return StatusCode::FAILURE;
1337 }
1338
1339 // Deep copy the new calib into the old DataObject. To copy the *whole*
1340 // object, not just the CalibBase part, classes derived from CalibBase
1341 // must override update method.
1342 // NOTE: classes directly derived from CalibBase must call
1343 // CalibBase::update in their own update method.
1344 pBase->update(*pNewBase, &log);
1345 res.clear();
1346 f1->Close();
1347 delete f1;
1348 delete pNewBase;
1349 return StatusCode::SUCCESS;
1350}
virtual StatusCode update(CalibBase1 &obj, MsgStream *)
Definition: CalibBase1.cxx:33

Referenced by updateObj().

◆ updateObj()

StatusCode CalibMySQLCnvSvc::updateObj ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
)
virtual

Update a transient representation from another rep of this object.

Update a transient representation from another representation of an object. Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.

Definition at line 287 of file CalibMySQLCnvSvc.cxx.

288 {
289
290 // using facilities::Timestamp;
291
292 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
293
294 // Don't update when we're using enter time
295 log << MSG::DEBUG << "CalibMySQLCnvSvc::updateObj starting ...."<<endreq;
296
297 if( 0 == pObject ) {
298 log << MSG::ERROR << "There is no object to update" << endreq;
299 return StatusCode::FAILURE;
300 }
301
302 StatusCode sc = updateCalib(pObject, pAddress->par()[0],
303 pAddress->clID(), pAddress->registry() );
304 if ( !sc.isSuccess() ) {
305 log << MSG::ERROR << "Could not update calib DataObject" << endreq;
306 return sc;
307 }
308
309 return StatusCode::SUCCESS;
310}
virtual StatusCode updateCalib(DataObject *pObject, const std::string &fullpath, const CLID &classID, IRegistry *entry=0)

◆ updateObjRefs()

StatusCode CalibMySQLCnvSvc::updateObjRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
)
virtual

Update the references of an updated transient object.

Update the references of an updated transient object. [actually, don't. Calib data doesn't have any inter-object references.] Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.

Definition at line 315 of file CalibMySQLCnvSvc.cxx.

316 {
317 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
318 return StatusCode::SUCCESS;
319}

◆ updateRep()

StatusCode CalibMySQLCnvSvc::updateRep ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
)
virtual

Update a converted representation of a transient object.

Update a converted representation of a transient object. Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters.

Definition at line 346 of file CalibMySQLCnvSvc.cxx.

347 {
348 MsgStream log(msgSvc(), "CalibMySQLCnvSvc" );
349 // log << MSG::WARNING << "Method updateRep is not implemented" << endreq;
350 return StatusCode::SUCCESS;
351}

◆ updateRepRefs()

StatusCode CalibMySQLCnvSvc::updateRepRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
)
virtual

Update the references of an already converted object.

Update the references of an already converted object. Overloaded from ConversionSvc because CalibMySQLCnvSvc has no converters. Don't do anything because calib objects have no inter-object references.

Definition at line 357 of file CalibMySQLCnvSvc.cxx.

358 {
359 MsgStream log(msgSvc(), "CalibMySQLCnvSvc");
360 //log << MSG::WARNING << "Method updateRepRefs is not implemented" << endreq;
361 return StatusCode::SUCCESS;
362}

Friends And Related Function Documentation

◆ SvcFactory< CalibMySQLCnvSvc >

friend class SvcFactory< CalibMySQLCnvSvc >
friend

Only factories can access protected constructors.

Definition at line 1 of file CalibMySQLCnvSvc.h.


The documentation for this class was generated from the following files: