BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
CalibRootCnvSvc Class Reference

#include <CalibRootCnvSvc.h>

Inheritance diagram for CalibRootCnvSvc:

Public Member Functions

 CalibRootCnvSvc (const std::string &name, ISvcLocator *svc)
 Only factories can access protected constructors.
virtual ~CalibRootCnvSvc ()
virtual StatusCode writeToRoot (const std::string &outputFile, const std::string &tdsPath)
virtual StatusCode writeToRoot (const std::string &outputFile, CalibData::CalibBase1 *calib)
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *pObject)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
std::string getrootfile ()
StatusCode decodeDescription (const std::string &oldpath, std::string &realpath)
IConverter * createConverter (long typ, const CLID &wanted, const ICnvFactory *fac) override
Public Member Functions inherited from ICalibRootSvc
 DeclareInterfaceID (ICalibRootSvc, 1, 0)
 DeclareInterfaceID (ICalibRootSvc, 1, 0)
 DeclareInterfaceID (ICalibRootSvc, 1, 0)

Detailed Description


A conversion service for GLAST calibration bulk data in ROOT format.

Author
J. Bogart
Date
July 2004

Definition at line 42 of file CalibRootCnvSvc.h.

Constructor & Destructor Documentation

◆ CalibRootCnvSvc()

CalibRootCnvSvc::CalibRootCnvSvc ( const std::string & name,
ISvcLocator * svc )

Only factories can access protected constructors.

Definition at line 37 of file CalibRootCnvSvc.cxx.

38 : ConversionSvc( name, svc, CALIBROOT_StorageType ), m_detPersSvc( 0 ), m_detDataSvc( 0 ) {
39 // huangb add
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" ) );
50 // Top_up Qiumei Ma
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" ) );
55 // Some day might have a property to declare having to do with path to
56 // xml files.
57}

Referenced by CalibRootCnvSvc().

◆ ~CalibRootCnvSvc()

virtual CalibRootCnvSvc::~CalibRootCnvSvc ( )
inlinevirtual

Definition at line 48 of file CalibRootCnvSvc.h.

48{}

Member Function Documentation

◆ createAddress()

StatusCode CalibRootCnvSvc::createAddress ( long svc_type,
const CLID & clid,
const std::string * par,
const unsigned long * ip,
IOpaqueAddress *& refpAddress )
virtual

Create a ROOT address using explicit arguments to identify a single object

Parameters
svc_typethe service type
CLIDthe CLID of the ROOT Element for which an address is created
paran array of three strings containing the format version, calibration type name and the flavor, in this order
iphas a single element, the serial number of the MySQL row which corresponds to this element
refpAddressthe new address created
Returns
a StatusCode giving the status of the address creation

Definition at line 160 of file CalibRootCnvSvc.cxx.

