TGeoNode.h

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoNode.h 35859 2010-09-29 13:59:30Z brun $
00002 // Author: Andrei Gheata   24/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_TGeoNode
00013 #define ROOT_TGeoNode
00014 
00015 #ifndef ROOT_Riosfwd
00016 #include "Riosfwd.h"
00017 #endif
00018 
00019 #ifndef ROOT_TGeoAtt
00020 #include "TGeoAtt.h"
00021 #endif
00022 
00023 #ifndef ROOT_TNamed
00024 #include "TNamed.h"
00025 #endif
00026 
00027 #ifndef ROOT_TGeoVolume
00028 #include "TGeoVolume.h"
00029 #endif
00030 
00031 #ifndef ROOT_TGeoPatternFinder
00032 #include "TGeoPatternFinder.h"
00033 #endif
00034 
00035 // forward declarations
00036 class TString;
00037 class TGeoVolume;
00038 class TGeoShape;
00039 class TGeoMedium;
00040 class TGeoMatrix;
00041 class TGeoHMatrix;
00042 
00043 ////////////////////////////////////////////////////////////////////////////
00044 //                                                                        //
00045 // TGeoNode - base class for logical nodes. They represent volumes        //
00046 //   positioned inside a mother volume                                    //
00047 //                                                                        //
00048 ////////////////////////////////////////////////////////////////////////////
00049 
00050 class TGeoNode : public TNamed,
00051                  public TGeoAtt
00052 {
00053 protected:
00054    TGeoVolume       *fVolume;         // volume associated with this
00055    TGeoVolume       *fMother;         // mother volume
00056    Int_t             fNumber;         // copy number
00057    Int_t             fNovlp;          // number of overlaps
00058    Int_t            *fOverlaps;       //[fNovlp] list of indices for overlapping brothers
00059 
00060    TGeoNode(const TGeoNode&);
00061    TGeoNode& operator=(const TGeoNode&);
00062 
00063 public:
00064    enum {
00065       kGeoNodeMatrix = BIT(10),
00066       kGeoNodeOffset = BIT(11),
00067       kGeoNodeVC     = BIT(12),
00068       kGeoNodeOverlap = BIT(13)
00069    };
00070 
00071    // constructors
00072    TGeoNode();
00073    TGeoNode(const TGeoVolume *vol);
00074    // destructor
00075    virtual ~TGeoNode();
00076 
00077    void              Browse(TBrowser *b);
00078    virtual void      cd() const {;}
00079    void              CheckOverlaps(Double_t ovlp=0.1, Option_t *option=""); // *MENU*
00080    void              CheckShapes();
00081    Int_t             CountDaughters(Bool_t unique_volumes=kFALSE);
00082    virtual Int_t     DistancetoPrimitive(Int_t px, Int_t py);
00083    void              Draw(Option_t *option="");
00084    void              DrawOnly(Option_t *option="");
00085    void              DrawOverlaps();
00086    virtual void      ExecuteEvent(Int_t event, Int_t px, Int_t py);
00087    void              FillIdArray(Int_t &ifree, Int_t &nodeid, Int_t *array) const;
00088    Int_t             FindNode(const TGeoNode *node, Int_t level);
00089    virtual Int_t     GetByteCount() const {return 44;}
00090    TGeoNode         *GetDaughter(Int_t ind) const {return fVolume->GetNode(ind);}
00091    virtual TGeoMatrix *GetMatrix() const = 0;
00092 
00093    Int_t             GetColour() const {return fVolume->GetLineColor();}
00094    virtual Int_t     GetIndex() const                    {return 0;}
00095    virtual TGeoPatternFinder *GetFinder() const          {return 0;}
00096    TGeoMedium       *GetMedium() const                   {return fVolume->GetMedium();}
00097    TGeoVolume       *GetMotherVolume() const             {return fMother;}
00098    Int_t             GetNdaughters() const {return fVolume->GetNdaughters();}
00099    TObjArray        *GetNodes() const {return fVolume->GetNodes();}
00100    Int_t             GetNumber() const {return fNumber;}
00101    Int_t            *GetOverlaps(Int_t &novlp) const {novlp=fNovlp; return fOverlaps;}
00102    TGeoVolume       *GetVolume() const                   {return fVolume;}
00103    virtual char     *GetObjectInfo(Int_t px, Int_t py) const;
00104    virtual Int_t     GetOptimalVoxels() const {return 0;}
00105    void              InspectNode() const; // *MENU*
00106    virtual Bool_t    IsFolder() const {return (GetNdaughters()?kTRUE:kFALSE);}
00107    Bool_t            IsOffset() const {return TObject::TestBit(kGeoNodeOffset);}
00108    Bool_t            IsOnScreen() const; // *MENU*
00109    Bool_t            IsOverlapping() const {return TObject::TestBit(kGeoNodeOverlap);}
00110    Bool_t            IsVirtual() const {return TObject::TestBit(kGeoNodeVC);}
00111    Bool_t            IsVisible() const {return (TGeoAtt::IsVisible() && fVolume->IsVisible());}
00112    Bool_t            IsVisDaughters() const {return (TGeoAtt::IsVisDaughters() && fVolume->IsVisDaughters());}
00113    Bool_t            MayOverlap(Int_t iother) const;
00114 
00115    virtual TGeoNode *MakeCopyNode() const {return 0;}
00116    Double_t          Safety(Double_t *point, Bool_t in=kTRUE) const;
00117    void              SaveAttributes(ostream &out);
00118    void              SetCurrentPoint(Double_t x, Double_t y, Double_t z) {fVolume->SetCurrentPoint(x,y,z);}// *MENU*
00119    void              SetVolume(TGeoVolume *volume)       {fVolume = volume;}
00120    void              SetNumber(Int_t number)             {fNumber=number;}
00121    void              SetOverlapping(Bool_t flag=kTRUE)   {TObject::SetBit(kGeoNodeOverlap, flag);}
00122    void              SetVirtual()                        {TObject::SetBit(kGeoNodeVC, kTRUE);}
00123    void              SetVisibility(Bool_t vis=kTRUE); // *MENU*
00124    void              SetInvisible()                      {SetVisibility(kFALSE);} // *MENU*
00125    void              SetAllInvisible()                   {VisibleDaughters(kFALSE);} // *MENU*
00126    void              SetMotherVolume(TGeoVolume *mother) {fMother = mother;}
00127    void              SetOverlaps(Int_t *ovlp, Int_t novlp);
00128 
00129    virtual void      MasterToLocal(const Double_t *master, Double_t *local) const;
00130    virtual void      MasterToLocalVect(const Double_t *master, Double_t *local) const;
00131    virtual void      LocalToMaster(const Double_t *local, Double_t *master) const;
00132    virtual void      LocalToMasterVect(const Double_t *local, Double_t *master) const;
00133 
00134    virtual void      ls(Option_t *option = "") const;
00135    virtual void      Paint(Option_t *option = "");       
00136    void              PrintCandidates() const; // *MENU*
00137    void              PrintOverlaps() const; // *MENU*
00138    void              VisibleDaughters(Bool_t vis=kTRUE); // *MENU*
00139 
00140    ClassDef(TGeoNode, 2)               // base class for all geometry nodes
00141 };
00142 
00143 ////////////////////////////////////////////////////////////////////////////
00144 //                                                                        //
00145 // TGeoNodeMatrix - node containing a general transformation              //
00146 //                                                                        //
00147 ////////////////////////////////////////////////////////////////////////////
00148 
00149 class TGeoNodeMatrix : public TGeoNode
00150 {
00151 private:
00152    TGeoMatrix       *fMatrix;         // transf. matrix of fNode in fMother system
00153 
00154 protected:
00155    TGeoNodeMatrix(const TGeoNodeMatrix& gnm);
00156    TGeoNodeMatrix& operator=(const TGeoNodeMatrix& gnm);
00157 
00158 public:
00159    // constructors
00160    TGeoNodeMatrix();
00161    TGeoNodeMatrix(const TGeoVolume *vol, const TGeoMatrix *matrix);
00162    // destructor
00163    virtual ~TGeoNodeMatrix();
00164 
00165    virtual Int_t     GetByteCount() const;
00166    virtual Int_t     GetOptimalVoxels() const;
00167    virtual Bool_t    IsFolder() const {return kTRUE;}
00168    virtual TGeoMatrix *GetMatrix() const   {return fMatrix;}
00169    virtual TGeoNode *MakeCopyNode() const;
00170    void              SetMatrix(const TGeoMatrix *matrix);
00171 
00172    ClassDef(TGeoNodeMatrix, 1)               // a geometry node in the general case
00173 };
00174 
00175 ////////////////////////////////////////////////////////////////////////////
00176 //                                                                        //
00177 // TGeoNodeOffset - node containing only an translation offset            //
00178 //                                                                        //
00179 ////////////////////////////////////////////////////////////////////////////
00180 
00181 class TGeoNodeOffset : public TGeoNode
00182 {
00183 private:
00184    Double_t          fOffset; // X offset for this node with respect to its mother
00185    Int_t             fIndex;  // index of this node in the division
00186    TGeoPatternFinder *fFinder; // finder for this node
00187 
00188 protected:
00189    TGeoNodeOffset(const TGeoNodeOffset&); 
00190    TGeoNodeOffset& operator=(const TGeoNodeOffset&);
00191 
00192 public:
00193    // constructors
00194    TGeoNodeOffset();
00195    TGeoNodeOffset(const TGeoVolume *vol, Int_t index, Double_t offset);
00196    // destructor
00197    virtual ~TGeoNodeOffset();
00198 
00199    virtual void      cd() const           {fFinder->cd(fIndex);}
00200    Double_t          GetOffset() const {return fOffset;}
00201    virtual Int_t     GetIndex() const;
00202    virtual TGeoPatternFinder *GetFinder() const {return fFinder;}
00203    virtual TGeoMatrix *GetMatrix() const {cd(); return fFinder->GetMatrix();}
00204    virtual TGeoNode *MakeCopyNode() const;
00205    void              SetFinder(const TGeoPatternFinder *finder) {fFinder = (TGeoPatternFinder*)finder;}
00206 
00207    ClassDef(TGeoNodeOffset, 1)      // a geometry node with just an offset
00208 };
00209 
00210 ////////////////////////////////////////////////////////////////////////////
00211 //                                                                        //
00212 // TGeoIteratorPlugin - Plugin for a TGeoIterator providing the method    //
00213 //                      ProcessNode each time Next is called.             //
00214 //                                                                        //
00215 ////////////////////////////////////////////////////////////////////////////
00216 
00217 class TGeoIterator;
00218 
00219 class TGeoIteratorPlugin : public TObject
00220 {
00221 protected:
00222    const TGeoIterator *fIterator;           // Caller iterator
00223 private:
00224    // No copy
00225    TGeoIteratorPlugin(const TGeoIteratorPlugin &);
00226    TGeoIteratorPlugin &operator=(const TGeoIteratorPlugin &);
00227 public:
00228    TGeoIteratorPlugin() : TObject(),fIterator(0) {}
00229    virtual ~TGeoIteratorPlugin() {}
00230    
00231    virtual void      ProcessNode() = 0; 
00232    void              SetIterator(const TGeoIterator *iter) {fIterator = iter;} 
00233    
00234    ClassDef(TGeoIteratorPlugin, 0)  // ABC for user plugins connecter to a geometry iterator.
00235 };   
00236    
00237 ////////////////////////////////////////////////////////////////////////////
00238 //                                                                        //
00239 // TGeoIterator - iterator for the node tree                              //
00240 //                                                                        //
00241 ////////////////////////////////////////////////////////////////////////////
00242 
00243 class TGeoIterator
00244 {
00245 private:
00246    TGeoVolume       *fTop;                  // Top volume of the iterated branch
00247    Bool_t            fMustResume;           // Private flag to resume from current node.
00248    Bool_t            fMustStop;             // Private flag to signal that the iterator has finished.
00249    Int_t             fLevel;                // Current level in the tree
00250    Int_t             fType;                 // Type of iteration
00251    Int_t            *fArray;                // Array of node indices for the current path
00252    TGeoHMatrix      *fMatrix;               // Current global matrix
00253    TString           fTopName;              // User name for top
00254    TGeoIteratorPlugin
00255                     *fPlugin;               // User iterator plugin
00256    Bool_t            fPluginAutoexec;       // Plugin automatically executed during next()                 
00257    
00258    void            IncreaseArray();
00259 protected:
00260    TGeoIterator() : fTop(0), fMustResume(0), fMustStop(0), fLevel(0), fType(0), 
00261                     fArray(0), fMatrix(0), fTopName(), fPlugin(0), fPluginAutoexec(kFALSE) { }
00262 
00263 public:
00264    TGeoIterator(TGeoVolume *top);
00265    TGeoIterator(const TGeoIterator &iter);
00266    virtual          ~TGeoIterator();
00267    
00268    TGeoIterator   &operator=(const TGeoIterator &iter);
00269    TGeoNode       *operator()();
00270    TGeoNode       *Next();
00271 
00272    const TGeoMatrix *GetCurrentMatrix() const;
00273    Int_t           GetIndex(Int_t i) const {return ((i<=fLevel)?fArray[i]:-1);}
00274    Int_t           GetLevel() const {return fLevel;}
00275    TGeoNode       *GetNode(Int_t level) const;
00276    void            GetPath(TString &path) const;
00277    TGeoIteratorPlugin 
00278                   *GetUserPlugin() const {return fPlugin;}
00279    
00280    TGeoVolume     *GetTopVolume() const {return fTop;}
00281    Int_t           GetType() const {return fType;}
00282    void            Reset(TGeoVolume *top=0);
00283    void            SetUserPlugin(TGeoIteratorPlugin *plugin);
00284    void            SetPluginAutoexec(Bool_t mode) {fPluginAutoexec = mode;}
00285    void            SetType(Int_t type) {fType = type;}
00286    void            SetTopName(const char* name);
00287    void            Skip();
00288    
00289    ClassDef(TGeoIterator,0)  //Iterator for geometry.
00290 };
00291 
00292 #endif

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