14#include "G4VPhysicalVolume.hh"
16#include <VecGeom/management/BVHManager.h>
17#include <VecGeom/navigation/BVHNavigator.h>
18#include <VecGeom/navigation/BVHSafetyEstimator.h>
19#include <VecGeom/navigation/VSafetyEstimator.h>
20#include <VecGeom/volumes/LogicalVolume.h>
21#include <VecGeom/volumes/PlacedVolume.h>
23#include <fairlogger/Logger.h>
30constexpr std::size_t kMaxChain = 16;
32constexpr int kMaxDepth = 64;
41 auto const* pvol =
state.Top();
42 auto const* lvol = pvol->GetLogicalVolume();
43 auto const* estimator = lvol->GetSafetyEstimator();
44 if (estimator ==
nullptr) {
47 if (limit < kInfinity && estimator == vecgeom::BVHSafetyEstimator::Instance() && lvol->GetDaughters().size() > 0) {
49 vecgeom::Transformation3D
m;
51 const V3 local =
m.Transform(
toVG(point));
52 double safety = pvol->SafetyToOut(local);
54 safety = vecgeom::BVHNavigator::ComputeBVHSafety<vecgeom::BVHSafetyEstimator>(
55 *vecgeom::BVHManager::GetBVH(lvol), local, safety, std::min(safety, limit *
kG4ToVG));
66 G4VPhysicalVolume* want[kMaxDepth];
68 if (!
state.IsOutside()) {
70 for (
int l = 0; l <
levels &&
n < kMaxDepth; ++l) {
71 auto const* placed =
state.At(l);
72 if (placed ==
nullptr) {
78 LOG(fatal) <<
"VecGeom placement " << placed->GetLabel() <<
" (id " << placed->id() <<
") at level " << l
79 <<
" has no Geant4 counterpart";
81 for (
unsigned c = 0;
c <
size &&
n < kMaxDepth; ++
c) {
90 fHistory.SetFirstEntry(
nullptr);
94 const int depth =
static_cast<int>(fHistory.GetDepth());
96 while (common <=
depth && common <
n && fHistory.GetVolume(common) == want[common]) {
101 fHistory.SetFirstEntry(want[0]);
103 }
else if (
depth >= common) {
104 fHistory.BackLevel(
depth - common + 1);
106 for (
int k = common; k <
n; ++k) {
109 fHistory.NewLevel(want[k], kNormal, want[k]->GetCopyNo());
111 return fHistory.GetTopVolume();
119 if (
mMap.
world() ==
nullptr || fHistory.GetVolume(0) ==
nullptr) {
123 const std::size_t
depth = fHistory.GetDepth();
126 G4VPhysicalVolume* run[kMaxChain];
127 vecgeom::VPlacedVolume
const* found =
nullptr;
129 for (std::size_t
e = l;
e <=
depth &&
n < kMaxChain; ++
e, ++
n) {
130 run[
n] = fHistory.GetVolume(
e);
132 if (candidate ==
nullptr) {
145 if (found !=
nullptr) {
149 if (found ==
nullptr) {
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
G4VPhysicalVolume *const * chain(int vgId, unsigned &size) const
static vecgeom::VPlacedVolume const * ambiguous()
Marks a Geant4 volume that several VecGeom placements reach.
std::vector< vecgeom::VPlacedVolume const * > const & candidates(int g4Id) const
The placements that share an ambiguous Geant4 volume, to be told apart by their chains.
unsigned chainSize(int vgId) const
How many Geant4 levels a VecGeom placement accounts for.
vecgeom::VPlacedVolume const * toVecGeom(int g4Id) const
bool chainMatches(vecgeom::VPlacedVolume const *pv, G4VPhysicalVolume *const *first, std::size_t n) const
Whether a placement's chain is exactly the given run of Geant4 volumes.
vecgeom::VPlacedVolume const * world() const
The outermost placement, standing for the Geant4 world volume.
G4VPhysicalVolume * historyFromState(vecgeom::NavigationState const &state)
VecGeomG4Map const & mMap
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 constexpr double kVGToG4
static constexpr double kG4ToVG
vecgeom::Vector3D< double > V3
GLint GLint GLsizei GLsizei GLsizei depth
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"