Skip to content

Commit b4b5f0e

Browse files
committed
GeoAssembly bounding box after alignment: use ROOT expert patch
- cf discussion in root-project/root#12242 - Improvement of PR #1244 - see also Issue #1243 - Solves new sub-case of Cbmroot issue https://redmine.cbm.gsi.de/issues/2620 More generic solution also catching edge case where only Nodes inside assembly are aligned but not assembly itself
1 parent 703ea46 commit b4b5f0e

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

fairroot/alignment/FairAlignmentHandler.cxx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <TGeoManager.h>
55
#include <TGeoPhysicalNode.h>
66
#include <TGeoShapeAssembly.h>
7+
#include <TGeoVoxelFinder.h>
78
#include <fairlogger/Logger.h>
89

910
void FairAlignmentHandler::AlignGeometry() const
@@ -18,8 +19,9 @@ void FairAlignmentHandler::AlignGeometry() const
1819
AlignGeometryByFullPath();
1920
}
2021

21-
// --- Force BoundingBox recomputation for AssemblyVolumes as they may have been corrupted by alignment
22-
// FIXME: will hopefully be fixed in Root in near future, temp fix in meantime
22+
// --- Force BoundingBox recomputation for volumes/nodes needing it after alignment
23+
// FIXME: May be added to RefreshPhysicalNode step in Root in near future, temp fix needed here in meantime
24+
/// cf https://github.com/root-project/root/issues/12242
2325
RecomputePhysicalAssmbBbox();
2426

2527
LOG(info) << "Refreshing geometry...";
@@ -100,15 +102,23 @@ void FairAlignmentHandler::AddAlignmentMatrices(const std::map<std::string, TGeo
100102

101103
void FairAlignmentHandler::RecomputePhysicalAssmbBbox() const
102104
{
103-
TObjArray* pPhysNodesArr = gGeoManager->GetListOfPhysicalNodes();
104-
105-
for (auto pPhysNode : TRangeDynCast<TGeoPhysicalNode>(pPhysNodesArr)) {
106-
if (pPhysNode) {
107-
auto pShapeAsb = dynamic_cast<TGeoShapeAssembly*>(pPhysNode->GetShape());
108-
if (pShapeAsb) {
109-
// Should reach here only if the original node was a TGeoShapeAssembly
110-
pShapeAsb->ComputeBBox();
111-
}
105+
/// After alignment, forces the recomputation of the bounding box of all volumesAssemblies and the rebuilding of
106+
/// Nodes requiring it.
107+
/// => Not done after each change to geometry in ROOT for perf reason
108+
/// => to be called once all changes done
109+
/// => original snippet proposed in https://github.com/root-project/root/issues/12242 by A. Gheata
110+
TObjArray* volumes = gGeoManager->GetListOfVolumes();
111+
for (auto vol : TRangeDynCast<TGeoVolume>(volumes)) {
112+
if (!vol) {
113+
continue;
114+
}
115+
if (vol->IsAssembly()) {
116+
vol->GetShape()->ComputeBBox();
117+
}
118+
auto finder = vol->GetVoxels();
119+
if (finder && finder->NeedRebuild()) {
120+
finder->Voxelize();
121+
vol->FindOverlaps();
112122
}
113123
}
114124
}

0 commit comments

Comments
 (0)