BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSNavigatorPlacements.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 BDSNAVIGATORPLACEMENTS_H
19#define BDSNAVIGATORPLACEMENTS_H
20
21#include "G4AffineTransform.hh"
22#include "G4Navigator.hh"
23#include "G4ThreeVector.hh"
24#include "G4Types.hh"
25
26#include <utility>
27
28class G4VPhysicalVolume;
29
49{
50public:
53
55 static void AttachWorldVolumeToNavigator(G4VPhysicalVolume* worldPVIn)
56 {navigator->SetWorldVolume(worldPVIn); worldPV = worldPVIn;}
57
58 static void ResetNavigatorStates();
59
63 G4ThreeVector ConvertToLocal(const G4ThreeVector& globalPosition,
64 G4bool& foundAPlacementVolume) const;
65
67 G4ThreeVector ConvertToLocalNoSetup(const G4ThreeVector& globalPosition) const;
68
73 G4ThreeVector ConvertAxisToGlobal(const G4ThreeVector& localAxis) const;
74
79 std::pair<G4ThreeVector, G4ThreeVector> ConvertAxisToGlobal(const std::pair<G4ThreeVector, G4ThreeVector>& localAxis) const;
80
81protected:
82 mutable G4AffineTransform globalToLocal;
83 mutable G4AffineTransform localToGlobal;
84
87 static G4Navigator* navigator;
88
89private:
91 inline const G4AffineTransform& GlobalToLocal() const {return globalToLocal;}
92 inline const G4AffineTransform& LocalToGlobal() const {return localToGlobal;}
94
101 G4bool InitialiseTransform(const G4ThreeVector& globalPosition) const;
102
105 static G4int numberOfInstances;
106
108 static G4VPhysicalVolume* worldPV;
109};
110
111
112#endif
Extra G4Navigator to get coordinate transforms for placement world.
const G4AffineTransform & LocalToGlobal() const
Utility function to select appropriate transform.
G4bool InitialiseTransform(const G4ThreeVector &globalPosition) const
static void AttachWorldVolumeToNavigator(G4VPhysicalVolume *worldPVIn)
Setup the navigator w.r.t. to a world volume - typically real world.
G4ThreeVector ConvertToLocalNoSetup(const G4ThreeVector &globalPosition) const
Similar to above function but does NOT initialise the transforms.
const G4AffineTransform & GlobalToLocal() const
Utility function to select appropriate transform.
G4ThreeVector ConvertToLocal(const G4ThreeVector &globalPosition, G4bool &foundAPlacementVolume) const
G4ThreeVector ConvertAxisToGlobal(const G4ThreeVector &localAxis) const
static G4VPhysicalVolume * worldPV
Cache of world PV to test if we're getting the wrong volume for the transform.
static G4Navigator * navigator