Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 10:18:06

0001 #pragma once
0002 
0003 #include <math.h>
0004 
0005 #include <TObject.h>
0006 #include <TVector3.h>
0007 
0008 namespace IRT2 {
0009 
0010 class ParametricSurface: public TObject {
0011  public:
0012  ParametricSurface(): m_Umin(0.0), m_Umax(0.0), m_Vmin(0.0), m_Vmax(0.0) {};
0013  ParametricSurface(const TVector3 &x0, double umin, double umax, double vmin, double vmax):
0014   m_Center(x0), m_Umin(umin), m_Umax(umax), m_Vmin(vmin), m_Vmax(vmax) {};
0015   ~ParametricSurface() {};
0016 
0017   // 2D parameter ranges (call them U&V);
0018   double Umin( void ) const { return m_Umin; };
0019   double Umax( void ) const { return m_Umax; };
0020   double Vmin( void ) const { return m_Vmin; };
0021   double Vmax( void ) const { return m_Vmax; };
0022   bool IsInside(double u, double v) const {
0023     return (u >= m_Umin && u <= m_Umax && v >= m_Vmin && v <= m_Vmax);
0024   };
0025   void SetUVranges(double umin, double umax, double vmin, double vmax) {
0026     m_Umin = umin; m_Umax = umax; m_Vmin = vmin; m_Vmax = vmax;
0027   };
0028 
0029   virtual double GetU(const TVector3 &xx) const = 0;
0030   virtual double GetV(const TVector3 &xx) const = 0;
0031   virtual bool IsInside(const TVector3 &xx) const {
0032     return IsInside(GetU(xx), GetV(xx));
0033   };
0034 
0035   virtual TVector3 GetSpacePoint(double u, double v) const = 0;
0036   // There is no check that the point actually belongs to the surface;
0037   // it is assumed that GEANT stepping was done correctly, so the point 
0038   // is more or less close to the 2D surface; for flat and spherical 
0039   // surfaces this is a mute point anyway since this function is implemented 
0040   // in a trivial way;
0041   virtual TVector3 GetNormal(const TVector3 &xx) const = 0;
0042   // Provide a reasonable wrapper; of course simple surfaces 
0043   // can to their own calculations;
0044   virtual TVector3 GetNormal(double u, double v) const {
0045     auto pt = GetSpacePoint(u, v);
0046     return GetNormal(pt);
0047   };
0048   // default, not overriden by all derived classes
0049   virtual TVector3 GetNormal( void ) const {
0050     return TVector3(0.0, 0.0, 0.0);
0051   };
0052   const TVector3 &GetCenter( void ) const { return m_Center; };
0053   virtual double GetDistance(const TVector3 &xx) const = 0;
0054 
0055   // Crossing with the straight line defined by {x0,n0}; 
0056   virtual bool GetCrossing(const TVector3 &x0, const TVector3 &n0, TVector3 *crs, 
0057                bool check_normal = true) const = 0;
0058   bool GetQuadraticEquationCaseCrossing(const TVector3 &x0, const TVector3 &n0, TVector3 *crs, 
0059                     bool check_normal, double a, double b, double c) const;
0060 
0061   // Introduce only the transformations needed for the current task;
0062   virtual ParametricSurface *_Clone(double angle, const TVector3 &axis) const = 0;
0063   void Shift(const TVector3 &shift) {
0064     m_Center += shift;
0065   };
0066   
0067  protected:
0068   // It looks like surfaces I need typically have m_Center defined;
0069   TVector3 m_Center;
0070 
0071  private:
0072   double m_Umin, m_Umax, m_Vmin, m_Vmax;
0073 
0074 #ifndef DISABLE_ROOT_IO
0075   ClassDef(ParametricSurface, 1);
0076 #endif
0077 };
0078 
0079 class LocalCoordinatesXY: public TObject {
0080  public:
0081   LocalCoordinatesXY() {};
0082   ~LocalCoordinatesXY() {};
0083 
0084   virtual double GetLocalX(const TVector3 &xx) const = 0;
0085   virtual double GetLocalY(const TVector3 &xx) const = 0;
0086 
0087 #ifndef DISABLE_ROOT_IO
0088   ClassDef(LocalCoordinatesXY, 1);
0089 #endif
0090 };
0091 
0092 } // namespace IRT2