14#include "G4VPhysicalVolume.hh"
16#include <VecGeom/volumes/PlacedVolume.h>
18#include <fairlogger/Logger.h>
23constexpr std::size_t kMaxChain = 16;
25constexpr int kMaxDepth = 64;
35 G4VPhysicalVolume* want[kMaxDepth];
37 if (!
state.IsOutside()) {
39 for (
int l = 0; l <
levels &&
n < kMaxDepth; ++l) {
40 auto const* placed =
state.At(l);
41 if (placed ==
nullptr) {
47 LOG(fatal) <<
"VecGeom placement " << placed->GetLabel() <<
" (id " << placed->id() <<
") at level " << l
48 <<
" has no Geant4 counterpart";
50 for (
unsigned c = 0;
c <
size &&
n < kMaxDepth; ++
c) {
59 fHistory.SetFirstEntry(
nullptr);
63 const int depth =
static_cast<int>(fHistory.GetDepth());
65 while (common <=
depth && common <
n && fHistory.GetVolume(common) == want[common]) {
70 fHistory.SetFirstEntry(want[0]);
72 }
else if (
depth >= common) {
73 fHistory.BackLevel(
depth - common + 1);
75 for (
int k = common; k <
n; ++k) {
78 fHistory.NewLevel(want[k], kNormal, want[k]->GetCopyNo());
80 return fHistory.GetTopVolume();
88 if (
mMap.
world() ==
nullptr || fHistory.GetVolume(0) ==
nullptr) {
92 const std::size_t
depth = fHistory.GetDepth();
95 G4VPhysicalVolume* run[kMaxChain];
96 vecgeom::VPlacedVolume
const* found =
nullptr;
98 for (std::size_t e = l; e <=
depth &&
n < kMaxChain; ++e, ++
n) {
99 run[
n] = fHistory.GetVolume(e);
101 if (candidate ==
nullptr) {
114 if (found !=
nullptr) {
118 if (found ==
nullptr) {
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
bool stateFromHistory(vecgeom::NavigationState &state) const
GLint GLint GLsizei GLsizei GLsizei depth
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"