From 67872791a3537178053f50c30b04e3f5f3023380 Mon Sep 17 00:00:00 2001 From: Maarten van Veghel <mvegh@nikhef.nl> Date: Wed, 2 Mar 2022 20:14:33 +0100 Subject: [PATCH] adding enum string conversions --- .../include/Detector/Calo/DeCalorimeter.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Detector/Calo/include/Detector/Calo/DeCalorimeter.h b/Detector/Calo/include/Detector/Calo/DeCalorimeter.h index d38be2bad..b3ead237e 100644 --- a/Detector/Calo/include/Detector/Calo/DeCalorimeter.h +++ b/Detector/Calo/include/Detector/Calo/DeCalorimeter.h @@ -29,6 +29,25 @@ namespace LHCb::Detector::Calo { /// definition of calorimeter planes enum Plane { Front = 0, Middle, ShowerMax, Back }; + inline std::string toString( Plane e ) { + switch ( e ) { + case Plane::Front: + return "Front"; + case Plane::ShowerMax: + return "ShowerMax"; + case Plane::Middle: + return "Middle"; + case Plane::Back: + return "Back"; + default: + throw "Not a correct plane in Calo"; + } + } + + inline std::ostream& toStream( Plane e, std::ostream& os ) { return os << std::quoted( toString( e ), '\'' ); } + + inline std::ostream& operator<<( std::ostream& s, Plane e ) { return toStream( e, s ); } + namespace detail { struct DeCaloObject : LHCb::Detector::detail::DeIOVObject { -- GitLab