|
Gaudi Framework, version v21r8 |
| Home | Generated: 17 Mar 2010 |
#include <DetectorDataSvc/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 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. | |
| SmartIF< IAddressCreator > | m_addrCreator |
| Address Creator to be used. | |
Friends | |
| class | SvcFactory< DetDataSvc > |
A DataSvc specialized in detector data.
Definition at line 24 of file DetDataSvc.h.
| DetDataSvc::DetDataSvc | ( | const std::string & | name, | |
| ISvcLocator * | svc | |||
| ) |
Standard Constructor.
Definition at line 187 of file DetDataSvc.cpp.
00187 : 00188 base_class(name,svc), m_eventTime(0) { 00189 declareProperty("DetStorageType", m_detStorageType = XML_StorageType ); 00190 declareProperty("DetDbLocation", m_detDbLocation = "empty" ); 00191 declareProperty("DetDbRootName", m_detDbRootName = "dd" ); 00192 declareProperty("UsePersistency", m_usePersistency = false ); 00193 declareProperty("PersistencySvc", m_persistencySvcName = "DetectorPersistencySvc" ); 00194 m_rootName = "/dd"; 00195 m_rootCLID = CLID_Catalog; 00196 m_addrCreator = 0; 00197 }
| DetDataSvc::~DetDataSvc | ( | ) | [virtual] |
| 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 initialization 00024 StatusCode sc = DataSvc::initialize(); 00025 if( sc.isFailure() ) return sc; 00026 00027 // Set Data Loader 00028 SmartIF<IConversionSvc> cnv_svc(serviceLocator()->service(m_persistencySvcName)); 00029 if( !cnv_svc.isValid() ) { 00030 log << MSG::ERROR << "Unable to retrieve " << m_persistencySvcName << endmsg; 00031 return StatusCode::FAILURE; 00032 } 00033 00034 sc = setDataLoader(cnv_svc); 00035 if( sc.isFailure() ) { 00036 log << MSG::ERROR << "Unable to set DataLoader" << endmsg; 00037 return sc; 00038 } 00039 00040 // Get address creator from the DetectorPersistencySvc 00041 m_addrCreator = cnv_svc; 00042 if (!m_addrCreator.isValid()) { 00043 log << MSG::ERROR << "Unable to get AddressCreator." << endmsg; 00044 return StatusCode::FAILURE; 00045 } 00046 00047 return setupDetectorDescription(); 00048 }
| StatusCode DetDataSvc::reinitialize | ( | ) | [virtual] |
Initialize the service.
Reimplemented from DataSvc.
Definition at line 112 of file DetDataSvc.cpp.
00112 { 00113 MsgStream log(msgSvc(), name()); 00114 00115 // The DetectorDataSvc does not need to be re-initialized. If it is done 00116 // all the Algorithms having references to DetectorElements will become 00117 // invalid and crash the program. (Pere Mato) 00118 00119 // Call base class reinitialization 00120 //StatusCode sc = DataSvc::reinitialize(); 00121 //if( sc.isFailure() ) return sc; 00122 00123 // Delete the associated event time 00124 //if( 0 != m_eventTime ) delete m_eventTime; 00125 //m_eventTimeDefined = false; 00126 00127 //return setupDetectorDescription(); 00128 return StatusCode::SUCCESS; 00129 }
| StatusCode DetDataSvc::finalize | ( | void | ) | [virtual] |
Finalize the service.
Reimplemented from DataSvc.
Definition at line 132 of file DetDataSvc.cpp.
00133 { 00134 MsgStream log(msgSvc(), name()); 00135 log << MSG::DEBUG << "Finalizing" << endmsg; 00136 00137 // clears the store 00138 m_usePersistency = false; // avoid creation of an empty store when clearing 00139 clearStore().ignore(); 00140 00141 // Releases the address creator 00142 m_addrCreator = 0; 00143 00144 // Releases the DataLoader 00145 setDataLoader(0).ignore(); 00146 00147 // Finalize the base class 00148 return DataSvc::finalize(); 00149 }
| StatusCode DetDataSvc::clearStore | ( | ) | [virtual] |
Remove all data objects in the data store.
Reimplemented from DataSvc.
Definition at line 152 of file DetDataSvc.cpp.
00152 { 00153 00154 MsgStream log(msgSvc(), name()); 00155 00156 DataSvc::clearStore().ignore(); 00157 00158 if( m_usePersistency ) { 00159 // Create root address 00160 unsigned long iargs[] = {0,0}; 00161 const std::string args[] = {m_detDbLocation, m_detDbRootName}; 00162 IOpaqueAddress* rootAddr; 00163 StatusCode sc = m_addrCreator->createAddress (m_detStorageType, 00164 CLID_Catalog, 00165 args, 00166 iargs, 00167 rootAddr); 00168 // Set detector data store root 00169 if( sc.isSuccess() ) { 00170 std::string dbrName = "/" + m_detDbRootName; 00171 sc = i_setRoot( dbrName, rootAddr ); 00172 if( sc.isFailure() ) { 00173 log << MSG::ERROR 00174 << "Unable to set detector data store root" << endmsg; 00175 } 00176 } else { 00177 log << MSG::ERROR << "Unable to create address for /dd" << endmsg; 00178 } 00179 return sc; 00180 00181 } 00182 return StatusCode::SUCCESS; 00183 00184 }
| StatusCode DetDataSvc::updateObject | ( | DataObject * | toUpdate | ) | [virtual] |
Update object.
Reimplemented from DataSvc.
Definition at line 233 of file DetDataSvc.cpp.
00233 { 00234 00235 MsgStream log( msgSvc(), name() ); 00236 log << MSG::DEBUG << "Method updateObject starting" << endmsg; 00237 00238 // Check that object to update exists 00239 if ( 0 == toUpdate ) { 00240 log << MSG::ERROR 00241 << "There is no DataObject to update" << endmsg; 00242 return INVALID_OBJECT; 00243 } 00244 00245 // Retrieve IValidity interface of object to update 00246 IValidity* condition = dynamic_cast<IValidity*>( toUpdate ); 00247 if ( 0 == condition ) { 00248 log << MSG::WARNING 00249 << "Cannot update DataObject: DataObject does not implement IValidity" 00250 << endmsg; 00251 return StatusCode::SUCCESS; 00252 } 00253 00254 // Check that the event time has been defined 00255 if ( !validEventTime() ) { 00256 log << MSG::WARNING 00257 << "Cannot update DataObject: event time undefined" 00258 << endmsg; 00259 return StatusCode::SUCCESS; 00260 } 00261 00262 // No need to update if condition is valid 00263 if ( condition->isValid( eventTime() ) ) { 00264 log << MSG::DEBUG 00265 << "DataObject is valid: no need to update" << endmsg; 00266 return StatusCode::SUCCESS; 00267 } else { 00268 log << MSG::DEBUG 00269 << "DataObject is invalid: update it" << endmsg; 00270 } 00271 00272 // TODO: before loading updated object, update HERE its parent in data store 00273 00274 // Now delegate update to the conversion service by calling the base class 00275 log << MSG::DEBUG 00276 << "Delegate update to relevant conversion service" << endmsg; 00277 StatusCode status = DataSvc::updateObject(toUpdate); 00278 if ( !status.isSuccess() ) { 00279 log << MSG::ERROR 00280 << "Could not update DataObject" << endmsg; 00281 if ( status == NO_DATA_LOADER ) 00282 log << MSG::ERROR << "There is no data loader" << endmsg; 00283 return status; 00284 } 00285 00286 // Now cross-check that the new condition is valid 00287 condition = dynamic_cast<IValidity*>(toUpdate); 00288 if ( 0 == condition ) { 00289 log << MSG::ERROR 00290 << "Updated DataObject does not implement IValidity" << endmsg; 00291 return StatusCode::FAILURE; 00292 } 00293 if ( FSMState() == Gaudi::StateMachine::RUNNING && 00294 !condition->isValid( eventTime() ) ) { 00295 log << MSG::ERROR 00296 << "Updated DataObject is not valid" << endmsg; 00297 log << MSG::ERROR 00298 << "Are you sure the conversion service has updated it?" << endmsg; 00299 return StatusCode::FAILURE; 00300 } 00301 00302 // DataObject was successfully updated 00303 log << MSG::DEBUG << "Method updateObject exiting successfully" << endmsg; 00304 return StatusCode::SUCCESS; 00305 00306 }
| StatusCode DetDataSvc::setupDetectorDescription | ( | ) | [private] |
Deal with Detector Description initialization.
Definition at line 50 of file DetDataSvc.cpp.
00050 { 00051 // Now you can use the MsgSvc 00052 MsgStream log(msgSvc(), name()); 00053 00054 // Initialize the detector data transient store 00055 log << MSG::DEBUG << "Storage type used is: " << m_detStorageType << endmsg; 00056 log << MSG::DEBUG << "Setting DetectorDataSvc root node... " << endmsg; 00057 00058 if( m_usePersistency ) { 00059 00060 IOpaqueAddress* rootAddr; 00061 if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) { 00062 00063 // if the name of DBlocation is not given - construct it! 00064 // by retrieving the value of XMLDDBROOT 00065 00066 if ( 0 != getenv("XMLDDDBROOT") ) { 00067 m_detDbLocation = getenv("XMLDDDBROOT"); 00068 m_detDbLocation += "/DDDB/lhcb.xml"; 00069 } 00070 } 00071 if( m_detDbLocation.empty() || "empty" == m_detDbLocation ) { 00072 log << MSG::ERROR 00073 << "Detector data location name not set. Detector data will " 00074 << "not be found." << endmsg; 00075 return StatusCode::FAILURE; 00076 } 00077 else { 00078 // Create address 00079 unsigned long iargs[]={0,0}; 00080 const std::string args[] = {m_detDbLocation, m_detDbRootName}; 00081 StatusCode sc = m_addrCreator->createAddress (m_detStorageType, 00082 CLID_Catalog, 00083 args, 00084 iargs, 00085 rootAddr); 00086 if( sc.isSuccess() ) { 00087 std::string dbrName = "/" + m_detDbRootName; 00088 sc = i_setRoot( dbrName, rootAddr ); 00089 if( sc.isFailure() ) { 00090 log << MSG::ERROR << "Unable to set detector data store root" 00091 << endmsg; 00092 return sc; 00093 } 00094 } 00095 else { 00096 log << MSG::ERROR << "Unable to create address for /dd" << endmsg; 00097 return sc; 00098 } 00099 } 00100 // Writing the description file in the output log file [bugs #2854] 00101 log << MSG::ALWAYS << "Detector description database: " << m_detDbLocation << endmsg; 00102 } 00103 else { 00104 log << MSG::INFO << "Detector description not requested to be loaded" 00105 << endmsg; 00106 } 00107 00108 return StatusCode::SUCCESS; 00109 }
| bool DetDataSvc::validEventTime | ( | ) | const [virtual] |
Check if the event time has been set.
Kept for backward compatibility, returns always true.
Definition at line 213 of file DetDataSvc.cpp.
| const Gaudi::Time & DetDataSvc::eventTime | ( | ) | const [virtual] |
Get the event time.
Definition at line 218 of file DetDataSvc.cpp.
00218 { 00219 return m_eventTime; 00220 }
| void DetDataSvc::setEventTime | ( | const Gaudi::Time & | time | ) | [virtual] |
Set the new event time.
Definition at line 204 of file DetDataSvc.cpp.
00204 { 00205 m_eventTime = time; 00206 if ( msgSvc()->outputLevel() <= MSG::DEBUG) { 00207 MsgStream log( msgSvc(), name() ); 00208 log << MSG::DEBUG << "Event Time set to " << eventTime() << endmsg; 00209 } 00210 }
| void DetDataSvc::handle | ( | const Incident & | inc | ) | [virtual] |
Inform that a new incident has occured.
Definition at line 223 of file DetDataSvc.cpp.
00223 { 00224 MsgStream log( msgSvc(), name() ); 00225 log << MSG::DEBUG << "New incident received" << endmsg; 00226 log << MSG::DEBUG << "Incident source: " << inc.source() << endmsg; 00227 log << MSG::DEBUG << "Incident type: " << inc.type() << endmsg; 00228 return; 00229 }
friend class SvcFactory< DetDataSvc > [friend] |
Definition at line 27 of file DetDataSvc.h.
int DetDataSvc::m_detStorageType [private] |
std::string DetDataSvc::m_detDbLocation [private] |
std::string DetDataSvc::m_detDbRootName [private] |
std::string DetDataSvc::m_persistencySvcName [private] |
bool DetDataSvc::m_usePersistency [private] |
Gaudi::Time DetDataSvc::m_eventTime [private] |
SmartIF<IAddressCreator> DetDataSvc::m_addrCreator [private] |