From e1b58294ea672e3ccfc036c39d43e75c84c8ff59 Mon Sep 17 00:00:00 2001
From: Volker Friese <v.friese@gsi.de>
Date: Tue, 31 Jan 2023 15:14:19 +0100
Subject: [PATCH] Added calls to ReadInactiveChannels() to the Init methods of
 all digitizers. Refs #2708

---
 mvd/CbmMvdDigitizer.cxx                     | 12 ++++++++++++
 sim/detectors/bmon/CbmBmonDigitize.cxx      | 14 ++++++++++++++
 sim/detectors/much/CbmMuchDigitizeGem.cxx   | 12 ++++++++++++
 sim/detectors/psd/CbmPsdSimpleDigitizer.cxx | 12 ++++++++++++
 sim/detectors/rich/CbmRichDigitizer.cxx     | 11 +++++++++++
 sim/detectors/tof/CbmTofDigitize.cxx        | 13 +++++++++++++
 sim/detectors/trd/CbmTrdDigitizer.cxx       | 12 ++++++++++++
 7 files changed, 86 insertions(+)

diff --git a/mvd/CbmMvdDigitizer.cxx b/mvd/CbmMvdDigitizer.cxx
index 5e046b420a..a8f0eeef0e 100644
--- a/mvd/CbmMvdDigitizer.cxx
+++ b/mvd/CbmMvdDigitizer.cxx
@@ -279,6 +279,18 @@ InitStatus CbmMvdDigitizer::Init()
 
   if (fNoiseSensors) fDetector->SetProduceNoise();
 
+  // --- Read list of inactive channels
+  if (!fInactiveChannelFileName.IsNull()) {
+    LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
+    auto result = ReadInactiveChannels();
+    if (!result.second) {
+      LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
+      return kFATAL;
+    }
+    LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
+              << " channels set inactive";
+  }
+
   // Screen output
   cout << GetName() << " initialised with parameters: " << endl;
   //PrintParameters();
diff --git a/sim/detectors/bmon/CbmBmonDigitize.cxx b/sim/detectors/bmon/CbmBmonDigitize.cxx
index 052fbade4c..810f732f57 100644
--- a/sim/detectors/bmon/CbmBmonDigitize.cxx
+++ b/sim/detectors/bmon/CbmBmonDigitize.cxx
@@ -89,7 +89,21 @@ InitStatus CbmBmonDigitize::Init()
   LOG(info) << "==========================================================";
   LOG(info) << GetName() << ": Initialisation";
   LOG(info) << "Time resolution is " << fResolution << " [ns]";
+
   RegisterOutput();
+
+  // --- Read list of inactive channels
+  if (!fInactiveChannelFileName.IsNull()) {
+    LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
+    auto result = ReadInactiveChannels();
+    if (!result.second) {
+      LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
+      return kFATAL;
+    }
+    LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
+              << " channels set inactive";
+  }
+
   LOG(info) << GetName() << ": Initialisation successful";
   LOG(info) << "==========================================================";
   std::cout << std::endl;
diff --git a/sim/detectors/much/CbmMuchDigitizeGem.cxx b/sim/detectors/much/CbmMuchDigitizeGem.cxx
index 069def350e..a4c9f32cc8 100644
--- a/sim/detectors/much/CbmMuchDigitizeGem.cxx
+++ b/sim/detectors/much/CbmMuchDigitizeGem.cxx
@@ -462,6 +462,18 @@ InitStatus CbmMuchDigitizeGem::Init()
   //  else fgDeltaResponse[i] = exp(-(time-fPeakingTime)/fRemainderTime);
   //}
 
+  // --- Read list of inactive channels
+  if (!fInactiveChannelFileName.IsNull()) {
+    LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
+    auto result = ReadInactiveChannels();
+    if (!result.second) {
+      LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
+      return kFATAL;
+    }
+    LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
+              << " channels set inactive";
+  }
+
   // --- Enable histogram if want to enalyze Noise spectrum.
   //noise = new TH1D("noise", "Noise Generated per Event NoiseRate 10e-8", 100 , 0 , 200);
   LOG(info) << GetName() << ": Initialisation successful";
