library: libGraf3d #include "TGeometry.h"

# TGeometry

class description - source file - inheritance tree (.pdf)

## class TGeometry : public TNamed

| Inheritance Chart:
`TObject`
| <- | `TNamed`
| <- | `TGeometry` |

        public:

                            TGeometry()
                            TGeometry(const char* name, const char* title)
                            TGeometry(const TGeometry&)
                    virtual ~TGeometry()
               virtual void Browse(TBrowser* b)
               virtual void cd(const char* path = "0")
             static TClass* Class()
               virtual void Draw(Option_t* option = "")
           virtual TObject* FindObject(const char* name) const
           virtual TObject* FindObject(const TObject* obj) const
                      Int_t GeomLevel() const
          static TObjArray* Get(const char* name)
                    Float_t GetBomb() const
                TRotMatrix* GetCurrentMatrix() const
                     TNode* GetCurrentNode() const
                TRotMatrix* GetCurrentPosition(Double_t* x, Double_t* y, Double_t* z) const
                TRotMatrix* GetCurrentPosition(Float_t* x, Float_t* y, Float_t* z) const
                     Bool_t GetCurrentReflection() const
                 THashList* GetListOfMaterials() const
                 THashList* GetListOfMatrices() const
                     TList* GetListOfNodes() const
                 THashList* GetListOfShapes() const
                 TMaterial* GetMaterial(const char* name) const
                 TMaterial* GetMaterialByNumber(Int_t number) const
                     TNode* GetNode(const char* name) const
                TRotMatrix* GetRotMatrix(const char* name) const
                TRotMatrix* GetRotMatrixByNumber(Int_t number) const
                    TShape* GetShape(const char* name) const
                    TShape* GetShapeByNumber(Int_t number) const
            virtual TClass* IsA() const
             virtual Bool_t IsFolder() const
               virtual void Local2Master(Double_t* local, Double_t* master)
               virtual void Local2Master(Float_t* local, Float_t* master)
               virtual void ls(Option_t* option = "rsn2") const
               virtual void Master2Local(Double_t* master, Double_t* local)
               virtual void Master2Local(Float_t* master, Float_t* local)
               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 = "")
                 TGeometry& operator=(const TGeometry&)
              virtual Int_t PopLevel()
              virtual Int_t PushLevel()
               virtual void RecursiveRemove(TObject* obj)
               virtual void SetBomb(Float_t bomb = 1.4)
               virtual void SetCurrentNode(TNode* node)
               virtual void SetGeomLevel(Int_t level = 0)
               virtual void SetMatrix(TRotMatrix* matrix = 0)
               virtual void SetPosition(TRotMatrix* matrix, Double_t x = 0, Double_t y = 0, Double_t z = 0)
               virtual void SetPosition(TRotMatrix* matrix, Float_t x, Float_t y, Float_t z)
               virtual void SetPosition(Double_t x, Double_t y, Double_t z)
               virtual void SetPosition(Float_t x, Float_t y, Float_t z)
               virtual void ShowMembers(TMemberInspector& insp, char* parent)
               virtual void Streamer(TBuffer& b)
                       void StreamerNVirtual(TBuffer& b)
               virtual void UpdateMatrix(TNode* node)
               virtual void UpdateTempMatrix(Double_t x = 0, Double_t y = 0, Double_t z = 0, TRotMatrix* matrix = 0)
               virtual void UpdateTempMatrix(Double_t x, Double_t y, Double_t z, Double_t* matrix, Bool_t isReflection = kFALSE)
                static void UpdateTempMatrix(Double_t* dx1, Double_t* rmat1, Double_t x, Double_t y, Double_t z, Double_t* matrix, Double_t* dxnew, Double_t* rmatnew)

### Data Members

        private:

            THashList* fMaterials           ->Collection of materials
            THashList* fMatrices            ->Collection of rotation matrices
            THashList* fShapes              ->Collection of shapes
                TList* fNodes               ->Collection of nodes
           TRotMatrix* fMatrix              !Pointers to current rotation matrices
                TNode* fCurrentNode         !Pointer to current node
           TMaterial** fMaterialPointer     !Pointers to materials
          TRotMatrix** fMatrixPointer       !Pointers to rotation matrices
              TShape** fShapePointer        !Pointers to shapes
               Float_t fBomb                Bomb factor for exploded geometry
                 Int_t fGeomLevel           !
              Double_t fX                   !
              Double_t fY                   ! The global translation of the current node
              Double_t fZ                   !
              Double_t fTranslation[20][3]  !
              Double_t fRotMatrix[20][9]    !
                Bool_t fIsReflection[20]    !

