00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef LAYEREDTUBE_H
00015 #define LAYEREDTUBE_H
00016
00017
00018
00019 #include "gismo/CompositeMedium.h"
00020
00021 #include "geometry/Point.h"
00022 #include "geometry/Tube.h"
00023
00024
00025 class LayeredTube : public CompositeMedium
00026 {
00027 public:
00028
00029 LayeredTube(Medium* parent, float dz, float rzero);
00030
00031
00032
00033 Medium& addLayer(float thickness, const char* material="vacuum",
00034 Detector* det=0);
00035
00036
00037
00038
00039 const Medium* inside(const Point& p)const;
00040
00041
00042
00043 const Tube& tube()const{ return (const Tube&)volume();}
00044 Tube& tube(){ return (Tube&)volume();}
00045 const Point& origin()const{ return m_origin;}
00046 const Vector& axis()const{ return tube().axis();}
00047
00048 GeomObject& transform(const CoordTransform& T);
00049 void createDetectorView(gui::DisplayRep& view);
00050 const char* nameOf()const{return "LayeredTube";}
00051
00052
00053 protected:
00054 double distanceToEnter(const Ray&, const Medium*&, double)const;
00055 double distanceToLeave(const Ray&, const Medium*& ,double) const;
00056
00057 private:
00058 float m_dz, m_r_inner, m_r_outer;
00059
00060 class Layer : public Medium
00061 {
00062 friend class LayeredTube;
00063 Layer(Medium*, const char*, Detector*);
00064
00065 const Medium* inside(const Point&)const{return 0;}
00066 const char* nameOf()const{return "LayeredTube::Layer";}
00067 double distanceToLeave(const Ray& r, const Medium*& , double )const;
00068
00069 GeomObject& transform(const CoordTransform& T);
00070 void createDetectorView(gui::DisplayRep& v);
00071
00072 void printOn(std::ostream&)const;
00073
00074 const LayeredTube* parent()const;
00075
00076
00077 Layer *previous, *next;
00078 float min_r, max_r;
00079
00080 const Point& origin()const;
00081 const Vector& axis()const;
00082 const Tube& parentTube()const;
00083
00084
00085 double localRadius(const Point& p)const;
00086
00087 };
00088
00089 Layer * first, *last;
00090
00091 Point m_origin;
00092
00093 const Layer * select(const Point& x)const;
00094 friend class Layer;
00095
00096 };
00097
00099
00100 inline const LayeredTube*
00101 LayeredTube::Layer::parent()const{ return (const LayeredTube*)_parent;}
00102
00103 inline const Point&
00104 LayeredTube::Layer::origin()const{ return parent()->origin();}
00105
00106 inline const Vector&
00107 LayeredTube::Layer::axis()const{ return parent()->axis();}
00108
00109 inline const Tube&
00110 LayeredTube::Layer::parentTube()const { return parent()->tube();}
00111
00112 inline double
00113 LayeredTube::Layer::localRadius(const Point& x) const
00114 {
00115 Vector r = x - origin();
00116 return sqrt( r.mag2() - sqr(r*axis()) );
00117 }
00118
00119 #endif
00120
00121
00122
00123