| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

CoordSysSvc Class Reference

Default implementation of ICoordSysSvc. More...

#include <CoordSysSvc.h>

Inheritance diagram for CoordSysSvc:

[legend]
Collaboration diagram for CoordSysSvc:
[legend]
List of all members.

Public Types

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status

Public Member Functions

 CoordSysSvc (const std::string &name, ISvcLocator *svc)
 ~CoordSysSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
IDetectorElementbelongsToDE (const Gaudi::XYZPoint &globalPoint, IDetectorElement *start=0, int depth=-1)
 Find the smallest IDetectorElement that contains the given global point but do not descend further than the given depth in the IDetectorElement tree which is counted from the top most IDetectorElement.
IDetectorElementcoordSysDE (const Gaudi::XYZPoint &globalPoint, int height=0)
 Find the smallest IDetectorElement containing the global point and who's logical volume provides a canonical coordinate system.
IDetectorElementcoordSysDE (const Gaudi::XYZPoint &globalPoint, IDetectorElement *start, int height=0)
IDetectorElementnextHigherCoordSysDE (IDetectorElement *csde)
virtual unsigned long addRef ()
virtual unsigned long release ()
virtual const std::string & name () const
virtual const InterfaceIDtype () 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 PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
ISvcLocatorserviceLocator () const
IMessageSvcmsgSvc ()
IMessageSvcmsgSvc () const
IMessageSvcmessageService ()
IMessageSvcmessageService () 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
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IAuditorSvcauditorSvc () const

Static Public Member Functions

static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()

Public Attributes

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR

Protected Member Functions

int outputLevel () const
virtual void setServiceManager (ISvcManager *)=0

Protected Attributes

IntegerProperty m_outputLevel
Gaudi::StateMachine::State m_state
Gaudi::StateMachine::State m_targetState
IMessageSvcm_messageSvc

Private Attributes

std::string m_CoordSysUserParameter
 The CoordSysUserParameter property to set what user parameter to look for to find the DetectorElement that provides the coordinate system.
std::string m_TopDetectorElementName
 The TopDetectorElementName property to set the name of the DetectorElement that holds all others.
IDataProviderSvcm_detSvc
IGeometryInfom_topGI
IDetectorElementm_lastBelongsTo
IDetectorElementm_lastCoordSys

Friends

friend class ServiceManager

Detailed Description

Default implementation of ICoordSysSvc.

bv@bnl.gov Thu Oct 23 11:15:47 2008

Definition at line 22 of file CoordSysSvc.h.


Constructor & Destructor Documentation

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

Definition at line 10 of file CoordSysSvc.cc.

00011     : Service(name,svc)
00012     , m_detSvc(0)
00013     , m_topGI(0)
00014     , m_lastBelongsTo(0)
00015     , m_lastCoordSys(0)
00016 {
00017     declareProperty("CoordSysUserParameter",m_CoordSysUserParameter="CoordinateSystem",
00018                     "Name of the user parameter attached to the DetectorElement "
00019                     "that has the LVolume that provides the coordinate system.");
00020     declareProperty("TopDetectorElementName",
00021                     m_TopDetectorElementName="/dd/Structure/DayaBay",
00022                     "Name of the DetectorElement that holds all others");
00023 
00024 }

CoordSysSvc::~CoordSysSvc (  ) 

Definition at line 26 of file CoordSysSvc.cc.

00027 {
00028 }


Member Function Documentation

StatusCode CoordSysSvc::initialize (  )  [virtual]

Reimplemented from Service.

Definition at line 30 of file CoordSysSvc.cc.

00031 {
00032     this->Service::initialize();
00033 
00034     MsgStream msg(msgSvc(),name());
00035     msg << MSG::DEBUG << "CoordSysSvc::initialize()" << endreq;
00036 
00037     StatusCode sc = service("DetectorDataSvc",m_detSvc,true);
00038     if (sc.isFailure()) return sc;
00039 
00040     SmartDataPtr<IDetectorElement> topDE(m_detSvc,m_TopDetectorElementName);
00041     if (!topDE) return StatusCode::FAILURE;
00042 
00043     m_topGI = topDE->geometry();
00044 
00045     return StatusCode::SUCCESS;
00046 }

StatusCode CoordSysSvc::finalize (  )  [virtual]

Reimplemented from Service.

Definition at line 47 of file CoordSysSvc.cc.

00048 {
00049     m_detSvc->release();
00050     m_detSvc = 0;
00051     return StatusCode::SUCCESS;
00052 }

