Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:50

0001 // @(#)root/geom:$Id$
0002 // Author: Andrei Gheata   18/03/02
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 // Author : Andrei Gheata -           date Wed 12 Dec 2001 09:45:08 AM CET
0012 
0013 #ifndef ROOT_TGeoCache
0014 #define ROOT_TGeoCache
0015 
0016 #include "TGeoNode.h"
0017 
0018 #ifdef R__LESS_INCLUDES
0019 struct TGeoStateInfo;
0020 #else
0021 #include "TGeoStateInfo.h"
0022 #endif
0023 
0024 // forward declarations
0025 class TGeoManager;
0026 class TGeoHMatrix;
0027 
0028 class TGeoCacheState : public TObject {
0029 protected:
0030    Int_t fCapacity;     // maximum level stored
0031    Int_t fLevel;        // level in the current branch
0032    Int_t fNmany;        // number of overlapping nodes on current branch
0033    Int_t fStart;        // start level
0034    Int_t fIdBranch[30]; // ID branch
0035    Double_t fPoint[3];  // last point in master frame
0036    Bool_t fOverlapping; // overlap flag
0037 
0038    TGeoNode **fNodeBranch;      // last node branch stored
0039    TGeoHMatrix **fMatrixBranch; // global matrices for last branch
0040    TGeoHMatrix **fMatPtr;       // array of matrix pointers
0041 
0042    TGeoCacheState(const TGeoCacheState &);
0043    TGeoCacheState &operator=(const TGeoCacheState &);
0044 
0045 public:
0046    TGeoCacheState();
0047    TGeoCacheState(Int_t capacity);
0048    ~TGeoCacheState() override;
0049 
0050    void SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point = nullptr);
0051    Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const;
0052 
0053    ClassDefOverride(TGeoCacheState, 0) // class storing the cache state
0054 };
0055 
0056 class TGeoNodeCache : public TObject {
0057 private:
0058    Int_t fGeoCacheMaxLevels;    // maximum supported number of levels
0059    Int_t fGeoCacheStackSize;    // maximum size of the stack
0060    Int_t fGeoInfoStackSize;     // maximum size of the stack of info states
0061    Int_t fLevel;                // level in the current branch
0062    Int_t fStackLevel;           // current level in the stack
0063    Int_t fInfoLevel;            // current level in the stack
0064    Int_t fCurrentID;            // unique ID of current node
0065    Int_t fIndex;                // index in array of ID's
0066    Int_t fIdBranch[100];        // current branch of indices
0067    TString fPath;               // path for current branch
0068    TGeoNode *fTop;              // top node
0069    TGeoNode *fNode;             //! current node
0070    TGeoHMatrix *fMatrix;        //! current matrix
0071    TObjArray *fStack;           // stack of cache states
0072    TGeoHMatrix **fMatrixBranch; // current branch of global matrices
0073    TGeoHMatrix **fMPB;          // pre-built matrices
0074    TGeoNode **fNodeBranch;      // current branch of nodes
0075    TGeoStateInfo **fInfoBranch; // current branch of nodes
0076    TGeoStateInfo *fPWInfo;      //! State info for the parallel world
0077    Int_t *fNodeIdArray;         //! array of node id's
0078 
0079    TGeoNodeCache(const TGeoNodeCache &) = delete;
0080    TGeoNodeCache &operator=(const TGeoNodeCache &) = delete;
0081 
0082 public:
0083    TGeoNodeCache();
0084    TGeoNodeCache(TGeoNode *top, Bool_t nodeid = kFALSE, Int_t capacity = 30);
0085    ~TGeoNodeCache() override;
0086 
0087    void BuildIdArray();
0088    void BuildInfoBranch();
0089    void CdNode(Int_t nodeid);
0090    Bool_t CdDown(Int_t index);
0091    Bool_t CdDown(TGeoNode *node);
0092    void CdTop()
0093    {
0094       fLevel = 1;
0095       CdUp();
0096    }
0097    void CdUp();
0098    void FillIdBranch(const Int_t *br, Int_t startlevel = 0)
0099    {
0100       memcpy(fIdBranch + startlevel, br, (fLevel + 1 - startlevel) * sizeof(Int_t));
0101       fIndex = fIdBranch[fLevel];
0102    }
0103    const Int_t *GetIdBranch() const { return fIdBranch; }
0104    void *GetBranch() const { return fNodeBranch; }
0105    void GetBranchNames(Int_t *names) const;
0106    void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
0107    void GetBranchOnlys(Int_t *isonly) const;
0108    void *GetMatrices() const { return fMatrixBranch; }
0109    TGeoHMatrix *GetCurrentMatrix() const { return fMatrix; }
0110    Int_t GetCurrentNodeId() const;
0111    TGeoNode *GetMother(Int_t up = 1) const { return ((fLevel - up) >= 0) ? fNodeBranch[fLevel - up] : nullptr; }
0112    TGeoHMatrix *GetMotherMatrix(Int_t up = 1) const
0113    {
0114       return ((fLevel - up) >= 0) ? fMatrixBranch[fLevel - up] : nullptr;
0115    }
0116    TGeoNode *GetNode() const { return fNode; }
0117    TGeoNode *GetTopNode() const { return fTop; }
0118    TGeoStateInfo *GetInfo();
0119    TGeoStateInfo *GetMakePWInfo(Int_t nd);
0120    void ReleaseInfo();
0121    Int_t GetLevel() const { return fLevel; }
0122    const char *GetPath();
0123    Int_t GetStackLevel() const { return fStackLevel; }
0124    Int_t GetNodeId() const;
0125    Bool_t HasIdArray() const { return fNodeIdArray ? kTRUE : kFALSE; }
0126    Bool_t IsDummy() const { return kTRUE; }
0127 
0128    void LocalToMaster(const Double_t *local, Double_t *master) const;
0129    void MasterToLocal(const Double_t *master, Double_t *local) const;
0130    void LocalToMasterVect(const Double_t *local, Double_t *master) const;
0131    void MasterToLocalVect(const Double_t *master, Double_t *local) const;
0132    void LocalToMasterBomb(const Double_t *local, Double_t *master) const;
0133    void MasterToLocalBomb(const Double_t *master, Double_t *local) const;
0134    Int_t PushState(Bool_t ovlp, Int_t ntmany = 0, Int_t startlevel = 0, Double_t *point = nullptr);
0135    Bool_t PopState(Int_t &nmany, Double_t *point = nullptr);
0136    Bool_t PopState(Int_t &nmany, Int_t level, Double_t *point = nullptr);
0137    void PopDummy(Int_t ipop = 9999) { fStackLevel = (ipop > fStackLevel) ? (fStackLevel - 1) : (ipop - 1); }
0138    void Refresh()
0139    {
0140       fNode = fNodeBranch[fLevel];
0141       fMatrix = fMatrixBranch[fLevel];
0142    }
0143    Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point = nullptr);
0144 
0145    ClassDefOverride(TGeoNodeCache, 0) // cache of reusable physical nodes
0146 };
0147 
0148 #endif