Logo ROOT  
Reference Guide
TGeoCache.h
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Andrei Gheata 18/03/02
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 // Author : Andrei Gheata - date Wed 12 Dec 2001 09:45:08 AM CET
12 
13 #ifndef ROOT_TGeoCache
14 #define ROOT_TGeoCache
15 
16 #include "TGeoNode.h"
17 
18 #ifdef R__LESS_INCLUDES
19 struct TGeoStateInfo;
20 #else
21 #include "TGeoStateInfo.h"
22 #endif
23 
24 // forward declarations
25 class TGeoManager;
26 class TGeoHMatrix;
27 
28 class TGeoCacheState : public TObject
29 {
30 protected:
31  Int_t fCapacity; // maximum level stored
32  Int_t fLevel; // level in the current branch
33  Int_t fNmany; // number of overlapping nodes on current branch
34  Int_t fStart; // start level
35  Int_t fIdBranch[30]; // ID branch
36  Double_t fPoint[3]; // last point in master frame
37  Bool_t fOverlapping; // overlap flag
38 
39  TGeoNode **fNodeBranch; // last node branch stored
40  TGeoHMatrix **fMatrixBranch; // global matrices for last branch
41  TGeoHMatrix **fMatPtr; // array of matrix pointers
42 
45 
46 public:
48  TGeoCacheState(Int_t capacity);
49  virtual ~TGeoCacheState();
50 
51  void SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point=0);
52  Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const;
53 
54  ClassDef(TGeoCacheState, 0) // class storing the cache state
55 };
56 
57 class TGeoNodeCache : public TObject
58 {
59 private:
60  Int_t fGeoCacheMaxLevels;// maximum supported number of levels
61  Int_t fGeoCacheStackSize;// maximum size of the stack
62  Int_t fGeoInfoStackSize; // maximum size of the stack of info states
63  Int_t fLevel; // level in the current branch
64  Int_t fStackLevel; // current level in the stack
65  Int_t fInfoLevel; // current level in the stack
66  Int_t fCurrentID; // unique ID of current node
67  Int_t fIndex; // index in array of ID's
68  Int_t fIdBranch[100]; // current branch of indices
69  TString fPath; // path for current branch
70  TGeoNode *fTop; // top node
71  TGeoNode *fNode; //! current node
72  TGeoHMatrix *fMatrix; //! current matrix
73  TObjArray *fStack; // stack of cache states
74  TGeoHMatrix **fMatrixBranch; // current branch of global matrices
75  TGeoHMatrix **fMPB; // pre-built matrices
76  TGeoNode **fNodeBranch; // current branch of nodes
77  TGeoStateInfo **fInfoBranch; // current branch of nodes
78  TGeoStateInfo *fPWInfo; //! State info for the parallel world
79  Int_t *fNodeIdArray; //! array of node id's
80 
81  TGeoNodeCache(const TGeoNodeCache&) = delete;
83 
84 public:
85  TGeoNodeCache();
86  TGeoNodeCache(TGeoNode *top, Bool_t nodeid=kFALSE, Int_t capacity=30);
87  virtual ~TGeoNodeCache();
88 
89  void BuildIdArray();
90  void BuildInfoBranch();
91  void CdNode(Int_t nodeid);
92  Bool_t CdDown(Int_t index);
93  Bool_t CdDown(TGeoNode *node);
94  void CdTop() {fLevel=1; CdUp();}
95  void CdUp();
96  void FillIdBranch(const Int_t *br, Int_t startlevel=0) {memcpy(fIdBranch+startlevel,br,(fLevel+1-startlevel)*sizeof(Int_t)); fIndex=fIdBranch[fLevel];}
97  const Int_t *GetIdBranch() const {return fIdBranch;}
98  void *GetBranch() const {return fNodeBranch;}
99  void GetBranchNames(Int_t *names) const;
100  void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
101  void GetBranchOnlys(Int_t *isonly) const;
102  void *GetMatrices() const {return fMatrixBranch;}
104  Int_t GetCurrentNodeId() const;
105  TGeoNode *GetMother(Int_t up=1) const {return ((fLevel-up)>=0)?fNodeBranch[fLevel-up]:0;}
106  TGeoHMatrix *GetMotherMatrix(Int_t up=1) const {return ((fLevel-up)>=0)?fMatrixBranch[fLevel-up]:0;}
107  TGeoNode *GetNode() const {return fNode;}
108  TGeoNode *GetTopNode() const {return fTop;}
111  void ReleaseInfo();
112  Int_t GetLevel() const {return fLevel;}
113  const char *GetPath();
114  Int_t GetStackLevel() const {return fStackLevel;}
115  Int_t GetNodeId() const;
116  Bool_t HasIdArray() const { return fNodeIdArray ? kTRUE : kFALSE; }
117  Bool_t IsDummy() const {return kTRUE;}
118 
119  void LocalToMaster(const Double_t *local, Double_t *master) const;
120  void MasterToLocal(const Double_t *master, Double_t *local) const;
121  void LocalToMasterVect(const Double_t *local, Double_t *master) const;
122  void MasterToLocalVect(const Double_t *master, Double_t *local) const;
123  void LocalToMasterBomb(const Double_t *local, Double_t *master) const;
124  void MasterToLocalBomb(const Double_t *master, Double_t *local) const;
125  Int_t PushState(Bool_t ovlp, Int_t ntmany=0, Int_t startlevel=0, Double_t *point=0);
126  Bool_t PopState(Int_t &nmany, Double_t *point=0);
127  Bool_t PopState(Int_t &nmany, Int_t level, Double_t *point=0);
128  void PopDummy(Int_t ipop=9999) {fStackLevel=(ipop>fStackLevel)?(fStackLevel-1):(ipop-1);}
130  Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point=0);
131 
132  ClassDef(TGeoNodeCache, 0) // cache of reusable physical nodes
133 };
134 
135 #endif
TGeoNodeCache::GetBranchOnlys
void GetBranchOnlys(Int_t *isonly) const
Fill copy numbers of current branch nodes.
Definition: TGeoCache.cxx:307
TGeoNodeCache::CdNode
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
Definition: TGeoCache.cxx:165
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGeoNodeCache::BuildInfoBranch
void BuildInfoBranch()
Builds info branch. Navigation is possible only after this step.
Definition: TGeoCache.cxx:142
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TGeoCacheState::TGeoCacheState
TGeoCacheState()
Default ctor.
Definition: TGeoCache.cxx:460
TGeoNodeCache::HasIdArray
Bool_t HasIdArray() const
Definition: TGeoCache.h:116
TGeoNodeCache::fMatrixBranch
TGeoHMatrix ** fMatrixBranch
Definition: TGeoCache.h:74
TGeoNodeCache::TGeoNodeCache
TGeoNodeCache()
Dummy constructor.
Definition: TGeoCache.cxx:34
TGeoNodeCache::fNode
TGeoNode * fNode
Definition: TGeoCache.h:71
TGeoNodeCache::~TGeoNodeCache
virtual ~TGeoNodeCache()
Destructor.
Definition: TGeoCache.cxx:101
TGeoNodeCache::fTop
TGeoNode * fTop
Definition: TGeoCache.h:70
TGeoCacheState::operator=
TGeoCacheState & operator=(const TGeoCacheState &)
assignment operator
Definition: TGeoCache.cxx:522
TGeoNodeCache::fGeoCacheStackSize
Int_t fGeoCacheStackSize
Definition: TGeoCache.h:61
TGeoNodeCache::fInfoBranch
TGeoStateInfo ** fInfoBranch
Definition: TGeoCache.h:77
TGeoNodeCache::CdDown
Bool_t CdDown(Int_t index)
Make daughter INDEX of current node the active state. Compute global matrix.
Definition: TGeoCache.cxx:202
Int_t
int Int_t
Definition: RtypesCore.h:45
TGeoNodeCache::fGeoCacheMaxLevels
Int_t fGeoCacheMaxLevels
Definition: TGeoCache.h:60
TGeoCacheState::fMatrixBranch
TGeoHMatrix ** fMatrixBranch
Definition: TGeoCache.h:40
TGeoNodeCache::MasterToLocalVect
void MasterToLocalVect(const Double_t *master, Double_t *local) const
Vector in master frame defined by current matrix converted to local one.
Definition: TGeoCache.cxx:427
TGeoNodeCache::GetNodeId
Int_t GetNodeId() const
Get unique node id.
Definition: TGeoCache.cxx:273
TGeoNodeCache::GetMother
TGeoNode * GetMother(Int_t up=1) const
Definition: TGeoCache.h:105
TGeoNodeCache::fNodeIdArray
Int_t * fNodeIdArray
State info for the parallel world.
Definition: TGeoCache.h:79
TGeoCacheState::fMatPtr
TGeoHMatrix ** fMatPtr
Definition: TGeoCache.h:41
TGeoCacheState::fLevel
Int_t fLevel
Definition: TGeoCache.h:32
TGeoCacheState
Class storing the state of the cache at a given moment.
Definition: TGeoCache.h:29
TGeoNodeCache
Special pool of reusable nodes.
Definition: TGeoCache.h:58
TGeoNodeCache::RestoreState
Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point=0)
Pop next state/point from a backed-up state.
Definition: TGeoCache.cxx:393
TString
Basic string class.
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGeoNodeCache::fIndex
Int_t fIndex
Definition: TGeoCache.h:67
TGeoNodeCache::GetBranchNumbers
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill copy numbers of current branch nodes.
Definition: TGeoCache.cxx:296
TGeoNode
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:41
TGeoNodeCache::BuildIdArray
void BuildIdArray()
Builds node id array.
Definition: TGeoCache.cxx:124
bool
TGeoNodeCache::GetBranch
void * GetBranch() const
Definition: TGeoCache.h:98
TGeoNodeCache::Refresh
void Refresh()
Definition: TGeoCache.h:129
TGeoNodeCache::fPath
TString fPath
Definition: TGeoCache.h:69
TGeoNodeCache::fInfoLevel
Int_t fInfoLevel
Definition: TGeoCache.h:65
TGeoStateInfo
Statefull info for the current geometry level.
Definition: TGeoStateInfo.h:21
TGeoCacheState::GetState
Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const
Restore a modeler state.
Definition: TGeoCache.cxx:591
TGeoNodeCache::GetNode
TGeoNode * GetNode() const
Definition: TGeoCache.h:107
TGeoNodeCache::operator=
TGeoNodeCache & operator=(const TGeoNodeCache &)=delete
TGeoNodeCache::fStack
TObjArray * fStack
current matrix
Definition: TGeoCache.h:73
TGeoNodeCache::PushState
Int_t PushState(Bool_t ovlp, Int_t ntmany=0, Int_t startlevel=0, Double_t *point=0)
Push current state into heap.
Definition: TGeoCache.cxx:357
TGeoHMatrix
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition: TGeoMatrix.h:421
TGeoNodeCache::CdUp
void CdUp()
Make mother of current node the active state.
Definition: TGeoCache.cxx:252
TGeoCacheState::fCapacity
Int_t fCapacity
Definition: TGeoCache.h:31
TGeoNodeCache::LocalToMasterBomb
void LocalToMasterBomb(const Double_t *local, Double_t *master) const
Local point converted to master frame defined by current matrix and rescaled with bomb factor.
Definition: TGeoCache.cxx:435
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGeoNodeCache::fCurrentID
Int_t fCurrentID
Definition: TGeoCache.h:66
TGeoNodeCache::GetCurrentMatrix
TGeoHMatrix * GetCurrentMatrix() const
Definition: TGeoCache.h:103
TGeoNodeCache::PopDummy
void PopDummy(Int_t ipop=9999)
Definition: TGeoCache.h:128
TGeoNodeCache::LocalToMaster
void LocalToMaster(const Double_t *local, Double_t *master) const
Local point converted to master frame defined by current matrix.
Definition: TGeoCache.cxx:403
TGeoCacheState::fIdBranch
Int_t fIdBranch[30]
Definition: TGeoCache.h:35
TGeoNodeCache::LocalToMasterVect
void LocalToMasterVect(const Double_t *local, Double_t *master) const
Local vector converted to master frame defined by current matrix.
Definition: TGeoCache.cxx:419
TGeoNodeCache::GetLevel
Int_t GetLevel() const
Definition: TGeoCache.h:112
TGeoNodeCache::GetInfo
TGeoStateInfo * GetInfo()
Get next state info pointer.
Definition: TGeoCache.cxx:319
TGeoCacheState::fStart
Int_t fStart
Definition: TGeoCache.h:34
TGeoNodeCache::GetIdBranch
const Int_t * GetIdBranch() const
Definition: TGeoCache.h:97
TGeoNodeCache::fNodeBranch
TGeoNode ** fNodeBranch
Definition: TGeoCache.h:76
TGeoNodeCache::ReleaseInfo
void ReleaseInfo()
Release last used state info pointer.
Definition: TGeoCache.cxx:336
TGeoNodeCache::GetMotherMatrix
TGeoHMatrix * GetMotherMatrix(Int_t up=1) const
Definition: TGeoCache.h:106
TGeoCacheState::fOverlapping
Bool_t fOverlapping
Definition: TGeoCache.h:37
TGeoNodeCache::fIdBranch
Int_t fIdBranch[100]
Definition: TGeoCache.h:68
TGeoNodeCache::fPWInfo
TGeoStateInfo * fPWInfo
Definition: TGeoCache.h:78
TGeoNodeCache::MasterToLocalBomb
void MasterToLocalBomb(const Double_t *master, Double_t *local) const
Point in master frame defined by current matrix converted to local one and rescaled with bomb factor.
Definition: TGeoCache.cxx:443
TGeoNodeCache::IsDummy
Bool_t IsDummy() const
Definition: TGeoCache.h:117
Double_t
double Double_t
Definition: RtypesCore.h:59
TGeoNodeCache::TGeoNodeCache
TGeoNodeCache(const TGeoNodeCache &)=delete
array of node id's
TGeoNodeCache::fLevel
Int_t fLevel
Definition: TGeoCache.h:63
TGeoNodeCache::MasterToLocal
void MasterToLocal(const Double_t *master, Double_t *local) const
Point in master frame defined by current matrix converted to local one.
Definition: TGeoCache.cxx:411
TGeoNodeCache::CdTop
void CdTop()
Definition: TGeoCache.h:94
TGeoNodeCache::FillIdBranch
void FillIdBranch(const Int_t *br, Int_t startlevel=0)
Definition: TGeoCache.h:96
TGeoNodeCache::fGeoInfoStackSize
Int_t fGeoInfoStackSize
Definition: TGeoCache.h:62
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGeoCacheState::SetState
void SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point=0)
Fill current modeller state.
Definition: TGeoCache.cxx:564
TGeoNodeCache::GetCurrentNodeId
Int_t GetCurrentNodeId() const
Returns a fixed ID for current physical node.
Definition: TGeoCache.cxx:264
TGeoNodeCache::fMPB
TGeoHMatrix ** fMPB
Definition: TGeoCache.h:75
TGeoNodeCache::GetBranchNames
void GetBranchNames(Int_t *names) const
Fill names with current branch volume names (4 char - used by GEANT3 interface).
Definition: TGeoCache.cxx:284
TGeoCacheState::fNmany
Int_t fNmany
Definition: TGeoCache.h:33
TGeoNodeCache::GetTopNode
TGeoNode * GetTopNode() const
Definition: TGeoCache.h:108
TGeoNodeCache::GetStackLevel
Int_t GetStackLevel() const
Definition: TGeoCache.h:114
TGeoCacheState::fPoint
Double_t fPoint[3]
Definition: TGeoCache.h:36
TGeoStateInfo.h
TGeoNodeCache::GetPath
const char * GetPath()
Returns the current geometry path.
Definition: TGeoCache.cxx:344
TGeoCacheState::~TGeoCacheState
virtual ~TGeoCacheState()
Dtor.
Definition: TGeoCache.cxx:549
TGeoNodeCache::fMatrix
TGeoHMatrix * fMatrix
current node
Definition: TGeoCache.h:72
TGeoNodeCache::GetMatrices
void * GetMatrices() const
Definition: TGeoCache.h:102
TGeoManager
The manager class for any TGeo geometry.
Definition: TGeoManager.h:45
TGeoCacheState::fNodeBranch
TGeoNode ** fNodeBranch
Definition: TGeoCache.h:39
TGeoNode.h
TGeoNodeCache::fStackLevel
Int_t fStackLevel
Definition: TGeoCache.h:64
int
TGeoNodeCache::GetMakePWInfo
TGeoStateInfo * GetMakePWInfo(Int_t nd)
Get the PW info, if none create one.
Definition: TGeoCache.cxx:154
TGeoNodeCache::PopState
Bool_t PopState(Int_t &nmany, Double_t *point=0)
Pop next state/point from heap.
Definition: TGeoCache.cxx:370