StatusCode CoordSysSvc::queryInterface ( const InterfaceID riid,
void **  ppvInterface 
) [virtual]

Reimplemented from Service.

Definition at line 53 of file CoordSysSvc.cc.

00055 {
00056     StatusCode sc = StatusCode::FAILURE;
00057     if (ppvInterface) {
00058         *ppvInterface = 0;
00059     
00060         if (ICoordSysSvc::interfaceID().versionMatch(riid)) {
00061             *ppvInterface = static_cast<ICoordSysSvc*>(this);
00062             sc = StatusCode::SUCCESS;
00063             addRef();
00064         }
00065         else sc = Service::queryInterface( riid, ppvInterface );    
00066     }
00067     return sc;
00068 }

IDetectorElement * CoordSysSvc::belongsToDE ( const Gaudi::XYZPoint globalPoint,
IDetectorElement start = 0,
int  depth = -1 
) [virtual]

Find the smallest IDetectorElement that contains the given global point but do not descend further than the given depth in the IDetectorElement tree which is counted from the top most IDetectorElement.

If depth<0 do not limit the search. Return 0 on failure.

Implements ICoordSysSvc.

Definition at line 70 of file CoordSysSvc.cc.

00072 {
00073     MsgStream msg(msgSvc(),name());
00074 
00075     // first check if we can try to optimize a little and get lucky
00076     // starting at last result.
00077     if (!start && depth < 0 && m_lastBelongsTo) {
00078         IGeometryInfo* gi = m_lastBelongsTo->geometry();
00079         if (gi->isInside(globalPoint)) {
00080             string path = gi->belongsToPath(globalPoint,-1);
00081             //msg << MSG::VERBOSE
00082             //    << "cached DE ("<< m_lastBelongsTo->name() 
00083             //    <<") gives belongsToPath = " << path << endreq;
00084 
00085             SmartDataPtr<IDetectorElement> de(m_detSvc,path);
00086             if (!de) {
00087                 msg << MSG::ERROR
00088                     << "Failed to get DetectorElement " << path << endreq;
00089                 return 0;
00090             }
00091             m_lastBelongsTo = de;
00092             return m_lastBelongsTo;
00093         }
00094         m_lastBelongsTo = 0;    // bummer
00095     }
00096 
00097     IGeometryInfo* gi = m_topGI;
00098     if (start) gi = start->geometry();
00099 
00100     string path = gi->belongsToPath(globalPoint,depth);
00101     if (!gi->isInside(globalPoint)) {
00102         MsgStream msg(msgSvc(),name());
00103         msg << MSG::DEBUG
00104             << "Failed to get DetectorElement path for point " << globalPoint << endreq;
00105         return 0;
00106     }
00107 
00108     SmartDataPtr<IDetectorElement> de(m_detSvc,path);
00109     if (!de) {
00110         MsgStream msg(msgSvc(),name());
00111         msg << MSG::WARNING
00112             << "No Detector Element at " << path << endreq;
00113         return 0;
00114     }
00115     m_lastBelongsTo = de;
00116     return m_lastBelongsTo;
00117 }

IDetectorElement * CoordSysSvc::coordSysDE ( const Gaudi::XYZPoint globalPoint,
int  height = 0 
) [virtual]

Find the smallest IDetectorElement containing the global point and who's logical volume provides a canonical coordinate system.

A non zero height specifies to return the IDetectorElement that satisfies this which contains this number of other satisfying IDetectorElement. Return 0 on failure.

Implements ICoordSysSvc.

Definition at line 165 of file CoordSysSvc.cc.

