From 0cc3112e4b110633bbf4e5beb614be286fa96f7a Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Mon, 13 Feb 2023 20:28:58 +0100
Subject: [PATCH] QA: Improvements to CbmQaEff (integrated efficiency and
 drawing methods)

---
 core/qa/CbmQaEff.cxx                      | 93 +++++++++++++++++++++--
 core/qa/CbmQaEff.h                        | 40 +++++++++-
 macro/{run/run_reco_qa.C => qa/test_qa.C} |  9 ++-
 reco/L1/CMakeLists.txt                    |  4 +-
 reco/L1/qa/CbmCaInputQaMuch.cxx           | 21 +----
 reco/L1/qa/CbmCaInputQaSts.cxx            | 22 +-----
 reco/L1/qa/CbmCaInputQaTof.cxx            | 21 +----
 reco/L1/qa/CbmCaInputQaTof.h              |  2 +-
 reco/L1/qa/CbmCaInputQaTrd.cxx            | 23 +-----
 reco/L1/qa/CbmCaInputQaTrd.h              |  6 +-
 reco/L1/qa/CbmCaQaCuts.h                  | 16 ----
 11 files changed, 152 insertions(+), 105 deletions(-)
 rename macro/{run/run_reco_qa.C => qa/test_qa.C} (96%)
 delete mode 100644 reco/L1/qa/CbmCaQaCuts.h

diff --git a/core/qa/CbmQaEff.cxx b/core/qa/CbmQaEff.cxx
index 02d295c68c..d4b18167bf 100644
--- a/core/qa/CbmQaEff.cxx
+++ b/core/qa/CbmQaEff.cxx
@@ -21,11 +21,59 @@ CbmQaEff::CbmQaEff() : TEfficiency() {}
 //
 CbmQaEff::CbmQaEff(const CbmQaEff& other) : TEfficiency(other) {}
 
