diff --git a/Phys/FunTuple/src/FunTuple.cpp b/Phys/FunTuple/src/FunTuple.cpp index f319612b178f5f54911986287c3bfeea389bc0ef..c1c90fbb48a127b480c768aacfa3a1846bf92988 100755 --- a/Phys/FunTuple/src/FunTuple.cpp +++ b/Phys/FunTuple/src/FunTuple.cpp @@ -62,45 +62,44 @@ namespace LHCb { void( const T& ), Gaudi::Functional::Traits::BaseClass_t<LHCb::DetDesc::AlgorithmWithCondition<GaudiTupleAlg>>>; // typedefs for different containers of strings (to be used in definition of ParticleTupleProp objects) - typedef std::vector<std::string> VECT_STRINGS; - typedef std::vector<VECT_STRINGS> VECT_VECT_STRINGS; + using vec_strings_t = std::vector<std::string>; + using vec_vec_strings_t = std::vector<vec_strings_t>; // typedefs to be used as input signature in making container of thor functors - typedef std::vector<ThOr::FunctorDesc> VECT_THORFUNCDESC; - typedef std::vector<VECT_THORFUNCDESC> VECT_VECT_THORFUNCDESC; - typedef std::map<std::string, ThOr::FunctorDesc> MAP_THORFUNCDESC; - template <typename InputSignature> - using THORFUNC = Functors::Functor<InputSignature>; + using vec_funcdesc_t = std::vector<ThOr::FunctorDesc>; + using vec_vec_funcdesc_t = std::vector<vec_funcdesc_t>; + using map_funcdesc_t = std::map<std::string, ThOr::FunctorDesc>; + template <typename InputSignature> - using VECT_THORFUNC = std::vector<THORFUNC<InputSignature>>; + using vec_functor_t = std::vector<Functors::Functor<InputSignature>>; template <typename InputSignature> - using VECT_VECT_THORFUNC = std::vector<VECT_THORFUNC<InputSignature>>; + using vec_vec_functor_t = std::vector<vec_functor_t<InputSignature>>; template <typename InputSignature> - using MAP_THORFUNC = std::map<std::string, THORFUNC<InputSignature>>; + using map_functor_t = std::map<std::string, Functors::Functor<InputSignature>>; // custom class for error code handling (probably needs extending) namespace EC { enum class ErrorCode : StatusCode::code_t { - NAME_NUMBER_MISMATCH = 10, - NUMBER_NOT_UNITARY, - MAX_BUFFER, - SIZE_EXCEED, - TYPE_NOT_SUPPORTED + NameNumberMismatch = 10, + NumberNotUnitary, + MaxBuffer, + SizeExceeded, + TypeNotSupported }; struct ErrorCategory : StatusCode::Category { - const char* name() const override { return "FunTuple"; } - bool isRecoverable( StatusCode::code_t ) const override { return false; } - std::string message( StatusCode::code_t code ) const override { + [[nodiscard]] const char* name() const override { return "FunTuple"; } + [[nodiscard]] bool isRecoverable( StatusCode::code_t ) const override { return false; } + [[nodiscard]] std::string message( StatusCode::code_t code ) const override { switch ( static_cast<ErrorCode>( code ) ) { - case ErrorCode::NAME_NUMBER_MISMATCH: + case ErrorCode::NameNumberMismatch: return "Error (run_full_counter_mode=True): size of field names and number of counters do not match"; - case ErrorCode::NUMBER_NOT_UNITARY: + case ErrorCode::NumberNotUnitary: return "Error (run_full_counter_mode=False): number of counters is not unitary"; - case ErrorCode::MAX_BUFFER: + case ErrorCode::MaxBuffer: return "The size of vector exceeds the max buffer size of 10000"; - case ErrorCode::SIZE_EXCEED: + case ErrorCode::SizeExceeded: return "The size of vector exceeds more than 4. Tupling is not supported."; - case ErrorCode::TYPE_NOT_SUPPORTED: + case ErrorCode::TypeNotSupported: return "Value type returned by functor not recognised. The problematic functor is shown below."; default: return StatusCode::default_category().message( code ); @@ -121,15 +120,15 @@ namespace LHCb { // wrap MCParticles and Particles objects to return specific type (used in find_candidates method of funtuple) template <class T1> struct function_return { - typedef T1 type; + using type = T1; }; template <> struct function_return<LHCb::MCParticles> { - typedef std::vector<LHCb::MCParticle::ConstVector> type; + using type = std::vector<LHCb::MCParticle::ConstVector>; }; template <> struct function_return<LHCb::Particle::Range> { - typedef std::vector<LHCb::Particle::ConstVector> type; + using type = std::vector<LHCb::Particle::ConstVector>; }; } // namespace FTuple } // namespace LHCb @@ -140,7 +139,7 @@ STATUSCODE_ENUM_IMPL( LHCb::FTuple::EC::ErrorCode, LHCb::FTuple::EC::ErrorCatego namespace LHCb { namespace FTuple { // max buffer size for storing array - unsigned int maxSizeArray{10000}; + constexpr unsigned int maxSizeArray{10000}; // For tupling arrays user can specify variable name (e.g. "PT") and length name ("nPVs") as "PT[nPVs]". // This function gets "nPVs" from fieldname, if nothing found assignes default name "indx" @@ -150,7 +149,7 @@ namespace LHCb { std::string stop_del = "]"; idxname = fieldname.substr( fieldname.find( start_del ) + start_del.length(), fieldname.find( stop_del ) - ( fieldname.find( start_del ) + start_del.length() ) ); - if ( idxname == start_del || idxname == stop_del || idxname == "" || idxname == fieldname || + if ( idxname == start_del || idxname == stop_del || idxname.empty() || idxname == fieldname || idxname == fieldname.substr( 0, fieldname.find( stop_del ) ) ) { idxname = "indx"; } @@ -177,7 +176,7 @@ namespace LHCb { // fill for std::vector forward to farray template <typename ValueType> StatusCode fill_( const Tuples::Tuple& ntuple, const std::string& colname, const std::vector<ValueType>& val ) { - if ( val.size() > maxSizeArray ) return StatusCode{EC::ErrorCode::MAX_BUFFER}; + if ( val.size() > maxSizeArray ) { return StatusCode{EC::ErrorCode::MaxBuffer}; } std::string array_idxName = get_length_name( colname ); return ntuple->farray( colname, val, array_idxName, maxSizeArray ); } @@ -185,7 +184,7 @@ namespace LHCb { // fill for std::vector<SIMDWrapper::scalar::float_v> StatusCode fill_( const Tuples::Tuple& ntuple, const std::string& colname, const std::vector<SIMDWrapper::scalar::float_v>& val ) { - if ( val.size() > maxSizeArray ) return StatusCode{EC::ErrorCode::MAX_BUFFER}; + if ( val.size() > maxSizeArray ) return StatusCode{EC::ErrorCode::MaxBuffer}; std::string array_idxName = get_length_name( colname ); auto cast = []( const SIMDWrapper::scalar::float_v& vali ) { return vali.cast(); }; return ntuple->farray( colname, cast, std::begin( val ), std::end( val ), array_idxName, maxSizeArray ); @@ -206,7 +205,7 @@ namespace LHCb { Gaudi::LorentzVector( as_arithmetic( val( 0 ) ), as_arithmetic( val( 1 ) ), as_arithmetic( val( 2 ) ), as_arithmetic( val( 3 ) ) ) ); } - return StatusCode{EC::ErrorCode::SIZE_EXCEED}; + return StatusCode{EC::ErrorCode::SizeExceeded}; } // fill for LinAlg Vec3 with SIMD type @@ -237,7 +236,7 @@ namespace LHCb { StatusCode fill_( const Tuples::Tuple& ntuple, const std::string& colname, std::map<std::string, ValueType> const& val ) { for ( const auto& [key, value] : val ) { - if ( auto sc = fill_( ntuple, colname + "_" + key, value ); sc.isFailure() ) return sc; + if ( auto sc = fill_( ntuple, colname + "_" += key, value ); sc.isFailure() ) { return sc; } } return StatusCode::SUCCESS; } @@ -247,7 +246,7 @@ namespace LHCb { StatusCode fill_<std::any>( const Tuples::Tuple& ntuple, const std::string& colname, std::map<std::string, std::any> const& val ) { for ( const auto& [key, value] : val ) { - if ( auto sc = fill_( ntuple, colname + "_" + key, value ); sc.isFailure() ) return sc; + if ( auto sc = fill_( ntuple, colname + "_" += key, value ); sc.isFailure() ) { return sc; } } return StatusCode::SUCCESS; } @@ -303,7 +302,7 @@ namespace LHCb { // fill function to loop through supported types invoking function that calls fill function StatusCode fill_( const Tuples::Tuple& ntuple, const std::string& colname, std::any const& val ) { auto f = map_valtype_callcolfun.find( val.type() ); - if ( f == map_valtype_callcolfun.end() ) return StatusCode{EC::ErrorCode::TYPE_NOT_SUPPORTED}; + if ( f == map_valtype_callcolfun.end() ) { return StatusCode{EC::ErrorCode::TypeNotSupported}; } return std::invoke( f->second, ntuple, colname, val ); } } // namespace FTuple @@ -314,8 +313,8 @@ class FunTupleBase : public LHCb::FTuple::Consumer<T> { public: FunTupleBase( const std::string& name, ISvcLocator* pSvc ); - virtual StatusCode initialize() override; - virtual void operator()( const T& particles ) const override; + StatusCode initialize() override; + void operator()( const T& particles ) const override; protected: // functions for conducting checks in initialise method @@ -325,9 +324,9 @@ protected: const std::string& functor_type ) const; // functions used in the definition of ParticleTupleProp objects - void fill_returntypes( const LHCb::FTuple::VECT_VECT_STRINGS& funcreturntypes, - const LHCb::FTuple::VECT_VECT_STRINGS& funcfieldnames_suffix, - LHCb::FTuple::VECT_VECT_STRINGS& vec_returntypes ); + void fill_returntypes( const LHCb::FTuple::vec_vec_strings_t& funcreturntypes, + const LHCb::FTuple::vec_vec_strings_t& funcfieldnames_suffix, + LHCb::FTuple::vec_vec_strings_t& vec_returntypes ); StatusCode setParticleTupleProps(); // functions for instantiating functors and counters (TODO: thor instantiations has template specialisation so need @@ -338,10 +337,10 @@ protected: // function for preparing thor used in instantiating template <typename Signature> - StatusCode prepare_thor( LHCb::FTuple::VECT_VECT_THORFUNC<Signature>& vec_vec_fun ); + StatusCode prepare_thor( LHCb::FTuple::vec_vec_functor_t<Signature>& vec_vec_fun ); template <typename Signature> - StatusCode prepare_thor( LHCb::FTuple::MAP_THORFUNC<Signature>& map_fun ); + StatusCode prepare_thor( LHCb::FTuple::map_functor_t<Signature>& map_fun ); template <typename F, typename H> StatusCode prepare_loki( F& fun_loki, std::vector<std::vector<F>>& func_loki_vec, H& factory_loki ); @@ -378,27 +377,27 @@ private: std::vector<ParticleTupleProp> m_particletupleprops; // field name vector - Gaudi::Property<LHCb::FTuple::VECT_STRINGS> m_fieldnames_prefix{ - this, "field_names_prefix", LHCb::FTuple::VECT_STRINGS(), "List of TBranch name prefixes"}; + Gaudi::Property<LHCb::FTuple::vec_strings_t> m_fieldnames_prefix{ + this, "field_names_prefix", LHCb::FTuple::vec_strings_t(), "List of TBranch name prefixes"}; // decay descriptors - Gaudi::Property<LHCb::FTuple::VECT_STRINGS> m_decaydescriptors{ - this, "decay_descriptors", LHCb::FTuple::VECT_STRINGS(), "List of DecayDescriptors"}; + Gaudi::Property<LHCb::FTuple::vec_strings_t> m_decaydescriptors{ + this, "decay_descriptors", LHCb::FTuple::vec_strings_t(), "List of DecayDescriptors"}; // LoKi functors (code: string) - Gaudi::Property<LHCb::FTuple::VECT_VECT_STRINGS> m_functors_loki{ - this, "loki_functors", LHCb::FTuple::VECT_VECT_STRINGS(), "Container of list of LoKi functor names"}; + Gaudi::Property<LHCb::FTuple::vec_vec_strings_t> m_functors_loki{ + this, "loki_functors", LHCb::FTuple::vec_vec_strings_t(), "Container of list of LoKi functor names"}; // TBranch name for loki - Gaudi::Property<LHCb::FTuple::VECT_VECT_STRINGS> m_funcfieldnames_suffix_loki{ - this, "loki_functor_field_names", LHCb::FTuple::VECT_VECT_STRINGS(), + Gaudi::Property<LHCb::FTuple::vec_vec_strings_t> m_funcfieldnames_suffix_loki{ + this, "loki_functor_field_names", LHCb::FTuple::vec_vec_strings_t(), "Container of list of LoKi functor TBranch names"}; // user specified precision to cast loki functor output (currently this not available since Gaudi needs to allow this) - Gaudi::Property<LHCb::FTuple::VECT_VECT_STRINGS> m_funcreturntypes_loki{ - this, "loki_functor_return_types", LHCb::FTuple::VECT_VECT_STRINGS(), + Gaudi::Property<LHCb::FTuple::vec_vec_strings_t> m_funcreturntypes_loki{ + this, "loki_functor_return_types", LHCb::FTuple::vec_vec_strings_t(), "Container of list of LoKi functor return types"}; - LHCb::FTuple::VECT_VECT_STRINGS m_returntypes_loki; + LHCb::FTuple::vec_vec_strings_t m_returntypes_loki; // loki preamble Gaudi::Property<std::vector<std::string>> m_preamble_def_loki{this, "loki_preamble", {}, "List of preamble strings"}; @@ -425,32 +424,32 @@ private: ToolHandle<Decays::IMCDecay> m_mcdecaytool_loki = {this, "MCDecay", "LoKi::MCDecay"}; // Non-void ThOr functors (used to tuple candidate info) - Gaudi::Property<LHCb::FTuple::VECT_VECT_THORFUNCDESC> m_functors_thor{ + Gaudi::Property<LHCb::FTuple::vec_vec_funcdesc_t> m_functors_thor{ this, "thor_functors", {}, "List of non-void ThOr Functors"}; // Void ThOr functors (used to tuple event info, called once per candidate) - Gaudi::Property<LHCb::FTuple::MAP_THORFUNCDESC> m_void_functors_thor{ + Gaudi::Property<LHCb::FTuple::map_funcdesc_t> m_void_functors_thor{ this, "void_thor_functors", {}, "Map of void ThOr Functors"}; // Thor TBranch names - Gaudi::Property<LHCb::FTuple::VECT_VECT_STRINGS> m_funcfieldnames_suffix_thor{ - this, "thor_functor_field_names", LHCb::FTuple::VECT_VECT_STRINGS(), + Gaudi::Property<LHCb::FTuple::vec_vec_strings_t> m_funcfieldnames_suffix_thor{ + this, "thor_functor_field_names", LHCb::FTuple::vec_vec_strings_t(), "Contianer of list of ThOr functor TBranch names"}; // user specified precision to cast thor functor output (currently this not available since Gaudi needs to allow this) - Gaudi::Property<LHCb::FTuple::VECT_VECT_STRINGS> m_funcreturntypes_thor{ - this, "thor_functor_return_types", LHCb::FTuple::VECT_VECT_STRINGS(), + Gaudi::Property<LHCb::FTuple::vec_vec_strings_t> m_funcreturntypes_thor{ + this, "thor_functor_return_types", LHCb::FTuple::vec_vec_strings_t(), "Container of list of ThOr functor return types"}; - LHCb::FTuple::VECT_VECT_STRINGS m_returntypes_thor; // return types (vectors where returntypes are actually stored) + LHCb::FTuple::vec_vec_strings_t m_returntypes_thor; // return types (vectors where returntypes are actually stored) // Thor functor factory ServiceHandle<Functors::IFactory> m_factory_thor{this, "Factory", "FunctorFactory"}; // Thor Vector of functors (This is input dependent) // containers for holding thor (TODO: Need one for v2Paritlce) - LHCb::FTuple::VECT_VECT_THORFUNC<LHCb::ThOrInputType::Signature_Particle> m_fun_thor; - LHCb::FTuple::VECT_VECT_THORFUNC<LHCb::ThOrInputType::Signature_MCParticle> m_mcfun_thor; - LHCb::FTuple::MAP_THORFUNC<LHCb::ThOrInputType::Signature_Void> m_void_thor; + LHCb::FTuple::vec_vec_functor_t<LHCb::ThOrInputType::Signature_Particle> m_fun_thor; + LHCb::FTuple::vec_vec_functor_t<LHCb::ThOrInputType::Signature_MCParticle> m_mcfun_thor; + LHCb::FTuple::map_functor_t<LHCb::ThOrInputType::Signature_Void> m_void_thor; // Gaudi event monitoring counter mutable Gaudi::Accumulators::Counter<> m_processed_evt{this, "# processed events"}; @@ -551,7 +550,7 @@ StatusCode FunTupleBase<LHCb::MCParticles>::instantiate_thor() { template <class T> template <typename Signature> -StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::VECT_VECT_THORFUNC<Signature>& vec_vec_fun ) { +StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::vec_vec_functor_t<Signature>& vec_vec_fun ) { if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Preparing ThOr functors" << endmsg; } // retrive factory m_factory_thor.retrieve().ignore(); @@ -576,7 +575,7 @@ StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::VECT_VECT_THORFUNC<Signa template <class T> template <typename Signature> -StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::MAP_THORFUNC<Signature>& map_fun ) { +StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::map_functor_t<Signature>& map_fun ) { if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Preparing ThOr functors" << endmsg; } // retrive factory m_factory_thor.retrieve().ignore(); @@ -609,24 +608,26 @@ template <typename F, typename H> StatusCode FunTupleBase<T>::prepare_loki( F& fun_loki, std::vector<std::vector<F>>& func_loki_vec, H& factory_loki ) { MsgStream debug = this->debug(); // Instantiate all the functors (the FunctorProp objects created cant hold some reason this info) - if ( this->msgLevel( MSG::VERBOSE ) ) this->verbose() << "Preparing LoKi functors" << endmsg; + if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Preparing LoKi functors" << endmsg; } m_preamble_loki = boost::algorithm::join( m_preamble_def_loki.value(), "\n" ); for ( const auto& ptp : m_particletupleprops ) { std::vector<F> i_fun; for ( const auto& tup : ptp.FunctorProps_loki() ) { - if ( this->msgLevel( MSG::DEBUG ) ) debug << "prepare_loki: Getting LoKi functor" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "prepare_loki: Getting LoKi functor" << endmsg; } StatusCode sc_func_mc = factory_loki->get( tup.Func_loki, fun_loki, m_preamble_loki ); if ( sc_func_mc.isFailure() ) { return this->Error( "Error in preparing functor in particle field " + ptp.FieldName() + " with functor field name " + tup.Func_fieldname_loki ); } - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "prepare_loki: Storing the functor into a temporary vector" << endmsg; + } i_fun.push_back( fun_loki ); // different - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "prepare_loki: Created a function in " + ptp.FieldName() + " with " + tup.Func_fieldname_loki + " : The function is '" << i_fun.back() << "'" << endmsg; + } } func_loki_vec.push_back( i_fun ); } @@ -638,15 +639,14 @@ StatusCode FunTupleBase<T>::instantiate_dynamic_counters() { auto append_fields = [&]( auto& counters, std::string const& prefix, bool const& full_counter_mode ) { return counters.with_lock( [&]( std::deque<Gaudi::Accumulators::Counter<>>& counter ) { if ( full_counter_mode ) { - for ( const auto& bn : m_fieldnames_prefix ) counter.emplace_back( this, prefix + bn ); + for ( const auto& bn : m_fieldnames_prefix ) { counter.emplace_back( this, prefix + bn ); } return ( counter.size() == m_fieldnames_prefix.size() ) ? StatusCode{StatusCode::SUCCESS} - : StatusCode{LHCb::FTuple::EC::ErrorCode::NAME_NUMBER_MISMATCH}; - } else { - counter.emplace_back( this, prefix + m_fieldnames_prefix[0] ); - return ( counter.size() == 1 ) ? StatusCode{StatusCode::SUCCESS} - : StatusCode{LHCb::FTuple::EC::ErrorCode::NUMBER_NOT_UNITARY}; + : StatusCode{LHCb::FTuple::EC::ErrorCode::NameNumberMismatch}; } + counter.emplace_back( this, prefix + m_fieldnames_prefix[0] ); + return ( counter.size() == 1 ) ? StatusCode{StatusCode::SUCCESS} + : StatusCode{LHCb::FTuple::EC::ErrorCode::NumberNotUnitary}; } ); }; @@ -679,7 +679,7 @@ StatusCode FunTupleBase<T>::checks() { } if ( !m_all_empty_lokifuncs ) { - if ( this->msgLevel( MSG::VERBOSE ) ) this->verbose() << "Conducting checks with LoKi " << endmsg; + if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Conducting checks with LoKi " << endmsg; } // If the return types are not given set to a default (double), currently property not used anywhere, so does not // matter fill_returntypes( m_funcreturntypes_loki, m_funcfieldnames_suffix_loki, m_returntypes_loki ); @@ -692,7 +692,7 @@ StatusCode FunTupleBase<T>::checks() { } if ( !m_all_empty_thorfuncs ) { - if ( this->msgLevel( MSG::VERBOSE ) ) this->verbose() << "Conducting checks with ThOr " << endmsg; + if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Conducting checks with ThOr " << endmsg; } // If the return types are not given set to a default (double), currently property not used anywhere, so does not // matter fill_returntypes( m_funcreturntypes_thor, m_funcfieldnames_suffix_thor, m_returntypes_thor ); @@ -728,14 +728,14 @@ StatusCode FunTupleBase<T>::checks_with_vector_sizes( const int& fieldnames_size } template <class T> -void FunTupleBase<T>::fill_returntypes( const LHCb::FTuple::VECT_VECT_STRINGS& funcreturntypes, - const LHCb::FTuple::VECT_VECT_STRINGS& funcfieldnames_suffix, - LHCb::FTuple::VECT_VECT_STRINGS& vec_returntypes ) { +void FunTupleBase<T>::fill_returntypes( const LHCb::FTuple::vec_vec_strings_t& funcreturntypes, + const LHCb::FTuple::vec_vec_strings_t& funcfieldnames_suffix, + LHCb::FTuple::vec_vec_strings_t& vec_returntypes ) { if ( funcreturntypes.empty() ) { // If the return types are not given set to a default (double), currently property not used anywhere, so does not // matter for ( const auto& fbnm : funcfieldnames_suffix ) { - LHCb::FTuple::VECT_STRINGS returntypes( fbnm.size() ); + LHCb::FTuple::vec_strings_t returntypes( fbnm.size() ); for ( std::size_t j = 0; j < fbnm.size(); ++j ) { returntypes[j] = std::string( "double" ); } vec_returntypes.push_back( returntypes ); } @@ -747,8 +747,9 @@ void FunTupleBase<T>::fill_returntypes( const LHCb::FTuple::VECT_VECT_STRINGS& f template <class T> StatusCode FunTupleBase<T>::setParticleTupleProps() { // make a list of ParticleTupleProp objects to hold info related to particle being tupled - if ( this->msgLevel( MSG::VERBOSE ) ) + if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Setting the properties of ParticleTupleProp objects" << endmsg; + } for ( unsigned int i = 0; i < m_fieldnames_prefix.size(); i++ ) { ParticleTupleProp ptp = ParticleTupleProp(); ptp.setFieldName( m_fieldnames_prefix[i] ); @@ -773,13 +774,13 @@ void FunTupleBase<T>::operator()( const T& particles ) const { // Messaging service MsgStream debug = this->debug(); - if ( this->msgLevel( MSG::DEBUG ) ) debug << "operator(): Finding candidates" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "operator(): Finding candidates" << endmsg; } const auto vector_of_cands = find_candidates( particles ); - if ( this->msgLevel( MSG::DEBUG ) ) debug << "operator(): If any candidates found book nTuple" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "operator(): If any candidates found book nTuple" << endmsg; } write_tuple( vector_of_cands ); - if ( this->msgLevel( MSG::DEBUG ) ) debug << "operator(): Moving to next event updating the counter" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "operator(): Moving to next event updating the counter" << endmsg; } ++m_processed_evt; } @@ -793,16 +794,17 @@ void FunTupleBase<T>::write_tuple( const std::vector<std::vector<ValueType>>& ve // quit if current event has no candidate if ( vector_of_cands[0].empty() ) { - if ( this->msgLevel( MSG::DEBUG ) ) debug << "write_tuple: No candidates booking skipped" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "write_tuple: No candidates booking skipped" << endmsg; } return; - } else { - if ( this->msgLevel( MSG::DEBUG ) ) debug << "write_tuple: Candidates found booking their info" << endmsg; } - if ( this->msgLevel( MSG::DEBUG ) ) debug << "write_tuple: Defining Tuples:Tuple instance" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { + debug << "write_tuple: Candidates found booking their info" << endmsg; + debug << "write_tuple: Defining Tuples:Tuple instance" << endmsg; + } Tuples::Tuple ntuple = this->nTuple( m_ntupleTname ); - if ( this->msgLevel( MSG::DEBUG ) ) debug << "write_tuple: Looping over the candidates and fields" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "write_tuple: Looping over the candidates and fields" << endmsg; } for ( unsigned int ncand = 0; ncand < vector_of_cands[0].size(); ncand++ ) { // number of cands (write tuple) // fill event level info with void ThOr functors @@ -813,7 +815,7 @@ void FunTupleBase<T>::write_tuple( const std::vector<std::vector<ValueType>>& ve // helpful notifier on what might have gone wrong if ( sc_book_event.isFailure() ) { using LHCb::FTuple::EC::ErrorCode; - if ( sc_book_event.getCode() == static_cast<StatusCode::code_t>( ErrorCode::TYPE_NOT_SUPPORTED ) ) { + if ( sc_book_event.getCode() == static_cast<StatusCode::code_t>( ErrorCode::TypeNotSupported ) ) { err << "Value type returned by functor not supported. Problematic ThOr functor : " << value.code << " with field name: " << key << endmsg; } else { @@ -845,15 +847,17 @@ void FunTupleBase<T>::write_tuple( const std::vector<std::vector<ValueType>>& ve for ( unsigned int nfunctor = 0; nfunctor < ( ptp.FunctorProps_loki() ).size(); nfunctor++ ) { ParticleProp::FunctorProp_loki functup = ( ptp.FunctorProps_loki() )[nfunctor]; std::string fieldname = ptp.FieldName() + "_" + functup.Func_fieldname_loki; - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "write_tuple: Getting Loki output for fieldname " << fieldname << endmsg; + } auto val = get_loki_output( *cand, nfield, nfunctor ); - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "write_tuple: Booking Loki output for fieldname " << fieldname << endmsg; + } StatusCode sc_book = LHCb::FTuple::fill_( ntuple, fieldname, val ); if ( sc_book.isFailure() ) { using LHCb::FTuple::EC::ErrorCode; - if ( sc_book.getCode() == static_cast<StatusCode::code_t>( ErrorCode::TYPE_NOT_SUPPORTED ) ) { + if ( sc_book.getCode() == static_cast<StatusCode::code_t>( ErrorCode::TypeNotSupported ) ) { err << "Value type returned by functor not supported. Problematic LoKi functor : " << functup.Func_loki << " with field name: " << fieldname << endmsg; } else { @@ -871,15 +875,17 @@ void FunTupleBase<T>::write_tuple( const std::vector<std::vector<ValueType>>& ve for ( unsigned int nfunctor = 0; nfunctor < ( ptp.FunctorProps_thor() ).size(); nfunctor++ ) { ParticleProp::FunctorProp_thor functup = ( ptp.FunctorProps_thor() )[nfunctor]; std::string fieldname = ptp.FieldName() + "_" + functup.Func_fieldname_thor; - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "write_tuple: Getting ThOr output for fieldname " << fieldname << endmsg; + } auto val = get_thor_output( *cand, nfield, nfunctor ); - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "write_tuple: Booking ThOr output for fieldname " << fieldname << endmsg; + } StatusCode sc_book = LHCb::FTuple::fill_( ntuple, fieldname, val ); if ( sc_book.isFailure() ) { using LHCb::FTuple::EC::ErrorCode; - if ( sc_book.getCode() == static_cast<StatusCode::code_t>( ErrorCode::TYPE_NOT_SUPPORTED ) ) { + if ( sc_book.getCode() == static_cast<StatusCode::code_t>( ErrorCode::TypeNotSupported ) ) { err << "Value type returned by functor not supported. Problematic ThOr functor : " << ( *( functup.Func_thor ) ).code << " with field name: " << fieldname << endmsg; } else { @@ -891,7 +897,7 @@ void FunTupleBase<T>::write_tuple( const std::vector<std::vector<ValueType>>& ve } } } - if ( this->msgLevel( MSG::DEBUG ) ) debug << "write_tuple: Writing tuple after booking" << endmsg; + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "write_tuple: Writing tuple after booking" << endmsg; } StatusCode sc_write = ntuple->write(); if ( sc_write.isFailure() ) { this->err() << "Unable to write the tuple" << endmsg; } } @@ -910,8 +916,9 @@ FunTupleBase<LHCb::MCParticles>::find_candidates( const LHCb::MCParticles& parti debug << "find_candidates (MCParticles): Preparing the input particle vector" << endmsg; } LHCb::MCParticle::ConstVector input; - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "find_candidates (MCParticles): Using the particles passed through the algorithm" << endmsg; + } for ( const auto& ip : particles ) { if ( this->msgLevel( MSG::DEBUG ) ) { debug << "find_candidates (MCParticles): Filling input vector with particle" << endmsg; @@ -962,7 +969,7 @@ FunTupleBase<LHCb::MCParticles>::find_candidates( const LHCb::MCParticles& parti if ( m_full_counter_mode ) { update_counters( nfield, cands.size() ); } else { - if ( nfield == 0 ) update_counters( nfield, cands.size() ); + if ( nfield == 0 ) { update_counters( nfield, cands.size() ); } } // push the cands to vector of cands if ( this->msgLevel( MSG::DEBUG ) ) { @@ -987,8 +994,9 @@ FunTupleBase<LHCb::Particle::Range>::find_candidates( const LHCb::Particle::Rang debug << "find_candidates (Particles): Preparing the input particle vector" << endmsg; } LHCb::Particle::ConstVector input; - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "find_candidates (Particles): Using the particles passed through the algorithm" << endmsg; + } for ( const auto& ip : particles ) { if ( this->msgLevel( MSG::DEBUG ) ) { debug << "find_candidates (Particles): Filling input vector with particle" << endmsg; @@ -1037,7 +1045,7 @@ FunTupleBase<LHCb::Particle::Range>::find_candidates( const LHCb::Particle::Rang if ( m_full_counter_mode ) { update_counters( nfield, cands.size() ); } else { - if ( nfield == 0 ) update_counters( nfield, cands.size() ); + if ( nfield == 0 ) { update_counters( nfield, cands.size() ); } } // push the cands to vector of cands if ( this->msgLevel( MSG::DEBUG ) ) { @@ -1053,24 +1061,25 @@ FunTupleBase<LHCb::Particle::Range>::find_candidates( const LHCb::Particle::Rang template <class T> void FunTupleBase<T>::update_counters( const unsigned int& field_indx, const unsigned int& ncands ) const { MsgStream debug = this->debug(); - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { debug << "update_counters: The number of candidates found in the event are " << ncands << " for field index " << field_indx << endmsg; + } // define a function to increment the counters auto increment_counter = [&field_indx]( auto& counters ) { return counters.with_lock( [&]( std::deque<Gaudi::Accumulators::Counter<>>& counter ) { ++counter[field_indx]; } ); }; if ( ncands == 0 ) { increment_counter( m_vec_empty_evt ); - if ( this->msgLevel( MSG::DEBUG ) ) + if ( this->msgLevel( MSG::DEBUG ) ) { this->Warning( "update_counters: No candidates found in this event. Skipping this event", StatusCode::SUCCESS ) .ignore(); + } return; - } else { - increment_counter( m_vec_nonempty_evt ); } + increment_counter( m_vec_nonempty_evt ); + if ( ncands > 1 ) { increment_counter( m_vec_multiple_cand_evt ); } - return; } DECLARE_COMPONENT_WITH_ID( FunTupleBase<LHCb::Particle::Range>, "FunTupleBase_Particles" )