BOSS 7.0.1
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 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
 
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 ()
 
 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 ()
 
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 Calibration/CalibSvc/CalibROOTCnv/CalibROOTCnv-00-01-12/CalibROOTCnv/CalibRootCnvSvc.h.

Constructor & Destructor Documentation

◆ CalibRootCnvSvc() [1/2]

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 // Some day might have a property to declare having to do with path to
39 // xml files.
40}

◆ ~CalibRootCnvSvc() [1/2]

virtual CalibRootCnvSvc::~CalibRootCnvSvc ( )
inlineprotectedvirtual

◆ CalibRootCnvSvc() [2/2]

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

◆ ~CalibRootCnvSvc() [2/2]

virtual CalibRootCnvSvc::~CalibRootCnvSvc ( )
inlineprotectedvirtual

Member Function Documentation

◆ createAddress() [1/2]

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

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

◆ createAddress() [2/2]

virtual 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

◆ decodeDescription() [1/2]

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

Definition at line 307 of file CalibRootCnvSvc.cxx.

309{
310 MsgStream log(msgSvc(), "CalibMySQLCnvSvc");
311
312 if(oldpath[0]!='$'){
313 realpath=oldpath;
314 }
315 if(oldpath[0]=='$'){
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];
321 }
322 std::string otherpath;
323 for(int i=idx-1;i<oldpath.size();i++){
324 otherpath[i-idx+1]=oldpath[i];
325 }
326 realpath = std::string(getenv(relpath.c_str()))+otherpath;
327 }
328 if( std::string::npos == idx ){
329 std::string relpath;
330 for(int i=1;i<oldpath.size();i++){
331 relpath[i-1] = oldpath[i];
332 }
333 realpath = std::string(getenv(relpath.c_str()));
334 }
335 }
336
337 return StatusCode::SUCCESS;
338}

Referenced by createAddress().

◆ decodeDescription() [2/2]

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

◆ finalize() [1/2]

StatusCode CalibRootCnvSvc::finalize ( )
virtual

Definition at line 134 of file CalibRootCnvSvc.cxx.

134 {
135 // If anything was allocated, get rid of it. So far, nothing was.
136
137 return ConversionSvc::finalize();
138}

◆ finalize() [2/2]

virtual StatusCode CalibRootCnvSvc::finalize ( )
virtual

◆ getrootfile() [1/2]

std::string CalibRootCnvSvc::getrootfile ( )
inlinevirtual

Implements ICalibRootSvc.

Definition at line 91 of file Calibration/CalibSvc/CalibROOTCnv/CalibROOTCnv-00-01-12/CalibROOTCnv/CalibRootCnvSvc.h.

92 { return m_rootfile[0];}

◆ getrootfile() [2/2]

std::string CalibRootCnvSvc::getrootfile ( )
inlinevirtual

Implements ICalibRootSvc.

Definition at line 91 of file InstallArea/include/CalibROOTCnv/CalibROOTCnv/CalibRootCnvSvc.h.

92 { return m_rootfile[0];}

◆ initialize() [1/2]

StatusCode CalibRootCnvSvc::initialize ( )
virtual

Definition at line 57 of file CalibRootCnvSvc.cxx.

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

◆ initialize() [2/2]

virtual StatusCode CalibRootCnvSvc::initialize ( )
virtual

◆ queryInterface() [1/2]

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

Definition at line 42 of file CalibRootCnvSvc.cxx.

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

◆ queryInterface() [2/2]

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

◆ updateObj() [1/2]

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

Definition at line 290 of file CalibRootCnvSvc.cxx.

291 {
292
293 // using facilities::Timestamp;
294
295 MsgStream log(msgSvc(), "CalibRootCnvSvc" );
296
297 // Don't update when we're using enter time
298 log << MSG::DEBUG << "CalibRootCnvSvc::updateObj starting ...."<<endreq;
299 /*
300 if (!m_useEventTime)
301 { log << MSG::DEBUG << "Method updateObj needn't update" << endreq;
302 return StatusCode::SUCCESS;
303 }
304 */
305}

◆ updateObj() [2/2]

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

◆ writeToRoot() [1/4]

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

Implements ICalibRootSvc.

Definition at line 270 of file CalibRootCnvSvc.cxx.

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

◆ writeToRoot() [2/4]

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

Implements ICalibRootSvc.

◆ writeToRoot() [3/4]

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

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

Referenced by writeToRoot().

◆ writeToRoot() [4/4]

virtual 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.

Friends And Related Function Documentation

◆ SvcFactory< CalibRootCnvSvc >

friend class SvcFactory< CalibRootCnvSvc >
friend

Only factories can access protected constructors.

Definition at line 1 of file Calibration/CalibSvc/CalibROOTCnv/CalibROOTCnv-00-01-12/CalibROOTCnv/CalibRootCnvSvc.h.


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