162 {
163 MsgStream log( msgSvc(), name() );
164 log << MSG::DEBUG << "here is the createAddress in the CalibRootCnvSvc" << endmsg;
165 if ( svc_type != CALIBROOT_StorageType )
166 {
167 log << MSG::ERROR << "bad storage type" << (int)svc_type << endmsg;
168 return StatusCode::FAILURE;
169 }
170 // std::cout<<"clid=="<<clid<<std::endl;
171 std::string dataIdent;
172 std::string fullpath;
173 int index = -99;
174 if ( clid == 6412 ) return StatusCode::SUCCESS;
175 if ( clid == CLID_Calib_MdcCal ) { index = 0; }
176 else if ( clid == CLID_Calib_TofCal ) { index = 1; }
177 else if ( clid == CLID_Calib_DedxCal ) { index = 2; }
178 else if ( clid == CLID_Calib_EmcCal ) { index = 3; }
179 else if ( clid == CLID_Calib_MucCal ) { index = 4; }
180 else if ( clid == CLID_Calib_EsTimeCal ) { index = 5; }
181 else if ( clid == CLID_Calib_EstTofCal ) { index = 6; }
182 else if ( clid == CLID_TofQ_Elec ) { index = 7; }
183 else if ( clid == CLID_Calib_TofSim ) { index = 8; }
184 else if ( clid == CLID_Dedx_Sim ) { index = 9; }
185 // Top_up Qiumei Ma
186 else if ( clid == CLID_Calib_InjSigInterval ) { index = 10; }
187 else if ( clid == CLID_Calib_InjSigTime ) { index = 11; }
188 else if ( clid == CLID_Calib_OffEvtFilter ) { index = 12; }
189 else if ( clid == CLID_Calib_CorrectedETS ) { index = 13; }
190
191 else { log << MSG::WARNING << "Wrong CLID" << endmsg; }
192 // std::cout<<"index=="<<index<<std::endl;
193 // see if svctype set in the CalibDataSvc is MYSQL_StorageType or CALIBROOT_StorageType
194 /* IInstrumentName* iInstrumentName;
195 StatusCode sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
196 (void**) &iInstrumentName);
197
198 if ( !sc.isSuccess() ) {
199 log << MSG::ERROR
200 << "Cannot query IInstrumentName interface of CalibDataSvc"
201 << endmsg;
202 return sc;
203 } else {
204 log << MSG::DEBUG
205 << "Retrieved IInstrumentName interface of CalibDataSvc"
206 << endmsg;
207 }
208
209 int svctype = iInstrumentName->getsvctype();
210 if(svctype== CALIBROOT_StorageType)
211 {
212 */
213 // dataIdent = m_rootfile[index];
214 if ( m_rootfile[index] == "no rootfile" )
215 {
216 log << MSG::INFO << "no sepcified calibration file path of type " << index << endmsg;
217 return StatusCode::FAILURE;
218 }
219 decodeDescription( m_rootfile[index], dataIdent );
220 fullpath = par[0];
221 /* }
222
223 if(svctype== MYSQL_StorageType)
224 { log << MSG::INFO<<"rootfile is not set in the jobOption,get it from MySQL"<<endmsg;
225 dataIdent = par[0];
226 fullpath = par[1];
227 }
228
229 if ((svctype != CALIBROOT_StorageType)&&(svctype!= MYSQL_StorageType)) {
230 log << MSG::ERROR << "bad storage type" << (int)svctype << endmsg;
231 return StatusCode::FAILURE;
232 }
233 */
234
235 // std::string dataIdent(par[0]); // file identifier for PDS version of data
236 log << MSG::INFO << "dataIdent is:" << dataIdent << endmsg;
237 // std::string fullpath(par[1]); // path within TCDS for the object
238 log << MSG::INFO << "fullpath is :" << fullpath << endmsg;
239
240 int runfrm = ip[0];
241 int runto = ip[1];
242
243 // for now have to ignore fmtVersion because of defective implementation
244 // of GenericAddress. If we want it, should probably write new
245 // opaque address implementation for this package to use. All
246 // dealings with (calibration) opaque addresses are confined to
247 // the CalibSvc package.
248 refpAddress =
249 new GenericAddress( CALIBROOT_StorageType, clid, dataIdent, fullpath, runfrm, runto );
250
251 return StatusCode::SUCCESS;
252}
IMessageSvc * msgSvc()
StatusCode decodeDescription(const std::string &oldpath, std::string &realpath)

◆ createConverter()

IConverter * CalibRootCnvSvc::createConverter ( long typ,
const CLID & wanted,
const ICnvFactory * fac )
override

Definition at line 340 of file CalibRootCnvSvc.cxx.

341 {
342 if ( wanted == RootCorrectedETSCnv::classID() )
343 return new RootCorrectedETSCnv( serviceLocator().get() );
344 if ( wanted == RootDedxCalibDataCnv::classID() )
345 return new RootDedxCalibDataCnv( serviceLocator().get() );
346 if ( wanted == RootDedxSimDataCnv::classID() )
347 return new RootDedxSimDataCnv( serviceLocator().get() );
348 if ( wanted == RootEmcCalibDataCnv::classID() )
349 return new RootEmcCalibDataCnv( serviceLocator().get() );
350 if ( wanted == RootEsTimeCalibDataCnv::classID() )
351 return new RootEsTimeCalibDataCnv( serviceLocator().get() );
352 if ( wanted == RootEstTofCalibDataCnv::classID() )
353 return new RootEstTofCalibDataCnv( serviceLocator().get() );
354 if ( wanted == RootInjSigIntervalCnv::classID() )
355 return new RootInjSigIntervalCnv( serviceLocator().get() );
356 if ( wanted == RootInjSigTimeCnv::classID() )
357 return new RootInjSigTimeCnv( serviceLocator().get() );
358 if ( wanted == RootMdcCalibDataCnv::classID() )
359 return new RootMdcCalibDataCnv( serviceLocator().get() );
360 if ( wanted == RootMucCalibDataCnv::classID() )
361 return new RootMucCalibDataCnv( serviceLocator().get() );
362 if ( wanted == RootOffEvtFilterCnv::classID() )
363 return new RootOffEvtFilterCnv( serviceLocator().get() );
364 if ( wanted == RootTofCalibDataCnv::classID() )
365 return new RootTofCalibDataCnv( serviceLocator().get() );
366 if ( wanted == RootTofElecDataCnv::classID() )
367 return new RootTofElecDataCnv( serviceLocator().get() );
368 if ( wanted == RootTofSimDataCnv::classID() )
369 return new RootTofSimDataCnv( serviceLocator().get() );
370
371 return ConversionSvc::createConverter( typ, wanted, fac );
372}
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()

