The Gaudi Framework master (934d2c3c)
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>
19
20// STD includes
21#include <cmath>
22#include <numbers>
23#include <vector>
24
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
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" };
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
#define DECLARE_COMPONENT(type)
constexpr void reserve(size_type __n)
constexpr reference at(size_type __n)
constexpr size_type size() const noexcept
Gaudi::Property< unsigned int > m_sensibility
Gaudi::Accumulators::Counter n_tracks
TrackingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< unsigned int > m_nBins
Tracks operator()(Hits const &hits) const override
Implementation of property with value of concrete type.
Definition Property.h:35
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
std::vector< Track > Tracks
Definition Track.h:26
std::vector< Hit > Hits
Definition Hit.h:24
A basic integral counter;.