The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
CheckerAlg.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 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
12#include "MCTrack.h"
13#include "Track.h"
14
15#include <Gaudi/Accumulators.h>
17
18#include <climits>
19
21
25 class CheckerAlg : public Functional::Consumer<void( MCTracks const&, Tracks const& )> {
26 public:
27 CheckerAlg( const std::string& name, ISvcLocator* pSvcLocator )
28 : Consumer(
29 name, pSvcLocator,
30 { KeyValue{ "MCTracksLocation", "/Event/MCTracks" }, KeyValue{ "TracksLocation", "/Event/Tracks" } } ) {}
31
32 void operator()( MCTracks const& mcTracks, Tracks const& tracks ) const override {
33 for ( auto const& track : tracks ) {
34 MCTracks selection;
35 selection.reserve( 10 );
36 std::copy_if( mcTracks.begin(), mcTracks.end(), std::back_inserter( selection ),
37 [track, this]( MCTrack mcTrack ) { return almostEqual( track.theta, mcTrack.theta ); } );
38 if ( selection.size() == 0 ) {
40 } else {
42 }
43 }
44 for ( auto const& mcTrack : mcTracks ) {
45 Tracks selection;
46 selection.reserve( 10 );
47 std::copy_if( tracks.begin(), tracks.end(), std::back_inserter( selection ),
48 [mcTrack, this]( Track track ) { return almostEqual( track.theta, mcTrack.theta ); } );
49 if ( selection.size() == 0 ) {
51 } else if ( selection.size() > 1 ) {
53 }
54 }
55 }
56
57 private:
58 bool almostEqual( float a, float b ) const { return std::abs( a - b ) <= m_maxDeltaTheta; }
59
60 Gaudi::Property<float> m_maxDeltaTheta{ this, "DeltaThetaMax", 0.001,
61 "(Relative) maximum delta theta to consider 2 tracks as identical" };
62 mutable Gaudi::Accumulators::Counter<> n_foundTracks{ this, "Number of Tracks properly reconstructed" };
63 mutable Gaudi::Accumulators::Counter<> n_ghostTracks{ this, "Number of ghost Tracks" };
64 mutable Gaudi::Accumulators::Counter<> n_duplicatedTracks{ this, "Number of Tracks reconstructed twice" };
65 mutable Gaudi::Accumulators::Counter<> n_lostTracks{ this, "Number of Tracks missing after reconstruction" };
66 };
67
68 DECLARE_COMPONENT( CheckerAlg )
69
70} // namespace Gaudi::Example::TinyExperiment
#define DECLARE_COMPONENT(type)
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 PropertyFwd.h:27
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:28
std::vector< Track > Tracks
Definition Track.h:28
details::Consumer< Signature, Traits_, details::isLegacy< Traits_ > > Consumer
Definition Consumer.h:69
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition ParticleID.h:191
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:21