BOSS 7.0.6
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)
 
 CalibDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
 
virtual ~CalibDataSvc ()
 Standard Destructor.
 
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.
 

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 
)

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 //Top_up Qiumei Ma
76 declareProperty("InjSigInterval_CalibStorageType",
77 m_calibType[12] = CALIBROOT_StorageType );
78 declareProperty("InjSigTime_CalibStorageType",
79 m_calibType[13] = CALIBROOT_StorageType );
80 declareProperty("OffEvtFilter_CalibStorageType",
81 m_calibType[14] = CALIBROOT_StorageType );
82 declareProperty("CorrectedETS_CalibStorageType",
83 m_calibType[15] = CALIBROOT_StorageType );
84
85 std::cout<<"CALIBROOT_StorageType " <<CALIBROOT_StorageType<<" "<<std::endl;
86 //MdcAlign
87 m_calibType[7]=14;
88 //MdcDataConst
89 m_calibType[11]=14;
90
91 // m_rootName and m_rootCLID are declared in base class DataSvc
92 m_rootName = "/" + m_calibRootName;
93 m_rootCLID = CLID_DataObject;
94
95
96
97}
unsigned const char CALIBROOT_StorageType
Definition: ICalibRootSvc.h:20

◆ ~CalibDataSvc()

CalibDataSvc::~CalibDataSvc ( )
virtual

Standard Destructor.

Definition at line 100 of file CalibDataSvc.cxx.

100 {
101 setDataLoader(0);
102 clearStore();
103}
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 297 of file CalibDataSvc.cxx.

297 {
298 DataSvc::clearStore();
299 return StatusCode::SUCCESS;
300}

Referenced by ~CalibDataSvc().

◆ finalize()

StatusCode CalibDataSvc::finalize ( )
virtual

Finalize the service.

Definition at line 263 of file CalibDataSvc.cxx.

264{
265 MsgStream log(msgSvc(), name());
266 log << MSG::DEBUG << "Finalizing" << endreq;
267
268 // return StatusCode::SUCCESS;
269 // Finalize the base class
270 // huangb temply delete
271 return DataSvc::finalize();
272}
IMessageSvc * msgSvc()

◆ handle()

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

Inform that a new incident has occured.

Definition at line 303 of file CalibDataSvc.cxx.

303 {
304 MsgStream log( msgSvc(), name() );
305 return;
306}

◆ initialize()

StatusCode CalibDataSvc::initialize ( )
virtual

Definition at line 106 of file CalibDataSvc.cxx.

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

◆ 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 340 of file CalibDataSvc.cxx.

341 {
342 return DataSvc::loadObject(pLoader, pRegistry);
343
344}

◆ queryInterface()

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

Query the interface of the service.

Definition at line 274 of file CalibDataSvc.cxx.

275{
276 // With the highest priority return the specific interfaces
277 // If interfaces are not directly available, try out a base class
278 if (IDetDataSvc::interfaceID().versionMatch(riid) ) {
279 *ppvInterface = (IDetDataSvc*)this;
280 } else if (IInstrumentName::interfaceID().versionMatch(riid) ) {
281 *ppvInterface = (IInstrumentName*) this;
282 // } else if ( IID_IIncidentListener.versionMatch(riid) ) {
283 // *ppvInterface = (IIncidentListener*)this;
284} else {
285 return DataSvc::queryInterface(riid, ppvInterface);
286}
287addRef();
288return StatusCode::SUCCESS;
289}
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 428 of file CalibDataSvc.cxx.

430 {
431 DataObject* pO = 0;
432 StatusCode status =DataSvc::retrieveObject(parentPath, pO);
433 if ( !status.isSuccess() && m_forceLeaves ) {
434 pO = createDefaultObject();
435 status =DataSvc::registerObject(parentPath, pO);
436 if ( !status.isSuccess() ) {
437 pO->release();
438 }//end of if
439 }//end of if( !status.isSuccess() && m_forceLeaves )
440 if ( status.isSuccess() ) {
441 status =DataSvc::registerObject(pO, objPath, pObject);
442 }
443 if(status.isSuccess() ){
444 return status;
445 }
446}

◆ retrieveObject()

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

Definition at line 346 of file CalibDataSvc.cxx.

