DetDataSvc Class Reference


More...

#include <DetectorDataSvc/DetDataSvc.h>

Inheritance diagram for DetDataSvc:
Collaboration diagram for DetDataSvc:

Public Member Functions

StatusCode initialize () override
 Initialize the service. More...
 
StatusCode reinitialize () override
 Initialize the service. More...
 
StatusCode finalize () override
 Finalize the service. More...
 
StatusCode clearStore () override
 Remove all data objects in the data store. More...
 
StatusCode updateObject (DataObject *toUpdate) override
 Update object. More...
 
 DetDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
 ~DetDataSvc () override=default
 Standard Destructor. More...
 
bool validEventTime () const override
 Check if the event time has been set. More...
 
const Gaudi::TimeeventTime () const override
 Get the event time. More...
 
void setEventTime (const Gaudi::Time &time) override
 Set the new event time. More...
 
void handle (const Incident &) override
 Inform that a new incident has occured. More...
 
- Public Member Functions inherited from extends< BASE, Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Member Functions

StatusCode setupDetectorDescription ()
 Deal with Detector Description initialization. More...
 

Private Attributes

int m_detStorageType = XML_StorageType
 Detector Data Persistency Storage type. More...
 
std::string m_detDbLocation = "empty"
 Location of detector Db (filename,URL) More...
 
std::string m_detDbRootName = "dd"
 Name of the root node of the detector. More...
 
std::string m_persistencySvcName = "DetectorPersistencySvc"
 Name of the persistency service. More...
 
bool m_usePersistency = false
 Flag to control if the persistency is required. More...
 
Gaudi::Time m_eventTime = 0
 Current event time. More...
 
SmartIF< IAddressCreatorm_addrCreator = nullptr
 Address Creator to be used. More...
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

Detailed Description


A DataSvc specialized in detector data. Now inherits from TsDataSvc, a thread safe version of the DataSvc, which allows concurrent retrieval of DataObjects.

Author
Marco Clemencic (previous author unknown)
Danilo Piparo

Definition at line 28 of file DetDataSvc.h.

Constructor & Destructor Documentation

DetDataSvc::DetDataSvc ( const std::string &  name,
ISvcLocator svc 
)

Standard Constructor.

Definition at line 183 of file DetDataSvc.cpp.

183  :
184  base_class(name,svc) {
185  declareProperty("DetStorageType", m_detStorageType = XML_StorageType );
186  declareProperty("DetDbLocation", m_detDbLocation = "empty" );
187  declareProperty("DetDbRootName", m_detDbRootName = "dd" );
188  declareProperty("UsePersistency", m_usePersistency = false );
189  declareProperty("PersistencySvc", m_persistencySvcName = "DetectorPersistencySvc" );
190  m_rootName = "/dd";
191  m_rootCLID = CLID_Catalog;
192 }
const long XML_StorageType
Definition: ClassID.h:57
extends base_class
Typedef to this class.
Definition: extends.h:14
std::string m_persistencySvcName
Name of the persistency service.
Definition: DetDataSvc.h:96
int m_detStorageType
Detector Data Persistency Storage type.
Definition: DetDataSvc.h:87
std::string m_detDbRootName
Name of the root node of the detector.
Definition: DetDataSvc.h:93
std::string m_detDbLocation
Location of detector Db (filename,URL)
Definition: DetDataSvc.h:90
bool m_usePersistency
Flag to control if the persistency is required.
Definition: DetDataSvc.h:99
DetDataSvc::~DetDataSvc ( )
overridedefault

Standard Destructor.

Member Function Documentation

StatusCode DetDataSvc::clearStore ( )
override

Remove all data objects in the data store.

Definition at line 150 of file DetDataSvc.cpp.

