Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
19struct TGeoStateInfo;
20#else
21#include "TGeoStateInfo.h"
22#endif
23
24// forward declarations
25class TGeoManager;
26class TGeoHMatrix;
27
28class TGeoCacheState : public TObject {
29protected:
30 Int_t fCapacity; // maximum level stored
31 Int_t fLevel; // level in the current branch
32 Int_t fNmany; // number of overlapping nodes on current branch
33 Int_t fStart; // start level
34 Int_t fIdBranch[30]; // ID branch
35 Double_t fPoint[3]; // last point in master frame
36 Bool_t fOverlapping; // overlap flag
37
38 TGeoNode **fNodeBranch; // last node branch stored
39 TGeoHMatrix **fMatrixBranch; // global matrices for last branch
40 TGeoHMatrix **fMatPtr; // array of matrix pointers
41
44
45public:
47 TGeoCacheState(Int_t capacity);
48 ~TGeoCacheState() override;
49
50 void SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point = nullptr);
51 Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const;
52
53 ClassDefOverride(TGeoCacheState, 0) // class storing the cache state
54};
55
56class TGeoNodeCache : public TObject {
57private:
58 Int_t fGeoCacheMaxLevels; // maximum supported number of levels
59 Int_t fGeoCacheStackSize; // maximum size of the stack
60 Int_t fGeoInfoStackSize; // maximum size of the stack of info states
61 Int_t fLevel; // level in the current branch
62 Int_t fStackLevel; // current level in the stack
63 Int_t fInfoLevel; // current level in the stack
64 Int_t fCurrentID; // unique ID of current node
65 Int_t fIndex; // index in array of ID's
66 Int_t fIdBranch[100]; // current branch of indices
67 TString fPath; // path for current branch
68 TGeoNode *fTop; // top node
69 TGeoNode *fNode; //! current node
70 TGeoHMatrix *fMatrix; //! current matrix
71 TObjArray *fStack; // stack of cache states
72 TGeoHMatrix **fMatrixBranch; // current branch of global matrices
73 TGeoHMatrix **fMPB; // pre-built matrices
74 TGeoNode **fNodeBranch; // current branch of nodes
75 TGeoStateInfo **fInfoBranch; // current branch of nodes
76 TGeoStateInfo *fPWInfo; //! State info for the parallel world
77 Int_t *fNodeIdArray; //! array of node id's
78
79 TGeoNodeCache(const TGeoNodeCache &) = delete;
81
82public:
84 TGeoNodeCache(TGeoNode *top, Bool_t nodeid = kFALSE, Int_t capacity = 30);
85 ~TGeoNodeCache() override;
86
87 void BuildIdArray();
88 void BuildInfoBranch();
89 void CdNode(Int_t nodeid);
91 Bool_t CdDown(TGeoNode *node);
92 void CdTop()
93 {
94 fLevel = 1;
95 CdUp();
96 }
97 void CdUp();
98 void FillIdBranch(const Int_t *br, Int_t startlevel = 0)
99 {
100 memcpy(fIdBranch + startlevel, br, (fLevel + 1 - startlevel) * sizeof(Int_t));
102 }
103 const Int_t *GetIdBranch() const { return fIdBranch; }
104 void *GetBranch() const { return fNodeBranch; }
105 void GetBranchNames(Int_t *names) const;
106 void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
107 void GetBranchOnlys(Int_t *isonly) const;
108 void *GetMatrices() const { return fMatrixBranch; }
110 Int_t GetCurrentNodeId() const;
111 TGeoNode *GetMother(Int_t up = 1) const { return ((fLevel - up) >= 0) ? fNodeBranch[fLevel - up] : nullptr; }
113 {
114 return ((fLevel - up) >= 0) ? fMatrixBranch[fLevel - up] : nullptr;
115 }
116 TGeoNode *GetNode() const { return fNode; }
117 TGeoNode *GetTopNode() const { return fTop; }
120 void ReleaseInfo();
121 Int_t GetLevel() const { return fLevel; }
122 const char *GetPath();
123 Int_t GetStackLevel() const { return fStackLevel; }
124 Int_t GetNodeId() const;
125 Bool_t HasIdArray() const { return fNodeIdArray ? kTRUE : kFALSE; }
126 Bool_t IsDummy() const { return kTRUE; }
127
128 void LocalToMaster(const Double_t *local, Double_t *master) const;
129 void MasterToLocal(const Double_t *master, Double_t *local) const;
130 void LocalToMasterVect(const Double_t *local, Double_t *master) const;
131 void MasterToLocalVect(const Double_t *master, Double_t *local) const;
132 void LocalToMasterBomb(const Double_t *local, Double_t *master) const;
133 void MasterToLocalBomb(const Double_t *master, Double_t *local) const;
134 Int_t PushState(Bool_t ovlp, Int_t ntmany = 0, Int_t startlevel = 0, Double_t *point = nullptr);
135 Bool_t PopState(Int_t &nmany, Double_t *point = nullptr);
136 Bool_t PopState(Int_t &nmany, Int_t level, Double_t *point = nullptr);
137 void PopDummy(Int_t ipop = 9999) { fStackLevel = (ipop > fStackLevel) ? (fStackLevel - 1) : (ipop - 1); }
138 void Refresh()
139 {
142 }
143 Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point = nullptr);
144
145 ClassDefOverride(TGeoNodeCache, 0) // cache of reusable physical nodes
146};
147
148#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Class storing the state of the cache at a given moment.
Definition TGeoCache.h:28
TGeoHMatrix ** fMatPtr
Definition TGeoCache.h:40
Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const
Restore a modeler state.
Int_t fIdBranch[30]
Definition TGeoCache.h:34
Bool_t fOverlapping
Definition TGeoCache.h:36
TGeoHMatrix ** fMatrixBranch
Definition TGeoCache.h:39
~TGeoCacheState() override
Dtor.
Int_t fCapacity
Definition TGeoCache.h:30
TGeoNode ** fNodeBranch
Definition TGeoCache.h:38
TGeoCacheState()
Default ctor.
void SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point=nullptr)
Fill current modeller state.
Double_t fPoint[3]
Definition TGeoCache.h:35
TGeoCacheState & operator=(const TGeoCacheState &)
assignment operator
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition TGeoMatrix.h:458
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
Special pool of reusable nodes.
Definition TGeoCache.h:56
TGeoNodeCache(const TGeoNodeCache &)=delete
array of node id's
void * GetMatrices() const
Definition TGeoCache.h:108
TGeoNode * GetTopNode() const
Definition TGeoCache.h:117
Bool_t IsDummy() const
Definition TGeoCache.h:126
Int_t fGeoCacheStackSize
Definition TGeoCache.h:59
TGeoHMatrix ** fMPB
Definition TGeoCache.h:73
TGeoNode * GetNode() const
Definition TGeoCache.h:116
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
void * GetBranch() const
Definition TGeoCache.h:104
Bool_t PopState(Int_t &nmany, Double_t *point=nullptr)
Pop next state/point from heap.
TGeoNodeCache()
Dummy constructor.
Definition TGeoCache.cxx:34
void CdTop()
Definition TGeoCache.h:92
void GetBranchOnlys(Int_t *isonly) const
Fill copy numbers of current branch nodes.
TGeoNodeCache & operator=(const TGeoNodeCache &)=delete
const char * GetPath()
Returns the current geometry path.
void MasterToLocal(const Double_t *master, Double_t *local) const
Point in master frame defined by current matrix converted to local one.
TGeoStateInfo * fPWInfo
Definition TGeoCache.h:76
Int_t fIdBranch[100]
Definition TGeoCache.h:66
void BuildIdArray()
Builds node id array.
Int_t fInfoLevel
Definition TGeoCache.h:63
Int_t * fNodeIdArray
State info for the parallel world.
Definition TGeoCache.h:77
void BuildInfoBranch()
Builds info branch. Navigation is possible only after this step.
Int_t PushState(Bool_t ovlp, Int_t ntmany=0, Int_t startlevel=0, Double_t *point=nullptr)
Push current state into heap.
const Int_t * GetIdBranch() const
Definition TGeoCache.h:103
void PopDummy(Int_t ipop=9999)
Definition TGeoCache.h:137
TGeoHMatrix ** fMatrixBranch
Definition TGeoCache.h:72
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill copy numbers of current branch nodes.
TGeoStateInfo ** fInfoBranch
Definition TGeoCache.h:75
TObjArray * fStack
current matrix
Definition TGeoCache.h:71
Int_t GetNodeId() const
Get unique node id.
TGeoStateInfo * GetInfo()
Get next state info pointer.
TGeoStateInfo * GetMakePWInfo(Int_t nd)
Get the PW info, if none create one.
TGeoHMatrix * GetMotherMatrix(Int_t up=1) const
Definition TGeoCache.h:112
Int_t fStackLevel
Definition TGeoCache.h:62
void MasterToLocalVect(const Double_t *master, Double_t *local) const
Vector in master frame defined by current matrix converted to local one.
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.
Int_t fCurrentID
Definition TGeoCache.h:64
Bool_t HasIdArray() const
Definition TGeoCache.h:125
TGeoHMatrix * fMatrix
current node
Definition TGeoCache.h:70
Bool_t CdDown(Int_t index)
Make daughter INDEX of current node the active state. Compute global matrix.
Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point=nullptr)
Pop next state/point from a backed-up state.
void LocalToMaster(const Double_t *local, Double_t *master) const
Local point converted to master frame defined by current matrix.
void LocalToMasterVect(const Double_t *local, Double_t *master) const
Local vector converted to master frame defined by current matrix.
Int_t GetCurrentNodeId() const
Returns a fixed ID for current physical node.
TGeoNode ** fNodeBranch
Definition TGeoCache.h:74
TGeoNode * fTop
Definition TGeoCache.h:68
TString fPath
Definition TGeoCache.h:67
TGeoNode * fNode
Definition TGeoCache.h:69
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.
Int_t GetStackLevel() const
Definition TGeoCache.h:123
void CdUp()
Make mother of current node the active state.
void GetBranchNames(Int_t *names) const
Fill names with current branch volume names (4 char - used by GEANT3 interface).
TGeoHMatrix * GetCurrentMatrix() const
Definition TGeoCache.h:109
void FillIdBranch(const Int_t *br, Int_t startlevel=0)
Definition TGeoCache.h:98
void ReleaseInfo()
Release last used state info pointer.
void Refresh()
Definition TGeoCache.h:138
Int_t fGeoCacheMaxLevels
Definition TGeoCache.h:58
TGeoNode * GetMother(Int_t up=1) const
Definition TGeoCache.h:111
Int_t GetLevel() const
Definition TGeoCache.h:121
~TGeoNodeCache() override
Destructor.
Int_t fGeoInfoStackSize
Definition TGeoCache.h:60
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
Statefull info for the current geometry level.