BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
CalibDataSvc Class Reference

#include <CalibDataSvc.h>

+ Inheritance diagram for CalibDataSvc:

Public Member Functions

virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 Finalize the service.
 
virtual StatusCode clearStore ()
 Remove all data objects in the data store.
 
virtual StatusCode updateObject (DataObject *toUpdate)
 Update object.
 
virtual StatusCode loadObject (IConversionSvc *pLoader, IRegistry *pRegistry)
 
virtual StatusCode retrieveObject (const std::string &fullPath, DataObject *&pObject)
 
virtual StatusCode registerObject (const std::string &parentPath, const std::string &objPath, DataObject *pObject)
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 Query the interface of the service.
 
virtual void handle (const Incident &)
 Inform that a new incident has occured.
 

Protected Member Functions

 CalibDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
 
virtual ~CalibDataSvc ()
 Standard Destructor.
 

Friends

class SvcFactory< CalibDataSvc >
 

Detailed Description

A DataSvc specialized for calibration data.
This Service borrows heavily from DetDataSvc. In particular it implements the IDetDataSvc interface. The only significant difference is in initialize() and in the elimination of members concerned with detector (geometry) description.

Maybe will also need to implement another abstract service which gets (and sets?) instrument.

Author
J. Bogart
Date
15 Oct. 2002

Definition at line 36 of file CalibDataSvc.h.

Constructor & Destructor Documentation

◆ CalibDataSvc()

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

Standard Constructor.

Definition at line 45 of file CalibDataSvc.cxx.

45 :
46 DataSvc(name,svc)
47 {
48
49 // declare a property which is a list of known calibrations.
50 // Have default list in one of the standard options files.
51 // User can add others.
52 declareProperty("CalibNameList", m_calibList);
53 declareProperty("CalibFlavorList", m_flavorList);
54 declareProperty("CalibRootName", m_calibRootName = "Calib" );
55 declareProperty("Mdc_CalibStorageType",
56 m_calibType[0] = CALIBROOT_StorageType );
57 declareProperty("Tof_CalibStorageType",
58 m_calibType[1] = CALIBROOT_StorageType );
59 declareProperty("Dedx_CalibStorageType",
60 m_calibType[2] = CALIBROOT_StorageType );
61 declareProperty("EMC_CalibStorageType",
62 m_calibType[3] = CALIBROOT_StorageType );
63 declareProperty("MUC_CalibStorageType",
64 m_calibType[4] = CALIBROOT_StorageType );
65 declareProperty("EsTime_CalibStorageType",
66 m_calibType[5] = CALIBROOT_StorageType );
67 declareProperty("EstTof_CalibStorageType",
68 m_calibType[6] = CALIBROOT_StorageType );
69 declareProperty("TofQElec_CalibStorageType",
70 m_calibType[8] = CALIBROOT_StorageType );
71 declareProperty("TofSim_CalibStorageType",
72 m_calibType[9] = CALIBROOT_StorageType );
73 declareProperty("DedxSim_CalibStorageType",
74 m_calibType[10] = CALIBROOT_StorageType );
75
76 //MdcAlign
77 m_calibType[7]=14;
78 //MdcDataConst
79 m_calibType[11]=14;
80
81 // m_rootName and m_rootCLID are declared in base class DataSvc
82 m_rootName = "/" + m_calibRootName;
83 m_rootCLID = CLID_DataObject;
84
85
86
87}
unsigned const char CALIBROOT_StorageType
Definition: ICalibRootSvc.h:20

◆ ~CalibDataSvc()

CalibDataSvc::~CalibDataSvc ( )
protectedvirtual

Standard Destructor.

Definition at line 90 of file CalibDataSvc.cxx.

90 {
91 setDataLoader(0);
92 clearStore();
93}
virtual StatusCode clearStore()
Remove all data objects in the data store.

Member Function Documentation

◆ clearStore()

StatusCode CalibDataSvc::clearStore ( )
virtual

Remove all data objects in the data store.

Definition at line 290 of file CalibDataSvc.cxx.

290 {
291 DataSvc::clearStore();
292 return StatusCode::SUCCESS;
293}

Referenced by ~CalibDataSvc().

◆ finalize()

StatusCode CalibDataSvc::finalize ( )
virtual

Finalize the service.

Definition at line 256 of file CalibDataSvc.cxx.

257{
258 MsgStream log(msgSvc(), name());
259 log << MSG::DEBUG << "Finalizing" << endreq;
260
261 // return StatusCode::SUCCESS;
262 // Finalize the base class
263 // huangb temply delete
264 return DataSvc::finalize();
265}
IMessageSvc * msgSvc()

◆ handle()

void CalibDataSvc::handle ( const Incident &  inc)
virtual

