| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# DetDataSvc Class Reference

`#include <DetectorDataSvc/DetDataSvc.h>`

Inheritance diagram for DetDataSvc:

[legend]
Collaboration diagram for DetDataSvc:

[legend]

List of all members.

## Detailed Description

---------------------------------------------------------------------------

A DataSvc specialised in detector data.

Author:
  Marco Clemencic (previous author unknown)

Definition at line 24 of file DetDataSvc.h.

## Public Member Functions
virtual StatusCode | initialize ()
| Initialize the service.
virtual StatusCode | reinitialize ()
| Initialize the service.
virtual StatusCode | finalize ()
| Finalize the service.
virtual StatusCode | clearStore ()
| Remove all data objects in the data store.
virtual StatusCode | updateObject (DataObject *toUpdate)
| Update object.
| DetDataSvc (const std::string &name, ISvcLocator *svc)
| Standard Constructor.
virtual | ~DetDataSvc ()
| Standard Destructor.
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface)
| Query the interface of the service.
virtual bool | validEventTime () const
| Check if the event time has been set.
virtual const Gaudi::Time & | eventTime () const
| Get the event time.
virtual void | setEventTime (const Gaudi::Time &time)
| Set the new event time.
virtual void | handle (const Incident &)
| Inform that a new incident has occured.
## Private Member Functions
StatusCode | setupDetectorDescription ()
| Deal with Detector Description initialization.
## Private Attributes
int | m_detStorageType
| Detector Data Persistency Storage type.
std::string | m_detDbLocation
| Location of detector Db (filename,URL).
std::string | m_detDbRootName
| Name of the root node of the detector.
std::string | m_persistencySvcName
| Name of the persistency service.
bool | m_usePersistency
| Flag to control if the persistency is required.
Gaudi::Time | m_eventTime
| Current event time.
IAddressCreator * | m_addrCreator
| Address Creator to be used.
## Friends
class | SvcFactory< DetDataSvc >

## Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 208 of file DetDataSvc.cpp.

    00208                                                              :
    00209   DataSvc(name,svc), m_eventTime(0)  {
    00210   declareProperty("DetStorageType",  m_detStorageType = XML_StorageType );
    00211   declareProperty("DetDbLocation",   m_detDbLocation  = "empty" );
    00212   declareProperty("DetDbRootName",   m_detDbRootName  = "dd" );
    00213   declareProperty("UsePersistency",  m_usePersistency = false );
    00214   declareProperty("PersistencySvc",  m_persistencySvcName = "DetectorPersistencySvc" );
    00215   m_rootName = "/dd";
    00216   m_rootCLID = CLID_Catalog;
    00217   m_addrCreator = 0;
    00218 }

DetDataSvc::~DetDataSvc | ( |  | ) | `[virtual]`

Standard Destructor.

Definition at line 221 of file DetDataSvc.cpp.

    00221                          {
    00222 }

## Member Function Documentation

StatusCode DetDataSvc::initialize | ( |  | ) | `[virtual]`

Initialize the service.

Reimplemented from DataSvc.

Definition at line 20 of file DetDataSvc.cpp.

    00020                                     {
    00021   MsgStream log(msgSvc(), name());
    00022
    00023   // Call base class initialisation
    00024   StatusCode sc  = DataSvc::initialize();
    00025   if( sc.isFailure() ) return sc;
    00026
    00027   // Set Data Loader
    00028   IConversionSvc* cnv_svc;
    00029   sc = serviceLocator()->service(m_persistencySvcName, cnv_svc, true);
    00030   if( sc .isFailure() ) {
    00031     log << MSG::ERROR << "Unable to retrieve " << m_persistencySvcName << endreq;
    00032     return sc;
    00033   }
    00034
    00035   sc = setDataLoader( cnv_svc );
    00036   cnv_svc->release();
    00037   if( sc .isFailure() ) {
    00038     log << MSG::ERROR << "Unable to set DataLoader" << endreq;
    00039     return sc;
    00040   }
    00041
    00042   // Get address creator fron the DetectorPersistencySvc
    00043   sc = cnv_svc->queryInterface(IID_IAddressCreator, pp_cast<void>(&m_addrCreator));
    00044   if (sc.isFailure()) {
    00045     log << MSG::ERROR << "Unable to get AddressCreator." << endreq;
    00046     return StatusCode::FAILURE;
    00047   }
    00048
    00049   return setupDetectorDescription();
    00050 }