347{
348 MsgStream log( msgSvc(), name() );
349
350 int runNo;
351 //maqm SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event");
352 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event/EventHeader");
353 if( evt ){
354 runNo = evt -> runNumber();
355 log << MSG::DEBUG <<"The runNumber of current event is "<<runNo<<endreq;
356 }
357
358 else{
359 log << MSG::WARNING << "WARNING accessing Event" <<endreq;
360 // return StatusCode::FAILURE;
361 }
362
363
364 StatusCode sc =DataSvc::retrieveObject(fullPath,pObject);
365 if (!sc.isSuccess()) {
366 log<< MSG::ERROR << "Unable to get the retrieveObject"
367 << endreq;
368 return sc;
369 }
370 // if(fullPath=="/Calib/MdcAlign"&&m_calibType[0]==CALIBROOT_StorageType)
371 // { return StatusCode::SUCCESS;}
372 if(fullPath=="/Calib/MdcCal"&&m_calibType[0]==CALIBROOT_StorageType){
373 return StatusCode::SUCCESS;}
374 if(fullPath=="/Calib/DedxCal"&&m_calibType[2]==CALIBROOT_StorageType){
375 return StatusCode::SUCCESS;}
376 if(fullPath=="/Calib/TofCal"&&m_calibType[1]==CALIBROOT_StorageType){
377 return StatusCode::SUCCESS;}
378 if(fullPath=="/Calib/EmcCal"&&m_calibType[3]==CALIBROOT_StorageType){
379 return StatusCode::SUCCESS;}
380 if(fullPath=="/Calib/MucCal"&&m_calibType[4]==CALIBROOT_StorageType){
381 return StatusCode::SUCCESS;}
382 if(fullPath=="/Calib/EsTimeCal"&&m_calibType[5]==CALIBROOT_StorageType){
383 return StatusCode::SUCCESS;}
384 if(fullPath=="/Calib/EstTofCal"&&m_calibType[6]==CALIBROOT_StorageType){
385 return StatusCode::SUCCESS;}
386 if(fullPath=="/Calib/TofQElec"&&m_calibType[8]==CALIBROOT_StorageType){
387 return StatusCode::SUCCESS;}
388 if(fullPath=="/Calib/TofSim"&&m_calibType[9]==CALIBROOT_StorageType){
389 return StatusCode::SUCCESS;}
390 if(fullPath=="/Calib/DedxSim"&&m_calibType[10]==CALIBROOT_StorageType){
391 return StatusCode::SUCCESS;}
392 //Top_up Qiumei Ma
393 if(fullPath=="/Calib/InjSigInterval"&&m_calibType[12]==CALIBROOT_StorageType){
394 return StatusCode::SUCCESS;}
395 if(fullPath=="/Calib/InjSigTime"&&m_calibType[13]==CALIBROOT_StorageType){
396 return StatusCode::SUCCESS;}
397 if(fullPath=="/Calib/OffEvtFilter"&&m_calibType[14]==CALIBROOT_StorageType){
398 return StatusCode::SUCCESS;}
399 if(fullPath=="/Calib/CorrectedETS"&&m_calibType[15]==CALIBROOT_StorageType){
400 return StatusCode::SUCCESS;}
401
402 CalibData::CalibBase1* tmpObject = dynamic_cast<CalibData::CalibBase1*>(pObject);
403 if(fullPath=="/Calib/TofCal"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
404 { return StatusCode::SUCCESS;}
405 if(fullPath=="/Calib/EstTofCal"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
406 { return StatusCode::SUCCESS;}
407 if(fullPath=="/Calib/TofSim"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
408 { return StatusCode::SUCCESS;}
409 if(fullPath=="/Calib/DedxSim"&&runNo>= tmpObject->getrunfrm()&&runNo<=tmpObject->getrunto())
410 { return StatusCode::SUCCESS;}
411
412
413
414 if( fabs(runNo) >= tmpObject->getrunfrm() && fabs(runNo)<=tmpObject->getrunto())
415 {
416 log << MSG::DEBUG <<__LINE__<< " runfrm @CalibDataSvc is:"<<tmpObject->getrunfrm()<<" runto min is:"<<tmpObject->getrunto()<<endreq;
417 return StatusCode::SUCCESS;}
418 else
419 {
420 log<< MSG::INFO <<"@CalibDataSvc runfrm="<< tmpObject->getrunfrm()<<"runto="<<tmpObject->getrunto()<<"runNo="<<runNo<<endreq;
421 log<< MSG::DEBUG << "update the Object"
422 << endreq;
423 sc =DataSvc:: updateObject(pObject);
424 return sc;
425 }//end of else
426}//end of if
int runNo
Definition: DQA_TO_DB.cxx:12
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 313 of file CalibDataSvc.cxx.

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

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: