From f2ef2918366e9373f1cf24e287203c0ede6f9da3 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Fri, 6 Aug 2021 12:57:30 +0200
Subject: [PATCH] RPC_CondCabling: delete unused code

Delete unused `read` method and remove the usage of the `setdbfmtflag`
method.
---
 .../RPC_CondCabling/CMAprogram.h              |  1 -
 .../RPC_CondCabling/src/CMAprogram.cxx        | 71 +++----------------
 .../RPC_CondCabling/src/RpcCablingCondAlg.cxx |  5 --
 3 files changed, 9 insertions(+), 68 deletions(-)

diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/RPC_CondCabling/CMAprogram.h b/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/RPC_CondCabling/CMAprogram.h
index d5ed05d81f8..dfede4c0730 100755
--- a/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/RPC_CondCabling/CMAprogram.h
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/RPC_CondCabling/CMAprogram.h
@@ -106,7 +106,6 @@ private:
     bool m_threshold_registers[3][CMAparameters::pivot_channels][CMAparameters::confirm_channels];
     uint32_t m_program_bytes[3][CMAparameters::pivot_channels][2];
 
-    bool read(DBline&);
     bool read_v02(DBline&);
 
 public:
diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/CMAprogram.cxx b/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/CMAprogram.cxx
index 5f644d25301..6773dcb86ef 100755
--- a/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/CMAprogram.cxx
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/CMAprogram.cxx
@@ -4,7 +4,7 @@
 
 #include "RPC_CondCabling/CMAprogram.h"
 
-#include <cstring>
+#include <string>
 
 CMAprogram::CMAprogram() {
 
@@ -34,61 +34,9 @@ CMAprogram::CMAprogram(std::istringstream& filestr, bool NewCab) :
     m_status = read_v02(data);
 }
 
-bool CMAprogram::read(DBline& data) {
-    unsigned long right_bit = 0x1;
-
-    // switch to new DBline I/O format
-    data.setdbfmtflag(0);
-
-    ++data;
-
-    while (data) {
-        // start read the threshold registers
-        for (int i = 1; i <= 3; ++i) {
-            int majority;
-
-            if (data("th #", i) && data("maj_reg") >> majority) {
-                int th = 0;
-                int ch = 0;
-                uint32_t first_word = 0;
-                uint32_t second_word = 0;
-
-                ++data;
-
-                while (data("th") >> th >> "thr_reg" >> ch >> data.dbhex() >> first_word >> second_word >> data.dbdec()) {
-                    if (th < 1) return false;
-                    m_program_bytes[th - 1][ch][1] = first_word;
-                    m_program_bytes[th - 1][ch][0] = second_word;
-
-                    for (int bit = 0; bit < 32; ++bit) {
-                        m_threshold_registers[th - 1][ch][bit] = ((second_word >> bit) & right_bit) != 0;
-                        m_threshold_registers[th - 1][ch][bit + 32] = ((first_word >> bit) & right_bit) != 0;
-                    }
-
-                    ++data;
-                }
-            }
-        }
-
-        data("overlap1") >> data.dbhex() >> m_overlap1;
-        data("overlap2") >> data.dbhex() >> m_overlap2;
-        data("trig_local_direc_i") >> m_trig_local_direc_i;
-        data("trig_local_direc_j") >> m_trig_local_direc_j;
-        data("trig_k_readout") >> m_trig_k_readout;
-
-        ++data;
-    }
-
-    // switch back to previous DBline I/O format
-    data.setdbfmtflag(1);
-    return true;
-}
-
 bool CMAprogram::read_v02(DBline& data) {
     uint32_t right_bit = 0x1;
-
-    // switch to new DBline I/O format
-    data.setdbfmtflag(0);
+    std::string ignore;
 
     ++data;
 
@@ -175,12 +123,12 @@ bool CMAprogram::read_v02(DBline& data) {
         if (m_isnewcab) {
             // case RPC_CondCabling
             if (data("set_trig_thr0_thr_reg_00")) {
-                std::string newString = "empty";
                 for (int i = 0; i < 32; ++i) {
+                    ignore.clear();
                     if (i == 0)
                         data >> data.dbhex() >> twowords >> data.dbdec();
                     else
-                        data >> newString >> data.dbhex() >> twowords >> data.dbdec();
+                        data >> ignore >> data.dbhex() >> twowords >> data.dbdec();
 
                     union Data {
                         uint64_t bits;
@@ -201,12 +149,12 @@ bool CMAprogram::read_v02(DBline& data) {
             }
 
             if (data("set_trig_thr1_thr_reg_00")) {
-                std::string newString = "empty";
+                ignore.clear();
                 for (int i = 0; i < 32; ++i) {
                     if (i == 0)
                         data >> data.dbhex() >> twowords >> data.dbdec();
                     else
-                        data >> newString >> data.dbhex() >> twowords >> data.dbdec();
+                        data >> ignore >> data.dbhex() >> twowords >> data.dbdec();
 
                     union Data {
                         uint64_t bits;
@@ -228,12 +176,12 @@ bool CMAprogram::read_v02(DBline& data) {
             }
 
             if (data("set_trig_thr2_thr_reg_00")) {
-                std::string newString = "empty";
+                ignore.clear();
                 for (int i = 0; i < 32; ++i) {
                     if (i == 0)
                         data >> data.dbhex() >> twowords >> data.dbdec();
                     else
-                        data >> newString >> data.dbhex() >> twowords >> data.dbdec();
+                        data >> ignore >> data.dbhex() >> twowords >> data.dbdec();
 
                     union Data {
                         uint64_t bits;
@@ -294,8 +242,7 @@ bool CMAprogram::read_v02(DBline& data) {
             ++data;
         }
     }
-    // switch back to previous DBline I/O format
-    data.setdbfmtflag(1);
+
     return true;
 }
 
diff --git a/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/RpcCablingCondAlg.cxx b/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/RpcCablingCondAlg.cxx
index 848afe52840..40d4f056835 100644
--- a/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/RpcCablingCondAlg.cxx
+++ b/MuonSpectrometer/MuonConditions/MuonCondCabling/RPC_CondCabling/src/RpcCablingCondAlg.cxx
@@ -358,8 +358,6 @@ StatusCode RpcCablingCondAlg::setup(const CondAttrListCollection* readCdoMap, co
     }
 
     DBline data_corr(MAP_corr);
-    // switch to new DBline I/O format
-    data_corr.setdbfmtflag(0);
     nlines = 0;
     while (++data_corr) {
         ++nlines;
@@ -425,9 +423,6 @@ StatusCode RpcCablingCondAlg::setup(const CondAttrListCollection* readCdoMap, co
         }
     }
     ATH_MSG_DEBUG("setup() - corrected map n. of lines read is " << nlines);
-    // switch back to previous DBline I/O format
-    data_corr.setdbfmtflag(1);
-
     ATH_MSG_DEBUG("setup() - " << m_readKey_map_schema_corr.key() << " maps have been parsed");
 
     for (int side = 0; side < 2; ++side) {
-- 
GitLab