Commit 6f6e32b5 authored by CI Runner's avatar CI Runner
Browse files

Include Neutral as a ChildType in the vertex fitter

parent 7fb48697
Pipeline #3278907 passed with stage
in 24 seconds
......@@ -118,16 +118,16 @@ namespace Sel::Fitters {
enum struct ChildType : unsigned char {
TrackWithVelo = 0,
TrackWithoutVelo,
Track,
Composite,
Resonance,
Neutral,
Other,
NumTypes
};
template <ChildType C>
static constexpr bool has_full_state_v = ( C == ChildType::Composite || C == ChildType::Resonance ||
C == ChildType::Other );
C == ChildType::Neutral || C == ChildType::Other );
/** Indirectly stolen from TrackVertexUtils::poca
*/
......@@ -259,7 +259,7 @@ namespace Sel::Fitters {
// bit messy.
if constexpr ( child_type == ChildType::Composite ) {
addToFourVector_Composite( vertexpos, p4, p4cov, gainmatrix );
} else if constexpr ( child_type == ChildType::Track ) {
} else if constexpr ( child_type == ChildType::TrackWithVelo || child_type == ChildType::TrackWithoutVelo ) {
addToFourVector_Track( vertexpos, p4, p4cov, gainmatrix );
} else {
}
......@@ -417,7 +417,7 @@ namespace Sel::Fitters {
* @todo Handle TrackWithoutVelo.
*/
template <typename child_t>
struct TrackChildHelper {
struct TrackWithVeloChildHelper {
/** Determine if the given `child_t` type represents a [chunk of] tracks.
* @todo Make this more sophisticated and follow changes in the event
* model.
......@@ -454,9 +454,60 @@ namespace Sel::Fitters {
static auto prepareChild( [[maybe_unused]] VecN<3, float_v> const& vertex_position,
[[maybe_unused]] mask_v const& vertex_position_mask, [[maybe_unused]] ChildType type,
child_t const& child ) {
assert( type == ChildType::TrackWithVelo || type == ChildType::TrackWithoutVelo );
assert( type == ChildType::TrackWithVelo );
using VertexTrack =
VertexTraj<child_t, ChildType::Track /* flag this represents a track not a weakly-decaying composite */>;
VertexTraj<child_t,
ChildType::TrackWithVelo /* flag this represents a track not a weakly-decaying composite */>;
return VertexTrack{child, child.state( child_t::StateLocation::ClosestToBeam )};
}
};
/** Helper type for identifying and handling TrackWithVelo and
* TrackWithoutVelo children.
* @todo Handle TrackWithoutVelo.
*/
template <typename child_t>
struct TrackWithoutVeloChildHelper {
/** Determine if the given `child_t` type represents a [chunk of] tracks.
* @todo Make this more sophisticated and follow changes in the event
* model.
*/
constexpr static bool value = Sel::Utils::has_tracklike_API<child_t>;
/** Given that `value` was `true`, derive (at runtime) the `ChildType` of
* `child_t`. This basically means "is it a long or downstream track".
* @todo Implement check and maybe return `ChildType::TrackWithoutVelo`.
* @todo Clearly state what is supported when `child` is a vector type.
* For example, if it is a proxy into a container that supports
* heterogeneous row types (e.g. some rows are long, some rows are
* downstream) then there is not a single correct return value we
* can give here. Is that a runtime error? Should the return type
* be changed so that can be supported?
*/
static ChildType deriveType( LHCb::IParticlePropertySvc const&, [[maybe_unused]] child_t const& child ) {
return ChildType::TrackWithoutVelo;
}
/** Given that `value` was `true`, and that `type` was returned by our
* `deriveType` function, return the narrowest-possible std::variant of
* types implementing the API used in the vertex fit. For tracks there
* should just be one return type (i.e. a variant of size 1), but there
* will be some runtime branching on the `type` to figure out how to get
* the relevant state.
* @todo Use `vertex_position` and its validity mask
* `vertex_position_mask` to determine if a sophisticated
* extrapolation is needed.
* @todo Implement this logic, don't just blindly call the
* `state(StateLocation::ClosestToBeam)` accessor. Remove [[maybe_unused]].
*/
template <typename mask_v, typename float_v>
static auto prepareChild( [[maybe_unused]] VecN<3, float_v> const& vertex_position,
[[maybe_unused]] mask_v const& vertex_position_mask, [[maybe_unused]] ChildType type,
child_t const& child ) {
assert( type == ChildType::TrackWithoutVelo );
using VertexTrack =
VertexTraj<child_t,
ChildType::TrackWithoutVelo /* flag this represents a track not a weakly-decaying composite */>;
return VertexTrack{child, child.state( child_t::StateLocation::ClosestToBeam )};
}
};
......@@ -516,7 +567,33 @@ namespace Sel::Fitters {
}
};
/** Helper type for the default `Other` case.
/** Helper type for the default `Neutral` case.
*/
template <typename child_t>
struct NeutralChildHelper {
/** This helper just tries generic logic, it should be tried last and it
* accepts everything. If it doesn't work, a compile error is the
* correct outcome.
*/
constexpr static bool value = Sel::Utils::has_neutrals_API<child_t>;
/** Catch-all, don't expect other logic here.
*/
static ChildType deriveType( LHCb::IParticlePropertySvc const&, child_t const& ) { return ChildType::Neutral; }
/** @todo Need to implement the helper class that handles generic
* children and return an instance of it. As a 1-member variant.
*/
template <typename mask_v, typename float_v>
static auto prepareChild( [[maybe_unused]] VecN<3, float_v> const& vertex_position,
[[maybe_unused]] mask_v const& vertex_position_mask, [[maybe_unused]] ChildType type,
child_t const& child ) {
assert( type == ChildType::Neutral );
using VertexNeutral =
VertexTraj<child_t, ChildType::Neutral /* flag this represents a track not a weakly-decaying composite */>;
return VertexNeutral{child, stateVectorFromNeutral( child )};
}
};
/** Helper type for the default `Neutral` case.
*/
template <typename child_t>
struct LeftoverHelper {
......@@ -527,7 +604,7 @@ namespace Sel::Fitters {
constexpr static bool value = true;
/** Catch-all, don't expect other logic here.
*/
static ChildType deriveType( LHCb::IParticlePropertySvc const&, child_t const& ) { return ChildType::Other; }
static ChildType deriveType( LHCb::IParticlePropertySvc const&, child_t const& ) { return ChildType::Neutral; }
/** @todo Need to implement the helper class that handles generic
* children and return an instance of it. As a 1-member variant.
*/
......@@ -536,9 +613,7 @@ namespace Sel::Fitters {
[[maybe_unused]] mask_v const& vertex_position_mask, [[maybe_unused]] ChildType type,
child_t const& child ) {
assert( type == ChildType::Other );
using VertexOther =
VertexTraj<child_t, ChildType::Other /* flag this represents a track not a weakly-decaying composite */>;
return VertexOther{child, stateVectorFromOther( child )};
return bool{};
}
};
......@@ -547,7 +622,8 @@ namespace Sel::Fitters {
*/
template <typename child_t>
using all_helper_types =
boost::mp11::mp_list<TrackChildHelper<child_t>, CompositeChildHelper<child_t>, LeftoverHelper<child_t>>;
boost::mp11::mp_list<TrackWithVeloChildHelper<child_t>, TrackWithoutVeloChildHelper<child_t>,
NeutralChildHelper<child_t>, CompositeChildHelper<child_t>, LeftoverHelper<child_t>>;
/** Helper types that match (::value == true) for a given child type.
*/
......@@ -714,7 +790,7 @@ namespace Sel::Fitters {
oss << "Could not initialise Sel::Fitters::ParticleVertex: #TrackWithVelo = "
<< count( ChildType::TrackWithVelo ) << ", #TrackWithoutVelo = " << count( ChildType::TrackWithoutVelo )
<< ", #Composite = " << count( ChildType::Composite ) << ", #Resonance = " << count( ChildType::Resonance )
<< ", #Other = " << count( ChildType::Other );
<< ", #Neutral = " << count( ChildType::Neutral ) << ", #Other = " << count( ChildType::Other );
throw exception( oss.str() );
}
}
......@@ -750,7 +826,8 @@ namespace Sel::Fitters {
// - TrackWithoutVelo: tracks without velo hits (only downstream, hopefully)
// - Resonance: composites with ctau < 1micron
// - Composite: other composites
// - Other: everything else, e.g. photons, pi0, jets
// - Neutral: neutral objects, e.g. photons, pi0
// - Other: everything else, e.g. jets
// Not all of these classifications can be made at compile time based on
// the template pack `child_ts...`. If the input children are themselves
// variants then `deriveType` is used as a visitor, increasing the amount
......@@ -773,7 +850,7 @@ namespace Sel::Fitters {
// Now estimate everything that goes into the vertex, this array will be
// filled with variants; the different variant types encode the different
// handling required for TrackWith[out]Velo/Composite/Resonance/Other.
// handling required for TrackWith[out]Velo/Composite/Resonance/Neutral/Other.
std::tuple extrapolated_children{
prepareChild( vertex_position, prelim_fit_mask, types[IChild], children.template get<IChild>() )...};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment