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

#include <CalibRootCnvSvc.h>

+ Inheritance diagram for CalibRootCnvSvc:

Public Member Functions

virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 
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)
 
virtual StatusCode writeToRoot (const std::string &outputFile, const std::string &tdsPath)=0
 
virtual StatusCode writeToRoot (const std::string &outputFile, CalibData::CalibBase1 *calib)=0
 
virtual std::string getrootfile ()=0
 

Protected Member Functions

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

Friends

class SvcFactory< CalibRootCnvSvc >
 Only factories can access protected constructors.
 

Additional Inherited Members

- Static Public Member Functions inherited from ICalibRootSvc
static const InterfaceID & interfaceID ()
 

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 
)
protected

Definition at line 23 of file CalibRootCnvSvc.cxx.

24 :
25 ConversionSvc(name, svc, CALIBROOT_StorageType),
26 m_detPersSvc(0), m_detDataSvc(0) {
27 //huangb add
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"));
38 //Top_up Qiumei Ma
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"));
43 // Some day might have a property to declare having to do with path to
44 // xml files.
45 }
unsigned const char CALIBROOT_StorageType
Definition: ICalibRootSvc.h:20

◆ ~CalibRootCnvSvc()

virtual CalibRootCnvSvc::~CalibRootCnvSvc ( )
inlineprotectedvirtual

Definition at line 50 of file CalibRootCnvSvc.h.

50{}

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 145 of file CalibRootCnvSvc.cxx.

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

◆ decodeDescription()

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

Definition at line 320 of file CalibRootCnvSvc.cxx.

322{
323 MsgStream log(msgSvc(), "CalibMySQLCnvSvc");
324
325 if(oldpath[0]!='$'){
326 realpath=oldpath;
327 }
328 if(oldpath[0]=='$'){
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];
334 }
335 std::string otherpath;
336 for(int i=idx-1;i<oldpath.size();i++){
337 otherpath[i-idx+1]=oldpath[i];
338 }
339 realpath = std::string(getenv(relpath.c_str()))+otherpath;
340 }
341 if( std::string::npos == idx ){
342 std::string relpath;
343 for(int i=1;i<oldpath.size();i++){
344 relpath[i-1] = oldpath[i];
345 }
346 realpath = std::string(getenv(relpath.c_str()));
347 }
348 }
349
350 return StatusCode::SUCCESS;
351}

Referenced by createAddress().

◆ finalize()

StatusCode CalibRootCnvSvc::finalize ( )
virtual

Definition at line 139 of file CalibRootCnvSvc.cxx.

139 {
140 // If anything was allocated, get rid of it. So far, nothing was.
141
142 return ConversionSvc::finalize();
143}

◆ getrootfile()

std::string CalibRootCnvSvc::getrootfile ( )
inlinevirtual

Implements ICalibRootSvc.

Definition at line 91 of file CalibRootCnvSvc.h.

92 { return m_rootfile[0];}

◆ initialize()

StatusCode CalibRootCnvSvc::initialize ( )
virtual

Definition at line 62 of file CalibRootCnvSvc.cxx.

62 {
63 StatusCode sc = ConversionSvc::initialize();
64
65 MsgStream log(msgSvc(), "CalibRootCnvSvc");
66
67 if (!sc.isSuccess()) return sc;
68
69 // Locate the Calib Data Service. Since it inherits from DataSvc
70 // it has to implement IDataProviderSvc
71 m_detDataSvc = 0;
72 /*sc = serviceLocator()->getService
73 ("CalibDataSvc", IID_IDataProviderSvc,(IInterface*&) m_detDataSvc);*/
74 sc = serviceLocator()->getService
75 ("CalibDataSvc", IDataProviderSvc::interfaceID(),(IInterface*&) m_detDataSvc);
76 if ( !sc.isSuccess() ) {
77 log << MSG::ERROR << "Could not locate CalibDataSvc" << endreq;
78 return sc;
79 }
80
81 /* IInstrumentName* iInstrumentName;
82 sc = m_detDataSvc->queryInterface(IID_IInstrumentName,
83 (void**) &iInstrumentName);
84 */
85 // Set the CalibDataSvc as data provider service
86 sc = setDataProvider(m_detDataSvc);
87 if ( !sc.isSuccess() ) {
88 log << MSG::ERROR << "Could not set data provider" << endreq;
89 return sc;
90 }
91 //huangb add
92 sc = setProperties();
93
94 // Locate IConversionSvc interface of the DetectorPersistencySvc
95 sc = serviceLocator()->service
96 ("DetectorPersistencySvc", m_detPersSvc, true);
97 if ( !sc.isSuccess() ) {
98 log << MSG::ERROR
99 << "Cannot locate IConversionSvc interface of DetectorPersistencySvc"
100 << endreq;
101 return sc;
102 } else {
103 log << MSG::DEBUG
104 << "Retrieved IConversionSvc interface of DetectorPersistencySvc"
105 << endreq;
106 }
107
108 // Query the IAddressCreator interface of the detector persistency service
109 IAddressCreator* iAddrCreator;
110 /* sc = m_detPersSvc->queryInterface(IID_IAddressCreator,
111
112 (void**) &iAddrCreator);*/
113
114 sc = m_detPersSvc->queryInterface(IAddressCreator::interfaceID(),
115 (void**) &iAddrCreator);
116 if ( !sc.isSuccess() ) {
117 log << MSG::ERROR
118 << "Cannot query IAddressCreator interface of DetectorPersistencySvc"
119 << endreq;
120 return sc;
121 } else {
122 log << MSG::DEBUG
123 << "Retrieved IAddressCreator interface of DetectorPersistencySvc"
124 << endreq;
125 }
126 log << MSG::DEBUG
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;
131 return sc;
132 }
133
134 // set properties if there are any??
135
136 return sc;
137}

