diff --git a/alignment/FairAlignmentHandler.cxx b/alignment/FairAlignmentHandler.cxx index cb63e623a4..b7cac4f761 100644 --- a/alignment/FairAlignmentHandler.cxx +++ b/alignment/FairAlignmentHandler.cxx @@ -5,10 +5,8 @@ #include #include #include - -FairAlignmentHandler::FairAlignmentHandler() {} - -FairAlignmentHandler::~FairAlignmentHandler() {} +#include +#include void FairAlignmentHandler::AlignGeometry() const { @@ -22,8 +20,9 @@ void FairAlignmentHandler::AlignGeometry() const AlignGeometryByFullPath(); } - // --- Force BoundingBox recomputation for AssemblyVolumes as they may have been corrupted by alignment - // FIXME: will hopefully be fixed in Root in near future, temp fix in meantime + // --- Force BoundingBox recomputation for volumes/nodes needing it after alignment + // FIXME: May be added to RefreshPhysicalNode step in Root in near future, temp fix needed here in meantime + /// cf https://github.com/root-project/root/issues/12242 RecomputePhysicalAssmbBbox(); LOG(info) << "Refreshing geometry..."; @@ -104,20 +103,23 @@ void FairAlignmentHandler::AddAlignmentMatrices(const std::mapGetListOfPhysicalNodes(); - - TGeoPhysicalNode* pPhysNode = nullptr; - TGeoShapeAssembly* pShapeAsb = nullptr; - - Int_t iNbNodes = pPhysNodesArr->GetEntriesFast(); - for (Int_t iInd = 0; iInd < iNbNodes; ++iInd) { - pPhysNode = dynamic_cast(pPhysNodesArr->At(iInd)); - if (pPhysNode) { - pShapeAsb = dynamic_cast(pPhysNode->GetShape()); - if (pShapeAsb) { - // Should reach here only if the original node was a TGeoShapeAssembly - pShapeAsb->ComputeBBox(); - } + /// After alignment, forces the recomputation of the bounding box of all volumesAssemblies and the rebuilding of + /// Nodes requiring it. + /// => Not done after each change to geometry in ROOT for perf reason + /// => to be called once all changes done + /// => original snippet proposed in https://github.com/root-project/root/issues/12242 by A. Gheata + TObjArray* volumes = gGeoManager->GetListOfVolumes(); + for (auto vol : TRangeDynCast(volumes)) { + if (!vol) { + continue; + } + if (vol->IsAssembly()) { + vol->GetShape()->ComputeBBox(); + } + auto finder = vol->GetVoxels(); + if (finder && finder->NeedRebuild()) { + finder->Voxelize(); + vol->FindOverlaps(); } } } diff --git a/alignment/FairAlignmentHandler.h b/alignment/FairAlignmentHandler.h index 3535ea5697..a9ca37181b 100644 --- a/alignment/FairAlignmentHandler.h +++ b/alignment/FairAlignmentHandler.h @@ -18,8 +18,8 @@ class FairAlignmentHandler void RecomputePhysicalAssmbBbox() const; public: - FairAlignmentHandler(); - virtual ~FairAlignmentHandler(); + FairAlignmentHandler() = default; + virtual ~FairAlignmentHandler() = default; }; #endif