TGeoPatternFinder.h

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoPatternFinder.h 25779 2008-10-10 12:33:44Z brun $
00002 // Author: Andrei Gheata   30/10/01
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGeoPatternFinder
00013 #define ROOT_TGeoPatternFinder
00014 
00015 #ifndef ROOT_TObject
00016 #include "TObject.h"
00017 #endif
00018 
00019 #ifndef ROOT_TGeoVolume
00020 #include "TGeoVolume.h"
00021 #endif
00022 
00023 
00024 class TGeoMatrix;
00025 
00026 ////////////////////////////////////////////////////////////////////////////////
00027 //                                                                            //
00028 // TGeoPatternFinder - base finder class for patterns. A pattern is specifying 
00029 //   a division type                                                          //
00030 //                                                                            //
00031 ////////////////////////////////////////////////////////////////////////////////
00032 
00033 class TGeoPatternFinder : public TObject
00034 {
00035 protected :
00036    enum EGeoPatternFlags {
00037       kPatternReflected = BIT(14)
00038    };   
00039    Double_t            fStep;           // division step length
00040    Double_t            fStart;          // starting point on divided axis
00041    Double_t            fEnd;            // ending point
00042    Int_t               fCurrent;        // current division element
00043    Int_t               fNdivisions;     // number of divisions
00044    Int_t               fDivIndex;       // index of first div. node
00045    TGeoMatrix         *fMatrix;         // generic matrix
00046    TGeoVolume         *fVolume;         // volume to which applies
00047    Int_t               fNextIndex;      //! index of next node
00048 
00049    TGeoPatternFinder(const TGeoPatternFinder&); 
00050    TGeoPatternFinder& operator=(const TGeoPatternFinder&);
00051 
00052 public:
00053    // constructors
00054    TGeoPatternFinder();
00055    TGeoPatternFinder(TGeoVolume *vol, Int_t ndiv);
00056    // destructor
00057    virtual ~TGeoPatternFinder();
00058    // methods
00059    virtual void        cd(Int_t /*idiv*/) {}
00060    virtual TGeoNode   *CdNext();
00061    virtual TGeoNode   *FindNode(Double_t * /*point*/, const Double_t * /*dir*/=0) {return 0;} 
00062    virtual Int_t       GetByteCount() const {return 36;}
00063    Int_t               GetCurrent()      {return fCurrent;}
00064    Int_t               GetDivIndex()     {return fDivIndex;}
00065    virtual Int_t       GetDivAxis()      {return 1;}
00066    virtual TGeoMatrix *GetMatrix()       {return fMatrix;}
00067    Int_t               GetNdiv() const   {return fNdivisions;}
00068    Int_t               GetNext() const   {return fNextIndex;}
00069    TGeoNode           *GetNodeOffset(Int_t idiv) {return fVolume->GetNode(fDivIndex+idiv);}  
00070    Double_t            GetStart() const  {return fStart;}
00071    Double_t            GetStep() const   {return fStep;}
00072    Double_t            GetEnd() const    {return fEnd;}
00073    TGeoVolume         *GetVolume() const {return fVolume;}
00074    virtual Bool_t      IsOnBoundary(const Double_t * /*point*/) const {return kFALSE;}
00075    Bool_t              IsReflected() const {return TObject::TestBit(kPatternReflected);}
00076    virtual 
00077    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00078    void                Reflect(Bool_t flag=kTRUE) {TObject::SetBit(kPatternReflected,flag);}
00079    void                SetDivIndex(Int_t index) {fDivIndex = index;}
00080    void                SetNext(Int_t index)     {fNextIndex = index;}
00081    void                SetVolume(TGeoVolume *vol) {fVolume = vol;}
00082 
00083    ClassDef(TGeoPatternFinder, 3)              // patterns to divide volumes
00084 };
00085 
00086 ////////////////////////////////////////////////////////////////////////////
00087 //                                                                        //
00088 // TGeoPatternX - a X axis divison pattern                                //
00089 //                                                                        //
00090 ////////////////////////////////////////////////////////////////////////////
00091 
00092 class TGeoTranslation;
00093 
00094 class TGeoPatternX : public TGeoPatternFinder 
00095 {
00096 public:
00097    // constructors
00098    TGeoPatternX();
00099    TGeoPatternX(TGeoVolume *vol, Int_t ndivisions);
00100    TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00101    TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00102 
00103    // destructor
00104    virtual ~TGeoPatternX();
00105    // methods
00106    virtual void        cd(Int_t idiv);
00107    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0);
00108    virtual Double_t    FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext);
00109    virtual Int_t       GetDivAxis()      {return 1;}
00110    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00111    virtual 
00112    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00113    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00114 
00115    ClassDef(TGeoPatternX, 1)              // X division pattern
00116 };
00117 
00118 ////////////////////////////////////////////////////////////////////////////
00119 //                                                                        //
00120 // TGeoPatternY - a Y axis divison pattern                                //
00121 //                                                                        //
00122 ////////////////////////////////////////////////////////////////////////////
00123 
00124 class TGeoPatternY : public TGeoPatternFinder
00125 {
00126 public:
00127    // constructors
00128    TGeoPatternY();
00129    TGeoPatternY(TGeoVolume *vol, Int_t ndivisions);
00130    TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00131    TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00132    // destructor
00133    virtual ~TGeoPatternY();
00134    // methods
00135    virtual void        cd(Int_t idiv);
00136    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00137    virtual Double_t    FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext);
00138    virtual Int_t       GetDivAxis()      {return 2;}
00139    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00140    virtual 
00141    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00142    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00143 
00144    ClassDef(TGeoPatternY, 1)              // Y division pattern
00145 };
00146 
00147 ////////////////////////////////////////////////////////////////////////////
00148 //                                                                        //
00149 // TGeoPatternZ - a Z axis divison pattern                                //
00150 //                                                                        //
00151 ////////////////////////////////////////////////////////////////////////////
00152 
00153 class TGeoPatternZ : public TGeoPatternFinder
00154 {
00155 public:
00156    // constructors
00157    TGeoPatternZ();
00158    TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions);
00159    TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00160    TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00161    // destructor
00162    virtual ~TGeoPatternZ();
00163    // methods
00164    virtual void        cd(Int_t idiv);
00165    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00166    virtual Double_t    FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext);
00167    virtual Int_t       GetDivAxis()      {return 3;}
00168    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00169    virtual 
00170    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00171    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00172 
00173    ClassDef(TGeoPatternZ, 1)              // Z division pattern
00174 };
00175 
00176 ////////////////////////////////////////////////////////////////////////////
00177 //                                                                        //
00178 // TGeoPatternParaX - a X axis divison pattern for PARA shapes            //
00179 //                                                                        //
00180 ////////////////////////////////////////////////////////////////////////////
00181 
00182 class TGeoPatternParaX : public TGeoPatternFinder 
00183 {
00184 public:
00185    // constructors
00186    TGeoPatternParaX();
00187    TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions);
00188    TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00189    TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00190 
00191    // destructor
00192    virtual ~TGeoPatternParaX();
00193    // methods
00194    virtual void        cd(Int_t idiv);
00195    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0);
00196    virtual Int_t       GetDivAxis()      {return 1;}
00197    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00198    virtual 
00199    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00200    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00201 
00202    ClassDef(TGeoPatternParaX, 1)              // Para X division pattern
00203 };
00204 
00205 ////////////////////////////////////////////////////////////////////////////
00206 //                                                                        //
00207 // TGeoPatternParaY - a Y axis divison pattern for PARA shapes            //
00208 //                                                                        //
00209 ////////////////////////////////////////////////////////////////////////////
00210 
00211 class TGeoPatternParaY : public TGeoPatternFinder 
00212 {
00213 private :
00214 // data members
00215    Double_t         fTxy;      // tangent of alpha
00216 public:
00217    // constructors
00218    TGeoPatternParaY();
00219    TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions);
00220    TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00221    TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00222 
00223    // destructor
00224    virtual ~TGeoPatternParaY();
00225    // methods
00226    virtual void        cd(Int_t idiv);
00227    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0);
00228    virtual Int_t       GetDivAxis()      {return 2;}
00229    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00230    virtual 
00231    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00232    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00233 
00234    ClassDef(TGeoPatternParaY, 1)              // Para Y division pattern
00235 };
00236 
00237 ////////////////////////////////////////////////////////////////////////////
00238 //                                                                        //
00239 // TGeoPatternParaZ - a Z axis divison pattern for PARA shapes            //
00240 //                                                                        //
00241 ////////////////////////////////////////////////////////////////////////////
00242 
00243 class TGeoPatternParaZ : public TGeoPatternFinder 
00244 {
00245 private :
00246 // data members
00247    Double_t            fTxz;  // tangent of alpha xz
00248    Double_t            fTyz;  // tangent of alpha yz
00249 public:
00250    // constructors
00251    TGeoPatternParaZ();
00252    TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions);
00253    TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00254    TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00255 
00256    // destructor
00257    virtual ~TGeoPatternParaZ();
00258    // methods
00259    virtual void        cd(Int_t idiv);
00260    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0);
00261    virtual Int_t       GetDivAxis()      {return 3;}
00262    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00263    virtual 
00264    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00265    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00266 
00267    ClassDef(TGeoPatternParaZ, 1)              // Para Z division pattern
00268 };
00269 
00270 ////////////////////////////////////////////////////////////////////////////
00271 //                                                                        //
00272 // TGeoPatternTrapZ - a Z axis divison pattern for TRAP or GTRA shapes    //
00273 //                                                                        //
00274 ////////////////////////////////////////////////////////////////////////////
00275 
00276 class TGeoPatternTrapZ : public TGeoPatternFinder 
00277 {
00278 private :
00279 // data members
00280    Double_t            fTxz;  // tangent of alpha xz
00281    Double_t            fTyz;  // tangent of alpha yz
00282 public:
00283    // constructors
00284    TGeoPatternTrapZ();
00285    TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions);
00286    TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00287    TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00288 
00289    // destructor
00290    virtual ~TGeoPatternTrapZ();
00291    // methods
00292    Double_t            GetTxz() const {return fTxz;}
00293    Double_t            GetTyz() const {return fTyz;}
00294    virtual void        cd(Int_t idiv);
00295    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0);
00296    virtual Int_t       GetDivAxis()      {return 3;}
00297    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00298    virtual 
00299    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00300    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00301 
00302    ClassDef(TGeoPatternTrapZ, 1)              // Trap od Gtra Z division pattern
00303 };
00304 
00305 
00306 ////////////////////////////////////////////////////////////////////////////
00307 //                                                                        //
00308 // TGeoPatternCylR - a cylindrical R divison pattern                      //
00309 //                                                                        //
00310 ////////////////////////////////////////////////////////////////////////////
00311 
00312 class TGeoPatternCylR : public TGeoPatternFinder
00313 {
00314 public:
00315    // constructors
00316    TGeoPatternCylR();
00317    TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions);
00318    TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00319    TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00320    // destructor
00321    virtual ~TGeoPatternCylR();
00322    // methods
00323    virtual void        cd(Int_t idiv) {fCurrent=idiv;}
00324    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00325    virtual Int_t       GetDivAxis()      {return 1;}
00326    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00327    virtual 
00328    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00329    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00330 
00331    ClassDef(TGeoPatternCylR, 1)              // Cylindrical R division pattern
00332 };
00333 
00334 ////////////////////////////////////////////////////////////////////////////
00335 //                                                                        //
00336 // TGeoPatternCylPhi - a cylindrical phi divison pattern                  //
00337 //                                                                        //
00338 ////////////////////////////////////////////////////////////////////////////
00339 
00340 class TGeoPatternCylPhi : public TGeoPatternFinder
00341 {
00342 private :
00343 // data members
00344    Double_t           *fSinCos;          //![2*fNdivisions] table of sines/cosines
00345 
00346 protected:
00347    TGeoPatternCylPhi(const TGeoPatternCylPhi& pfc) 
00348      : TGeoPatternFinder(pfc), fSinCos(pfc.fSinCos) { }
00349    TGeoPatternCylPhi& operator=(const TGeoPatternCylPhi& pfc)
00350      {if(this!=&pfc) {TGeoPatternFinder::operator=(pfc); fSinCos=pfc.fSinCos;}
00351      return *this;}
00352 
00353 public:
00354    // constructors
00355    TGeoPatternCylPhi();
00356    TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions);
00357    TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00358    TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00359    // destructor
00360    virtual ~TGeoPatternCylPhi();
00361    // methods
00362    virtual void        cd(Int_t idiv);
00363    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00364    virtual Int_t       GetDivAxis()      {return 2;}
00365    virtual Bool_t      IsOnBoundary(const Double_t *point) const;
00366    virtual 
00367    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00368    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00369 
00370    ClassDef(TGeoPatternCylPhi, 1)              // Cylindrical phi division pattern
00371 };
00372 
00373 ////////////////////////////////////////////////////////////////////////////
00374 //                                                                        //
00375 // TGeoPatternSphR - a spherical R divison pattern                        //
00376 //                                                                        //
00377 ////////////////////////////////////////////////////////////////////////////
00378 
00379 class TGeoPatternSphR : public TGeoPatternFinder
00380 {
00381 public:
00382    // constructors
00383    TGeoPatternSphR();
00384    TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions);
00385    TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00386    TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00387    // destructor
00388    virtual ~TGeoPatternSphR();
00389    // methods
00390    virtual void        cd(Int_t idiv) {fCurrent=idiv;}
00391    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00392    virtual Int_t       GetDivAxis()      {return 1;}
00393    virtual 
00394    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00395    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00396 
00397    ClassDef(TGeoPatternSphR, 1)              // spherical R division pattern
00398 };
00399 
00400 ////////////////////////////////////////////////////////////////////////////
00401 //                                                                        //
00402 // TGeoPatternSphTheta - a spherical theta divison pattern                //
00403 //                                                                        //
00404 ////////////////////////////////////////////////////////////////////////////
00405 
00406 class TGeoPatternSphTheta : public TGeoPatternFinder
00407 {
00408 public:
00409    // constructors
00410    TGeoPatternSphTheta();
00411    TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions);
00412    TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00413    TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00414    // destructor
00415    virtual ~TGeoPatternSphTheta();
00416    // methods
00417    virtual void        cd(Int_t idiv) {fCurrent=idiv;}
00418    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00419    virtual Int_t       GetDivAxis()      {return 2;}
00420    virtual 
00421    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00422    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00423 
00424    ClassDef(TGeoPatternSphTheta, 1)              // spherical theta division pattern
00425 };
00426 
00427 ////////////////////////////////////////////////////////////////////////////
00428 //                                                                        //
00429 // TGeoPatternSphPhi - a spherical phi divison pattern                    //
00430 //                                                                        //
00431 ////////////////////////////////////////////////////////////////////////////
00432 
00433 class TGeoPatternSphPhi : public TGeoPatternFinder
00434 {
00435 public:
00436    // constructors
00437    TGeoPatternSphPhi();
00438    TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions);
00439    TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step);
00440    TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
00441    // destructor
00442    virtual ~TGeoPatternSphPhi();
00443    // methods
00444    virtual void        cd(Int_t idiv) {fCurrent=idiv;}
00445    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00446    virtual Int_t       GetDivAxis()      {return 3;}
00447    virtual 
00448    TGeoPatternFinder  *MakeCopy(Bool_t reflect=kFALSE);
00449    virtual void        SavePrimitive(ostream &out, Option_t *option = "");
00450 
00451    ClassDef(TGeoPatternSphPhi, 1)              // Spherical phi division pattern
00452 };
00453 
00454 ////////////////////////////////////////////////////////////////////////////
00455 //                                                                        //
00456 // TGeoPatternHoneycomb - a divison pattern specialized for honeycombs    //
00457 //                                                                        //
00458 ////////////////////////////////////////////////////////////////////////////
00459 
00460 class TGeoPatternHoneycomb : public TGeoPatternFinder
00461 {
00462 private :
00463 // data members
00464    Int_t               fNrows;                  // number of rows
00465    Int_t               fAxisOnRows;             // axis along each row
00466    Int_t              *fNdivisions;             // [fNrows] number of divisions for each row
00467    Double_t           *fStart;                  // [fNrows] starting points for each row
00468 
00469 protected:
00470    TGeoPatternHoneycomb(const TGeoPatternHoneycomb&);
00471    TGeoPatternHoneycomb& operator=(const TGeoPatternHoneycomb&);
00472 
00473 public:
00474    // constructors
00475    TGeoPatternHoneycomb();
00476    TGeoPatternHoneycomb(TGeoVolume *vol, Int_t nrows);
00477    // destructor
00478    virtual ~TGeoPatternHoneycomb();
00479    // methods
00480    virtual void        cd(Int_t idiv) {fCurrent=idiv;}
00481    virtual TGeoNode   *FindNode(Double_t *point, const Double_t *dir=0); 
00482 
00483    ClassDef(TGeoPatternHoneycomb, 1)             // pattern for honeycomb divisions
00484 };
00485 
00486 #endif

Generated on Tue Jul 5 14:12:19 2011 for ROOT_528-00b_version by  doxygen 1.5.1