4#include "GaudiKernel/GenericAddress.h"
5#include "GaudiKernel/IConversionSvc.h"
6#include "GaudiKernel/IConverter.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/IDetDataSvc.h"
9#include "GaudiKernel/ISvcLocator.h"
10#include "GaudiKernel/MsgStream.h"
12#include "CalibData/CalibBase.h"
13#include "CalibData/CalibBase1.h"
14#include "CalibDataSvc/IInstrumentName.h"
40 declareProperty(
"Mdcrootfile", m_rootfile[0] = std::string(
"no rootfile" ) );
41 declareProperty(
"Tofrootfile", m_rootfile[1] = std::string(
"no rootfile" ) );
42 declareProperty(
"Dedxrootfile", m_rootfile[2] = std::string(
"no rootfile" ) );
43 declareProperty(
"Emcrootfile", m_rootfile[3] = std::string(
"no rootfile" ) );
44 declareProperty(
"Mucrootfile", m_rootfile[4] = std::string(
"no rootfile" ) );
45 declareProperty(
"EsTimerootfile", m_rootfile[5] = std::string(
"no rootfile" ) );
46 declareProperty(
"EstTofrootfile", m_rootfile[6] = std::string(
"no rootfile" ) );
47 declareProperty(
"TofQElecrootfile", m_rootfile[7] = std::string(
"no rootfile" ) );
48 declareProperty(
"TofSimrootfile", m_rootfile[8] = std::string(
"no rootfile" ) );
49 declareProperty(
"DedxSimrootfile", m_rootfile[9] = std::string(
"no rootfile" ) );
51 declareProperty(
"InjSigIntervalrootfile", m_rootfile[10] = std::string(
"no rootfile" ) );
52 declareProperty(
"InjSigTimerootfile", m_rootfile[11] = std::string(
"no rootfile" ) );
53 declareProperty(
"OffEvtFilterrootfile", m_rootfile[12] = std::string(
"no rootfile" ) );
54 declareProperty(
"CorrectedETSrootfile", m_rootfile[13] = std::string(
"no rootfile" ) );
76 StatusCode sc = ConversionSvc::initialize();
78 MsgStream log(
msgSvc(),
"CalibRootCnvSvc" );
80 if ( !sc.isSuccess() )
return sc;
87 sc = serviceLocator()->getService(
"CalibDataSvc", IDataProviderSvc::interfaceID(),
88 (IInterface*&)m_detDataSvc );
89 if ( !sc.isSuccess() )
91 log << MSG::ERROR <<
"Could not locate CalibDataSvc" << endmsg;
100 sc = setDataProvider( m_detDataSvc );
101 if ( !sc.isSuccess() )
103 log << MSG::ERROR <<
"Could not set data provider" << endmsg;
110 sc = serviceLocator()->service(
"DetectorPersistencySvc", m_detPersSvc,
true );
111 if ( !sc.isSuccess() )
113 log << MSG::ERROR <<
"Cannot locate IConversionSvc interface of DetectorPersistencySvc"
119 log << MSG::DEBUG <<
"Retrieved IConversionSvc interface of DetectorPersistencySvc"
124 IAddressCreator* iAddrCreator;
129 sc = m_detPersSvc->queryInterface( IAddressCreator::interfaceID(), (
void**)&iAddrCreator );
130 if ( !sc.isSuccess() )
132 log << MSG::ERROR <<
"Cannot query IAddressCreator interface of DetectorPersistencySvc"
138 log << MSG::DEBUG <<
"Retrieved IAddressCreator interface of DetectorPersistencySvc"
141 log << MSG::DEBUG <<
"Set it as the address creator of the CalibRootCnvSvc" << endmsg;
142 sc = setAddressCreator( iAddrCreator );
143 if ( !sc.isSuccess() )
145 log << MSG::ERROR <<
"Cannot set the address creator" << endmsg;
157 return ConversionSvc::finalize();
161 const std::string* par,
const unsigned long* ip,
162 IOpaqueAddress*& refpAddress ) {
163 MsgStream log(
msgSvc(), name() );
164 log << MSG::DEBUG <<
"here is the createAddress in the CalibRootCnvSvc" << endmsg;
167 log << MSG::ERROR <<
"bad storage type" << (int)svc_type << endmsg;
168 return StatusCode::FAILURE;
171 std::string dataIdent;
172 std::string fullpath;
174 if ( clid == 6412 )
return StatusCode::SUCCESS;
191 else { log << MSG::WARNING <<
"Wrong CLID" << endmsg; }
214 if ( m_rootfile[index] ==
"no rootfile" )
216 log << MSG::INFO <<
"no sepcified calibration file path of type " << index << endmsg;
217 return StatusCode::FAILURE;
236 log << MSG::INFO <<
"dataIdent is:" << dataIdent << endmsg;
238 log << MSG::INFO <<
"fullpath is :" << fullpath << endmsg;
251 return StatusCode::SUCCESS;
255 const std::string& tdsPath ) {
256 MsgStream log(
msgSvc(), name() );
260 m_detDataSvc->findObject( tdsPath, pObj );
263 log <<
"No object in TDS with path " << tdsPath << endmsg;
264 return StatusCode::FAILURE;
271 log <<
"Object with path " << tdsPath <<
" not of proper type" << endmsg;
272 return StatusCode::FAILURE;
278 MsgStream log(
msgSvc(), name() );
280 IConverter* converter = ConversionSvc::converter( pCalib->clID() );
283 log <<
"No converter found for object with CLID " << pCalib->clID() << endmsg;
284 return StatusCode::FAILURE;
289 log <<
"Converter for CLID " << pCalib->clID() <<
" not of proper type" << endmsg;
290 return StatusCode::FAILURE;
300 MsgStream log(
msgSvc(),
"CalibRootCnvSvc" );
303 log << MSG::DEBUG <<
"CalibRootCnvSvc::updateObj starting ...." << endmsg;
310 return StatusCode::SUCCESS;
314 std::string& realpath ) {
315 MsgStream log(
msgSvc(),
"CalibMySQLCnvSvc" );
317 if ( oldpath[0] !=
'$' ) { realpath = oldpath; }
318 if ( oldpath[0] ==
'$' )
320 std::string::size_type idx = oldpath.find(
"/" );
321 if ( std::string::npos != idx )
324 for (
int i = 1; i < idx - 1; i++ ) { relpath[i - 1] = oldpath[i]; }
325 std::string otherpath;
326 for (
int i = idx - 1; i < oldpath.size(); i++ ) { otherpath[i - idx + 1] = oldpath[i]; }
327 realpath = std::string( getenv( relpath.c_str() ) ) + otherpath;
329 if ( std::string::npos == idx )
332 for (
int i = 1; i < oldpath.size(); i++ ) { relpath[i - 1] = oldpath[i]; }
333 realpath = std::string( getenv( relpath.c_str() ) );
337 return StatusCode::SUCCESS;
341 const ICnvFactory* fac ) {
371 return ConversionSvc::createConverter( typ, wanted, fac );
DECLARE_COMPONENT(BesBdkRc)
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()
IConverter * createConverter(long typ, const CLID &wanted, const ICnvFactory *fac) override
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)
Only factories can access protected constructors.
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()