StatusCode DetDataSvc::reinitialize | ( |  | ) | `[virtual]`

Initialize the service.

Reimplemented from DataSvc.

Definition at line 114 of file DetDataSvc.cpp.

    00114                                       {
    00115   MsgStream log(msgSvc(), name());
    00116
    00117   // The DetectorDataSvc does not need to be re-initialized. If it is done
    00118   // all the Algorithms having references to DetectorElements will become
    00119   // invalid and crash the program.  (Pere Mato)
    00120
    00121   // Call base class reinitialization
    00122   //StatusCode sc  = DataSvc::reinitialize();
    00123   //if( sc.isFailure() ) return sc;
    00124
    00125   // Delete the associated event time
    00126   //if( 0 != m_eventTime ) delete m_eventTime;
    00127   //m_eventTimeDefined = false;
    00128
    00129   //return setupDetectorDescription();
    00130   return StatusCode::SUCCESS;
    00131 }

StatusCode DetDataSvc::finalize | ( | void |  | ) | `[virtual]`

Finalize the service.

Reimplemented from DataSvc.

Definition at line 134 of file DetDataSvc.cpp.

    00135 {
    00136   MsgStream log(msgSvc(), name());
    00137   log << MSG::DEBUG << "Finalizing" << endreq;
    00138
    00139   // clears the store
    00140   m_usePersistency = false; // avoid creation of an empty store when clearing
    00141   clearStore().ignore();
    00142
    00143   // Releases the address creator
    00144   if (0 != m_addrCreator) {
    00145     m_addrCreator->release();
    00146   }
    00147
    00148   // Releases the DataLoader
    00149   setDataLoader(0).ignore();
    00150
    00151   // Finalize the base class
    00152   return DataSvc::finalize();
    00153 }

StatusCode DetDataSvc::clearStore | ( |  | ) | `[virtual]`

Remove all data objects in the data store.

Reimplemented from DataSvc.

Definition at line 173 of file DetDataSvc.cpp.

    00173                                     {
    00174
    00175   MsgStream log(msgSvc(), name());
    00176
    00177   DataSvc::clearStore().ignore();
    00178
    00179   if( m_usePersistency ) {
    00180     // Create root address
    00181     unsigned long iargs[]    = {0,0};
    00182     const std::string args[] = {m_detDbLocation, m_detDbRootName};
    00183     IOpaqueAddress*   rootAddr;
    00184     StatusCode sc = m_addrCreator->createAddress (m_detStorageType,
    00185                                                   CLID_Catalog,
    00186                                                   args,
    00187                                                   iargs,
    00188                                                   rootAddr);
    00189     // Set detector data store root
    00190     if( sc.isSuccess() ) {
    00191       std::string dbrName = "/" + m_detDbRootName;
    00192       sc = i_setRoot( dbrName, rootAddr );
    00193       if( sc.isFailure() ) {
    00194         log << MSG::ERROR
    00195             << "Unable to set detector data store root" << endreq;
    00196       }
    00197     } else {
    00198       log << MSG::ERROR << "Unable to create address for  /dd" << endreq;
    00199     }
    00200     return sc;
    00201
    00202   }
    00203   return StatusCode::SUCCESS;
    00204
    00205 }

StatusCode DetDataSvc::updateObject | ( | DataObject * | toUpdate | ) | `[virtual]`

Update object.

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

Reimplemented from DataSvc.

