29 if (!gGeoManager->cd(path)) {
30 std::stringstream msg;
31 msg <<
"Node with path " << path <<
" is not found in the geo manager";
32 throw std::runtime_error(msg.str());
36 const auto* bBox =
dynamic_cast<const TGeoBBox*
>(gGeoManager->GetCurrentVolume()->GetShape());
38 throw std::runtime_error(fmt::format(
"The shape of the volume under path {} is not a TGeoBBox", path.Data()));
41 std::array<std::array<double, 3>, 8> locBoxVertices = {
43 {bBox->GetOrigin()[0] + bBox->GetDX(), bBox->GetOrigin()[1] + bBox->GetDY(), bBox->GetOrigin()[2] + bBox->GetDZ()},
44 {bBox->GetOrigin()[0] + bBox->GetDX(), bBox->GetOrigin()[1] + bBox->GetDY(), bBox->GetOrigin()[2] - bBox->GetDZ()},
45 {bBox->GetOrigin()[0] + bBox->GetDX(), bBox->GetOrigin()[1] - bBox->GetDY(), bBox->GetOrigin()[2] + bBox->GetDZ()},
46 {bBox->GetOrigin()[0] + bBox->GetDX(), bBox->GetOrigin()[1] - bBox->GetDY(), bBox->GetOrigin()[2] - bBox->GetDZ()},
47 {bBox->GetOrigin()[0] - bBox->GetDX(), bBox->GetOrigin()[1] + bBox->GetDY(), bBox->GetOrigin()[2] + bBox->GetDZ()},
48 {bBox->GetOrigin()[0] - bBox->GetDX(), bBox->GetOrigin()[1] + bBox->GetDY(), bBox->GetOrigin()[2] - bBox->GetDZ()},
49 {bBox->GetOrigin()[0] - bBox->GetDX(), bBox->GetOrigin()[1] - bBox->GetDY(), bBox->GetOrigin()[2] + bBox->GetDZ()},
50 {bBox->GetOrigin()[0] - bBox->GetDX(), bBox->GetOrigin()[1] - bBox->GetDY(),
51 bBox->GetOrigin()[2] - bBox->GetDZ()}}};
53 std::array<std::pair<double, double>, 3> bounds = {
55 {+std::numeric_limits<double>::max(), -std::numeric_limits<double>::max()},
56 {+std::numeric_limits<double>::max(), -std::numeric_limits<double>::max()},
57 {+std::numeric_limits<double>::max(), -std::numeric_limits<double>::max()}}};
59 const auto* matrix{gGeoManager->GetCurrentMatrix()};
60 for (
int iVertex = 0; iVertex < 8; ++iVertex) {
61 std::array<double, 3> glbVertex;
62 matrix->LocalToMaster(locBoxVertices[iVertex].data(), glbVertex.data());
63 for (
int iDim = 0; iDim < 3; ++iDim) {
64 bounds[iDim].first = std::min(bounds[iDim].
first, glbVertex[iDim]);
65 bounds[iDim].second = std::max(bounds[iDim].second, glbVertex[iDim]);