00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGeoNavigator
00013 #define ROOT_TGeoNavigator
00014
00015 #ifndef ROOT_TObject
00016 #include "TObject.h"
00017 #endif
00018
00019 #ifndef ROOT_TGeoNodeCache
00020 #include "TGeoCache.h"
00021 #endif
00022
00023
00024
00025
00026
00027
00028
00029
00030 class TGeoManager;
00031 class TGeoNode;
00032 class TGeoVolume;
00033 class TGeoMatrix;
00034 class TGeoHMatrix;
00035
00036
00037 class TGeoNavigator : public TObject
00038 {
00039
00040 protected:
00041 TGeoNavigator(const TGeoNavigator&);
00042 TGeoNavigator& operator=(const TGeoNavigator&);
00043 TGeoNode *FindInCluster(Int_t *cluster, Int_t nc);
00044 Int_t GetTouchedCluster(Int_t start, Double_t *point, Int_t *check_list,
00045 Int_t ncheck, Int_t *result);
00046 TGeoNode *CrossDivisionCell();
00047 void SafetyOverlaps();
00048
00049 private :
00050 Double_t fStep;
00051 Double_t fSafety;
00052 Double_t fLastSafety;
00053 Double_t fNormal[3];
00054 Double_t fCldir[3];
00055 Double_t fCldirChecked[3];
00056 Double_t fPoint[3];
00057 Double_t fDirection[3];
00058 Double_t fLastPoint[3];
00059 Int_t fLevel;
00060 Int_t fNmany;
00061 Int_t fNextDaughterIndex;
00062 Int_t fOverlapSize;
00063 Int_t fOverlapMark;
00064 Int_t *fOverlapClusters;
00065 Bool_t fSearchOverlaps;
00066 Bool_t fCurrentOverlapping;
00067 Bool_t fStartSafe;
00068 Bool_t fIsEntering;
00069 Bool_t fIsExiting;
00070 Bool_t fIsStepEntering;
00071 Bool_t fIsStepExiting;
00072 Bool_t fIsOutside;
00073 Bool_t fIsOnBoundary;
00074 Bool_t fIsSameLocation;
00075 Bool_t fIsNullStep;
00076 TGeoManager *fGeometry;
00077 TGeoNodeCache *fCache;
00078 TGeoVolume *fCurrentVolume;
00079 TGeoNode *fCurrentNode;
00080 TGeoNode *fTopNode;
00081 TGeoNode *fLastNode;
00082 TGeoNode *fNextNode;
00083 TGeoNode *fForcedNode;
00084 TGeoCacheState *fBackupState;
00085 TGeoHMatrix *fCurrentMatrix;
00086 TGeoHMatrix *fGlobalMatrix;
00087 TString fPath;
00088
00089 public :
00090 TGeoNavigator();
00091 TGeoNavigator(TGeoManager* geom);
00092 virtual ~TGeoNavigator();
00093
00094 void BuildCache(Bool_t dummy=kFALSE, Bool_t nodeid=kFALSE);
00095 Bool_t cd(const char *path="");
00096 Bool_t CheckPath(const char *path) const;
00097 void CdNode(Int_t nodeid);
00098 void CdDown(Int_t index);
00099 void CdUp();
00100 void CdTop();
00101 void CdNext();
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 Int_t GetNmany() const {return fNmany;}
00106
00107 TGeoNode *CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode);
00108 TGeoNode *FindNextBoundary(Double_t stepmax=TGeoShape::Big(),const char *path="", Bool_t frombdr=kFALSE);
00109 TGeoNode *FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE);
00110 TGeoNode *FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE);
00111 TGeoNode *FindNode(Bool_t safe_start=kTRUE);
00112 TGeoNode *FindNode(Double_t x, Double_t y, Double_t z);
00113 Double_t *FindNormal(Bool_t forward=kTRUE);
00114 Double_t *FindNormalFast();
00115 TGeoNode *InitTrack(const Double_t *point, const Double_t *dir);
00116 TGeoNode *InitTrack(Double_t x, Double_t y, Double_t z, Double_t nx, Double_t ny, Double_t nz);
00117 void ResetState();
00118 void ResetAll();
00119 Double_t Safety(Bool_t inside=kFALSE);
00120 TGeoNode *SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=0);
00121 TGeoNode *Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE);
00122 const Double_t *GetLastPoint() const {return fLastPoint;}
00123 Int_t GetVirtualLevel();
00124 Bool_t GotoSafeLevel();
00125 Int_t GetSafeLevel() const;
00126 Double_t GetSafeDistance() const {return fSafety;}
00127 Double_t GetLastSafety() const {return fLastSafety;}
00128 Double_t GetStep() const {return fStep;}
00129 void InspectState() const;
00130 Bool_t IsSafeStep(Double_t proposed, Double_t &newsafety) const;
00131 Bool_t IsSameLocation(Double_t x, Double_t y, Double_t z, Bool_t change=kFALSE);
00132 Bool_t IsSameLocation() const {return fIsSameLocation;}
00133 Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const;
00134 Bool_t IsStartSafe() const {return fStartSafe;}
00135 void SetStartSafe(Bool_t flag=kTRUE) {fStartSafe=flag;}
00136 void SetStep(Double_t step) {fStep=step;}
00137 Bool_t IsCheckingOverlaps() const {return fSearchOverlaps;}
00138 Bool_t IsCurrentOverlapping() const {return fCurrentOverlapping;}
00139 Bool_t IsEntering() const {return fIsEntering;}
00140 Bool_t IsExiting() const {return fIsExiting;}
00141 Bool_t IsStepEntering() const {return fIsStepEntering;}
00142 Bool_t IsStepExiting() const {return fIsStepExiting;}
00143 Bool_t IsOutside() const {return fIsOutside;}
00144 Bool_t IsOnBoundary() const {return fIsOnBoundary;}
00145 Bool_t IsNullStep() const {return fIsNullStep;}
00146 void SetCheckingOverlaps(Bool_t flag=kTRUE) {fSearchOverlaps = flag;}
00147 void SetOutside(Bool_t flag=kTRUE) {fIsOutside = flag;}
00148
00149 void DoBackupState();
00150 void DoRestoreState();
00151 Int_t GetNodeId() const {return fCache->GetNodeId();}
00152 TGeoNode *GetNextNode() const {return fNextNode;}
00153 TGeoNode *GetMother(Int_t up=1) const {return fCache->GetMother(up);}
00154 TGeoHMatrix *GetMotherMatrix(Int_t up=1) const {return fCache->GetMotherMatrix(up);}
00155 TGeoHMatrix *GetHMatrix();
00156 TGeoHMatrix *GetCurrentMatrix() const {return fCache->GetCurrentMatrix();}
00157 TGeoNode *GetCurrentNode() const {return fCurrentNode;}
00158 Int_t GetCurrentNodeId() const {return fCache->GetCurrentNodeId();}
00159 const Double_t *GetCurrentPoint() const {return fPoint;}
00160 const Double_t *GetCurrentDirection() const {return fDirection;}
00161 TGeoVolume *GetCurrentVolume() const {return fCurrentNode->GetVolume();}
00162 const Double_t *GetCldirChecked() const {return fCldirChecked;}
00163 const Double_t *GetCldir() const {return fCldir;}
00164
00165 const Double_t *GetNormal() const {return fNormal;}
00166 Int_t GetLevel() const {return fLevel;}
00167 const char *GetPath() const;
00168 Int_t GetStackLevel() const {return fCache->GetStackLevel();}
00169 void SetCurrentPoint(const Double_t *point) {memcpy(fPoint,point,3*sizeof(Double_t));}
00170 void SetCurrentPoint(Double_t x, Double_t y, Double_t z) {
00171 fPoint[0]=x; fPoint[1]=y; fPoint[2]=z;}
00172 void SetLastPoint(Double_t x, Double_t y, Double_t z) {
00173 fLastPoint[0]=x; fLastPoint[1]=y; fLastPoint[2]=z;}
00174 void SetCurrentDirection(const Double_t *dir) {memcpy(fDirection,dir,3*sizeof(Double_t));}
00175 void SetCurrentDirection(Double_t nx, Double_t ny, Double_t nz) {
00176 fDirection[0]=nx; fDirection[1]=ny; fDirection[2]=nz;}
00177
00178 void SetCldirChecked(Double_t *dir) {memcpy(fCldirChecked, dir, 3*sizeof(Double_t));}
00179
00180
00181 void LocalToMaster(const Double_t *local, Double_t *master) const {fCache->LocalToMaster(local, master);}
00182 void LocalToMasterVect(const Double_t *local, Double_t *master) const {fCache->LocalToMasterVect(local, master);}
00183 void LocalToMasterBomb(const Double_t *local, Double_t *master) const {fCache->LocalToMasterBomb(local, master);}
00184 void MasterToLocal(const Double_t *master, Double_t *local) const {fCache->MasterToLocal(master, local);}
00185 void MasterToLocalVect(const Double_t *master, Double_t *local) const {fCache->MasterToLocalVect(master, local);}
00186 void MasterToLocalBomb(const Double_t *master, Double_t *local) const {fCache->MasterToLocalBomb(master, local);}
00187 void MasterToTop(const Double_t *master, Double_t *top) const;
00188 void TopToMaster(const Double_t *top, Double_t *master) const;
00189 TGeoNodeCache *GetCache() const {return fCache;}
00190
00191
00192 Int_t PushPath(Int_t startlevel=0) {return fCache->PushState(fCurrentOverlapping, startlevel, fNmany);}
00193 Bool_t PopPath() {fCurrentOverlapping=fCache->PopState(fNmany); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel();fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00194 Bool_t PopPath(Int_t index) {fCurrentOverlapping=fCache->PopState(fNmany,index); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel();fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00195 Int_t PushPoint(Int_t startlevel=0) {return fCache->PushState(fCurrentOverlapping, startlevel,fNmany,fPoint);}
00196 Bool_t PopPoint() {fCurrentOverlapping=fCache->PopState(fNmany,fPoint); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel(); fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00197 Bool_t PopPoint(Int_t index) {fCurrentOverlapping=fCache->PopState(fNmany,index, fPoint); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel(); fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00198 void PopDummy(Int_t ipop=9999) {fCache->PopDummy(ipop);}
00199
00200 ClassDef(TGeoNavigator, 0)
00201 };
00202
00203 #endif
00204