The Gaudi Framework master (934d2c3c)
Loading...
Searching...
No Matches
CheckerAlg.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11// Local includes
12#include "MCTrack.h"
13#include "Track.h"
14
15// Framework includes
16#include <Gaudi/Accumulators.h>
18
19// STL includes
20#include <algorithm>
21#include <cmath>
22#include <string>
23
25
29 class CheckerAlg : public Functional::Consumer<void( MCTracks const&, Tracks const& )> {
30 public:
31 CheckerAlg( const std::string& name, ISvcLocator* pSvcLocator )
32 : Consumer(
33 name, pSvcLocator,
34 { KeyValue{ "MCTracksLocation", "/Event/MCTracks" }, KeyValue{ "TracksLocation", "/Event/Tracks" } } ) {}
35
36 void operator()( MCTracks const& mcTracks, Tracks const& tracks ) const override {
37 for ( auto const& track : tracks ) {
38 bool found =
39 std::ranges::any_of( mcTracks, [&]( MCTrack const& mc ) { return almostEqual( track.theta, mc.theta ); } );
40 if ( found ) {
42 } else {
44 }
45 }
46 for ( auto const& mc : mcTracks ) {
47 auto n = std::ranges::count_if( tracks, [&]( Track const& t ) { return almostEqual( t.theta, mc.theta ); } );
48 if ( n == 0 ) {
50 } else if ( n > 1 ) {
52 }
53 }
54 }
55
56 private:
57 bool almostEqual( float a, float b ) const { return std::abs( a - b ) <= m_maxDeltaTheta; }
58
59 Gaudi::Property<float> m_maxDeltaTheta{ this, "DeltaThetaMax", 0.001,
60 "(Relative) maximum delta theta to consider 2 tracks as identical" };
61 mutable Gaudi::Accumulators::Counter<> n_foundTracks{ this, "Number of Tracks properly reconstructed" };
62 mutable Gaudi::Accumulators::Counter<> n_ghostTracks{ this, "Number of ghost Tracks" };
63 mutable Gaudi::Accumulators::Counter<> n_duplicatedTracks{ this, "Number of Tracks reconstructed twice" };
64 mutable Gaudi::Accumulators::Counter<> n_lostTracks{ this, "Number of Tracks missing after reconstruction" };
65 };
66
67 DECLARE_COMPONENT( CheckerAlg )
68
69} // namespace Gaudi::Example::TinyExperiment
#define DECLARE_COMPONENT(type)
_Tp abs(const complex< _Tp > &)
void operator()(MCTracks const &mcTracks, Tracks const &tracks) const override
CheckerAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Accumulators::Counter n_duplicatedTracks
bool almostEqual(float a, float b) const
Gaudi::Accumulators::Counter n_lostTracks
Gaudi::Accumulators::Counter n_foundTracks
Gaudi::Accumulators::Counter n_ghostTracks
Gaudi::Property< float > m_maxDeltaTheta
Implementation of property with value of concrete type.
Definition Property.h:35
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
std::vector< MCTrack > MCTracks
Definition MCTrack.h:25
std::vector< Track > Tracks
Definition Track.h:26
details::Consumer< Signature, Traits_, details::isLegacy< Traits_ > > Consumer
Definition Consumer.h:47
A basic integral counter;.
most simple MC Track ever : in 2D space, starting from the origin and thus fully defined by an angle ...
Definition MCTrack.h:21
most simple Track ever : in 2D space, starting from the origin and thus fully defined by an angle the...
Definition Track.h:22