+// ---------------------------------------------------------------------------------------------------------------------
+//
+std::tuple<double, double, double> CbmQaEff::GetTotalEfficiency() const
+{
+  // The efficiency is always calculated based on the number of passed events and total events, which are stored in the
+  // corresponding histograms inside the TEfficiency object. To get an integrated efficiency one needs just carefully
+  // re-bin these histograms and pass them to the TEfficiency ctor.
+  auto pHistP = std::unique_ptr<TH1>((TH1*) this->GetPassedHistogram()->Clone());
+  auto pHistT = std::unique_ptr<TH1>((TH1*) this->GetTotalHistogram()->Clone());
+
+  // X-axis range to calculate integrated efficiency
+  double range[2] = {pHistP->GetXaxis()->GetXmin(), pHistP->GetXaxis()->GetXmax()};
+
+  // Define the re-binned histograms
+  std::unique_ptr<TH1> pHistPR = nullptr;  // re-binned histogram of passed events
+  std::unique_ptr<TH1> pHistTR = nullptr;  // re-binned histogram of total events
+
+  if (GetDimension() == 1) {
+    pHistPR = std::unique_ptr<TH1>(pHistP->Rebin(1, "tmp_passed", range));
+    pHistTR = std::unique_ptr<TH1>(pHistT->Rebin(1, "tmp_total", range));
+  }
+  if (GetDimension() == 2) {
+    auto pHistPProj = std::unique_ptr<TH1>(static_cast<TH2*>(pHistP.get())->ProjectionX());
+    auto pHistTProj = std::unique_ptr<TH1>(static_cast<TH2*>(pHistT.get())->ProjectionX());
+
+    pHistPR = std::unique_ptr<TH1>(pHistPProj->Rebin(1, "tmp_passed", range));
+    pHistTR = std::unique_ptr<TH1>(pHistTProj->Rebin(1, "tmp_total", range));
+  }
+
+  // Define temporary efficiency, copy all the attributes
+  auto pIntEff = std::make_unique<TEfficiency>(*pHistPR, *pHistTR);
+  pIntEff->SetBetaAlpha(fBeta_alpha);
+  pIntEff->SetBetaBeta(fBeta_beta);
+  pIntEff->SetConfidenceLevel(fConfLevel);
+  pIntEff->SetWeight(fWeight);
+  pIntEff->SetStatisticOption(fStatisticOption);
+  pIntEff->SetPosteriorMode(this->UsesPosteriorMode());
+  pIntEff->SetCentralInterval(this->UsesCentralInterval());
+
+  double effV = pIntEff->GetEfficiency(1);
+  double effL = pIntEff->GetEfficiencyErrorLow(1);
+  double effU = pIntEff->GetEfficiencyErrorUp(1);
+
+  return {effV, effL, effU};
+}
+
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
 CbmQaEff* CbmQaEff::Integral(double lo, double hi)
 {
+  if (GetDimension() != 1) { return nullptr; }  // For now efficiency integration works only for 1D
+
   // Underlying histograms with passed and total events
   auto* pPassed = (TH1D*) (this->GetPassedHistogram());
   auto* pTotal  = (TH1D*) (this->GetTotalHistogram());
@@ -47,17 +95,48 @@ CbmQaEff* CbmQaEff::Integral(double lo, double hi)
   auto& histPassedReb = *(pPassed->Rebin(1, "ptmp", range));
   auto& histTotalReb  = *(pTotal->Rebin(1, "ttmp", range));
 
-  LOG(info) << "DEBUG: " << this->GetName() << ": passed: " << pPassed->GetEntries();
-  LOG(info) << "DEBUG: " << this->GetName() << ": total: " << pTotal->GetEntries();
-  LOG(info) << "DEBUG: " << this->GetName() << ": passed: " << histPassedReb.GetBinContent(1) << ' '
-            << histPassedReb.GetBinError(1);
-  LOG(info) << "DEBUG: " << this->GetName() << ": total: " << histTotalReb.GetBinContent(1) << ' '
-            << histPassedReb.GetBinError(1);
-
   TString sName = Form("%s_integrated", this->GetName());
 
   // New efficiency
   auto* pIntEff = new CbmQaEff(TEfficiency(histPassedReb, histTotalReb));
+
   pIntEff->SetName(sName);
   return pIntEff;
 }
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+CbmQaEff* CbmQaEff::DrawCopy(Option_t* opt, const char* postfix) const
+{
+  TString option = opt;
+  option.ToLower();
+  if (gPad && !option.Contains("same")) { gPad->Clear(); }
+  TString newName = "";
+  if (postfix) { newName.Form("%s%s", GetName(), postfix); }
+  CbmQaEff* pNewEff = (CbmQaEff*) Clone(newName.Data());
+  pNewEff->SetDirectory(nullptr);
+  pNewEff->SetBit(kCanDelete);
+  if (gPad) gPad->IncrementPaletteColor(1, option);
+  pNewEff->AppendPad(option);
+  return pNewEff;
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void CbmQaEff::SetStats()
+{
+  if (!fpStats) {
+    fpStats = new TPaveText(0.20, 0.17, 0.80, 0.24, "NDC");
+    fpStats->SetFillColor(0);
+
+    // Add integrated efficiency
+    auto [effVal, effLErr, effUErr] = this->GetTotalEfficiency();
+
+    fpStats->SetTextFont(42);
+    fpStats->SetTextSize(0.05);
+    fpStats->SetBorderSize(0);
+    fpStats->SetFillColor(0);
+    fpStats->AddText(0, 0,
+                     Form("#epsilon_{tot} = %.4f_{-%.4f}^{+%.4f} (CL %3.3f)", effVal, effLErr, effUErr, fConfLevel));
+  }
+}
diff --git a/core/qa/CbmQaEff.h b/core/qa/CbmQaEff.h
index 40977f08a3..f31fd14675 100644
--- a/core/qa/CbmQaEff.h
+++ b/core/qa/CbmQaEff.h
@@ -20,14 +20,18 @@
 #include "TGraphAsymmErrors.h"
 #include "TH2.h"
 #include "TPaveStats.h"
+#include "TPaveText.h"
 #include "TStyle.h"
 #include "TVirtualPad.h"
 
+#include <tuple>
 
 /// Implementation of ROOT TEfficiency class, which adds handy functionality and improves fitting and drawing
 ///
 class CbmQaEff : public TEfficiency {
 public:
+  static constexpr int kMarkerStyle = 20;
+
   /// Default constructor
   CbmQaEff();
 
@@ -49,14 +53,48 @@ public:
     return TEfficiency::Fit(args...);
   }
 
-  /// Integrates efficiency over the range
+  void Paint(Option_t* opt)
+  {
+    TEfficiency::Paint(opt);
+    SetStats();
+    if (fpStats) { fpStats->Draw(); }
+  }
+
+  void Draw(Option_t* opt = "")
+  {
+    if (GetDimension() == 1) { this->SetMarkerStyle(kMarkerStyle); }
+    TEfficiency::Draw(opt);
+  }
+
+  /// Draws copy of the object
+  /// \param opt     Option string
+  /// \param postfix Postfix of the name
+  CbmQaEff* DrawCopy(Option_t* opt, const char* postfix = "_copy") const;
+
+  /// Gets integrated efficiency in a selected range
+  /// \note Works only for 1D efficiency
   /// \param  lo  Lower bound of integration range
   /// \param  hi  Higher bound of integration range
   /// \return Pointer to efficiency object, which contains only one point
   CbmQaEff* Integral(double lo, double hi);
 
+  /// Gets total integrated efficiency
+  /// \return A tuple:
+  ///         - 0: value
+  ///         - 1: lower error
+  ///         - 2: upper error
+  std::tuple<double, double, double> GetTotalEfficiency() const;
+
+  /// @brief Sets statistics box for efficiency
+  void SetStats();
 
   ClassDef(CbmQaEff, 1);
+
+private:
+  TPaveText* fpStats = nullptr;  ///< Statistics box
+
+  // Functions of the base class, using which can produce inconsistent results
+  using TEfficiency::SetBetaBinParameters;
 };
 
 // **********************************************************