## Class Description

    *-*-*-*-*-*-*-*-*-*-*-* T G E O M E T R Y  description *-*-*-*-*-*-*-*-*-*-*
    *-*                    ===============================
    *-*
    *-*    The Geometry class describes the geometry of a detector.
    *-*    The current implementation supports the GEANT3 style description.
    *-*    A special program provided in the ROOT utilities (toroot) can be used
    *-*    to automatically translate a GEANT detector geometry into a ROOT geometry.
    *-*
    *-*   a Geometry object is entered into the list of geometries into the
    *-*     ROOT main object (see TROOT description) when the TGeometry
    *-*     constructor is invoked.
    *-*   Several geometries may coexist in memory.
    *-*
    *-*   A Geometry object consist of the following linked lists:
    *-*        - the TMaterial list (material definition only).
    *-*        - the TRotmatrix list (Rotation matrices definition only).
    *-*        - the TShape list (volume definition only).
    *-*        - the TNode list assembling all detector elements.
    *-*
    *-*   Only the Build and Draw functions for a geometry are currently supported.
    *-*
    *-*---------------------------------------------------------------------------
    *-*- The conversion program from Geant to Root has been added in the list
    *-*  of utilities in utils directory.(see g2root)
    *-*  The executable module of g2root can be found in $ROOTSYS/bin/g2root.
    *-*
    *-*  To use this conversion program, type the shell command:
    *-*        g2root  geant_rzfile macro_name
    *-*
    *-*  for example
    *-*        g2root na49.geom na49.C
    *-*  will convert the GEANT RZ file na49.geom into a ROOT macro na49.C
    *-*
    *-*  To generate the Geometry structure within Root, do:
    *-*    Root > .x na49.C
    *-*    Root > na49.Draw()
    *-*    Root > wh.x3d()    (this invokes the 3-d Root viewver)
    *-*    Root > TFile gna49("na49.root","NEW")  //open a new root file
    *-*    Root > na49.Write()                    //Write the na49 geometry structure
    *-*    Root > gna49.Write()                   //Write all keys (in this case only one)
    *-*  Note: all keys are also written on closing of the file, gna49.Close or
    *-*  when the program exits, Root closes all open files correctly.
    *-*  Once this file has been written, in a subsequent session, simply do:
    *-*    Root > TFile gna49("na49.root")
    *-*    Root > na49.Draw()
    *-*
    *-*  The figure below shows the geometry above using the x3d viewer.
    *-*  This x3d viewver is invoked by selecting "View x3d" in the View menu
    *-*  of a canvas (See example of this tool bar in TCanvas).

/* */

    *-*
    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

TGeometry()

    *-*-*-*-*-*-*-*-*-*-*-*-*Geometry default constructor*-*-*-*-*-*-*-*-*-*-*-*

TGeometry(const char *name,const char *title ) : TNamed (name, title)

    *-*-*-*-*-*-*-*-*-*-*-*-*Geometry normal constructor*-*-*-*-*-*-*-*-*-*-*-*
    *-*                      ===========================

~TGeometry()

    *-*-*-*-*-*-*-*-*-*-*-*-*Geometry default destructor*-*-*-*-*-*-*-*-*-*-*-*
    *-*                      ========================

void Browse(TBrowser *b)

void cd(const char *)

    *-*-*-*-*-*Change Current Geometry to this*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*        ===============================

void Draw(Option_t *option)

    *-*-*-*-*-*-*-*-*-*-*-*-*Draw this Geometry*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                      ==================

TObject* FindObject(const TObject *) const

     find object in a geometry node, material, etc

TObject* FindObject(const char *name) const

     search object identified by name in the geometry tree

TObjArray* Get(const char *name)

     Static function called by TROOT to search name in the geometry.
     Returns a TObjArray containing a pointer to the found object
     and a pointer to the container where the object was found.

TMaterial* GetMaterial(const char *name) const

    *-*-*-*-*-*-*-*-*Return pointer to Material with name*-*-*-*-*-*-*-*-*
    *-*              ====================================

TMaterial* GetMaterialByNumber(Int_t number) const

    *-*-*-*-*-*-*-*-*Return pointer to Material with number*-*-*-*-*-*-*-*-*
    *-*              ======================================

TNode* GetNode(const char *name) const

    *-*-*-*-*-*-*Return pointer to node with name in the geometry tree*-*-*-*-*
    *-*          =====================================================

TRotMatrix* GetRotMatrix(const char *name) const

    *-*-*-*-*-*-*-*-*Return pointer to RotMatrix with name*-*-*-*-*-*-*-*-*-*
    *-*              =====================================

TRotMatrix* GetRotMatrixByNumber(Int_t number) const

    *-*-*-*-*-*-*-*-*Return pointer to RotMatrix with number*-*-*-*-*-*-*-*-*-*
    *-*              =======================================

TShape* GetShape(const char *name) const

    *-*-*-*-*-*-*-*-*Return pointer to Shape with name*-*-*-*-*-*-*-*-*-*
    *-*              =================================

