Project
Loading...
Searching...
No Matches
VecGeomG4NavigatorBase.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_VECGEOMG4NAVIGATORBASE_H_
13#define O2_SIMSETUP_VECGEOMG4NAVIGATORBASE_H_
14
15#include "VecGeomG4Map.h"
16
17#include "G4Navigator.hh"
18#include "G4SystemOfUnits.hh"
19#include "G4ThreeVector.hh"
20
21#include <VecGeom/base/Transformation3D.h>
22#include <VecGeom/base/Vector3D.h>
23#include <VecGeom/navigation/NavigationState.h>
24#include <VecGeom/volumes/PlacedVolume.h>
25
26namespace o2::simsetup
27{
28
34{
35 protected:
36 using V3 = vecgeom::Vector3D<double>;
37 static constexpr double kG4ToVG = 1. / CLHEP::cm;
38 static constexpr double kVGToG4 = CLHEP::cm;
39
40 explicit VecGeomG4NavigatorBase(VecGeomG4Map const& map) : mMap(map) {}
41
42 static V3 toVG(const G4ThreeVector& p) { return {p.x() * kG4ToVG, p.y() * kG4ToVG, p.z() * kG4ToVG}; }
43 static V3 toDir(const G4ThreeVector& d) { return {d.x(), d.y(), d.z()}; }
44
47 G4VPhysicalVolume* historyFromState(vecgeom::NavigationState const& state);
48
51 bool stateFromHistory(vecgeom::NavigationState& state) const;
52
55 static double boundedSafety(vecgeom::NavigationState const& state, const G4ThreeVector& point, double limit);
56
59 [[gnu::always_inline]] static bool directionLeaves(const V3& n, const V3& dir)
60 {
61 constexpr double kMinExitingNormalCosine = 1e-3; // as in G4NormalNavigation
62 return n.Dot(dir) >= kMinExitingNormalCosine;
63 }
64
66 [[gnu::always_inline]] static bool directionLeaves(vecgeom::NavigationState const& exited, const V3& point,
67 const V3& dir)
68 {
69 if (exited.IsOutside() || exited.Top() == nullptr) {
70 return false;
71 }
72 vecgeom::Transformation3D m;
73 exited.TopMatrix(m);
74 V3 n;
75 exited.Top()->GetUnplacedVolume()->Normal(m.Transform(point), n);
76 if (!(n.Mag2() > 0.5)) {
77 return false; // no valid exit normal: Geant4 does not block either
78 }
79 return directionLeaves(m.InverseTransformDirection(n), dir);
80 }
81
83};
84
85} // namespace o2::simsetup
86
87#endif
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
SurfaceTrackState state
static bool directionLeaves(const V3 &n, const V3 &dir)
static V3 toDir(const G4ThreeVector &d)
G4VPhysicalVolume * historyFromState(vecgeom::NavigationState const &state)
static V3 toVG(const G4ThreeVector &p)
bool stateFromHistory(vecgeom::NavigationState &state) const
static double boundedSafety(vecgeom::NavigationState const &state, const G4ThreeVector &point, double limit)
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.
VecGeomG4NavigatorBase(VecGeomG4Map const &map)
GLdouble n
Definition glcorearb.h:1982
const GLfloat * m
Definition glcorearb.h:4066