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",
76 declareProperty(
"InjSigInterval_CalibStorageType",
78 declareProperty(
"InjSigTime_CalibStorageType",
80 declareProperty(
"OffEvtFilter_CalibStorageType",
82 declareProperty(
"CorrectedETS_CalibStorageType",
92 m_rootName =
"/" + m_calibRootName;
93 m_rootCLID = CLID_DataObject;
110 sc = DataSvc::initialize();
111 if (sc.isFailure() )
return sc;
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;
122 IIncidentSvc* incsvc;
123 sc = service(
"IncidentSvc", incsvc);
125 if( sc.isSuccess() ){
126 incsvc -> addListener(
this,
"NewRun", priority);
129 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
130 if (sc .isFailure() ) {
131 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
135 sc = setDataLoader(cnv_svc);
136 if (sc.isFailure() ) {
137 log << MSG::ERROR <<
"Unable to set data loader " << endreq;
140 sc = setProperties();
143 IAddressCreator* calibCreator = 0;
147 sc = serviceLocator()->service(
"DetectorPersistencySvc", calibCreator);
149 if( sc.isFailure() ) {
150 log << MSG::ERROR <<
"Unable to locate DetectorPersistencySvc." << endreq;
151 return StatusCode::FAILURE;
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;
170 typedef std::vector<CalibData::CalibModelSvc::CalibPair>::const_iterator
174 const std::vector<CalibData::CalibModelSvc::CalibPair>&
pairs =
177 for (pairIt =
pairs.begin(); pairIt !=
pairs.end(); pairIt++,jj++) {
181 std::string calibTypePath(pairIt->first);
185 unsigned long iargs[]={0,0};
186 IOpaqueAddress* pAddress;
205 std::string fullpath = calibTypePath;
206 std::string args[] = {fullpath};
208 sc = calibCreator->createAddress(m_calibType[jj],
210 args, iargs, pAddress);
213 if (!sc.isSuccess()) {
215 <<
"Unable to create Calib address with path " << fullpath << endreq;
220 sc = registerAddress(fullpath, pAddress);
221 if (!sc.isSuccess()) {
222 log<< MSG::ERROR <<
"Unable to register Calib address with path"
223 << fullpath << endreq;
257 return StatusCode::SUCCESS;
265 MsgStream log(
msgSvc(), name());
266 log << MSG::DEBUG <<
"Finalizing" << endreq;
271 return DataSvc::finalize();
278 if (IDetDataSvc::interfaceID().versionMatch(riid) ) {
279 *ppvInterface = (IDetDataSvc*)
this;
285 return DataSvc::queryInterface(riid, ppvInterface);
288return StatusCode::SUCCESS;
298 DataSvc::clearStore();
299 return StatusCode::SUCCESS;
304 MsgStream log(
msgSvc(), name() );
316 MsgStream log(
msgSvc(), name() );
317 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject"<<endreq;
319 if ( 0 == toUpdate ) {
321 <<
"There is no DataObject to update" << endreq;
322 return INVALID_OBJECT;
325 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject"<<endreq;
327 StatusCode status = DataSvc::updateObject(toUpdate);
328 if ( !status.isSuccess() ) {
330 <<
"Could not update DataObject" << endreq;
331 if ( status == NO_DATA_LOADER )
332 log << MSG::ERROR <<
"There is no data loader" << endreq;
335 log << MSG::INFO<<
"begin of CalibDataSvc::updateObject successfully updated"<<endreq;
337 return StatusCode::SUCCESS;
341 IRegistry* pRegistry) {
342 return DataSvc::loadObject(pLoader, pRegistry);
348 MsgStream log(
msgSvc(), name() );
352 SmartDataPtr<Event::EventHeader> evt(m_eventSvc,
"/Event/EventHeader");
354 runNo = evt -> runNumber();
355 log << MSG::DEBUG <<
"The runNumber of current event is "<<
runNo<<endreq;
359 log << MSG::WARNING <<
"WARNING accessing Event" <<endreq;
364 StatusCode sc =DataSvc::retrieveObject(fullPath,pObject);
365 if (!sc.isSuccess()) {
366 log<< MSG::ERROR <<
"Unable to get the retrieveObject"
373 return StatusCode::SUCCESS;}
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;}
394 return StatusCode::SUCCESS;}
396 return StatusCode::SUCCESS;}
398 return StatusCode::SUCCESS;}
400 return StatusCode::SUCCESS;}
404 {
return StatusCode::SUCCESS;}
406 {
return StatusCode::SUCCESS;}
408 {
return StatusCode::SUCCESS;}
410 {
return StatusCode::SUCCESS;}
416 log << MSG::DEBUG <<__LINE__<<
" runfrm @CalibDataSvc is:"<<tmpObject->
getrunfrm()<<
" runto min is:"<<tmpObject->
getrunto()<<endreq;
417 return StatusCode::SUCCESS;}
420 log<< MSG::INFO <<
"@CalibDataSvc runfrm="<< tmpObject->
getrunfrm()<<
"runto="<<tmpObject->
getrunto()<<
"runNo="<<
runNo<<endreq;
421 log<< MSG::DEBUG <<
"update the Object"
423 sc =DataSvc:: updateObject(pObject);
429 const std::string& objPath,
430 DataObject* pObject) {
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() ) {
440 if ( status.isSuccess() ) {
441 status =DataSvc::registerObject(pO, objPath, pObject);
443 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