Logo ROOT   6.12/07
Reference Guide
TGeoNode.h
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Andrei Gheata 24/10/01
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 
12 #ifndef ROOT_TGeoNode
13 #define ROOT_TGeoNode
14 
15 #include "TGeoAtt.h"
16 
17 #include "TNamed.h"
18 
19 #include "TGeoVolume.h"
20 
21 #include "TGeoPatternFinder.h"
22 
23 // forward declarations
24 class TString;
25 class TGeoVolume;
26 class TGeoShape;
27 class TGeoMedium;
28 class TGeoMatrix;
29 class TGeoHMatrix;
30 class TGeoExtension;
31 
32 ////////////////////////////////////////////////////////////////////////////
33 // //
34 // TGeoNode - base class for logical nodes. They represent volumes //
35 // positioned inside a mother volume //
36 // //
37 ////////////////////////////////////////////////////////////////////////////
38 
39 class TGeoNode : public TNamed,
40  public TGeoAtt
41 {
42 protected:
43  TGeoVolume *fVolume = nullptr; // volume associated with this
44  TGeoVolume *fMother = nullptr; // mother volume
45  Int_t fNumber = 0; // copy number
46  Int_t fNovlp = 0; // number of overlaps
47  Int_t *fOverlaps = nullptr; //[fNovlp] list of indices for overlapping brothers
48  TGeoExtension *fUserExtension = nullptr; //! Transient user-defined extension to volumes
49  TGeoExtension *fFWExtension = nullptr; //! Transient framework-defined extension to volumes
50 
51  TGeoNode(const TGeoNode&);
52  TGeoNode& operator=(const TGeoNode&);
53 
54 public:
55  enum {
58  kGeoNodeVC = BIT(16),
61  };
62 
63  // constructors
64  TGeoNode();
65  TGeoNode(const TGeoVolume *vol);
66  // destructor
67  virtual ~TGeoNode();
68 
69  void Browse(TBrowser *b);
70  virtual void cd() const {;}
71  void CheckOverlaps(Double_t ovlp=0.1, Option_t *option=""); // *MENU*
72  void CheckShapes();
73  Int_t CountDaughters(Bool_t unique_volumes=kFALSE);
74  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
75  void Draw(Option_t *option="");
76  void DrawOnly(Option_t *option="");
77  void DrawOverlaps();
78  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
79  void FillIdArray(Int_t &ifree, Int_t &nodeid, Int_t *array) const;
80  Int_t FindNode(const TGeoNode *node, Int_t level);
81  virtual Int_t GetByteCount() const {return 44;}
82  TGeoNode *GetDaughter(Int_t ind) const {return fVolume->GetNode(ind);}
83  virtual TGeoMatrix *GetMatrix() const = 0;
84 
85  Int_t GetColour() const {return fVolume->GetLineColor();}
86  virtual Int_t GetIndex() const {return 0;}
87  virtual TGeoPatternFinder *GetFinder() const {return 0;}
88  TGeoMedium *GetMedium() const {return fVolume->GetMedium();}
89  TGeoVolume *GetMotherVolume() const {return fMother;}
90  Int_t GetNdaughters() const {return fVolume->GetNdaughters();}
91  TObjArray *GetNodes() const {return fVolume->GetNodes();}
92  Int_t GetNumber() const {return fNumber;}
93  Int_t *GetOverlaps(Int_t &novlp) const {novlp=fNovlp; return fOverlaps;}
94  TGeoVolume *GetVolume() const {return fVolume;}
95  virtual char *GetObjectInfo(Int_t px, Int_t py) const;
96  virtual Int_t GetOptimalVoxels() const {return 0;}
97  void InspectNode() const; // *MENU*
99  virtual Bool_t IsFolder() const {return (GetNdaughters()?kTRUE:kFALSE);}
101  Bool_t IsOnScreen() const; // *MENU*
104  Bool_t IsVisible() const {return (TGeoAtt::IsVisible() && fVolume->IsVisible());}
105  Bool_t IsVisDaughters() const {return (TGeoAtt::IsVisDaughters() && fVolume->IsVisDaughters());}
106  Bool_t MayOverlap(Int_t iother) const;
107 
108  virtual TGeoNode *MakeCopyNode() const {return 0;}
109  Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const;
110  void SaveAttributes(std::ostream &out);
111  void SetCurrentPoint(Double_t x, Double_t y, Double_t z) {fVolume->SetCurrentPoint(x,y,z);}// *MENU*
112  void SetVolume(TGeoVolume *volume) {fVolume = volume;}
113  void SetNumber(Int_t number) {fNumber=number;}
117  void SetVisibility(Bool_t vis=kTRUE); // *MENU*
118  void SetInvisible() {SetVisibility(kFALSE);} // *MENU*
120  void SetMotherVolume(TGeoVolume *mother) {fMother = mother;}
121  void SetOverlaps(Int_t *ovlp, Int_t novlp);
122  void SetUserExtension(TGeoExtension *ext);
123  void SetFWExtension(TGeoExtension *ext);
128 
129  virtual void MasterToLocal(const Double_t *master, Double_t *local) const;
130  virtual void MasterToLocalVect(const Double_t *master, Double_t *local) const;
131  virtual void LocalToMaster(const Double_t *local, Double_t *master) const;
132  virtual void LocalToMasterVect(const Double_t *local, Double_t *master) const;
133 
134  virtual void ls(Option_t *option = "") const;
135  virtual void Paint(Option_t *option = "");
136  void PrintCandidates() const; // *MENU*
137  void PrintOverlaps() const; // *MENU*
138  void VisibleDaughters(Bool_t vis=kTRUE); // *MENU*
139 
140  ClassDef(TGeoNode, 2) // base class for all geometry nodes
141 };
142 
143 ////////////////////////////////////////////////////////////////////////////
144 // //
145 // TGeoNodeMatrix - node containing a general transformation //
146 // //
147 ////////////////////////////////////////////////////////////////////////////
148 
149 class TGeoNodeMatrix : public TGeoNode
150 {
151 private:
152  TGeoMatrix *fMatrix = nullptr; // transf. matrix of fNode in fMother system
153 
154 protected:
155  TGeoNodeMatrix(const TGeoNodeMatrix& gnm);
157 
158 public:
159  // constructors
160  TGeoNodeMatrix();
161  TGeoNodeMatrix(const TGeoVolume *vol, const TGeoMatrix *matrix);
162  // destructor
163  virtual ~TGeoNodeMatrix();
164 
165  virtual Int_t GetByteCount() const;
166  virtual Int_t GetOptimalVoxels() const;
167  virtual Bool_t IsFolder() const {return kTRUE;}
168  virtual TGeoMatrix *GetMatrix() const {return fMatrix;}
169  virtual TGeoNode *MakeCopyNode() const;
170  void SetMatrix(const TGeoMatrix *matrix);
171 
172  ClassDef(TGeoNodeMatrix, 1) // a geometry node in the general case
173 };
174 
175 ////////////////////////////////////////////////////////////////////////////
176 // //
177 // TGeoNodeOffset - node containing only an translation offset //
178 // //
179 ////////////////////////////////////////////////////////////////////////////
180 
181 class TGeoNodeOffset : public TGeoNode
182 {
183 private:
184  Double_t fOffset = 0.; // X offset for this node with respect to its mother
185  Int_t fIndex = 0; // index of this node in the division
186  TGeoPatternFinder *fFinder = nullptr; // finder for this node
187 
188 protected:
191 
192 public:
193  // constructors
194  TGeoNodeOffset();
195  TGeoNodeOffset(const TGeoVolume *vol, Int_t index, Double_t offset);
196  // destructor
197  virtual ~TGeoNodeOffset();
198 
199  virtual void cd() const {fFinder->cd(fIndex);}
200  Double_t GetOffset() const {return fOffset;}
201  virtual Int_t GetIndex() const;
202  virtual TGeoPatternFinder *GetFinder() const {return fFinder;}
203  virtual TGeoMatrix *GetMatrix() const {cd(); return fFinder->GetMatrix();}
204  virtual TGeoNode *MakeCopyNode() const;
205  void SetFinder(TGeoPatternFinder *finder) {fFinder = finder;}
206 
207  ClassDef(TGeoNodeOffset, 1) // a geometry node with just an offset
208 };
209 
210 ////////////////////////////////////////////////////////////////////////////
211 // //
212 // TGeoIteratorPlugin - Plugin for a TGeoIterator providing the method //
213 // ProcessNode each time Next is called. //
214 // //
215 ////////////////////////////////////////////////////////////////////////////
216 
217 class TGeoIterator;
218 
220 {
221 protected:
222  const TGeoIterator *fIterator = nullptr; // Caller iterator
223 private:
224  // No copy
227 public:
228  TGeoIteratorPlugin() : TObject(),fIterator(0) {}
229  virtual ~TGeoIteratorPlugin() {}
230 
231  virtual void ProcessNode() = 0;
232  void SetIterator(const TGeoIterator *iter) {fIterator = iter;}
233 
234  ClassDef(TGeoIteratorPlugin, 0) // ABC for user plugins connecter to a geometry iterator.
235 };
236 
237 ////////////////////////////////////////////////////////////////////////////
238 // //
239 // TGeoIterator - iterator for the node tree //
240 // //
241 ////////////////////////////////////////////////////////////////////////////
242 
244 {
245 private:
246  TGeoVolume *fTop = nullptr; // Top volume of the iterated branch
247  Bool_t fMustResume = kFALSE; // Private flag to resume from current node.
248  Bool_t fMustStop = kFALSE; // Private flag to signal that the iterator has finished.
249  Int_t fLevel = 0; // Current level in the tree
250  Int_t fType = 0; // Type of iteration
251  Int_t *fArray = nullptr; // Array of node indices for the current path
252  TGeoHMatrix *fMatrix = nullptr; // Current global matrix
253  TString fTopName; // User name for top
255  *fPlugin = nullptr; // User iterator plugin
256  Bool_t fPluginAutoexec = kFALSE; // Plugin automatically executed during next()
257 
258  void IncreaseArray();
259 protected:
260  TGeoIterator() : fTop(0), fMustResume(0), fMustStop(0), fLevel(0), fType(0),
261  fArray(0), fMatrix(0), fTopName(), fPlugin(0), fPluginAutoexec(kFALSE) { }
262 
263 public:
264  TGeoIterator(TGeoVolume *top);
265  TGeoIterator(const TGeoIterator &iter);
266  virtual ~TGeoIterator();
267 
268  TGeoIterator &operator=(const TGeoIterator &iter);
269  TGeoNode *operator()();
270  TGeoNode *Next();
271 
272  const TGeoMatrix *GetCurrentMatrix() const;
273  Int_t GetIndex(Int_t i) const {return ((i<=fLevel)?fArray[i]:-1);}
274  Int_t GetLevel() const {return fLevel;}
275  TGeoNode *GetNode(Int_t level) const;
276  void GetPath(TString &path) const;
278  *GetUserPlugin() const {return fPlugin;}
279 
280  TGeoVolume *GetTopVolume() const {return fTop;}
281  Int_t GetType() const {return fType;}
282  void Reset(TGeoVolume *top=0);
283  void SetUserPlugin(TGeoIteratorPlugin *plugin);
284  void SetPluginAutoexec(Bool_t mode) {fPluginAutoexec = mode;}
285  void SetType(Int_t type) {fType = type;}
286  void SetTopName(const char* name);
287  void Skip();
288 
289  ClassDef(TGeoIterator,0) //Iterator for geometry.
290 };
291 
292 #endif
virtual void ls(Option_t *option="") const
Print the path (A/B/C/...) to this node on stdout.
Definition: TGeoNode.cxx:585
Bool_t IsVisible() const
Definition: TGeoAtt.h:88
TGeoVolume * fMother
Definition: TGeoNode.h:44
A node containing local transformation.
Definition: TGeoNode.h:149
Int_t fNovlp
Definition: TGeoNode.h:46
An array of TObjects.
Definition: TObjArray.h:37
virtual void LocalToMasterVect(const Double_t *local, Double_t *master) const
Convert a vector from local reference system to mother reference.
Definition: TGeoNode.cxx:577
TGeoExtension * GetFWExtension() const
Definition: TGeoNode.h:125
void DrawOnly(Option_t *option="")
draw only this node independently of its vis options
Definition: TGeoNode.cxx:349
Int_t fNumber
Definition: TGeoNode.h:45
TGeoNode()
Default constructor.
Definition: TGeoNode.cxx:95
virtual TGeoNode * MakeCopyNode() const
Definition: TGeoNode.h:108
virtual ~TGeoIteratorPlugin()
Definition: TGeoNode.h:229
Bool_t IsOverlapping() const
Definition: TGeoNode.h:102
void SetVirtual()
Definition: TGeoNode.h:116
const char Option_t
Definition: RtypesCore.h:62
Geometrical transformation package.
Definition: TGeoMatrix.h:40
Visualization and tracking attributes for volumes and nodes.
Definition: TGeoAtt.h:17
virtual void cd() const
Definition: TGeoNode.h:70
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
#define BIT(n)
Definition: Rtypes.h:78
virtual void MasterToLocalVect(const Double_t *master, Double_t *local) const
Convert a vector from mother reference to local reference system.
Definition: TGeoNode.cxx:561
Double_t GetOffset() const
Definition: TGeoNode.h:200
virtual TGeoPatternFinder * GetFinder() const
Definition: TGeoNode.h:87
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
void SetCurrentPoint(Double_t x, Double_t y, Double_t z)
Definition: TGeoNode.h:111
Int_t FindNode(const TGeoNode *node, Int_t level)
Search for a node within the branch of this one.
Definition: TGeoNode.cxx:412
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Get node info for the browser.
Definition: TGeoNode.cxx:297
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
Basic string class.
Definition: TString.h:125
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:420
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Paint(Option_t *option="")
Paint this node and its content according to visualization settings.
Definition: TGeoNode.cxx:592
Bool_t IsOffset() const
Definition: TGeoNode.h:100
TRObject operator()(const T1 &t1) const
void VisibleDaughters(Bool_t vis=kTRUE)
Set visibility of the daughters (obsolete).
Definition: TGeoNode.cxx:696
virtual TGeoPatternFinder * GetFinder() const
Definition: TGeoNode.h:202
TGeoVolume * GetMotherVolume() const
Definition: TGeoNode.h:89
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
Int_t GetType() const
Definition: TGeoNode.h:281
virtual void cd() const
Definition: TGeoNode.h:199
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute mouse actions on this volume.
Definition: TGeoNode.cxx:286
TObjArray * GetNodes()
Definition: TGeoVolume.h:170
Int_t GetNdaughters() const
Definition: TGeoVolume.h:350
void SetUserExtension(TGeoExtension *ext)
Connect user-defined extension to the node.
Definition: TGeoNode.cxx:496
TGeoExtension * fUserExtension
Definition: TGeoNode.h:48
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
TString fTopName
Definition: TGeoNode.h:253
Int_t GetLevel() const
Definition: TGeoNode.h:274
void PrintOverlaps() const
print possible overlapping nodes
Definition: TGeoNode.cxx:651
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
A geometry iterator.
Definition: TGeoNode.h:243
virtual TGeoMatrix * GetMatrix() const
Definition: TGeoNode.h:203
void InspectNode() const
Inspect this node.
Definition: TGeoNode.cxx:317
void SetFWExtension(TGeoExtension *ext)
Connect framework defined extension to the node.
Definition: TGeoNode.cxx:511
Bool_t IsOnScreen() const
check if this node is drawn. Assumes that this node is current
Definition: TGeoNode.cxx:308
TGeoMedium * GetMedium() const
Definition: TGeoVolume.h:176
virtual Bool_t IsVisible() const
Definition: TGeoVolume.h:156
TGeoExtension * GetUserExtension() const
Definition: TGeoNode.h:124
virtual TGeoMatrix * GetMatrix() const =0
Int_t GetColour() const
Definition: TGeoNode.h:85
Bool_t IsCloned() const
Definition: TGeoNode.h:98
void Browse(TBrowser *b)
How-to-browse for a node.
Definition: TGeoNode.cxx:174
Base finder class for patterns.
TGeoMedium * GetMedium() const
Definition: TGeoNode.h:88
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
Int_t GetNumber() const
Definition: TGeoNode.h:92
Int_t GetIndex(Int_t i) const
Definition: TGeoNode.h:273
void DrawOverlaps()
Method drawing the overlap candidates with this node.
Definition: TGeoNode.cxx:370
void SetType(Int_t type)
Definition: TGeoNode.h:285
Base abstract class for all shapes.
Definition: TGeoShape.h:25
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition: TGeoNode.cxx:214
void SetMotherVolume(TGeoVolume *mother)
Definition: TGeoNode.h:120
TGeoNode * GetDaughter(Int_t ind) const
Definition: TGeoNode.h:82
TGeoVolume * fVolume
Definition: TGeoNode.h:43
void SaveAttributes(std::ostream &out)
save attributes for this node
Definition: TGeoNode.cxx:439
void SetInvisible()
Definition: TGeoNode.h:118
void Draw(Option_t *option="")
draw current node according to option
Definition: TGeoNode.cxx:357
ABC for user objects attached to TGeoVolume or TGeoNode.
Definition: TGeoExtension.h:19
void PrintCandidates() const
print daughters candidates for containing current point
Definition: TGeoNode.cxx:602
TGeoExtension * fFWExtension
Transient user-defined extension to volumes.
Definition: TGeoNode.h:49
Bool_t IsVisDaughters() const
Definition: TGeoNode.h:105
Bool_t IsVirtual() const
Definition: TGeoNode.h:103
void SetIterator(const TGeoIterator *iter)
Definition: TGeoNode.h:232
void Reset(Detail::TBranchProxy *x)
Int_t CountDaughters(Bool_t unique_volumes=kFALSE)
Returns the number of daughters.
Definition: TGeoNode.cxx:190
virtual void MasterToLocal(const Double_t *master, Double_t *local) const
Convert the point coordinates from mother reference to local reference system.
Definition: TGeoNode.cxx:553
const Bool_t kFALSE
Definition: RtypesCore.h:88
PyObject * fType
void SetFinder(TGeoPatternFinder *finder)
Definition: TGeoNode.h:205
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
void SetCloned(Bool_t flag=kTRUE)
Definition: TGeoNode.h:114
void SetOverlapping(Bool_t flag=kTRUE)
Definition: TGeoNode.h:115
void SetPluginAutoexec(Bool_t mode)
Definition: TGeoNode.h:284
double Double_t
Definition: RtypesCore.h:55
TObjArray * GetNodes() const
Definition: TGeoNode.h:91
virtual TGeoMatrix * GetMatrix()
Return current matrix.
int type
Definition: TGX11.cxx:120
TGeoExtension * GrabFWExtension() const
Get a copy of the framework extension pointer.
Definition: TGeoNode.cxx:534
Int_t * fOverlaps
Definition: TGeoNode.h:47
Double_t y[n]
Definition: legend1.C:17
Node containing an offset.
Definition: TGeoNode.h:181
TGeoIteratorPlugin * GetUserPlugin() const
Definition: TGeoNode.h:278
void FillIdArray(Int_t &ifree, Int_t &nodeid, Int_t *array) const
Fill array with node id. Recursive on node branch.
Definition: TGeoNode.cxx:393
void SetAllInvisible()
Definition: TGeoNode.h:119
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:23
void SetVolume(TGeoVolume *volume)
Definition: TGeoNode.h:112
TGeoNode & operator=(const TGeoNode &)
assignment operator
Definition: TGeoNode.cxx:145
Mother of all ROOT objects.
Definition: TObject.h:37
virtual ~TGeoNode()
Destructor.
Definition: TGeoNode.cxx:164
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Bool_t MayOverlap(Int_t iother) const
Check the overlab between the bounding box of the node overlaps with the one the brother with index I...
Definition: TGeoNode.cxx:543
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:39
void CheckShapes()
check for wrong parameters in shapes
Definition: TGeoNode.cxx:338
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
compute the closest distance of approach from point px,py to this node
Definition: TGeoNode.cxx:272
Bool_t IsVisDaughters() const
Definition: TGeoAtt.h:89
TGeoExtension * GrabUserExtension() const
Get a copy of the user extension pointer.
Definition: TGeoNode.cxx:523
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
computes the closest distance from given point to this shape
Definition: TGeoNode.cxx:665
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
Convert the point coordinates from local reference system to mother reference.
Definition: TGeoNode.cxx:569
Int_t * GetOverlaps(Int_t &novlp) const
Definition: TGeoNode.h:93
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Int_t GetNdaughters() const
Definition: TGeoNode.h:90
void SetCurrentPoint(Double_t x, Double_t y, Double_t z)
Set the current tracking point.
virtual Int_t GetByteCount() const
Definition: TGeoNode.h:81
virtual void cd(Int_t)
void SetVisibility(Bool_t vis=kTRUE)
Set visibility of the node (obsolete).
Definition: TGeoNode.cxx:685
virtual Int_t GetIndex() const
Definition: TGeoNode.h:86
virtual TGeoMatrix * GetMatrix() const
Definition: TGeoNode.h:168
const Bool_t kTRUE
Definition: RtypesCore.h:87
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:94
virtual Int_t GetOptimalVoxels() const
Definition: TGeoNode.h:96
char name[80]
Definition: TGX11.cxx:109
void SetOverlaps(Int_t *ovlp, Int_t novlp)
set the list of overlaps for this node (ovlp must be created with operator new)
Definition: TGeoNode.cxx:675
void SetNumber(Int_t number)
Definition: TGeoNode.h:113
TGeoVolume * GetTopVolume() const
Definition: TGeoNode.h:280
Bool_t IsVisible() const
Definition: TGeoNode.h:104
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TGeoNode.h:99
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TGeoNode.h:167