diff --git a/sim/detectors/psd/CbmPsdSimpleDigitizer.cxx b/sim/detectors/psd/CbmPsdSimpleDigitizer.cxx
index 5d2e48c30c..d1c9fe4937 100644
--- a/sim/detectors/psd/CbmPsdSimpleDigitizer.cxx
+++ b/sim/detectors/psd/CbmPsdSimpleDigitizer.cxx
@@ -70,6 +70,18 @@ InitStatus CbmPsdSimpleDigitizer::Init()
   // Create and register output array
   RegisterOutput();
 
+  // --- Read list of inactive channels
+  if (!fInactiveChannelFileName.IsNull()) {
+    LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
+    auto result = ReadInactiveChannels();
+    if (!result.second) {
+      LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
+      return kFATAL;
+    }
+    LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
+              << " channels set inactive";
+  }
+
   // Statistics
   fNofEvents = 0;
   fNofPoints = 0;
diff --git a/sim/detectors/rich/CbmRichDigitizer.cxx b/sim/detectors/rich/CbmRichDigitizer.cxx
index 05be1505ea..6b6761cd6e 100644
--- a/sim/detectors/rich/CbmRichDigitizer.cxx
+++ b/sim/detectors/rich/CbmRichDigitizer.cxx
@@ -92,6 +92,17 @@ InitStatus CbmRichDigitizer::Init()
 
   RegisterOutput();
 
+  // --- Read list of inactive channels
+  if (!fInactiveChannelFileName.IsNull()) {
+    LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
+    auto result = ReadInactiveChannels();
+    if (!result.second) {
+      LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
+      return kFATAL;
+    }
+    LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
+              << " channels set inactive";
+  }
 
   LOG(info) << GetName() << ": Initialisation successful";
 
diff --git a/sim/detectors/tof/CbmTofDigitize.cxx b/sim/detectors/tof/CbmTofDigitize.cxx
index 9453373af2..32f8b487d1 100644
--- a/sim/detectors/tof/CbmTofDigitize.cxx
+++ b/sim/detectors/tof/CbmTofDigitize.cxx
@@ -263,6 +263,19 @@ InitStatus CbmTofDigitize::Init()
 
   if (kFALSE == CreateHistos()) return kFATAL;
 
+  // --- Read list of inactive channels
+  if (!fInactiveChannelFileName.IsNull()) {
+    LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
+    auto result = ReadInactiveChannels();
+    if (!result.second) {
+      LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
+      return kFATAL;
+    }
+    LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
+              << " channels set inactive";
+  }
+
+
   LOG(info) << GetName() << ": Initialisation successful";
   LOG(info) << "==========================================================";
   return kSUCCESS;
diff --git a/sim/detectors/trd/CbmTrdDigitizer.cxx b/sim/detectors/trd/CbmTrdDigitizer.cxx
index a328d179b1..2a36c4f662 100644
--- a/sim/detectors/trd/CbmTrdDigitizer.cxx
+++ b/sim/detectors/trd/CbmTrdDigitizer.cxx
@@ -130,6 +130,18 @@ InitStatus CbmTrdDigitizer::Init()
   // Set time-based mode if appropriate
   SetTimeBased(fEventMode ? kFALSE : kTRUE);
 
+  // --- Read list of inactive channels
+  if (!fInactiveChannelFileName.IsNull()) {
+    LOG(info) << GetName() << ": Reading inactive channels from " << fInactiveChannelFileName;
+    auto result = ReadInactiveChannels();
+    if (!result.second) {
+      LOG(error) << GetName() << ": Error in reading from file! Task will be inactive.";
+      return kFATAL;
+    }
+    LOG(info) << GetName() << ": " << std::get<0>(result) << " lines read from file, " << fInactiveChannels.size()
+              << " channels set inactive";
+  }
+
   RegisterOutput();
 
 
-- 
GitLab