From 3342528c080bfa129660a8c2370e65b8043f3a3f Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Tue, 8 Nov 2022 10:33:52 +0100 Subject: [PATCH] Move cluster error to weighted mean position error, based on cell size --- DataFormats/FTLRecHit/interface/FTLCluster.h | 12 ++++++++++++ .../FTLClusterizer/interface/MTDCPEBase.h | 2 ++ RecoLocalFastTime/FTLClusterizer/src/MTDCPEBase.cc | 7 ++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/DataFormats/FTLRecHit/interface/FTLCluster.h b/DataFormats/FTLRecHit/interface/FTLCluster.h index 2a45a93fee89a..51e0e26c0f9f6 100644 --- a/DataFormats/FTLRecHit/interface/FTLCluster.h +++ b/DataFormats/FTLRecHit/interface/FTLCluster.h @@ -127,6 +127,18 @@ class FTLCluster { return weighted_mean(this->theHitENERGY, y_pos); } + inline float positionError(const float sigmaPos) const { + float sumW2(0.f), sumW(0.f); + for (const auto& hitW : theHitENERGY) { + sumW2 += hitW * hitW; + sumW += hitW; + } + if (sumW > 0) + return sigmaPos * std::sqrt(sumW2) / sumW; + else + return -999.f; + } + inline float time() const { auto t = [this](unsigned int i) { return this->theHitTIME[i]; }; return weighted_mean(this->theHitENERGY, t); diff --git a/RecoLocalFastTime/FTLClusterizer/interface/MTDCPEBase.h b/RecoLocalFastTime/FTLClusterizer/interface/MTDCPEBase.h index 4330904c84224..125abb8fa5779 100644 --- a/RecoLocalFastTime/FTLClusterizer/interface/MTDCPEBase.h +++ b/RecoLocalFastTime/FTLClusterizer/interface/MTDCPEBase.h @@ -80,6 +80,8 @@ class MTDCPEBase : public MTDClusterParameterEstimator { virtual TimeValue clusterTime(DetParam const& dp, ClusterParam& cp) const; virtual TimeValueError clusterTimeError(DetParam const& dp, ClusterParam& cp) const; + static constexpr float sigma_flat = 1.f / std::sqrt(12.f); + protected: //--------------------------------------------------------------------------- // Data members diff --git a/RecoLocalFastTime/FTLClusterizer/src/MTDCPEBase.cc b/RecoLocalFastTime/FTLClusterizer/src/MTDCPEBase.cc index 85d7aec9a379c..8f0c6b63af812 100644 --- a/RecoLocalFastTime/FTLClusterizer/src/MTDCPEBase.cc +++ b/RecoLocalFastTime/FTLClusterizer/src/MTDCPEBase.cc @@ -66,10 +66,11 @@ LocalPoint MTDCPEBase::localPosition(DetParam const& dp, ClusterParam& cp) const } LocalError MTDCPEBase::localError(DetParam const& dp, ClusterParam& cp) const { - constexpr double one_over_twelve = 1. / 12.; MeasurementPoint pos(cp.theCluster->x(), cp.theCluster->y()); - MeasurementError simpleRect(one_over_twelve, 0, one_over_twelve); - return dp.theTopol->localError(pos, simpleRect); + float sigma2 = cp.theCluster->positionError(sigma_flat); + sigma2 *= sigma2; + MeasurementError posErr(sigma2, 0, sigma2); + return dp.theTopol->localError(pos, posErr); } MTDCPEBase::TimeValue MTDCPEBase::clusterTime(DetParam const& dp, ClusterParam& cp) const {