diff --git a/macro/run/run_reco_qa.C b/macro/qa/test_qa.C
similarity index 96%
rename from macro/run/run_reco_qa.C
rename to macro/qa/test_qa.C
index 446121bace..ec44c73965 100644
--- a/macro/run/run_reco_qa.C
+++ b/macro/qa/test_qa.C
@@ -37,10 +37,11 @@
 #include <TStopwatch.h>
 #endif
 
-void run_reco_qa(TString dataTra = "data/sis100_muon_jpsi_test", TString dataRaw = "data/sis100_muon_jpsi_test",
-                 TString dataReco = "data/sis100_muon_jpsi_test", TString dataPar = "data/sis100_muon_jpsi_test",
-                 TString dataSink = "data/sis100_muon_jpsi_test", TString setup = "sis100_muon_jpsi",
-                 Int_t nEvents = -1, TString dataTra2 = "", TString dataTra3 = "")
+// TODO: split into functions for reco, digitization and transport QAs
+void test_qa(TString dataTra = "data/sis100_muon_jpsi_test", TString dataRaw = "data/sis100_muon_jpsi_test",
+             TString dataReco = "data/sis100_muon_jpsi_test", TString dataPar = "data/sis100_muon_jpsi_test",
+             TString dataSink = "data/sis100_muon_jpsi_test", TString setup = "sis100_muon_jpsi", Int_t nEvents = -1,
+             TString dataTra2 = "", TString dataTra3 = "")
 {
 
   gROOT->SetBatch(kTRUE);
diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt
index 2532b316b5..0168f1d368 100644
--- a/reco/L1/CMakeLists.txt
+++ b/reco/L1/CMakeLists.txt
@@ -102,8 +102,7 @@ set(HEADERS
   L1Algo/L1Undef.h
   catools/CaToolsWindowFinder.h
   catools/CaToolsLinkKey.h
-  qa/CbmCaQaCuts.h
-  
+  qa/CbmCaInputQaBase.h
 )
 
 
@@ -206,6 +205,7 @@ install(FILES CbmL1Counters.h
               L1Algo/L1SimdSerializer.h
               L1Algo/L1TrackPar.h
               L1Algo/L1Track.h
+              qa/CbmCaInputQaBase.h
         DESTINATION include
        )
 
diff --git a/reco/L1/qa/CbmCaInputQaMuch.cxx b/reco/L1/qa/CbmCaInputQaMuch.cxx
index ed8d3d823c..272a448535 100644
--- a/reco/L1/qa/CbmCaInputQaMuch.cxx
+++ b/reco/L1/qa/CbmCaInputQaMuch.cxx
@@ -131,8 +131,7 @@ bool CbmCaInputQaMuch::Check()
     pEffTable->SetColWidth(20);
 
     for (int iSt = 0; iSt < nSt; ++iSt) {
-      auto pEff  = std::unique_ptr<CbmQaEff>(fvpe_reco_eff_vs_r[iSt]->Integral(fEffRange[0], fEffRange[1]));
-      double eff = pEff->GetEfficiency(1);
+      auto [eff, effEL, effEU] = fvpe_reco_eff_vs_r[iSt]->GetTotalEfficiency();
       pEffTable->SetCell(iSt, 0, iSt);
       pEffTable->SetCell(iSt, 1, eff);
       res = CheckRange("Hit finder efficiency in station " + std::to_string(iSt), eff, fEffThrsh, 1.000);
@@ -820,27 +819,15 @@ InitStatus CbmCaInputQaMuch::InitCanvases()
     pc_reco_eff_vs_r->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_r->cd(iSt + 1);
-      fvpe_reco_eff_vs_r[iSt]->Paint("AP");
-      auto* pGr = dynamic_cast<TGraphAsymmErrors*>(fvpe_reco_eff_vs_r[iSt]->GetPaintedGraph());
-      if (!pGr) {
-        LOG(error) << fName << ": unable to get painted graph from efficiency " << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pGr->DrawClone("AP");
+      fvpe_reco_eff_vs_r[iSt]->SetMarkerStyle(20);
+      fvpe_reco_eff_vs_r[iSt]->DrawCopy("AP", "");
     }
 
     auto* pc_reco_eff_vs_xy = MakeCanvas<CbmQaCanvas>("reco_eff_vs_xy", "Hit efficiencies wrt x and y", 1600, 800);
     pc_reco_eff_vs_xy->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_xy->cd(iSt + 1);
-      fvpe_reco_eff_vs_xy[iSt]->Paint("colz");
-      auto* pH2 = dynamic_cast<TH2F*>(fvpe_reco_eff_vs_xy[iSt]->GetPaintedHistogram());
-      if (!pH2) {
-        LOG(error) << fName << ": unable to get painted histogram from efficiency "
-                   << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pH2->DrawCopy("colz", "");
+      fvpe_reco_eff_vs_xy[iSt]->DrawCopy("colz", "");
     }
   }
 
diff --git a/reco/L1/qa/CbmCaInputQaSts.cxx b/reco/L1/qa/CbmCaInputQaSts.cxx
index a616e002e4..26c4b9dd42 100644
--- a/reco/L1/qa/CbmCaInputQaSts.cxx
+++ b/reco/L1/qa/CbmCaInputQaSts.cxx
@@ -126,15 +126,13 @@ bool CbmCaInputQaSts::Check()
     //
     // Fit efficiency curves
     LOG(info) << "-- Hit efficiency integrated over hit distance from station center";
-    LOG(info) << "\tintegration range: [" << fEffRange[0] << ", " << fEffRange[1] << "] cm";
 
     auto* pEffTable = MakeTable("eff_table", "Efficiency table", nSt, 2);
     pEffTable->SetNamesOfCols({"Station ID", "Efficiency"});
     pEffTable->SetColWidth(20);
 
     for (int iSt = 0; iSt < nSt; ++iSt) {
-      auto pEff  = std::unique_ptr<CbmQaEff>(fvpe_reco_eff_vs_r[iSt]->Integral(fEffRange[0], fEffRange[1]));
-      double eff = pEff->GetEfficiency(1);
+      auto [eff, effEL, effEU] = fvpe_reco_eff_vs_r[iSt]->GetTotalEfficiency();
       pEffTable->SetCell(iSt, 0, iSt);
       pEffTable->SetCell(iSt, 1, eff);
       res = CheckRange("Hit finder efficiency in station " + std::to_string(iSt), eff, fEffThrsh, 1.000);
@@ -900,27 +898,15 @@ InitStatus CbmCaInputQaSts::InitCanvases()
     pc_reco_eff_vs_r->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_r->cd(iSt + 1);
-      fvpe_reco_eff_vs_r[iSt]->Paint("AP");
-      auto* pGr = dynamic_cast<TGraphAsymmErrors*>(fvpe_reco_eff_vs_r[iSt]->GetPaintedGraph());
-      if (!pGr) {
-        LOG(error) << fName << ": unable to get painted graph from efficiency " << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pGr->DrawClone("AP");
+      fvpe_reco_eff_vs_r[iSt]->SetMarkerStyle(20);
+      fvpe_reco_eff_vs_r[iSt]->DrawCopy("AP", "");
     }
 
     auto* pc_reco_eff_vs_xy = MakeCanvas<CbmQaCanvas>("reco_eff_vs_xy", "Hit efficiencies wrt x and y", 1600, 800);
     pc_reco_eff_vs_xy->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_xy->cd(iSt + 1);
-      fvpe_reco_eff_vs_xy[iSt]->Paint("colz");
-      auto* pH2 = dynamic_cast<TH2F*>(fvpe_reco_eff_vs_xy[iSt]->GetPaintedHistogram());
-      if (!pH2) {
-        LOG(error) << fName << ": unable to get painted histogram from efficiency "
-                   << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pH2->DrawCopy("colz", "");
+      fvpe_reco_eff_vs_xy[iSt]->DrawCopy("colz", "");
     }
   }
 
diff --git a/reco/L1/qa/CbmCaInputQaTof.cxx b/reco/L1/qa/CbmCaInputQaTof.cxx
index cb0e89ae7f..db984e9c1d 100644
--- a/reco/L1/qa/CbmCaInputQaTof.cxx
+++ b/reco/L1/qa/CbmCaInputQaTof.cxx
@@ -134,8 +134,7 @@ bool CbmCaInputQaTof::Check()
     pEffTable->SetColWidth(20);
 
     for (int iSt = 0; iSt < nSt; ++iSt) {
-      auto pEff  = std::unique_ptr<CbmQaEff>(fvpe_reco_eff_vs_r[iSt]->Integral(fEffRange[0], fEffRange[1]));
-      double eff = pEff->GetEfficiency(1);
+      auto [eff, effEL, effEU] = fvpe_reco_eff_vs_r[iSt]->GetTotalEfficiency();
       pEffTable->SetCell(iSt, 0, iSt);
       pEffTable->SetCell(iSt, 1, eff);
       res = CheckRange("Hit finder efficiency in station " + std::to_string(iSt), eff, fEffThrsh, 1.000);
@@ -908,27 +907,15 @@ InitStatus CbmCaInputQaTof::InitCanvases()
     pc_reco_eff_vs_r->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_r->cd(iSt + 1);
-      fvpe_reco_eff_vs_r[iSt]->Paint("AP");
-      auto* pGr = dynamic_cast<TGraphAsymmErrors*>(fvpe_reco_eff_vs_r[iSt]->GetPaintedGraph());
-      if (!pGr) {
-        LOG(error) << fName << ": unable to get painted graph from efficiency " << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pGr->DrawClone("AP");
+      fvpe_reco_eff_vs_r[iSt]->SetMarkerStyle(20);
+      fvpe_reco_eff_vs_r[iSt]->DrawCopy("AP", "");
     }
 
     auto* pc_reco_eff_vs_xy = MakeCanvas<CbmQaCanvas>("reco_eff_vs_xy", "Hit efficiencies wrt x and y", 1600, 800);
     pc_reco_eff_vs_xy->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_xy->cd(iSt + 1);
-      fvpe_reco_eff_vs_xy[iSt]->Paint("colz");
-      auto* pH2 = dynamic_cast<TH2F*>(fvpe_reco_eff_vs_xy[iSt]->GetPaintedHistogram());
-      if (!pH2) {
-        LOG(error) << fName << ": unable to get painted histogram from efficiency "
-                   << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pH2->DrawCopy("colz", "");
+      fvpe_reco_eff_vs_xy[iSt]->DrawCopy("colz", "");
     }
   }
 
diff --git a/reco/L1/qa/CbmCaInputQaTof.h b/reco/L1/qa/CbmCaInputQaTof.h
index 3bf035ced9..02062816a7 100644
--- a/reco/L1/qa/CbmCaInputQaTof.h
+++ b/reco/L1/qa/CbmCaInputQaTof.h
@@ -119,7 +119,7 @@ private:
   static constexpr double kRHitDt[2] = {-10., 10.};   ///< Range for hit time [ns]
 
   static constexpr double kRResX[2] = {-2., 2.};  ///< Range for residual of x coordinate [cm]
-  static constexpr double kRResY[2] = {-2., 2.};  ///< Range for residual of y coordinate [cm]
+  static constexpr double kRResY[2] = {-4., 4.};  ///< Range for residual of y coordinate [cm]
   static constexpr double kRResT[2] = {-.5, .5};  ///< Range for residual of time [ns]
 
   static constexpr double kRPullX[2] = {-10., 10.};  ///< Range for pull of x coordinate
diff --git a/reco/L1/qa/CbmCaInputQaTrd.cxx b/reco/L1/qa/CbmCaInputQaTrd.cxx
index e97fa1a4a1..827f066b38 100644
--- a/reco/L1/qa/CbmCaInputQaTrd.cxx
+++ b/reco/L1/qa/CbmCaInputQaTrd.cxx
@@ -130,8 +130,7 @@ bool CbmCaInputQaTrd::Check()
     pEffTable->SetColWidth(20);
 
     for (int iSt = 0; iSt < nSt; ++iSt) {
-      auto pEff  = std::unique_ptr<CbmQaEff>(fvpe_reco_eff_vs_r[iSt]->Integral(fEffRange[0], fEffRange[1]));
-      double eff = pEff->GetEfficiency(1);
+      auto [eff, effEL, effEU] = fvpe_reco_eff_vs_r[iSt]->GetTotalEfficiency();
       pEffTable->SetCell(iSt, 0, iSt);
       pEffTable->SetCell(iSt, 1, eff);
       res = CheckRange("Hit finder efficiency in station " + std::to_string(iSt), eff, fEffThrsh, 1.000);
@@ -822,29 +821,15 @@ InitStatus CbmCaInputQaTrd::InitCanvases()
     pc_reco_eff_vs_r->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_r->cd(iSt + 1);
-      fvpe_reco_eff_vs_r[iSt]->Paint("AP");
-      auto* pGr = dynamic_cast<TGraphAsymmErrors*>(fvpe_reco_eff_vs_r[iSt]->GetPaintedGraph());
-      if (!pGr) {
-        LOG(error) << fName << ": unable to get painted graph from efficiency " << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pGr->DrawClone("AP");
-      auto* pFit = (TF1*) pGr->FindObject("pol0");
-      if (pFit) { pFit->Draw("SAME"); }
+      fvpe_reco_eff_vs_r[iSt]->SetMarkerStyle(20);
+      fvpe_reco_eff_vs_r[iSt]->DrawCopy("AP", "");
     }
 
     auto* pc_reco_eff_vs_xy = MakeCanvas<CbmQaCanvas>("reco_eff_vs_xy", "Hit efficiencies wrt x and y", 1600, 800);
     pc_reco_eff_vs_xy->Divide2D(nSt);
     for (int iSt = 0; iSt < nSt; ++iSt) {
       pc_reco_eff_vs_xy->cd(iSt + 1);
-      fvpe_reco_eff_vs_xy[iSt]->Paint("colz");
-      auto* pH2 = dynamic_cast<TH2F*>(fvpe_reco_eff_vs_xy[iSt]->GetPaintedHistogram());
-      if (!pH2) {
-        LOG(error) << fName << ": unable to get painted histogram from efficiency "
-                   << fvpe_reco_eff_vs_xy[iSt]->GetName();
-        continue;
-      }
-      pH2->DrawCopy("colz", "");
+      fvpe_reco_eff_vs_xy[iSt]->DrawCopy("colz", "");
     }
   }
 
diff --git a/reco/L1/qa/CbmCaInputQaTrd.h b/reco/L1/qa/CbmCaInputQaTrd.h
index 9e9f403ea8..db714adbf8 100644
--- a/reco/L1/qa/CbmCaInputQaTrd.h
+++ b/reco/L1/qa/CbmCaInputQaTrd.h
@@ -108,9 +108,9 @@ private:
   static constexpr double kRHitDy[2] = {-.05, .005};  ///< Range for hit y coordinate [cm]
   static constexpr double kRHitDt[2] = {-10., 10.};   ///< Range for hit time [ns]
 
-  static constexpr double kRResX[2] = {-.4, .4};  ///< Range for residual of x coordinate [cm]
-  static constexpr double kRResY[2] = {-.4, .4};  ///< Range for residual of y coordinate [cm]
-  static constexpr double kRResT[2] = {-5., 5.};  ///< Range for residual of time [ns]
+  static constexpr double kRResX[2] = {-2., 2.};    ///< Range for residual of x coordinate [cm]
+  static constexpr double kRResY[2] = {-2., 2.};    ///< Range for residual of y coordinate [cm]
+  static constexpr double kRResT[2] = {-20., 20.};  ///< Range for residual of time [ns]
 
   static constexpr double kRPullX[2] = {-10., 10.};  ///< Range for pull of x coordinate
   static constexpr double kRPullY[2] = {-10., 10.};  ///< Range for pull of y coordinate
diff --git a/reco/L1/qa/CbmCaQaCuts.h b/reco/L1/qa/CbmCaQaCuts.h
deleted file mode 100644
index 9e9d643ec7..0000000000
--- a/reco/L1/qa/CbmCaQaCuts.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
-   SPDX-License-Identifier: GPL-3.0-only
-   Authors: Sergei Zharko [committer] */
-
-#ifndef CbmCaQaCuts_h
-#define CbmCaQaCuts_h 1
-
-namespace cbm::ca::qa::cuts
-{
-  constexpr double kMinP = 0.05;  ///< minimal momentum [Gev/c]
-
-  // Max difference between hit and station z
-  constexpr double kMaxDzStHitSts = 1.;  ///< Max distance for STS
-};                                       // namespace cbm::ca::qa::cuts
-
-#endif  // CbmCaQaCuts_h
-- 
GitLab