BOSS 7.1.1
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 void handle (const Incident &)
 Query the interface of the service.
 

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

47 :
48 DataSvc(name,svc)
49{
50
51 // declare a property which is a list of known calibrations.
52 // Have default list in one of the standard options files.
53 // User can add others.
54 declareProperty("CalibNameList", m_calibList);
55 declareProperty("CalibFlavorList", m_flavorList);
56 declareProperty("CalibRootName", m_calibRootName = "Calib" );
57 declareProperty("Mdc_CalibStorageType",
58 m_calibType[0] = CALIBROOT_StorageType );
59 declareProperty("Tof_CalibStorageType",
60 m_calibType[1] = CALIBROOT_StorageType );
61 declareProperty("Dedx_CalibStorageType",
62 m_calibType[2] = CALIBROOT_StorageType );
63 declareProperty("EMC_CalibStorageType",
64 m_calibType[3] = CALIBROOT_StorageType );
65 declareProperty("MUC_CalibStorageType",
66 m_calibType[4] = CALIBROOT_StorageType );
67 declareProperty("EsTime_CalibStorageType",
68 m_calibType[5] = CALIBROOT_StorageType );
69 declareProperty("EstTof_CalibStorageType",
70 m_calibType[6] = CALIBROOT_StorageType );
71 declareProperty("TofQElec_CalibStorageType",
72 m_calibType[8] = CALIBROOT_StorageType );
73 declareProperty("TofSim_CalibStorageType",
74 m_calibType[9] = CALIBROOT_StorageType );
75 declareProperty("DedxSim_CalibStorageType",
76 m_calibType[10] = CALIBROOT_StorageType );
77 //Top_up Qiumei Ma
78 declareProperty("InjSigInterval_CalibStorageType",
79 m_calibType[12] = CALIBROOT_StorageType );
80 declareProperty("InjSigTime_CalibStorageType",
81 m_calibType[13] = CALIBROOT_StorageType );
82 declareProperty("OffEvtFilter_CalibStorageType",
83 m_calibType[14] = CALIBROOT_StorageType );
84 declareProperty("CorrectedETS_CalibStorageType",
85 m_calibType[15] = CALIBROOT_StorageType );
86
87 std::cout<<"CALIBROOT_StorageType is:::" <<CALIBROOT_StorageType<<" "<<std::endl;
88 //MdcAlign
89 m_calibType[7]=14;
90 //MdcDataConst
91 m_calibType[11]=14;
92
93 // m_rootName and m_rootCLID are declared in base class DataSvc
94 m_rootName = "/" + m_calibRootName;
95 m_rootCLID = CLID_DataObject;
96
97
98
99}
unsigned const char CALIBROOT_StorageType

◆ ~CalibDataSvc()

CalibDataSvc::~CalibDataSvc ( )
virtual

Standard Destructor.

Definition at line 102 of file CalibDataSvc.cxx.

102 {
103 setDataLoader(0);
104 clearStore();
105}
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 299 of file CalibDataSvc.cxx.

299 {
300 DataSvc::clearStore();
301 return StatusCode::SUCCESS;
302}

Referenced by ~CalibDataSvc().

◆ finalize()

StatusCode CalibDataSvc::finalize ( )
virtual

Finalize the service.

Definition at line 265 of file CalibDataSvc.cxx.

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

◆ handle()

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

Query the interface of the service.

Inform that a new incident has occured

Definition at line 305 of file CalibDataSvc.cxx.

305 {
306 MsgStream log( msgSvc(), name() );
307 return;
308}

◆ initialize()

StatusCode CalibDataSvc::initialize ( )
virtual

Definition at line 108 of file CalibDataSvc.cxx.

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

343 {
344 return DataSvc::loadObject(pLoader, pRegistry);
345
346}

◆ registerObject()

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

Definition at line 430 of file CalibDataSvc.cxx.

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

◆ retrieveObject()

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

Definition at line 348 of file CalibDataSvc.cxx.

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

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

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