◆ decodeDescription()

StatusCode CalibRootCnvSvc::decodeDescription ( const std::string & oldpath,
std::string & realpath )

Definition at line 313 of file CalibRootCnvSvc.cxx.

314 {
315 MsgStream log( msgSvc(), "CalibMySQLCnvSvc" );
316
317 if ( oldpath[0] != '$' ) { realpath = oldpath; }
318 if ( oldpath[0] == '$' )
319 {
320 std::string::size_type idx = oldpath.find( "/" );
321 if ( std::string::npos != idx )
322 {
323 std::string relpath;
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;
328 }
329 if ( std::string::npos == idx )
330 {
331 std::string relpath;
332 for ( int i = 1; i < oldpath.size(); i++ ) { relpath[i - 1] = oldpath[i]; }
333 realpath = std::string( getenv( relpath.c_str() ) );
334 }
335 }
336
337 return StatusCode::SUCCESS;
338}

Referenced by createAddress().

◆ finalize()

StatusCode CalibRootCnvSvc::finalize ( )
virtual

Definition at line 154 of file CalibRootCnvSvc.cxx.

154 {
155 // If anything was allocated, get rid of it. So far, nothing was.
156
157 return ConversionSvc::finalize();
158}

◆ getrootfile()

std::string CalibRootCnvSvc::getrootfile ( )
inlinevirtual

Implements ICalibRootSvc.

Definition at line 82 of file CalibRootCnvSvc.h.

82{ return m_rootfile[0]; }

◆ initialize()

StatusCode CalibRootCnvSvc::initialize ( )
virtual

Definition at line 75 of file CalibRootCnvSvc.cxx.

75 {
76 StatusCode sc = ConversionSvc::initialize();
77
78 MsgStream log( msgSvc(), "CalibRootCnvSvc" );
79
80 if ( !sc.isSuccess() ) return sc;
81
82 // Locate the Calib Data Service. Since it inherits from DataSvc
83 // it has to implement IDataProviderSvc
84 m_detDataSvc = 0;
85 /*sc = serviceLocator()->getService
86 ("CalibDataSvc", IID_IDataProviderSvc,(IInterface*&) m_detDataSvc);*/
87 sc = serviceLocator()->getService( "CalibDataSvc", IDataProviderSvc::interfaceID(),
88 (IInterface*&)m_detDataSvc );
89 if ( !sc.isSuccess() )
90 {
91 log << MSG::ERROR << "Could not locate CalibDataSvc" << endmsg;
92 return sc;
93 }
94
95 /* IInstrumentName* iInstrumentName;
96 sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
97 (void**) &iInstrumentName);
98 */
99 // Set the CalibDataSvc as data provider service
100 sc = setDataProvider( m_detDataSvc );
101 if ( !sc.isSuccess() )
102 {
103 log << MSG::ERROR << "Could not set data provider" << endmsg;
104 return sc;
105 }
106 // huangb add
107 // sc = setProperties();
108
109 // Locate IConversionSvc interface of the DetectorPersistencySvc
110 sc = serviceLocator()->service( "DetectorPersistencySvc", m_detPersSvc, true );
111 if ( !sc.isSuccess() )
112 {
113 log << MSG::ERROR << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
114 << endmsg;
115 return sc;
116 }
117 else
118 {
119 log << MSG::DEBUG << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
120 << endmsg;
121 }
122
123 // Query the IAddressCreator interface of the detector persistency service
124 IAddressCreator* iAddrCreator;
125 /* sc = m_detPersSvc->queryInterface(IID_IAddressCreator,
126
127 (void**) &iAddrCreator);*/
128
129 sc = m_detPersSvc->queryInterface( IAddressCreator::interfaceID(), (void**)&iAddrCreator );
130 if ( !sc.isSuccess() )
131 {
132 log << MSG::ERROR << "Cannot query IAddressCreator interface of DetectorPersistencySvc"
133 << endmsg;
134 return sc;
135 }
136 else
137 {
138 log << MSG::DEBUG << "Retrieved IAddressCreator interface of DetectorPersistencySvc"
139 << endmsg;
140 }
141 log << MSG::DEBUG << "Set it as the address creator of the CalibRootCnvSvc" << endmsg;
142 sc = setAddressCreator( iAddrCreator );
143 if ( !sc.isSuccess() )
144 {
145 log << MSG::ERROR << "Cannot set the address creator" << endmsg;
146 return sc;
147 }
148
149 // set properties if there are any??
150
151 return sc;
152}

