Project
Loading...
Searching...
No Matches
VecGeomG4Navigator.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_SIMSETUP_VECGEOMG4NAVIGATOR_H_
13#define O2_SIMSETUP_VECGEOMG4NAVIGATOR_H_
14
16
17namespace o2::simsetup
18{
19
37{
38 public:
41 VecGeomG4Navigator(VecGeomG4Map const& map, double pushDepth, bool zeroSafety);
42 ~VecGeomG4Navigator() override;
43
44 G4double ComputeStep(const G4ThreeVector& globalPoint, const G4ThreeVector& direction,
45 const G4double proposedStepLength, G4double& newSafety) override;
46
47 G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector& point, const G4ThreeVector& direction,
48 const G4TouchableHistory& history) override;
49
50 G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point, const G4ThreeVector* direction = nullptr,
51 const G4bool relativeSearch = true,
52 const G4bool ignoreDirection = true) override;
53
54 void LocateGlobalPointWithinVolume(const G4ThreeVector& position) override;
55
56 G4double ComputeSafety(const G4ThreeVector& globalPoint, const G4double proposedMaxLength = DBL_MAX,
57 const G4bool keepState = true) override;
58
59 // Both point out of the volume left; the local one is in the frame of the final volume.
60 G4ThreeVector GetLocalExitNormal(G4bool* valid) override;
61 G4ThreeVector GetGlobalExitNormal(const G4ThreeVector& point, G4bool* valid) override;
62
63 private:
65 G4VPhysicalVolume* updateG4History();
66 void locateFromWorld(const V3& point);
68 void leaveFlushVolumes(const V3& point, const V3& dir, int minLevel, vecgeom::VPlacedVolume const* avoid);
70 void updateCrossingFlags(bool entering);
71 void clearLastExited()
72 {
73 mCurState.SetLastExited(mEmptyState.GetLastExitedState());
74 mExitBlockPending = false;
75 }
77 void setExited(vecgeom::NavigationState const& st, bool normalFromPush)
78 {
79 mExitedState = st;
80 mExitBlockPending = true;
81 mExitNormalFromPush = normalFromPush && mPushNormalValid;
82 }
85 double boundaryPush(const V3& point, const V3& dir);
87 bool computeExitNormal(const G4ThreeVector& point, V3& globalNormal) const;
88
89 double mPushDepth = 1.e-9;
90 bool mZeroSafety = false;
91
92 vecgeom::NavigationState mCurState;
93 vecgeom::NavigationState mNextState;
94 vecgeom::NavigationState mStepState;
95 vecgeom::NavigationState mReloScratch;
96 vecgeom::NavigationState mPathScratch;
97 vecgeom::NavigationState mHistoryState;
98 vecgeom::NavigationState mEmptyState;
99 vecgeom::NavigationState mNormalState;
100 vecgeom::NavigationState mExitedState;
101 bool mExitBlockPending = false;
102 bool mExitNormalFromPush = false;
103 V3 mPushNormal;
104 bool mPushNormalValid = false;
105 bool mHistoryValid = false;
106
107 bool mWouldEnter = false;
108 bool mWouldExit = false;
109 G4ThreeVector mNextPoint{-1e8, -1e8, -1e8};
110 G4ThreeVector mLastLocatedPoint{-1e8, -1e8, -1e8};
111 bool mLocatedOnBoundary = false;
112 G4ThreeVector mSafetyOrig{-1e8, -1e8, -1e8};
113 double mLastSafety = 0.;
114 double mLastSafetyLimit = kInfinity;
115 bool mNormalEnter = false;
116 bool mNormalValid = false;
117 G4ThreeVector mNormalPoint{-1e8, -1e8, -1e8};
118
120 static constexpr int kActionThresholdNoZeroSteps = 10;
121 static constexpr int kAbandonThresholdNoZeroSteps = 25;
122 int mNzeroSteps = 0;
123
124 // What the navigator had to work around, reported at the end.
125 long mZeroStepCount = 0;
126 long mStuckPushCount = 0;
127 long mAbandonCount = 0;
128 long mNegativeSafetyCount = 0;
129 long mUnmappableHistoryCount = 0;
130 long mRelocatedResumeCount = 0;
131 long mNoNormalCount = 0;
132};
133
134} // namespace o2::simsetup
135
136#endif
bool valid
Acts::Vector3 position
benchmark::State & st
G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid) override
G4double ComputeSafety(const G4ThreeVector &globalPoint, const G4double proposedMaxLength=DBL_MAX, const G4bool keepState=true) override
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &direction, const G4double proposedStepLength, G4double &newSafety) override
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &history) override
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool relativeSearch=true, const G4bool ignoreDirection=true) override
void LocateGlobalPointWithinVolume(const G4ThreeVector &position) override
G4ThreeVector GetLocalExitNormal(G4bool *valid) override