ROOT  6.06/09
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 #ifndef ROOT_TGeoNode
17 #include "TGeoNode.h"
18 #endif
19 
20 #ifndef ROOT_TGeoStateInfo
21 #include "TGeoStateInfo.h"
22 #endif
23 
24 // forward declarations
25 class TGeoManager;
26 class TGeoHMatrix;
27 
28 /////////////////////////////////////////////////////////////////////////////
29 // //
30 // TGeoCacheState - class storing the state of the cache at a given moment //
31 // //
32 /////////////////////////////////////////////////////////////////////////////
33 
34 class TGeoCacheState : public TObject
35 {
36 protected:
37  Int_t fCapacity; // maximum level stored
38  Int_t fLevel; // level in the current branch
39  Int_t fNmany; // number of overlapping nodes on current branch
40  Int_t fStart; // start level
41  Int_t fIdBranch[30]; // ID branch
42  Double_t fPoint[3]; // last point in master frame
43  Bool_t fOverlapping; // overlap flag
44 
45  TGeoNode **fNodeBranch; // last node branch stored
46  TGeoHMatrix **fMatrixBranch; // global matrices for last branch
47  TGeoHMatrix **fMatPtr; // array of matrix pointers
48 
51 
52 public:
54  TGeoCacheState(Int_t capacity);
55  virtual ~TGeoCacheState();
56 
57  void SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point=0);
58  Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const;
59 
60  ClassDef(TGeoCacheState, 0) // class storing the cache state
61 };
62 
63 /////////////////////////////////////////////////////////////////////////////
64 // //
65 // TGeoNodeCache - cache of reusable physical nodes //
66 // //
67 /////////////////////////////////////////////////////////////////////////////
68 
69 class TGeoNodeCache : public TObject
70 {
71 private:
72  Int_t fGeoCacheMaxLevels;// maximum supported number of levels
73  Int_t fGeoCacheStackSize;// maximum size of the stack
74  Int_t fGeoInfoStackSize; // maximum size of the stack of info states
75  Int_t fLevel; // level in the current branch
76  Int_t fStackLevel; // current level in the stack
77  Int_t fInfoLevel; // current level in the stack
78  Int_t fCurrentID; // unique ID of current node
79  Int_t fIndex; // index in array of ID's
80  Int_t fIdBranch[100]; // current branch of indices
81  TString fPath; // path for current branch
82  TGeoNode *fTop; // top node
83  TGeoNode *fNode; //! current node
84  TGeoHMatrix *fMatrix; //! current matrix
85  TObjArray *fStack; // stack of cache states
86  TGeoHMatrix **fMatrixBranch; // current branch of global matrices
87  TGeoHMatrix **fMPB; // pre-built matrices
88  TGeoNode **fNodeBranch; // current branch of nodes
89  TGeoStateInfo **fInfoBranch; // current branch of nodes
90  TGeoStateInfo *fPWInfo; //! State info for the parallel world
91  Int_t *fNodeIdArray; //! array of node id's
92 
93  TGeoNodeCache(const TGeoNodeCache&); // Not implemented
94  TGeoNodeCache& operator=(const TGeoNodeCache&); // Not implemented
95 
96 public:
97  TGeoNodeCache();
98  TGeoNodeCache(TGeoNode *top, Bool_t nodeid=kFALSE, Int_t capacity=30);
99  virtual ~TGeoNodeCache();
100 
101  void BuildIdArray();
102  void BuildInfoBranch();
103  void CdNode(Int_t nodeid);
104  Bool_t CdDown(Int_t index);
105  Bool_t CdDown(TGeoNode *node);
106  void CdTop() {fLevel=1; CdUp();}
107  void CdUp();
108  void FillIdBranch(const Int_t *br, Int_t startlevel=0) {memcpy(fIdBranch+startlevel,br,(fLevel+1-startlevel)*sizeof(Int_t)); fIndex=fIdBranch[fLevel];}
109  const Int_t *GetIdBranch() const {return fIdBranch;}
110  void *GetBranch() const {return fNodeBranch;}
111  void GetBranchNames(Int_t *names) const;
112  void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
113  void GetBranchOnlys(Int_t *isonly) const;
114  void *GetMatrices() const {return fMatrixBranch;}
116  Int_t GetCurrentNodeId() const;
117  TGeoNode *GetMother(Int_t up=1) const {return ((fLevel-up)>=0)?fNodeBranch[fLevel-up]:0;}
118  TGeoHMatrix *GetMotherMatrix(Int_t up=1) const {return ((fLevel-up)>=0)?fMatrixBranch[fLevel-up]:0;}
119  TGeoNode *GetNode() const {return fNode;}
120  TGeoNode *GetTopNode() const {return fTop;}
123  void ReleaseInfo();
124  Int_t GetLevel() const {return fLevel;}
125  const char *GetPath();
126  Int_t GetStackLevel() const {return fStackLevel;}
127  Int_t GetNodeId() const;
128  Bool_t HasIdArray() const {return (fNodeIdArray)?kTRUE:kFALSE;}
129  Bool_t IsDummy() const {return kTRUE;}
130 
131  void LocalToMaster(const Double_t *local, Double_t *master) const;
132  void MasterToLocal(const Double_t *master, Double_t *local) const;
133  void LocalToMasterVect(const Double_t *local, Double_t *master) const;
134  void MasterToLocalVect(const Double_t *master, Double_t *local) const;
135  void LocalToMasterBomb(const Double_t *local, Double_t *master) const;
136  void MasterToLocalBomb(const Double_t *master, Double_t *local) const;
137  Int_t PushState(Bool_t ovlp, Int_t ntmany=0, Int_t startlevel=0, Double_t *point=0);
138  Bool_t PopState(Int_t &nmany, Double_t *point=0);
139  Bool_t PopState(Int_t &nmany, Int_t level, Double_t *point=0);
140  void PopDummy(Int_t ipop=9999) {fStackLevel=(ipop>fStackLevel)?(fStackLevel-1):(ipop-1);}
141  void Refresh() {fNode=fNodeBranch[fLevel]; fMatrix=fMatrixBranch[fLevel];}
142  Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point=0);
143 
144  ClassDef(TGeoNodeCache, 0) // cache of reusable physical nodes
145 };
146 
147 #endif
Int_t fGeoCacheMaxLevels
Definition: TGeoCache.h:72
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:419
An array of TObjects.
Definition: TObjArray.h:39
void PopDummy(Int_t ipop=9999)
Definition: TGeoCache.h:140
virtual ~TGeoNodeCache()
Destructor.
Definition: TGeoCache.cxx:110
Int_t fCurrentID
Definition: TGeoCache.h:78
void Refresh()
Definition: TGeoCache.h:141
TGeoHMatrix * GetCurrentMatrix() const
Definition: TGeoCache.h:115
TObjArray * fStack
current matrix
Definition: TGeoCache.h:85
TGeoStateInfo * GetInfo()
Get next state info pointer.
Definition: TGeoCache.cxx:327
Int_t fIdBranch[100]
Definition: TGeoCache.h:80
Int_t GetStackLevel() const
Definition: TGeoCache.h:126
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
TGeoNode * GetNode() const
Definition: TGeoCache.h:119
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
TGeoStateInfo * GetMakePWInfo(Int_t nd)
Get the PW info, if none create one.
Definition: TGeoCache.cxx:162
void LocalToMaster(const Double_t *local, Double_t *master) const
Local point converted to master frame defined by current matrix.
Definition: TGeoCache.cxx:411
void GetBranchOnlys(Int_t *isonly) const
Fill copy numbers of current branch nodes.
Definition: TGeoCache.cxx:315
TGeoNode * GetMother(Int_t up=1) const
Definition: TGeoCache.h:117
TGeoStateInfo ** fInfoBranch
Definition: TGeoCache.h:89
void LocalToMasterVect(const Double_t *local, Double_t *master) const
Local vector converted to master frame defined by current matrix.
Definition: TGeoCache.cxx:427
void FillIdBranch(const Int_t *br, Int_t startlevel=0)
Definition: TGeoCache.h:108
#define ClassDef(name, id)
Definition: Rtypes.h:254
TString fPath
Definition: TGeoCache.h:81
Int_t fIdBranch[30]
Definition: TGeoCache.h:41
Bool_t HasIdArray() const
Definition: TGeoCache.h:128
void CdTop()
Definition: TGeoCache.h:106
void * GetBranch() const
Definition: TGeoCache.h:110
Int_t fStart
Definition: TGeoCache.h:40
Int_t fIndex
Definition: TGeoCache.h:79
Bool_t PopState(Int_t &nmany, Double_t *point=0)
Pop next state/point from heap.
Definition: TGeoCache.cxx:378
Int_t * fNodeIdArray
State info for the parallel world.
Definition: TGeoCache.h:91
TGeoHMatrix ** fMatrixBranch
Definition: TGeoCache.h:46
void ReleaseInfo()
Release last used state info pointer.
Definition: TGeoCache.cxx:344
TGeoHMatrix ** fMPB
Definition: TGeoCache.h:87
Int_t GetCurrentNodeId() const
Returns a fixed ID for current physical node.
Definition: TGeoCache.cxx:272
TGeoHMatrix * GetMotherMatrix(Int_t up=1) const
Definition: TGeoCache.h:118
TGeoHMatrix ** fMatPtr
Definition: TGeoCache.h:47
Int_t fCapacity
Definition: TGeoCache.h:37
Int_t fLevel
Definition: TGeoCache.h:38
Int_t GetLevel() const
Definition: TGeoCache.h:124
Int_t GetNodeId() const
Get unique node id.
Definition: TGeoCache.cxx:281
Int_t fGeoCacheStackSize
Definition: TGeoCache.h:73
Int_t fInfoLevel
Definition: TGeoCache.h:77
Bool_t IsDummy() const
Definition: TGeoCache.h:129
const Int_t * GetIdBranch() const
Definition: TGeoCache.h:109
virtual ~TGeoCacheState()
Dtor.
Definition: TGeoCache.cxx:556
Int_t fGeoInfoStackSize
Definition: TGeoCache.h:74
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:435
double Double_t
Definition: RtypesCore.h:55
Double_t fPoint[3]
Definition: TGeoCache.h:42
const char * GetPath()
Returns the current geometry path.
Definition: TGeoCache.cxx:352
Int_t fStackLevel
Definition: TGeoCache.h:76
TGeoNodeCache & operator=(const TGeoNodeCache &)
void GetBranchNames(Int_t *names) const
Fill names with current branch volume names (4 char - used by GEANT3 interface).
Definition: TGeoCache.cxx:292
TGeoNode ** fNodeBranch
Definition: TGeoCache.h:88
TGeoNode * fNode
Definition: TGeoCache.h:83
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:365
TGeoStateInfo * fPWInfo
Definition: TGeoCache.h:90
Mother of all ROOT objects.
Definition: TObject.h:58
Bool_t CdDown(Int_t index)
Make daughter INDEX of current node the active state. Compute global matrix.
Definition: TGeoCache.cxx:210
TGeoHMatrix ** fMatrixBranch
Definition: TGeoCache.h:86
void * GetMatrices() const
Definition: TGeoCache.h:114
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill copy numbers of current branch nodes.
Definition: TGeoCache.cxx:304
void BuildIdArray()
Builds node id array.
Definition: TGeoCache.cxx:133
Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const
Restore a modeler state.
Definition: TGeoCache.cxx:598
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
Definition: TGeoCache.cxx:173
TGeoNode ** fNodeBranch
Definition: TGeoCache.h:45
Bool_t fOverlapping
Definition: TGeoCache.h:43
void CdUp()
Make mother of current node the active state.
Definition: TGeoCache.cxx:260
TGeoNode * fTop
Definition: TGeoCache.h:82
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:451
Int_t fLevel
Definition: TGeoCache.h:75
const Bool_t kTRUE
Definition: Rtypes.h:91
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:571
TGeoNode * GetTopNode() const
Definition: TGeoCache.h:120
Int_t fNmany
Definition: TGeoCache.h:39
TGeoCacheState & operator=(const TGeoCacheState &)
assignment operator
Definition: TGeoCache.cxx:529
void BuildInfoBranch()
Bulds info branch. Navigation is possible only after this step.
Definition: TGeoCache.cxx:150
Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point=0)
Pop next state/point from a backed-up state.
Definition: TGeoCache.cxx:401
TGeoHMatrix * fMatrix
current node
Definition: TGeoCache.h:84
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:443