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"));
48 void** ppvInterface) {
50 if (IID_ICalibRootSvc.versionMatch(riid)) {
55 return ConversionSvc::queryInterface(riid, ppvInterface);
59return StatusCode::SUCCESS;
63 StatusCode sc = ConversionSvc::initialize();
65 MsgStream log(
msgSvc(),
"CalibRootCnvSvc");
67 if (!sc.isSuccess())
return sc;
74 sc = serviceLocator()->getService
75 (
"CalibDataSvc", IDataProviderSvc::interfaceID(),(IInterface*&) m_detDataSvc);
76 if ( !sc.isSuccess() ) {
77 log << MSG::ERROR <<
"Could not locate CalibDataSvc" << endreq;
86 sc = setDataProvider(m_detDataSvc);
87 if ( !sc.isSuccess() ) {
88 log << MSG::ERROR <<
"Could not set data provider" << endreq;
95 sc = serviceLocator()->service
96 (
"DetectorPersistencySvc", m_detPersSvc,
true);
97 if ( !sc.isSuccess() ) {
99 <<
"Cannot locate IConversionSvc interface of DetectorPersistencySvc"
104 <<
"Retrieved IConversionSvc interface of DetectorPersistencySvc"
109 IAddressCreator* iAddrCreator;
114 sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(),
115 (
void**) &iAddrCreator);
116 if ( !sc.isSuccess() ) {
118 <<
"Cannot query IAddressCreator interface of DetectorPersistencySvc"
123 <<
"Retrieved IAddressCreator interface of DetectorPersistencySvc"
127 <<
"Set it as the address creator of the CalibRootCnvSvc" << endreq;
128 sc = setAddressCreator(iAddrCreator);
129 if ( !sc.isSuccess() ) {
130 log << MSG::ERROR <<
"Cannot set the address creator" << endreq;
142 return ConversionSvc::finalize();
147 const std::string* par,
148 const unsigned long* ip,
149 IOpaqueAddress*& refpAddress) {
150 MsgStream log(
msgSvc(), name() );
151 log << MSG::DEBUG<<
"here is the createAddress in the CalibRootCnvSvc"<<endreq;
153 log << MSG::ERROR <<
"bad storage type" << (int)svc_type << endreq;
154 return StatusCode::FAILURE;
157 std::string dataIdent;
158 std::string fullpath;
160 if(clid==6412)
return StatusCode::SUCCESS;
192 log << MSG::WARNING<<
"Wrong CLID"<<endreq;
216 if(m_rootfile[index]==
"no rootfile")
218 log << MSG::INFO<<
"no sepcified calibration file path of type "<< index <<endreq;
219 return StatusCode::FAILURE;
238 log << MSG::INFO<<
"dataIdent is:"<<dataIdent<<endreq;
240 log << MSG::INFO<<
"fullpath is :"<<fullpath<<endreq;
258 return StatusCode::SUCCESS;
263 const std::string& tdsPath) {
264 MsgStream log(
msgSvc(), name() );
268 m_detDataSvc->findObject(tdsPath, pObj);
270 log <<
"No object in TDS with path " << tdsPath << endreq;
271 return StatusCode::FAILURE;
278 log <<
"Object with path " << tdsPath <<
" not of proper type" << endreq;
279 return StatusCode::FAILURE;
285 MsgStream log(
msgSvc(), name() );
287 IConverter* converter = ConversionSvc::converter(pCalib->clID());
289 log <<
"No converter found for object with CLID " << pCalib->clID()
291 return StatusCode::FAILURE;
295 log <<
"Converter for CLID " << pCalib->clID() <<
" not of proper type"
297 return StatusCode::FAILURE;
304 DataObject* pObject ) {
308 MsgStream log(
msgSvc(),
"CalibRootCnvSvc" );
311 log << MSG::DEBUG <<
"CalibRootCnvSvc::updateObj starting ...."<<endreq;
321 std::string& realpath )
323 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc");
329 std::string::size_type idx =oldpath.find(
"/");
330 if( std::string::npos != idx )
331 { std::string relpath;
332 for(
int i=1;i<idx-1;i++){
333 relpath[i-1] = oldpath[i];
335 std::string otherpath;
336 for(
int i=idx-1;i<oldpath.size();i++){
337 otherpath[i-idx+1]=oldpath[i];
339 realpath = std::string(getenv(relpath.c_str()))+otherpath;
341 if( std::string::npos == idx ){
343 for(
int i=1;i<oldpath.size();i++){
344 relpath[i-1] = oldpath[i];
346 realpath = std::string(getenv(relpath.c_str()));
350 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 queryInterface(const InterfaceID &riid, void **ppvInterface)
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)
CalibRootCnvSvc(const std::string &name, ISvcLocator *svc)
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)