Inform that a new incident has occured.

Definition at line 296 of file CalibDataSvc.cxx.

296 {
297 MsgStream log( msgSvc(), name() );
298 return;
299 }

◆ initialize()

StatusCode CalibDataSvc::initialize ( )
virtual

Definition at line 96 of file CalibDataSvc.cxx.

96 {
97
98 StatusCode sc;
99
100 sc = DataSvc::initialize(); // Call base class initialisation
101 if (sc.isFailure() ) return sc;
102
103 // Set up MsgSvc, Data Loader
104 MsgStream log(msgSvc(), name());
105 IConversionSvc* cnv_svc;
106 sc = serviceLocator()->service("DetectorPersistencySvc", cnv_svc, true);
107 if (sc .isFailure() ) {
108 log << MSG::ERROR << "Unable to find DetectorPersistencySvc " << endreq;
109 return sc;
110 }
111
112 IIncidentSvc* incsvc;
113 sc = service("IncidentSvc", incsvc);
114 int priority = 100;
115 if( sc.isSuccess() ){
116 incsvc -> addListener(this, "NewRun", priority);
117 }
118
119 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true);
120 if (sc .isFailure() ) {
121 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq;
122 return sc;
123 }
124
125 sc = setDataLoader(cnv_svc);
126 if (sc.isFailure() ) {
127 log << MSG::ERROR << "Unable to set data loader " << endreq;
128 return sc;
129 }
130 sc = setProperties();
131
132 // Initialize the calibration data transient store
133 IAddressCreator* calibCreator = 0;
134
135 // Use Gaudi-supplied DetectorPersistencySvc; it's essentially
136 // the same as base class PersistencySvc, which is all we need
137 sc = serviceLocator()->service("DetectorPersistencySvc", calibCreator);
138
139 if( sc.isFailure() ) {
140 log << MSG::ERROR << "Unable to locate DetectorPersistencySvc." << endreq;
141 return StatusCode::FAILURE;
142 }
143
144 // Make the root for the TDDS data
145 DataObject* rootObj = new DataObject();
146 sc = setRoot(m_rootName, rootObj);
147 if (!sc.isSuccess() ) {
148 log << MSG::ERROR << "Unable to set calib data store root." << endreq;
149 delete rootObj;
150 return sc;
151 }
152
153// Create and register the next level of nodes.
154// Have one per calibration type. They are of a class trivially
155// derived from DataObject, CalibCLIDNode. Only additional
156// information is CLID of child nodes. List comes from CalibData
157// namespace
158//StatusCode CalibDataSvc::makeFlavorNodes(IAddressCreator* calibCreator,
159// MsgStream* log) {
160 typedef std::vector<CalibData::CalibModelSvc::CalibPair>::const_iterator
161 PairIt;
162 PairIt pairIt;
164 const std::vector<CalibData::CalibModelSvc::CalibPair>& pairs =
165 svc.getPairs();
166 int jj =0;
167 for (pairIt = pairs.begin(); pairIt != pairs.end(); pairIt++,jj++) {
168
169 CalibCLIDNode* node = new CalibCLIDNode(pairIt->second);
170
171 std::string calibTypePath(pairIt->first);
172 // sc =DataSvc::registerObject(calibTypePath, node);
173
174 // Still have to figure out what to do about args, iargs
175 unsigned long iargs[]={0,0};
176 IOpaqueAddress* pAddress;
177
178 // Set up nodes for each calibration type, default flavor
179 // Create and register addresses suitable for the metadata
180 // conversion service. Ultimately, in order to find the "right"
181 // set of constants, it needs to know
182 // Calibration type, e.g. CAL Electronic gain
183 // Flavor e.g. vanilla
184 // Event time validity period of constants must include this time
185 // Instrument LAT, EM, etc.
186 // We save the first two, or equivalent information, in the first
187 // string parameter of a generic address
188 // Consumers can use utilities in CalibData::CalibModelSvc to
189 // extract fields they need
190 // Event time and Instrument will be discovered by conversion service
191 // when constants are requested by invoking our (CalibDataSvc) time
192 // and instrument name services, resp.
193
194 // Always do vanilla
195 std::string fullpath = calibTypePath;
196 std::string args[] = {fullpath};
197
198// sc = calibCreator->createAddress(m_calibStorageType,
199// pairIt->second, // class id
200// args, iargs, pAddress);
201 sc = calibCreator->createAddress(m_calibType[jj],
202 pairIt->second, // class id
203 args, iargs, pAddress);
204
205
206 if (!sc.isSuccess()) {
207 log<< MSG::INFO
208 << "Unable to create Calib address with path " << fullpath << endreq;
209 }
210
211 // A node unof a specific flavor is a child of the per-calibration type
212 // node for which an object was registered above.
213 sc = registerAddress(fullpath, pAddress);
214 if (!sc.isSuccess()) {
215 log<< MSG::ERROR << "Unable to register Calib address with path"
216 << fullpath << endreq;
217 }
218 // Now do the same for any requested flavors
219 /*
220 unsigned int ix;
221
222 for (ix = 0; ix < m_flavorList.size(); ix++) {
223 log<<MSG::DEBUG<<"here is the flavor in the CalibDataSvc"<<endreq;
224 // Don't redo vanilla, if present in user list
225 if (m_flavorList[ix] == std::string("vanilla")) continue;
226
227 fullpath = calibTypePath + "/" + m_flavorList[ix];
228 args[0] = fullpath;
229
230 sc = calibCreator->createAddress(m_calibStorageType,
231 pairIt->second, args, iargs, pAddress);
232 if (!sc.isSuccess()) {
233
234
235 log<< MSG::ERROR << "Unable to create Calib address with path "
236 << fullpath << endreq;
237 }
238 sc = DataSvc::registerAddress(fullpath, pAddress);
239 if (!sc.isSuccess()) {
240 log<< MSG::ERROR << "Unable to register Calib address with path "
241 << fullpath << endreq;
242 }
243 }
244 // end flavor loop
245 */
246 }
247// end calibType loop
248// initialize the parameters
249
250 return StatusCode::SUCCESS;
251}
const std::vector< CalibPair > & getPairs() const
CalibPairCol::const_iterator PairIt
Definition: CalibModel.h:110
_EXTERN_ CalibPairCol pairs
Definition: CalibModel.h:111

