Logo ROOT   6.16/01
Reference Guide
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
23{
24protected:
25 Int_t fLevel; // Branch depth
26 Int_t fMaxLevel; // Array length
27 TGeoHMatrix fMatrix; // Global matrix (owned)
28 TGeoNode **fArray; //![fMaxLevel+1] Array of nodes
29 TGeoNode *fRealArray[1]; // Beginning address of the array of nodes
30
31private:
32 TGeoBranchArray(Int_t level); // not allowed
33 TGeoBranchArray(const TGeoBranchArray&); // not allowed
34public:
36 kBASelfAlloc = BIT(14) // does self allocation or not
37 };
38 // This replaces the dummy constructor to make sure that I/O can be
39 // performed while the user is only allowed to use the static maker
41
42 // The static maker to be use to create an instance of the branch array
43 static TGeoBranchArray *MakeInstance(size_t maxlevel);
44
45 // The static maker to be use to create an instance of the branch array
46 static TGeoBranchArray *MakeInstanceAt(size_t maxlevel, void *addr);
47
48 // The equivalent of the copy constructor
49 static TGeoBranchArray *MakeCopy(const TGeoBranchArray &other);
50
51 // The equivalent of the copy constructor
52 static TGeoBranchArray *MakeCopyAt(const TGeoBranchArray &other, void *addr);
53
54 // The equivalent of the destructor
55 static void ReleaseInstance(TGeoBranchArray *obj);
56
57 // Assignment allowed
59
60 // Fast copy based on memcpy to destination array
62
63 // Equivalent of sizeof function
64 static size_t SizeOf(size_t maxlevel)
65 { return (sizeof(TGeoBranchArray)+sizeof(TGeoBranchArray*)*(maxlevel)); }
66
67 // Equivalent of sizeof function
68 static size_t SizeOfInstance(size_t maxlevel)
69 { return (sizeof(TGeoBranchArray)+sizeof(TGeoBranchArray*)*(maxlevel)); }
70
71 inline size_t SizeOf() const
72 { return (sizeof(TGeoBranchArray)+sizeof(TGeoBranchArray*)*(fMaxLevel)); }
73
74 // The data start should point to the address of the first data member,
75 // after the virtual table
76 void *DataStart() const {return (void*)&fLevel;}
77
78 // The actual size of the data for an instance, excluding the virtual table
79 size_t DataSize() const {return SizeOf()-size_t(&fLevel)+(size_t)this;}
80
81 // Update the internal addresses of n contiguous branch array objects, starting
82 // with this one
83 void UpdateArray(size_t nobj);
84
85 // Destructor. Release instance to be called instead
86 virtual ~TGeoBranchArray() {}
87
88 Bool_t operator ==(const TGeoBranchArray& other) const;
89 Bool_t operator !=(const TGeoBranchArray& other) const;
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
95 void AddLevel(Int_t dindex);
96 static Long64_t BinarySearch(Long64_t n, const TGeoBranchArray **array, TGeoBranchArray *value);
97 virtual Int_t Compare(const TObject *obj) const;
98 void CleanMatrix();
99 TGeoNode **GetArray() const {return fArray;}
100 size_t GetLevel() const {return fLevel;}
101 size_t GetMaxLevel() const {return fMaxLevel;}
102 const TGeoHMatrix
103 *GetMatrix() const {return &fMatrix;}
104 TGeoNode *GetNode(Int_t level) const {return fArray[level];}
106 void GetPath(TString &path) const;
107 void Init(TGeoNode **branch, TGeoMatrix *global, Int_t level);
109 virtual Bool_t IsSortable() const {return kTRUE;}
110 Bool_t IsOutside() const {return (fLevel<0)?kTRUE:kFALSE;}
111 virtual void Print(Option_t *option="") const;
112 static void Sort(Int_t n, TGeoBranchArray **array, Int_t *index, Bool_t down=kTRUE);
113 void UpdateNavigator(TGeoNavigator *nav) const;
114
116};
117
120 bool operator ()(Int_t i1, Int_t i2) {return **(fData+i1) < **(fData+i2);}
122};
123
126 bool operator ()(Int_t i1, Int_t i2) {return **(fData+i1) > **(fData+i2);}
128};
129
130#endif
#define d(i)
Definition: RSha256.hxx:102
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
#define BIT(n)
Definition: Rtypes.h:82
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)
virtual ~TGeoBranchArray()
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.
TGeoNode * GetCurrentNode() const
void CleanMatrix()
Garbage collect the stored matrix.
virtual void Print(Option_t *option="") const
Print branch information.
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
TGeoBranchArray(Int_t level)
Constructor. Allocates the array with a size given by level.
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
virtual Int_t Compare(const TObject *obj) const
Compare with other object of same type.
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.
virtual Bool_t IsSortable() const
size_t GetLevel() const
TGeoHMatrix fMatrix
size_t GetMaxLevel() const
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition: TGeoMatrix.h:421
Geometrical transformation package.
Definition: TGeoMatrix.h:41
Class providing navigation API for TGeo geometries.
Definition: TGeoNavigator.h:34
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:41
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
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)
#define dest(otri, vertexptr)
Definition: triangle.c:1040