◆ queryInterface()

StatusCode CalibRootCnvSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Definition at line 47 of file CalibRootCnvSvc.cxx.

48 {
49 /* Uncomment if choose to derive from abstract root conv. interface */
50 if (IID_ICalibRootSvc.versionMatch(riid)) {
51 *ppvInterface = (ICalibRootSvc*)this;
52 }
53 else {
54 // Interface is not directly availible: try out a base class
55 return ConversionSvc::queryInterface(riid, ppvInterface);
56 /* } */
57 addRef();
58}
59return StatusCode::SUCCESS;
60}

◆ updateObj()

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

Definition at line 303 of file CalibRootCnvSvc.cxx.

304 {
305
306 // using facilities::Timestamp;
307
308 MsgStream log(msgSvc(), "CalibRootCnvSvc" );
309
310 // Don't update when we're using enter time
311 log << MSG::DEBUG << "CalibRootCnvSvc::updateObj starting ...."<<endreq;
312 /*
313 if (!m_useEventTime)
314 { log << MSG::DEBUG << "Method updateObj needn't update" << endreq;
315 return StatusCode::SUCCESS;
316 }
317 */
318}

◆ writeToRoot() [1/2]

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

Implements ICalibRootSvc.

Definition at line 283 of file CalibRootCnvSvc.cxx.

284 {
285 MsgStream log(msgSvc(), name() );
286 // Find converter corresponding to this object
287 IConverter* converter = ConversionSvc::converter(pCalib->clID());
288 if (!converter) {
289 log << "No converter found for object with CLID " << pCalib->clID()
290 << endreq;
291 return StatusCode::FAILURE;
292 }
293 RootCalBaseCnv* pCnv = dynamic_cast<RootCalBaseCnv*>(converter);
294 if (!pCnv) {
295 log << "Converter for CLID " << pCalib->clID() << " not of proper type"
296 << endreq;
297 return StatusCode::FAILURE;
298 }
299 // Call its createRoot method
300 return pCnv->createRoot(outfile, pCalib);
301}
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 262 of file CalibRootCnvSvc.cxx.

263 {
264 MsgStream log( msgSvc(), name() );
265
266 // Find corresponding object
267 DataObject* pObj;
268 m_detDataSvc->findObject(tdsPath, pObj);
269 if (!pObj) {
270 log << "No object in TDS with path " << tdsPath << endreq;
271 return StatusCode::FAILURE;
272 }
273
274 CalibData::CalibBase1* pCalib =
275 dynamic_cast<CalibData::CalibBase1*> (pObj);
276
277 if (!pCalib) {
278 log << "Object with path " << tdsPath << " not of proper type" << endreq;
279 return StatusCode::FAILURE;
280 }
281 return writeToRoot(outfile, pCalib);
282}
virtual StatusCode writeToRoot(const std::string &outputFile, const std::string &tdsPath)

Referenced by writeToRoot().

Friends And Related Function Documentation

◆ SvcFactory< CalibRootCnvSvc >

friend class SvcFactory< CalibRootCnvSvc >
friend

Only factories can access protected constructors.

Definition at line 1 of file CalibRootCnvSvc.h.


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