Skip to content
Snippets Groups Projects
Commit c698fdb0 authored by Gerhard Raven's avatar Gerhard Raven
Browse files

Further streamlining of ThOr functors using ADL

* use ADL for composites
* use ADL for combinations
* use ADL for track-like
* constrain default ADL implementation (which call member functions) to
  not be to 'eager'
* move code from .icpp into .h
parent 6fbe0fc2
No related branches found
No related tags found
2 merge requests!3702merge counter decoder into Louis' original branch,!3394More ADL support for ThOr
......@@ -15,6 +15,7 @@
#include "Kernel/HeaderMapping.h"
#include "Kernel/IDistanceCalculator.h"
#include "LHCbMath/Vec3.h"
namespace Combination::details {
using fp = float;
......@@ -56,20 +57,24 @@ struct ParticleCombination {
/// Geometry information passed to the distance calculator
IGeometryInfo const& m_geometry;
/** @brief Squared-magnitude of the four momentum sum of the children.
/** @brief three momentum sum of the children.
*/
Combination::details::fp mom2() const {
Combination::details::fp px = 0.f;
Combination::details::fp py = 0.f;
Combination::details::fp pz = 0.f;
auto threeMomentum() const {
Combination::details::fp px = 0;
Combination::details::fp py = 0;
Combination::details::fp pz = 0;
for ( auto* i : m_children ) {
px += i->momentum().px();
py += i->momentum().py();
pz += i->momentum().pz();
}
return px * px + py * py + pz * pz;
return LHCb::LinAlg::Vec3{px, py, pz};
}
/** @brief Squared-magnitude of the three momentum sum of the children.
*/
Combination::details::fp mom2() const { return threeMomentum().mag2(); }
template <std::size_t... idxs>
ParticleCombination<std::tuple_element_t<idxs, std::tuple<InputTypes...>>...> get_subcombination() const {
ParticleCombination<std::tuple_element_t<idxs, std::tuple<InputTypes...>>...> out{m_distance_calculator,
......@@ -101,11 +106,15 @@ struct ParticleCombination {
/** @brief Invariant mass of the four momentum sum of the children.
*/
Combination::details::fp mass() const {
Combination::details::fp mass2() const { // TODO: use numerically more stable version
using std::sqrt;
Combination::details::fp energy = 0.;
for ( auto* i : m_children ) { energy += sqrt( pow( i->p(), 2 ) + pow( i->measuredMass(), 2 ) ); }
return sqrt( energy * energy - mom2() );
return energy * energy - mom2();
}
Combination::details::fp mass() const {
using std::sqrt;
return sqrt( mass2() );
}
/** @brief Distance of closest approach between two children.
......
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