From 6a4b7ee75f3d6f976783199a49d4bca843c1a3c9 Mon Sep 17 00:00:00 2001 From: scott snyder <scott.snyder@cern.ch> Date: Fri, 19 Oct 2018 13:37:13 +0200 Subject: [PATCH] TileIdentifier: Add string converters for enums. Add helpers to convert the enums TileFragHash::TYPE and TileRawChannelUnit::UNIT to strings. --- .../TileIdentifier/TileFragHash.h | 14 +++++++--- .../TileIdentifier/TileRawChannelUnit.h | 14 ++++++++-- .../TileIdentifier/src/TileFragHash.cxx | 25 ++++++++++++++++- .../TileIdentifier/src/TileRawChannelUnit.cxx | 28 +++++++++++++++++++ 4 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 TileCalorimeter/TileIdentifier/src/TileRawChannelUnit.cxx diff --git a/TileCalorimeter/TileIdentifier/TileIdentifier/TileFragHash.h b/TileCalorimeter/TileIdentifier/TileIdentifier/TileFragHash.h index 5d9178e3453d..ea10c7de9ab1 100755 --- a/TileCalorimeter/TileIdentifier/TileIdentifier/TileFragHash.h +++ b/TileCalorimeter/TileIdentifier/TileIdentifier/TileFragHash.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ @@ -8,7 +8,8 @@ class TileHWID; -#include <vector> +#include <vector> +#include <string> /** * @class TileFragHash @@ -52,8 +53,13 @@ class TileFragHash { /**return hash type */ TYPE type() const {return m_type;} - - private: + + + /** Printable representation of a type. */ + static std::string typeToString (TYPE type); + + +private: /** total number of IDs */ int m_size; // total number of IDs int m_offset; // different offset for different types of collections diff --git a/TileCalorimeter/TileIdentifier/TileIdentifier/TileRawChannelUnit.h b/TileCalorimeter/TileIdentifier/TileIdentifier/TileRawChannelUnit.h index 520847273a6d..5aae15fa879a 100644 --- a/TileCalorimeter/TileIdentifier/TileIdentifier/TileRawChannelUnit.h +++ b/TileCalorimeter/TileIdentifier/TileIdentifier/TileRawChannelUnit.h @@ -1,9 +1,13 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ -#ifndef TILECONDITIONS_TILERAWCHANNELUNIT__H -#define TILECONDITIONS_TILERAWCHANNELUNIT__H +#ifndef TILECONDITIONS_TILERAWCHANNELUNIT_H +#define TILECONDITIONS_TILERAWCHANNELUNIT_H + + +#include <string> + class TileRawChannelUnit { @@ -21,6 +25,10 @@ class TileRawChannelUnit OnlineOffset = 4, Invalid = 99 }; + + + /** Printable representation of a unit. */ + static std::string unitToString (UNIT type); }; #endif diff --git a/TileCalorimeter/TileIdentifier/src/TileFragHash.cxx b/TileCalorimeter/TileIdentifier/src/TileFragHash.cxx index 693b74e8ee01..69e58ffdbddc 100755 --- a/TileCalorimeter/TileIdentifier/src/TileFragHash.cxx +++ b/TileCalorimeter/TileIdentifier/src/TileFragHash.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ @@ -78,3 +78,26 @@ int TileFragHash::hash (const ID& id) const return m_lookup[id]; } + +/** + * @brief Printable representation of a type. + */ +std::string TileFragHash::typeToString (TYPE type) +{ + switch (type) { +#define CASE(X) case TileFragHash::X: return #X + CASE(Digitizer); + CASE(OptFilterDsp); + CASE(OptFilterOffline); + CASE(OptFilterDspCompressed); + CASE(ManyAmps); + CASE(MF); + CASE(FitFilter); + CASE(FitFilterCool); + CASE(FlatFilter); + CASE(Beam); +#undef CASE + default: break; + }; + return "UNKNOWN"; +} diff --git a/TileCalorimeter/TileIdentifier/src/TileRawChannelUnit.cxx b/TileCalorimeter/TileIdentifier/src/TileRawChannelUnit.cxx new file mode 100644 index 000000000000..02fe205e4e75 --- /dev/null +++ b/TileCalorimeter/TileIdentifier/src/TileRawChannelUnit.cxx @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration. + */ + + +#include "TileIdentifier/TileRawChannelUnit.h" + + +/** + * @brief Printable representation of a unit. + */ +std::string TileRawChannelUnit::unitToString (UNIT unit) +{ + switch (unit) { +#define CASE(X) case TileRawChannelUnit::X: return #X + CASE(ADCcounts); + CASE(PicoCoulombs); + CASE(CesiumPicoCoulombs); + CASE(MegaElectronVolts); + CASE(OnlineADCcounts); + CASE(OnlinePicoCoulombs); + CASE(OnlineCesiumPicoCoulombs); + CASE(OnlineMegaElectronVolts); +#undef CASE + default: break; + }; + return "UNKNOWN"; +} -- GitLab