Warning, file /include/root/TGeoNavigator.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGeoNavigator
0013 #define ROOT_TGeoNavigator
0014
0015 #include "TObject.h"
0016
0017 #include "TGeoCache.h"
0018
0019
0020
0021
0022
0023
0024
0025
0026 class TGeoManager;
0027 class TGeoNode;
0028 class TGeoVolume;
0029 class TGeoMatrix;
0030 class TGeoHMatrix;
0031
0032 class TGeoNavigator : public TObject {
0033
0034 protected:
0035 TGeoNavigator(const TGeoNavigator &) = delete;
0036 TGeoNavigator &operator=(const TGeoNavigator &) = delete;
0037 TGeoNode *FindInCluster(Int_t *cluster, Int_t nc);
0038 Int_t GetTouchedCluster(Int_t start, Double_t *point, Int_t *check_list, Int_t ncheck, Int_t *result);
0039 TGeoNode *CrossDivisionCell();
0040 void SafetyOverlaps();
0041
0042 private:
0043 Double_t fStep;
0044 Double_t fSafety;
0045 Double_t fLastSafety;
0046 Double_t fNormal[3];
0047 Double_t fCldir[3];
0048 Double_t fCldirChecked[3];
0049 Double_t fPoint[3];
0050 Double_t fDirection[3];
0051 Double_t fLastPoint[3];
0052 Double_t fLastPWSaftyPnt[3];
0053 Double_t fLastPWSafety{-1};
0054 Int_t fThreadId;
0055 Int_t fLevel;
0056 Int_t fNmany;
0057 Int_t fNextDaughterIndex;
0058 Int_t fOverlapSize;
0059 Int_t fOverlapMark;
0060 Int_t *fOverlapClusters;
0061 Bool_t fSearchOverlaps;
0062 Bool_t fCurrentOverlapping;
0063 Bool_t fStartSafe;
0064 Bool_t fIsEntering;
0065 Bool_t fIsExiting;
0066 Bool_t fIsStepEntering;
0067 Bool_t fIsStepExiting;
0068 Bool_t fIsOutside;
0069 Bool_t fIsOnBoundary;
0070 Bool_t fIsSameLocation;
0071 Bool_t fIsNullStep;
0072 TGeoManager *fGeometry;
0073 TGeoNodeCache *fCache;
0074 TGeoVolume *fCurrentVolume;
0075 TGeoNode *fCurrentNode;
0076 TGeoNode *fTopNode;
0077 TGeoNode *fLastNode;
0078 TGeoNode *fNextNode;
0079 TGeoNode *fForcedNode;
0080 TGeoCacheState *fBackupState;
0081 TGeoHMatrix *fCurrentMatrix;
0082 TGeoHMatrix *fGlobalMatrix;
0083 TGeoHMatrix *fDivMatrix;
0084 TString fPath;
0085
0086 static Bool_t fgUsePWSafetyCaching;
0087
0088 public:
0089 TGeoNavigator();
0090 TGeoNavigator(TGeoManager *geom);
0091 ~TGeoNavigator() override;
0092
0093 void BuildCache(Bool_t dummy = kFALSE, Bool_t nodeid = kFALSE);
0094 Bool_t cd(const char *path = "");
0095 Bool_t CheckPath(const char *path) const;
0096 void CdNode(Int_t nodeid);
0097 void CdDown(Int_t index);
0098 void CdDown(TGeoNode *node);
0099 void CdUp();
0100 void CdTop();
0101 void CdNext();
0102 void GetBranchNames(Int_t *names) const;
0103 void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
0104 void GetBranchOnlys(Int_t *isonly) const;
0105 Int_t GetNmany() const { return fNmany; }
0106
0107 TGeoNode *CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode);
0108 TGeoNode *FindNextBoundary(Double_t stepmax = TGeoShape::Big(), const char *path = "", Bool_t frombdr = kFALSE);
0109 TGeoNode *FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix = kFALSE);
0110 TGeoNode *FindNextBoundaryAndStep(Double_t stepmax = TGeoShape::Big(), Bool_t compsafe = kFALSE);
0111 TGeoNode *FindNode(Bool_t safe_start = kTRUE);
0112 TGeoNode *FindNode(Double_t x, Double_t y, Double_t z);
0113 Double_t *FindNormal(Bool_t forward = kTRUE);
0114 Double_t *FindNormalFast();
0115 TGeoNode *InitTrack(const Double_t *point, const Double_t *dir);
0116 TGeoNode *InitTrack(Double_t x, Double_t y, Double_t z, Double_t nx, Double_t ny, Double_t nz);
0117 void ResetState();
0118 void ResetAll();
0119 Double_t Safety(Bool_t inside = kFALSE);
0120 TGeoNode *SearchNode(Bool_t downwards = kFALSE, const TGeoNode *skipnode = nullptr);
0121 TGeoNode *Step(Bool_t is_geom = kTRUE, Bool_t cross = kTRUE);
0122 const Double_t *GetLastPoint() const { return fLastPoint; }
0123 Int_t GetVirtualLevel();
0124 Bool_t GotoSafeLevel();
0125 Int_t GetSafeLevel() const;
0126 Double_t GetSafeDistance() const { return fSafety; }
0127 Double_t GetLastSafety() const { return fLastSafety; }
0128 Double_t GetStep() const { return fStep; }
0129 Int_t GetThreadId() const { return fThreadId; }
0130 void InspectState() const;
0131 Bool_t IsSafeStep(Double_t proposed, Double_t &newsafety) const;
0132 Bool_t IsSameLocation(Double_t x, Double_t y, Double_t z, Bool_t change = kFALSE);
0133 Bool_t IsSameLocation() const { return fIsSameLocation; }
0134 Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const;
0135 Bool_t IsStartSafe() const { return fStartSafe; }
0136 void SetStartSafe(Bool_t flag = kTRUE) { fStartSafe = flag; }
0137 void SetStep(Double_t step) { fStep = step; }
0138 Bool_t IsCheckingOverlaps() const { return fSearchOverlaps; }
0139 Bool_t IsCurrentOverlapping() const { return fCurrentOverlapping; }
0140 Bool_t IsEntering() const { return fIsEntering; }
0141 Bool_t IsExiting() const { return fIsExiting; }
0142 Bool_t IsStepEntering() const { return fIsStepEntering; }
0143 Bool_t IsStepExiting() const { return fIsStepExiting; }
0144 Bool_t IsOutside() const { return fIsOutside; }
0145 Bool_t IsOnBoundary() const { return fIsOnBoundary; }
0146 Bool_t IsNullStep() const { return fIsNullStep; }
0147 void SetCheckingOverlaps(Bool_t flag = kTRUE) { fSearchOverlaps = flag; }
0148 void SetOutside(Bool_t flag = kTRUE) { fIsOutside = flag; }
0149
0150 void DoBackupState();
0151 void DoRestoreState();
0152 Int_t GetNodeId() const { return fCache->GetNodeId(); }
0153 Int_t GetNextDaughterIndex() const { return fNextDaughterIndex; }
0154 TGeoNode *GetNextNode() const { return fNextNode; }
0155 TGeoNode *GetMother(Int_t up = 1) const { return fCache->GetMother(up); }
0156 TGeoHMatrix *GetMotherMatrix(Int_t up = 1) const { return fCache->GetMotherMatrix(up); }
0157 TGeoHMatrix *GetHMatrix();
0158 TGeoHMatrix *GetCurrentMatrix() const { return fCache->GetCurrentMatrix(); }
0159 TGeoNode *GetCurrentNode() const { return fCurrentNode; }
0160 Int_t GetCurrentNodeId() const { return fCache->GetCurrentNodeId(); }
0161 const Double_t *GetCurrentPoint() const { return fPoint; }
0162 const Double_t *GetCurrentDirection() const { return fDirection; }
0163 TGeoVolume *GetCurrentVolume() const { return fCurrentNode->GetVolume(); }
0164 const Double_t *GetCldirChecked() const { return fCldirChecked; }
0165 const Double_t *GetCldir() const { return fCldir; }
0166 TGeoHMatrix *GetDivMatrix() const { return fDivMatrix; }
0167
0168 const Double_t *GetNormal() const { return fNormal; }
0169 Int_t GetLevel() const { return fLevel; }
0170 const char *GetPath() const;
0171 Int_t GetStackLevel() const { return fCache->GetStackLevel(); }
0172 void SetCurrentPoint(const Double_t *point) { memcpy(fPoint, point, 3 * sizeof(Double_t)); }
0173 void SetCurrentPoint(Double_t x, Double_t y, Double_t z)
0174 {
0175 fPoint[0] = x;
0176 fPoint[1] = y;
0177 fPoint[2] = z;
0178 }
0179 void SetLastPoint(Double_t x, Double_t y, Double_t z)
0180 {
0181 fLastPoint[0] = x;
0182 fLastPoint[1] = y;
0183 fLastPoint[2] = z;
0184 }
0185 void SetCurrentDirection(const Double_t *dir) { memcpy(fDirection, dir, 3 * sizeof(Double_t)); }
0186 void SetCurrentDirection(Double_t nx, Double_t ny, Double_t nz)
0187 {
0188 fDirection[0] = nx;
0189 fDirection[1] = ny;
0190 fDirection[2] = nz;
0191 }
0192
0193 void SetCldirChecked(Double_t *dir) { memcpy(fCldirChecked, dir, 3 * sizeof(Double_t)); }
0194 void SetLastSafetyForPoint(Double_t safe, const Double_t *point)
0195 {
0196 fLastSafety = safe;
0197 memcpy(fLastPoint, point, 3 * sizeof(Double_t));
0198 }
0199 void SetLastSafetyForPoint(Double_t safe, Double_t x, Double_t y, Double_t z)
0200 {
0201 fLastSafety = safe;
0202 fLastPoint[0] = x;
0203 fLastPoint[1] = y, fLastPoint[2] = z;
0204 }
0205
0206
0207
0208 Double_t GetPWSafetyEstimateFromCache(Double_t cpoint[3]) const
0209 {
0210
0211 if (fLastPWSafety < TGeoShape::Tolerance()) {
0212 return -1.;
0213 }
0214 const auto d0 = fLastPWSaftyPnt[0] - cpoint[0];
0215 const auto d1 = fLastPWSaftyPnt[1] - cpoint[1];
0216 const auto d2 = fLastPWSaftyPnt[2] - cpoint[2];
0217 const auto d_sq = d0 * d0 + d1 * d1 + d2 * d2;
0218
0219 if (d_sq >= (fLastPWSafety * fLastPWSafety)) {
0220 return -1.;
0221 }
0222
0223 return fLastPWSafety - std::sqrt(d_sq);
0224 }
0225
0226
0227
0228 Double_t GetPWSafety(Double_t cpoint[3], Double_t saf_max);
0229
0230
0231 static void SetPWSafetyCaching(Bool_t b) { fgUsePWSafetyCaching = b; }
0232 static Bool_t IsPWSafetyCaching() { return fgUsePWSafetyCaching; }
0233
0234
0235 void LocalToMaster(const Double_t *local, Double_t *master) const { fCache->LocalToMaster(local, master); }
0236 void LocalToMasterVect(const Double_t *local, Double_t *master) const { fCache->LocalToMasterVect(local, master); }
0237 void LocalToMasterBomb(const Double_t *local, Double_t *master) const { fCache->LocalToMasterBomb(local, master); }
0238 void MasterToLocal(const Double_t *master, Double_t *local) const { fCache->MasterToLocal(master, local); }
0239 void MasterToLocalVect(const Double_t *master, Double_t *local) const { fCache->MasterToLocalVect(master, local); }
0240 void MasterToLocalBomb(const Double_t *master, Double_t *local) const { fCache->MasterToLocalBomb(master, local); }
0241 void MasterToTop(const Double_t *master, Double_t *top) const;
0242 void TopToMaster(const Double_t *top, Double_t *master) const;
0243 TGeoNodeCache *GetCache() const { return fCache; }
0244
0245
0246 Int_t PushPath(Int_t startlevel = 0) { return fCache->PushState(fCurrentOverlapping, startlevel, fNmany); }
0247 Bool_t PopPath()
0248 {
0249 fCurrentOverlapping = fCache->PopState(fNmany);
0250 fCurrentNode = fCache->GetNode();
0251 fLevel = fCache->GetLevel();
0252 fGlobalMatrix = fCache->GetCurrentMatrix();
0253 return fCurrentOverlapping;
0254 }
0255 Bool_t PopPath(Int_t index)
0256 {
0257 fCurrentOverlapping = fCache->PopState(fNmany, index);
0258 fCurrentNode = fCache->GetNode();
0259 fLevel = fCache->GetLevel();
0260 fGlobalMatrix = fCache->GetCurrentMatrix();
0261 return fCurrentOverlapping;
0262 }
0263 Int_t PushPoint(Int_t startlevel = 0) { return fCache->PushState(fCurrentOverlapping, startlevel, fNmany, fPoint); }
0264 Bool_t PopPoint()
0265 {
0266 fCurrentOverlapping = fCache->PopState(fNmany, fPoint);
0267 fCurrentNode = fCache->GetNode();
0268 fLevel = fCache->GetLevel();
0269 fGlobalMatrix = fCache->GetCurrentMatrix();
0270 return fCurrentOverlapping;
0271 }
0272 Bool_t PopPoint(Int_t index)
0273 {
0274 fCurrentOverlapping = fCache->PopState(fNmany, index, fPoint);
0275 fCurrentNode = fCache->GetNode();
0276 fLevel = fCache->GetLevel();
0277 fGlobalMatrix = fCache->GetCurrentMatrix();
0278 return fCurrentOverlapping;
0279 }
0280 void PopDummy(Int_t ipop = 9999) { fCache->PopDummy(ipop); }
0281
0282 ClassDefOverride(TGeoNavigator, 0)
0283 };
0284
0285 #include "TObjArray.h"
0286
0287
0288
0289
0290
0291
0292
0293
0294 class TGeoNavigatorArray : public TObjArray {
0295 private:
0296 TGeoNavigator *fCurrentNavigator;
0297 TGeoManager *fGeoManager;
0298
0299 TGeoNavigatorArray(const TGeoNavigatorArray &) = delete;
0300 TGeoNavigatorArray &operator=(const TGeoNavigatorArray &) = delete;
0301
0302 public:
0303 TGeoNavigatorArray() : TObjArray(), fCurrentNavigator(nullptr), fGeoManager(nullptr) {}
0304 TGeoNavigatorArray(TGeoManager *mgr) : TObjArray(), fCurrentNavigator(nullptr), fGeoManager(mgr) { SetOwner(); }
0305 ~TGeoNavigatorArray() override {}
0306
0307 TGeoNavigator *AddNavigator();
0308 inline TGeoNavigator *GetCurrentNavigator() const { return fCurrentNavigator; }
0309 TGeoNavigator *SetCurrentNavigator(Int_t inav) { return (fCurrentNavigator = (TGeoNavigator *)At(inav)); }
0310
0311 ClassDefOverride(TGeoNavigatorArray, 0)
0312 };
0313 #endif