Skip to content
Snippets Groups Projects

Simplify Measurement & Projectors

Merged Gerhard Raven requested to merge simplify-measurement-projectors into master
All threads resolved!
6 files
+ 38
107
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -8,16 +8,10 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#pragma once
// Include files
#include "Event/TrackTypes.h"
#include "Kernel/BrokenLineTrajectory.h"
#include "Kernel/CircleTraj.h"
#include "Kernel/LHCbID.h"
#include "Kernel/LineTraj.h"
#include "Kernel/PolymorphicValue.h"
#include "Kernel/STLExtensions.h"
#include "Kernel/Trajectory.h"
#include "Kernel/meta_enum.h"
@@ -88,31 +82,23 @@ namespace LHCb {
class Measurement final {
public:
struct FT {
LHCb::LineTraj<double> trajectory;
const DeFTMat* mat = nullptr;
const DeFTMat* mat = nullptr;
};
struct Muon {
LHCb::LineTraj<double> trajectory;
const DeMuonChamber* chamber = nullptr;
const DeMuonChamber* chamber = nullptr;
};
struct UT {
LHCb::LineTraj<double> trajectory;
const DeUTSector* sector = nullptr;
const DeUTSector* sector = nullptr;
};
struct VP {
/// x or y measurement
enum class Projection { X = 1, Y = 2 };
LHCb::LineTraj<double> trajectory;
const DeVPSensor* sensor = nullptr;
Projection projection() const {
return details::Measurement::isX( trajectory.direction( 0 ) )
? VP::Projection::Y // measurement is perpendicular to direction
const DeVPSensor* sensor = nullptr;
bool isX;
Projection projection() const {
return isX ? VP::Projection::Y // measurement is perpendicular to direction
: VP::Projection::X;
}
#if defined( __GNUC__ ) && __GNUC__ < 8
VP() noexcept {} // first element in variant, make default constructible..
VP( LHCb::LineTraj<double> traj, const DeVPSensor* s ) noexcept : trajectory{std::move( traj )}, sensor( s ) {}
#endif
};
private:
@@ -121,31 +107,36 @@ namespace LHCb {
// to 'elsewhere' into the variant instead.
using SubInfo = std::variant<VP, UT, FT, Muon>;
double m_z; ///< the z-position of the measurement
double m_errMeasure; ///< the measurement error
LHCbID m_lhcbID; ///< the corresponding LHCbID
SubInfo m_sub; ///< subdetector specific information
double m_z; ///< the z-position of the measurement
double m_errMeasure; ///< the measurement error
LHCbID m_lhcbID; ///< the corresponding LHCbID
LHCb::LineTraj<double> m_trajectory;
SubInfo m_sub; ///< subdetector specific information
template <typename SubI, typename = std::enable_if_t<std::is_convertible_v<SubI, SubInfo>>>
Measurement( LHCbID id, double z, double errMeas, SubI&& subi )
: m_z{z}, m_errMeasure{errMeas}, m_lhcbID{id}, m_sub{std::forward<SubI>( subi )} {}
Measurement( LHCbID id, double z, double errMeas, LHCb::LineTraj<double> traj, SubI&& subi )
: m_z{z}
, m_errMeasure{errMeas}
, m_lhcbID{id}
, m_trajectory{std::move( traj )}
, m_sub{std::forward<SubI>( subi )} {}
public:
/// VP constructor
Measurement( LHCbID id, double z, LHCb::LineTraj<double> traj, double errMeas, const DeVPSensor* elem )
: Measurement{id, z, errMeas, VP{std::move( traj ), elem}} {}
: Measurement{id, z, errMeas, std::move( traj ), VP{elem, details::Measurement::isX( traj.direction( 0 ) )}} {}
/// UT constructor
Measurement( LHCbID id, double z, LHCb::LineTraj<double> traj, double errMeas, const DeUTSector* elem )
: Measurement{id, z, errMeas, UT{std::move( traj ), elem}} {}
: Measurement{id, z, errMeas, std::move( traj ), UT{elem}} {}
/// FT constructor
Measurement( LHCbID id, double z, LHCb::LineTraj<double> traj, double errMeas, const DeFTMat* elem )
: Measurement{id, z, errMeas, FT{std::move( traj ), elem}} {}
: Measurement{id, z, errMeas, std::move( traj ), FT{elem}} {}
/// Muon constructor
Measurement( LHCbID id, double z, LHCb::LineTraj<double> traj, double errMeas, const DeMuonChamber* elem )
: Measurement{id, z, errMeas, Muon{std::move( traj ), elem}} {}
: Measurement{id, z, errMeas, std::move( traj ), Muon{elem}} {}
// Observers
@@ -157,7 +148,9 @@ namespace LHCb {
/// Get the sub-detector specific information
template <typename SubI>
const SubI* getIf() const;
const SubI* getIf() const {
return std::get_if<SubI>( &m_sub );
}
/// Check whether this Measurements 'is-a' specific 'sub' measurement
template <typename SubI>
@@ -167,7 +160,7 @@ namespace LHCb {
/// Retrieve the measurement error
double resolution( const Gaudi::XYZPoint& /*point*/, const Gaudi::XYZVector& /*vec*/ ) const {
return visit( [&]( const auto& ) { return errMeasure(); } );
return errMeasure();
}
/// Retrieve the measurement error squared
@@ -177,9 +170,7 @@ namespace LHCb {
}
/// Retrieve the trajectory representing the measurement
Trajectory<double> const& trajectory() const {
return visit( []( const auto& sub ) -> Trajectory<double> const& { return sub.trajectory; } );
}
LHCb::LineTraj<double> const& trajectory() const { return m_trajectory; }
/// Retrieve const the corresponding LHCbID
LHCbID lhcbID() const { return m_lhcbID; }
@@ -227,20 +218,10 @@ namespace LHCb {
/// Modifiers
template <typename SubI>
SubI* getIf();
SubI* getIf() {
return std::get_if<SubI>( &m_sub );
}
}; //< class Measurement
/// implementation of templated member functions requiring specialization
template <typename SubI>
inline const SubI* Measurement::getIf() const {
return std::get_if<SubI>( &m_sub );
}
template <typename SubI>
inline SubI* Measurement::getIf() {
return std::get_if<SubI>( &m_sub );
}
} // namespace LHCb
Loading