Logo ROOT   6.10/09
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 #include "TNamed.h"
25 #include "THashList.h"
26 
27 const Int_t kMAXLEVELS = 20;
28 const Int_t kVectorSize = 3;
30 
31 class TNode;
32 class TBrowser;
33 class TMaterial;
34 class TRotMatrix;
35 class TShape;
36 class TObjArray;
37 
38 
39 class TGeometry : public TNamed {
40 
41 private:
42  THashList *fMaterials; //->Collection of materials
43  THashList *fMatrices; //->Collection of rotation matrices
44  THashList *fShapes; //->Collection of shapes
45  TList *fNodes; //->Collection of nodes
46  TRotMatrix *fMatrix; //!Pointers to current rotation matrices
47  TNode *fCurrentNode; //!Pointer to current node
48  TMaterial **fMaterialPointer; //!Pointers to materials
49  TRotMatrix **fMatrixPointer; //!Pointers to rotation matrices
50  TShape **fShapePointer; //!Pointers to shapes
51  Float_t fBomb; //Bomb factor for exploded geometry
53  Double_t fX; //!
54  Double_t fY; //! The global translation of the current node
55  Double_t fZ; //!
59 
60 protected:
61  TGeometry(const TGeometry&);
62  TGeometry& operator=(const TGeometry&);
63 
64 public:
65  TGeometry();
66  TGeometry(const char *name, const char *title);
67  virtual ~TGeometry();
68  virtual void Browse(TBrowser *b);
69  virtual void cd(const char *path=0);
70  virtual void Draw(Option_t *option="");
71  virtual TObject *FindObject(const char *name) const;
72  virtual TObject *FindObject(const TObject *obj) const;
73  Float_t GetBomb() const {return fBomb;}
74  Int_t GeomLevel() const {return fGeomLevel;}
75  THashList *GetListOfShapes() const {return fShapes;}
76  TList *GetListOfNodes() const {return fNodes;}
79  TNode *GetCurrentNode() const {return fCurrentNode;}
80  TMaterial *GetMaterial(const char *name) const;
81  TMaterial *GetMaterialByNumber(Int_t number) const;
82  TNode *GetNode(const char *name) const;
83  TShape *GetShape(const char *name) const;
84  TShape *GetShapeByNumber(Int_t number) const;
85  TRotMatrix *GetRotMatrix(const char *name) const;
86  TRotMatrix *GetRotMatrixByNumber(Int_t number) const;
91  Bool_t IsFolder() const {return kTRUE;}
92  virtual void Local2Master(Double_t *local, Double_t *master);
93  virtual void Local2Master(Float_t *local, Float_t *master);
94  virtual void ls(Option_t *option="rsn2") const;
95  virtual void Master2Local(Double_t *master, Double_t *local);
96  virtual void Master2Local(Float_t *master, Float_t *local);
97  virtual void Node(const char *name, const char *title, const char *shapename, Double_t x=0, Double_t y=0, Double_t z=0
98  , const char *matrixname="", Option_t *option="");
99  virtual Int_t PushLevel(){return fGeomLevel++;}
100  virtual Int_t PopLevel(){return fGeomLevel>0?fGeomLevel--:0;}
101  virtual void RecursiveRemove(TObject *obj);
102  virtual void SetBomb(Float_t bomb=1.4) {fBomb = bomb;}
103  virtual void SetCurrentNode(TNode *node) {fCurrentNode = node;}
104  virtual void SetGeomLevel(Int_t level=0){fGeomLevel=level;}
105  virtual void SetMatrix(TRotMatrix *matrix=0){fMatrix = matrix;}
106  virtual void SetPosition(TRotMatrix *matrix, Double_t x=0,Double_t y=0,Double_t z=0);
107  virtual void SetPosition(TRotMatrix *matrix, Float_t x,Float_t y,Float_t z);
108  virtual void SetPosition(Double_t x,Double_t y,Double_t z);
109  virtual void SetPosition(Float_t x,Float_t y,Float_t z);
110  virtual void UpdateMatrix(TNode *node);
111  virtual void UpdateTempMatrix(Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0);
112  virtual void UpdateTempMatrix(Double_t x, Double_t y, Double_t z, Double_t *matrix,Bool_t isReflection=kFALSE);
113 
114  static TObjArray *Get(const char *name);
115  static void UpdateTempMatrix(Double_t *dx1,Double_t *rmat1,
116  Double_t x, Double_t y, Double_t z, Double_t *matrix,
117  Double_t *dxnew, Double_t *rmatnew);
118 
119  ClassDef(TGeometry,2) //Structure for Matrices, Shapes and Nodes
120 };
121 
122 
124 {
125  return fMatrix;
126 }
128 {
129  *x = fX; *y = fY; *z = fZ; return GetCurrentMatrix();
130 }
132 {
133  *x = Float_t(fX); *y = Float_t(fY); *z = Float_t(fZ); return GetCurrentMatrix();
134 }
136 {
137  return fIsReflection[fGeomLevel];
138 }
140 {
141  fX = x; fY = y; fZ = z;
142 }
144 {
145  fX = x; fY = y; fZ = z;
146 }
148 {
149  SetMatrix(matrix);
150  SetPosition(x,y,z);
151 }
153 {
154  SetMatrix(matrix);
155  SetPosition(x,y,z);
156 }
157 
159 
160 #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:127
An array of TObjects.
Definition: TObjArray.h:37
TRotMatrix * GetRotMatrix(const char *name) const
Return pointer to RotMatrix with name.
Definition: TGeometry.cxx:356
THashList * fShapes
Definition: TGeometry.h:44
float Float_t
Definition: RtypesCore.h:53
Double_t fZ
The global translation of the current node.
Definition: TGeometry.h:55
const char Option_t
Definition: RtypesCore.h:62
THashList * fMaterials
Definition: TGeometry.h:42
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:123
Double_t fY
Definition: TGeometry.h:54
TMaterial ** fMaterialPointer
Pointer to current node.
Definition: TGeometry.h:48
const Int_t kMAXLEVELS
Definition: TGeometry.h:27
TNode description.
Definition: TNode.h:33
Double_t fRotMatrix[kMAXLEVELS][kMatrixSize]
Definition: TGeometry.h:57
virtual void SetPosition(TRotMatrix *matrix, Double_t x=0, Double_t y=0, Double_t z=0)
Definition: TGeometry.h:147
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
THashList * GetListOfMaterials() const
Definition: TGeometry.h:77
TNode * GetCurrentNode() const
Definition: TGeometry.h:79
Double_t x[n]
Definition: legend1.C:17
virtual ~TGeometry()
Geometry default destructor.
Definition: TGeometry.cxx:200
#define ClassDef(name, id)
Definition: Rtypes.h:297
const Int_t kVectorSize
Definition: TGeometry.h:28
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Int_t GeomLevel() const
Definition: TGeometry.h:74
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:135
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:99
Bool_t fIsReflection[kMAXLEVELS]
Definition: TGeometry.h:58
Manages a detector material.
Definition: TMaterial.h:28
TNode * fCurrentNode
Pointers to current rotation matrices.
Definition: TGeometry.h:47
virtual void ls(Option_t *option="rsn2") const
List this geometry.
Definition: TGeometry.cxx:473
Int_t fGeomLevel
Definition: TGeometry.h:52
A doubly linked list.
Definition: TList.h:43
TGeometry description.
Definition: TGeometry.h:39
Double_t fX
Definition: TGeometry.h:53
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:45
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
TGeometry & operator=(const TGeometry &)
assignment operator
Definition: TGeometry.cxx:168
This is the base class for all geometry shapes.
Definition: TShape.h:35
Manages a detector rotation matrix.
Definition: TRotMatrix.h:28
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:91
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:51
TMaterial * GetMaterial(const char *name) const
Return pointer to Material with name.
Definition: TGeometry.cxx:322
TList * GetListOfNodes() const
Definition: TGeometry.h:76
TShape ** fShapePointer
Pointers to rotation matrices.
Definition: TGeometry.h:50
TShape * GetShapeByNumber(Int_t number) const
Return pointer to Shape with number.
Definition: TGeometry.cxx:387
TRotMatrix ** fMatrixPointer
Pointers to materials.
Definition: TGeometry.h:49
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual void Draw(Option_t *option="")
Draw this Geometry.
Definition: TGeometry.cxx:254
virtual void SetCurrentNode(TNode *node)
Definition: TGeometry.h:103
virtual void SetMatrix(TRotMatrix *matrix=0)
Definition: TGeometry.h:105
TGeometry()
Geometry default constructor.
Definition: TGeometry.cxx:96
THashList * GetListOfMatrices() const
Definition: TGeometry.h:78
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:75
const Int_t kMatrixSize
Definition: TGeometry.h:29
Double_t fTranslation[kMAXLEVELS][kVectorSize]
Definition: TGeometry.h:56
virtual void SetGeomLevel(Int_t level=0)
Definition: TGeometry.h:104
Float_t GetBomb() const
Definition: TGeometry.h:73
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:43
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:102
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
R__EXTERN TGeometry * gGeometry
Definition: TGeometry.h:158
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual Int_t PopLevel()
Definition: TGeometry.h:100
TRotMatrix * fMatrix
Definition: TGeometry.h:46
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