Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-19 10:09:22

0001 // @(#)root/geom:$Id$
0002 // Author: Andrei Gheata   25/10/01
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGeoManager
0013 #define ROOT_TGeoManager
0014 
0015 #include <mutex>
0016 #include <thread>
0017 #include <map>
0018 
0019 #include "TNamed.h"
0020 #include "TObjArray.h"
0021 #include "TGeoNavigator.h"
0022 
0023 // forward declarations
0024 class TVirtualGeoTrack;
0025 class TGeoNode;
0026 class TGeoPhysicalNode;
0027 class TGeoPNEntry;
0028 class TGeoVolume;
0029 class TGeoVolumeMulti;
0030 class TGeoMatrix;
0031 class TGeoHMatrix;
0032 class TGeoMaterial;
0033 class TGeoMedium;
0034 class TGeoShape;
0035 class TVirtualGeoPainter;
0036 class TVirtualGeoChecker;
0037 class THashList;
0038 class TGeoParallelWorld;
0039 class TGeoRegion;
0040 class TGDMLMatrix;
0041 class TGeoOpticalSurface;
0042 class TGeoSkinSurface;
0043 class TGeoBorderSurface;
0044 
0045 class TGeoManager : public TNamed {
0046 public:
0047    enum EDefaultUnits { kG4Units = 0, kRootUnits = 1 };
0048 
0049 protected:
0050    static std::mutex fgMutex;           //! mutex for navigator booking in MT mode
0051    static Bool_t fgLock;                //! Lock preventing a second geometry to be loaded
0052    static Int_t fgVerboseLevel;         //! Verbosity level for Info messages (no IO).
0053    static Int_t fgMaxLevel;             //! Maximum level in geometry
0054    static Int_t fgMaxDaughters;         //! Maximum number of daughters
0055    static Int_t fgMaxXtruVert;          //! Maximum number of Xtru vertices
0056    static UInt_t fgExportPrecision;     //! Precision to be used in ASCII exports
0057    static EDefaultUnits fgDefaultUnits; //! Default units in GDML if not explicit in some tags
0058 
0059    TGeoManager(const TGeoManager &) = delete;
0060    TGeoManager &operator=(const TGeoManager &) = delete;
0061 
0062 private:
0063    Double_t fPhimin;                //! lowest range for phi cut
0064    Double_t fPhimax;                //! highest range for phi cut
0065    Double_t fTmin;                  //! lower time limit for tracks drawing
0066    Double_t fTmax;                  //! upper time limit for tracks drawing
0067    Int_t fNNodes;                   // total number of physical nodes
0068    TString fPath;                   //! path to current node
0069    TString fParticleName;           //! particles to be drawn
0070    Double_t fVisDensity;            // transparency threshold by density
0071    Int_t fExplodedView;             // exploded view mode
0072    Int_t fVisOption;                // global visualization option
0073    Int_t fVisLevel;                 // maximum visualization depth
0074    Int_t fNsegments;                // number of segments to approximate circles
0075    Int_t fNtracks;                  // number of tracks
0076    Int_t fMaxVisNodes;              // maximum number of visible nodes
0077    TVirtualGeoTrack *fCurrentTrack; //! current track
0078    Int_t fNpdg;                     // number of different pdg's stored
0079    Int_t fPdgId[1024];              // pdg conversion table
0080    Bool_t fClosed;                  //! flag that geometry is closed
0081    Bool_t fLoopVolumes;             //! flag volume lists loop
0082    Bool_t fStreamVoxels;            // flag to allow voxelization I/O
0083    Bool_t fIsGeomReading;           //! flag set when reading geometry
0084    Bool_t fIsGeomCleaning;          //! flag to notify that the manager is being destructed
0085    Bool_t fPhiCut;                  // flag for phi cuts
0086    Bool_t fTimeCut;                 // time cut for tracks
0087    Bool_t fDrawExtra;               //! flag that the list of physical nodes has to be drawn
0088    Bool_t fMatrixTransform;         //! flag for using GL matrix
0089    Bool_t fMatrixReflection;        //! flag for GL reflections
0090    Bool_t fActivity;                //! switch ON/OFF volume activity (default OFF - all volumes active))
0091    Bool_t fIsNodeSelectable;        //! flag that nodes are the selected objects in pad rather than volumes
0092    TVirtualGeoPainter *fPainter;    //! current painter
0093    TVirtualGeoChecker *fChecker;    //! current checker
0094 
0095    TObjArray *fMatrices;        //-> list of local transformations
0096    TObjArray *fShapes;          //-> list of shapes
0097    TObjArray *fVolumes;         //-> list of volumes
0098    TObjArray *fPhysicalNodes;   //-> list of physical nodes
0099    TObjArray *fGShapes;         //! list of runtime shapes
0100    TObjArray *fGVolumes;        //! list of runtime volumes
0101    TObjArray *fTracks;          //-> list of tracks attached to geometry
0102    TObjArray *fPdgNames;        //-> list of pdg names for tracks
0103    TObjArray *fGDMLMatrices;    //-> list of matrices read from GDML
0104    TObjArray *fOpticalSurfaces; //-> list of optical surfaces read from GDML
0105    TObjArray *fSkinSurfaces;    //-> list of skin surfaces read from GDML
0106    TObjArray *fBorderSurfaces;  //-> list of border surfaces read from GDML
0107    TList *fMaterials;           //-> list of materials
0108    TList *fMedia;               //-> list of tracking media
0109    TObjArray *fNodes;           //-> current branch of nodes
0110    TObjArray *fOverlaps;        //-> list of geometrical overlaps
0111    TObjArray *fRegions;         //-> list of regions
0112    UChar_t *fBits;              //! bits used for voxelization
0113    // Map of navigator arrays per thread
0114    typedef std::map<std::thread::id, TGeoNavigatorArray *> NavigatorsMap_t;
0115    typedef NavigatorsMap_t::iterator NavigatorsMapIt_t;
0116    typedef std::map<std::thread::id, Int_t> ThreadsMap_t;
0117    typedef ThreadsMap_t::const_iterator ThreadsMapIt_t;
0118    // Map of constant properties
0119    typedef std::map<std::string, Double_t> ConstPropMap_t;
0120 
0121    NavigatorsMap_t fNavigators;      //! Map between thread id's and navigator arrays
0122    static ThreadsMap_t *fgThreadId;  //! Thread id's map
0123    static Int_t fgNumThreads;        //! Number of registered threads
0124    static Bool_t fgLockNavigators;   //! Lock existing navigators
0125    TGeoNavigator *fCurrentNavigator; //! current navigator
0126    TGeoVolume *fCurrentVolume;       //! current volume
0127    TGeoVolume *fTopVolume;           //! top level volume in geometry
0128    TGeoNode *fTopNode;               //! top physical node
0129    TGeoVolume *fMasterVolume;        // master volume
0130    TGeoHMatrix *fGLMatrix;           // matrix to be used for view transformations
0131    TObjArray *fUniqueVolumes;        //-> list of unique volumes
0132    TGeoShape *fClippingShape;        //! clipping shape for raytracing
0133    TGeoElementTable *fElementTable;  //! table of elements
0134 
0135    Int_t fNLevel;                     // maximum accepted level in geometry
0136    TGeoVolume *fPaintVolume;          //! volume currently painted
0137    TGeoVolume *fUserPaintVolume;      //!
0138    THashList *fHashVolumes;           //! hash list of volumes providing fast search
0139    THashList *fHashGVolumes;          //! hash list of group volumes providing fast search
0140    THashList *fHashPNE;               //-> hash list of physical node entries
0141    mutable TObjArray *fArrayPNE;      //! array of physical node entries
0142    Int_t fSizePNEId;                  // size of the array of unique ID's for PN entries
0143    Int_t fNPNEId;                     // number of PN entries having a unique ID
0144    Int_t *fKeyPNEId;                  //[fSizePNEId] array of uid values for PN entries
0145    Int_t *fValuePNEId;                //[fSizePNEId] array of pointers to PN entries with ID's
0146    Int_t fMaxThreads;                 //! Max number of threads
0147    Bool_t fMultiThread;               //! Flag for multi-threading
0148    Int_t fRaytraceMode;               //! Raytrace mode: 0=normal, 1=pass through, 2=transparent
0149    Bool_t fUsePWNav;                  // Activate usage of parallel world in navigation
0150    TGeoParallelWorld *fParallelWorld; // Parallel world
0151    ConstPropMap_t fProperties;        // Map of user-defined constant properties
0152                                       //--- private methods
0153    Bool_t IsLoopingVolumes() const { return fLoopVolumes; }
0154    void Init();
0155    Bool_t InitArrayPNE() const;
0156    Bool_t InsertPNEId(Int_t uid, Int_t ientry);
0157    void SetLoopVolumes(Bool_t flag = kTRUE) { fLoopVolumes = flag; }
0158    void UpdateElements();
0159    void Voxelize(Option_t *option = nullptr);
0160 
0161 public:
0162    // constructors
0163    TGeoManager();
0164    TGeoManager(const char *name, const char *title);
0165    // destructor
0166    ~TGeoManager() override;
0167    //--- adding geometrical objects
0168    Int_t AddMaterial(const TGeoMaterial *material);
0169    Int_t AddOverlap(const TNamed *ovlp);
0170    Int_t AddRegion(TGeoRegion *region);
0171    Int_t AddTransformation(const TGeoMatrix *matrix);
0172    Int_t AddShape(const TGeoShape *shape);
0173    Int_t AddTrack(Int_t id, Int_t pdgcode, TObject *particle = nullptr);
0174    Int_t AddTrack(TVirtualGeoTrack *track);
0175    Int_t AddVolume(TGeoVolume *volume);
0176    TGeoNavigator *AddNavigator();
0177    Bool_t AddProperty(const char *property, Double_t value);
0178    Double_t GetProperty(const char *name, Bool_t *error = nullptr) const;
0179    Double_t GetProperty(size_t i, TString &name, Bool_t *error = nullptr) const;
0180    Int_t GetNproperties() const { return fProperties.size(); }
0181    void ClearOverlaps();
0182    void RegisterMatrix(const TGeoMatrix *matrix);
0183    void SortOverlaps();
0184    //--- browsing and tree navigation
0185    void Browse(TBrowser *b) override;
0186    void SetVisibility(TObject *obj, Bool_t vis);
0187    virtual Bool_t cd(const char *path = ""); // *MENU*
0188    Bool_t CheckPath(const char *path) const;
0189    void CdNode(Int_t nodeid);
0190    void CdDown(Int_t index);
0191    void CdUp();
0192    void CdTop();
0193    void CdNext();
0194    void GetBranchNames(Int_t *names) const;
0195    void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
0196    void GetBranchOnlys(Int_t *isonly) const;
0197    Int_t GetNmany() const { return GetCurrentNavigator()->GetNmany(); }
0198    const char *GetPdgName(Int_t pdg) const;
0199    void SetPdgName(Int_t pdg, const char *name);
0200    Bool_t IsFolder() const override { return kTRUE; }
0201    //--- visualization settings
0202    virtual void Edit(Option_t *option = ""); // *MENU*
0203    void BombTranslation(const Double_t *tr, Double_t *bombtr);
0204    void UnbombTranslation(const Double_t *tr, Double_t *bombtr);
0205    void ClearAttributes(); // *MENU*
0206    void DefaultAngles();   // *MENU*
0207    void DefaultColors();   // *MENU*
0208    TGeoShape *GetClippingShape() const { return fClippingShape; }
0209    Int_t GetNsegments() const;
0210    TVirtualGeoPainter *GetGeomPainter();
0211    TVirtualGeoPainter *GetPainter() const { return fPainter; }
0212    TVirtualGeoChecker *GetGeomChecker();
0213    TVirtualGeoChecker *GetChecker() const { return fChecker; }
0214    Int_t GetBombMode() const { return fExplodedView; }
0215    void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const;
0216    Int_t GetMaxVisNodes() const { return fMaxVisNodes; }
0217    Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const;
0218    Double_t GetTmax() const { return fTmax; }
0219    TGeoVolume *GetPaintVolume() const { return fPaintVolume; }
0220    TGeoVolume *GetUserPaintVolume() const { return fUserPaintVolume; }
0221    Double_t GetVisDensity() const { return fVisDensity; }
0222    Int_t GetVisLevel() const;
0223    Int_t GetVisOption() const;
0224    Bool_t IsInPhiRange() const;
0225    Bool_t IsDrawingExtra() const { return fDrawExtra; }
0226    Bool_t IsNodeSelectable() const { return fIsNodeSelectable; }
0227    Bool_t IsVisLeaves() const { return fVisOption == 1; }
0228    void ModifiedPad() const;
0229    void OptimizeVoxels(const char *filename = "tgeovox.C");                                     // *MENU*
0230    void SetClipping(Bool_t flag = kTRUE) { SetClippingShape(flag ? fClippingShape : nullptr); } // *MENU*
0231    void SetClippingShape(TGeoShape *clip);
0232    void SetExplodedView(Int_t iopt = 0); // *MENU*
0233    void SetPhiRange(Double_t phimin = 0., Double_t phimax = 360.);
0234    void SetNsegments(Int_t nseg); // *MENU*
0235    Bool_t SetCurrentNavigator(Int_t index);
0236    void
0237    SetBombFactors(Double_t bombx = 1.3, Double_t bomby = 1.3, Double_t bombz = 1.3, Double_t bombr = 1.3); // *MENU*
0238    void SetPaintVolume(TGeoVolume *vol) { fPaintVolume = vol; }
0239    void SetUserPaintVolume(TGeoVolume *vol) { fUserPaintVolume = vol; }
0240    void SetTopVisible(Bool_t vis = kTRUE);
0241    void SetTminTmax(Double_t tmin = 0, Double_t tmax = 999);
0242    void SetDrawExtraPaths(Bool_t flag = kTRUE) { fDrawExtra = flag; }
0243    void SetNodeSelectable(Bool_t flag = kTRUE) { fIsNodeSelectable = flag; }
0244    void SetVisDensity(Double_t dens = 0.01); // *MENU*
0245    void SetVisLevel(Int_t level = 3);        // *MENU*
0246    void SetVisOption(Int_t option = 0);
0247    void ViewLeaves(Bool_t flag = kTRUE);                    // *TOGGLE* *GETTER=IsVisLeaves
0248    void SaveAttributes(const char *filename = "tgeoatt.C"); // *MENU*
0249    void RestoreMasterVolume();                              // *MENU*
0250    void SetMaxVisNodes(Int_t maxnodes = 10000);             // *MENU*
0251    //--- geometry checking
0252    void AnimateTracks(Double_t tmin = 0, Double_t tmax = 5E-8, Int_t nframes = 200, Option_t *option = "/*"); // *MENU*
0253    void CheckBoundaryErrors(Int_t ntracks = 1000000, Double_t radius = -1.);                                  // *MENU*
0254    void CheckBoundaryReference(Int_t icheck = -1);
0255    void CheckGeometryFull(Int_t ntracks = 1000000, Double_t vx = 0., Double_t vy = 0., Double_t vz = 0.,
0256                           Option_t *option = "ob"); // *MENU*
0257    void CheckGeometry(Option_t *option = "");
0258    void CheckOverlaps(Double_t ovlp = 0.1, Option_t *option = "");                         // *MENU*
0259    void CheckPoint(Double_t x = 0, Double_t y = 0, Double_t z = 0, Option_t *option = "", Double_t safety = 0.); // *MENU*
0260    void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option);
0261    void ConvertReflections();
0262    void DrawCurrentPoint(Int_t color = 2); // *MENU*
0263    void DrawTracks(Option_t *option = ""); // *MENU*
0264    void SetParticleName(const char *pname) { fParticleName = pname; }
0265    const char *GetParticleName() const { return fParticleName.Data(); }
0266    void DrawPath(const char *path, Option_t *option = "");
0267    void PrintOverlaps() const; // *MENU*
0268    void RandomPoints(const TGeoVolume *vol, Int_t npoints = 10000, Option_t *option = "");
0269    void RandomRays(Int_t nrays = 1000, Double_t startx = 0, Double_t starty = 0, Double_t startz = 0,
0270                    const char *target_vol = nullptr, Bool_t check_norm = kFALSE);
0271    TGeoNode *SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil = 1E-5, const char *g3path = "");
0272    void SetNmeshPoints(Int_t npoints = 1000);
0273    void SetCheckedNode(TGeoNode *node);
0274    void Test(Int_t npoints = 1000000, Option_t *option = "");           // *MENU*
0275    void TestOverlaps(const char *path = "");                            // *MENU*
0276    Double_t Weight(Double_t precision = 0.01, Option_t *option = "va"); // *MENU*
0277 
0278    //--- GEANT3-like geometry creation
0279    TGeoVolume *Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step,
0280                         Int_t numed = 0, Option_t *option = "");
0281    void
0282    Matrix(Int_t index, Double_t theta1, Double_t phi1, Double_t theta2, Double_t phi2, Double_t theta3, Double_t phi3);
0283    TGeoMaterial *Material(const char *name, Double_t a, Double_t z, Double_t dens, Int_t uid, Double_t radlen = 0,
0284                           Double_t intlen = 0);
0285    TGeoMaterial *
0286    Mixture(const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nelem, Float_t *wmat, Int_t uid);
0287    TGeoMaterial *
0288    Mixture(const char *name, Double_t *a, Double_t *z, Double_t dens, Int_t nelem, Double_t *wmat, Int_t uid);
0289    TGeoMedium *Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm,
0290                       Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin);
0291    void Node(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
0292              Bool_t isOnly, Float_t *upar, Int_t npar = 0);
0293    void Node(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
0294              Bool_t isOnly, Double_t *upar, Int_t npar = 0);
0295    TGeoVolume *Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar = 0);
0296    TGeoVolume *Volume(const char *name, const char *shape, Int_t nmed, Double_t *upar, Int_t npar = 0);
0297    void SetVolumeAttribute(const char *name, const char *att, Int_t val);
0298    //--- geometry building
0299    void BuildDefaultMaterials();
0300    void CloseGeometry(Option_t *option = "d");
0301    Bool_t IsClosed() const { return fClosed; }
0302    TGeoVolume *MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices = nullptr);
0303    TGeoVolume *MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz);
0304    TGeoVolume *MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1,
0305                         Double_t rmin2, Double_t rmax2);
0306    TGeoVolume *MakeCons(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1,
0307                         Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2);
0308    TGeoVolume *MakeCtub(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1,
0309                         Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz);
0310    TGeoVolume *MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz);
0311    TGeoVolume *MakeGtra(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t twist,
0312                         Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
0313                         Double_t tl2, Double_t alpha2);
0314    TGeoVolume *MakePara(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz, Double_t alpha,
0315                         Double_t theta, Double_t phi);
0316    TGeoVolume *MakePcon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nz);
0317    TGeoVolume *MakeParaboloid(const char *name, TGeoMedium *medium, Double_t rlo, Double_t rhi, Double_t dz);
0318    TGeoVolume *MakeHype(const char *name, TGeoMedium *medium, Double_t rin, Double_t stin, Double_t rout,
0319                         Double_t stout, Double_t dz);
0320    TGeoVolume *MakePgon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nedges, Int_t nz);
0321    TGeoVolume *MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin = 0,
0322                           Double_t themax = 180, Double_t phimin = 0, Double_t phimax = 360);
0323    TGeoVolume *MakeTorus(const char *name, TGeoMedium *medium, Double_t r, Double_t rmin, Double_t rmax,
0324                          Double_t phi1 = 0, Double_t dphi = 360);
0325    TGeoVolume *MakeTrap(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t h1,
0326                         Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2,
0327                         Double_t alpha2);
0328    TGeoVolume *MakeTrd1(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy, Double_t dz);
0329    TGeoVolume *
0330    MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz);
0331    TGeoVolume *MakeTube(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz);
0332    TGeoVolume *MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1,
0333                         Double_t phi2);
0334    TGeoVolume *MakeXtru(const char *name, TGeoMedium *medium, Int_t nz);
0335 
0336    TGeoPNEntry *SetAlignableEntry(const char *unique_name, const char *path, Int_t uid = -1);
0337    TGeoPNEntry *GetAlignableEntry(const char *name) const;
0338    TGeoPNEntry *GetAlignableEntry(Int_t index) const;
0339    TGeoPNEntry *GetAlignableEntryByUID(Int_t uid) const;
0340    Int_t GetNAlignable(Bool_t with_uid = kFALSE) const;
0341    TGeoPhysicalNode *MakeAlignablePN(const char *name);
0342    TGeoPhysicalNode *MakeAlignablePN(TGeoPNEntry *entry);
0343    TGeoPhysicalNode *MakePhysicalNode(const char *path = nullptr);
0344    void ClearPhysicalNodes(Bool_t mustdelete = kFALSE);
0345    void RefreshPhysicalNodes(Bool_t lock = kTRUE);
0346    TVirtualGeoTrack *MakeTrack(Int_t id, Int_t pdgcode, TObject *particle);
0347    TGeoVolumeAssembly *MakeVolumeAssembly(const char *name);
0348    TGeoVolumeMulti *MakeVolumeMulti(const char *name, TGeoMedium *medium);
0349    void SetTopVolume(TGeoVolume *vol);
0350 
0351    //--- geometry queries
0352    TGeoNode *CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode);
0353    TGeoNode *FindNextBoundary(Double_t stepmax = TGeoShape::Big(), const char *path = "", Bool_t frombdr = kFALSE);
0354    TGeoNode *FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix = kFALSE);
0355    TGeoNode *FindNextBoundaryAndStep(Double_t stepmax = TGeoShape::Big(), Bool_t compsafe = kFALSE);
0356    TGeoNode *FindNode(Bool_t safe_start = kTRUE);
0357    TGeoNode *FindNode(Double_t x, Double_t y, Double_t z);
0358    Double_t *FindNormal(Bool_t forward = kTRUE);
0359    Double_t *FindNormalFast();
0360    TGeoNode *InitTrack(const Double_t *point, const Double_t *dir);
0361    TGeoNode *InitTrack(Double_t x, Double_t y, Double_t z, Double_t nx, Double_t ny, Double_t nz);
0362    void ResetState();
0363    Double_t Safety(Bool_t inside = kFALSE);
0364    TGeoNode *SearchNode(Bool_t downwards = kFALSE, const TGeoNode *skipnode = nullptr);
0365    TGeoNode *Step(Bool_t is_geom = kTRUE, Bool_t cross = kTRUE);
0366    void DisableInactiveVolumes() { fActivity = kTRUE; }
0367    void EnableInactiveVolumes() { fActivity = kFALSE; }
0368    void SetCurrentTrack(Int_t i) { fCurrentTrack = (TVirtualGeoTrack *)fTracks->At(i); }
0369    void SetCurrentTrack(TVirtualGeoTrack *track) { fCurrentTrack = track; }
0370    Int_t GetNtracks() const { return fNtracks; }
0371    TVirtualGeoTrack *GetCurrentTrack() { return fCurrentTrack; }
0372    TVirtualGeoTrack *GetLastTrack()
0373    {
0374       return (TVirtualGeoTrack *)((fNtracks > 0) ? fTracks->At(fNtracks - 1) : nullptr);
0375    }
0376    const Double_t *GetLastPoint() const { return GetCurrentNavigator()->GetLastPoint(); }
0377    TVirtualGeoTrack *GetTrack(Int_t index)
0378    {
0379       return (index < fNtracks) ? (TVirtualGeoTrack *)fTracks->At(index) : nullptr;
0380    }
0381    Int_t GetTrackIndex(Int_t id) const;
0382    TVirtualGeoTrack *GetTrackOfId(Int_t id) const;
0383    TVirtualGeoTrack *FindTrackWithId(Int_t id) const;
0384    TVirtualGeoTrack *GetParentTrackOfId(Int_t id) const;
0385    Int_t GetVirtualLevel();
0386    Bool_t GotoSafeLevel();
0387    Int_t GetSafeLevel() const;
0388    Double_t GetSafeDistance() const { return GetCurrentNavigator()->GetSafeDistance(); }
0389    Double_t GetLastSafety() const { return GetCurrentNavigator()->GetLastSafety(); }
0390    Double_t GetStep() const { return GetCurrentNavigator()->GetStep(); }
0391    void InspectState() const;
0392    Bool_t IsAnimatingTracks() const { return fIsGeomReading; }
0393    Bool_t IsCheckingOverlaps() const { return GetCurrentNavigator()->IsCheckingOverlaps(); }
0394    Bool_t IsMatrixTransform() const { return fMatrixTransform; }
0395    Bool_t IsMatrixReflection() const { return fMatrixReflection; }
0396    Bool_t IsSameLocation(Double_t x, Double_t y, Double_t z, Bool_t change = kFALSE);
0397    Bool_t IsSameLocation() const { return GetCurrentNavigator()->IsSameLocation(); }
0398    Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const;
0399    Bool_t IsStartSafe() const { return GetCurrentNavigator()->IsStartSafe(); }
0400    void SetCheckingOverlaps(Bool_t flag = kTRUE) { GetCurrentNavigator()->SetCheckingOverlaps(flag); }
0401    void SetStartSafe(Bool_t flag = kTRUE) { GetCurrentNavigator()->SetStartSafe(flag); }
0402    void SetMatrixTransform(Bool_t on = kTRUE) { fMatrixTransform = on; }
0403    void SetMatrixReflection(Bool_t flag = kTRUE) { fMatrixReflection = flag; }
0404    void SetStep(Double_t step) { GetCurrentNavigator()->SetStep(step); }
0405    Bool_t IsCurrentOverlapping() const { return GetCurrentNavigator()->IsCurrentOverlapping(); }
0406    Bool_t IsEntering() const { return GetCurrentNavigator()->IsEntering(); }
0407    Bool_t IsExiting() const { return GetCurrentNavigator()->IsExiting(); }
0408    Bool_t IsStepEntering() const { return GetCurrentNavigator()->IsStepEntering(); }
0409    Bool_t IsStepExiting() const { return GetCurrentNavigator()->IsStepExiting(); }
0410    Bool_t IsOutside() const { return GetCurrentNavigator()->IsOutside(); }
0411    Bool_t IsOnBoundary() const { return GetCurrentNavigator()->IsOnBoundary(); }
0412    Bool_t IsNullStep() const { return GetCurrentNavigator()->IsNullStep(); }
0413    Bool_t IsActivityEnabled() const { return fActivity; }
0414    void SetOutside(Bool_t flag = kTRUE) { GetCurrentNavigator()->SetOutside(flag); }
0415 
0416    //--- cleaning
0417    void CleanGarbage();
0418    void ClearShape(const TGeoShape *shape);
0419    void ClearTracks()
0420    {
0421       fTracks->Delete();
0422       fNtracks = 0;
0423    }
0424    void ClearNavigators();
0425    void RemoveMaterial(Int_t index);
0426    void RemoveNavigator(const TGeoNavigator *nav);
0427    void ResetUserData();
0428 
0429    //--- utilities
0430    Int_t CountNodes(const TGeoVolume *vol = nullptr, Int_t nlevels = 10000, Int_t option = 0);
0431    void CountLevels();
0432    void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0433    static Int_t Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3);
0434    Int_t ReplaceVolume(TGeoVolume *vorig, TGeoVolume *vnew);
0435    Int_t TransformVolumeToAssembly(const char *vname);
0436    UChar_t *GetBits() { return fBits; }
0437    virtual Int_t GetByteCount(Option_t *option = nullptr);
0438    void SetAllIndex();
0439    static Int_t GetMaxDaughters();
0440    static Int_t GetMaxLevels();
0441    static Int_t GetMaxXtruVert();
0442    Int_t GetMaxThreads() const { return fMaxThreads - 1; }
0443    void SetMaxThreads(Int_t nthreads);
0444    Int_t GetRTmode() const { return fRaytraceMode; }
0445    void SetRTmode(Int_t mode); // *MENU*
0446    Bool_t IsMultiThread() const { return fMultiThread; }
0447    static void SetNavigatorsLock(Bool_t flag);
0448    static Int_t ThreadId();
0449    static Int_t GetNumThreads();
0450    static void ClearThreadsMap();
0451    void ClearThreadData() const;
0452    void CreateThreadData() const;
0453 
0454    //--- I/O
0455    virtual Int_t Export(const char *filename, const char *name = "", Option_t *option = "vg");
0456    static void LockGeometry();
0457    static void UnlockGeometry();
0458    static Int_t GetVerboseLevel();
0459    static void SetVerboseLevel(Int_t vl);
0460    static TGeoManager *Import(const char *filename, const char *name = "", Option_t *option = "");
0461    static Bool_t IsLocked();
0462    static void SetExportPrecision(UInt_t prec);
0463    static UInt_t GetExportPrecision();
0464    static void SetDefaultUnits(EDefaultUnits new_value);
0465    static EDefaultUnits GetDefaultUnits();
0466    static Bool_t LockDefaultUnits(Bool_t new_value);
0467    Bool_t IsStreamingVoxels() const { return fStreamVoxels; }
0468    Bool_t IsCleaning() const { return fIsGeomCleaning; }
0469 
0470    //--- list getters
0471    TObjArray *GetListOfNodes() { return fNodes; }
0472    TObjArray *GetListOfPhysicalNodes() { return fPhysicalNodes; }
0473    TObjArray *GetListOfOverlaps() { return fOverlaps; }
0474    TObjArray *GetListOfMatrices() const { return fMatrices; }
0475    TList *GetListOfMaterials() const { return fMaterials; }
0476    TList *GetListOfMedia() const { return fMedia; }
0477    TObjArray *GetListOfVolumes() const { return fVolumes; }
0478    TObjArray *GetListOfGVolumes() const { return fGVolumes; }
0479    TObjArray *GetListOfShapes() const { return fShapes; }
0480    TObjArray *GetListOfGShapes() const { return fGShapes; }
0481    TObjArray *GetListOfUVolumes() const { return fUniqueVolumes; }
0482    TObjArray *GetListOfTracks() const { return fTracks; }
0483    TObjArray *GetListOfGDMLMatrices() const { return fGDMLMatrices; }
0484    TObjArray *GetListOfOpticalSurfaces() const { return fOpticalSurfaces; }
0485    TObjArray *GetListOfSkinSurfaces() const { return fSkinSurfaces; }
0486    TObjArray *GetListOfBorderSurfaces() const { return fBorderSurfaces; }
0487    TObjArray *GetListOfRegions() const { return fRegions; }
0488    TGeoNavigatorArray *GetListOfNavigators() const;
0489    TGeoElementTable *GetElementTable();
0490 
0491    //--- modeler state getters/setters
0492    void DoBackupState();
0493    void DoRestoreState();
0494    TGeoNode *GetNode(Int_t level) const { return (TGeoNode *)fNodes->UncheckedAt(level); }
0495    Int_t GetNodeId() const { return GetCurrentNavigator()->GetNodeId(); }
0496    TGeoNode *GetNextNode() const { return GetCurrentNavigator()->GetNextNode(); }
0497    TGeoNode *GetMother(Int_t up = 1) const { return GetCurrentNavigator()->GetMother(up); }
0498    TGeoHMatrix *GetMotherMatrix(Int_t up = 1) const { return GetCurrentNavigator()->GetMotherMatrix(up); }
0499    TGeoHMatrix *GetHMatrix();
0500    TGeoHMatrix *GetCurrentMatrix() const { return GetCurrentNavigator()->GetCurrentMatrix(); }
0501    TGeoHMatrix *GetGLMatrix() const { return fGLMatrix; }
0502    TGeoNavigator *GetCurrentNavigator() const;
0503    TGeoNode *GetCurrentNode() const { return GetCurrentNavigator()->GetCurrentNode(); }
0504    Int_t GetCurrentNodeId() const;
0505    const Double_t *GetCurrentPoint() const { return GetCurrentNavigator()->GetCurrentPoint(); }
0506    const Double_t *GetCurrentDirection() const { return GetCurrentNavigator()->GetCurrentDirection(); }
0507    TGeoVolume *GetCurrentVolume() const { return GetCurrentNavigator()->GetCurrentVolume(); }
0508    const Double_t *GetCldirChecked() const { return GetCurrentNavigator()->GetCldirChecked(); }
0509    const Double_t *GetCldir() const { return GetCurrentNavigator()->GetCldir(); }
0510    const Double_t *GetNormal() const { return GetCurrentNavigator()->GetNormal(); }
0511    Int_t GetLevel() const { return GetCurrentNavigator()->GetLevel(); }
0512    Int_t GetMaxLevel() const { return fNLevel; }
0513    const char *GetPath() const;
0514    Int_t GetStackLevel() const { return GetCurrentNavigator()->GetStackLevel(); }
0515    TGeoVolume *GetMasterVolume() const { return fMasterVolume; }
0516    TGeoVolume *GetTopVolume() const { return fTopVolume; }
0517    TGeoNode *GetTopNode() const { return fTopNode; }
0518    TGeoPhysicalNode *GetPhysicalNode(Int_t i) const { return (TGeoPhysicalNode *)fPhysicalNodes->UncheckedAt(i); }
0519    void SetCurrentPoint(Double_t *point) { GetCurrentNavigator()->SetCurrentPoint(point); }
0520    void SetCurrentPoint(Double_t x, Double_t y, Double_t z) { GetCurrentNavigator()->SetCurrentPoint(x, y, z); }
0521    void SetLastPoint(Double_t x, Double_t y, Double_t z) { GetCurrentNavigator()->SetLastPoint(x, y, z); }
0522    void SetCurrentDirection(Double_t *dir) { GetCurrentNavigator()->SetCurrentDirection(dir); }
0523    void SetCurrentDirection(Double_t nx, Double_t ny, Double_t nz)
0524    {
0525       GetCurrentNavigator()->SetCurrentDirection(nx, ny, nz);
0526    }
0527    void SetCldirChecked(Double_t *dir) { GetCurrentNavigator()->SetCldirChecked(dir); }
0528 
0529    //--- point/vector reference frame conversion
0530    void LocalToMaster(const Double_t *local, Double_t *master) const
0531    {
0532       GetCurrentNavigator()->LocalToMaster(local, master);
0533    }
0534    void LocalToMasterVect(const Double_t *local, Double_t *master) const
0535    {
0536       GetCurrentNavigator()->LocalToMasterVect(local, master);
0537    }
0538    void LocalToMasterBomb(const Double_t *local, Double_t *master) const
0539    {
0540       GetCurrentNavigator()->LocalToMasterBomb(local, master);
0541    }
0542    void MasterToLocal(const Double_t *master, Double_t *local) const
0543    {
0544       GetCurrentNavigator()->MasterToLocal(master, local);
0545    }
0546    void MasterToLocalVect(const Double_t *master, Double_t *local) const
0547    {
0548       GetCurrentNavigator()->MasterToLocalVect(master, local);
0549    }
0550    void MasterToLocalBomb(const Double_t *master, Double_t *local) const
0551    {
0552       GetCurrentNavigator()->MasterToLocalBomb(master, local);
0553    }
0554    void MasterToTop(const Double_t *master, Double_t *top) const;
0555    void TopToMaster(const Double_t *top, Double_t *master) const;
0556 
0557    //--- general use getters/setters
0558    TGeoMaterial *FindDuplicateMaterial(const TGeoMaterial *mat) const;
0559    TGeoVolume *FindVolumeFast(const char *name, Bool_t multi = kFALSE);
0560    TGeoMaterial *GetMaterial(const char *matname) const;
0561    TGeoMaterial *GetMaterial(Int_t id) const;
0562    TGeoMedium *GetMedium(const char *medium) const;
0563    TGeoMedium *GetMedium(Int_t numed) const;
0564    Int_t GetMaterialIndex(const char *matname) const;
0565 
0566    //--- GDML object accessors
0567    TGDMLMatrix *GetGDMLMatrix(const char *name) const;
0568    void AddGDMLMatrix(TGDMLMatrix *mat);
0569    TGeoOpticalSurface *GetOpticalSurface(const char *name) const;
0570    void AddOpticalSurface(TGeoOpticalSurface *optsurf);
0571    TGeoSkinSurface *GetSkinSurface(const char *name) const;
0572    void AddSkinSurface(TGeoSkinSurface *surf);
0573    TGeoBorderSurface *GetBorderSurface(const char *name) const;
0574    void AddBorderSurface(TGeoBorderSurface *surf);
0575 
0576    //   TGeoShape             *GetShape(const char *name) const;
0577    TGeoVolume *GetVolume(const char *name) const;
0578    TGeoVolume *GetVolume(Int_t uid) const { return (TGeoVolume *)fUniqueVolumes->At(uid); }
0579    int GetNregions() const { return fRegions->GetEntriesFast(); }
0580    TGeoRegion *GetRegion(int i) { return (TGeoRegion *)fRegions->At(i); }
0581    Int_t GetUID(const char *volname) const;
0582    Int_t GetNNodes()
0583    {
0584       if (!fNNodes)
0585          CountNodes();
0586       return fNNodes;
0587    }
0588    TGeoNodeCache *GetCache() const { return GetCurrentNavigator()->GetCache(); }
0589    //   void                   SetCache(const TGeoNodeCache *cache) {fCache = (TGeoNodeCache*)cache;}
0590    void SetAnimateTracks(Bool_t flag = kTRUE) { fIsGeomReading = flag; }
0591    virtual ULong_t SizeOf(const TGeoNode *node, Option_t *option); // size of the geometry in memory
0592    void SelectTrackingMedia();
0593 
0594    //--- stack manipulation
0595    Int_t PushPath(Int_t startlevel = 0) { return GetCurrentNavigator()->PushPath(startlevel); }
0596    Bool_t PopPath() { return GetCurrentNavigator()->PopPath(); }
0597    Bool_t PopPath(Int_t index) { return GetCurrentNavigator()->PopPath(index); }
0598    Int_t PushPoint(Int_t startlevel = 0) { return GetCurrentNavigator()->PushPoint(startlevel); }
0599    Bool_t PopPoint() { return GetCurrentNavigator()->PopPoint(); }
0600    Bool_t PopPoint(Int_t index) { return GetCurrentNavigator()->PopPoint(index); }
0601    void PopDummy(Int_t ipop = 9999) { return GetCurrentNavigator()->PopDummy(ipop); }
0602 
0603    //--- parallel world navigation
0604    TGeoParallelWorld *CreateParallelWorld(const char *name);
0605    TGeoParallelWorld *GetParallelWorld() const { return fParallelWorld; }
0606    void SetUseParallelWorldNav(Bool_t flag);
0607    Bool_t IsParallelWorldNav() const { return fUsePWNav; }
0608 
0609    ClassDefOverride(TGeoManager, 17) // geometry manager
0610 };
0611 
0612 R__EXTERN TGeoManager *gGeoManager;
0613 
0614 #endif