150  {
151 
152  MsgStream log(msgSvc(), name());
153 
155 
156  if( m_usePersistency ) {
157  // Create root address
158  unsigned long iargs[] = {0,0};
159  const std::string args[] = {m_detDbLocation, m_detDbRootName};
160  IOpaqueAddress* rootAddr;
162  CLID_Catalog,
163  args,
164  iargs,
165  rootAddr);
166  // Set detector data store root
167  if( sc.isSuccess() ) {
168  sc = i_setRoot( "/" + m_detDbRootName, rootAddr );
169  if( sc.isFailure() ) {
170  error() << "Unable to set detector data store root" << endmsg;
171  }
172  } else {
173  error() << "Unable to create address for /dd" << endmsg;
174  }
175  return sc;
176 
177  }
178  return StatusCode::SUCCESS;
179 
180 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ipar, IOpaqueAddress *&refpAddress)=0
Create a Generic address using explicit arguments to identify a single object.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IAddressCreator > m_addrCreator
Address Creator to be used.
Definition: DetDataSvc.h:105
int m_detStorageType
Detector Data Persistency Storage type.
Definition: DetDataSvc.h:87
std::string m_detDbRootName
Name of the root node of the detector.
Definition: DetDataSvc.h:93
list args
Definition: gaudirun.py:290
std::string m_detDbLocation
Location of detector Db (filename,URL)
Definition: DetDataSvc.h:90
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
Definition: TsDataSvc.cpp:115
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:108
bool m_usePersistency
Flag to control if the persistency is required.
Definition: DetDataSvc.h:99
const Gaudi::Time & DetDataSvc::eventTime ( ) const
override

Get the event time.

Definition at line 206 of file DetDataSvc.cpp.

206  {
207  return m_eventTime;
208 }
Gaudi::Time m_eventTime
Current event time.
Definition: DetDataSvc.h:102
StatusCode DetDataSvc::finalize ( )
override

Finalize the service.

Definition at line 131 of file DetDataSvc.cpp.

