Skip to content
Snippets Groups Projects
Commit 269e3305 authored by Rosen Matev's avatar Rosen Matev :sunny:
Browse files

Merge branch 'chasse_Functor_JIT' into 'master'

feat(functor): adapt to new JIT FunctorFactory

See merge request !871
parents 987c7015 720c4967
No related branches found
No related tags found
1 merge request!871feat(functor): adapt to new JIT FunctorFactory
Pipeline #3771467 passed
......@@ -115,10 +115,6 @@ namespace LHCb {
using Signature_MCParticle = std::any( LHCb::MCParticle const& );
using Signature_Particle = std::any( LHCb::Particle const& );
using Signature_Void = std::any();
FTuple::VECT_STRINGS Headers_MCParticle{"Event/MCParticle.h"};
// MCParticle.h added to header to get the MC association working e.g. with F.MAP_INPUT(F.P, MCAssocTable)
// Since neither F.P or F.MAP_INPUT contains this header
FTuple::VECT_STRINGS Headers_Particle{"Event/Particle.h", "Event/MCParticle.h"};
} // namespace ThOrInputType
namespace FTuple {
......@@ -342,15 +338,10 @@ protected:
// function for preparing thor used in instantiating
template <typename Signature>
StatusCode prepare_thor( LHCb::FTuple::VECT_VECT_THORFUNC<Signature>& vec_vec_fun,
const LHCb::FTuple::VECT_STRINGS& headers );
StatusCode prepare_thor( LHCb::FTuple::VECT_VECT_THORFUNC<Signature>& vec_vec_fun );
template <typename Signature>
StatusCode prepare_thor( LHCb::FTuple::MAP_THORFUNC<Signature>& map_fun, const LHCb::FTuple::VECT_STRINGS& headers );
template <typename Signature>
LHCb::FTuple::THORFUNC<Signature> prepare_single_thor( ThOr::FunctorDesc& tfuncthor,
const LHCb::FTuple::VECT_STRINGS& headers );
StatusCode prepare_thor( LHCb::FTuple::MAP_THORFUNC<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 );
......@@ -461,10 +452,6 @@ private:
LHCb::FTuple::VECT_VECT_THORFUNC<LHCb::ThOrInputType::Signature_MCParticle> m_mcfun_thor;
LHCb::FTuple::MAP_THORFUNC<LHCb::ThOrInputType::Signature_Void> m_void_thor;
// extra headers to be included into ThOr functors
Gaudi::Property<std::vector<std::string>> m_extraheaders_thor{
this, "thor_preamble", {}, "List of preamble/header to be included in ThOr Functors"};
// Gaudi event monitoring counter
mutable Gaudi::Accumulators::Counter<> m_processed_evt{this, "# processed events"};
......@@ -539,13 +526,12 @@ StatusCode FunTupleBase<T>::initialize() {
template <>
StatusCode FunTupleBase<LHCb::Particle::Range>::instantiate_thor() {
// prepare void functors
StatusCode sc_func_void =
prepare_thor<LHCb::ThOrInputType::Signature_Void>( m_void_thor, LHCb::ThOrInputType::Headers_Particle );
StatusCode sc_func_void = prepare_thor<LHCb::ThOrInputType::Signature_Void>( m_void_thor );
if ( sc_func_void.isFailure() ) { return sc_func_void; }
// prepare nonvoid functors
StatusCode sc_func =
prepare_thor<LHCb::ThOrInputType::Signature_Particle>( m_fun_thor, LHCb::ThOrInputType::Headers_Particle );
StatusCode sc_func = prepare_thor<LHCb::ThOrInputType::Signature_Particle>( m_fun_thor );
if ( sc_func.isFailure() ) { return this->Error( "Error in preparing ThOr functors for Particles" ); }
return sc_func;
}
......@@ -553,68 +539,57 @@ StatusCode FunTupleBase<LHCb::Particle::Range>::instantiate_thor() {
template <>
StatusCode FunTupleBase<LHCb::MCParticles>::instantiate_thor() {
// prepare void functors
StatusCode sc_func_void =
prepare_thor<LHCb::ThOrInputType::Signature_Void>( m_void_thor, LHCb::ThOrInputType::Headers_MCParticle );
StatusCode sc_func_void = prepare_thor<LHCb::ThOrInputType::Signature_Void>( m_void_thor );
if ( sc_func_void.isFailure() ) { return sc_func_void; }
// prepare nonvoid functors
StatusCode sc_func =
prepare_thor<LHCb::ThOrInputType::Signature_MCParticle>( m_mcfun_thor, LHCb::ThOrInputType::Headers_MCParticle );
StatusCode sc_func = prepare_thor<LHCb::ThOrInputType::Signature_MCParticle>( m_mcfun_thor );
if ( sc_func.isFailure() ) { return this->Error( "Error in preparing ThOr functors for MCParticles" ); }
return sc_func;
}
template <class T>
template <typename Signature>
StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::VECT_VECT_THORFUNC<Signature>& vec_vec_fun,
const LHCb::FTuple::VECT_STRINGS& headers ) {
MsgStream debug = this->debug();
if ( this->msgLevel( MSG::VERBOSE ) ) this->verbose() << "Preparing ThOr functors" << endmsg;
StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::VECT_VECT_THORFUNC<Signature>& vec_vec_fun ) {
if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Preparing ThOr functors" << endmsg; }
// retrive factory
m_factory_thor.retrieve().ignore();
// loop over branches
for ( auto& ptp : m_particletupleprops ) {
// we need to ensure that the reference of the functor we pass to
// register_functor does not change!! Thus let's just default construct the
// entire vector with the right size.
vec_vec_fun.emplace_back();
// loop through functors in a branch and get a prepared functor
for ( auto& tup : ptp.FunctorProps_thor() ) {
ThOr::FunctorDesc tfuncthor = *( tup.Func_thor );
vec_vec_fun.back().emplace_back( prepare_single_thor<Signature>( tfuncthor, headers ) );
vec_vec_fun.back().reserve( ptp.FunctorProps_thor().size() );
for ( auto const& tup : ptp.FunctorProps_thor() ) {
if ( this->msgLevel( MSG::DEBUG ) ) {
this->debug() << "prepare_thor: ThOr descendant" << *( tup.Func_thor ) << endmsg;
}
m_factory_thor->register_functor( this, vec_vec_fun.back().emplace_back(), *( tup.Func_thor ) );
}
}
if ( this->msgLevel( MSG::DEBUG ) ) debug << "prepare_thor: ThOr container size is " << vec_vec_fun.size() << endmsg;
if ( this->msgLevel( MSG::DEBUG ) ) {
this->debug() << "prepare_thor: ThOr container size is " << vec_vec_fun.size() << endmsg;
}
return StatusCode::SUCCESS;
}
template <class T>
template <typename Signature>
StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::MAP_THORFUNC<Signature>& map_fun,
const LHCb::FTuple::VECT_STRINGS& headers ) {
MsgStream debug = this->debug();
if ( this->msgLevel( MSG::VERBOSE ) ) this->verbose() << "Preparing ThOr functors" << endmsg;
StatusCode FunTupleBase<T>::prepare_thor( LHCb::FTuple::MAP_THORFUNC<Signature>& map_fun ) {
if ( this->msgLevel( MSG::VERBOSE ) ) { this->verbose() << "Preparing ThOr functors" << endmsg; }
// retrive factory
m_factory_thor.retrieve().ignore();
// loop over maps of non-void functors (requires non-const value) and insert it into map_fun
for ( auto& [key, value] : m_void_functors_thor ) {
map_fun.try_emplace( key, prepare_single_thor<Signature>( value, headers ) );
for ( auto const& [key, functor_desc] : m_void_functors_thor ) {
if ( this->msgLevel( MSG::DEBUG ) ) { this->debug() << "prepare_thor: ThOr descendant" << functor_desc << endmsg; }
m_factory_thor->register_functor( this, map_fun[key], functor_desc );
}
if ( this->msgLevel( MSG::DEBUG ) ) {
this->debug() << "prepare_thor: ThOr container size is " << map_fun.size() << endmsg;
}
if ( this->msgLevel( MSG::DEBUG ) ) debug << "prepare_thor: ThOr container size is " << map_fun.size() << endmsg;
return StatusCode::SUCCESS;
}
template <class T>
template <typename Signature>
LHCb::FTuple::THORFUNC<Signature> FunTupleBase<T>::prepare_single_thor( ThOr::FunctorDesc& tfuncthor,
const LHCb::FTuple::VECT_STRINGS& headers ) {
MsgStream debug = this->debug();
if ( this->msgLevel( MSG::DEBUG ) ) debug << "prepare_single_thor: ThOr descendant" << tfuncthor << endmsg;
// add all the necessary headers + ones passed by user if necessary
for ( const auto& header : headers ) { tfuncthor.headers.emplace_back( header ); }
for ( const auto& header : m_extraheaders_thor ) { tfuncthor.headers.emplace_back( header ); }
if ( this->msgLevel( MSG::DEBUG ) )
debug << "prepare_single_thor: ThOr descendant after adding headers" << tfuncthor << endmsg;
return std::move( m_factory_thor->get<typename LHCb::FTuple::THORFUNC<Signature>>( this, tfuncthor ) );
}
template <>
StatusCode FunTupleBase<LHCb::Particle::Range>::instantiate_loki() {
StatusCode sc_func = prepare_loki( m_vfun_loki, m_fun_loki, m_factory_loki );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment