library: libGeom
#include "TGeoVolume.h"


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

class TGeoVolume : public TNamed, public TGeoAtt, public TAttLine, public TAttFill, public TAtt3D

Inheritance Chart:

TGeoVolume() TGeoVolume(const char* name, const TGeoShape* shape, const TGeoMedium* med = 0) TGeoVolume(const TGeoVolume&) virtual ~TGeoVolume() virtual void AddNode(const TGeoVolume* vol, Int_t copy_no, TGeoMatrix* mat = 0, Option_t* option = "") void AddNodeOffset(const TGeoVolume* vol, Int_t copy_no, Double_t offset = 0, Option_t* option = "") virtual void AddNodeOverlap(const TGeoVolume* vol, Int_t copy_no, TGeoMatrix* mat = 0, Option_t* option = "") virtual void Browse(TBrowser* b) virtual void cd(Int_t inode) const void CheckGeometry(Int_t nrays = 1, Double_t startx = 0, Double_t starty = 0, Double_t startz = 0) const void CheckOverlaps(Double_t ovlp = 0.1, Option_t* option = "") const void CheckShapes() static TClass* Class() void CleanAll() void ClearNodes() void ClearShape() TGeoVolume* CloneVolume() const Bool_t Contains(Double_t* point) const Int_t CountNodes(Int_t nlevels = 1000, Int_t option = 0) virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) virtual TGeoVolume* Divide(const char* divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed = 0, Option_t* option = "") virtual void Draw(Option_t* option = "") virtual void DrawOnly(Option_t* option = "") virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py) Bool_t FindMatrixOfDaughterVolume(TGeoVolume* vol) const TGeoNode* FindNode(const char* name) const void FindOverlaps() const virtual Int_t GetByteCount() const virtual Int_t GetCurrentNodeIndex() const TObject* GetField() const TGeoPatternFinder* GetFinder() const TGeoManager* GetGeoManager() const Int_t GetIndex(const TGeoNode* node) const TGeoMaterial* GetMaterial() const TGeoMedium* GetMedium() const Int_t GetNdaughters() const virtual Int_t GetNextNodeIndex() const TGeoNode* GetNode(const char* name) const TGeoNode* GetNode(Int_t i) const Int_t GetNodeIndex(const TGeoNode* node, Int_t* check_list, Int_t ncheck) const TObjArray* GetNodes() Int_t GetNtotal() const Int_t GetNumber() const virtual char* GetObjectInfo(Int_t px, Int_t py) const Bool_t GetOptimalVoxels() const virtual Option_t* GetOption() const char* GetPointerName() const TGeoShape* GetShape() const Char_t GetTransparency() const TGeoVoxelFinder* GetVoxels() const void GrabFocus() void Gsord(Int_t) void InspectMaterial() const void InspectShape() const void InvisibleAll(Bool_t flag = kTRUE) virtual TClass* IsA() const Bool_t IsAllInvisible() const virtual Bool_t IsAssembly() const Bool_t IsCylVoxels() const virtual Bool_t IsFolder() const Bool_t IsRaytracing() const Bool_t IsRunTime() const Bool_t IsStyleDefault() const Bool_t IsTopVolume() const Bool_t IsValid() const virtual Bool_t IsVisible() const Bool_t IsVisibleDaughters() const virtual Bool_t IsVolumeMulti() const Bool_t IsXYZVoxels() const TH2F* LegoPlot(Int_t ntheta = 20, Double_t themin = 0., Double_t themax = 180., Int_t nphi = 60, Double_t phimin = 0., Double_t phimax = 360., Double_t rmin = 0., Double_t rmax = 9999999, Option_t* option = "") void MakeCopyNodes(const TGeoVolume* other) virtual TGeoVolume* MakeCopyVolume(TGeoShape* newshape) TGeoVolume& operator=(const TGeoVolume&) Bool_t OptimizeVoxels() virtual void Paint(Option_t* option = "") void PrintNodes() const void PrintVoxels() const void RandomPoints(Int_t npoints = 1000000, Option_t* option = "") void RandomRays(Int_t nrays = 10000, Double_t startx = 0, Double_t starty = 0, Double_t startz = 0) void Raytrace(Bool_t flag = kTRUE) void SaveAs(const char* filename) virtual void SavePrimitive(ofstream& out, Option_t* option) void SetAsTopVolume() void SetCurrentPoint(Double_t x, Double_t y, Double_t z) void SetCylVoxels(Bool_t flag = kTRUE) void SetField(const TObject* field) void SetFinder(const TGeoPatternFinder* finder) void SetInvisible() virtual void SetLineColor(Color_t lcolor) virtual void SetLineStyle(Style_t lstyle) virtual void SetLineWidth(Width_t lwidth) virtual void SetMedium(const TGeoMedium* medium) void SetNodes(TObjArray* nodes) void SetNtotal(Int_t ntotal) void SetNumber(Int_t number) void SetOption(const char* option) void SetShape(const TGeoShape* shape) void SetTransparency(Char_t transparency = 0) virtual void SetVisibility(Bool_t vis = kTRUE) void SetVoxelFinder(const TGeoVoxelFinder* finder) virtual void ShowMembers(TMemberInspector& insp, char* parent) void SortNodes() virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) void UnmarkSaved() Bool_t Valid() const void VisibleDaughters(Bool_t vis = kTRUE) void Voxelize(Option_t* option) Double_t Weight(Double_t precision = 0.01, Option_t* option = "v")

Data Members

TObjArray* fNodes array of nodes inside this volume TGeoShape* fShape shape TGeoMedium* fMedium tracking medium TGeoPatternFinder* fFinder finder object for divisions TGeoVoxelFinder* fVoxels finder object for bounding boxes TGeoManager* fGeoManager ! pointer to TGeoManager owning this volume TObject* fField ! just a hook for now TString fOption ! option - if any Int_t fNumber volume serial number in the list of volumes Int_t fNtotal total number of physical nodes public:
static const TGeoVolume::EGeoVolumeTypes kVolumeDiv static const TGeoVolume::EGeoVolumeTypes kVolumeOverlap static const TGeoVolume::EGeoVolumeTypes kVolumeImportNodes static const TGeoVolume::EGeoVolumeTypes kVolumeMulti static const TGeoVolume::EGeoVolumeTypes kVoxelsXYZ static const TGeoVolume::EGeoVolumeTypes kVoxelsCyl static const TGeoVolume::EGeoVolumeTypes kVolumeClone

Class Description

   TGeoVolume - the base class representing solids.

   Volumes are the basic objects used in building the geometrical hierarchy.
 They represent unpositioned objects but store all information about the
 placement of the other volumes they may contain. Therefore a volume can
 be replicated several times in the geometry. In order to create a volume, one
 has to put togeather a shape and a medium which are already defined. Volumes
 have to be named by users at creation time. Every different name may represent a
 an unique volume object, but may also represent more general a family (class)
 of volume objects having the same shape type and medium, but possibly
 different shape parameters. It is the user's task to provide different names
 for different volume families in order to avoid ambiguities at tracking time.
 A generic family rather than a single volume is created only in two cases :
 when a generic shape is provided to the volume constructor or when a division
 operation is applied. Each volume in the geometry stores an unique
 ID corresponding to its family. In order to ease-up their creation, the manager
 class is providing an API that allows making a shape and a volume in a single step.

   Volumes are objects that can be visualized, therefore having visibility,
 colour, line and fill attributes that can be defined or modified any time after
 the volume creation. It is advisable however to define these properties just
 after the first creation of a volume namespace, since in case of volume families
 any new member created by the modeler inherits these properties.

    In order to provide navigation features, volumes have to be able to find
 the proper container of any point defined in the local reference frame. This
 can be the volume itself, one of its positioned daughter volumes or none if
 the point is actually outside. On the other hand, volumes have to provide also
 other navigation methods such as finding the distances to its shape boundaries
 or which daughter will be crossed first. The implementation of these features
 is done at shape level, but the local mother-daughters management is handled
 by volumes that builds additional optimisation structures upon geometry closure.
 In order to have navigation features properly working one has to follow the
 general rules for building a valid geometry (see TGeoManager class).

   Now let's make a simple volume representing a copper wire. We suppose that
 a medium is already created (see TGeoMedium class on how to create media).
 We will create a TUBE shape for our wire, having Rmin=0cm, Rmax=0.01cm
 and a half-length dZ=1cm :

   TGeoTube *tube = new TGeoTube("wire_tube", 0, 0.01, 1);

 One may ommit the name for the shape if no retreiving by name is further needed
 during geometry building. The same shape can be shared by different volumes
 having different names and materials. Now let's make the volume for our wire.
 The prototype for volumes constructor looks like :

   TGeoVolume::TGeoVolume(const char *name, TGeoShape *shape, TGeoMedium *med)

 Since TGeoTube derives brom the base shape class, we can provide it to the volume
 constructor :

   TGeoVolume *wire_co = new TGeoVolume("WIRE_CO", tube, ptrCOPPER);

 Do not bother to delete neither the media, shapes or volumes that you have
 created since all will be automatically cleaned on exit by the manager class.
 If we would have taken a look inside TGeoManager::MakeTube() method, we would
 have been able to create our wire with a single line :

   TGeoVolume *wire_co = gGeoManager->MakeTube("WIRE_CO", ptrCOPPER, 0, 0.01, 1);

 The same applies for all primitive shapes, for which there can be found
 corresponding MakeSHAPE() methods. Their usage is much more convenient unless
 a shape has to be shared between more volumes. Let's make now an aluminium wire
 having the same shape, supposing that we have created the copper wire with the
 line above :

   TGeoVolume *wire_al = new TGeoVolume("WIRE_AL", wire_co->GetShape(), ptrAL);

 Now that we have learned how to create elementary volumes, let's see how we
 can create a geometrical hierarchy.

   Positioning volumes

   When creating a volume one does not specify if this will contain or not other
 volumes. Adding daughters to a volume implies creating those and adding them
 one by one to the list of daughters. Since the volume has to know the position
 of all its daughters, we will have to supply at the same time a geometrical
 transformation with respect to its local reference frame for each of them.
 The objects referencing a volume and a transformation are called NODES and
 their creation is fully handled by the modeler. They represent the link
 elements in the hierarchy of volumes. Nodes are unique and distinct geometrical
 objects ONLY from their container point of view. Since volumes can be replicated
 in the geometry, the same node may be found on different branches.

/* */

   An important observation is that volume objects are owned by the TGeoManager
 class. This stores a list of all volumes in the geometry, that is cleaned
 upon destruction.

   Let's consider positioning now our wire in the middle of a gas chamber. We
 need first to define the gas chamber :

   TGeoVolume *chamber = gGeoManager->MakeTube("CHAMBER", ptrGAS, 0, 1, 1);

 Now we can put the wire inside :

   chamber->AddNode(wire_co, 1);

 If we inspect now the chamber volume in a browser, we will notice that it has
 one daughter. Of course the gas has some container also, but let's keep it like
 that for the sake of simplicity. The full prototype of AddNode() is :

   TGeoVolume::AddNode(TGeoVolume *daughter, Int_t usernumber,
                       TGeoMatrix *matrix=gGeoIdentity)

 Since we did not supplied the third argument, the wire will be positioned with
 an identity transformation inside the chamber. One will notice that the inner
 radii of the wire and chamber are both zero - therefore, aren't the two volumes
 overlapping ? The answer is no, the modeler is even relaying on the fact that
 any daughter is fully contained by its mother. On the other hand, neither of
 the nodes positioned inside a volume should overlap with each other. We will
 see that there are allowed some exceptions to those rules.

 Overlapping volumes

   Positioning volumes that does not overlap their neighbours nor extrude
 their container is sometimes quite strong contrain. Some parts of the geometry
 might overlap naturally, e.g. two crossing tubes. The modeller supports such
 cases only if the overlapping nodes are declared by the user. In order to do
 that, one should use TGeoVolume::AddNodeOverlap() instead of TGeoVolume::AddNode().
   When 2 or more positioned volumes are overlapping, not all of them have to
 be declared so, but at least one. A point inside an overlapping region equally
 belongs to all overlapping nodes, but the way these are defined can enforce
 the modeler to give priorities.
   The general rule is that the deepest node in the hierarchy containing a point
 have the highest priority. For the same geometry level, non-overlapping is
 prioritized over overlapping. In order to illustrate this, we will consider
 few examples. We will designate non-overlapping nodes as ONLY and the others
 MANY as in GEANT3, where this concept was introduced:
   1. The part of a MANY node B extruding its container A will never be "seen"
 during navigation, as if B was in fact the result of the intersection of A and B.
   2. If we have two nodes A (ONLY) and B (MANY) inside the same container, all
 points in the overlapping region of A and B will be designated as belonging to A.
   3. If A an B in the above case were both MANY, points in the overlapping
 part will be designated to the one defined first. Both nodes must have the
 same medium.
   4. The silces of a divided MANY will be as well MANY.

 One needs to know that navigation inside geometry parts MANY nodes is much
 slower. Any overlapping part can be defined based on composite shapes - this
 is always recommended.

 dummy constructor

