Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoIterator Class Reference

A geometry iterator.

A geometry iterator that sequentially follows all nodes of the geometrical hierarchy of a volume. The iterator has to be initiated with a top volume pointer:

TGeoIterator next(myVolume);
A geometry iterator.
Definition TGeoNode.h:248

One can use the iterator as any other in ROOT:

TGeoNode *node;
while ((node=next())) {
...
}
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39

The iterator can perform 2 types of iterations that can be selected via:

next.SetType(Int_t type);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type

Here TYPE can be:

  • 0 (default) - 'first daughter next' behavior
  • 1 - iteration at the current level only

Supposing the tree structure looks like:

TOP ___ A_1 ___ A1_1 ___ A11_1
| | |___ A12_1
| |_____A2_1 ___ A21_1
| |___ A21_2
|___ B_1 ...

The order of iteration for TYPE=0 is: A_1, A1_1, A11_1, A12_1, A2_1, A21_1, A21_2, B_1, ...

The order of iteration for TYPE=1 is: A_1, B_1, ... At any moment during iteration, TYPE can be changed. If the last iterated node is for instance A1_1 and the iteration type was 0, one can do:

next.SetType(1);

The next iterated nodes will be the rest of A daughters: A2,A3,... The iterator will return 0 after finishing all daughters of A.

During iteration, the following can be retrieved:

The iterator can be reset by changing (or not) the top volume:

void Reset(TGeoVolume *top=nullptr)
Resets the iterator for volume TOP.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43

Example:

We want to find out a volume named "MyVol" in the hierarchy of TOP volume.

TIter next(TOP);
TGeoNode *node;
TString name("MyVol");
while ((node=next()))
if (name == node->GetVolume()->GetName()) return node->GetVolume();
char name[80]
Definition TGX11.cxx:110
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Basic string class.
Definition TString.h:139

Definition at line 248 of file TGeoNode.h.

Public Member Functions

 TGeoIterator (const TGeoIterator &iter)
 Copy ctor.
 
 TGeoIterator (TGeoVolume *top)
 Geometry iterator for a branch starting with a TOP node.
 
virtual ~TGeoIterator ()
 Destructor.
 
const TGeoMatrixGetCurrentMatrix () const
 Returns global matrix for current node.
 
Int_t GetIndex (Int_t i) const
 
Int_t GetLevel () const
 
TGeoNodeGetNode (Int_t level) const
 Returns current node at a given level.
 
void GetPath (TString &path) const
 Returns the path for the current node.
 
TGeoVolumeGetTopVolume () const
 
Int_t GetType () const
 
TGeoIteratorPluginGetUserPlugin () const
 
virtual TClassIsA () const
 
TGeoNodeNext ()
 Returns next node.
 
TGeoNodeoperator() ()
 Returns next node.
 
TGeoIteratoroperator= (const TGeoIterator &iter)
 Assignment.
 
void Reset (TGeoVolume *top=nullptr)
 Resets the iterator for volume TOP.
 
void SetPluginAutoexec (Bool_t mode)
 
void SetTopName (const char *name)
 Set the top name for path.
 
void SetType (Int_t type)
 
void SetUserPlugin (TGeoIteratorPlugin *plugin)
 Set a plugin.
 
void Skip ()
 Stop iterating the current branch.
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
void Up ()
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Protected Member Functions

 TGeoIterator ()
 

Private Member Functions

void IncreaseArray ()
 Increase by 30 the size of the array.
 

Private Attributes

Int_tfArray = nullptr
 
Int_t fLevel = 0
 
TGeoHMatrixfMatrix = nullptr
 
Bool_t fMustResume = kFALSE
 
Bool_t fMustStop = kFALSE
 
TGeoIteratorPluginfPlugin = nullptr
 
Bool_t fPluginAutoexec = kFALSE
 
TGeoVolumefTop = nullptr
 
TString fTopName
 
Int_t fType = 0
 

#include <TGeoNode.h>

Constructor & Destructor Documentation

◆ TGeoIterator() [1/3]

TGeoIterator::TGeoIterator ( )
inlineprotected

Definition at line 264 of file TGeoNode.h.

◆ TGeoIterator() [2/3]

TGeoIterator::TGeoIterator ( TGeoVolume top)

Geometry iterator for a branch starting with a TOP node.

Definition at line 991 of file TGeoNode.cxx.

◆ TGeoIterator() [3/3]

TGeoIterator::TGeoIterator ( const TGeoIterator iter)

Copy ctor.

Definition at line 1008 of file TGeoNode.cxx.

◆ ~TGeoIterator()

TGeoIterator::~TGeoIterator ( )
virtual

Destructor.

Definition at line 1028 of file TGeoNode.cxx.

Member Function Documentation

◆ Class()

static TClass * TGeoIterator::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TGeoIterator::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TGeoIterator::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 308 of file TGeoNode.h.

◆ DeclFileName()

static const char * TGeoIterator::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 308 of file TGeoNode.h.

