7#include "GaudiKernel/IAddressCreator.h"
8#include "GaudiKernel/IConversionSvc.h"
9#include "GaudiKernel/IOpaqueAddress.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "GaudiKernel/IIncidentSvc.h"
12#include "GaudiKernel/IValidity.h"
13#include "GaudiKernel/IDataProviderSvc.h"
14#include "GaudiKernel/DataObject.h"
15#include "GaudiKernel/MsgStream.h"
16#include "GaudiKernel/SvcFactory.h"
18#include "GaudiKernel/SmartDataPtr.h"
24#include "GaudiKernel/RegistryEntry.h"
34#define CAST_REGENTRY(x,y) dynamic_cast<x>(y)
54 declareProperty(
"CalibNameList", m_calibList);
55 declareProperty(
"CalibFlavorList", m_flavorList);
56 declareProperty(
"CalibRootName", m_calibRootName =
"Calib" );
57 declareProperty(
"Mdc_CalibStorageType",
59 declareProperty(
"Tof_CalibStorageType",
61 declareProperty(
"Dedx_CalibStorageType",
63 declareProperty(
"EMC_CalibStorageType",
65 declareProperty(
"MUC_CalibStorageType",
67 declareProperty(
"EsTime_CalibStorageType",
69 declareProperty(
"EstTof_CalibStorageType",
71 declareProperty(
"TofQElec_CalibStorageType",
73 declareProperty(
"TofSim_CalibStorageType",
75 declareProperty(
"DedxSim_CalibStorageType",
78 declareProperty(
"InjSigInterval_CalibStorageType",
80 declareProperty(
"InjSigTime_CalibStorageType",
82 declareProperty(
"OffEvtFilter_CalibStorageType",
84 declareProperty(
"CorrectedETS_CalibStorageType",
94 m_rootName =
"/" + m_calibRootName;
95 m_rootCLID = CLID_DataObject;
112 sc = DataSvc::initialize();
113 if (sc.isFailure() )
return sc;
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;
124 IIncidentSvc* incsvc;
125 sc = service(
"IncidentSvc", incsvc);
127 if( sc.isSuccess() ){
128 incsvc -> addListener(
this,
"NewRun", priority);
131 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
132 if (sc .isFailure() ) {
133 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
137 sc = setDataLoader(cnv_svc);
138 if (sc.isFailure() ) {
139 log << MSG::ERROR <<
"Unable to set data loader " << endreq;
142 sc = setProperties();
145 IAddressCreator* calibCreator = 0;
149 sc = serviceLocator()->service(
"DetectorPersistencySvc", calibCreator);
151 if( sc.isFailure() ) {
152 log << MSG::ERROR <<
"Unable to locate DetectorPersistencySvc." << endreq;
153 return StatusCode::FAILURE;
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;
172 typedef std::vector<CalibData::CalibModelSvc::CalibPair>::const_iterator
176 const std::vector<CalibData::CalibModelSvc::CalibPair>&
pairs =
179 for (pairIt =
pairs.begin(); pairIt !=
pairs.end(); pairIt++,jj++) {
183 std::string calibTypePath(pairIt->first);
187 unsigned long iargs[]={0,0};
188 IOpaqueAddress* pAddress;
207 std::string fullpath = calibTypePath;
208 std::string args[] = {fullpath};
210 sc = calibCreator->createAddress(m_calibType[jj],
212 args, iargs, pAddress);
215 if (!sc.isSuccess()) {
217 <<
"Unable to create Calib address with path " << fullpath << endreq;
222 sc = registerAddress(fullpath, pAddress);
223 if (!sc.isSuccess()) {
224 log<< MSG::ERROR <<
"Unable to register Calib address with path"
225 << fullpath << endreq;
259 return StatusCode::SUCCESS;
267 MsgStream log(
msgSvc(), name());
268 log << MSG::DEBUG <<
"Finalizing" << endreq;
273 return DataSvc::finalize();
300 DataSvc::clearStore();
301 return StatusCode::SUCCESS;
306 MsgStream log(
msgSvc(), name() );
318 MsgStream log(
msgSvc(), name() );
319 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject"<<endreq;
321 if ( 0 == toUpdate ) {
323 <<
"There is no DataObject to update" << endreq;
324 return INVALID_OBJECT;
327 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject"<<endreq;
329 StatusCode status = DataSvc::updateObject(toUpdate);
330 if ( !status.isSuccess() ) {
332 <<
"Could not update DataObject" << endreq;
333 if ( status == NO_DATA_LOADER )
334 log << MSG::ERROR <<
"There is no data loader" << endreq;
337 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject successfully updated"<<endreq;
339 return StatusCode::SUCCESS;
343 IRegistry* pRegistry) {
344 return DataSvc::loadObject(pLoader, pRegistry);
350 MsgStream log(
msgSvc(), name() );
354 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,
"/Event/EventHeader");
356 runNo = evt -> runNumber();
357 log << MSG::DEBUG <<
"The runNumber of current event is "<<
runNo<<endreq;
361 log << MSG::WARNING <<
"WARNING accessing Event" <<endreq;
366 StatusCode sc =DataSvc::retrieveObject(fullPath,pObject);
367 if (!sc.isSuccess()) {
368 log<< MSG::ERROR <<
"Unable to get the retrieveObject"
375 return StatusCode::SUCCESS;}
377 return StatusCode::SUCCESS;}
379 return StatusCode::SUCCESS;}
381 return StatusCode::SUCCESS;}
383 return StatusCode::SUCCESS;}
385 return StatusCode::SUCCESS;}
387 return StatusCode::SUCCESS;}
389 return StatusCode::SUCCESS;}
391 return StatusCode::SUCCESS;}
393 return StatusCode::SUCCESS;}
396 return StatusCode::SUCCESS;}
398 return StatusCode::SUCCESS;}
400 return StatusCode::SUCCESS;}
402 return StatusCode::SUCCESS;}
406 {
return StatusCode::SUCCESS;}
408 {
return StatusCode::SUCCESS;}
410 {
return StatusCode::SUCCESS;}
412 {
return StatusCode::SUCCESS;}
418 log << MSG::DEBUG <<__LINE__<<
" runfrm @CalibDataSvc is:"<<tmpObject->
getrunfrm()<<
" runto min is:"<<tmpObject->
getrunto()<<endreq;
419 return StatusCode::SUCCESS;}
422 log<< MSG::INFO <<
"@CalibDataSvc runfrm="<< tmpObject->
getrunfrm()<<
"runto="<<tmpObject->
getrunto()<<
"runNo="<<
runNo<<endreq;
423 log<< MSG::DEBUG <<
"update the Object"
425 sc =DataSvc:: updateObject(pObject);
431 const std::string& objPath,
432 DataObject* pObject) {
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() ) {
442 if ( status.isSuccess() ) {
443 status =DataSvc::registerObject(pO, objPath, pObject);
445 if(status.isSuccess() ){
DataSvcHelpers::RegistryEntry RegEntry
unsigned const char CALIBROOT_StorageType
virtual StatusCode loadObject(IConversionSvc *pLoader, IRegistry *pRegistry)
virtual StatusCode registerObject(const std::string &parentPath, const std::string &objPath, DataObject *pObject)
virtual StatusCode initialize()
virtual StatusCode updateObject(DataObject *toUpdate)
Update object.
virtual void handle(const Incident &)
Query the interface of the service.
virtual StatusCode retrieveObject(const std::string &fullPath, DataObject *&pObject)
virtual StatusCode finalize()
Finalize the service.
virtual ~CalibDataSvc()
Standard Destructor.
CalibDataSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
virtual StatusCode clearStore()
Remove all data objects in the data store.
virtual int getrunto() const
virtual int getrunfrm() const
const std::vector< CalibPair > & getPairs() const
CalibPairCol::const_iterator PairIt
_EXTERN_ CalibPairCol pairs