The Gaudi Framework
master (934d2c3c)
Toggle main menu visibility
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
>
17
#include <
Gaudi/Functional/Consumer.h
>
18
19
// STL includes
20
#include <
algorithm
>
21
#include <
cmath
>
22
#include <
string
>
23
24
namespace
Gaudi::Example::TinyExperiment
{
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 ) {
41
++
n_foundTracks
;
42
}
else
{
43
++
n_ghostTracks
;
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 ) {
49
++
n_lostTracks
;
50
}
else
if
( n > 1 ) {
51
++
n_duplicatedTracks
;
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
Accumulators.h
Consumer.h
MCTrack.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
Track.h
algorithm
string
cmath
std::abs
_Tp abs(const complex< _Tp > &)
Gaudi::Example::TinyExperiment::CheckerAlg::operator()
void operator()(MCTracks const &mcTracks, Tracks const &tracks) const override
Definition
CheckerAlg.cpp:36
Gaudi::Example::TinyExperiment::CheckerAlg::CheckerAlg
CheckerAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CheckerAlg.cpp:31
Gaudi::Example::TinyExperiment::CheckerAlg::n_duplicatedTracks
Gaudi::Accumulators::Counter n_duplicatedTracks
Definition
CheckerAlg.cpp:63
Gaudi::Example::TinyExperiment::CheckerAlg::almostEqual
bool almostEqual(float a, float b) const
Definition
CheckerAlg.cpp:57
Gaudi::Example::TinyExperiment::CheckerAlg::n_lostTracks
Gaudi::Accumulators::Counter n_lostTracks
Definition
CheckerAlg.cpp:64
Gaudi::Example::TinyExperiment::CheckerAlg::n_foundTracks
Gaudi::Accumulators::Counter n_foundTracks
Definition
CheckerAlg.cpp:61
Gaudi::Example::TinyExperiment::CheckerAlg::n_ghostTracks
Gaudi::Accumulators::Counter n_ghostTracks
Definition
CheckerAlg.cpp:62
Gaudi::Example::TinyExperiment::CheckerAlg::m_maxDeltaTheta
Gaudi::Property< float > m_maxDeltaTheta
Definition
CheckerAlg.cpp:59
Gaudi::Property
Implementation of property with value of concrete type.
Definition
Property.h:35
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
Gaudi::Example::TinyExperiment
Definition
CheckerAlg.cpp:24
Gaudi::Example::TinyExperiment::MCTracks
std::vector< MCTrack > MCTracks
Definition
MCTrack.h:25
Gaudi::Example::TinyExperiment::Tracks
std::vector< Track > Tracks
Definition
Track.h:26
Gaudi::Functional::Consumer
details::Consumer< Signature, Traits_, details::isLegacy< Traits_ > > Consumer
Definition
Consumer.h:47
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition
Accumulators.h:935
Gaudi::Example::TinyExperiment::MCTrack
most simple MC Track ever : in 2D space, starting from the origin and thus fully defined by an angle ...
Definition
MCTrack.h:21
Gaudi::Example::TinyExperiment::MCTrack::theta
float theta
Definition
MCTrack.h:22
Gaudi::Example::TinyExperiment::Track
most simple Track ever : in 2D space, starting from the origin and thus fully defined by an angle the...
Definition
Track.h:22
GaudiExamples
TinyExperiment
src
CheckerAlg.cpp
Generated on
for The Gaudi Framework by
1.18.0