00167 {
00168     // Try to optimize, guess that the last one is right for this one
00169     IDetectorElement* de = m_lastBelongsTo;
00170 
00171     // check to see if last found or one of its parents can be reused
00172     while (de) {
00173 
00174         // if the DE doesn't contain the point, try its parent
00175         if (!de->geometry()->isInside(globalPoint)) {
00176             de = this->nextHigherCoordSysDE(de);
00177             continue;
00178         }
00179 
00180         // if DE doesn't have a CoordinateSystem parameter, keep going higher
00181         const ParamValidDataObject* params = de->params();
00182         if (!(params && params->exists(m_CoordSysUserParameter))) {
00183             de = this->nextHigherCoordSysDE(de);
00184             continue;
00185         }
00186 
00187         // know the DE has a CS parameter and contains the point, so drill down...
00188         de = this->belongsToDE(globalPoint,de,-1);
00189 
00190         // and come back up
00191         de = this->coordSysDE(globalPoint,de,height);
00192         if (de) {
00193             m_lastBelongsTo = de;
00194             return de;
00195         }
00196 
00197     }
00198 
00199     // Got to start from the scratch...
00200     de = this->belongsToDE(globalPoint);
00201     if (!de) {
00202         MsgStream msg(msgSvc(),name());
00203         msg << MSG::DEBUG
00204             << "Failed to find DE belonging to point " << globalPoint << endreq;
00205         return 0;
00206     }
00207     m_lastBelongsTo = this->coordSysDE(globalPoint,de,height);
00208     if (!m_lastBelongsTo) {
00209         MsgStream msg(msgSvc(),name());
00210         msg << MSG::DEBUG
00211             << "Failed to find DE starting with " << de->name()
00212             << " and height " << height << " using global point: " << globalPoint
00213             << endreq;
00214         Gaudi::XYZPoint lpoint = de->geometry()->toLocal(globalPoint);
00215         msg << "In that frame the point is " << lpoint << endreq;
00216     }
00217     return m_lastBelongsTo;
00218 }

IDetectorElement * CoordSysSvc::coordSysDE ( const Gaudi::XYZPoint globalPoint,
IDetectorElement start,
int  height = 0 
) [virtual]

Implements ICoordSysSvc.

Definition at line 131 of file CoordSysSvc.cc.

00133 {
00134 
00135     IDetectorElement* de = start;
00136 
00137     // Start from start and work our way up, require a DE that has a
00138     // matching CoordinateSystem value and contains the global point.
00139     // If not, go to next larger CoordinateSystem DE.
00140     while (de) {
00141 
00142         const ParamValidDataObject* params = de->params();
00143         if (params && params->exists(m_CoordSysUserParameter)) {
00144             int level = params->param<int>(m_CoordSysUserParameter);
00145             if (!height || level == height) {
00146                 if (de->geometry()->isInside(globalPoint)) {
00147                     m_lastCoordSys = de;
00148                     return m_lastCoordSys;
00149                 }
00150             }
00151         }
00152         de = this->nextHigherCoordSysDE(de);
00153     }
00154             
00155     // reach here, got nuttin.
00156     MsgStream msg(msgSvc(),name());
00157     msg << MSG::DEBUG
00158         << "Failed to find coord sys DE starting from " 
00159         << start->name() << endreq;
00160     Gaudi::XYZPoint lpoint = start->geometry()->toLocal(globalPoint);
00161     msg << "In that frame the point is " << lpoint << endreq;
00162     return 0;
00163 }

IDetectorElement * CoordSysSvc::nextHigherCoordSysDE ( IDetectorElement csde  ) 

Definition at line 119 of file CoordSysSvc.cc.

00120 {
00121     do {
00122         csde = csde->parentIDetectorElement();
00123         if (!csde) return 0;
00124         const ParamValidDataObject* params = csde->params();
00125         if (params && params->exists(m_CoordSysUserParameter)) 
00126             return csde;
00127     } while (csde);
00128     return 0;
00129 }

const InterfaceID & ICoordSysSvc::interfaceID (  )  [static, inherited]

Reimplemented from IService.

Definition at line 3 of file ICoordSysSvc.cc.

00003                                              {
00004 
00005   static const InterfaceID m_IID("ICoordSysSvc", 1, 0);
00006 
00007   return m_IID;
00008 }


Member Data Documentation

std::string CoordSysSvc::m_CoordSysUserParameter [private]

The CoordSysUserParameter property to set what user parameter to look for to find the DetectorElement that provides the coordinate system.

Default is "CoordinateSystem".

Definition at line 63 of file CoordSysSvc.h.

std::string CoordSysSvc::m_TopDetectorElementName [private]

The TopDetectorElementName property to set the name of the DetectorElement that holds all others.

Default is "/dd/Structure/DayaBay".

Definition at line 68 of file CoordSysSvc.h.

IDataProviderSvc* CoordSysSvc::m_detSvc [private]

Definition at line 70 of file CoordSysSvc.h.

IGeometryInfo* CoordSysSvc::m_topGI [private]

Definition at line 73 of file CoordSysSvc.h.

IDetectorElement* CoordSysSvc::m_lastBelongsTo [private]

Definition at line 76 of file CoordSysSvc.h.

IDetectorElement* CoordSysSvc::m_lastCoordSys [private]

Definition at line 77 of file CoordSysSvc.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:15:10 2011 for DetHelpers by doxygen 1.4.7