From 5e0b7f8fcee0c823a891850106be6136a59502a8 Mon Sep 17 00:00:00 2001
From: "se.gorbunov" <se.gorbunov@gsi.de>
Date: Tue, 19 Sep 2023 10:18:24 +0000
Subject: [PATCH] CA: fix angles in TRD QA

---
 core/detectors/trd/CbmTrdTrackingInterface.cxx | 15 +++++++++++++++
 core/detectors/trd/CbmTrdTrackingInterface.h   |  2 +-
 reco/L1/qa/CbmCaInputQaTrd.cxx                 |  6 +++---
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/core/detectors/trd/CbmTrdTrackingInterface.cxx b/core/detectors/trd/CbmTrdTrackingInterface.cxx
index 00e6a8c0c9..1d2d4e27db 100644
--- a/core/detectors/trd/CbmTrdTrackingInterface.cxx
+++ b/core/detectors/trd/CbmTrdTrackingInterface.cxx
@@ -56,6 +56,21 @@ int CbmTrdTrackingInterface::GetNtrackingStations() const
   return nTrdLayers;
 }
 
+
+std::tuple<double, double> CbmTrdTrackingInterface::GetStereoAnglesSensor(int address) const
+{
+  const CbmTrdParModDigi* par = dynamic_cast<const CbmTrdParModDigi*>(fTrdDigiPar->GetModulePar(address));
+  if (!par) {
+    LOG(fatal) << "CbmTrdTrackingInterface::Init: error accessing the TRD module for address " << address
+               << " (failed dynamic cast to CbmTrdParModDigi)";
+  }
+  if ((par->GetOrientation() == 1) || (par->GetOrientation() == 3)) {
+    // swap X & Y for orientations 1 or 3
+    return std::tuple(TMath::Pi() / 2., 0.);
+  }
+  return std::tuple(0., TMath::Pi() / 2.);
+}
+
 //-------------------------------------------------------------------------------------------------------------------------------------
 //
 InitStatus CbmTrdTrackingInterface::Init()
diff --git a/core/detectors/trd/CbmTrdTrackingInterface.h b/core/detectors/trd/CbmTrdTrackingInterface.h
index 9f6670d826..bd5828265c 100644
--- a/core/detectors/trd/CbmTrdTrackingInterface.h
+++ b/core/detectors/trd/CbmTrdTrackingInterface.h
@@ -61,7 +61,7 @@ public:
   /// @note   The tracking does not use this method. It is only used by the QA task.
   /// @param  address  detector unique identifier
   /// @return [phiU, phiV] - Stereo angles [rad]
-  std::tuple<double, double> GetStereoAnglesSensor(int /*address*/) const { return std::tuple(0., TMath::Pi() / 2.); }
+  std::tuple<double, double> GetStereoAnglesSensor(int address) const;
 
   /// @brief  Gets a tracking station of a CbmHit
   /// @param  hit  A pointer to CbmHit
diff --git a/reco/L1/qa/CbmCaInputQaTrd.cxx b/reco/L1/qa/CbmCaInputQaTrd.cxx
index 5f21a2c15c..bf33aedf72 100644
--- a/reco/L1/qa/CbmCaInputQaTrd.cxx
+++ b/reco/L1/qa/CbmCaInputQaTrd.cxx
@@ -48,10 +48,10 @@ void CbmCaInputQaTrd::DefineParameters()
   SetRange(fRHitDv, 0.0000, 5.00);   // [cm]
   SetRange(fRHitDt, 0.0000, 10.00);  // [ns]
   // Residuals
-  SetRange(fRResX, -2.00, 2.00);
-  SetRange(fRResY, -4.00, 4.00);
+  SetRange(fRResX, -10.00, 10.00);
+  SetRange(fRResY, -10.00, 10.00);
   SetRange(fRResU, -2.00, 2.00);
-  SetRange(fRResV, -4.00, 4.00);
+  SetRange(fRResV, -10.00, 10.00);
   SetRange(fRResT, -0.50, 0.50);
   // QA result selection criteria
   SetRange(fEffRange, 10.0, 30.0);  ///< Range for hit efficiency approximation
-- 
GitLab