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

#include <CalibDataSvc.h>

Inheritance diagram for CalibDataSvc:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode finalize () override
 Finalize the service.
virtual StatusCode clearStore () override
 Remove all data objects in the data store.
virtual StatusCode updateObject (DataObject *toUpdate) override
 Update object.
virtual StatusCode loadObject (IConversionSvc *pLoader, IRegistry *pRegistry) override
virtual StatusCode retrieveObject (IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
virtual StatusCode registerObject (std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
 CalibDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
virtual ~CalibDataSvc ()
 Standard Destructor.
virtual void handle (const Incident &) override
 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 37 of file CalibDataSvc.h.

Constructor & Destructor Documentation

◆ CalibDataSvc()

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

Standard Constructor.

Definition at line 46 of file CalibDataSvc.cxx.

47 : DataSvc( name, svc ) {
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", m_calibType[0] = CALIBROOT_StorageType );
56 declareProperty( "Tof_CalibStorageType", m_calibType[1] = CALIBROOT_StorageType );
57 declareProperty( "Dedx_CalibStorageType", m_calibType[2] = CALIBROOT_StorageType );
58 declareProperty( "Emc_CalibStorageType", m_calibType[3] = CALIBROOT_StorageType );
59 declareProperty( "Muc_CalibStorageType", m_calibType[4] = CALIBROOT_StorageType );
60 declareProperty( "EsTime_CalibStorageType", m_calibType[5] = CALIBROOT_StorageType );
61 declareProperty( "EstTof_CalibStorageType", m_calibType[6] = CALIBROOT_StorageType );
62 declareProperty( "TofQElec_CalibStorageType", m_calibType[8] = CALIBROOT_StorageType );
63 declareProperty( "TofSim_CalibStorageType", m_calibType[9] = CALIBROOT_StorageType );
64 declareProperty( "DedxSim_CalibStorageType", m_calibType[10] = CALIBROOT_StorageType );
65 // Top_up Qiumei Ma
66 declareProperty( "InjSigInterval_CalibStorageType",
67 m_calibType[12] = CALIBROOT_StorageType );
68 declareProperty( "InjSigTime_CalibStorageType", m_calibType[13] = CALIBROOT_StorageType );
69 declareProperty( "OffEvtFilter_CalibStorageType", m_calibType[14] = CALIBROOT_StorageType );
70 declareProperty( "CorrectedETS_CalibStorageType", m_calibType[15] = CALIBROOT_StorageType );
71
72 std::cout << "CALIBROOT_StorageType is:::" << CALIBROOT_StorageType << " " << std::endl;
73 // MdcAlign
74 m_calibType[7] = 14;
75 // MdcDataConst
76 m_calibType[11] = 14;
77
78 // m_rootName and m_rootCLID are declared in base class DataSvc
79 m_rootName = "/" + m_calibRootName;
80 m_rootCLID = CLID_DataObject;
81}

◆ ~CalibDataSvc()

CalibDataSvc::~CalibDataSvc ( )
virtual

Standard Destructor.

Definition at line 84 of file CalibDataSvc.cxx.

84 {
85 setDataLoader( 0 ).ignore();
86 clearStore().ignore();
87}
virtual StatusCode clearStore() override
Remove all data objects in the data store.

Member Function Documentation

◆ clearStore()

StatusCode CalibDataSvc::clearStore ( )
overridevirtual

Remove all data objects in the data store.

Definition at line 277 of file CalibDataSvc.cxx.

277 {
278 DataSvc::clearStore().ignore();
279 return StatusCode::SUCCESS;
280}

Referenced by ~CalibDataSvc().

◆ finalize()

StatusCode CalibDataSvc::finalize ( )
overridevirtual

Finalize the service.

Definition at line 248 of file CalibDataSvc.cxx.

248 {
249 MsgStream log( msgSvc(), name() );
250 log << MSG::DEBUG << "Finalizing" << endmsg;
251
252 // return StatusCode::SUCCESS;
253 // Finalize the base class
254 // huangb temply delete
255 return DataSvc::finalize();
256}
IMessageSvc * msgSvc()

◆ handle()

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

Query the interface of the service.

Inform that a new incident has occured

Definition at line 283 of file CalibDataSvc.cxx.

283 {
284 MsgStream log( msgSvc(), name() );
285 return;
286}

◆ initialize()

StatusCode CalibDataSvc::initialize ( )
overridevirtual

Definition at line 90 of file CalibDataSvc.cxx.

90 {
91
92 StatusCode sc;
93
94 sc = DataSvc::initialize(); // Call base class initialisation
95 if ( sc.isFailure() ) return sc;
96
97 // Set up MsgSvc, Data Loader
98 MsgStream log( msgSvc(), name() );
99 IConversionSvc* cnv_svc;
100 sc = serviceLocator()->service( "DetectorPersistencySvc", cnv_svc, true );
101 if ( sc.isFailure() )
102 {
103 log << MSG::ERROR << "Unable to find DetectorPersistencySvc " << endmsg;
104 return sc;
105 }
106
107 IIncidentSvc* incsvc;
108 sc = service( "IncidentSvc", incsvc );
109 int priority = 100;
110 if ( sc.isSuccess() ) { incsvc->addListener( this, "NewRun", priority ); }
111
112 sc = serviceLocator()->service( "EventDataSvc", m_eventSvc, true );
113 if ( sc.isFailure() )
114 {
115 log << MSG::ERROR << "Unable to find EventDataSvc " << endmsg;
116 return sc;
117 }
118
119 sc = setDataLoader( cnv_svc );
120 if ( sc.isFailure() )
121 {
122 log << MSG::ERROR << "Unable to set data loader " << endmsg;
123 return sc;
124 }
125 // sc = setProperties();
126
127 // Initialize the calibration data transient store
128 IAddressCreator* calibCreator = 0;
129
130 // Use Gaudi-supplied DetectorPersistencySvc; it's essentially
131 // the same as base class PersistencySvc, which is all we need
132 sc = serviceLocator()->service( "DetectorPersistencySvc", calibCreator );
133
134 if ( sc.isFailure() )
135 {
136 log << MSG::ERROR << "Unable to locate DetectorPersistencySvc." << endmsg;
137 return StatusCode::FAILURE;
138 }
139
140 // Make the root for the TDDS data
141 debug() << "Setting root: " << m_rootName.value() << endmsg;
142 DataObject* rootObj = new DataObject();
143 sc = setRoot( m_rootName.value(), rootObj );
144 if ( !sc.isSuccess() )
145 {
146 log << MSG::ERROR << "Unable to set calib data store root." << endmsg;
147 delete rootObj;
148 return sc;
149 }
150
151 // Create and register the next level of nodes.
152 // Have one per calibration type. They are of a class trivially
153 // derived from DataObject, CalibCLIDNode. Only additional
154 // information is CLID of child nodes. List comes from CalibData
155 // namespace
156 // StatusCode CalibDataSvc::makeFlavorNodes(IAddressCreator* calibCreator,
157 // MsgStream* log) {
158 typedef std::vector<CalibData::CalibModelSvc::CalibPair>::const_iterator PairIt;
159
160 PairIt pairIt;
161 CalibData::CalibModelSvc svc;
162
163 const std::vector<CalibData::CalibModelSvc::CalibPair>& pairs = svc.getPairs();
164
165 int jj = 0;
166 for ( pairIt = pairs.begin(); pairIt != pairs.end(); pairIt++, jj++ )
167 {
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_calibType[jj],
199 pairIt->second, // class id
200 args, iargs, pAddress );
201
202 if ( !sc.isSuccess() )
203 { log << MSG::INFO << "Unable to create Calib address with path " << fullpath << endmsg; }
204
205 // A node unof a specific flavor is a child of the per-calibration type
206 // node for which an object was registered above.
207 sc = registerAddress( fullpath, pAddress );
208 if ( !sc.isSuccess() )
209 {
210 log << MSG::ERROR << "Unable to register Calib address with path" << fullpath << endmsg;
211 }
212 // Now do the same for any requested flavors
213 /*
214 unsigned int ix;
215
216 for (ix = 0; ix < m_flavorList.size(); ix++) {
217 log<<MSG::DEBUG<<"here is the flavor in the CalibDataSvc"<<endmsg;
218 // Don't redo vanilla, if present in user list
219 if (m_flavorList[ix] == std::string("vanilla")) continue;
220
221 fullpath = calibTypePath + "/" + m_flavorList[ix];
222 args[0] = fullpath;
223
224 sc = calibCreator->createAddress(m_calibStorageType,
225 pairIt->second, args, iargs, pAddress);
226 if (!sc.isSuccess()) {
227
228
229 log<< MSG::ERROR << "Unable to create Calib address with path "
230 << fullpath << endmsg;
231 }
232 sc = DataSvc::registerAddress(fullpath, pAddress);
233 if (!sc.isSuccess()) {
234 log<< MSG::ERROR << "Unable to register Calib address with path "
235 << fullpath << endmsg;
236 }
237 }
238 // end flavor loop
239 */
240 }
241 // end calibType loop
242 // initialize the parameters
243
244 return StatusCode::SUCCESS;
245}
const std::vector< CalibPair > & getPairs() const

◆ loadObject()

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

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

Definition at line 313 of file CalibDataSvc.cxx.

313 {
314 return DataSvc::loadObject( pLoader, pRegistry );
315}

◆ registerObject()

StatusCode CalibDataSvc::registerObject ( std::string_view parentPath,
std::string_view objPath,
DataObject * pObject )
overridevirtual

Definition at line 407 of file CalibDataSvc.cxx.

408 {
409 fatal() << "In registerObject, parentPath=" << parentPath << " objPath=" << objPath
410 << " pObject=" << pObject << endmsg;
411
412 DataObject* pO = 0;
413 StatusCode status = DataSvc::retrieveObject( parentPath, pO );
414
415 bool isForceLeaves =
416 DataSvc::getProperty( "ForceLeaves" ).toString() == "true"; // added by mrli 2024-6-11
417 if ( !status.isSuccess() && isForceLeaves )
418 {
419 pO = createDefaultObject();
420 status = DataSvc::registerObject( parentPath, pO );
421 if ( !status.isSuccess() ) { pO->release(); } // end of if
422 } // end of if( !status.isSuccess() && m_forceLeaves )
423 if ( status.isSuccess() ) { status = DataSvc::registerObject( pO, objPath, pObject ); }
424 if ( status.isSuccess() )
425 {
426 fatal() << "registerObject [" << status.isSuccess() << "]: parentPath = " << parentPath
427 << " objPath = " << objPath << " pObject = " << pObject << endmsg;
428 return status;
429 }
430
431 return status;
432}

◆ retrieveObject()

StatusCode CalibDataSvc::retrieveObject ( IRegistry * pDirectory,
std::string_view path,
DataObject *& pObject )
overridevirtual

Definition at line 317 of file CalibDataSvc.cxx.

318 {
319
320 MsgStream log( msgSvc(), name() );
321
322 debug() << "In retrieveObject" << endmsg;
323
324 int runNo;
325 // maqm SmartDataPtr<Event::EventHeader> evt(m_eventSvc,"/Event");
326 SmartDataPtr<Event::EventHeader> evt( m_eventSvc, "/Event/EventHeader" );
327 if ( evt )
328 {
329 runNo = evt->runNumber();
330 log << MSG::DEBUG << "The runNumber of current event is " << runNo << endmsg;
331 }
332
333 else
334 {
335 log << MSG::WARNING << "WARNING accessing Event" << endmsg;
336 // return StatusCode::FAILURE;
337 }
338
339 StatusCode sc = DataSvc::retrieveObject( pDirectory, fullPath, pObject );
340 if ( !sc.isSuccess() )
341 {
342 log << MSG::ERROR << "Unable to get the retrieveObject" << endmsg;
343 return sc;
344 }
345 // if(fullPath=="/Calib/MdcAlign"&&m_calibType[0]==CALIBROOT_StorageType)
346 // { return StatusCode::SUCCESS;}
347 if ( fullPath == "/Calib/MdcCal" && m_calibType[0] == CALIBROOT_StorageType )
348 { return StatusCode::SUCCESS; }
349 if ( fullPath == "/Calib/DedxCal" && m_calibType[2] == CALIBROOT_StorageType )
350 { return StatusCode::SUCCESS; }
351 if ( fullPath == "/Calib/TofCal" && m_calibType[1] == CALIBROOT_StorageType )
352 { return StatusCode::SUCCESS; }
353 if ( fullPath == "/Calib/EmcCal" && m_calibType[3] == CALIBROOT_StorageType )
354 { return StatusCode::SUCCESS; }
355 if ( fullPath == "/Calib/MucCal" && m_calibType[4] == CALIBROOT_StorageType )
356 { return StatusCode::SUCCESS; }
357 if ( fullPath == "/Calib/EsTimeCal" && m_calibType[5] == CALIBROOT_StorageType )
358 { return StatusCode::SUCCESS; }
359 if ( fullPath == "/Calib/EstTofCal" && m_calibType[6] == CALIBROOT_StorageType )
360 { return StatusCode::SUCCESS; }
361 if ( fullPath == "/Calib/TofQElec" && m_calibType[8] == CALIBROOT_StorageType )
362 { return StatusCode::SUCCESS; }
363 if ( fullPath == "/Calib/TofSim" && m_calibType[9] == CALIBROOT_StorageType )
364 { return StatusCode::SUCCESS; }
365 if ( fullPath == "/Calib/DedxSim" && m_calibType[10] == CALIBROOT_StorageType )
366 { return StatusCode::SUCCESS; }
367 // Top_up Qiumei Ma
368 if ( fullPath == "/Calib/InjSigInterval" && m_calibType[12] == CALIBROOT_StorageType )
369 { return StatusCode::SUCCESS; }
370 if ( fullPath == "/Calib/InjSigTime" && m_calibType[13] == CALIBROOT_StorageType )
371 { return StatusCode::SUCCESS; }
372 if ( fullPath == "/Calib/OffEvtFilter" && m_calibType[14] == CALIBROOT_StorageType )
373 { return StatusCode::SUCCESS; }
374 if ( fullPath == "/Calib/CorrectedETS" && m_calibType[15] == CALIBROOT_StorageType )
375 { return StatusCode::SUCCESS; }
376
377 CalibData::CalibBase1* tmpObject = dynamic_cast<CalibData::CalibBase1*>( pObject );
378 if ( fullPath == "/Calib/TofCal" && runNo >= tmpObject->getrunfrm() &&
379 runNo <= tmpObject->getrunto() )
380 { return StatusCode::SUCCESS; }
381 if ( fullPath == "/Calib/EstTofCal" && runNo >= tmpObject->getrunfrm() &&
382 runNo <= tmpObject->getrunto() )
383 { return StatusCode::SUCCESS; }
384 if ( fullPath == "/Calib/TofSim" && runNo >= tmpObject->getrunfrm() &&
385 runNo <= tmpObject->getrunto() )
386 { return StatusCode::SUCCESS; }
387 if ( fullPath == "/Calib/DedxSim" && runNo >= tmpObject->getrunfrm() &&
388 runNo <= tmpObject->getrunto() )
389 { return StatusCode::SUCCESS; }
390
391 if ( abs( runNo ) >= tmpObject->getrunfrm() && abs( runNo ) <= tmpObject->getrunto() )
392 {
393 log << MSG::DEBUG << __LINE__ << " runfrm @CalibDataSvc is:" << tmpObject->getrunfrm()
394 << " runto min is:" << tmpObject->getrunto() << endmsg;
395 return StatusCode::SUCCESS;
396 }
397 else
398 {
399 log << MSG::INFO << "@CalibDataSvc runfrm=" << tmpObject->getrunfrm()
400 << "runto=" << tmpObject->getrunto() << "runNo=" << runNo << endmsg;
401 log << MSG::DEBUG << "update the Object" << endmsg;
402 sc = DataSvc::updateObject( pObject );
403 return sc;
404 } // end of else
405} // end of if
int runNo
Definition DQA_TO_DB.cxx:13

◆ updateObject()

StatusCode CalibDataSvc::updateObject ( DataObject * toUpdate)
overridevirtual

Update object.

Definition at line 288 of file CalibDataSvc.cxx.

288 {
289 MsgStream log( msgSvc(), name() );
290 log << MSG::INFO << "begin of CalibDataSvc::updateObject" << endmsg;
291 // Check that object to update exists
292 if ( 0 == toUpdate )
293 {
294 log << MSG::ERROR << "There is no DataObject to update" << endmsg;
295 return Status::INVALID_OBJECT;
296 }
297
298 log << MSG::INFO << "begin of CalibDataSvc::updateObject" << endmsg;
299 // Now delegate update to the conversion service by calling the base class
300 StatusCode status = DataSvc::updateObject( toUpdate );
301 if ( !status.isSuccess() )
302 {
303 log << MSG::ERROR << "Could not update DataObject" << endmsg;
304 if ( status == Status::NO_DATA_LOADER )
305 log << MSG::ERROR << "There is no data loader" << endmsg;
306 return status;
307 }
308 log << MSG::INFO << "begin of CalibDataSvc::updateObject successfully updated" << endmsg;
309 // DataObject was successfully updated
310 return StatusCode::SUCCESS;
311}

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