Definition at line 255 of file DetDataSvc.cpp.

    00255                                                           {
    00256
    00257   MsgStream log( msgSvc(), name() );
    00258   log << MSG::DEBUG << "Method updateObject starting" << endreq;
    00259
    00260   // Check that object to update exists
    00261   if ( 0 == toUpdate ) {
    00262     log << MSG::ERROR
    00263         << "There is no DataObject to update" << endreq;
    00264     return INVALID_OBJECT;
    00265   }
    00266
    00267   // Retrieve IValidity interface of object to update
    00268   IValidity* condition = dynamic_cast<IValidity*>( toUpdate );
    00269   if ( 0 == condition ) {
    00270     log << MSG::WARNING
    00271         << "Cannot update DataObject: DataObject does not implement IValidity"
    00272         << endreq;
    00273     return StatusCode::SUCCESS;
    00274   }
    00275
    00276   // Check that the event time has been defined
    00277   if ( !validEventTime() ) {
    00278     log << MSG::WARNING
    00279         << "Cannot update DataObject: event time undefined"
    00280         << endreq;
    00281     return StatusCode::SUCCESS;
    00282   }
    00283
    00284   // No need to update if condition is valid
    00285   if ( condition->isValid( eventTime() ) ) {
    00286     log << MSG::DEBUG
    00287         << "DataObject is valid: no need to update" << endreq;
    00288     return StatusCode::SUCCESS;
    00289   } else {
    00290     log << MSG::DEBUG
    00291         << "DataObject is invalid: update it" << endreq;
    00292   }
    00293
    00294   // TODO: before loading updated object, update HERE its parent in data store
    00295
    00296   // Now delegate update to the conversion service by calling the base class
    00297   log << MSG::DEBUG
    00298       << "Delegate update to relevant conversion service" << endreq;
    00299   StatusCode status = DataSvc::updateObject(toUpdate);
    00300   if ( !status.isSuccess() ) {
    00301     log << MSG::ERROR
    00302         << "Could not update DataObject" << endreq;
    00303     if ( status == NO_DATA_LOADER )
    00304       log << MSG::ERROR << "There is no data loader" << endreq;
    00305     return status;
    00306   }
    00307
    00308   // Now cross-check that the new condition is valid
    00309   condition = dynamic_cast<IValidity*>(toUpdate);
    00310   if ( 0 == condition ) {
    00311     log << MSG::ERROR
    00312         << "Updated DataObject does not implement IValidity" << endreq;
    00313     return StatusCode::FAILURE;
    00314   }
    00315   if ( !condition->isValid( eventTime() ) ) {
    00316     log << MSG::ERROR
    00317         << "Updated DataObject is not valid" << endreq;
    00318     log << MSG::ERROR
    00319         << "Are you sure the conversion service has updated it?" << endreq;
    00320     return StatusCode::FAILURE;
    00321   }
    00322
    00323   // DataObject was successfully updated
    00324   log << MSG::DEBUG << "Method updateObject exiting successfully" << endreq;
    00325   return StatusCode::SUCCESS;
    00326
    00327 }

StatusCode DetDataSvc::setupDetectorDescription | ( |  | ) | `[private]`

Deal with Detector Description initialization.

Definition at line 52 of file DetDataSvc.cpp.

    00052                                                 {
    00053   // Now you can use the MsgSvc
    00054   MsgStream log(msgSvc(), name());
    00055
    00056   // Initialize the detector data transient store
    00057   log << MSG::DEBUG << "Storage type used is: " << m_detStorageType << endreq;
    00058   log << MSG::DEBUG << "Setting DetectorDataSvc root node... " << endreq;
    00059
    00060   if( m_usePersistency ) {
    00061
    00062     IOpaqueAddress* rootAddr;
    00063     if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) {
    00064
    00065       // if the name of DBlocation is not given - construct it!
    00066             // by retrieving the value of XMLDDBROOT
    00067
    00068       if ( 0 != getenv("XMLDDDBROOT") ) {
    00069         m_detDbLocation  = getenv("XMLDDDBROOT");
    00070         m_detDbLocation += "/DDDB/lhcb.xml";
    00071       }
    00072     }
    00073     if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) {
    00074       log << MSG::ERROR
    00075           << "Detector data location name not set. Detector data will "
    00076           << "not be found." << endreq;
    00077       return StatusCode::FAILURE;
    00078     }
    00079     else {
    00080       // Create address
    00081       unsigned long iargs[]={0,0};
    00082       const std::string args[] = {m_detDbLocation, m_detDbRootName};
    00083       StatusCode sc = m_addrCreator->createAddress (m_detStorageType,
    00084                                                     CLID_Catalog,
    00085                                                     args,
    00086                                                     iargs,
    00087                                                     rootAddr);
    00088       if( sc.isSuccess() ) {
    00089         std::string dbrName = "/" + m_detDbRootName;
    00090         sc = i_setRoot( dbrName, rootAddr );
    00091         if( sc.isFailure() ) {
    00092           log << MSG::ERROR << "Unable to set detector data store root"
    00093               << endreq;
    00094           return sc;
    00095         }
    00096       }
    00097       else {
    00098         log << MSG::ERROR << "Unable to create address for  /dd" << endreq;
    00099         return sc;
    00100       }
    00101     }
    00102     // Writing the description file in the output log file [bugs #2854]
    00103     log << MSG::ALWAYS << "Detector description database: " << m_detDbLocation << endreq;
    00104   }
    00105   else {
    00106     log << MSG::INFO << "Detector description not requested to be loaded"
    00107         << endreq;
    00108   }
    00109
    00110   return StatusCode::SUCCESS;
    00111 }

