BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSAuxiliaryNavigator.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSAUXILIARYNAVIGATOR_H
19#define BDSAUXILIARYNAVIGATOR_H
20
21#include "BDSMagnetStrength.hh"
22
23#include "globals.hh" // geant4 types / globals
24#include "G4AffineTransform.hh"
25#include "G4Navigator.hh"
26#include "G4ThreeVector.hh"
27#include "G4Transform3D.hh"
28
29class BDSStep;
30class G4Step;
31class G4VPhysicalVolume;
32
64{
65public:
68
70 static void AttachWorldVolumeToNavigator(G4VPhysicalVolume* worldPVIn)
71 {auxNavigator->SetWorldVolume(worldPVIn); worldPV = worldPVIn;}
72
75 static void AttachWorldVolumeToNavigatorCL(G4VPhysicalVolume* curvilinearWorldPVIn)
76 {auxNavigatorCL->SetWorldVolume(curvilinearWorldPVIn); curvilinearWorldPV = curvilinearWorldPVIn;}
77
78 static void RegisterCurvilinearBridgeWorld(G4VPhysicalVolume* curvilinearBridgeWorldPVIn)
79 {auxNavigatorCLB->SetWorldVolume(curvilinearBridgeWorldPVIn); curvilinearBridgeWorldPV = curvilinearBridgeWorldPVIn;}
80
81 static void ResetNavigatorStates();
82
84 G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
85 const G4ThreeVector* direction = nullptr,
86 const G4bool pRelativeSearch = true,
87 const G4bool ignoreDirection = true,
88 G4bool useCurvilinear = true) const;
89
93 G4VPhysicalVolume* LocateGlobalPointAndSetup(G4Step const* const step,
94 G4bool useCurvilinear = true) const;
95
100 BDSStep ConvertToLocal(G4Step const* const step,
101 G4bool useCurvilinear = true) const;
102
110 BDSStep ConvertToLocal(const G4ThreeVector& globalPosition,
111 const G4ThreeVector& globalDirection,
112 const G4double stepLength = 0,
113 const G4bool useCurvilinear = true,
114 const G4double marginLength = 1) const;
115
120 BDSStep ConvertToGlobalStep(const G4ThreeVector& localPosition,
121 const G4ThreeVector& localDirection,
122 const G4bool useCurvilinear = true) const;
123
127 G4ThreeVector ConvertToLocal(const G4double globalPoint[3],
128 const G4bool useCurvilinear = true) const;
129
131 G4ThreeVector ConvertToLocal(const G4ThreeVector& globalPosition,
132 const G4bool useCurvilinear = true) const;
133
135 G4ThreeVector ConvertToLocalNoSetup(const G4ThreeVector& globalPosition,
136 const G4bool useCurvilinear = true) const;
137
143 G4ThreeVector ConvertAxisToLocal(const G4ThreeVector& globalAxis,
144 const G4bool useCurvilinear = true) const;
145
149 G4ThreeVector ConvertAxisToLocal(const G4double globalPoint[3],
150 const G4double globalAxis[3],
151 const G4bool useCurvilinear = true) const;
152
154 G4ThreeVector ConvertAxisToLocal(const G4ThreeVector& globalPoint,
155 const G4ThreeVector& globalAxis,
156 const G4bool useCurvilinear = true) const;
157
162 G4ThreeVector ConvertAxisToGlobal(const G4ThreeVector& localAxis,
163 const G4bool useCurvilinear = true) const;
164
169 std::pair<G4ThreeVector, G4ThreeVector> ConvertAxisToGlobal(const std::pair<G4ThreeVector, G4ThreeVector>& localAxis,
170 const G4bool useCurvilinear = true) const;
171
174 G4ThreeVector ConvertToGlobal(const G4ThreeVector& localPosition,
175 const G4bool useCurvilinear = true) const;
176
179 G4ThreeVector ConvertAxisToGlobal(const G4ThreeVector& globalPosition,
180 const G4ThreeVector& localAxis,
181 const G4bool useCurvilinear = true) const;
182
185 G4ThreeVector ConvertToGlobal(const G4ThreeVector& globalPosition,
186 const G4ThreeVector& localPosition,
187 const G4bool useCurvilinear = true) const;
188
191 BDSStep GlobalToCurvilinear(const G4double fieldArcLength,
192 const G4ThreeVector& unitField,
193 const G4double angle,
194 const G4ThreeVector& position,
195 const G4ThreeVector& unitMomentum,
196 const G4double h,
197 const G4bool useCurvilinearWorld,
198 const G4double FCof,
199 const G4double tilt = 0);
200
201 BDSStep GlobalToCurvilinear(const G4ThreeVector& position,
202 const G4ThreeVector& unitMomentum,
203 const G4double h,
204 const G4bool useCurvilinearWorld);
205
206 BDSStep CurvilinearToGlobal(const G4ThreeVector& localPosition,
207 const G4ThreeVector& localMomentum,
208 const G4bool useCurvilinearWorld);
209
210 BDSStep CurvilinearToGlobal(const G4double fieldArcLength,
211 const G4ThreeVector& unitField,
212 const G4double angle,
213 const G4ThreeVector& CLPosition,
214 const G4ThreeVector& CLMomentum,
215 const G4bool useCurvilinearWorld,
216 const G4double FCof,
217 const G4double tilt = 0);
218
219protected:
220 mutable G4AffineTransform globalToLocal;
221 mutable G4AffineTransform localToGlobal;
222 mutable G4AffineTransform globalToLocalCL;
223 mutable G4AffineTransform localToGlobalCL;
224 mutable G4bool bridgeVolumeWasUsed;
225
228 static G4Navigator* auxNavigator;
229
233 static G4Navigator* auxNavigatorCL;
234
238 static G4Navigator* auxNavigatorCLB;
239
240private:
242 G4Navigator* Navigator(G4bool curvilinear) const;
243
245 const G4AffineTransform& GlobalToLocal(G4bool curvilinear) const;
246 const G4AffineTransform& LocalToGlobal(G4bool curvilinear) const;
248
249 void InitialiseTransform(const G4bool massworld = true,
250 const G4bool curvilinearWorld = true) const;
251
258 void InitialiseTransform(const G4ThreeVector& globalPosition) const;
259
264 void InitialiseTransform(const G4ThreeVector& globalPosition,
265 const G4ThreeVector& globalMomentum,
266 const G4double stepLength);
267
270 static G4int numberOfInstances;
271
273 static G4VPhysicalVolume* worldPV;
274 static G4VPhysicalVolume* curvilinearWorldPV;
275 static G4VPhysicalVolume* curvilinearBridgeWorldPV;
277
282 G4double volumeMargin;
283};
284
285
286#endif
Extra G4Navigator to get coordinate transforms.
G4ThreeVector ConvertToGlobal(const G4ThreeVector &localPosition, const G4bool useCurvilinear=true) const
static G4VPhysicalVolume * curvilinearBridgeWorldPV
Cache of world PV to test if we're getting the wrong volume for the transform.
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true, G4bool useCurvilinear=true) const
A wrapper for the underlying static navigator instance located within this class.
BDSStep GlobalToCurvilinear(const G4double fieldArcLength, const G4ThreeVector &unitField, const G4double angle, const G4ThreeVector &position, const G4ThreeVector &unitMomentum, const G4double h, const G4bool useCurvilinearWorld, const G4double FCof, const G4double tilt=0)
G4Navigator * Navigator(G4bool curvilinear) const
Utility function to select appropriate navigator.
static G4VPhysicalVolume * worldPV
Cache of world PV to test if we're getting the wrong volume for the transform.
G4ThreeVector ConvertAxisToLocal(const G4ThreeVector &globalAxis, const G4bool useCurvilinear=true) const
BDSStep ConvertToGlobalStep(const G4ThreeVector &localPosition, const G4ThreeVector &localDirection, const G4bool useCurvilinear=true) const
static G4Navigator * auxNavigator
G4ThreeVector ConvertToLocalNoSetup(const G4ThreeVector &globalPosition, const G4bool useCurvilinear=true) const
Similar to above function but does NOT initialise the transforms.
static void AttachWorldVolumeToNavigatorCL(G4VPhysicalVolume *curvilinearWorldPVIn)
G4ThreeVector ConvertAxisToGlobal(const G4ThreeVector &localAxis, const G4bool useCurvilinear=true) const
static G4Navigator * auxNavigatorCLB
static G4Navigator * auxNavigatorCL
const G4AffineTransform & LocalToGlobal(G4bool curvilinear) const
Utility function to select appropriate transform.
static G4VPhysicalVolume * curvilinearWorldPV
Cache of world PV to test if we're getting the wrong volume for the transform.
BDSStep ConvertToLocal(G4Step const *const step, G4bool useCurvilinear=true) const
static void AttachWorldVolumeToNavigator(G4VPhysicalVolume *worldPVIn)
Setup the navigator w.r.t. to a world volume - typically real world.
const G4AffineTransform & GlobalToLocal(G4bool curvilinear) const
Utility function to select appropriate transform.
A simple class to represent the positions of a step.
Definition BDSStep.hh:32