diff --git a/alignment/FairAlignmentHandler.cxx b/alignment/FairAlignmentHandler.cxx index 5e8bf25403..cb63e623a4 100644 --- a/alignment/FairAlignmentHandler.cxx +++ b/alignment/FairAlignmentHandler.cxx @@ -4,6 +4,7 @@ #include #include +#include FairAlignmentHandler::FairAlignmentHandler() {} @@ -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(kFALSE); + LOG(info) << "alignment finished!"; } } @@ -93,3 +101,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(); + } + } + } +} diff --git a/alignment/FairAlignmentHandler.h b/alignment/FairAlignmentHandler.h index 1bae25bd78..3535ea5697 100644 --- a/alignment/FairAlignmentHandler.h +++ b/alignment/FairAlignmentHandler.h @@ -15,6 +15,8 @@ class FairAlignmentHandler void AddAlignmentMatrices(const std::map& alignmentMatrices, bool invertMatrices); + void RecomputePhysicalAssmbBbox() const; + public: FairAlignmentHandler(); virtual ~FairAlignmentHandler(); diff --git a/examples/simulation/Tutorial4/macros/plots.C b/examples/simulation/Tutorial4/macros/plots.C index a41d4b96fe..718ad09c60 100644 --- a/examples/simulation/Tutorial4/macros/plots.C +++ b/examples/simulation/Tutorial4/macros/plots.C @@ -128,7 +128,13 @@ int plots(Int_t nEvents = 1000, Int_t iout = 1, TString mcEngine = "align_TGeant } // event loop end auto pullx_Ent = pullx->GetEntries(); + auto pullx_Mea = pullx->GetMean(); + auto pully_Mea = pully->GetMean(); + auto pullz_Mea = pullz->GetMean(); auto pullx_Dev = pullx->GetStdDev(); + auto pully_Dev = pully->GetStdDev(); + auto pullz_Dev = pullz->GetStdDev(); + cout << "Mean (" << pullx_Mea << ", " << pully_Mea << ", " << pullz_Mea << ") " << endl; // save histos to file // TFile *fHist = TFile::Open("data/auaumbias.hst.root","RECREATE"); @@ -164,13 +170,13 @@ int plots(Int_t nEvents = 1000, Int_t iout = 1, TString mcEngine = "align_TGeant cout << "Parameter file is " << ParFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; - if (nevent >= 10 && pullx_Ent > nevent * 35 && abs(pullx_Dev - 0.1) < 0.03) + if (nevent >= 10 && pullx_Ent > nevent * 35 && abs(pullx_Dev - 0.1) < 0.03 && abs(pully_Dev - 0.1) < 0.04) cout << "Macro finished successfully. Number of events (" << nevent << "), hist entries (" << pullx_Ent - << ") and deviation (" << pullx_Dev << ") inside limits." << endl; + << ") and deviation (" << pullx_Dev << ", " << pully_Dev << ", " << pullz_Dev << ") inside limits." + << endl; else cout << "Macro failed. Number of events (" << nevent << "), hist entries (" << pullx_Ent << ") or deviation (" - << pullx_Dev << ") too far off." << endl; - + << pullx_Dev << ", " << pully_Dev << ", " << pullz_Dev << ") too far off." << endl; // ------------------------------------------------------------------------ return 0;