10#include "GaudiKernel/IDataManagerSvc.h"
16#include "GaudiKernel/SmartDataPtr.h"
18#include "GaudiKernel/DataObject.h"
19#include "GaudiKernel/GenericAddress.h"
20#include "GaudiKernel/IConverter.h"
21#include "GaudiKernel/IDetDataSvc.h"
22#include "GaudiKernel/IDataProviderSvc.h"
23#include "GaudiKernel/IOpaqueAddress.h"
24#include "GaudiKernel/ISvcLocator.h"
25#include "GaudiKernel/IValidity.h"
26#include "GaudiKernel/MsgStream.h"
27#include "GaudiKernel/SvcFactory.h"
29#include "TBufferFile.h"
46 unsigned int toQualityMask(std::vector<std::string>& qualities) {
49 unsigned int mask = 0;
50 unsigned n = qualities.size();
52 for (
unsigned i = 0; i <
n; i++) {
53 std::string iString = qualities[i];
54 if (iString.size() < 3)
continue;
56 if (iString ==
"PRO") mask |= Metadata::LEVELProd;
57 else if (iString ==
"DEV") mask |= Metadata::LEVELDev;
58 else if (iString ==
"TES") mask |= Metadata::LEVELTest;
59 else if (iString ==
"SUP") mask |= Metadata::LEVELSuperseded;
66 : ConversionSvc (name, svc, MYSQL_StorageType)
67 , m_meta(0), m_useEventTime(
true),m_enterTimeStart(0), m_enterTimeEnd(0),
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(
"") );
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");
127 StatusCode sc = ConversionSvc::initialize();
128 if ( !sc.isSuccess() )
return sc;
130 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
131 log << MSG::INFO <<
"Specific initialization starting" << endreq;
133 IDataProviderSvc* pCDS = 0;
134 sc = serviceLocator()->getService (
"CalibDataSvc", IDataProviderSvc::interfaceID(), (IInterface*&)pCDS);
136 if ( !sc.isSuccess() ) {
137 log << MSG::ERROR <<
"Could not locate CalibDataSvc" << endreq;
141 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
142 if (sc .isFailure() ) {
143 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
148 sc = setDataProvider(pCDS);
149 if ( !sc.isSuccess() ) {
150 log << MSG::ERROR <<
"Could not set data provider" << endreq;
156 sc = serviceLocator()->service
157 (
"DetectorPersistencySvc", m_detPersSvc,
true);
158 if ( !sc.isSuccess() ) {
160 <<
"Cannot locate IConversionSvc interface of DetectorPersistencySvc"
165 <<
"Retrieved IConversionSvc interface of DetectorPersistencySvc"
169 IAddressCreator* iAddrCreator;
170 sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(),(
void**) &iAddrCreator);
172 if ( !sc.isSuccess() ) {
173 log << MSG::ERROR <<
"Could not locate CalibDataSvc" << endreq;
177 sc = setAddressCreator(iAddrCreator);
178 if ( !sc.isSuccess() ) {
179 log << MSG::ERROR <<
"Cannot set the address creator" << endreq;
184 sc = setProperties();
185 if ( !sc.isSuccess() ) {
186 log << MSG::ERROR <<
"Could not set jobOptions properties" << endreq;
189 log << MSG::DEBUG <<
"Properties were read from jobOptions" << endreq;
194 m_qualityMask = toQualityMask(m_qualityList);
195 if (!m_qualityMask) {
207 log << MSG::ERROR <<
"Could not open connection to metadata dbs" << endreq;
215 log << MSG::INFO <<
"Specific initialization completed" << endreq;
222 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc");
223 log << MSG::DEBUG <<
"Finalizing" << endreq;
226 return ConversionSvc::finalize();
233 if ( IID_ICalibMetaCnvSvc == riid ) {
238 return ConversionSvc::queryInterface(riid, ppvInterface);
241 return StatusCode::SUCCESS;
249 DataObject*& refpObject ) {
251 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
264 pAddress->registry() );
267 if ( !sc.isSuccess() ) {
268 log << MSG::ERROR <<
"Could not create calib DataObject" << endreq;
270 log << MSG::DEBUG <<
"Method createObj exiting" << endreq;
280 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
281 return StatusCode::SUCCESS;
288 DataObject* pObject ) {
292 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
295 log << MSG::DEBUG <<
"CalibMySQLCnvSvc::updateObj starting ...."<<endreq;
298 log << MSG::ERROR <<
"There is no object to update" << endreq;
299 return StatusCode::FAILURE;
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;
309 return StatusCode::SUCCESS;
317 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
318 return StatusCode::SUCCESS;
327 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
329 return StatusCode::SUCCESS;
338 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
340 return StatusCode::SUCCESS;
348 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
350 return StatusCode::SUCCESS;
359 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc");
361 return StatusCode::SUCCESS;
369 const std::string* par,
370 const unsigned long* ,
371 IOpaqueAddress*& refpAddress ) {
373 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
374 if ( svc_type!= MYSQL_StorageType ) {
376 <<
"Cannot create addresses of type " << (int)svc_type
377 <<
" which is different from " << (
int)MYSQL_StorageType
379 return StatusCode::FAILURE;
382 <<
" create address in CalibMySQLCnvSvc "
385 refpAddress =
new GenericAddress( MYSQL_StorageType,
389 return StatusCode::SUCCESS;
394 std::string& CalParVer,
398 std::string BossRelease,
403 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
409 StatusCode sc=serviceLocator()->service(
"DatabaseSvc",m_dbsvc,
true);
410 if (sc .isFailure() ) {
411 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
415 const char* bossRelease = BossRelease.c_str();
416 const char* dataType = DataType.c_str();
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);
420 int row_no = m_dbsvc->
query(
"offlinedb",stmt,res);
422 std::cout<<
"ERROR:error searching with:"<<stmt<<std::endl;
427 runfrm=records1->
GetInt(
"RunFrom");
428 runto=records1->
GetInt(
"RunTo");
434 cout<<
"ERROR: "<<dataType<<
" set overlapped run number in the table CalVtxLumVer"<<endl;
437 return StatusCode::SUCCESS;
454 const std::string& fullpath,
458 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
464 if (std::string(
"Test") == cType.substr(0, 4)) {
465 cType = std::string(
"Test_Gen");
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;
474 std::string flag=
"default";
477 MSG::Level msgLevel = MSG::DEBUG;
479 std::string physFmt =
"UNK";
480 std::string fmtVersion;
481 std::string dataIdent;
484 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,
"/Event/EventHeader");
487 log << MSG::WARNING <<
"Unable to read the Event for TDS" << endreq;
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();
499 if((cType==
"TofCal")&&(m_bossver[3]==
"default" ))
501 std::string cType=
"Tof";
502 if(m_bossRelease==
"default")
504 log << MSG::FATAL <<
" Boss Release for TofCal not set!" << endreq;
510 st1=
getSftParVer(m_bossver[3],m_calPar[3],runfrm1,runto1,
runNo,m_bossRelease,cType);
512 if (st1 .isFailure() )
514 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
522 else if ((cType==
"TofCal")&&(m_bossver[3]!=
"default" ))
532 if((cType==
"EmcCal")&&(m_bossver[2]==
"default" ))
534 std::string cType=
"Emc";
535 if(m_bossRelease==
"default")
537 log << MSG::FATAL <<
" Boss Release for EmcCal not set!" << endreq;
542 st1=
getSftParVer(m_bossver[2],m_calPar[2],runfrm1,runto1,
runNo,m_bossRelease,cType);
545 if (st1 .isFailure() )
547 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
553 else if((cType==
"EmcCal")&&(m_bossver[2]!=
"default" ))
562 if((cType==
"DedxCal")&&(m_bossver[1]==
"default" ))
564 std::string cType=
"Dedx";
565 if(m_bossRelease==
"default")
567 log << MSG::FATAL <<
" Boss Release for DedxCal not set!" << endreq;
572 st1=
getSftParVer(m_bossver[1],m_calPar[1],runfrm1,runto1,
runNo,m_bossRelease,cType);
574 if (st1 .isFailure() )
576 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
582 else if((cType==
"DedxCal")&&(m_bossver[1]!=
"default" ))
591 if((cType==
"MdcCal")&&(m_bossver[0]==
"default" ))
593 std::string cType=
"Mdc";
595 if(m_bossRelease==
"default")
597 log << MSG::FATAL <<
" Boss Release for MdcCal not set!" << endreq;
602 st1=
getSftParVer(m_bossver[0],m_calPar[0],runfrm1,runto1,
runNo,m_bossRelease,cType);
604 if (st1 .isFailure() )
606 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
612 else if((cType==
"MdcCal")&&(m_bossver[0]!=
"default"))
622 if((cType==
"MucCal")&&(m_bossver[4]==
"default" ))
624 std::string cType=
"Muc";
625 if(m_bossRelease==
"default")
627 log << MSG::FATAL <<
" Boss Release for MucCal not set!" << endreq;
632 st1=
getSftParVer(m_bossver[4],m_calPar[4],runfrm1,runto1,
runNo,m_bossRelease,cType);
633 if (st1 .isFailure() )
635 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
641 else if((cType==
"MucCal")&&(m_bossver[4]!=
"default" ))
650 if((cType==
"EsTimeCal")&&(m_bossver[5]==
"default" ))
652 std::string cType=
"EsTime";
653 if(m_bossRelease==
"default")
655 log << MSG::FATAL <<
" Boss Release for EsTimeCal not set!" << endreq;
660 st1=
getSftParVer(m_bossver[5],m_calPar[5],runfrm1,runto1,
runNo,m_bossRelease,cType);
661 if (st1 .isFailure() )
663 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
669 else if((cType==
"EsTimeCal")&&(m_bossver[5]!=
"default" ))
678 if((cType==
"MdcAlign")&&(m_bossver[7]==
"default" ))
680 std::string cType=
"MdcAlign";
681 if(m_bossRelease==
"default") {
682 log << MSG::FATAL <<
" Boss Release for MdcAlignCal not set!" << endreq;
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;
694 else if((cType==
"MdcAlign")&&(m_bossver[7]!=
"default" ))
703 if((cType==
"TofQElec")&&(m_bossver[8]==
"default" ))
705 std::string cType=
"TofQElec";
706 if(m_bossRelease==
"default") {
707 log << MSG::FATAL <<
" Boss Release for TofQElecCal not set!" << endreq;
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;
720 else if((cType==
"TofQElec")&&(m_bossver[8]!=
"default" ))
729 if((cType==
"TofSim")&&(m_bossver[9]==
"default" ))
731 std::string cType=
"TofSim";
732 if(m_bossRelease==
"default") {
733 log << MSG::FATAL <<
" Boss Release for TofSimCal not set!" << endreq;
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;
745 else if((cType==
"TofSim")&&(m_bossver[9]!=
"default" ))
754 if((cType==
"DedxSim")&&(m_bossver[10]==
"default" ))
756 std::string cType=
"DedxSim";
757 if(m_bossRelease==
"default") {
758 log << MSG::FATAL <<
" Boss Release for DedxSimCal not set!" << endreq;
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;
770 else if((cType==
"DedxSim")&&(m_bossver[10]!=
"default" ))
779 if((cType==
"MdcDataConst")&&(m_bossver[11]==
"default" ))
781 std::string cType=
"MdcData";
782 if(m_bossRelease==
"default") {
783 log << MSG::FATAL <<
" Boss Release for MdcDataConst not set!" << endreq;
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;
795 else if((cType==
"MdcDataConst")&&(m_bossver[11]!=
"default" ))
804 if((cType==
"EstTofCal")&&(m_bossver[6]==
"default" ))
806 std::string cType=
"EsTof";
807 if(m_bossRelease==
"default") {
808 log << MSG::FATAL <<
" Boss Release for EstTofCal not set!" << endreq;
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;
820 else if((cType==
"EstTofCal")&&(m_bossver[6]!=
"default" ))
829 log << MSG::ERROR <<
"no record in the database" << endreq;
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;
845 log << MSG::DEBUG <<
"dataIdent is:"<<dataIdent<< endreq;
846 unsigned char storageType;
855 log << MSG::DEBUG <<
"Creating an address of type "
856 << (int)storageType <<
" for class " << classID << endreq;
858 IOpaqueAddress* tmpAddress;
859 const std::string par[3] = {dataIdent, fullpath, fmtVersion};
862 const unsigned long ipar[2] = {0,0};
867 tmpAddress =
new TreeAddress(storageType, classID,*records1,ipar);
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;
891 log << MSG::DEBUG <<__LINE__<<
" runfrm of max is:"<<runfrm<<
" runto min is:"<<runto<<endreq;
907 tmpAddress->addRef();
910 tmpAddress->setRegistry(entry);
913 sc = m_detPersSvc->createObj(tmpAddress, refpObject);
914 tmpAddress->release();
915 if ( !sc.isSuccess() ) {
917 <<
"Persistency service could not create a new object" << endreq;
919 log << msgLevel << std::endl <<
"Exiting... " << std::endl << endreq;
926 log << MSG::DEBUG <<
"New object successfully created" << endreq;
927 return StatusCode::SUCCESS;
944 const std::string& fullpath,
950 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
953 std::string testfile = std::string(getenv(
"CALIBMYSQLCNVROOT"))+
"/share/test.root";
954 TFile *
f1=
new TFile(testfile.c_str(),
"read");
962 if (std::string(
"Test") == cType.substr(0, 4)) {
963 cType = std::string(
"Test_Gen");
967 log << MSG::ERROR <<
"There is no DataObject to update" << endreq;
968 return StatusCode::FAILURE;
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;
977 return StatusCode::FAILURE;
986 <<
"Object to be updated is not a calib object! " << endreq;
987 return StatusCode::FAILURE;
999 std::string fmtVersion;
1000 std::string dataIdent;
1001 std::string flag=
"default";
1009 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,
"/Event/EventHeader");
1012 log << MSG::WARNING <<
"Unable to read the Event for TDS" << endreq;
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();
1026 if((cType==
"TofCal"))
1028 std::string cType=
"Tof";
1029 if(m_flag[3]==
"default")
1031 st1=
getSftParVer(m_bossver[3],m_calPar[3],runfrm1,runto1,
runNo,m_bossRelease,cType);
1033 if (st1 .isFailure() )
1035 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1048 if((cType==
"EmcCal"))
1050 std::string cType=
"Emc";
1051 if(m_flag[2]==
"default")
1053 st1=
getSftParVer(m_bossver[2],m_calPar[2],runfrm1,runto1,
runNo,m_bossRelease,cType);
1055 if (st1 .isFailure() )
1057 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1069 if((cType==
"DedxCal"))
1071 std::string cType=
"Dedx";
1072 if(m_flag[1]==
"default")
1074 st1=
getSftParVer(m_bossver[1],m_calPar[1],runfrm1,runto1,
runNo,m_bossRelease,cType);
1076 if (st1 .isFailure() )
1078 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1088 if((cType==
"MdcCal"))
1090 std::string cType=
"Mdc";
1091 if(m_flag[0]==
"default")
1094 st1=
getSftParVer(m_bossver[0],m_calPar[0],runfrm1,runto1,
runNo,m_bossRelease,cType);
1096 if (st1 .isFailure() )
1098 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1108 if((cType==
"MucCal"))
1110 std::string cType=
"Muc";
1111 if(m_flag[4]==
"default")
1113 st1=
getSftParVer(m_bossver[4],m_calPar[4],runfrm1,runto1,
runNo,m_bossRelease,cType);
1115 if (st1 .isFailure() )
1117 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1127 if((cType==
"EsTimeCal"))
1129 std::string cType=
"EsTime";
1130 if(m_flag[5]==
"default")
1132 st1=
getSftParVer(m_bossver[5],m_calPar[5],runfrm1,runto1,
runNo,m_bossRelease,cType);
1134 if (st1 .isFailure() )
1136 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1146 if((cType==
"MdcAlign"))
1148 std::string cType=
"MdcAlign";
1149 if(m_flag[7]==
"default")
1151 st1=
getSftParVer(m_bossver[7],m_calPar[7],runfrm1,runto1,
runNo,m_bossRelease,cType);
1153 if (st1 .isFailure() ) {
1154 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1164 if((cType==
"TofQElec"))
1166 std::string cType=
"TofQElec";
1167 if(m_flag[8]==
"default")
1170 st1=
getSftParVer(m_bossver[8],m_calPar[8],runfrm1,runto1,
runNo,m_bossRelease,cType);
1179 if((cType==
"TofSim"))
1181 std::string cType=
"TofSim";
1182 if(m_flag[9]==
"default")
1184 st1=
getSftParVer(m_bossver[9],m_calPar[9],runfrm1,runto1,
runNo,m_bossRelease,cType);
1186 if (st1 .isFailure() ) {
1187 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1197 if((cType==
"DedxSim"))
1199 std::string cType=
"DedxSim";
1200 if(m_flag[10]==
"default")
1202 st1=
getSftParVer(m_bossver[10],m_calPar[10],runfrm1,runto1,
runNo,m_bossRelease,cType);
1204 if (st1 .isFailure() ) {
1205 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1215 if((cType==
"MdcDataConst"))
1217 std::string cType=
"MdcData";
1218 if(m_flag[11]==
"default")
1220 st1=
getSftParVer(m_bossver[11],m_calPar[11],runfrm1,runto1,
runNo,m_bossRelease,cType);
1222 if (st1 .isFailure() ) {
1223 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1233 if((cType==
"EstTofCal"))
1235 std::string cType=
"EsTof";
1236 if(m_flag[6]==
"default")
1238 st1=
getSftParVer(m_bossver[6],m_calPar[6],runfrm1,runto1,
runNo,m_bossRelease,cType);
1240 if (st1 .isFailure() ) {
1241 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
1251 log << MSG::ERROR <<
"Error searching in the database" << endreq;
1256 unsigned char storageType;
1263 log << MSG::DEBUG <<
"Creating an address of type "
1264 << (int)storageType <<
" for class " << classID << endreq;
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;
1277 IOpaqueAddress* tmpAddress;
1279 const unsigned long ipar[2] = {0,0};
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;
1302 log << MSG::DEBUG <<__LINE__<<
" runfrm of max is:"<<runfrm<<
" runto min is:"<<runto<<endreq;
1309 log << MSG::DEBUG <<
"Temporary address successfully created" << endreq;
1310 tmpAddress->addRef();
1313 tmpAddress->setRegistry(entry);
1316 DataObject* pNewObject;
1317 status = m_detPersSvc->createObj(tmpAddress, pNewObject);
1318 tmpAddress->release();
1319 if ( !status.isSuccess() ) {
1321 <<
"Persistency service could not create object" << endreq;
1331 if (0 == pNewBase) {
1333 <<
"Cannot update objects other than Calib objects: "
1334 <<
"update() must be defined!"
1336 return StatusCode::FAILURE;
1344 pBase->
update(*pNewBase, &log);
1349 return StatusCode::SUCCESS;
1353 unsigned char& type )
1355 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc");
1358 if (description == std::string(
"XML")) {
1359 type = XML_StorageType;
1361 else if (description == std::string(
"ROOT")) {
1364 else if (description == std::string(
"TREE")) {
1368 log << MSG::ERROR <<
"unsupported storage type " << description << endreq;
1369 return StatusCode::FAILURE;
1371 return StatusCode::SUCCESS;
unsigned const char CALIBROOT_StorageType
unsigned const char CALIBTREE_StorageType
struct st_mysql_res MYSQL_RES
virtual StatusCode update(CalibBase1 &obj, MsgStream *)
static std::string getCalibType(const std::string &fullpath)
Return calibration type name, extracted from full path name in TCDS.
virtual StatusCode finalize()
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)
Update a converted representation of a transient object.
virtual StatusCode decodeDescription(const std::string &description, unsigned char &type)
Decode the string storage type to enumerated storage type.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Resolve the references of the created transient object.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)
Create a transient representation from another rep of this 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 createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert a transient object to a requested representation.
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 fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Resolve the references of a converted object.
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Update the references of an updated transient object.
CalibMySQLCnvSvc(const std::string &name, ISvcLocator *svc)
virtual calibUtil::Metadata * getMeta()
Handle to the MySQL metadata database.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *pObject)
Update a transient representation from another rep of this object.
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
virtual ~CalibMySQLCnvSvc()
virtual StatusCode initialize()
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Update the references of an already converted object.
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
void setRunFrom(int runFrom)
set run from
void setRunTo(int runTo)
set run to