The Gaudi Framework
master (934d2c3c)
Toggle main menu visibility
Loading...
Searching...
No Matches
TrackingAlg.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
12
// Local includes
13
#include "
Hit.h
"
14
#include "
Track.h
"
15
16
// Framework includes
17
#include <
Gaudi/Accumulators.h
>
18
#include <
Gaudi/Functional/Transformer.h
>
19
20
// STD includes
21
#include <
cmath
>
22
#include <
numbers
>
23
#include <
vector
>
24
25
namespace
Gaudi::Example::TinyExperiment
{
26
30
class
TrackingAlg
:
public
Functional::Transformer<Tracks( Hits const& )> {
31
public
:
32
TrackingAlg
(
const
std::string& name,
ISvcLocator
* pSvcLocator )
33
: Transformer( name, pSvcLocator, { {
"HitsLocation"
,
"/Event/Hits"
} },
34
{
"TracksLocation"
,
"/Event/Tracks"
} ) {}
35
36
Tracks
operator()
(
Hits
const
& hits )
const override
{
37
// hough transform, actually only computing theta, and not dealing properly with borders of bins
38
std::vector<unsigned int>
bins(
m_nBins
, 0 );
39
for
(
auto
const
& hit : hits ) {
40
auto
theta = std::atan( hit.y / hit.x );
41
auto
index =
static_cast<
unsigned
int
>
( ( theta + std::numbers::pi_v<float> / 2 ) / std::numbers::pi_v<float> *
42
m_nBins
);
43
++bins.
at
( index );
44
}
45
// extract tracks
46
Tracks
tracks;
47
tracks.
reserve
( hits.
size
() / 10 );
48
for
(
unsigned
int
n = 0; n <
m_nBins
; n++ ) {
49
if
( bins[n] >=
m_sensibility
) {
50
tracks.emplace_back( -std::numbers::pi_v<float> / 2 +
51
( std::numbers::pi_v<float> * ( n + 0.5f ) ) /
m_nBins
);
52
++
n_tracks
;
53
}
54
}
55
return
tracks;
56
}
57
58
private
:
59
Gaudi::Property<unsigned int>
m_nBins
{
this
,
"NumberBins"
, 180,
"Number of bins in the Hough Transform for theta"
};
60
Gaudi::Property<unsigned int>
m_sensibility
{
this
,
"Sensibility"
, 6,
61
"How many hits do we want for considering we have a track ?"
};
62
mutable
Gaudi::Accumulators::Counter<>
n_tracks
{
this
,
"Number of Tracks"
};
63
};
64
65
DECLARE_COMPONENT
( TrackingAlg )
66
67
}
// namespace Gaudi::Example::TinyExperiment
Accumulators.h
Hit.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
Track.h
Transformer.h
numbers
vector
cmath
std::vector
std::vector::reserve
constexpr void reserve(size_type __n)
std::vector::at
constexpr reference at(size_type __n)
std::vector::size
constexpr size_type size() const noexcept
Gaudi::Example::TinyExperiment::TrackingAlg::m_sensibility
Gaudi::Property< unsigned int > m_sensibility
Definition
TrackingAlg.cpp:60
Gaudi::Example::TinyExperiment::TrackingAlg::n_tracks
Gaudi::Accumulators::Counter n_tracks
Definition
TrackingAlg.cpp:62
Gaudi::Example::TinyExperiment::TrackingAlg::TrackingAlg
TrackingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TrackingAlg.cpp:32
Gaudi::Example::TinyExperiment::TrackingAlg::m_nBins
Gaudi::Property< unsigned int > m_nBins
Definition
TrackingAlg.cpp:59
Gaudi::Example::TinyExperiment::TrackingAlg::operator()
Tracks operator()(Hits const &hits) const override
Definition
TrackingAlg.cpp:36
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::Tracks
std::vector< Track > Tracks
Definition
Track.h:26
Gaudi::Example::TinyExperiment::Hits
std::vector< Hit > Hits
Definition
Hit.h:24
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition
Accumulators.h:935
GaudiExamples
TinyExperiment
src
TrackingAlg.cpp
Generated on
for The Gaudi Framework by
1.18.0