TGeoVolume(const char *name, const TGeoShape *shape, const TGeoMedium *med) :TNamed(name, "")
 default constructor


void Browse(TBrowser *b)
 How to browse a volume

void CheckGeometry(Int_t nrays, Double_t startx, Double_t starty, Double_t startz) const
 Shoot nrays with random directions from starting point (startx, starty, startz)
 in the reference frame of this volume. Track each ray until exiting geometry, then
 shoot backwards from exiting point and compare boundary crossing points.

void CheckOverlaps(Double_t ovlp, Option_t *option) const
 Overlap checking tool. Check for illegal overlaps within a limit OVLP.

void CleanAll()

void ClearShape()

void CheckShapes()
 check for negative parameters in shapes.
 THIS METHOD LEAVES SOME GARBAGE NODES -> memory leak, to be fixed
   printf("---Checking daughters of volume %s\n", GetName());

Int_t CountNodes(Int_t nlevels, Int_t option)
 Count total number of subnodes starting from this volume, nlevels down
 option = 0 (default) - count only once per volume
 option = 1           - count every time
 option = 2           - count volumes on visible branches
 option = 3           - return maximum level counted already with option = 0

Bool_t IsFolder() const
 Return TRUE if volume contains nodes

Bool_t IsStyleDefault() const
 check if the visibility and attributes are the default ones

Bool_t IsTopVolume() const
 True if this is the top volume of the geometry

Bool_t IsRaytracing() const

void InspectMaterial() const

void cd(Int_t inode) const
 Actualize matrix of node indexed <inode>

void AddNode(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t * /*option*/)
 Add a TGeoNode to the list of nodes. This is the usual method for adding
 daughters inside the container volume.

void AddNodeOffset(const TGeoVolume *vol, Int_t copy_no, Double_t offset, Option_t * /*option*/)
 Add a division node to the list of nodes. The method is called by
 TGeoVolume::Divide() for creating the division nodes.

void AddNodeOverlap(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t * /*option*/)
 Add a TGeoNode to the list of nodes. This is the usual method for adding
 daughters inside the container volume.

TGeoVolume* Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed, Option_t *option)
 Division a la G3. The volume will be divided along IAXIS (see shape classes), in NDIV
 slices, from START with given STEP. The division volumes will have medium number NUMED.
 If NUMED=0 they will get the medium number of the divided volume (this). If NDIV<=0,
 all range of IAXIS will be divided and the resulting number of divisions will be centered on
 IAXIS. If STEP<=0, the real STEP will be computed as the full range of IAXIS divided by NDIV.
 Options (case insensitive):
  N  - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
  NX - divide range starting with START in NDIV cells          (GSDVN2 in G3)
  S  - divide all range with given STEP. NDIV is computed and divisions will be centered
         in full range (same effect as NDIV<=0)                (GSDVS, GSDVT in G3)
  SX - same as DVS, but from START position.                   (GSDVS2, GSDVT2 in G3)

Int_t DistancetoPrimitive(Int_t px, Int_t py)
 compute the closest distance of approach from point px,py to this volume

void Draw(Option_t *option)
 draw top volume according to option

void DrawOnly(Option_t *option)
 draw only this volume

Bool_t OptimizeVoxels()
 Perform an exensive sampling to find which type of voxelization is
 most efficient.

void Paint(Option_t *option)
 paint volume

void PrintVoxels() const

void PrintNodes() const
 print nodes

TH2F* LegoPlot(Int_t ntheta, Double_t themin, Double_t themax, Int_t nphi, Double_t phimin, Double_t phimax, Double_t rmin, Double_t rmax, Option_t *option)
 Generate a lego plot fot the top volume, according to option.

void RandomPoints(Int_t npoints, Option_t *option)
 Draw random points in the bounding box of this volume.

void RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz)
 Random raytracing method.

void Raytrace(Bool_t flag)
 Draw this volume with current settings and perform raytracing in the pad.

void SaveAs(const char *filename)
  Save geometry having this as top volume as a C++ macro.

void SavePrimitive(ofstream &out, Option_t *option)
 Save a primitive as a C++ statement(s) on output stream "out".

void UnmarkSaved()
 Reset SavePrimitive bits.

void ExecuteEvent(Int_t event, Int_t px, Int_t py)
 Execute mouse actions on this volume.

TGeoNode* FindNode(const char *name) const
 search a daughter inside the list of nodes

Int_t GetNodeIndex(const TGeoNode *node, Int_t *check_list, Int_t ncheck) const

