diff --git a/core/base/utils/CbmGeometryUtils.cxx b/core/base/utils/CbmGeometryUtils.cxx index 41480c686e493cec8a5577f1bebf46138460281c..5701b38c22cdba9787a8479e091bfdbd931fecfc 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 401e189fbf79dd32ee0a53fab731aa92bd1d6089..72b304c9c3152524df29ab1e3dca7b75167d0116 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 5f2634b96fcb41a7cf1b75d0b3c48daddc1d8f9a..1d8cd6ef4905e7b5243f264108c4614bd1703214 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)