The Gaudi Framework
master (37c0b60a)
TrackingAlg.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 "
Hit.h
"
13
#include "
Track.h
"
14
15
#include <
Gaudi/Accumulators.h
>
16
#include <
Gaudi/Functional/Transformer.h
>
17
18
#include <cmath>
19
#include <vector>
20
21
namespace
Gaudi::Example::TinyExperiment
{
22
26
class
TrackingAlg
:
public
Functional::Transformer
<Tracks( Hits const& )> {
27
public
:
28
TrackingAlg
(
const
std::string
&
name
,
ISvcLocator
* pSvcLocator )
29
:
Transformer
(
name
, pSvcLocator, { {
"HitsLocation"
,
"/Event/Hits"
} },
30
{
"TracksLocation"
,
"/Event/Tracks"
} ) {}
31
32
Tracks
operator()
(
Hits
const
& hits )
const override
{
33
// hough transform, actually only computing theta, and not dealing properly with borders of bins
34
std::vector<unsigned int>
bins(
m_nBins
, 0 );
35
for
(
auto
const
& hit : hits ) {
36
auto
theta =
std::atan
( hit.y / hit.x );
37
auto
index
=
static_cast<
unsigned
int
>
( ( theta + M_PI / 2 ) / M_PI *
m_nBins
);
38
++bins.
at
(
index
);
39
}
40
// extract tracks
41
Tracks
tracks;
42
tracks.
reserve
( hits.size() / 10 );
43
for
(
unsigned
int
n
= 0;
n
<
m_nBins
;
n
++ ) {
44
if
( bins[
n
] > 0 ) {}
45
if
( bins[
n
] >=
m_sensibility
) {
46
tracks.
emplace_back
( -M_PI / 2 + ( M_PI * (
n
+ 0.5f ) ) /
m_nBins
);
47
++
n_tracks
;
48
}
49
}
50
return
tracks;
51
};
52
53
private
:
54
Gaudi::Property<unsigned int>
m_nBins
{
this
,
"NumberBins"
, 180,
"Number of bins in the Hough Transform for theta"
};
55
Gaudi::Property<unsigned int>
m_sensibility
{
this
,
"Sensibility"
, 6,
56
"How many hits do we want for considering we have a track ?"
};
57
mutable
Gaudi::Accumulators::Counter<>
n_tracks
{
this
,
"Number of Tracks"
};
58
};
59
60
DECLARE_COMPONENT
( TrackingAlg )
61
62
}
// namespace Gaudi::Example::TinyExperiment
Gaudi::Example::TinyExperiment::TrackingAlg::n_tracks
Gaudi::Accumulators::Counter n_tracks
Definition:
TrackingAlg.cpp:57
std::string
STL class.
Gaudi::Example::TinyExperiment::TrackingAlg
Tracking algorithm building tracks from hits using a simplified Hough transform.
Definition:
TrackingAlg.cpp:26
std::vector::reserve
T reserve(T... args)
Gaudi::Accumulators::Counter<>
std::vector
STL class.
ISvcLocator
Definition:
ISvcLocator.h:46
Gaudi::Example::TinyExperiment::TrackingAlg::TrackingAlg
TrackingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
TrackingAlg.cpp:28
std::vector::at
T at(T... args)
std::atan
T atan(T... args)
Transformer.h
cpluginsvc.n
n
Definition:
cpluginsvc.py:234
Gaudi::Example::TinyExperiment::TrackingAlg::m_sensibility
Gaudi::Property< unsigned int > m_sensibility
Definition:
TrackingAlg.cpp:55
Gaudi::Example::TinyExperiment::TrackingAlg::operator()
Tracks operator()(Hits const &hits) const override
Definition:
TrackingAlg.cpp:32
Hit.h
Accumulators.h
std::vector::emplace_back
T emplace_back(T... args)
ConditionsStallTest.name
name
Definition:
ConditionsStallTest.py:77
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition:
PluginServiceV1.h:46
Gaudi::Example::TinyExperiment
Definition:
CheckerAlg.cpp:20
Gaudi ::Functional::Transformer
details::Transformer< Signature, Traits_, details::isLegacy< Traits_ > > Transformer
Definition:
Transformer.h:237
Track.h
Gaudi::Example::TinyExperiment::TrackingAlg::m_nBins
Gaudi::Property< unsigned int > m_nBins
Definition:
TrackingAlg.cpp:54
Gaudi::Property< unsigned int >
Gaudi::ParticleProperties::index
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
Definition:
IParticlePropertySvc.cpp:39
GaudiExamples
TinyExperiment
src
TrackingAlg.cpp
Generated on Thu Dec 19 2024 15:34:58 for The Gaudi Framework by
1.8.18