Skip to content
Snippets Groups Projects

Resolve #345 "Add loki mtdocachi2 functor to thor"

Merged Emily Kaiyin Jiang requested to merge 345-add-loki-mtdocachi2-functor-to-thor into master
Files
4
/*****************************************************************************\
* (c) Copyright 2019-20 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
* (c) Copyright 2019-20 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#pragma once
#include "Event/FlavourTag.h"
@@ -20,6 +20,10 @@
#include "SelKernel/Utilities.h"
#include "SelKernel/VertexRelation.h"
#include "Event/Particle.h"
#include "Event/Particle_v2.h"
#include "Functors/TrackLike.h"
/** @file Composite.h
* @brief Definitions of functors for composite-particle-like objects.
*/
@@ -47,6 +51,43 @@ namespace Functors::detail {
} // namespace Functors::detail
namespace Functors::Composite {
/**MTDOCACHI2**/
template <int N>
struct MotherTrajectoryDistanceOfClosestApproachChi2 : public Function {
static_assert( N >= 1, "Indices start from 1 for LoKi compatibility." );
MotherTrajectoryDistanceOfClosestApproachChi2( std::integral_constant<int, N> = {} ) {}
void bind( TopLevelInfo& top_level ) { m_dist_calc.emplace( top_level.algorithm() ); }
template <typename VContainer, typename Particle>
auto operator()( VContainer const& vertices, Particle const& composite ) const {
auto const bestPV = Sel::getBestPV( composite, vertices );
using Sel::Utils::decayProducts;
auto const& children = decayProducts( composite );
auto const& pN = children[N - 1];
auto const& pN_state = Sel::stateVectorFromComposite( pN );
using Sel::Utils::posCovMatrix;
using Sel::Utils::referencePoint;
using Sel::Utils::threeMomCovMatrix;
using Sel::Utils::threeMomentum;
using Sel::Utils::threeMomPosCovMatrix;
auto const& composite_state = Sel::stateVectorComputations(
endVertexPos( bestPV ), threeMomentum( composite ), threeMomCovMatrix( composite ), posCovMatrix( bestPV ),
threeMomPosCovMatrix( composite ) );
const auto& dist_calc = *m_dist_calc;
return dist_calc.stateDOCAChi2( composite_state, pN_state );
}
private:
std::optional<Functors::detail::DefaultDistanceCalculator_t> m_dist_calc;
};
/** @brief Flight distance chi2 to the given vertex.
*
* Note that if the given data object contains a vertex link then that will
Loading