◆ loadObject()

StatusCode CalibDataSvc::loadObject ( IConversionSvc *  pLoader,
IRegistry *  pRegistry 
)
virtual

Load object. Override DataSvc implementation to get current event time first if necessary

Definition at line 333 of file CalibDataSvc.cxx.

334 {
335 return DataSvc::loadObject(pLoader, pRegistry);
336
337}

◆ queryInterface()

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

Query the interface of the service.

Definition at line 267 of file CalibDataSvc.cxx.

268{
269 // With the highest priority return the specific interfaces
270 // If interfaces are not directly available, try out a base class
271 if (IDetDataSvc::interfaceID().versionMatch(riid) ) {
272 *ppvInterface = (IDetDataSvc*)this;
273 } else if (IInstrumentName::interfaceID().versionMatch(riid) ) {
274 *ppvInterface = (IInstrumentName*) this;
275// } else if ( IID_IIncidentListener.versionMatch(riid) ) {
276// *ppvInterface = (IIncidentListener*)this;
277 } else {
278 return DataSvc::queryInterface(riid, ppvInterface);
279 }
280 addRef();
281 return StatusCode::SUCCESS;
282}
Simple interface to keep track of which instrument (LAT, EM, etc.) the process is concerned with....
static const InterfaceID & interfaceID()

◆ registerObject()

StatusCode CalibDataSvc::registerObject ( const std::string &  parentPath,
const std::string &  objPath,
DataObject *  pObject 
)
virtual

Definition at line 413 of file CalibDataSvc.cxx.

415 {
416 DataObject* pO = 0;
417 StatusCode status =DataSvc::retrieveObject(parentPath, pO);
418 if ( !status.isSuccess() && m_forceLeaves ) {
419 pO = createDefaultObject();
420 status =DataSvc::registerObject(parentPath, pO);
421 if ( !status.isSuccess() ) {
422 pO->release();
423 }//end of if
424 }//end of if( !status.isSuccess() && m_forceLeaves )
425 if ( status.isSuccess() ) {
426 status =DataSvc::registerObject(pO, objPath, pObject);
427 }
428 if(status.isSuccess() ){
429 return status;
430}
431}

◆ retrieveObject()

StatusCode CalibDataSvc::retrieveObject ( const std::string &  fullPath,
DataObject *&  pObject 
)
virtual

Definition at line 339 of file CalibDataSvc.cxx.

