Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoBranchArray.h
Go to the documentation of this file.
1// @(#):$Id$
2// Author: Andrei Gheata 01/03/11
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_TGeoBranchArray
13#define ROOT_TGeoBranchArray
14
15#include "TObject.h"
16
17#include "TGeoMatrix.h"
18
19class TGeoNavigator;
20class TGeoNode;
21
22class TGeoBranchArray : public TObject {
23protected:
24 Int_t fLevel; // Branch depth
25 Int_t fMaxLevel; // Array length
26 TGeoHMatrix fMatrix; // Global matrix (owned)
27 TGeoNode **fArray; //![fMaxLevel+1] Array of nodes
28 TGeoNode *fRealArray[1]; // Beginning address of the array of nodes
29
30private:
31 TGeoBranchArray(Int_t level); // not allowed
32 TGeoBranchArray(const TGeoBranchArray &); // not allowed
33public:
35 kBASelfAlloc = BIT(14) // does self allocation or not
36 };
37 // This replaces the dummy constructor to make sure that I/O can be
38 // performed while the user is only allowed to use the static maker
40 {
41 fRealArray[0] = nullptr;
42 }
43
44 // The static maker to be use to create an instance of the branch array
45 static TGeoBranchArray *MakeInstance(size_t maxlevel);
46
47 // The static maker to be use to create an instance of the branch array
48 static TGeoBranchArray *MakeInstanceAt(size_t maxlevel, void *addr);
49
50 // The equivalent of the copy constructor
51 static TGeoBranchArray *MakeCopy(const TGeoBranchArray &other);
52
53 // The equivalent of the copy constructor
54 static TGeoBranchArray *MakeCopyAt(const TGeoBranchArray &other, void *addr);
55
56 // The equivalent of the destructor
57 static void ReleaseInstance(TGeoBranchArray *obj);
58
59 // Assignment allowed
61
62 // Fast copy based on memcpy to destination array
64
65 // Equivalent of sizeof function
66 static size_t SizeOf(size_t maxlevel) { return (sizeof(TGeoBranchArray) + sizeof(TGeoBranchArray *) * (maxlevel)); }
67
68 // Equivalent of sizeof function
69 static size_t SizeOfInstance(size_t maxlevel)
70 {
71 return (sizeof(TGeoBranchArray) + sizeof(TGeoBranchArray *) * (maxlevel));
72 }
73
74 inline size_t SizeOf() const { return (sizeof(TGeoBranchArray) + sizeof(TGeoBranchArray *) * (fMaxLevel)); }
75
76 // The data start should point to the address of the first data member,
77 // after the virtual table
78 void *DataStart() const { return (void *)&fLevel; }
79
80 // The actual size of the data for an instance, excluding the virtual table
81 size_t DataSize() const { return SizeOf() - size_t(&fLevel) + (size_t)this; }
82
83 // Update the internal addresses of n contiguous branch array objects, starting
84 // with this one
85 void UpdateArray(size_t nobj);
86
87 // Destructor. Release instance to be called instead
88 ~TGeoBranchArray() override {}
89
90 Bool_t operator==(const TGeoBranchArray &other) const;
91 Bool_t operator!=(const TGeoBranchArray &other) const;
92 Bool_t operator>(const TGeoBranchArray &other) const;
93 Bool_t operator<(const TGeoBranchArray &other) const;
94 Bool_t operator>=(const TGeoBranchArray &other) const;
95 Bool_t operator<=(const TGeoBranchArray &other) const;
96
97 void AddLevel(Int_t dindex);
99 Int_t Compare(const TObject *obj) const override;
100 void CleanMatrix();
101 TGeoNode **GetArray() const { return fArray; }
102 size_t GetLevel() const { return fLevel; }
103 size_t GetMaxLevel() const { return fMaxLevel; }
104 const TGeoHMatrix *GetMatrix() const { return &fMatrix; }
105 TGeoNode *GetNode(Int_t level) const { return fArray[level]; }
106 TGeoNode *GetCurrentNode() const { return fArray[fLevel]; }
107 void GetPath(TString &path) const;
108 void Init(TGeoNode **branch, TGeoMatrix *global, Int_t level);
110 Bool_t IsSortable() const override { return kTRUE; }
111 Bool_t IsOutside() const { return (fLevel < 0) ? kTRUE : kFALSE; }
112 void Print(Option_t *option = "") const override;
113 static void Sort(Int_t n, TGeoBranchArray **array, Int_t *index, Bool_t down = kTRUE);
114 void UpdateNavigator(TGeoNavigator *nav) const;
115
117};
118
121 bool operator()(Int_t i1, Int_t i2) { return **(fData + i1) < **(fData + i2); }
123};
124
127 bool operator()(Int_t i1, Int_t i2) { return **(fData + i1) > **(fData + i2); }
129};
130
131#endif
#define d(i)
Definition RSha256.hxx:102
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
An array of daughter indices making a geometry path.
static void ReleaseInstance(TGeoBranchArray *obj)
Releases the space allocated for the object.
void * DataStart() const
const TGeoHMatrix * GetMatrix() const
TGeoNode ** GetArray() const
TGeoBranchArray & operator=(const TGeoBranchArray &)
Assignment. Not valid anymore. Use TGeoBranchArray::MakeCopy instead.
size_t SizeOf() const
static TGeoBranchArray * MakeCopyAt(const TGeoBranchArray &other, void *addr)
Make a copy of a branch array at the location (if indicated)
static TGeoBranchArray * MakeCopy(const TGeoBranchArray &other)
Make a copy of a branch array at the location (if indicated)
void Init(TGeoNode **branch, TGeoMatrix *global, Int_t level)
Init the branch array from an array of nodes, the global matrix for the path and the level.
static size_t SizeOf(size_t maxlevel)
void GetPath(TString &path) const
Fill path pointed by the array.
~TGeoBranchArray() override
TGeoNode * GetCurrentNode() const
void CleanMatrix()
Garbage collect the stored matrix.
static size_t SizeOfInstance(size_t maxlevel)
Bool_t operator!=(const TGeoBranchArray &other) const
Not equal operator.
static TGeoBranchArray * MakeInstanceAt(size_t maxlevel, void *addr)
Make an instance of the class which allocates the node array.
Bool_t operator<(const TGeoBranchArray &other) const
Is equal operator.
size_t DataSize() const
Bool_t IsSortable() const override
void CopyTo(TGeoBranchArray *dest)
Raw memcpy of the branch array content to an existing destination.
Bool_t IsOutside() const
TGeoNode * fRealArray[1]
[fMaxLevel+1] Array of nodes
Bool_t operator>(const TGeoBranchArray &other) const
Is equal operator.
void UpdateArray(size_t nobj)
Updates the internal addresses for n contiguous objects which have the same fMaxLevel Updates the int...
void UpdateNavigator(TGeoNavigator *nav) const
Update the navigator to reflect the branch.
TGeoNode * GetNode(Int_t level) const
Bool_t operator>=(const TGeoBranchArray &other) const
Is equal operator.
TGeoBranchArray(TRootIOCtor *)
static TGeoBranchArray * MakeInstance(size_t maxlevel)
Make an instance of the class which allocates the node array.
Bool_t operator<=(const TGeoBranchArray &other) const
Is equal operator.
static void Sort(Int_t n, TGeoBranchArray **array, Int_t *index, Bool_t down=kTRUE)
Sorting of an array of branch array pointers.
TGeoNode ** fArray
void AddLevel(Int_t dindex)
Add and extra daughter to the current path array. No validity check performed !
void InitFromNavigator(TGeoNavigator *nav)
Init the branch array from current navigator state.
Bool_t operator==(const TGeoBranchArray &other) const
Is equal operator.
static Long64_t BinarySearch(Long64_t n, const TGeoBranchArray **array, TGeoBranchArray *value)
Binary search in an array of n pointers to branch arrays, to locate value.
size_t GetLevel() const
TGeoHMatrix fMatrix
Int_t Compare(const TObject *obj) const override
Compare with other object of same type.
void Print(Option_t *option="") const override
Print branch information.
size_t GetMaxLevel() const
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition TGeoMatrix.h:458
Geometrical transformation package.
Definition TGeoMatrix.h:38
Class providing navigation API for TGeo geometries.
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
const Int_t n
Definition legend1.C:16
TGeoBranchArray ** fData
compareBAasc(TGeoBranchArray **d)
bool operator()(Int_t i1, Int_t i2)
compareBAdesc(TGeoBranchArray **d)
TGeoBranchArray ** fData
bool operator()(Int_t i1, Int_t i2)