Skip to content

Commit

Permalink
Improve geometry state after alignment
Browse files Browse the repository at this point in the history
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
  • Loading branch information
PALoizeau committed Oct 21, 2022
1 parent 8501262 commit d6ecf62
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions alignment/FairAlignmentHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <TGeoManager.h>
#include <TGeoPhysicalNode.h>
#include <TGeoShapeAssembly.h>

FairAlignmentHandler::FairAlignmentHandler() {}

Expand All @@ -21,6 +22,13 @@ 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
RecomputePhysicalAssmbBbox();

LOG(info) << "Refreshing geometry...";
gGeoManager->RefreshPhysicalNodes();

LOG(info) << "alignment finished!";
}
}
Expand Down Expand Up @@ -93,3 +101,23 @@ void FairAlignmentHandler::AddAlignmentMatrices(const std::map<std::string, TGeo
fAlignmentMatrices[m.first] *= m.second;
}
}

void FairAlignmentHandler::RecomputePhysicalAssmbBbox() const
{
TObjArray* pPhysNodesArr = gGeoManager->GetListOfPhysicalNodes();

TGeoPhysicalNode* pPhysNode = nullptr;
TGeoShapeAssembly* pShapeAsb = nullptr;

Int_t iNbNodes = pPhysNodesArr->GetEntriesFast();
for (Int_t iInd = 0; iInd < iNbNodes; ++iInd) {
pPhysNode = dynamic_cast<TGeoPhysicalNode*>(pPhysNodesArr->At(iInd));
if (pPhysNode) {
pShapeAsb = dynamic_cast<TGeoShapeAssembly*>(pPhysNode->GetShape());
if (pShapeAsb) {
// Should reach here only if the original node was a TGeoShapeAssembly
pShapeAsb->ComputeBBox();
}
}
}
}
2 changes: 2 additions & 0 deletions alignment/FairAlignmentHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class FairAlignmentHandler

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

void RecomputePhysicalAssmbBbox() const;

public:
FairAlignmentHandler();
virtual ~FairAlignmentHandler();
Expand Down

0 comments on commit d6ecf62

Please sign in to comment.