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

In This Package:

SolidSphere.h

Go to the documentation of this file.
00001 // $Id: SolidSphere.h,v 1.19 2008/10/28 14:41:39 cattanem Exp $ 
00002 // ===========================================================================
00003 #ifndef     DETDESC_SOLIDSPHERE_H
00004 #define     DETDESC_SOLIDSPHERE_H 1 
00005 // DetDesc 
00006 #include "DetDesc/SolidBase.h" 
00007 // Units
00008 #include "GaudiKernel/SystemOfUnits.h" 
00009 
00010 template <class TYPE>
00011 class SolidFactory;
00012 
00013 
00021 class SolidSphere: public virtual SolidBase
00022 {
00024   friend class SolidFactory<SolidSphere>;
00025   
00026 public:
00027   
00038   SolidSphere( const std::string& name                             ,
00039                const double       OuterRadius                      ,
00040                const double       InsideRadius    =   0.0          , 
00041                const double       StartPhiAngle   =   0.0 * Gaudi::Units::degree,
00042                const double       DeltaPhiAngle   = 360.0 * Gaudi::Units::degree,
00043                const double       StartThetaAngle =   0.0 * Gaudi::Units::degree,
00044                const double       DeltaThetaAngle = 180.0 * Gaudi::Units::degree,
00045                const int          CoverModel      =   0            );
00046 
00047   // destructor 
00048   virtual ~SolidSphere();
00049   
00055   inline std::string typeName () const { return "SolidSphere"; };
00056   
00065   bool isInside ( const Gaudi::XYZPoint& point ) const;
00066   bool isInside ( const Gaudi::Polar3DPoint& point ) const ;
00067   bool isInside ( const Gaudi::RhoZPhiPoint& point ) const ;
00068 
00094   const ISolid* cover () const;
00095   
00104   virtual std::ostream& printOut ( std::ostream& os = std::cout ) const;  
00105   
00114   virtual MsgStream&    printOut ( MsgStream& os ) const;  
00115   
00135   virtual unsigned int intersectionTicks( const Gaudi::XYZPoint & Point,
00136                                           const Gaudi::XYZVector& Vector,
00137                                           ISolid::Ticks& ticks  ) const ;
00138 
00139   virtual unsigned int intersectionTicks( const Gaudi::Polar3DPoint  & Point,
00140                                           const Gaudi::Polar3DVector & Vector,
00141                                           ISolid::Ticks     & ticks) const ; 
00142 
00143   virtual unsigned int intersectionTicks( const Gaudi::RhoZPhiPoint  & Point,
00144                                           const Gaudi::RhoZPhiVector & Vector,
00145                                           ISolid::Ticks     & ticks) const ;
00146   
00150   inline       double               insideRadius   () const 
00151   { return m_sphere_insideR  ; };
00152   
00156   inline       double               insideR2   () const 
00157   { return m_sphere_insideR2 ; }; 
00158   
00162   inline       double               outerRadius  () const 
00163   { return m_sphere_outerR  ; };
00164   
00168   inline       double               outerR2       () const 
00169   { return m_sphere_outerR2 ; }; 
00170   
00174   inline       double               startPhiAngle  () const 
00175   { return m_sphere_startPhiAngle  ; }; 
00176   
00180   inline       double               deltaPhiAngle  () const 
00181   { return m_sphere_deltaPhiAngle  ; }; 
00182   
00186   inline       double               startThetaAngle() const 
00187   { return m_sphere_startThetaAngle; };
00188  
00192   inline       double               deltaThetaAngle() const
00193   { return m_sphere_deltaThetaAngle; }; 
00194   
00198   inline       double  insideDiameter () const 
00199   { return insideRadius()    * 2 ; }; 
00200 
00204   inline       double  outerDiameter  () const 
00205   { return outerRadius()     * 2 ; };
00206  
00210   inline       double  endPhiAngle    () const 
00211   { return m_sphere_startPhiAngle   + m_sphere_deltaPhiAngle   ; }; 
00212   
00216   inline       double  endThetaAngle  () const 
00217   { return m_sphere_startThetaAngle + m_sphere_deltaThetaAngle ; };
00218   
00223   Ticks::size_type maxNumberOfTicks() const { return 4 ; }
00224 
00225 protected:
00226   
00228   bool noPhiGap   () const { return m_noPhiGap   ; }
00230   bool noThetaGap () const { return m_noThetaGap ; }
00231   
00236   template<class aPoint>
00237   inline bool insideR     ( const aPoint& point ) const ;
00238   
00243   template<class aPoint>
00244   inline bool insidePhi   ( const aPoint& point ) const ;
00245   
00250   template<class aPoint>
00251   inline bool insideTheta ( const aPoint& point ) const ;
00252   
00253 protected:
00254 
00258   SolidSphere( const std::string& name = "Anonymous Sphere" );
00259 
00262   void setBP();
00263   
00264 private:
00265   //
00266   SolidSphere           ( const SolidSphere& );  // no copy-constructor 
00267   SolidSphere& operator=( const SolidSphere& );  // no assignment 
00268 
00274   template <class aPoint>
00275   bool isInsideImpl(const aPoint& point) const;
00276 
00277   template<class aPoint, class aVector>
00278   unsigned int intersectionTicksImpl( const aPoint  & Point,
00279                                       const aVector & Vector,
00280                                       ISolid::Ticks& ticks ) const;
00281 
00282   //
00283 private:
00284 
00286   double                m_sphere_outerR2         ;  
00287   double                m_sphere_insideR2        ; 
00288   double                m_sphere_startPhiAngle   ;
00289   double                m_sphere_deltaPhiAngle   ; 
00290   double                m_sphere_startThetaAngle ; 
00291   double                m_sphere_deltaThetaAngle ;
00293   int                   m_sphere_coverModel      ;
00294   //
00295   double                m_sphere_outerR          ;  
00296   double                m_sphere_insideR         ; 
00297   // 
00298   bool                  m_noPhiGap               ;
00299   bool                  m_noThetaGap             ;
00300   //
00301 };
00302 // ===========================================================================
00303 
00304 
00305 // ===========================================================================
00310 // ===========================================================================
00311 template <class aPoint>
00312 inline bool SolidSphere::insideR( const aPoint& point ) const 
00313 {
00314   const double r2 = point.mag2();
00315   if(  r2 >  outerR2 () ) { return false ; }
00316   if(  r2 < insideR2 () ) { return false ; }
00317   // inside! 
00318   return true ;
00319 };
00320 // ===========================================================================
00321 
00322 // ===========================================================================
00327 // ===========================================================================
00328 template <class aPoint>
00329 inline bool SolidSphere::insidePhi( const aPoint& point ) const 
00330 {
00331   if( noPhiGap()                                    ) { return true ; }
00332   double phi = point.phi() ;   // [-180,180] 
00333   if( startPhiAngle ()                   <= phi &&
00334       startPhiAngle () + deltaPhiAngle() >= phi     ) { return true ; }
00335   phi += 360 * Gaudi::Units::degree ;
00336   if( startPhiAngle ()                   <= phi &&
00337       startPhiAngle () + deltaPhiAngle() >= phi     ) { return true ; }
00338   // 
00339   return false ;
00340 };
00341 // ===========================================================================
00342 
00343 // ===========================================================================
00348 // ===========================================================================
00349 template <class aPoint>
00350 inline bool SolidSphere::insideTheta( const aPoint& point ) const 
00351 {
00352   if( noThetaGap()                                        ) { return true ; }
00353   const double theta = point.theta() ;  
00354   if( startThetaAngle ()                     <= theta &&
00355       startThetaAngle () + deltaThetaAngle() >= theta     ) { return true ; }
00356   // 
00357   return false ;
00358 };
00359 // ===========================================================================
00360 
00361 // ===========================================================================
00362 // The END 
00363 // ===========================================================================
00364 #endif 
00365 // ===========================================================================
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:00:13 2011 for DetDesc by doxygen 1.4.7