diff --git a/Event/EventPacker/src/lib/PackedFlavourTag.cpp b/Event/EventPacker/src/lib/PackedFlavourTag.cpp index f474d2e452649bf866663cac3d908098e181cab9..1441b372fb8610bead703a899d47d3d973627498 100644 --- a/Event/EventPacker/src/lib/PackedFlavourTag.cpp +++ b/Event/EventPacker/src/lib/PackedFlavourTag.cpp @@ -40,7 +40,7 @@ void FlavourTagPacker::pack( const Data& ft, PackedData& pft, PackedDataVector& auto& ptagger = pfts.taggers().emplace_back(); // save data members - ptagger.type = T.type(); + ptagger.type = static_cast<decltype( ptagger.type )>( T.type() ); ptagger.decision = to_underlying( T.decision() ); ptagger.omega = StandardPacker::fraction( T.omega() ); @@ -102,7 +102,7 @@ StatusCode FlavourTagPacker::unpack( const PackedData& pft, Data& ft, const Pack auto& tagger = taggers.emplace_back(); // set the tagger members - tagger.setType( ptagger.type ); + tagger.setType( static_cast<Tagger::TaggerType>( ptagger.type ) ); tagger.setDecision( Tagger::TagResult{ ptagger.decision } ); tagger.setOmega( StandardPacker::fraction( ptagger.omega ) ); diff --git a/Event/PhysEvent/include/Event/Tagger.h b/Event/PhysEvent/include/Event/Tagger.h index e1304e0b58157bfa73becee272270049a3cc3a3b..50197976a368a964d73366a2c8a4a0cd1e09800b 100644 --- a/Event/PhysEvent/include/Event/Tagger.h +++ b/Event/PhysEvent/include/Event/Tagger.h @@ -11,7 +11,6 @@ #pragma once #include "Event/Particle.h" #include "GaudiKernel/SmartRefVector.h" -#include "GaudiKernel/VectorMap.h" #include <algorithm> #include <ostream> #include <string> @@ -30,7 +29,7 @@ namespace LHCb { class Tagger final { public: /// The type of tagger which has produced this decision - enum TaggerType { + enum class TaggerType : unsigned short int { none = 0, unknown = 1, Run2_SSPion = 2, @@ -55,21 +54,21 @@ namespace LHCb { /// Fill the ASCII output stream std::ostream& fillStream( std::ostream& s ) const { return s << "{ " - << "type : " << m_type << "\ndecision : " << m_decision << "\nomega : " << m_omega - << "\nmvaValue : " << m_mvaValue << "\ncharge : " << m_charge << "\n }"; + << "type : " << static_cast<unsigned short>( m_type ) << "\ndecision : " << m_decision + << "\nomega : " << m_omega << "\nmvaValue : " << m_mvaValue << "\ncharge : " << m_charge << "\n }"; } /// conversion of string to enum for type TaggerType static TaggerType TaggerTypeToType( const std::string& aName ); /// conversion to string for enum type TaggerType - static const std::string& TaggerTypeToString( int aEnum ); + static const std::string& toString( Tagger::TaggerType aEnum ); /// Retrieve const The type of tagger - [[nodiscard]] unsigned short int type() const { return m_type; } + [[nodiscard]] TaggerType type() const { return m_type; } /// Update The type of tagger - Tagger& setType( unsigned short int value ) { + Tagger& setType( TaggerType value ) { m_type = value; return *this; } @@ -141,12 +140,12 @@ namespace LHCb { friend std::ostream& operator<<( std::ostream& str, const Tagger& obj ) { return obj.fillStream( str ); } private: - unsigned short int m_type = 0; ///< The type of tagger - short int m_decision = 0; ///< decision of tagger - float m_omega = 0.5; ///< wrong tag fraction of tagger from MC tuning - float m_mvaValue = 0; ///< raw output of the mva - float m_charge = 0; ///< (weighted) charge of the tagging particle - SmartRefVector<LHCb::Particle> m_taggerParts; ///< Vector of Particle(s) used to build the Tagger + TaggerType m_type = TaggerType::none; ///< The type of tagger + short int m_decision = 0; ///< decision of tagger + float m_omega = 0.5; ///< wrong tag fraction of tagger from MC tuning + float m_mvaValue = 0; ///< raw output of the mva + float m_charge = 0; ///< (weighted) charge of the tagging particle + SmartRefVector<LHCb::Particle> m_taggerParts; ///< Vector of Particle(s) used to build the Tagger }; // class Tagger diff --git a/Event/PhysEvent/src/Tagger.cpp b/Event/PhysEvent/src/Tagger.cpp index 29be565922458bb8504ca3c898f137348e5246ec..d74035e78dac253ba5d62b975dd078ba5f994d73 100644 --- a/Event/PhysEvent/src/Tagger.cpp +++ b/Event/PhysEvent/src/Tagger.cpp @@ -9,6 +9,7 @@ * or submit itself to any jurisdiction. * \*****************************************************************************/ #include "Event/Tagger.h" +#include "GaudiKernel/VectorMap.h" namespace { using TaggerType = LHCb::Tagger::TaggerType; @@ -38,38 +39,20 @@ namespace LHCb { } return s << "ERROR wrong value " << int( e ) << " for enum LHCb::FlavourTag::TagResult"; } + std::ostream& operator<<( std::ostream& s, LHCb::Tagger::TaggerType e ) { - switch ( e ) { - case Tagger::none: - return s << "none"; - case Tagger::unknown: - return s << "unknown"; - case Tagger::Run2_SSPion: - return s << "Run2_SSPion"; - case Tagger::Run2_SSKaon: - return s << "Run2_SSKaon"; - case Tagger::Run2_SSProton: - return s << "Run2_SSProton"; - case Tagger::Run2_OSKaon: - return s << "Run2_OSKaon"; - case Tagger::Run2_OSMuon: - return s << "Run2_OSMuon"; - case Tagger::Run2_OSElectron: - return s << "Run2_OSElectron"; - case Tagger::Run2_OSVertexCharge: - return s << "Run2_OSVertexCharge"; - } - return s << "ERROR wrong value " << int( e ) << " for enum LHCb::Tagger::TaggerType"; + s << LHCb::Tagger::toString( e ); + return s; } Tagger::TaggerType Tagger::TaggerTypeToType( const std::string& aName ) { auto iter = s_TaggerTypeTypMap.find( aName ); - return iter != s_TaggerTypeTypMap.end() ? iter->second : unknown; + return iter != s_TaggerTypeTypMap.end() ? iter->second : Tagger::TaggerType::unknown; } - const std::string& Tagger::TaggerTypeToString( int aEnum ) { + const std::string& Tagger::toString( Tagger::TaggerType aEnum ) { auto iter = std::find_if( s_TaggerTypeTypMap.begin(), s_TaggerTypeTypMap.end(), - [&]( const std::pair<const std::string, TaggerType>& i ) { return i.second == aEnum; } ); + [&]( const auto& i ) { return i.second == aEnum; } ); return iter != s_TaggerTypeTypMap.end() ? iter->first : s_unknown; } } // namespace LHCb