00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_TGeoCache
00014 #define ROOT_TGeoCache
00015
00016 #ifndef ROOT_TGeoNode
00017 #include "TGeoNode.h"
00018 #endif
00019
00020
00021 class TGeoManager;
00022 class TGeoHMatrix;
00023
00024
00025
00026
00027
00028
00029
00030 class TGeoCacheState : public TObject
00031 {
00032 protected:
00033 Int_t fCapacity;
00034 Int_t fLevel;
00035 Int_t fNmany;
00036 Int_t fStart;
00037 Int_t fIdBranch[30];
00038 Double_t fPoint[3];
00039 Bool_t fOverlapping;
00040
00041 TGeoNode **fNodeBranch;
00042 TGeoHMatrix **fMatrixBranch;
00043 TGeoHMatrix **fMatPtr;
00044
00045 TGeoCacheState(const TGeoCacheState&);
00046 TGeoCacheState& operator=(const TGeoCacheState&);
00047
00048 public:
00049 TGeoCacheState();
00050 TGeoCacheState(Int_t capacity);
00051 virtual ~TGeoCacheState();
00052
00053 void SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point=0);
00054 Bool_t GetState(Int_t &level, Int_t &nmany, Double_t *point) const;
00055
00056 ClassDef(TGeoCacheState, 4)
00057 };
00058
00059
00060
00061
00062
00063
00064
00065 class TGeoNodeCache : public TObject
00066 {
00067 private:
00068 Int_t fGeoCacheMaxLevels;
00069 Int_t fGeoCacheStackSize;
00070 Int_t fLevel;
00071 Int_t fStackLevel;
00072 Int_t fCurrentID;
00073 Int_t fIndex;
00074 Int_t fIdBranch[100];
00075 TString fPath;
00076 TGeoNode *fTop;
00077 TGeoNode *fNode;
00078 TGeoHMatrix *fMatrix;
00079 TObjArray *fStack;
00080 TGeoHMatrix **fMatrixBranch;
00081 TGeoHMatrix **fMPB;
00082 TGeoNode **fNodeBranch;
00083 Int_t *fNodeIdArray;
00084
00085 protected:
00086 TGeoNodeCache(const TGeoNodeCache&);
00087 TGeoNodeCache& operator=(const TGeoNodeCache&);
00088
00089 public:
00090 TGeoNodeCache();
00091 TGeoNodeCache(TGeoNode *top, Bool_t nodeid=kFALSE, Int_t capacity=30);
00092 virtual ~TGeoNodeCache();
00093
00094 void BuildIdArray();
00095 void CdNode(Int_t nodeid);
00096 Bool_t CdDown(Int_t index);
00097 void CdTop() {fLevel=1; CdUp();}
00098 void CdUp();
00099 void FillIdBranch(const Int_t *br, Int_t startlevel=0) {memcpy(fIdBranch+startlevel,br,(fLevel+1-startlevel)*sizeof(Int_t)); fIndex=fIdBranch[fLevel];}
00100 const Int_t *GetIdBranch() const {return fIdBranch;}
00101 void *GetBranch() const {return fNodeBranch;}
00102 void GetBranchNames(Int_t *names) const;
00103 void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
00104 void GetBranchOnlys(Int_t *isonly) const;
00105 void *GetMatrices() const {return fMatrixBranch;}
00106 TGeoHMatrix *GetCurrentMatrix() const {return fMatrix;}
00107 Int_t GetCurrentNodeId() const;
00108 TGeoNode *GetMother(Int_t up=1) const {return ((fLevel-up)>=0)?fNodeBranch[fLevel-up]:0;}
00109 TGeoHMatrix *GetMotherMatrix(Int_t up=1) const {return ((fLevel-up)>=0)?fMatrixBranch[fLevel-up]:0;}
00110 TGeoNode *GetNode() const {return fNode;}
00111 TGeoNode *GetTopNode() const {return fTop;}
00112 Int_t GetLevel() const {return fLevel;}
00113 const char *GetPath();
00114 Int_t GetStackLevel() const {return fStackLevel;}
00115 Int_t GetNodeId() const;
00116 Bool_t HasIdArray() const {return (fNodeIdArray)?kTRUE:kFALSE;}
00117 Bool_t IsDummy() const {return kTRUE;}
00118
00119 void LocalToMaster(const Double_t *local, Double_t *master) const;
00120 void MasterToLocal(const Double_t *master, Double_t *local) const;
00121 void LocalToMasterVect(const Double_t *local, Double_t *master) const;
00122 void MasterToLocalVect(const Double_t *master, Double_t *local) const;
00123 void LocalToMasterBomb(const Double_t *local, Double_t *master) const;
00124 void MasterToLocalBomb(const Double_t *master, Double_t *local) const;
00125 Int_t PushState(Bool_t ovlp, Int_t ntmany=0, Int_t startlevel=0, Double_t *point=0);
00126 Bool_t PopState(Int_t &nmany, Double_t *point=0);
00127 Bool_t PopState(Int_t &nmany, Int_t level, Double_t *point=0);
00128 void PopDummy(Int_t ipop=9999) {fStackLevel=(ipop>fStackLevel)?(fStackLevel-1):(ipop-1);}
00129 void Refresh() {fNode=fNodeBranch[fLevel]; fMatrix=fMatrixBranch[fLevel];}
00130 Bool_t RestoreState(Int_t &nmany, TGeoCacheState *state, Double_t *point=0);
00131
00132 ClassDef(TGeoNodeCache, 0)
00133 };
00134
00135 #endif
00136
00137