TGeoCache.h

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoCache.h 21425 2007-12-17 15:59:27Z brun $
00002 // Author: Andrei Gheata   18/03/02
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 // Author : Andrei Gheata -           date Wed 12 Dec 2001 09:45:08 AM CET
00012 
00013 #ifndef ROOT_TGeoCache
00014 #define ROOT_TGeoCache
00015 
00016 #ifndef ROOT_TGeoNode
00017 #include "TGeoNode.h"
00018 #endif
00019 
00020 // forward declarations
00021 class TGeoManager;
00022 class TGeoHMatrix;
00023 
00024 /////////////////////////////////////////////////////////////////////////////
00025 //                                                                         //
00026 // TGeoCacheState - class storing the state of the cache at a given moment //
00027 //                                                                         //
00028 /////////////////////////////////////////////////////////////////////////////
00029 
00030 class TGeoCacheState : public TObject
00031 {
00032 protected:
00033    Int_t                fCapacity;      // maximum level stored
00034    Int_t                fLevel;         // level in the current branch
00035    Int_t                fNmany;         // number of overlapping nodes on current branch
00036    Int_t                fStart;         // start level
00037    Int_t                fIdBranch[30];  // ID branch
00038    Double_t             fPoint[3];      // last point in master frame
00039    Bool_t               fOverlapping;   // overlap flag
00040 
00041    TGeoNode           **fNodeBranch;    // last node branch stored
00042    TGeoHMatrix        **fMatrixBranch;  // global matrices for last branch
00043    TGeoHMatrix        **fMatPtr;        // array of matrix pointers
00044 
00045    TGeoCacheState(const TGeoCacheState&); 
00046    TGeoCacheState& operator=(const TGeoCacheState&);
00047 
00048 public:
00049    TGeoCacheState();
00050    TGeoCacheState(Int_t capacity);
00051    virtual ~TGeoCacheState();
00052 
00053    void                 SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point=0);
00054    Bool_t               GetState(Int_t &level, Int_t &nmany, Double_t *point) const;
00055 
00056    ClassDef(TGeoCacheState, 4)       // class storing the cache state
00057 };
00058 
00059 /////////////////////////////////////////////////////////////////////////////
00060 //                                                                         //
00061 // TGeoNodeCache - cache of reusable physical nodes                        //
00062 //                                                                         //
00063 /////////////////////////////////////////////////////////////////////////////
00064 
00065 class TGeoNodeCache : public TObject
00066 {
00067 private:
00068    Int_t                 fGeoCacheMaxLevels;// maximum supported number of levels
00069    Int_t                 fGeoCacheStackSize;// maximum size of the stack
00070    Int_t                 fLevel;            // level in the current branch
00071    Int_t                 fStackLevel;       // current level in the stack
00072    Int_t                 fCurrentID;        // unique ID of current node
00073    Int_t                 fIndex;            // index in array of ID's
00074    Int_t                 fIdBranch[100];    // current branch of indices
00075    TString               fPath;             // path for current branch
00076    TGeoNode             *fTop;              // top node
00077    TGeoNode             *fNode;             //! current node
00078    TGeoHMatrix          *fMatrix;           //! current matrix
00079    TObjArray            *fStack;            // stack of cache states
00080    TGeoHMatrix         **fMatrixBranch;     // current branch of global matrices
00081    TGeoHMatrix         **fMPB;              // pre-built matrices
00082    TGeoNode            **fNodeBranch;       // current branch of nodes
00083    Int_t                *fNodeIdArray;      //! array of node id's
00084 
00085 protected:
00086    TGeoNodeCache(const TGeoNodeCache&); // Not implemented
00087    TGeoNodeCache& operator=(const TGeoNodeCache&); // Not implemented
00088 
00089 public:
00090    TGeoNodeCache();
00091    TGeoNodeCache(TGeoNode *top, Bool_t nodeid=kFALSE, Int_t capacity=30);
00092    virtual ~TGeoNodeCache();
00093 
00094    void                 BuildIdArray();
00095    void                 CdNode(Int_t nodeid);
00096    Bool_t               CdDown(Int_t index);
00097    void                 CdTop() {fLevel=1; CdUp();}
00098    void                 CdUp();
00099    void                 FillIdBranch(const Int_t *br, Int_t startlevel=0) {memcpy(fIdBranch+startlevel,br,(fLevel+1-startlevel)*sizeof(Int_t)); fIndex=fIdBranch[fLevel];}
00100    const Int_t         *GetIdBranch() const {return fIdBranch;}
00101    void                *GetBranch() const   {return fNodeBranch;}
00102    void                 GetBranchNames(Int_t *names) const;
00103    void                 GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
00104    void                 GetBranchOnlys(Int_t *isonly) const;
00105    void                *GetMatrices() const {return fMatrixBranch;}
00106    TGeoHMatrix         *GetCurrentMatrix() const {return fMatrix;}
00107    Int_t                GetCurrentNodeId() const;
00108    TGeoNode            *GetMother(Int_t up=1) const {return ((fLevel-up)>=0)?fNodeBranch[fLevel-up]:0;}
00109    TGeoHMatrix         *GetMotherMatrix(Int_t up=1) const {return ((fLevel-up)>=0)?fMatrixBranch[fLevel-up]:0;}
00110    TGeoNode            *GetNode() const        {return fNode;}
00111    TGeoNode            *GetTopNode() const     {return fTop;}
00112    Int_t                GetLevel() const       {return fLevel;}
00113    const char          *GetPath();
00114    Int_t                GetStackLevel() const  {return fStackLevel;}
00115    Int_t                GetNodeId() const;
00116    Bool_t               HasIdArray() const {return (fNodeIdArray)?kTRUE:kFALSE;}
00117    Bool_t               IsDummy() const {return kTRUE;}
00118 
00119    void                 LocalToMaster(const Double_t *local, Double_t *master) const;
00120    void                 MasterToLocal(const Double_t *master, Double_t *local) const;
00121    void                 LocalToMasterVect(const Double_t *local, Double_t *master) const;
00122    void                 MasterToLocalVect(const Double_t *master, Double_t *local) const;
00123    void                 LocalToMasterBomb(const Double_t *local, Double_t *master) const;
00124    void                 MasterToLocalBomb(const Double_t *master, Double_t *local) const;
00125    Int_t                PushState(Bool_t ovlp, Int_t ntmany=0, Int_t startlevel=0, Double_t *point=0);
00126    Bool_t               PopState(Int_t &nmany, Double_t *point=0);
00127    Bool_t               PopState(Int_t &nmany, Int_t level, Double_t *point=0);
00128    void                 PopDummy(Int_t ipop=9999) {fStackLevel=(ipop>fStackLevel)?(fStackLevel-1):(ipop-1);}
00129    void                 Refresh() {fNode=fNodeBranch[fLevel]; fMatrix=fMatrixBranch[fLevel];}
00130    Bool_t               RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point=0);
00131 
00132    ClassDef(TGeoNodeCache, 0)        // cache of reusable physical nodes
00133 };
00134 
00135 #endif
00136 
00137 

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