◆ GetCurrentMatrix()

const TGeoMatrix * TGeoIterator::GetCurrentMatrix ( ) const

Returns global matrix for current node.

Definition at line 1163 of file TGeoNode.cxx.

◆ GetIndex()

Int_t TGeoIterator::GetIndex ( Int_t  i) const
inline

Definition at line 293 of file TGeoNode.h.

◆ GetLevel()

Int_t TGeoIterator::GetLevel ( ) const
inline

Definition at line 294 of file TGeoNode.h.

◆ GetNode()

TGeoNode * TGeoIterator::GetNode ( Int_t  level) const

Returns current node at a given level.

Definition at line 1180 of file TGeoNode.cxx.

◆ GetPath()

void TGeoIterator::GetPath ( TString path) const

Returns the path for the current node.

Definition at line 1193 of file TGeoNode.cxx.

◆ GetTopVolume()

TGeoVolume * TGeoIterator::GetTopVolume ( ) const
inline

Definition at line 299 of file TGeoNode.h.

◆ GetType()

Int_t TGeoIterator::GetType ( ) const
inline

Definition at line 300 of file TGeoNode.h.

◆ GetUserPlugin()

TGeoIteratorPlugin * TGeoIterator::GetUserPlugin ( ) const
inline

Definition at line 297 of file TGeoNode.h.

◆ IncreaseArray()

void TGeoIterator::IncreaseArray ( )
private

Increase by 30 the size of the array.

Definition at line 1211 of file TGeoNode.cxx.

◆ IsA()

virtual TClass * TGeoIterator::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 308 of file TGeoNode.h.

◆ Next()

TGeoNode * TGeoIterator::Next ( )

Returns next node.

Definition at line 1065 of file TGeoNode.cxx.

◆ operator()()

TGeoNode * TGeoIterator::operator() ( )

Returns next node.

Definition at line 1155 of file TGeoNode.cxx.

◆ operator=()

TGeoIterator & TGeoIterator::operator= ( const TGeoIterator iter)

Assignment.

Definition at line 1038 of file TGeoNode.cxx.

◆ Reset()

void TGeoIterator::Reset ( TGeoVolume top = nullptr)

Resets the iterator for volume TOP.

Definition at line 1222 of file TGeoNode.cxx.

◆ SetPluginAutoexec()

void TGeoIterator::SetPluginAutoexec ( Bool_t  mode)
inline

Definition at line 303 of file TGeoNode.h.

◆ SetTopName()

void TGeoIterator::SetTopName ( const char *  name)

Set the top name for path.

Definition at line 1234 of file TGeoNode.cxx.

◆ SetType()

void TGeoIterator::SetType ( Int_t  type)
inline

Definition at line 304 of file TGeoNode.h.

◆ SetUserPlugin()

void TGeoIterator::SetUserPlugin ( TGeoIteratorPlugin plugin)

Set a plugin.

Definition at line 1282 of file TGeoNode.cxx.

◆ Skip()

void TGeoIterator::Skip ( )

Stop iterating the current branch.

The iteration of the next node will behave as if the branch starting from the current node (included) is not existing.

Definition at line 1243 of file TGeoNode.cxx.

◆ Streamer()

virtual void TGeoIterator::Streamer ( TBuffer )
virtual

◆ StreamerNVirtual()

void TGeoIterator::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 308 of file TGeoNode.h.

◆ Up()

void TGeoIterator::Up ( )
inline

Definition at line 286 of file TGeoNode.h.

Member Data Documentation

◆ fArray

Int_t* TGeoIterator::fArray = nullptr
private

Definition at line 255 of file TGeoNode.h.

◆ fLevel

Int_t TGeoIterator::fLevel = 0
private

Definition at line 253 of file TGeoNode.h.

◆ fMatrix

TGeoHMatrix* TGeoIterator::fMatrix = nullptr
private

Definition at line 256 of file TGeoNode.h.

◆ fMustResume

Bool_t TGeoIterator::fMustResume = kFALSE
private

Definition at line 251 of file TGeoNode.h.

◆ fMustStop

Bool_t TGeoIterator::fMustStop = kFALSE
private

Definition at line 252 of file TGeoNode.h.

◆ fPlugin

TGeoIteratorPlugin* TGeoIterator::fPlugin = nullptr
private

Definition at line 258 of file TGeoNode.h.

◆ fPluginAutoexec

Bool_t TGeoIterator::fPluginAutoexec = kFALSE
private

Definition at line 259 of file TGeoNode.h.

◆ fTop

TGeoVolume* TGeoIterator::fTop = nullptr
private

Definition at line 250 of file TGeoNode.h.

◆ fTopName

TString TGeoIterator::fTopName
private

Definition at line 257 of file TGeoNode.h.

◆ fType

Int_t TGeoIterator::fType = 0
private

Definition at line 254 of file TGeoNode.h.

Libraries for TGeoIterator:

The documentation for this class was generated from the following files: