From 9887d586325113d4a54e1f52fcc27d483b88345d Mon Sep 17 00:00:00 2001 From: "se.gorbunov" <se.gorbunov@gsi.de> Date: Tue, 22 Aug 2023 22:58:17 +0000 Subject: [PATCH] sts hithinder: fix rotation of the hit covariance matrix --- core/base/utils/CbmGeometryUtils.cxx | 27 +++++++++++++++++++++++ core/base/utils/CbmGeometryUtils.h | 10 +++++++++ reco/detectors/sts/CbmStsAlgoFindHits.cxx | 11 ++++----- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/core/base/utils/CbmGeometryUtils.cxx b/core/base/utils/CbmGeometryUtils.cxx index 41480c686e..5701b38c22 100644 --- a/core/base/utils/CbmGeometryUtils.cxx +++ b/core/base/utils/CbmGeometryUtils.cxx @@ -322,5 +322,32 @@ namespace Cbm } + void LocalToMasterCovarianceMatrix(const TGeoMatrix& m, Double_t& covXX, Double_t& covXY, Double_t& covYY) + { + // Fast calculation with skipping zeros + + // 3x3 covariance matrix. c01==c11, other elements are 0. + double c00 = covXX; + double c10 = covXY; + double c11 = covYY; + + // 3x3 transformation matrix. other elements will not be needed + double r00 = m.GetRotationMatrix()[0]; + double r01 = m.GetRotationMatrix()[1]; + double r10 = m.GetRotationMatrix()[3]; + double r11 = m.GetRotationMatrix()[4]; + + // rc == r * c + double rc00 = r00 * c00 + r01 * c10; + double rc01 = r00 * c10 + r01 * c11; + double rc10 = r10 * c00 + r11 * c10; + double rc11 = r10 * c10 + r11 * c11; + + // transformed c = rc * r^t + covXX = rc00 * r00 + rc01 * r01; + covXY = rc10 * r00 + rc11 * r01; + covYY = rc10 * r10 + rc11 * r11; + } + } // namespace GeometryUtils } // namespace Cbm diff --git a/core/base/utils/CbmGeometryUtils.h b/core/base/utils/CbmGeometryUtils.h index 401e189fbf..72b304c9c3 100644 --- a/core/base/utils/CbmGeometryUtils.h +++ b/core/base/utils/CbmGeometryUtils.h @@ -2,6 +2,8 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ +#include "Rtypes.h" + class TGeoMatrix; class TGeoVolume; class FairModule; @@ -24,5 +26,13 @@ namespace Cbm void AssignMediumAtImport(TGeoVolume* v); void ExpandNodes(TGeoVolume* volume, FairModule* mod); + + /// @brief Convert the local X/Y covariance matrix to global coordinates + /// @param m the transformation matrix + /// @param covXX covariance X,X + /// @param covXY covariance X,Y + /// @param covYY covariance Y,Y + void LocalToMasterCovarianceMatrix(const TGeoMatrix& m, Double_t& covXX, Double_t& covXY, Double_t& covYY); + } // namespace GeometryUtils } // namespace Cbm diff --git a/reco/detectors/sts/CbmStsAlgoFindHits.cxx b/reco/detectors/sts/CbmStsAlgoFindHits.cxx index 5f2634b96f..1d8cd6ef49 100644 --- a/reco/detectors/sts/CbmStsAlgoFindHits.cxx +++ b/reco/detectors/sts/CbmStsAlgoFindHits.cxx @@ -9,6 +9,7 @@ #include "CbmStsAlgoFindHits.h" #include "CbmDigiManager.h" +#include "CbmGeometryUtils.h" #include "CbmStsCluster.h" #include "CbmStsDigi.h" #include "CbmStsHit.h" @@ -40,17 +41,17 @@ void CbmStsAlgoFindHits::CreateHit(Double_t xLocal, Double_t yLocal, Double_t va // --- Transform into global coordinate system Double_t local[3] = {xLocal, yLocal, 0.}; Double_t global[3]; - if (fMatrix) fMatrix->LocalToMaster(local, global); + + if (fMatrix) { + fMatrix->LocalToMaster(local, global); + Cbm::GeometryUtils::LocalToMasterCovarianceMatrix(*fMatrix, varX, varXY, varY); + } else { global[0] = local[0]; global[1] = local[1]; global[2] = local[2]; } //? no transformation matrix available - // We assume here that the local-to-global transformations is only translation - // plus maybe rotation upside down or front-side back. In that case, the - // global covariance matrix is the same as the local one. - // TODO: Proper transformation of covariance matrix Double_t error[3] = {TMath::Sqrt(varX), TMath::Sqrt(varY), 0.}; // --- Calculate hit time (average of cluster times) -- GitLab