340{
341 MsgStream log( msgSvc(), name() );
342
343 int runNo;
344 //maqm SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event");
345 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event/EventHeader");
346 if( evt ){
347 runNo = evt -> runNumber();
348 log << MSG::DEBUG <<"The runNumber of current event is "<<runNo<<endreq;
349 }
350
351 else{
352 log << MSG::WARNING << "WARNING accessing Event" <<endreq;
353// return StatusCode::FAILURE;
354 }
355
356
357StatusCode sc =DataSvc::retrieveObject(fullPath,pObject);
358 if (!sc.isSuccess()) {
359 log<< MSG::ERROR << "Unable to get the retrieveObject"
360 << endreq;
361 return sc;
362 }
363// if(fullPath=="/Calib/MdcAlign"&&m_calibType[0]==CALIBROOT_StorageType)
364// { return StatusCode::SUCCESS;}
365if(fullPath=="/Calib/MdcCal"&&m_calibType[0]==CALIBROOT_StorageType){
366 return StatusCode::SUCCESS;}
367if(fullPath=="/Calib/DedxCal"&&m_calibType[2]==CALIBROOT_StorageType){
368 return StatusCode::SUCCESS;}
369if(fullPath=="/Calib/TofCal"&&m_calibType[1]==CALIBROOT_StorageType){
370 return StatusCode::SUCCESS;}
371if(fullPath=="/Calib/EmcCal"&&m_calibType[3]==CALIBROOT_StorageType){
372 return StatusCode::SUCCESS;}
373if(fullPath=="/Calib/MucCal"&&m_calibType[4]==CALIBROOT_StorageType){
374 return StatusCode::SUCCESS;}
375if(fullPath=="/Calib/EsTimeCal"&&m_calibType[5]==CALIBROOT_StorageType){
376 return StatusCode::SUCCESS;}
377if(fullPath=="/Calib/EstTofCal"&&m_calibType[6]==CALIBROOT_StorageType){
378 return StatusCode::SUCCESS;}
379if(fullPath=="/Calib/TofQElec"&&m_calibType[8]==CALIBROOT_StorageType){
380 return StatusCode::SUCCESS;}
381if(fullPath=="/Calib/TofSim"&&m_calibType[9]==CALIBROOT_StorageType){
382 return StatusCode::SUCCESS;}
383if(fullPath=="/Calib/DedxSim"&&m_calibType[10]==CALIBROOT_StorageType){
384 return StatusCode::SUCCESS;}
385
386
387CalibData::CalibBase1* tmpObject = dynamic_cast<CalibData::CalibBase1*>(pObject);
388if(fullPath=="/Calib/TofCal"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
389{ return StatusCode::SUCCESS;}
390if(fullPath=="/Calib/EstTofCal"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
391{ return StatusCode::SUCCESS;}
392if(fullPath=="/Calib/TofSim"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
393{ return StatusCode::SUCCESS;}
394if(fullPath=="/Calib/DedxSim"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
395{ return StatusCode::SUCCESS;}
396
397
398
399if( fabs(runNo) >= tmpObject->getrunfrm() && fabs(runNo)<=tmpObject->getrunto())
400{
401 log << MSG::DEBUG <<__LINE__<< " runfrm @CalibDataSvc is:"<<tmpObject->getrunfrm()<<" runto min is:"<<tmpObject->getrunto()<<endreq;
402 return StatusCode::SUCCESS;}
403else
404{
405 log<< MSG::INFO <<"@CalibDataSvc runfrm="<< tmpObject->getrunfrm()<<"runto="<<tmpObject->getrunto()<<"runNo="<<runNo<<endreq;
406 log<< MSG::DEBUG << "update the Object"
407 << endreq;
408 sc =DataSvc:: updateObject(pObject);
409 return sc;
410}//end of else
411}//end of if
int runNo
virtual int getrunto() const
Definition: CalibBase1.h:53
virtual int getrunfrm() const
Definition: CalibBase1.h:52

◆ updateObject()

StatusCode CalibDataSvc::updateObject ( DataObject *  toUpdate)
virtual

Update object.

Definition at line 306 of file CalibDataSvc.cxx.

306 {
307
308
309 MsgStream log( msgSvc(), name() );
310 log << MSG::INFO<<"begin of CalibDataSvc::updateObject"<<endreq;
311 // Check that object to update exists
312 if ( 0 == toUpdate ) {
313 log << MSG::ERROR
314 << "There is no DataObject to update" << endreq;
315 return INVALID_OBJECT;
316 }
317
318 log << MSG::INFO<<"begin of CalibDataSvc::updateObject"<<endreq;
319 // Now delegate update to the conversion service by calling the base class
320 StatusCode status = DataSvc::updateObject(toUpdate);
321 if ( !status.isSuccess() ) {
322 log << MSG::ERROR
323 << "Could not update DataObject" << endreq;
324 if ( status == NO_DATA_LOADER )
325 log << MSG::ERROR << "There is no data loader" << endreq;
326 return status;
327 }
328 log << MSG::INFO<<"begin of CalibDataSvc::updateObject successfully updated"<<endreq;
329 // DataObject was successfully updated
330 return StatusCode::SUCCESS;
331}

Friends And Related Function Documentation

◆ SvcFactory< CalibDataSvc >

friend class SvcFactory< CalibDataSvc >
friend

Definition at line 1 of file CalibDataSvc.h.


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