BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
CalibTreeCnvSvc.cxx
Go to the documentation of this file.
1#include "GaudiKernel/GenericAddress.h"
2#include "GaudiKernel/IConversionSvc.h"
3#include "GaudiKernel/IConverter.h"
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/IDetDataSvc.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/MsgStream.h"
8
9#include "CalibData/CalibBase.h"
10#include "CalibData/CalibBase1.h"
11#include "CalibDataSvc/IInstrumentName.h"
12
13#include "CalibTreeCnvSvc.h"
14// #include "cnv/TreeCalBaseCnv.h"
15
30#include "cnv/TreeTofQElecCnv.h"
31#include "cnv/TreeTofSimCnv.h"
32
33// Make instances only via static factory class
34// static SvcFactory<CalibTreeCnvSvc> calibRootCnvSvc_factory;
35// const ISvcFactory& CalibTreeCnvSvcFactory = calibRootCnvSvc_factory;
37CalibTreeCnvSvc::CalibTreeCnvSvc( const std::string& name, ISvcLocator* svc )
38 : ConversionSvc( name, svc, CALIBTREE_StorageType ), m_detPersSvc( 0 ), m_detDataSvc( 0 ) {
39
40 // huangb add
41}
42
43/*StatusCode CalibTreeCnvSvc::queryInterface(const InterfaceID& riid,
44 void** ppvInterface) {
45 // Uncomment if choose to derive from abstract root conv. interface
46 if (IID_ICalibTreeSvc.versionMatch(riid)) {
47 *ppvInterface = (ICalibTreeSvc*)this;
48 }
49 else {
50 // Interface is not directly availible: try out a base class
51 return ConversionSvc::queryInterface(riid, ppvInterface);
52 // }
53 addRef();
54 }
55 return StatusCode::SUCCESS;
56}
57*/
58
60 StatusCode sc = ConversionSvc::initialize();
61
62 MsgStream log( msgSvc(), "CalibTreeCnvSvc" );
63
64 if ( !sc.isSuccess() ) return sc;
65
66 // Locate the Calib Data Service. Since it inherits from DataSvc
67 // it has to implement IDataProviderSvc
68 m_detDataSvc = 0;
69 /*sc = serviceLocator()->getService
70 ("CalibDataSvc", IID_IDataProviderSvc,(IInterface*&) m_detDataSvc);*/
71 sc = serviceLocator()->getService( "CalibDataSvc", IDataProviderSvc::interfaceID(),
72 (IInterface*&)m_detDataSvc );
73 if ( !sc.isSuccess() )
74 {
75 log << MSG::ERROR << "Could not locate CalibDataSvc" << endmsg;
76 return sc;
77 }
78
79 /* IInstrumentName* iInstrumentName;
80 sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
81 (void**) &iInstrumentName);
82 */
83 // Set the CalibDataSvc as data provider service
84 sc = setDataProvider( m_detDataSvc );
85 if ( !sc.isSuccess() )
86 {
87 log << MSG::ERROR << "Could not set data provider" << endmsg;
88 return sc;
89 }
90 // huangb add
91 // sc = setProperties();
92
93 // Locate IConversionSvc interface of the DetectorPersistencySvc
94 sc = serviceLocator()->service( "DetectorPersistencySvc", m_detPersSvc, true );
95 if ( !sc.isSuccess() )
96 {
97 log << MSG::ERROR << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
98 << endmsg;
99 return sc;
100 }
101 else
102 {
103 log << MSG::DEBUG << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
104 << endmsg;
105 }
106
107 // Query the IAddressCreator interface of the detector persistency service
108 IAddressCreator* iAddrCreator;
109 /*sc = m_detPersSvc->queryInterface(IID_IAddressCreator,
110 (void**) &iAddrCreator);*/
111 sc = m_detPersSvc->queryInterface( IAddressCreator::interfaceID(), (void**)&iAddrCreator );
112 if ( !sc.isSuccess() )
113 {
114 log << MSG::ERROR << "Cannot query IAddressCreator interface of DetectorPersistencySvc"
115 << endmsg;
116 return sc;
117 }
118 else
119 {
120 log << MSG::DEBUG << "Retrieved IAddressCreator interface of DetectorPersistencySvc"
121 << endmsg;
122 }
123 log << MSG::DEBUG << "Set it as the address creator of the CalibTreeCnvSvc" << endmsg;
124 sc = setAddressCreator( iAddrCreator );
125 if ( !sc.isSuccess() )
126 {
127 log << MSG::ERROR << "Cannot set the address creator" << endmsg;
128 return sc;
129 }
130
131 // set properties if there are any??
132
133 return sc;
134}
135
137 // If anything was allocated, get rid of it. So far, nothing was.
138
139 return ConversionSvc::finalize();
140}
141
142StatusCode CalibTreeCnvSvc::createAddress( long svc_type, const CLID& clid,
143 const std::string* par, const unsigned long* ip,
144 IOpaqueAddress*& refpAddress ) {
145 // createAddress of CalibTreeCnvSvc
146 MsgStream log( msgSvc(), name() );
147 if ( svc_type != CALIBTREE_StorageType )
148 {
149 log << MSG::ERROR << "bad storage type" << (int)svc_type << endmsg;
150 return StatusCode::FAILURE;
151 }
152 std::string dataIdent;
153 std::string fullpath;
154 int index;
155 if ( clid == CLID_Calib_MdcCal ) { index = 0; }
156 else if ( clid == CLID_Calib_TofCal ) { index = 1; }
157 else if ( clid == CLID_Calib_DedxCal ) { index = 2; }
158 else if ( clid == CLID_Calib_EmcCal ) { index = 3; }
159 else { log << MSG::WARNING << "Wrong CLID" << endmsg; }
160
161 // see if svctype set in the CalibDataSvc is MYSQL_StorageType or CALIBROOT_StorageType
162 /* IInstrumentName* iInstrumentName;
163 StatusCode sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
164 (void**) &iInstrumentName);
165
166 if ( !sc.isSuccess() ) {
167 log << MSG::ERROR
168 << "Cannot query IInstrumentName interface of CalibDataSvc"
169 << endmsg;
170 return sc;
171 } else {
172 log << MSG::DEBUG
173 << "Retrieved IInstrumentName interface of CalibDataSvc"
174 << endmsg;
175 }
176
177 int svctype = iInstrumentName->getsvctype();
178 if(svctype== CALIBROOT_StorageType)
179 {
180 dataIdent = m_rootfile[index];
181 fullpath = par[0];
182 }
183
184 if(svctype== MYSQL_StorageType)
185 { log << MSG::INFO<<"rootfile is not set in the jobOption,get it from MySQL"<<endmsg;
186 dataIdent = par[0];
187 fullpath = par[1];
188 }
189
190 if ((svctype != CALIBROOT_StorageType)&&(svctype!= MYSQL_StorageType)) {
191 log << MSG::ERROR << "bad storage type" << (int)svctype << endmsg;
192 return StatusCode::FAILURE;
193 }
194 */
195 // std::string dataIdent(par[0]); // file identifier for PDS version of data
196 // log << MSG::INFO<<"dataIdent is:"<<dataIdent<<endmsg;
197 // std::string fullpath(par[1]); // path within TCDS for the object
198 // log << MSG::INFO<<"fullpath is :"<<fullpath<<endmsg;
199
200 int runfrm = ip[0];
201 int runto = ip[1];
202 dataIdent = par[0];
203 fullpath = par[1];
204
205 // for now have to ignore fmtVersion because of defective implementation
206 // of GenericAddress. If we want it, should probably write new
207 // opaque address implementation for this package to use. All
208 // dealings with (calibration) opaque addresses are confined to
209 // the CalibSvc package.
210 refpAddress =
211 new GenericAddress( CALIBTREE_StorageType, clid, dataIdent, fullpath, runfrm, runto );
212
213 return StatusCode::SUCCESS;
214}
215
216StatusCode CalibTreeCnvSvc::updateObj( IOpaqueAddress* pAddress, DataObject* pObject ) {
217
218 // using facilities::Timestamp;
219
220 MsgStream log( msgSvc(), "CalibTreeCnvSvc" );
221
222 // Don't update when we're using enter time
223 log << MSG::DEBUG << "CalibTreeCnvSvc::updateObj starting ...." << endmsg;
224
225 return StatusCode::SUCCESS;
226}
227
228IConverter* CalibTreeCnvSvc::createConverter( long typ, const CLID& wanted,
229 const ICnvFactory* fac ) {
230 if ( wanted == TreeCorrectedETSCnv::classID() )
231 return new TreeCorrectedETSCnv( serviceLocator().get() );
232 if ( wanted == TreeDedxCalibDataCnv::classID() )
233 return new TreeDedxCalibDataCnv( serviceLocator().get() );
234 if ( wanted == TreeDedxSimDataCnv::classID() )
235 return new TreeDedxSimDataCnv( serviceLocator().get() );
236 if ( wanted == TreeEmcCalibDataCnv::classID() )
237 return new TreeEmcCalibDataCnv( serviceLocator().get() );
238 if ( wanted == TreeEsTimeCalibDataCnv::classID() )
239 return new TreeEsTimeCalibDataCnv( serviceLocator().get() );
240 if ( wanted == TreeEstTofCalibDataCnv::classID() )
241 return new TreeEstTofCalibDataCnv( serviceLocator().get() );
242 if ( wanted == TreeInjSigIntervalCnv::classID() )
243 return new TreeInjSigIntervalCnv( serviceLocator().get() );
244 if ( wanted == TreeInjSigTimeCnv::classID() )
245 return new TreeInjSigTimeCnv( serviceLocator().get() );
246 if ( wanted == TreeMdcAlignDataCnv::classID() )
247 return new TreeMdcAlignDataCnv( serviceLocator().get() );
248 if ( wanted == TreeMdcCalibDataCnv::classID() )
249 return new TreeMdcCalibDataCnv( serviceLocator().get() );
250 if ( wanted == TreeMdcDataConstCnv::classID() )
251 return new TreeMdcDataConstCnv( serviceLocator().get() );
252 if ( wanted == TreeMucCalibDataCnv::classID() )
253 return new TreeMucCalibDataCnv( serviceLocator().get() );
254 if ( wanted == TreeOffEvtFilterCnv::classID() )
255 return new TreeOffEvtFilterCnv( serviceLocator().get() );
256 if ( wanted == TreeTofCalibDataCnv::classID() )
257 return new TreeTofCalibDataCnv( serviceLocator().get() );
258 if ( wanted == TreeTofElecDataCnv::classID() )
259 return new TreeTofElecDataCnv( serviceLocator().get() );
260 if ( wanted == TreeTofSimDataCnv::classID() )
261 return new TreeTofSimDataCnv( serviceLocator().get() );
262
263 return ConversionSvc::createConverter( typ, wanted, fac );
264}
DECLARE_COMPONENT(BesBdkRc)
IMessageSvc * msgSvc()
virtual StatusCode finalize()
IConverter * createConverter(long typ, const CLID &clid, const ICnvFactory *fac)
virtual StatusCode initialize()
CalibTreeCnvSvc(const std::string &name, ISvcLocator *svc)
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *pObject)
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
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()
static const CLID & classID()
static const CLID & classID()