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)
52 declareProperty(
"CalibNameList", m_calibList);
53 declareProperty(
"CalibFlavorList", m_flavorList);
54 declareProperty(
"CalibRootName", m_calibRootName =
"Calib" );
55 declareProperty(
"Mdc_CalibStorageType",
57 declareProperty(
"Tof_CalibStorageType",
59 declareProperty(
"Dedx_CalibStorageType",
61 declareProperty(
"EMC_CalibStorageType",
63 declareProperty(
"MUC_CalibStorageType",
65 declareProperty(
"EsTime_CalibStorageType",
67 declareProperty(
"EstTof_CalibStorageType",
69 declareProperty(
"TofQElec_CalibStorageType",
71 declareProperty(
"TofSim_CalibStorageType",
73 declareProperty(
"DedxSim_CalibStorageType",
82 m_rootName =
"/" + m_calibRootName;
83 m_rootCLID = CLID_DataObject;
100 sc = DataSvc::initialize();
101 if (sc.isFailure() )
return sc;
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;
112 IIncidentSvc* incsvc;
113 sc = service(
"IncidentSvc", incsvc);
115 if( sc.isSuccess() ){
116 incsvc -> addListener(
this,
"NewRun", priority);
119 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
120 if (sc .isFailure() ) {
121 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
125 sc = setDataLoader(cnv_svc);
126 if (sc.isFailure() ) {
127 log << MSG::ERROR <<
"Unable to set data loader " << endreq;
130 sc = setProperties();
133 IAddressCreator* calibCreator = 0;
137 sc = serviceLocator()->service(
"DetectorPersistencySvc", calibCreator);
139 if( sc.isFailure() ) {
140 log << MSG::ERROR <<
"Unable to locate DetectorPersistencySvc." << endreq;
141 return StatusCode::FAILURE;
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;
160 typedef std::vector<CalibData::CalibModelSvc::CalibPair>::const_iterator
164 const std::vector<CalibData::CalibModelSvc::CalibPair>&
pairs =
167 for (pairIt =
pairs.begin(); pairIt !=
pairs.end(); pairIt++,jj++) {
171 std::string calibTypePath(pairIt->first);
175 unsigned long iargs[]={0,0};
176 IOpaqueAddress* pAddress;
195 std::string fullpath = calibTypePath;
196 std::string args[] = {fullpath};
201 sc = calibCreator->createAddress(m_calibType[jj],
203 args, iargs, pAddress);
206 if (!sc.isSuccess()) {
208 <<
"Unable to create Calib address with path " << fullpath << endreq;
213 sc = registerAddress(fullpath, pAddress);
214 if (!sc.isSuccess()) {
215 log<< MSG::ERROR <<
"Unable to register Calib address with path"
216 << fullpath << endreq;
250 return StatusCode::SUCCESS;
258 MsgStream log(
msgSvc(), name());
259 log << MSG::DEBUG <<
"Finalizing" << endreq;
264 return DataSvc::finalize();
271 if (IDetDataSvc::interfaceID().versionMatch(riid) ) {
272 *ppvInterface = (IDetDataSvc*)
this;
278 return DataSvc::queryInterface(riid, ppvInterface);
281 return StatusCode::SUCCESS;
291 DataSvc::clearStore();
292 return StatusCode::SUCCESS;
297 MsgStream log(
msgSvc(), name() );
309 MsgStream log(
msgSvc(), name() );
310 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject"<<endreq;
312 if ( 0 == toUpdate ) {
314 <<
"There is no DataObject to update" << endreq;
315 return INVALID_OBJECT;
318 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject"<<endreq;
320 StatusCode status = DataSvc::updateObject(toUpdate);
321 if ( !status.isSuccess() ) {
323 <<
"Could not update DataObject" << endreq;
324 if ( status == NO_DATA_LOADER )
325 log << MSG::ERROR <<
"There is no data loader" << endreq;
328 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject successfully updated"<<endreq;
330 return StatusCode::SUCCESS;
334 IRegistry* pRegistry) {
335 return DataSvc::loadObject(pLoader, pRegistry);
341 MsgStream log(
msgSvc(), name() );
345 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,
"/Event/EventHeader");
347 runNo = evt -> runNumber();
348 log << MSG::DEBUG <<
"The runNumber of current event is "<<
runNo<<endreq;
352 log << MSG::WARNING <<
"WARNING accessing Event" <<endreq;
357StatusCode sc =DataSvc::retrieveObject(fullPath,pObject);
358 if (!sc.isSuccess()) {
359 log<< MSG::ERROR <<
"Unable to get the retrieveObject"
366 return StatusCode::SUCCESS;}
368 return StatusCode::SUCCESS;}
370 return StatusCode::SUCCESS;}
372 return StatusCode::SUCCESS;}
374 return StatusCode::SUCCESS;}
376 return StatusCode::SUCCESS;}
378 return StatusCode::SUCCESS;}
380 return StatusCode::SUCCESS;}
382 return StatusCode::SUCCESS;}
384 return StatusCode::SUCCESS;}
389{
return StatusCode::SUCCESS;}
391{
return StatusCode::SUCCESS;}
393{
return StatusCode::SUCCESS;}
395{
return StatusCode::SUCCESS;}
401 log << MSG::DEBUG <<__LINE__<<
" runfrm @CalibDataSvc is:"<<tmpObject->
getrunfrm()<<
" runto min is:"<<tmpObject->
getrunto()<<endreq;
402 return StatusCode::SUCCESS;}
405 log<< MSG::INFO <<
"@CalibDataSvc runfrm="<< tmpObject->
getrunfrm()<<
"runto="<<tmpObject->
getrunto()<<
"runNo="<<
runNo<<endreq;
406 log<< MSG::DEBUG <<
"update the Object"
408 sc =DataSvc:: updateObject(pObject);
414 const std::string& objPath,
415 DataObject* pObject) {
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() ) {
425 if ( status.isSuccess() ) {
426 status =DataSvc::registerObject(pO, objPath, pObject);
428 if(status.isSuccess() ){
DataSvcHelpers::RegistryEntry RegEntry
unsigned const char CALIBROOT_StorageType
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Query the interface of the service.
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 &)
Inform that a new incident has occured.
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
Simple interface to keep track of which instrument (LAT, EM, etc.) the process is concerned with....
static const InterfaceID & interfaceID()
CalibPairCol::const_iterator PairIt
_EXTERN_ CalibPairCol pairs