diff --git a/core/detectors/fsd/CbmFsdGeoHandler.cxx b/core/detectors/fsd/CbmFsdGeoHandler.cxx index d1b311fbb09349d02f581927dec2f693555a4f24..1535e5e477a4edacf3c94ebafd1ca35ce3100c7d 100644 --- a/core/detectors/fsd/CbmFsdGeoHandler.cxx +++ b/core/detectors/fsd/CbmFsdGeoHandler.cxx @@ -14,6 +14,7 @@ #include <TGeoMatrix.h> // for TGeoMatrix #include <TGeoNode.h> // for TGeoIterator, TGeoNode #include <TGeoVolume.h> // for TGeoVolume +#include <TVector3.h> // for TVector3 #include <TVirtualMC.h> // for TVirtualMC, gMC #include <string> // for operator<, stoul @@ -37,6 +38,7 @@ void CbmFsdGeoHandler::InitMaps() TGeoIterator geoIterator(gGeoManager->GetTopNode()->GetVolume()); TGeoNode* curNode; + TGeoCombiTrans* unitToGlobalMatrix = nullptr; geoIterator.Reset(); // safety to reset to "cave" befor the loop starts while ((curNode = geoIterator())) { TString nodePath; @@ -50,6 +52,9 @@ void CbmFsdGeoHandler::InitMaps() if (nodeName.Contains(fUnitStr)) { currentUnitId = curNode->GetNumber(); + const TGeoMatrix* curUnitMatrix = geoIterator.GetCurrentMatrix(); + unitToGlobalMatrix = new TGeoCombiTrans(*(curUnitMatrix)); + CbmFsdUnitSpecs* unitSpecs = new CbmFsdUnitSpecs(); unitSpecs->fUnitId = currentUnitId; unitSpecs->fUnitName = static_cast<TString>(curNode->GetVolume()->GetName()); @@ -58,8 +63,14 @@ void CbmFsdGeoHandler::InitMaps() } if (nodeName.Contains(fModuleStr)) { currentModuleId = curNode->GetNumber(); - const TGeoMatrix* curMatrix = geoIterator.GetCurrentMatrix(); - const Double_t* curNodeTr = curMatrix->GetTranslation(); + + TGeoMatrix* moduleToUnitMatrix = curNode->GetMatrix(); + TVector3 localModuleCoord(moduleToUnitMatrix->GetTranslation()); + TVector3 globalModuleCoord; + if (!unitToGlobalMatrix) { + LOG(fatal) << "No parent (unit) matrix initialized!!"; + } + unitToGlobalMatrix->LocalToMaster(&localModuleCoord[0], &globalModuleCoord[0]); TGeoVolume* curScintillator = nullptr; for (int idn = 0; idn < curNode->GetNdaughters(); idn++) { @@ -72,9 +83,9 @@ void CbmFsdGeoHandler::InitMaps() const TGeoBBox* shape = (const TGeoBBox*) (curScintillator->GetShape()); CbmFsdModuleSpecs* moduleSpecs = new CbmFsdModuleSpecs(); - moduleSpecs->fX = curNodeTr[0]; - moduleSpecs->fY = curNodeTr[1]; - moduleSpecs->fZ = curNodeTr[2]; + moduleSpecs->fX = globalModuleCoord[0]; + moduleSpecs->fY = globalModuleCoord[1]; + moduleSpecs->fZ = globalModuleCoord[2]; moduleSpecs->dX = shape->GetDX(); moduleSpecs->dY = shape->GetDY(); moduleSpecs->dZ = shape->GetDZ();