Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

LayeredTube.h

Go to the documentation of this file.
00001 // $Id: LayeredTube.h,v 1.3 2001/01/25 22:24:32 burnett Exp $
00002 //
00003 // This file is part of Gismo2
00004 //
00005 // Define a LayeredTube, a medium that is a tube with cylindrical layers
00006 // The layers are added by the function member
00007 //
00008 //     addLayer(float thickness, const char* material, Detector detector);
00009 //
00010 // The layers are members of a private class LayeredTube::Layer, itself a Medium
00011 // subclass.
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    // create a new LayeredTube
00031    // +r direction
00032 
00033    Medium& addLayer(float thickness, const char* material="vacuum",
00034                          Detector* det=0);
00035    // add a new layer after the previous one. The enclosing Box will be increased
00036    // in the z-direction by thickness.
00037    // returns reference to the new medium for further modification
00038 
00039    const Medium* inside(const Point& p)const;
00040    // return the parent, if outside, or the appropriate layer if inside 
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;  // dimensions
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       // override inherited function to get right type of parent
00076 
00077       Layer *previous, *next;
00078       float min_r, max_r;  // range of r
00079 
00080       const Point& origin()const;
00081       const Vector& axis()const;
00082       const Tube& parentTube()const;
00083       // access to stuff of the parent
00084 
00085       double localRadius(const Point& p)const;
00086       // calcualtes the radius with respect to axis in local coords
00087    };
00088     // internal class used to store linked list of layers
00089    Layer * first, *last;
00090 
00091    Point m_origin;  // keep track of origin for convenience
00092 
00093    const Layer * select(const Point& x)const;
00094    friend class Layer;
00095 
00096 };
00097 
00099 //                        inlines
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 

Generated at Mon Nov 26 18:18:33 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000