12#ifndef O2_SIMSETUP_VECGEOMG4NAVIGATORBASE_H_
13#define O2_SIMSETUP_VECGEOMG4NAVIGATORBASE_H_
17#include "G4Navigator.hh"
18#include "G4SystemOfUnits.hh"
19#include "G4ThreeVector.hh"
21#include <VecGeom/base/Transformation3D.h>
22#include <VecGeom/base/Vector3D.h>
23#include <VecGeom/navigation/NavigationState.h>
24#include <VecGeom/volumes/PlacedVolume.h>
36 using V3 = vecgeom::Vector3D<double>;
37 static constexpr double kG4ToVG = 1. / CLHEP::cm;
38 static constexpr double kVGToG4 = CLHEP::cm;
43 static V3 toDir(
const G4ThreeVector& d) {
return {d.x(), d.y(), d.z()}; }
57 constexpr double kMinExitingNormalCosine = 1e-3;
58 return n.Dot(dir) >= kMinExitingNormalCosine;
62 [[gnu::always_inline]]
static bool directionLeaves(vecgeom::NavigationState
const& exited,
const V3& point,
65 if (exited.IsOutside() || exited.Top() ==
nullptr) {
68 vecgeom::Transformation3D
m;
71 exited.Top()->GetUnplacedVolume()->Normal(
m.Transform(point),
n);
72 if (!(
n.Mag2() > 0.5)) {
static bool directionLeaves(const V3 &n, const V3 &dir)
static V3 toDir(const G4ThreeVector &d)
G4VPhysicalVolume * historyFromState(vecgeom::NavigationState const &state)
VecGeomG4Map const & mMap
static V3 toVG(const G4ThreeVector &p)
bool stateFromHistory(vecgeom::NavigationState &state) const
static bool directionLeaves(vecgeom::NavigationState const &exited, const V3 &point, const V3 &dir)
The same, with the normal taken from exited, which has the volume left on top.
static constexpr double kVGToG4
static constexpr double kG4ToVG
vecgeom::Vector3D< double > V3
VecGeomG4NavigatorBase(VecGeomG4Map const &map)