#include <DetElemFinder.h>
Inheritance diagram for DetElemFinder:
Public Types | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
enum | Status |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
Public Member Functions | |
DetElemFinder (const std::string &name, ISvcLocator *svcloc) | |
Standard constructor. | |
virtual | ~DetElemFinder () |
Destructor. | |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
Query interfaces (. | |
virtual const IDetectorElement * | detectorElementForPath (const std::string &path) const |
Find the detector element instance associated to a given physical volume path. | |
virtual StatusCode | initialize () |
Initialize Service. | |
virtual StatusCode | finalize () |
Finalize Service. | |
virtual unsigned long | addRef () |
virtual unsigned long | release () |
virtual const std::string & | name () const |
virtual const InterfaceID & | type () const |
virtual StatusCode | configure () |
virtual StatusCode | start () |
virtual StatusCode | stop () |
virtual StatusCode | terminate () |
virtual Gaudi::StateMachine::State | FSMState () const |
virtual Gaudi::StateMachine::State | targetFSMState () const |
virtual StatusCode | reinitialize () |
virtual StatusCode | restart () |
virtual StatusCode | sysInitialize () |
virtual StatusCode | sysStart () |
virtual StatusCode | sysStop () |
virtual StatusCode | sysFinalize () |
virtual StatusCode | sysReinitialize () |
virtual StatusCode | sysRestart () |
virtual StatusCode | setProperty (const Property &p) |
virtual StatusCode | setProperty (const std::string &s) |
virtual StatusCode | setProperty (const std::string &n, const std::string &v) |
StatusCode | setProperty (const std::string &name, const TYPE &value) |
virtual StatusCode | getProperty (Property *p) const |
virtual const Property & | getProperty (const std::string &name) const |
virtual StatusCode | getProperty (const std::string &n, std::string &v) const |
virtual const std::vector< Property * > & | getProperties () const |
ISvcLocator * | serviceLocator () const |
IMessageSvc * | msgSvc () |
IMessageSvc * | msgSvc () const |
IMessageSvc * | messageService () |
IMessageSvc * | messageService () const |
StatusCode | setProperties () |
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const |
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const |
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const |
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const |
IAuditorSvc * | auditorSvc () const |
virtual unsigned long | addRef ()=0 |
virtual unsigned long | release ()=0 |
Static Public Member Functions | |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
Public Attributes | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
Protected Member Functions | |
int | outputLevel () const |
Protected Attributes | |
IntegerProperty | m_outputLevel |
Gaudi::StateMachine::State | m_state |
Gaudi::StateMachine::State | m_targetState |
IMessageSvc * | m_messageSvc |
Private Types | |
typedef GaudiUtils::HashMap< std::string, const IDetectorElement * > | map_type |
Private Member Functions | |
StatusCode | insert (const IDetectorElement *de, const std::string &parent_path="") |
Recursively add the given detector element and its children. | |
StatusCode | detector_element_path (const IDetectorElement *de, std::string &path, const std::string &parent_path="") |
Find the detector element path and fill the variable path. | |
Private Attributes | |
std::string | m_detDataSvcName |
Name of the Data Provider (set by the option DetDataSvc, by default "DetectorDataSvc"). | |
std::string | m_rootElement |
Path to the detector element to start from. (DetElemFinder.RootElement = "/dd/Structure/LHCb"). | |
bool | m_dumpMap |
Flag to dump the retrieved map of detector elements. (DetElemFinder.DumpMap = false). | |
map_type | m_map |
Structure for the mapping. | |
Friends | |
class | SvcFactory< DetElemFinder > |
Allow SvcFactory to instantiate the service. | |
friend class | ServiceManager |
Definition at line 17 of file DetElemFinder.h.
typedef GaudiUtils::HashMap<std::string, const IDetectorElement *> DetElemFinder::map_type [private] |
Definition at line 66 of file DetElemFinder.h.
DetElemFinder::DetElemFinder | ( | const std::string & | name, | |
ISvcLocator * | svcloc | |||
) |
Standard constructor.
Definition at line 26 of file DetElemFinder.cpp.
00026 : 00027 Service(name,svcloc) 00028 { 00029 declareProperty( "DetectorDataSvc", m_detDataSvcName = "DetectorDataSvc" ); 00030 declareProperty( "RootElement", m_rootElement = "/dd/Structure/LHCb" ); 00031 declareProperty( "DumpMap", m_dumpMap = false ); 00032 } //=============================================================================
DetElemFinder::~DetElemFinder | ( | ) | [virtual] |
StatusCode DetElemFinder::queryInterface | ( | const InterfaceID & | riid, | |
void ** | ppvUnknown | |||
) | [virtual] |
Query interfaces (.
riid | ID of Interface to be retrieved | |
ppvUnknown | Pointer to Location for interface pointer |
Reimplemented from Service.
Definition at line 41 of file DetElemFinder.cpp.
00041 { 00042 if ( IID_IDetElemFinder.versionMatch(riid) ) { 00043 *ppvUnknown = (IDetElemFinder*)this; 00044 addRef(); 00045 return StatusCode::SUCCESS; 00046 } 00047 return Service::queryInterface(riid,ppvUnknown); 00048 }
const IDetectorElement * DetElemFinder::detectorElementForPath | ( | const std::string & | path | ) | const [virtual] |
Find the detector element instance associated to a given physical volume path.
Returns 0 if there is no suitable detector element.
Implements IDetElemFinder.
Definition at line 53 of file DetElemFinder.cpp.
StatusCode DetElemFinder::initialize | ( | ) | [virtual] |
Initialize Service.
Reimplemented from Service.
Definition at line 62 of file DetElemFinder.cpp.
00063 { 00064 // base class initialization 00065 StatusCode sc = Service::initialize(); 00066 if (!sc.isSuccess()) return sc; 00067 00068 // local initialization 00069 MsgStream log(msgSvc(),name()); 00070 log << MSG::DEBUG << "--- initialize ---" << endmsg; 00071 00072 IDataProviderSvc *detSvc = 0; 00073 sc = service(m_detDataSvcName,detSvc,true); 00074 if (!sc.isSuccess()) { 00075 log << MSG::ERROR << "Unable to get a handle to the detector data service (" 00076 << m_detDataSvcName << ")" << endmsg; 00077 return sc; 00078 } 00079 00080 DataObject *obj; 00081 sc = detSvc->retrieveObject(m_rootElement,obj); 00082 if (!sc.isSuccess()) { 00083 log << MSG::ERROR << "Unable to retrieve object '" << m_rootElement << "'" << endmsg; 00084 detSvc->release(); 00085 return sc; 00086 } 00087 IDetectorElement *de = dynamic_cast<IDetectorElement *>(obj); 00088 if (!de) { 00089 log << MSG::ERROR << "Object '" << m_rootElement << "' is not a DetectorElement" << endmsg; 00090 detSvc->release(); 00091 return sc; 00092 } 00093 00094 // I do not need anymore the data proivider 00095 detSvc->release(); 00096 00097 // add all the detector elements to the map 00098 return insert(de); 00099 }
StatusCode DetElemFinder::finalize | ( | ) | [virtual] |
Finalize Service.
Reimplemented from Service.
Definition at line 103 of file DetElemFinder.cpp.
00104 { 00105 // local finalization 00106 MsgStream log(msgSvc(),name()); 00107 log << MSG::DEBUG << "--- finalize ---" << endmsg; 00108 00109 //if (m_outputLevel <= MSG::DEBUG) { 00110 if ( m_dumpMap ) { 00111 for ( map_type::iterator i = m_map.begin(); i != m_map.end(); ++i ){ 00112 //log << MSG::DEBUG << i->first << " -> " << i->second->name() << endmsg; 00113 log << MSG::ALWAYS << i->first << " -> " << i->second->name() << endmsg; 00114 } 00115 } 00116 00117 // base class finalization 00118 return Service::finalize(); 00119 }
StatusCode DetElemFinder::insert | ( | const IDetectorElement * | de, | |
const std::string & | parent_path = "" | |||
) | [private] |
Recursively add the given detector element and its children.
The parameter parent_path is the used to speed up recursion.
Definition at line 178 of file DetElemFinder.cpp.
00178 { 00179 00180 MsgStream log(msgSvc(),name()); 00181 log << MSG::DEBUG << "Preocessing detector element " << de->name() << endmsg; 00182 00183 StatusCode sc = StatusCode::SUCCESS; 00184 00185 std::string path; 00186 00187 // discover the identifier of the DE from the parent: 00188 sc = detector_element_path(de,path,parent_path); 00189 if ( ! sc.isSuccess() ) { 00190 return sc; 00191 } 00192 00193 map_type::iterator x = m_map.find(path); 00194 if ( x != m_map.end() ) { 00195 log << MSG::ERROR << "Cannot insert duplicated path \"" << path << "\" for \"" << de->name() << "\"" << endmsg; 00196 log << MSG::ERROR << "Already used for \"" << x->second->name() << "\"" << endmsg; 00197 return StatusCode::FAILURE; 00198 } 00199 else { 00200 log << MSG::DEBUG << "Insert path \"" << path << "\"" << endmsg; 00201 m_map[path] = de; 00202 } 00203 00204 // insert all children 00205 IDetectorElement::IDEContainer::const_iterator child; 00206 for ( child = de->childBegin(); sc.isSuccess() && child != de->childEnd(); ++child ){ 00207 sc = insert(*child,path); 00208 if ( ! sc.isSuccess() ) { 00209 return sc; 00210 } 00211 } 00212 return sc; 00213 }
StatusCode DetElemFinder::detector_element_path | ( | const IDetectorElement * | de, | |
std::string & | path, | |||
const std::string & | parent_path = "" | |||
) | [private] |
Find the detector element path and fill the variable path.
If parent_path is not specified, it retrieved recursively.
Definition at line 124 of file DetElemFinder.cpp.
00125 { 00126 StatusCode sc = StatusCode::SUCCESS; 00127 00128 // initialize the output variable 00129 path = parent_path; 00130 00131 // get the parent geometryInfo (supportIGeometryInfo() is public) 00132 IGeometryInfo* sgi = de->geometry()->supportIGeometryInfo(); 00133 00134 if (NULL == sgi) { 00135 return sc; 00136 } 00137 00138 // If the parent path was not specified, I have to find it recursively 00139 if (parent_path.empty()){ 00140 if (de->parentIDetectorElement()) { 00141 sc = detector_element_path(de->parentIDetectorElement(),path); 00142 if (!sc.isSuccess()) { 00143 return sc; 00144 } 00145 } else { // this should never happen 00146 return sc; 00147 } 00148 } 00149 00150 // get support LVolume 00151 const ILVolume* lv = sgi->lvolume(); 00152 00153 // define a PVolumePath (this is simply std::vector<const IPVolume*> ) 00154 00155 ILVolume::PVolumePath volumePath; 00156 00157 // Fill it with PVolume* corresponding to the supportPath(). 00158 sc = lv->traverse( de->geometry()->supportPath().begin(), 00159 de->geometry()->supportPath().end(), 00160 volumePath ); 00161 if (!sc.isSuccess()) { 00162 MsgStream log(msgSvc(),name()); 00163 log << MSG::ERROR << "Cannot traverse the support path" << endmsg; 00164 return sc; 00165 } 00166 00167 // build the string 00168 for ( ILVolume::PVolumePath::iterator pv = volumePath.begin(); pv != volumePath.end(); ++pv ) { 00169 path += "/" + (*pv)->name(); 00170 } 00171 return sc; 00172 }
friend class SvcFactory< DetElemFinder > [friend] |
std::string DetElemFinder::m_detDataSvcName [private] |
Name of the Data Provider (set by the option DetDataSvc, by default "DetectorDataSvc").
Definition at line 58 of file DetElemFinder.h.
std::string DetElemFinder::m_rootElement [private] |
Path to the detector element to start from. (DetElemFinder.RootElement = "/dd/Structure/LHCb").
Definition at line 61 of file DetElemFinder.h.
bool DetElemFinder::m_dumpMap [private] |
Flag to dump the retrieved map of detector elements. (DetElemFinder.DumpMap = false).
Definition at line 64 of file DetElemFinder.h.
map_type DetElemFinder::m_map [private] |