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"
13#include "CalibROOTCnv/CalibRootCnvSvc.h"
14#include "CalibData/CalibBase.h"
16#include "CalibData/CalibBase1.h"
17#include "CalibDataSvc/IInstrumentName.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"));
43 void** ppvInterface) {
45 if (IID_ICalibRootSvc.versionMatch(riid)) {
50 return ConversionSvc::queryInterface(riid, ppvInterface);
54 return StatusCode::SUCCESS;
58 StatusCode sc = ConversionSvc::initialize();
60 MsgStream log(
msgSvc(),
"CalibRootCnvSvc");
62 if (!sc.isSuccess())
return sc;
69 sc = serviceLocator()->getService
70 (
"CalibDataSvc", IDataProviderSvc::interfaceID(),(IInterface*&) m_detDataSvc);
71 if ( !sc.isSuccess() ) {
72 log << MSG::ERROR <<
"Could not locate CalibDataSvc" << endreq;
81 sc = setDataProvider(m_detDataSvc);
82 if ( !sc.isSuccess() ) {
83 log << MSG::ERROR <<
"Could not set data provider" << endreq;
90 sc = serviceLocator()->service
91 (
"DetectorPersistencySvc", m_detPersSvc,
true);
92 if ( !sc.isSuccess() ) {
94 <<
"Cannot locate IConversionSvc interface of DetectorPersistencySvc"
99 <<
"Retrieved IConversionSvc interface of DetectorPersistencySvc"
104 IAddressCreator* iAddrCreator;
109 sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(),
110 (
void**) &iAddrCreator);
111 if ( !sc.isSuccess() ) {
113 <<
"Cannot query IAddressCreator interface of DetectorPersistencySvc"
118 <<
"Retrieved IAddressCreator interface of DetectorPersistencySvc"
122 <<
"Set it as the address creator of the CalibRootCnvSvc" << endreq;
123 sc = setAddressCreator(iAddrCreator);
124 if ( !sc.isSuccess() ) {
125 log << MSG::ERROR <<
"Cannot set the address creator" << endreq;
137 return ConversionSvc::finalize();
143 const std::string* par,
144 const unsigned long* ip,
145 IOpaqueAddress*& refpAddress) {
146 MsgStream log(
msgSvc(), name() );
147 log << MSG::DEBUG<<
"here is the createAddress in the CalibRootCnvSvc"<<endreq;
149 log << MSG::ERROR <<
"bad storage type" << (int)svc_type << endreq;
150 return StatusCode::FAILURE;
152 std::cout<<
"clid=="<<clid<<std::endl;
153 std::string dataIdent;
154 std::string fullpath;
156 if(clid==6412)
return StatusCode::SUCCESS;
179 log << MSG::WARNING<<
"Wrong CLID"<<endreq;
181 std::cout<<
"index=="<<index<<std::endl;
203if(m_rootfile[index]==
"no rootfile")
205log << MSG::INFO<<
"no sepcified calibration file path of type "<< index <<endreq;
206return StatusCode::FAILURE;
225 log << MSG::INFO<<
"dataIdent is:"<<dataIdent<<endreq;
227 log << MSG::INFO<<
"fullpath is :"<<fullpath<<endreq;
245 return StatusCode::SUCCESS;
250 const std::string& tdsPath) {
251 MsgStream log(
msgSvc(), name() );
255 m_detDataSvc->findObject(tdsPath, pObj);
257 log <<
"No object in TDS with path " << tdsPath << endreq;
258 return StatusCode::FAILURE;
265 log <<
"Object with path " << tdsPath <<
" not of proper type" << endreq;
266 return StatusCode::FAILURE;
272 MsgStream log(
msgSvc(), name() );
274 IConverter* converter = ConversionSvc::converter(pCalib->clID());
276 log <<
"No converter found for object with CLID " << pCalib->clID()
278 return StatusCode::FAILURE;
282 log <<
"Converter for CLID " << pCalib->clID() <<
" not of proper type"
284 return StatusCode::FAILURE;
291 DataObject* pObject ) {
295 MsgStream log(
msgSvc(),
"CalibRootCnvSvc" );
298 log << MSG::DEBUG <<
"CalibRootCnvSvc::updateObj starting ...."<<endreq;
308 std::string& realpath )
310 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc");
316 std::string::size_type idx =oldpath.find(
"/");
317 if( std::string::npos != idx )
318 { std::string relpath;
319 for(
int i=1;i<idx-1;i++){
320 relpath[i-1] = oldpath[i];
322 std::string otherpath;
323 for(
int i=idx-1;i<oldpath.size();i++){
324 otherpath[i-idx+1]=oldpath[i];
326 realpath = std::string(getenv(relpath.c_str()))+otherpath;
328 if( std::string::npos == idx ){
330 for(
int i=1;i<oldpath.size();i++){
331 relpath[i-1] = oldpath[i];
333 realpath = std::string(getenv(relpath.c_str()));
337 return StatusCode::SUCCESS;
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_TofCal
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)