Int_t GetIndex(const TGeoNode *node) const
 get index number for a given daughter

char* GetObjectInfo(Int_t px, Int_t py) const

Bool_t GetOptimalVoxels() const
--- Returns true if cylindrical voxelization is optimal.

char* GetPointerName() const
 Provide a pointer name containing uid.

void GrabFocus()
 Move perspective view focus to this volume

TGeoVolume* CloneVolume() const

void MakeCopyNodes(const TGeoVolume *other)
 make a new list of nodes and copy all nodes of other volume inside

TGeoVolume* MakeCopyVolume(TGeoShape *newshape)
 make a copy of this volume
    printf("   Making a copy of %s\n", GetName());

void SetAsTopVolume()

void SetCurrentPoint(Double_t x, Double_t y, Double_t z)

void SetShape(const TGeoShape *shape)
 set the shape associated with this volume

void SortNodes()
 sort nodes by decreasing volume of the bounding box. ONLY nodes comes first,
 then overlapping nodes and finally division nodes.

void Streamer(TBuffer &R__b)
 Stream an object of class TGeoVolume.

void SetOption(const char * /*option*/)
 set the current options

void SetLineColor(Color_t lcolor)

void SetLineStyle(Style_t lstyle)

void SetLineWidth(Style_t lwidth)

TGeoNode* GetNode(const char *name) const
 get the pointer to a daughter node

Int_t GetByteCount() const
 get the total size in bytes for this volume

void FindOverlaps() const
 loop all nodes marked as overlaps and find overlaping brothers

void SetVisibility(Bool_t vis)
 set visibility of this volume

Bool_t Valid() const

Bool_t FindMatrixOfDaughterVolume(TGeoVolume *vol) const
 Find a daughter node having VOL as volume and fill TGeoManager::fHMatrix
 with its global matrix.

void VisibleDaughters(Bool_t vis)
 set visibility for daughters

void Voxelize(Option_t *option)
 build the voxels for this volume

Double_t Weight(Double_t precision, Option_t *option)
 Estimate the weight of a volume with SIGMA(M)/M better than PRECISION.
 Option can be : v - verbose (default)

Inline Functions

                      void ClearNodes()
                    Bool_t Contains(Double_t* point) const
                    Bool_t IsAssembly() const
                    Bool_t IsRunTime() const
                    Bool_t IsVolumeMulti() const
                    Bool_t IsCylVoxels() const
                    Bool_t IsXYZVoxels() const
                    Bool_t IsValid() const
                    Bool_t IsVisible() const
                    Bool_t IsVisibleDaughters() const
                    Bool_t IsAllInvisible() const
                     Int_t GetCurrentNodeIndex() const
                     Int_t GetNextNodeIndex() const
                TObjArray* GetNodes()
                     Int_t GetNdaughters() const
                     Int_t GetNtotal() const
              TGeoManager* GetGeoManager() const
             TGeoMaterial* GetMaterial() const
               TGeoMedium* GetMedium() const
                  TObject* GetField() const
        TGeoPatternFinder* GetFinder() const
          TGeoVoxelFinder* GetVoxels() const
                 TGeoNode* GetNode(Int_t i) const
                     Int_t GetNumber() const
                 Option_t* GetOption() const
                    Char_t GetTransparency() const
                TGeoShape* GetShape() const
                      void Gsord(Int_t)
                      void InspectShape() const
                      void SetCylVoxels(Bool_t flag = kTRUE)
                      void SetNodes(TObjArray* nodes)
                      void SetTransparency(Char_t transparency = 0)
                      void SetField(const TObject* field)
                      void SetInvisible()
                      void SetMedium(const TGeoMedium* medium)
                      void SetVoxelFinder(const TGeoVoxelFinder* finder)
                      void SetFinder(const TGeoPatternFinder* finder)
                      void SetNumber(Int_t number)
                      void SetNtotal(Int_t ntotal)
                      void InvisibleAll(Bool_t flag = kTRUE)
                   TClass* Class()
                   TClass* IsA() const
                      void ShowMembers(TMemberInspector& insp, char* parent)
                      void StreamerNVirtual(TBuffer& b)
                TGeoVolume TGeoVolume(const TGeoVolume&)
               TGeoVolume& operator=(const TGeoVolume&)

Author: Andrei Gheata 30/05/02
Last update: root/geom:$Name: $:$Id: TGeoVolume.cxx,v 1.67 2005/09/06 16:45:48 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *

ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.