3#include "GaudiKernel/IDetDataSvc.h"
4#include "GaudiKernel/IConversionSvc.h"
5#include "GaudiKernel/IConverter.h"
7#include "GaudiKernel/MsgStream.h"
8#include "GaudiKernel/SvcFactory.h"
9#include "GaudiKernel/CnvFactory.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "GaudiKernel/IDataProviderSvc.h"
12#include "GaudiKernel/GenericAddress.h"
26 m_detPersSvc(0), m_detDataSvc(0) {
28 declareProperty(
"Mdcrootfile",m_rootfile[0]= std::string(
"no rootfile"));
29 declareProperty(
"Tofrootfile",m_rootfile[1]= std::string(
"no rootfile"));
30 declareProperty(
"Dedxrootfile",m_rootfile[2]= std::string(
"no rootfile"));
31 declareProperty(
"Emcrootfile",m_rootfile[3]= std::string(
"no rootfile"));
32 declareProperty(
"Mucrootfile",m_rootfile[4]= std::string(
"no rootfile"));
33 declareProperty(
"EsTimerootfile",m_rootfile[5]= std::string(
"no rootfile"));
34 declareProperty(
"EstTofrootfile",m_rootfile[6]= std::string(
"no rootfile"));
35 declareProperty(
"TofQElecrootfile",m_rootfile[7]= std::string(
"no rootfile"));
36 declareProperty(
"TofSimrootfile",m_rootfile[8]= std::string(
"no rootfile"));
37 declareProperty(
"DedxSimrootfile",m_rootfile[9]= std::string(
"no rootfile"));
39 declareProperty(
"InjSigIntervalrootfile",m_rootfile[10]= std::string(
"no rootfile"));
40 declareProperty(
"InjSigTimerootfile",m_rootfile[11]= std::string(
"no rootfile"));
41 declareProperty(
"OffEvtFilterrootfile",m_rootfile[12]= std::string(
"no rootfile"));
42 declareProperty(
"CorrectedETSrootfile",m_rootfile[13]= std::string(
"no rootfile"));
64 StatusCode sc = ConversionSvc::initialize();
66 MsgStream log(
msgSvc(),
"CalibRootCnvSvc");
68 if (!sc.isSuccess())
return sc;
75 sc = serviceLocator()->getService
76 (
"CalibDataSvc", IDataProviderSvc::interfaceID(),(IInterface*&) m_detDataSvc);
77 if ( !sc.isSuccess() ) {
78 log << MSG::ERROR <<
"Could not locate CalibDataSvc" << endreq;
87 sc = setDataProvider(m_detDataSvc);
88 if ( !sc.isSuccess() ) {
89 log << MSG::ERROR <<
"Could not set data provider" << endreq;
96 sc = serviceLocator()->service
97 (
"DetectorPersistencySvc", m_detPersSvc,
true);
98 if ( !sc.isSuccess() ) {
100 <<
"Cannot locate IConversionSvc interface of DetectorPersistencySvc"
105 <<
"Retrieved IConversionSvc interface of DetectorPersistencySvc"
110 IAddressCreator* iAddrCreator;
115 sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(),
116 (
void**) &iAddrCreator);
117 if ( !sc.isSuccess() ) {
119 <<
"Cannot query IAddressCreator interface of DetectorPersistencySvc"
124 <<
"Retrieved IAddressCreator interface of DetectorPersistencySvc"
128 <<
"Set it as the address creator of the CalibRootCnvSvc" << endreq;
129 sc = setAddressCreator(iAddrCreator);
130 if ( !sc.isSuccess() ) {
131 log << MSG::ERROR <<
"Cannot set the address creator" << endreq;
143 return ConversionSvc::finalize();
148 const std::string* par,
149 const unsigned long* ip,
150 IOpaqueAddress*& refpAddress) {
151 MsgStream log(
msgSvc(), name() );
152 log << MSG::DEBUG<<
"here is the createAddress in the CalibRootCnvSvc"<<endreq;
154 log << MSG::ERROR <<
"bad storage type" << (int)svc_type << endreq;
155 return StatusCode::FAILURE;
158 std::string dataIdent;
159 std::string fullpath;
161 if(clid==6412)
return StatusCode::SUCCESS;
193 log << MSG::WARNING<<
"Wrong CLID"<<endreq;
217 if(m_rootfile[index]==
"no rootfile")
219 log << MSG::INFO<<
"no sepcified calibration file path of type "<< index <<endreq;
220 return StatusCode::FAILURE;
239 log << MSG::INFO<<
"dataIdent is:"<<dataIdent<<endreq;
241 log << MSG::INFO<<
"fullpath is :"<<fullpath<<endreq;
259 return StatusCode::SUCCESS;
264 const std::string& tdsPath) {
265 MsgStream log(
msgSvc(), name() );
269 m_detDataSvc->findObject(tdsPath, pObj);
271 log <<
"No object in TDS with path " << tdsPath << endreq;
272 return StatusCode::FAILURE;
279 log <<
"Object with path " << tdsPath <<
" not of proper type" << endreq;
280 return StatusCode::FAILURE;
286 MsgStream log(
msgSvc(), name() );
288 IConverter* converter = ConversionSvc::converter(pCalib->clID());
290 log <<
"No converter found for object with CLID " << pCalib->clID()
292 return StatusCode::FAILURE;
296 log <<
"Converter for CLID " << pCalib->clID() <<
" not of proper type"
298 return StatusCode::FAILURE;
305 DataObject* pObject ) {
309 MsgStream log(
msgSvc(),
"CalibRootCnvSvc" );
312 log << MSG::DEBUG <<
"CalibRootCnvSvc::updateObj starting ...."<<endreq;
322 std::string& realpath )
324 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc");
330 std::string::size_type idx =oldpath.find(
"/");
331 if( std::string::npos != idx )
332 { std::string relpath;
333 for(
int i=1;i<idx-1;i++){
334 relpath[i-1] = oldpath[i];
336 std::string otherpath;
337 for(
int i=idx-1;i<oldpath.size();i++){
338 otherpath[i-idx+1]=oldpath[i];
340 realpath = std::string(getenv(relpath.c_str()))+otherpath;
342 if( std::string::npos == idx ){
344 for(
int i=1;i<oldpath.size();i++){
345 relpath[i-1] = oldpath[i];
347 realpath = std::string(getenv(relpath.c_str()));
351 return StatusCode::SUCCESS;
const CLID CLID_Calib_InjSigTime
const CLID CLID_Calib_EmcCal
const CLID CLID_Calib_TofSim
const CLID CLID_Calib_DedxCal
const CLID CLID_Calib_MdcCal
const CLID CLID_TofQ_Elec
const CLID CLID_Calib_InjSigInterval
const CLID CLID_Calib_TofCal
const CLID CLID_Calib_OffEvtFilter
const CLID CLID_Calib_CorrectedETS
const CLID CLID_Calib_MucCal
const CLID CLID_Calib_EsTimeCal
const CLID CLID_Calib_EstTofCal
unsigned const char CALIBROOT_StorageType
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *pObject)
virtual StatusCode finalize()
virtual StatusCode initialize()
StatusCode decodeDescription(const std::string &oldpath, std::string &realpath)
virtual StatusCode writeToRoot(const std::string &outputFile, const std::string &tdsPath)
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)