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;