00001
00002 #ifndef DETDESC_SOLIDBASE_H
00003 #define DETDESC_SOLIDBASE_H 1
00004
00005
00006 #include "DetDesc/Services.h"
00007 #include "DetDesc/ISolid.h"
00008
00010 class IMessageSvc;
00011
00020 class SolidBase: public virtual ISolid
00021 {
00022
00023 public:
00024
00030 virtual const std::string& name() const { return m_name ; }
00031
00039 virtual ISolid* reset ();
00040
00059 virtual unsigned int intersectionTicks( const Gaudi::XYZPoint & Point,
00060 const Gaudi::XYZVector & Vector,
00061 ISolid::Ticks & ticks) const ;
00062 virtual unsigned int intersectionTicks( const Gaudi::Polar3DPoint & Point,
00063 const Gaudi::Polar3DVector & Vector,
00064 ISolid::Ticks & ticks) const ;
00065 virtual unsigned int intersectionTicks( const Gaudi::RhoZPhiPoint & Point,
00066 const Gaudi::RhoZPhiVector & Vector,
00067 ISolid::Ticks & ticks) const ;
00068
00091 virtual unsigned int intersectionTicks( const Gaudi::XYZPoint& Point,
00092 const Gaudi::XYZVector & Vector,
00093 const ISolid::Tick& tickMin,
00094 const ISolid::Tick& tickMax,
00095 ISolid::Ticks& ticks ) const ;
00096
00097 virtual unsigned int intersectionTicks( const Gaudi::Polar3DPoint& Point,
00098 const Gaudi::Polar3DVector & Vector,
00099 const ISolid::Tick& tickMin,
00100 const ISolid::Tick& tickMax,
00101 ISolid::Ticks& ticks ) const ;
00102
00103 virtual unsigned int intersectionTicks( const Gaudi::RhoZPhiPoint& Point,
00104 const Gaudi::RhoZPhiVector & Vector,
00105 const ISolid::Tick& tickMin,
00106 const ISolid::Tick& tickMax,
00107 ISolid::Ticks& ticks ) const ;
00108
00116 virtual StatusCode queryInterface
00117 ( const InterfaceID& ID , void** ppI );
00118
00124 virtual unsigned long addRef () ;
00125
00131 virtual unsigned long release () ;
00132
00140 virtual const ISolid* coverTop () const ;
00141
00148 virtual std::ostream& printOut ( std::ostream& st ) const ;
00149
00156 virtual MsgStream& printOut ( MsgStream& st ) const ;
00157
00158 public :
00159
00161 inline double xMin () const { return m_xmin ; }
00163 inline double xMax () const { return m_xmax ; }
00164
00166 inline double yMin () const { return m_ymin ; }
00168 inline double yMax () const { return m_ymax ; }
00169
00171 inline double zMin () const { return m_zmin ; }
00173 inline double zMax () const { return m_zmax ; }
00174
00176 inline double rMax () const { return m_rmax ; }
00177
00179 inline double rhoMax () const { return m_rhomax ; }
00180
00181 protected:
00182
00188 template <class aPoint>
00189 inline bool isOutBBox
00190 ( const aPoint& point ,
00191 const double tolerance ) const
00192 {
00193 return
00194 point.z () < zMin () - tolerance ||
00195 point.z () > zMax () + tolerance ||
00196 point.x () < xMin () - tolerance ||
00197 point.x () > xMax () + tolerance ||
00198 point.y () < yMin () - tolerance ||
00199 point.y () > yMax () + tolerance ;
00200 };
00205 template <class aPoint>
00206 inline bool isOutBBox
00207 ( const aPoint& point ) const
00208 {
00209 return
00210 point.z () < zMin () ||
00211 point.z () > zMax () ||
00212 point.x () < xMin () ||
00213 point.x () > xMax () ||
00214 point.y () < yMin () ||
00215 point.y () > yMax () ;
00216 };
00217
00223 template <class aPoint>
00224 inline bool isOutBSphere
00225 ( const aPoint& point ,
00226 const double tolerance ) const
00227 {
00228 const double rmax = rMax() + tolerance ;
00229 return rmax <= 0 || point.mag2() > rmax * rmax ;
00230 };
00231
00236 template <class aPoint>
00237 inline bool isOutBSphere ( const aPoint& point ) const
00238 {
00239 return point.mag2 () > rMax () * rMax () ;
00240 };
00241
00248 template <class aPoint>
00249 inline bool isOutBCylinder
00250 ( const aPoint& point ,
00251 const double tolerance ) const
00252 {
00253 const double rhomax = rhoMax() + tolerance ;
00254 return rhomax <= 0 ? true :
00255 point.z () < zMin () - tolerance ? true :
00256 point.z () > zMax () + tolerance ? true :
00257 point.perp2 () > rhomax * rhomax ? true : false ;
00258 };
00259
00265 template <class aPoint>
00266 inline bool isOutBCylinder ( const aPoint& point ) const
00267 {
00268 return
00269 point.z () < zMin () ||
00270 point.z () > zMax () ||
00271 point.perp2 () > rhoMax () * rhoMax () ;
00272 };
00273
00281 template<class aPointA, class aPointB>
00282 inline bool isOutBBox
00283 ( const aPointA& p1 ,
00284 const aPointB& p2 ,
00285 const double tolerance ) const
00286 {
00287 return
00288 ( (p1.z() < zMin()-tolerance && p2.z() < zMin()-tolerance) ||
00289 (p1.z() > zMax()+tolerance && p2.z() > zMax()+tolerance) ||
00290 (p1.x() < xMin()-tolerance && p2.x() < xMin()-tolerance) ||
00291 (p1.x() > xMax()+tolerance && p2.x() > xMax()+tolerance) ||
00292 (p1.y() < yMin()-tolerance && p2.y() < yMin()-tolerance) ||
00293 (p1.y() > yMax()+tolerance && p2.y() > yMax()+tolerance) );
00294 };
00295
00302 template<class aPointA, class aPointB>
00303 inline bool isOutBBox
00304 ( const aPointA& p1 ,
00305 const aPointB& p2 ) const
00306 {
00307 return
00308 ( p1.z() < zMin() && p2.z() < zMin() ) ||
00309 ( p1.z() > zMax() && p2.z() > zMax() ) ||
00310 ( p1.x() < xMin() && p2.x() < xMin() ) ||
00311 ( p1.x() > xMax() && p2.x() > xMax() ) ||
00312 ( p1.y() < yMin() && p2.y() < yMin() ) ||
00313 ( p1.y() > yMax() && p2.y() > yMax() ) ;
00314 };
00315
00325 template <class aPoint, class aVector>
00326 inline bool isOutBBox
00327 ( const aPoint& p ,
00328 const aVector& v ,
00329 const ISolid::Tick& tmin ,
00330 const ISolid::Tick& tmax ,
00331 const double tolerance ) const
00332 {
00333 return isOutBBox( p + tmin * v , p + tmax * v , tolerance );
00334 };
00335
00344 template <class aPoint, class aVector>
00345 inline bool isOutBBox
00346 ( const aPoint& p ,
00347 const aVector& v ,
00348 const ISolid::Tick& tmin ,
00349 const ISolid::Tick& tmax ) const
00350 {
00351 return isOutBBox( p + tmin * v , p + tmax * v );
00352 };
00353
00360 template <class aPoint, class aVector>
00361 inline bool crossBSphere
00362 ( const aPoint& p ,
00363 const aVector& v ,
00364 const double tolerance = 0 ) const
00365 {
00366 const double pp = p.mag2 () ;
00367 const double vv = v.mag2 () ;
00368 const double pv = p.Dot ( v ) ;
00369 const double rmax = rMax() + tolerance ;
00370 const double dd = rmax * rmax ;
00371 return ( rmax > 0 &&
00372 !(0 == vv && pp > dd) &&
00373 !( (vv*pp) - (pv*pv) > vv*dd ) );
00374 };
00375
00382 template <class aPoint, class aVector>
00383 inline bool crossBCylinder
00384 ( const aPoint& p ,
00385 const aVector& v ,
00386 const double tolerance = 0 ) const
00387 {
00388 const double pp = p.perp2 () ;
00389 const double vv = v.perp2 () ;
00390 const double pv = p.Dot ( v ) - p.z() * v.z() ;
00391 const double rhomax = rhoMax() + tolerance ;
00392 const double dd = rhomax * rhomax ;
00393 return ( rhomax > 0 &&
00394 !( 0 == vv && pp > dd ) &&
00395 !( (vv*pp) - (pv*pv) > vv*dd ) );
00396 };
00397
00398 protected:
00399
00401 inline void setXMin ( const double value ) { m_xmin = value ; }
00403 inline void setXMax ( const double value ) { m_xmax = value ; }
00404
00406 inline void setYMin ( const double value ) { m_ymin = value ; }
00408 inline void setYMax ( const double value ) { m_ymax = value ; }
00409
00411 inline void setZMin ( const double value ) { m_zmin = value ; }
00413 inline void setZMax ( const double value ) { m_zmax = value ; }
00414
00416 inline void setRMax ( const double value ) { m_rmax = value ; }
00418 inline void setRhoMax ( const double value ) { m_rhomax = value ; }
00419
00424 void checkBP() const ;
00425
00430 IMessageSvc* msgSvc() const;
00431
00432 protected:
00433
00437 SolidBase( const std::string& Name="Undefined" );
00438
00440 virtual ~SolidBase();
00441
00442 private:
00444
00445
00446
00447 SolidBase& operator=( const SolidBase& ) ;
00448
00449 template<class aPoint, class aVector>
00450 unsigned int intersectionTicksImpl( const aPoint & Point,
00451 const aVector & Vector,
00452 const ISolid::Tick& tickMin,
00453 const ISolid::Tick& tickMax,
00454 ISolid::Ticks& ticks) const;
00455
00456 unsigned int intersectionTicksImpl( ISolid::Ticks& ticks ) const;
00457
00458 protected:
00459
00460 std::string m_name ;
00461 mutable ISolid* m_cover ;
00462
00463 double m_xmin ;
00464 double m_ymin ;
00465 double m_zmin ;
00466
00467 double m_xmax ;
00468 double m_ymax ;
00469 double m_zmax ;
00470
00471 double m_rmax ;
00472 double m_rhomax ;
00473
00475 DetDesc::Services* m_services;
00476 };
00477
00478
00479
00480
00481 #endif //< DETDESC_SOLIDBASE_H
00482