The Gaudi Framework
master (2bc036a5)
Toggle main menu visibility
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
>
16
#include <
Gaudi/Functional/Consumer.h
>
17
18
#include <climits>
19
20
namespace
Gaudi::Example::TinyExperiment
{
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 ) {
39
++
n_ghostTracks
;
40
}
else
{
41
++
n_foundTracks
;
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 ) {
50
++
n_lostTracks
;
51
}
else
if
( selection.size() > 1 ) {
52
++
n_duplicatedTracks
;
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
Accumulators.h
Consumer.h
MCTrack.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
Track.h
Gaudi::Example::TinyExperiment::CheckerAlg::operator()
void operator()(MCTracks const &mcTracks, Tracks const &tracks) const override
Definition
CheckerAlg.cpp:32
Gaudi::Example::TinyExperiment::CheckerAlg::CheckerAlg
CheckerAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CheckerAlg.cpp:27
Gaudi::Example::TinyExperiment::CheckerAlg::n_duplicatedTracks
Gaudi::Accumulators::Counter n_duplicatedTracks
Definition
CheckerAlg.cpp:64
Gaudi::Example::TinyExperiment::CheckerAlg::almostEqual
bool almostEqual(float a, float b) const
Definition
CheckerAlg.cpp:58
Gaudi::Example::TinyExperiment::CheckerAlg::n_lostTracks
Gaudi::Accumulators::Counter n_lostTracks
Definition
CheckerAlg.cpp:65
Gaudi::Example::TinyExperiment::CheckerAlg::n_foundTracks
Gaudi::Accumulators::Counter n_foundTracks
Definition
CheckerAlg.cpp:62
Gaudi::Example::TinyExperiment::CheckerAlg::n_ghostTracks
Gaudi::Accumulators::Counter n_ghostTracks
Definition
CheckerAlg.cpp:63
Gaudi::Example::TinyExperiment::CheckerAlg::m_maxDeltaTheta
Gaudi::Property< float > m_maxDeltaTheta
Definition
CheckerAlg.cpp:60
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:20
Gaudi::Example::TinyExperiment::MCTracks
std::vector< MCTrack > MCTracks
Definition
MCTrack.h:28
Gaudi::Example::TinyExperiment::Tracks
std::vector< Track > Tracks
Definition
Track.h:28
Gaudi::Functional::Consumer
details::Consumer< Signature, Traits_, details::isLegacy< Traits_ > > Consumer
Definition
Consumer.h:47
std::abs
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition
ParticleID.h:191
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition
Accumulators.h:962
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::Track
most simple Track ever : in 2D space, starting from the origin and thus fully defined by an angle the...
Definition
Track.h:21
GaudiExamples
TinyExperiment
src
CheckerAlg.cpp
Generated on
for The Gaudi Framework by
1.17.0