◆ updateObj()

StatusCode CalibRootCnvSvc::updateObj ( IOpaqueAddress * pAddress,
DataObject * pObject )
virtual

Definition at line 296 of file CalibRootCnvSvc.cxx.

296 {
297
298 // using facilities::Timestamp;
299
300 MsgStream log( msgSvc(), "CalibRootCnvSvc" );
301
302 // Don't update when we're using enter time
303 log << MSG::DEBUG << "CalibRootCnvSvc::updateObj starting ...." << endmsg;
304 /*
305 if (!m_useEventTime)
306 { log << MSG::DEBUG << "Method updateObj needn't update" << endmsg;
307 return StatusCode::SUCCESS;
308 }
309 */
310 return StatusCode::SUCCESS;
311}

◆ writeToRoot() [1/2]

StatusCode CalibRootCnvSvc::writeToRoot ( const std::string & outputFile,
CalibData::CalibBase1 * calib )
virtual

Implements ICalibRootSvc.

Definition at line 276 of file CalibRootCnvSvc.cxx.

277 {
278 MsgStream log( msgSvc(), name() );
279 // Find converter corresponding to this object
280 IConverter* converter = ConversionSvc::converter( pCalib->clID() );
281 if ( !converter )
282 {
283 log << "No converter found for object with CLID " << pCalib->clID() << endmsg;
284 return StatusCode::FAILURE;
285 }
286 RootCalBaseCnv* pCnv = dynamic_cast<RootCalBaseCnv*>( converter );
287 if ( !pCnv )
288 {
289 log << "Converter for CLID " << pCalib->clID() << " not of proper type" << endmsg;
290 return StatusCode::FAILURE;
291 }
292 // Call its createRoot method
293 return pCnv->createRoot( outfile, pCalib );
294}
virtual StatusCode createRoot(const std::string &fname, CalibData::CalibBase1 *pTDSObj)

◆ writeToRoot() [2/2]

StatusCode CalibRootCnvSvc::writeToRoot ( const std::string & outputFile,
const std::string & tdsPath )
virtual

Method to write a ROOT file corresponding to TDS object

Parameters
fileNamethe name of the file to be written
Returns
the document issued from the parsing

Implements ICalibRootSvc.

Definition at line 254 of file CalibRootCnvSvc.cxx.

255 {
256 MsgStream log( msgSvc(), name() );
257
258 // Find corresponding object
259 DataObject* pObj;
260 m_detDataSvc->findObject( tdsPath, pObj );
261 if ( !pObj )
262 {
263 log << "No object in TDS with path " << tdsPath << endmsg;
264 return StatusCode::FAILURE;
265 }
266
267 CalibData::CalibBase1* pCalib = dynamic_cast<CalibData::CalibBase1*>( pObj );
268
269 if ( !pCalib )
270 {
271 log << "Object with path " << tdsPath << " not of proper type" << endmsg;
272 return StatusCode::FAILURE;
273 }
274 return writeToRoot( outfile, pCalib );
275}
virtual StatusCode writeToRoot(const std::string &outputFile, const std::string &tdsPath)

Referenced by writeToRoot().


The documentation for this class was generated from the following files: