The Gaudi Framework
master (53dee381)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
Accumulators.h
Hit.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
Track.h
Transformer.h
Gaudi::Example::TinyExperiment::TrackingAlg::m_sensibility
Gaudi::Property< unsigned int > m_sensibility
Definition
TrackingAlg.cpp:55
Gaudi::Example::TinyExperiment::TrackingAlg::n_tracks
Gaudi::Accumulators::Counter n_tracks
Definition
TrackingAlg.cpp:57
Gaudi::Example::TinyExperiment::TrackingAlg::TrackingAlg
TrackingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TrackingAlg.cpp:28
Gaudi::Example::TinyExperiment::TrackingAlg::m_nBins
Gaudi::Property< unsigned int > m_nBins
Definition
TrackingAlg.cpp:54
Gaudi::Example::TinyExperiment::TrackingAlg::operator()
Tracks operator()(Hits const &hits) const override
Definition
TrackingAlg.cpp:32
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::Tracks
std::vector< Track > Tracks
Definition
Track.h:28
Gaudi::Example::TinyExperiment::Hits
std::vector< Hit > Hits
Definition
Hit.h:27
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition
Accumulators.h:962
GaudiExamples
TinyExperiment
src
TrackingAlg.cpp
Generated on
for The Gaudi Framework by
1.17.0