ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimHoughTransform_d0phi0_Tool.h
Go to the documentation of this file.
1// Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3#ifndef FPGATrackSimHOUGHTRANSFORM_D0PHI0_TOOL_H
4#define FPGATrackSimHOUGHTRANSFORM_D0PHI0_TOOL_H
5
13
14#include "GaudiKernel/ServiceHandle.h"
16
25
26#include "TFile.h"
27
28#include <string>
29#include <vector>
30#include <utility>
31#include <unordered_set>
32
35
36
37class FPGATrackSimHoughTransform_d0phi0_Tool : public extends <AthAlgTool, IFPGATrackSimRoadFinderTool>
38{
39 public:
40
42 // AthAlgTool
43
44 FPGATrackSimHoughTransform_d0phi0_Tool(const std::string&, const std::string&, const IInterface*);
45
46 virtual StatusCode initialize() override;
47 virtual StatusCode finalize() override;
48
50 // IFPGATrackSimRoadFinderTool
51
52 virtual StatusCode getRoads(const std::vector<std::shared_ptr<const FPGATrackSimHit>> & hits, std::vector<std::shared_ptr<const FPGATrackSimRoad>> & roads) override;
53 virtual int getSubRegion() const override{return m_subRegion;}
54
55 private:
56
58 // Handles
59
60 ServiceHandle<IFPGATrackSimBankSvc> m_FPGATrackSimBankSvc {this, "FPGATrackSimBankSvc", "FPGATrackSimBankSvc"};
61 ServiceHandle<IFPGATrackSimMappingSvc> m_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc", "FPGATrackSimMappingSvc"};
62
63
65 // Properties
66
67 Gaudi::Property <int> m_subRegion { this, "subRegion", 0," -1 for entire region (no slicing)"};
68 Gaudi::Property <float> m_tempMin_phi { this, "phi_min", 0, "min phi"};
69 Gaudi::Property <float> m_tempMax_phi { this, "phi_max", 1, "max phi"};
70 Gaudi::Property <float> m_tempMin_d0 { this, "d0_min", -1, "min q/pt"};
71 Gaudi::Property <float> m_tempMax_d0 { this, "d0_max", 1, "max q/pt"};
72 Gaudi::Property<std::vector<int> > m_threshold { this, "threshold", {1},"Minimum number of hit layers to fire a road"};
73 Gaudi::Property <unsigned int> m_imageSize_x { this, "nBins_x", 1, ""};
74 Gaudi::Property <unsigned int> m_imageSize_y { this, "nBins_y", 1, ""};
75 Gaudi::Property<std::vector<int> > m_conv { this, "convolution", {}, "Convolution filter, with size m_convSize_y * m_convSize_x"};
76 Gaudi::Property<std::vector<unsigned int> > m_combineLayers { this, "combine_layers", {0,1,2,3,4,5,6,7}, ""};
77 Gaudi::Property<std::vector<unsigned int> > m_binScale { this, "scale", {}, "Vector containing the scales for each layers"};
78 Gaudi::Property <unsigned int> m_convSize_x { this, "convSize_x", 0, ""};
79 Gaudi::Property <unsigned int> m_convSize_y { this, "convSize_y", 0, ""};
80 Gaudi::Property<std::vector<unsigned int> > m_hitExtend_x { this, "hitExtend_x", {}, "Hit lines will fill extra bins in x by this amount on each side, size == nLayers"};
81 Gaudi::Property <bool> m_traceHits { this, "traceHits", true, "Trace each hit that goes in a bin. Disabling this will save memory/time since each bin doesn't have to store all its hits but the roads created won't have hits from convolution, etc."};
82 Gaudi::Property <bool> m_stereo { this, "stereo", false, "Combine stereo layers"};
83 Gaudi::Property <bool> m_localMaxWindowSize { this, "localMaxWindowSize", 0, "Only create roads that are a local maximum within this window size. Set this to 0 to turn off local max filtering"};
84 Gaudi::Property <bool> m_useSectors { this, "useSectors", false, "Will reverse calculate the sector for track-fitting purposes"};
85 Gaudi::Property <bool> m_idealGeoRoads { this, "IdealGeoRoads", false, "Set sectors to use ideal geometry fit constants"};
86
89
90 FPGATrackSimTrackPars m_parMin; // These are the bounds of the image, i.e. the region of interest
91 FPGATrackSimTrackPars m_parMax; // Only the two parameters chosen above are used
92
93 unsigned m_nCombineLayers = 0U; // number of layers after combined
94 std::vector< std::vector<int> > m_combineLayer2D; // 2d array of combined layers i.e. [[1,2,3],[0,4,5],[6,7]] will combine (L1, L2, L3), (L0, L4, L5), (L6, L7)
95
97 // Convenience
98
99 unsigned m_nLayers = 0U; // alias to m_FPGATrackSimMapping->PlaneMap1stStage()->getNLogiLayers();
100
101 double m_step_x = 0; // step size of the bin boundaries in x
102 double m_step_y = 0; // step size of the bin boundaries in y
103 std::vector<double> m_bins_x; // size == m_imageSize_x + 1.
104 std::vector<double> m_bins_y; // size == m_imageSize_y + 1
105 // Bin boundaries, where m_bins_x[i] is the lower bound of bin i.
106 // These are calculated from m_parMin/Max.
107 std::unordered_map<int, std::vector<size_t>> m_yBins_scaled; // saved all scaled binnings
108
110 // An image is a 2d array of points, where each point has a value.
111 // This starts as the number of hits (or hit layers), but will
112 // change after the convolution. Also stored are all hits that
113 // contributed to each bin.
114 // Size m_imageSize_y * m_imageSize_x. (NOTE y is row coordinate)
115
117 // Event Storage
118
119 std::vector<FPGATrackSimRoad> m_roads;
120
122 // Metadata and Monitoring
123
124 int m_event = 0;
125 std::string m_name; // Gets the instance name from the full gaudi name
127
129 // Core
130
131 // std::vector<FPGATrackSimHit const *> filterHits(std::vector<FPGATrackSimHit const *> const & hits) const;
132 Image createLayerImage(std::vector<int> const & combine_layers, const std::vector<std::shared_ptr<const FPGATrackSimHit>> & hits, unsigned const scale) const;
133 Image createImage(const std::vector<std::shared_ptr<const FPGATrackSimHit>> & hits) const;
134 Image convolute(Image const & image) const;
135
137 // Helpers
138
139 double yToX(double y, const std::shared_ptr<const FPGATrackSimHit> & h) const;
140 std::pair<unsigned, unsigned> yToXBins(size_t yBin_min, size_t yBin_max, const std::shared_ptr<const FPGATrackSimHit> & hit) const;
141 bool passThreshold(Image const & image, unsigned x, unsigned y) const;
143 FPGATrackSimRoad createRoad(const std::unordered_set<std::shared_ptr<const FPGATrackSimHit>> & hits, unsigned x, unsigned y) const;
144 FPGATrackSimRoad createRoad(std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> &&hits, layer_bitmask_t hitLayers, unsigned x, unsigned y) const;
145 void addRoad(const std::unordered_set<std::shared_ptr<const FPGATrackSimHit>> & hits, unsigned x, unsigned y);
146 void addRoad(const std::vector<std::shared_ptr<const FPGATrackSimHit>> & hits, unsigned x, unsigned y);
147 int conv(unsigned y, unsigned x) { return m_conv[y * m_convSize_x + x]; } // NOTE: y index is first
148 void drawImage(Image const & image, std::string const & name);
149
150};
151
152
153
154#endif // FPGATrackSimHOUGHTRANSFORM_D0PHI0_TOOL_H
: FPGATrackSim-specific class to represent an hit in the detector.
Defines a class for roads.
Structs that store the 5 track parameters.
uint32_t layer_bitmask_t
Defines several vector wrappers for homogenous multi-dimensional vectors, declared as 1D arrays for l...
Interface declaration for road finder tools.
#define y
#define x
Header file for AthHistogramAlgorithm.
Gaudi::Property< std::vector< unsigned int > > m_combineLayers
ServiceHandle< IFPGATrackSimBankSvc > m_FPGATrackSimBankSvc
bool passThreshold(Image const &image, unsigned x, unsigned y) const
Image createLayerImage(std::vector< int > const &combine_layers, const std::vector< std::shared_ptr< const FPGATrackSimHit > > &hits, unsigned const scale) const
Gaudi::Property< std::vector< unsigned int > > m_binScale
void addRoad(const std::unordered_set< std::shared_ptr< const FPGATrackSimHit > > &hits, unsigned x, unsigned y)
Image createImage(const std::vector< std::shared_ptr< const FPGATrackSimHit > > &hits) const
FPGATrackSimHoughTransform_d0phi0_Tool(const std::string &, const std::string &, const IInterface *)
virtual StatusCode getRoads(const std::vector< std::shared_ptr< const FPGATrackSimHit > > &hits, std::vector< std::shared_ptr< const FPGATrackSimRoad > > &roads) override
FPGATrackSimRoad createRoad(const std::unordered_set< std::shared_ptr< const FPGATrackSimHit > > &hits, unsigned x, unsigned y) const
void drawImage(Image const &image, std::string const &name)
std::pair< unsigned, unsigned > yToXBins(size_t yBin_min, size_t yBin_max, const std::shared_ptr< const FPGATrackSimHit > &hit) const
vector2D< std::pair< int, std::unordered_set< std::shared_ptr< const FPGATrackSimHit > > > > Image
std::unordered_map< int, std::vector< size_t > > m_yBins_scaled
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
double yToX(double y, const std::shared_ptr< const FPGATrackSimHit > &h) const
Gaudi::Property< std::vector< unsigned int > > m_hitExtend_x
int r
Definition globals.cxx:22