TShape* GetShapeByNumber(Int_t number) const

    *-*-*-*-*-*-*-*-*Return pointer to Shape with number*-*-*-*-*-*-*-*-*-*
    *-*              ===================================

void Local2Master(Double_t *local, Double_t *master)

    *-*-*-*-*Convert one point from local system to master reference system*-*-*
    *-*      ==============================================================

      Note that before invoking this function, the global rotation matrix
      and translation vector for this node must have been computed.
      This is automatically done by the Paint functions.
      Otherwise TNode::UpdateMatrix should be called before.

void Local2Master(Float_t *local, Float_t *master)

    *-*-*-*-*Convert one point from local system to master reference system*-*-*
    *-*      ==============================================================

      Note that before invoking this function, the global rotation matrix
      and translation vector for this node must have been computed.
      This is automatically done by the Paint functions.
      Otherwise TNode::UpdateMatrix should be called before.

void ls(Option_t *option) const

    *-*-*-*-*-*-*-*-*-*-*-*List this geometry*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                   ===================

void Master2Local(Double_t *master, Double_t *local)

    *-*-*-*-*Convert one point from master system to local reference system*-*-*
    *-*      ==============================================================

      Note that before invoking this function, the global rotation matrix
      and translation vector for this node must have been computed.
      This is automatically done by the Paint functions.
      Otherwise TNode::UpdateMatrix should be called before.

void Master2Local(Float_t *master, Float_t *local)

    *-*-*-*-*Convert one point from master system to local reference system*-*-*
    *-*      ==============================================================

      Note that before invoking this function, the global rotation matrix
      and translation vector for this node must have been computed.
      This is automatically done by the Paint functions.
      Otherwise TNode::UpdateMatrix should be called before.

void Node(const char *name, const char *title, const char *shapename, Double_t x, Double_t y, Double_t z, const char *matrixname, Option_t *option)

    *-*-*-*-*-*-*-*Add a node to the current node in this geometry*-*-*-*-*-*-*
    *-*            ===============================================

void RecursiveRemove(TObject *obj)

    *-*-*-*-*-*-*-*Recursively remove object from a Geometry list*-*-*-*-*-*-*-*
    *-*            =========================================

void Streamer(TBuffer &b)

    *-*-*-*-*-*-*-*-*Stream a class object*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*              =========================================

void UpdateMatrix(TNode *node)

        Update global rotation matrix/translation vector for this node
       this function must be called before invoking Local2Master

void UpdateTempMatrix(Double_t x, Double_t y, Double_t z, TRotMatrix *rotMatrix)

void UpdateTempMatrix(Double_t x, Double_t y, Double_t z, Double_t *matrix,Bool_t isReflection)

void UpdateTempMatrix(Double_t *dx,Double_t *rmat , Double_t x, Double_t y, Double_t z, Double_t *matrix , Double_t *dxnew, Double_t *rmatnew)

    *-*-*-*-*-*-*Compute new translation vector and global matrix*-*-*-*-*-*-*-*
    *-*          ================================================
    *-*
    *-*  dx      old translation vector
    *-*  rmat    old global matrix
    *-*  x,y,z   offset of new local system with respect to mother
    *-*  dxnew   new translation vector
    *-*  rmatnew new global rotation matrix
    *-*
    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

### Inline Functions

                Float_t GetBomb() const
                  Int_t GeomLevel() const
             THashList* GetListOfShapes() const
                 TList* GetListOfNodes() const
             THashList* GetListOfMaterials() const
             THashList* GetListOfMatrices() const
                 TNode* GetCurrentNode() const
            TRotMatrix* GetCurrentMatrix() const
            TRotMatrix* GetCurrentPosition(Double_t* x, Double_t* y, Double_t* z) const
            TRotMatrix* GetCurrentPosition(Float_t* x, Float_t* y, Float_t* z) const
                 Bool_t GetCurrentReflection() const
                 Bool_t IsFolder() const
                  Int_t PushLevel()
                  Int_t PopLevel()
                   void SetBomb(Float_t bomb = 1.4)
                   void SetCurrentNode(TNode* node)
                   void SetGeomLevel(Int_t level = 0)
                   void SetMatrix(TRotMatrix* matrix = 0)
                   void SetPosition(TRotMatrix* matrix, Double_t x = 0, Double_t y = 0, Double_t z = 0)
                   void SetPosition(TRotMatrix* matrix, Float_t x, Float_t y, Float_t z)
                   void SetPosition(Double_t x, Double_t y, Double_t z)
                   void SetPosition(Float_t x, Float_t y, Float_t z)
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void StreamerNVirtual(TBuffer& b)
              TGeometry TGeometry(const TGeometry&)
             TGeometry& operator=(const TGeometry&)

Author: Rene Brun 22/09/95
Last update: root/g3d:$Name: $:$Id: TGeometry.cxx,v 1.8 2005/05/19 21:02:05 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *