Skip to content

Commit 28d5a49

Browse files
PALoizeaukarabowi
authored andcommitted
Improve geometry state after alignment
1. Refresh the geometry once done (needed in any case) 2. Fix for GeoAssembly bounding box having 0 dx/dy after alignment Fix could be removed once proper fix is done in Root, should not hurt if done twice (cherry picked from commit 602f0af)
1 parent 956d0fc commit 28d5a49

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

alignment/FairAlignmentHandler.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <TGeoManager.h>
66
#include <TGeoPhysicalNode.h>
7+
#include <TGeoShapeAssembly.h>
78

89
FairAlignmentHandler::FairAlignmentHandler() {}
910

@@ -21,6 +22,13 @@ void FairAlignmentHandler::AlignGeometry() const
2122
AlignGeometryByFullPath();
2223
}
2324

25+
// --- Force BoundingBox recomputation for AssemblyVolumes as they may have been corrupted by alignment
26+
// FIXME: will hopefully be fixed in Root in near future, temp fix in meantime
27+
RecomputePhysicalAssmbBbox();
28+
29+
LOG(info) << "Refreshing geometry...";
30+
gGeoManager->RefreshPhysicalNodes(kFALSE);
31+
2432
LOG(info) << "alignment finished!";
2533
}
2634
}
@@ -93,3 +101,23 @@ void FairAlignmentHandler::AddAlignmentMatrices(const std::map<std::string, TGeo
93101
fAlignmentMatrices[m.first] *= m.second;
94102
}
95103
}
104+
105+
void FairAlignmentHandler::RecomputePhysicalAssmbBbox() const
106+
{
107+
TObjArray* pPhysNodesArr = gGeoManager->GetListOfPhysicalNodes();
108+
109+
TGeoPhysicalNode* pPhysNode = nullptr;
110+
TGeoShapeAssembly* pShapeAsb = nullptr;
111+
112+
Int_t iNbNodes = pPhysNodesArr->GetEntriesFast();
113+
for (Int_t iInd = 0; iInd < iNbNodes; ++iInd) {
114+
pPhysNode = dynamic_cast<TGeoPhysicalNode*>(pPhysNodesArr->At(iInd));
115+
if (pPhysNode) {
116+
pShapeAsb = dynamic_cast<TGeoShapeAssembly*>(pPhysNode->GetShape());
117+
if (pShapeAsb) {
118+
// Should reach here only if the original node was a TGeoShapeAssembly
119+
pShapeAsb->ComputeBBox();
120+
}
121+
}
122+
}
123+
}

alignment/FairAlignmentHandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class FairAlignmentHandler
1515

1616
void AddAlignmentMatrices(const std::map<std::string, TGeoHMatrix>& alignmentMatrices, bool invertMatrices);
1717

18+
void RecomputePhysicalAssmbBbox() const;
19+
1820
public:
1921
FairAlignmentHandler();
2022
virtual ~FairAlignmentHandler();

0 commit comments

Comments
 (0)