132 {
133  DEBMSG << "Finalizing" << endmsg;
134 
135  // clears the store
136  m_usePersistency = false; // avoid creation of an empty store when clearing
137  clearStore().ignore();
138 
139  // Releases the address creator
140  m_addrCreator = nullptr;
141 
142  // Releases the DataLoader
143  setDataLoader(nullptr).ignore();
144 
145  // Finalize the base class
146  return TsDataSvc::finalize();
147 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode clearStore() override
Remove all data objects in the data store.
Definition: DetDataSvc.cpp:150
SmartIF< IAddressCreator > m_addrCreator
Address Creator to be used.
Definition: DetDataSvc.h:105
#define DEBMSG
Definition: DetDataSvc.cpp:19
StatusCode finalize() override
Service initialization.
Definition: TsDataSvc.cpp:1362
void ignore() const
Definition: StatusCode.h:108
bool m_usePersistency
Flag to control if the persistency is required.
Definition: DetDataSvc.h:99
void DetDataSvc::handle ( const Incident inc)
override

Inform that a new incident has occured.

Inform that a new incident has occurred.

Definition at line 211 of file DetDataSvc.cpp.

211  {
212  ON_DEBUG {
213  debug() << "New incident received" << endmsg;
214  debug() << "Incident source: " << inc.source() << endmsg;
215  debug() << "Incident type: " << inc.type() << endmsg;
216  }
217 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
const std::string & type() const
Access to the incident type.
Definition: Incident.h:34
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:40
#define ON_DEBUG
Definition: DetDataSvc.cpp:16
StatusCode DetDataSvc::initialize ( )
override

Initialize the service.

Definition at line 27 of file DetDataSvc.cpp.

27  {
28  // Call base class initialization
30  if( UNLIKELY(sc.isFailure()) ) return sc;
31 
32  // Set Data Loader
33  auto cnv_svc = serviceLocator()->service<IConversionSvc>(m_persistencySvcName);
34  if( UNLIKELY(!cnv_svc) ) {
35  error() << "Unable to retrieve " << m_persistencySvcName << endmsg;
36  return StatusCode::FAILURE;
37  }
38 
39  sc = setDataLoader(cnv_svc);
40  if( UNLIKELY(sc.isFailure()) ) {
41  error() << "Unable to set DataLoader" << endmsg;
42  return sc;
43  }
44 
45  // Get address creator from the DetectorPersistencySvc
46  m_addrCreator = cnv_svc;
47  if ( UNLIKELY(!m_addrCreator) ) {
48  error() << "Unable to get AddressCreator." << endmsg;
49  return StatusCode::FAILURE;
50  }
51 
52  return setupDetectorDescription();
53 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode initialize() override
Service initialization.
Definition: TsDataSvc.cpp:1321
std::string m_persistencySvcName
Name of the persistency service.
Definition: DetDataSvc.h:96
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
StatusCode setupDetectorDescription()
Deal with Detector Description initialization.
Definition: DetDataSvc.cpp:55
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IAddressCreator > m_addrCreator
Address Creator to be used.
Definition: DetDataSvc.h:105
#define UNLIKELY(x)
Definition: Kernel.h:126
StatusCode DetDataSvc::reinitialize ( )
override

Initialize the service.

Definition at line 113 of file DetDataSvc.cpp.

113  {
114  // The DetectorDataSvc does not need to be re-initialized. If it is done
115  // all the Algorithms having references to DetectorElements will become
116  // invalid and crash the program. (Pere Mato)
117 
118  // Call base class reinitialization
119  //StatusCode sc = DataSvc::reinitialize();
120  //if( sc.isFailure() ) return sc;
121 
122  // Delete the associated event time
123  //if( 0 != m_eventTime ) delete m_eventTime;
124  //m_eventTimeDefined = false;
125 
126  //return setupDetectorDescription();
127  return StatusCode::SUCCESS;
128 }
void DetDataSvc::setEventTime ( const Gaudi::Time time)
override

Set the new event time.

Definition at line 195 of file DetDataSvc.cpp.

195  {
196  m_eventTime = time;
197  DEBMSG << "Event Time set to " << eventTime() << endmsg;
198 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
const Gaudi::Time & eventTime() const override
Get the event time.
Definition: DetDataSvc.cpp:206
#define DEBMSG
Definition: DetDataSvc.cpp:19
Gaudi::Time m_eventTime
Current event time.
Definition: DetDataSvc.h:102
StatusCode DetDataSvc::setupDetectorDescription ( )
private

Deal with Detector Description initialization.

Todo:
: remove references to obsolete package XMLDDDBROOT

Definition at line 55 of file DetDataSvc.cpp.

55  {
56  // Initialize the detector data transient store
57  ON_DEBUG {
58  debug() << "Storage type used is: " << m_detStorageType << endmsg;
59  debug() << "Setting DetectorDataSvc root node... " << endmsg;
60  }
61 
62  if( m_usePersistency ) {
63 
64  IOpaqueAddress* rootAddr = nullptr;
65  if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) {
66 
67  // if the name of DBlocation is not given - construct it!
68  // by retrieving the value of XMLDDBROOT
69 
71  if ( isEnvSet("XMLDDDBROOT") ) {
72  m_detDbLocation = getEnv("XMLDDDBROOT");
73  m_detDbLocation += "/DDDB/lhcb.xml";
74  }
75  }
76  if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) {
77  error() << "Detector data location name not set. Detector data will "
78  "not be found." << endmsg;
79  return StatusCode::FAILURE;
80  }
81  else {
82  // Create address
83  unsigned long iargs[]={0,0};
84  const std::string args[] = {m_detDbLocation, m_detDbRootName};
86  CLID_Catalog,
87  args,
88  iargs,
89  rootAddr);
90  if( sc.isSuccess() ) {
91  sc = i_setRoot( "/" + m_detDbRootName, rootAddr );
92  if( sc.isFailure() ) {
93  error() << "Unable to set detector data store root" << endmsg;
94  return sc;
95  }
96  }
97  else {
98  error() << "Unable to create address for /dd" << endmsg;
99  return sc;
100  }
101  }
102  // Writing the description file in the output log file [bugs #2854]
103  always() << "Detector description database: " << m_detDbLocation << endmsg;
104  }
105  else {
106  info() << "Detector description not requested to be loaded" << endmsg;
107  }
108 
109  return StatusCode::SUCCESS;
110 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ipar, IOpaqueAddress *&refpAddress)=0
Create a Generic address using explicit arguments to identify a single object.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
#define ON_DEBUG
Definition: DetDataSvc.cpp:16
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IAddressCreator > m_addrCreator
Address Creator to be used.
Definition: DetDataSvc.h:105
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition: System.cpp:637
int m_detStorageType
Detector Data Persistency Storage type.
Definition: DetDataSvc.h:87
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:617
std::string m_detDbRootName
Name of the root node of the detector.
Definition: DetDataSvc.h:93
list args
Definition: gaudirun.py:290
std::string m_detDbLocation
Location of detector Db (filename,URL)
Definition: DetDataSvc.h:90
Opaque address interface definition.
bool m_usePersistency
Flag to control if the persistency is required.
Definition: DetDataSvc.h:99
StatusCode DetDataSvc::updateObject ( DataObject toUpdate)
override

Update object.

Todo:
update also its ancestors in the data store if necessary

Definition at line 221 of file DetDataSvc.cpp.

221  {
222 
223  DEBMSG << "Method updateObject starting" << endmsg;
224 
225  // Check that object to update exists
226  if ( !toUpdate ) {
227  error() << "There is no DataObject to update" << endmsg;
228  return INVALID_OBJECT;
229  }
230 
231  // Retrieve IValidity interface of object to update
232  IValidity* condition = dynamic_cast<IValidity*>( toUpdate );
233  if ( !condition ) {
234  warning()
235  << "Cannot update DataObject: DataObject does not implement IValidity"
236  << endmsg;
237  return StatusCode::SUCCESS;
238  }
239 
240  // Check that the event time has been defined
241  if ( !validEventTime() ) {
242  warning()
243  << "Cannot update DataObject: event time undefined"
244  << endmsg;
245  return StatusCode::SUCCESS;
246  }
247 
248  // No need to update if condition is valid
249  if ( condition->isValid( eventTime() ) ) {
250  DEBMSG << "DataObject is valid: no need to update" << endmsg;
251  return StatusCode::SUCCESS;
252  }
253 
254  DEBMSG << "DataObject is invalid: update it" << endmsg;
255  // TODO: before loading updated object, update HERE its parent in data store
256 
257  // Now delegate update to the conversion service by calling the base class
258  DEBMSG << "Delegate update to relevant conversion service" << endmsg;
259  StatusCode status = TsDataSvc::updateObject(toUpdate);
260  if ( !status.isSuccess() ) {
261  error() << "Could not update DataObject" << endmsg;
262  if ( status == NO_DATA_LOADER )
263  error() << "There is no data loader" << endmsg;
264  return status;
265  }
266 
267  // Now cross-check that the new condition is valid
268  condition = dynamic_cast<IValidity*>(toUpdate);
269  if ( !condition ) {
270  error() << "Updated DataObject does not implement IValidity" << endmsg;
271  return StatusCode::FAILURE;
272  }
273  if ( FSMState() == Gaudi::StateMachine::RUNNING &&
274  !condition->isValid( eventTime() ) ) {
275  error() << "Updated DataObject is not valid" << endmsg;
276  error() << "Are you sure the conversion service has updated it?" << endmsg;
277  return StatusCode::FAILURE;
278  }
279 
280  // DataObject was successfully updated
281  DEBMSG << "Method updateObject exiting successfully" << endmsg;
282  return StatusCode::SUCCESS;
283 
284 }
bool validEventTime() const override
Check if the event time has been set.
Definition: DetDataSvc.cpp:201
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
const Gaudi::Time & eventTime() const override
Get the event time.
Definition: DetDataSvc.cpp:206
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
Definition: TsDataSvc.cpp:1017
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual bool isValid() const =0
Check if the object is valid (it can be always invalid).
#define DEBMSG
Definition: DetDataSvc.cpp:19
Interface for objects with a validity.
Definition: IValidity.h:9
bool DetDataSvc::validEventTime ( ) const
override

Check if the event time has been set.

Kept for backward compatibility, returns always true.

Definition at line 201 of file DetDataSvc.cpp.

201  {
202  return true;
203 }

Member Data Documentation

SmartIF<IAddressCreator> DetDataSvc::m_addrCreator = nullptr
private

Address Creator to be used.

Definition at line 105 of file DetDataSvc.h.

std::string DetDataSvc::m_detDbLocation = "empty"
private

Location of detector Db (filename,URL)

Definition at line 90 of file DetDataSvc.h.

std::string DetDataSvc::m_detDbRootName = "dd"
private

Name of the root node of the detector.

Definition at line 93 of file DetDataSvc.h.

int DetDataSvc::m_detStorageType = XML_StorageType
private

Detector Data Persistency Storage type.

Definition at line 87 of file DetDataSvc.h.

Gaudi::Time DetDataSvc::m_eventTime = 0
private

Current event time.

Definition at line 102 of file DetDataSvc.h.

std::string DetDataSvc::m_persistencySvcName = "DetectorPersistencySvc"
private

Name of the persistency service.

Definition at line 96 of file DetDataSvc.h.

bool DetDataSvc::m_usePersistency = false
private

Flag to control if the persistency is required.

Definition at line 99 of file DetDataSvc.h.


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