StatusCode DetDataSvc::queryInterface | ( | const InterfaceID & | riid,
|  | void ** | ppvInterface |
| ) |  |  | `[virtual]`

Query the interface of the service.

Query interface.

Reimplemented from DataSvc.

Definition at line 156 of file DetDataSvc.cpp.

    00158 {
    00159   // With the highest priority return the specific interfaces
    00160   // If interfaces are not directly available, try out a base class
    00161   if ( IID_IDetDataSvc.versionMatch(riid) ) {
    00162     *ppvInterface = (IDetDataSvc*)this;
    00163   } else if ( IID_IIncidentListener.versionMatch(riid) ) {
    00164     *ppvInterface = (IIncidentListener*)this;
    00165   } else {
    00166     return DataSvc::queryInterface(riid, ppvInterface);
    00167   }
    00168   addRef();
    00169   return StatusCode::SUCCESS;
    00170 }

bool DetDataSvc::validEventTime | ( |  | ) | const`[virtual]`

Check if the event time has been set.

Kept for backward compatibility, returns always true.

Implements IDetDataSvc.

Definition at line 235 of file DetDataSvc.cpp.

    00235                                         {
    00236   return true;
    00237 }

const Gaudi::Time & DetDataSvc::eventTime | ( |  | ) | const`[virtual]`

Get the event time.

Implements IDetDataSvc.

Definition at line 240 of file DetDataSvc.cpp.

    00240                                                {
    00241   return m_eventTime;
    00242 }

void DetDataSvc::setEventTime | ( | const Gaudi::Time & | time | ) | `[virtual]`

Set the new event time.

Implements IDetDataSvc.

Definition at line 225 of file DetDataSvc.cpp.

    00225                                                       {
    00226   // m_eventTime = TimePoint( time );
    00227   m_eventTime = time;
    00228   if ( msgSvc()->outputLevel() <= MSG::DEBUG) {
    00229     MsgStream log( msgSvc(), name() );
    00230     log << MSG::DEBUG << "Event Time set to " << eventTime() << endmsg;
    00231   }
    00232 }

void DetDataSvc::handle | ( | const Incident & | inc | ) | `[virtual]`

Inform that a new incident has occured.

Implements IIncidentListener.

Definition at line 245 of file DetDataSvc.cpp.

    00245                                               {
    00246   MsgStream log( msgSvc(), name() );
    00247   log << MSG::DEBUG << "New incident received" << endreq;
    00248   log << MSG::DEBUG << "Incident source: " << inc.source() << endreq;
    00249   log << MSG::DEBUG << "Incident type: " << inc.type() << endreq;
    00250   return;
    00251 }

## Friends And Related Function Documentation

friend class SvcFactory< DetDataSvc >`[friend]`

Definition at line 29 of file DetDataSvc.h.

## Member Data Documentation

int DetDataSvc::m_detStorageType`[private]`

Detector Data Persistency Storage type.

Definition at line 95 of file DetDataSvc.h.

std::string DetDataSvc::m_detDbLocation`[private]`

Location of detector Db (filename,URL).

Definition at line 98 of file DetDataSvc.h.

std::string DetDataSvc::m_detDbRootName`[private]`

Name of the root node of the detector.

Definition at line 101 of file DetDataSvc.h.

std::string DetDataSvc::m_persistencySvcName`[private]`

Name of the persistency service.

Definition at line 104 of file DetDataSvc.h.

bool DetDataSvc::m_usePersistency`[private]`

Flag to control if the persistency is required.

Definition at line 107 of file DetDataSvc.h.

Gaudi::Time DetDataSvc::m_eventTime`[private]`

Current event time.

Definition at line 110 of file DetDataSvc.h.

IAddressCreator* DetDataSvc::m_addrCreator`[private]`

Address Creator to be used.

Definition at line 113 of file DetDataSvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiSvc/src/DetectorDataSvc/DetDataSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiSvc/src/DetectorDataSvc/DetDataSvc.cpp