Logo ROOT   6.08/07
Reference Guide
TGeometry.h
Go to the documentation of this file.
1 // @(#)root/g3d:$Id$
2 // Author: Rene Brun 22/09/95
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_TGeometry
13 #define ROOT_TGeometry
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGeometry //
19 // //
20 // Structure for Matrices, Shapes and Nodes. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TNamed
25 #include "TNamed.h"
26 #endif
27 #ifndef ROOT_THashList
28 #include "THashList.h"
29 #endif
30 
31 const Int_t kMAXLEVELS = 20;
32 const Int_t kVectorSize = 3;
34 
35 class TNode;
36 class TBrowser;
37 class TMaterial;
38 class TRotMatrix;
39 class TShape;
40 class TObjArray;
41 
42 
43 class TGeometry : public TNamed {
44 
45 private:
46  THashList *fMaterials; //->Collection of materials
47  THashList *fMatrices; //->Collection of rotation matrices
48  THashList *fShapes; //->Collection of shapes
49  TList *fNodes; //->Collection of nodes
50  TRotMatrix *fMatrix; //!Pointers to current rotation matrices
51  TNode *fCurrentNode; //!Pointer to current node
52  TMaterial **fMaterialPointer; //!Pointers to materials
53  TRotMatrix **fMatrixPointer; //!Pointers to rotation matrices
54  TShape **fShapePointer; //!Pointers to shapes
55  Float_t fBomb; //Bomb factor for exploded geometry
57  Double_t fX; //!
58  Double_t fY; //! The global translation of the current node
59  Double_t fZ; //!
63 
64 protected:
65  TGeometry(const TGeometry&);
66  TGeometry& operator=(const TGeometry&);
67 
68 public:
69  TGeometry();
70  TGeometry(const char *name, const char *title);
71  virtual ~TGeometry();
72  virtual void Browse(TBrowser *b);
73  virtual void cd(const char *path=0);
74  virtual void Draw(Option_t *option="");
75  virtual TObject *FindObject(const char *name) const;
76  virtual TObject *FindObject(const TObject *obj) const;
77  Float_t GetBomb() const {return fBomb;}
78  Int_t GeomLevel() const {return fGeomLevel;}
79  THashList *GetListOfShapes() const {return fShapes;}
80  TList *GetListOfNodes() const {return fNodes;}
83  TNode *GetCurrentNode() const {return fCurrentNode;}
84  TMaterial *GetMaterial(const char *name) const;
85  TMaterial *GetMaterialByNumber(Int_t number) const;
86  TNode *GetNode(const char *name) const;
87  TShape *GetShape(const char *name) const;
88  TShape *GetShapeByNumber(Int_t number) const;
89  TRotMatrix *GetRotMatrix(const char *name) const;
90  TRotMatrix *GetRotMatrixByNumber(Int_t number) const;
95  Bool_t IsFolder() const {return kTRUE;}
96  virtual void Local2Master(Double_t *local, Double_t *master);
97  virtual void Local2Master(Float_t *local, Float_t *master);
98  virtual void ls(Option_t *option="rsn2") const;
99  virtual void Master2Local(Double_t *master, Double_t *local);
100  virtual void Master2Local(Float_t *master, Float_t *local);
101  virtual void Node(const char *name, const char *title, const char *shapename, Double_t x=0, Double_t y=0, Double_t z=0
102  , const char *matrixname="", Option_t *option="");
103  virtual Int_t PushLevel(){return fGeomLevel++;}
104  virtual Int_t PopLevel(){return fGeomLevel>0?fGeomLevel--:0;}
105  virtual void RecursiveRemove(TObject *obj);
106  virtual void SetBomb(Float_t bomb=1.4) {fBomb = bomb;}
107  virtual void SetCurrentNode(TNode *node) {fCurrentNode = node;}
108  virtual void SetGeomLevel(Int_t level=0){fGeomLevel=level;}
109  virtual void SetMatrix(TRotMatrix *matrix=0){fMatrix = matrix;}
110  virtual void SetPosition(TRotMatrix *matrix, Double_t x=0,Double_t y=0,Double_t z=0);
111  virtual void SetPosition(TRotMatrix *matrix, Float_t x,Float_t y,Float_t z);
112  virtual void SetPosition(Double_t x,Double_t y,Double_t z);
113  virtual void SetPosition(Float_t x,Float_t y,Float_t z);
114  virtual void UpdateMatrix(TNode *node);
115  virtual void UpdateTempMatrix(Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0);
116  virtual void UpdateTempMatrix(Double_t x, Double_t y, Double_t z, Double_t *matrix,Bool_t isReflection=kFALSE);
117 
118  static TObjArray *Get(const char *name);
119  static void UpdateTempMatrix(Double_t *dx1,Double_t *rmat1,
120  Double_t x, Double_t y, Double_t z, Double_t *matrix,
121  Double_t *dxnew, Double_t *rmatnew);
122 
123  ClassDef(TGeometry,2) //Structure for Matrices, Shapes and Nodes
124 };
125 
126 
128 {
129  return fMatrix;
130 }
132 {
133  *x = fX; *y = fY; *z = fZ; return GetCurrentMatrix();
134 }
136 {
137  *x = Float_t(fX); *y = Float_t(fY); *z = Float_t(fZ); return GetCurrentMatrix();
138 }
140 {
141  return fIsReflection[fGeomLevel];
142 }
144 {
145  fX = x; fY = y; fZ = z;
146 }
148 {
149  fX = x; fY = y; fZ = z;
150 }
152 {
153  SetMatrix(matrix);
154  SetPosition(x,y,z);
155 }
157 {
158  SetMatrix(matrix);
159  SetPosition(x,y,z);
160 }
161 
163 
164 #endif
virtual void Browse(TBrowser *b)
Browse.
Definition: TGeometry.cxx:233
TRotMatrix * GetCurrentPosition(Double_t *x, Double_t *y, Double_t *z) const
Definition: TGeometry.h:131
An array of TObjects.
Definition: TObjArray.h:39
TRotMatrix * GetRotMatrix(const char *name) const
Return pointer to RotMatrix with name.
Definition: TGeometry.cxx:356
THashList * fShapes
Definition: TGeometry.h:48
float Float_t
Definition: RtypesCore.h:53
Double_t fZ
The global translation of the current node.
Definition: TGeometry.h:59
const char Option_t
Definition: RtypesCore.h:62
THashList * fMaterials
Definition: TGeometry.h:46
virtual TObject * FindObject(const char *name) const
Search object identified by name in the geometry tree.
Definition: TGeometry.cxx:273
TRotMatrix * GetCurrentMatrix() const
Definition: TGeometry.h:127
Double_t fY
Definition: TGeometry.h:58
TMaterial ** fMaterialPointer
Pointer to current node.
Definition: TGeometry.h:52
const Int_t kMAXLEVELS
Definition: TGeometry.h:31
TNode description.
Definition: TNode.h:43
Double_t fRotMatrix[kMAXLEVELS][kMatrixSize]
Definition: TGeometry.h:61
virtual void SetPosition(TRotMatrix *matrix, Double_t x=0, Double_t y=0, Double_t z=0)
Definition: TGeometry.h:151
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
THashList * GetListOfMaterials() const
Definition: TGeometry.h:81
TNode * GetCurrentNode() const
Definition: TGeometry.h:83
Double_t x[n]
Definition: legend1.C:17
virtual ~TGeometry()
Geometry default destructor.
Definition: TGeometry.cxx:200
#define ClassDef(name, id)
Definition: Rtypes.h:254
const Int_t kVectorSize
Definition: TGeometry.h:32
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Int_t GeomLevel() const
Definition: TGeometry.h:78
virtual void Local2Master(Double_t *local, Double_t *master)
Convert one point from local system to master reference system.
Definition: TGeometry.cxx:407
Bool_t GetCurrentReflection() const
Definition: TGeometry.h:139
virtual void Node(const char *name, const char *title, const char *shapename, Double_t x=0, Double_t y=0, Double_t z=0, const char *matrixname="", Option_t *option="")
Add a node to the current node in this geometry.
Definition: TGeometry.cxx:557
virtual Int_t PushLevel()
Definition: TGeometry.h:103
Bool_t fIsReflection[kMAXLEVELS]
Definition: TGeometry.h:62
Manages a detector material.
Definition: TMaterial.h:32
TNode * fCurrentNode
Pointers to current rotation matrices.
Definition: TGeometry.h:51
virtual void ls(Option_t *option="rsn2") const
List this geometry.
Definition: TGeometry.cxx:473
Int_t fGeomLevel
Definition: TGeometry.h:56
A doubly linked list.
Definition: TList.h:47
TGeometry description.
Definition: TGeometry.h:43
Double_t fX
Definition: TGeometry.h:57
virtual void UpdateMatrix(TNode *node)
Update global rotation matrix/translation vector for this node this function must be called before in...
Definition: TGeometry.cxx:635
TList * fNodes
Definition: TGeometry.h:49
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
TGeometry & operator=(const TGeometry &)
assignment operator
Definition: TGeometry.cxx:168
This is the base class for all geometry shapes.
Definition: TShape.h:47
Manages a detector rotation matrix.
Definition: TRotMatrix.h:30
TRotMatrix * GetRotMatrixByNumber(Int_t number) const
Return pointer to RotMatrix with number.
Definition: TGeometry.cxx:364
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TGeometry.h:95
TMaterial * GetMaterialByNumber(Int_t number) const
Return pointer to Material with number.
Definition: TGeometry.cxx:330
Float_t fBomb
Pointers to shapes.
Definition: TGeometry.h:55
TMaterial * GetMaterial(const char *name) const
Return pointer to Material with name.
Definition: TGeometry.cxx:322
TList * GetListOfNodes() const
Definition: TGeometry.h:80
TShape ** fShapePointer
Pointers to rotation matrices.
Definition: TGeometry.h:54
TShape * GetShapeByNumber(Int_t number) const
Return pointer to Shape with number.
Definition: TGeometry.cxx:387
TRotMatrix ** fMatrixPointer
Pointers to materials.
Definition: TGeometry.h:53
virtual void Draw(Option_t *option="")
Draw this Geometry.
Definition: TGeometry.cxx:254
virtual void SetCurrentNode(TNode *node)
Definition: TGeometry.h:107
virtual void SetMatrix(TRotMatrix *matrix=0)
Definition: TGeometry.h:109
TGeometry()
Geometry default constructor.
Definition: TGeometry.cxx:96
THashList * GetListOfMatrices() const
Definition: TGeometry.h:82
TNode * GetNode(const char *name) const
Return pointer to node with name in the geometry tree.
Definition: TGeometry.cxx:345
double Double_t
Definition: RtypesCore.h:55
Double_t y[n]
Definition: legend1.C:17
THashList * GetListOfShapes() const
Definition: TGeometry.h:79
const Int_t kMatrixSize
Definition: TGeometry.h:33
Double_t fTranslation[kMAXLEVELS][kVectorSize]
Definition: TGeometry.h:60
virtual void SetGeomLevel(Int_t level=0)
Definition: TGeometry.h:108
Float_t GetBomb() const
Definition: TGeometry.h:77
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual void UpdateTempMatrix(Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0)
Update temp matrix.
Definition: TGeometry.cxx:661
#define R__EXTERN
Definition: DllImport.h:27
THashList * fMatrices
Definition: TGeometry.h:47
static TObjArray * Get(const char *name)
Static function called by TROOT to search name in the geometry.
Definition: TGeometry.cxx:285
virtual void SetBomb(Float_t bomb=1.4)
Definition: TGeometry.h:106
virtual void cd(const char *path=0)
Change Current Geometry to this.
Definition: TGeometry.cxx:246
virtual void Master2Local(Double_t *master, Double_t *local)
Convert one point from master system to local reference system.
Definition: TGeometry.cxx:503
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
const Bool_t kTRUE
Definition: Rtypes.h:91
R__EXTERN TGeometry * gGeometry
Definition: TGeometry.h:162
virtual Int_t PopLevel()
Definition: TGeometry.h:104
char name[80]
Definition: TGX11.cxx:109
TRotMatrix * fMatrix
Definition: TGeometry.h:50
TShape * GetShape(const char *name) const
Return pointer to Shape with name.
Definition: TGeometry.cxx:379
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a Geometry list.
Definition: TGeometry.cxx:565