From fb8167276e2a0e384686a5bc1466a547792e951e Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Wed, 25 May 2022 16:55:16 +0200
Subject: [PATCH] L1Algo: rebase bug fixes

---
 reco/L1/CbmL1.cxx | 115 ----------------------------------------------
 reco/L1/CbmL1.h   |   4 +-
 2 files changed, 1 insertion(+), 118 deletions(-)

diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index 777a0c63e2..52bab25a82 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -2212,121 +2212,6 @@ void CbmL1::WriteSIMDKFData()
   }
 }
 
-//-------------------------------------------------------------------------------------------------------------------------------
-//
-void CbmL1::ReadMaterialTables(L1DetectorID detectorID)
-{
-  if (fMatBudgetFileName.find(detectorID) != fMatBudgetFileName.end()) {
-    auto* oldFile = gFile;
-    auto* oldDir  = gDirectory;
-
-    TString stationNamePrefix = "Radiation Thickness [%], Station";
-    auto rlFile               = TFile(fMatBudgetFileName.at(detectorID));
-    if (rlFile.IsZombie()) { LOG(fatal) << "File " << fMatBudgetFileName.at(detectorID) << " is zombie!"; }
-    LOG(info) << "Reading material budget for " << GetDetectorName(detectorID) << " from file "
-              << fMatBudgetFileName.at(detectorID);
-
-    for (int iSt = 0; iSt < fpInitManager->GetNstationsGeometry(detectorID); ++iSt) {
-      int iStActive = fpInitManager->GetStationIndexActive(iSt, detectorID);
-      if (iStActive == -1) { continue; }
-      // TODO: Unify material table names (S.Zharko)
-      TString stationName = stationNamePrefix + (detectorID == L1DetectorID::kMvd ? iSt : iSt + 1);
-      auto* hStaRadLen    = dynamic_cast<TProfile2D*>(rlFile.Get(stationName));
-      if (!hStaRadLen) {
-        LOG(fatal) << "CbmL1: material budget profile " << stationName << " does not exist in file "
-                   << fMatBudgetFileName.at(detectorID);
-      }
-      int nBins  = hStaRadLen->GetNbinsX();
-      float rMax = hStaRadLen->GetXaxis()->GetXmax();
-      algo->fRadThick[iStActive].SetBins(nBins, rMax);
-
-      float hole = 0.f;
-      switch (detectorID) {
-        case L1DetectorID::kMvd: hole = 0.f; break;
-        case L1DetectorID::kSts: hole = 0.f; break;
-        case L1DetectorID::kMuch: hole = 0.15f; break;
-        case L1DetectorID::kTrd: hole = 0.15f; break;
-        case L1DetectorID::kTof: hole = 0.0015f; break;
-      }
-      double averageRadThick = 0.;
-      double counter         = 0.;
-      for (int iBinX = 0; iBinX < nBins; ++iBinX) {
-        if (detectorID == L1DetectorID::kTof) { hole = 0.0015f; }  // TODO: Why? (S.Zharko)
-        for (int iBinY = 0; iBinY < nBins; ++iBinY) {
-          algo->fRadThick[iStActive].SetRadThick(iBinX, iBinY, 0.01 * hStaRadLen->GetBinContent(iBinX, iBinY));
-
-          /* Specific corrections for each detector type */
-          // TODO: Is it possible to account for these corrections in the moment of the maps creation? (S.Zharko)
-          switch (detectorID) {
-            case L1DetectorID::kMvd:
-              // Correction for holes in the material map
-              if (algo->fRadThick[iStActive].GetRadThick(iBinX, iBinY)
-                  < algo->GetStations()[iStActive].materialInfo.RadThick[0]) {
-                if (iBinY > 0 && iBinY < nBins - 1) {
-                  algo->fRadThick[iStActive].table[iBinX][iBinY] =
-                    0.01
-                    * TMath::Min(hStaRadLen->GetBinContent(iBinX, iBinY - 1),
-                                 hStaRadLen->GetBinContent(iBinX, iBinY + 1));
-                }
-              }
-              // Correction for the hardcodded value of RadThick of MVD stations
-              if (algo->fRadThick[iStActive].table[iBinX][iBinY] < 0.0015) {
-                algo->fRadThick[iStActive].table[iBinX][iBinY] = 0.0015;
-              }
-              break;
-            case L1DetectorID::kSts:
-              if (algo->fRadThick[iStActive].GetRadThick(iBinX, iBinY)
-                  < algo->GetStations()[iStActive].materialInfo.RadThick[0]) {
-                algo->fRadThick[iStActive].SetRadThick(iBinX, iBinY,
-                                                       algo->GetStations()[iStActive].materialInfo.RadThick[0]);
-              }
-              break;
-            case L1DetectorID::kMuch:
-            case L1DetectorID::kTrd:
-            case L1DetectorID::kTof:
-              // Correction for holes in the material map
-              if (iBinY > 0 && iBinY < nBins - 1) {
-<<<<<<< HEAD
-                algo->fRadThick[iStActive].table[iBinX][iBinY] =
-                  0.01
-                  * TMath::Min(hStaRadLen->GetBinContent(iBinX, iBinY - 1),
-                               hStaRadLen->GetBinContent(iBinX, iBinY + 1));
-              }
-              // Correction for the hardcodded value of RadThick of MVD stations
-              if (algo->fRadThick[iStActive].table[iBinX][iBinY] > 0.0015) {
-                hole = algo->fRadThick[iStActive].table[iBinX][iBinY];
-              }
-              if (algo->fRadThick[iStActive].table[iBinX][iBinY] < 0.0015) {
-                algo->fRadThick[iStActive].table[iBinX][iBinY] = hole;
-              }
-              break;
-          }  // switoch (detectorID)
-          averageRadThick += algo->fRadThick[iStActive].GetRadThick(iBinX, iBinY);
-          ++counter;
-        }  // iBinY
-      }    // iBinX
-      //averageRadThick /= static_cast<float>(counter);
-      averageRadThick /= counter;
-      LOG(info) << " - station " << iSt << " (global id is " << iStActive << "), average X/X0 is " << averageRadThick
-                << '\n';
-    }  // iSt
-
-    gFile      = oldFile;
-    gDirectory = oldDir;
-  }
-  else {
-    LOG(warn) << "No material budget file is found for " << GetDetectorName(detectorID)
-              << ". Homogenious material budget will be used";
-    for (int iSt = 0; iSt < fpInitManager->GetNstationsGeometry(detectorID); ++iSt) {
-      int iStActive = fpInitManager->GetStationIndexActive(iSt, detectorID);
-      if (iStActive == -1) { continue; }
-      algo->fRadThick[iStActive].SetBins(1, 100);
-      algo->fRadThick[iStActive].SetRadThick(0, 0, algo->GetStations()[iStActive].materialInfo.RadThick[0]);
-      LOG(info) << " Material for " << GetDetectorName(detectorID) << ": "
-                << algo->GetStations()[iStActive].materialInfo.RadThick[0];
-    }  // iSt
-  }
-}
 
 std::vector<L1Material> CbmL1::ReadMaterialBudget(L1DetectorID detectorID)
 {
diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h
index 148b618fa2..3dab8260a9 100644
--- a/reco/L1/CbmL1.h
+++ b/reco/L1/CbmL1.h
@@ -250,10 +250,8 @@ public:
     return "";
   }
 
-  /// Reads radiation length table from material budget file
+  /// Reads material budget information: station thickness in units of radiation length vs. point at the XY plane
   /// \param detectorID  ID of a detector subsystem
-  void ReadMaterialTables(L1DetectorID detectorID);
-
   std::vector<L1Material> ReadMaterialBudget(L1DetectorID detectorID);
 
 
-- 
GitLab