From 59fa9b56cf54676c583651ef2b63b51769a42695 Mon Sep 17 00:00:00 2001
From: "se.gorbunov" <se.gorbunov@gsi.de>
Date: Tue, 19 Sep 2023 09:05:54 +0000
Subject: [PATCH] CA: fix histo titles in QA

---
 macro/mcbm/mcbm_reco_event.C    |  2 +-
 reco/L1/qa/CbmCaInputQaBase.cxx | 33 +++++++++++++++++++--------------
 reco/L1/qa/CbmCaInputQaSts.cxx  | 24 ++++++++++++++++++++++--
 3 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/macro/mcbm/mcbm_reco_event.C b/macro/mcbm/mcbm_reco_event.C
index bbee100434..9ca28f2fa1 100644
--- a/macro/mcbm/mcbm_reco_event.C
+++ b/macro/mcbm/mcbm_reco_event.C
@@ -381,7 +381,7 @@ void mcbm_reco_event(Int_t nEvents = 10, TString dataset = "data/test",
   run->AddTask(kalman);
 
   // L1 tracking
-  auto l1 = (debugWithMC) ? new CbmL1("CA", 5, 3) : new CbmL1("CA");
+  auto l1 = (debugWithMC) ? new CbmL1("CA", 5, 1) : new CbmL1("CA");
   l1->SetMcbmMode();
   // User configuration example for CA:
   //l1->SetConfigUser(srcDir + "/macro/L1/configs/ca_params_user_example.yaml");
diff --git a/reco/L1/qa/CbmCaInputQaBase.cxx b/reco/L1/qa/CbmCaInputQaBase.cxx
index b00e98fdf0..a955b55639 100644
--- a/reco/L1/qa/CbmCaInputQaBase.cxx
+++ b/reco/L1/qa/CbmCaInputQaBase.cxx
@@ -396,9 +396,12 @@ void CbmCaInputQaBase<DetID>::FillHistograms()
         ++nMCpoints;
 
         int iE = fpMCEventList->GetEventIndex(link);
+        // TODO: debug
+        //if (iE < 0) continue;
 
-        LOG_IF(fatal, iE < 0 || iE >= nMCevents) << fName << ": id of MC event is out of range (hit id = " << iH
-                                                 << ", link id = " << iLink << ", event id = " << iE << ')';
+        LOG_IF(fatal, iE < 0 || iE >= nMCevents)
+          << fName << ": id of MC event is out of range (hit id = " << iH << ", link id = " << iLink
+          << ", event id = " << iE << ", mc point ID = " << iP << ')';
 
         // matched point
         const auto* pMCPoint = dynamic_cast<const Point_t*>(fpMCPoints->Get(link));
@@ -819,15 +822,16 @@ InitStatus CbmCaInputQaBase<DetID>::InitHistograms()
     fvph_hit_dy[iSt] = MakeQaObject<TH1F>(sF + "err/" + sN, sT, fNbins, fRHitDy[0], fRHitDy[1]);
 
     sN               = (TString) "hit_du" + nsuff;
-    sT               = (TString) "Hit position error across front strips" + tsuff + ";du_{hit} [cm]";
+    sT               = (TString) "Hit position error along the major detector coordinate U" + tsuff + ";du_{hit} [cm]";
     fvph_hit_du[iSt] = MakeQaObject<TH1F>(sF + "err/" + sN, sT, fNbins, fRHitDu[0], fRHitDu[1]);
 
     sN               = (TString) "hit_dv" + nsuff;
-    sT               = (TString) "Hit position error across back strips" + tsuff + ";dv_{hit} [cm]";
+    sT               = (TString) "Hit position error along the minor detector coordinate V" + tsuff + ";dv_{hit} [cm]";
     fvph_hit_dv[iSt] = MakeQaObject<TH1F>(sF + "err/" + sN, sT, fNbins, fRHitDv[0], fRHitDv[1]);
 
     sN = (TString) "hit_kuv" + nsuff;
-    sT = (TString) "Hit error correlation between front and back strips" + tsuff + ";kuv_{hit} [unitless]";
+    sT = (TString) "Hit error correlation between the major (U) and the minor detector coordinate Vs" + tsuff
+         + ";kuv_{hit} [unitless]";
     fvph_hit_kuv[iSt] = MakeQaObject<TH1F>(sF + "err/" + sN, sT, fNbins / 2 * 2 + 1, -1.1, 1.1);
 
     sN               = (TString) "hit_dt" + nsuff;
@@ -913,11 +917,11 @@ InitStatus CbmCaInputQaBase<DetID>::InitHistograms()
       fvph_res_y[iSt] = MakeQaObject<TH1F>(sF + "res/" + sN, sT, fNbins, fRResY[0], fRResY[1]);
 
       sN              = (TString) "res_u" + nsuff;
-      sT              = (TString) "Residuals for Front strip coordinate" + tsuff + ";u_{reco} - u_{MC} [cm]";
+      sT              = (TString) "Residuals for the major detector coordinate U" + tsuff + ";u_{reco} - u_{MC} [cm]";
       fvph_res_u[iSt] = MakeQaObject<TH1F>(sF + "res/" + sN, sT, fNbins, fRResU[0], fRResU[1]);
 
       sN              = (TString) "res_v" + nsuff;
-      sT              = (TString) "Residuals for Back strip coordinate" + tsuff + ";v_{reco} - v_{MC} [cm]";
+      sT              = (TString) "Residuals for the minor detector coordinate V" + tsuff + ";v_{reco} - v_{MC} [cm]";
       fvph_res_v[iSt] = MakeQaObject<TH1F>(sF + "res/" + sN, sT, fNbins, fRResV[0], fRResV[1]);
 
       sN              = (TString) "res_t" + nsuff;
@@ -933,11 +937,11 @@ InitStatus CbmCaInputQaBase<DetID>::InitHistograms()
       fvph_pull_y[iSt] = MakeQaObject<TH1F>(sF + "pull/" + sN, sT, kNbinsPull, kRPull[0], kRPull[1]);
 
       sN = (TString) "pull_u" + nsuff;
-      sT = (TString) "Pulls for Front strip coordinate" + tsuff + ";(u_{reco} - u_{MC}) / #sigma_{u}^{reco}";
+      sT = (TString) "Pulls for the major detector coordinate U" + tsuff + ";(u_{reco} - u_{MC}) / #sigma_{u}^{reco}";
       fvph_pull_u[iSt] = MakeQaObject<TH1F>(sF + "pull/" + sN, sT, kNbinsPull, kRPull[0], kRPull[1]);
 
       sN = (TString) "pull_v" + nsuff;
-      sT = (TString) "Pulls for Back strip coordinate" + tsuff + ";(v_{reco} - v_{MC}) / #sigma_{v}^{reco}";
+      sT = (TString) "Pulls for the minor detector coordinate V" + tsuff + ";(v_{reco} - v_{MC}) / #sigma_{v}^{reco}";
       fvph_pull_v[iSt] = MakeQaObject<TH1F>(sF + "pull/" + sN, sT, kNbinsPull, kRPull[0], kRPull[1]);
 
       sN               = (TString) "pull_t" + nsuff;
@@ -955,12 +959,12 @@ InitStatus CbmCaInputQaBase<DetID>::InitHistograms()
         MakeQaObject<TH2F>(sF + "res/" + sN, sT, fNbins, frYmin[iSt], frYmax[iSt], fNbins, fRResY[0], fRResY[1]);
 
       sN = (TString) "res_u_vs_u" + nsuff;
-      sT = (TString) "Residuals for Front strip coordinate" + tsuff + ";u_{MC} [cm];u_{reco} - u_{MC} [cm]";
+      sT = (TString) "Residuals for the major detector coordinate U" + tsuff + ";u_{MC} [cm];u_{reco} - u_{MC} [cm]";
       fvph_res_u_vs_u[iSt] =
         MakeQaObject<TH2F>(sF + "res/" + sN, sT, fNbins, frXmin[iSt], frXmax[iSt], fNbins, fRResU[0], fRResU[1]);
 
       sN = (TString) "res_v_vs_v" + nsuff;
-      sT = (TString) "Residuals for Back strip coordinate" + tsuff + ";v_{MC} [cm];v_{reco} - v_{MC} [cm]";
+      sT = (TString) "Residuals for the minor detector coordinate V" + tsuff + ";v_{MC} [cm];v_{reco} - v_{MC} [cm]";
       fvph_res_v_vs_v[iSt] =
         MakeQaObject<TH2F>(sF + "res/" + sN, sT, fNbins, frXmin[iSt], frXmax[iSt], fNbins, fRResV[0], fRResV[1]);
 
@@ -979,13 +983,14 @@ InitStatus CbmCaInputQaBase<DetID>::InitHistograms()
         MakeQaObject<TH2F>(sF + "pull/" + sN, sT, fNbins, frYmin[iSt], frYmax[iSt], kNbinsPull, kRPull[0], kRPull[1]);
 
       sN = (TString) "pull_u_vs_u" + nsuff;
-      sT =
-        (TString) "Pulls for Front strip coordinate" + tsuff + ";u_{MC} [cm];(u_{reco} - u_{MC}) / #sigma_{u}^{reco}";
+      sT = (TString) "Pulls for the major detector coordinate U" + tsuff
+           + ";u_{MC} [cm];(u_{reco} - u_{MC}) / #sigma_{u}^{reco}";
       fvph_pull_u_vs_u[iSt] =
         MakeQaObject<TH2F>(sF + "pull/" + sN, sT, fNbins, frXmin[iSt], frXmax[iSt], kNbinsPull, kRPull[0], kRPull[1]);
 
       sN = (TString) "pull_v_vs_v" + nsuff;
-      sT = (TString) "Pulls for Back strip coordinate" + tsuff + ";v_{MC} [cm];(v_{reco} - v_{MC}) / #sigma_{v}^{reco}";
+      sT = (TString) "Pulls for the minor detector coordinate V" + tsuff
+           + ";v_{MC} [cm];(v_{reco} - v_{MC}) / #sigma_{v}^{reco}";
       fvph_pull_v_vs_v[iSt] =
         MakeQaObject<TH2F>(sF + "pull/" + sN, sT, fNbins, frXmin[iSt], frXmax[iSt], kNbinsPull, kRPull[0], kRPull[1]);
 
diff --git a/reco/L1/qa/CbmCaInputQaSts.cxx b/reco/L1/qa/CbmCaInputQaSts.cxx
index f52fcbb5bd..e12ab9e10e 100644
--- a/reco/L1/qa/CbmCaInputQaSts.cxx
+++ b/reco/L1/qa/CbmCaInputQaSts.cxx
@@ -208,9 +208,31 @@ InitStatus CbmCaInputQaSts::InitHistograms()
   auto baseInitStatus = CbmCaInputQaBase::InitHistograms();
   if (kSUCCESS != baseInitStatus) { return baseInitStatus; }
 
+  int nSt             = fpDetInterface->GetNtrackingStations();
+  std::string detName = fpDetInterface->GetDetectorName();
+
+  // rename some histogramms with respect to STS specifics
+  for (int iSt = 0; iSt <= nSt; ++iSt) {
+    TString tsuff = (iSt == nSt) ? "" : Form(" in %s station %d", detName.c_str(), iSt);  // Histogram title suffix
+    fvph_hit_du[iSt]->SetTitle((TString) "Hit position error across front strips" + tsuff);
+    fvph_hit_dv[iSt]->SetTitle((TString) "Hit position error across back strips" + tsuff);
+    fvph_hit_kuv[iSt]->SetTitle((TString) "Hit error correlation between front and back strips" + tsuff);
+    if (IsMCUsed()) {
+      fvph_res_u[iSt]->SetTitle((TString) "Residuals for Front strip coordinate" + tsuff);
+      fvph_res_v[iSt]->SetTitle((TString) "Residuals for Back strip coordinate" + tsuff);
+      fvph_pull_u[iSt]->SetTitle((TString) "Pulls for Front strip coordinate" + tsuff);
+      fvph_pull_v[iSt]->SetTitle((TString) "Pulls for Back strip coordinate" + tsuff);
+      fvph_res_u_vs_u[iSt]->SetTitle((TString) "Residuals for Front strip coordinate" + tsuff);
+      fvph_res_v_vs_v[iSt]->SetTitle((TString) "Residuals for Back strip coordinate" + tsuff);
+      fvph_pull_u_vs_u[iSt]->SetTitle((TString) "Pulls for Front strip coordinate" + tsuff);
+      fvph_pull_v_vs_v[iSt]->SetTitle((TString) "Pulls for Back strip coordinate" + tsuff);
+    }
+  }
+
 
   // ----- Initialize histograms, which are use MC-information
   if (IsMCUsed()) {
+
     // Resize histogram vectors
     fvph_pull_u_Ndig.resize(fkMaxDigisInClusterForPulls + 1, nullptr);
     fvph_pull_v_Ndig.resize(fkMaxDigisInClusterForPulls + 1, nullptr);
@@ -247,5 +269,3 @@ InitStatus CbmCaInputQaSts::InitHistograms()
   }
   return kSUCCESS;
 }
-
-
-- 
GitLab