From 067cd742a9f8146636b97121b3c383aace69aa31 Mon Sep 17 00:00:00 2001
From: Siarhei Harkusha <Siarhei.Harkusha@cern.ch>
Date: Mon, 6 Feb 2023 17:35:11 +0100
Subject: [PATCH] TileConditions: Move encodeStatus from TileBadChanTool to
 TileBadChannels

TileBadChanTool and TileBadChannels condition objec have been updated
to move encodeStatus method from TileBadChanTool to TileBadChannels.
---
 .../TileConditions/TileBadChannels.h          |  4 +++-
 .../TileConditions/src/TileBadChanTool.cxx    | 19 ++-------------
 .../TileConditions/src/TileBadChannels.cxx    | 24 ++++++++++++++++++-
 3 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/TileCalorimeter/TileConditions/TileConditions/TileBadChannels.h b/TileCalorimeter/TileConditions/TileConditions/TileBadChannels.h
index bf7864a810d9..961349edd20c 100644
--- a/TileCalorimeter/TileConditions/TileConditions/TileBadChannels.h
+++ b/TileCalorimeter/TileConditions/TileConditions/TileBadChannels.h
@@ -1,7 +1,7 @@
 //Dear emacs, this is -*- c++ -*-
 
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TILECONDITIONS_TILEBADCHANNELS_H
@@ -76,6 +76,8 @@ class TileBadChannels {
     */
     const std::vector<int>& getMaskedDrawers(void) const {return m_maskedDrawers;};
 
+    static uint32_t encodeStatus(const TileBchStatus& status);
+    uint32_t encodeAdcStatus(const HWIdentifier adc_id) const;
 
   private:
 
diff --git a/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx b/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx
index 9b70a2572c63..d8bafd6ba098 100644
--- a/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx
+++ b/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 */
 
 // Tile includes
@@ -237,22 +237,7 @@ TileBadChanTool::getAdcStatus(unsigned int drawerIdx, unsigned int channel, unsi
 
 
 uint32_t TileBadChanTool::encodeStatus(const TileBchStatus& status) const {
-
-  uint32_t bad;
-
-  if (status.isGood())
-    bad = 0;
-  else if (status.isBad())
-    bad = 3;
-  else if (status.isNoisy())
-    bad = 1;
-  else if (status.isAffected())
-    bad = 2;
-  else
-    bad = 4;
-
-  return bad;
-
+  return TileBadChannels::encodeStatus(status);
 }
 
 const std::vector<float>& TileBadChanTool::getTripsProbabilities(unsigned int ros, const EventContext& ctx) const {
diff --git a/TileCalorimeter/TileConditions/src/TileBadChannels.cxx b/TileCalorimeter/TileConditions/src/TileBadChannels.cxx
index 1eae94730314..f670f7654923 100644
--- a/TileCalorimeter/TileConditions/src/TileBadChannels.cxx
+++ b/TileCalorimeter/TileConditions/src/TileBadChannels.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TileConditions/TileBadChannels.h"
@@ -48,3 +48,25 @@ void TileBadChannels::setMaskedDrawers(std::vector<int>&& maskedDrawers) {
   m_maskedDrawers = std::move(maskedDrawers);
   std::sort (m_maskedDrawers.begin(), m_maskedDrawers.end());
 }
+
+uint32_t TileBadChannels::encodeStatus(const TileBchStatus& status) {
+  uint32_t bad;
+
+  if (status.isGood()) {
+    bad = 0;
+  } else if (status.isBad()) {
+    bad = 3;
+  } else if (status.isNoisy()) {
+    bad = 1;
+  } else if (status.isAffected()) {
+    bad = 2;
+  } else {
+    bad = 4;
+  }
+
+  return bad;
+}
+
+uint32_t TileBadChannels::encodeAdcStatus(const HWIdentifier adc_id) const {
+  return encodeStatus(getAdcStatus(adc_id));
+}
-- 
GitLab