Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
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 
37 class 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<unsigned> > 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<unsigned> 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;
142  void matchIdealGeoSector(FPGATrackSimRoad & r) 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
FPGATrackSimHoughTransform_d0phi0_Tool::m_par_x
FPGATrackSimTrackPars::pars_index m_par_x
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:87
beamspotman.r
def r
Definition: beamspotman.py:676
FPGATrackSimTrackPars::ID0
@ ID0
Definition: FPGATrackSimTrackPars.h:49
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FPGATrackSimHoughTransform_d0phi0_Tool::m_convSize_y
Gaudi::Property< unsigned int > m_convSize_y
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:79
FPGATrackSimHoughTransform_d0phi0_Tool::m_idealGeoRoads
Gaudi::Property< bool > m_idealGeoRoads
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:85
FPGATrackSimHoughTransform_d0phi0_Tool::m_nLayers
unsigned m_nLayers
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:99
FPGATrackSimTrackPars
Definition: FPGATrackSimTrackPars.h:22
FPGATrackSimHoughTransform_d0phi0_Tool::m_binScale
Gaudi::Property< std::vector< unsigned int > > m_binScale
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:77
FPGATrackSimHoughTransform_d0phi0_Tool::matchIdealGeoSector
void matchIdealGeoSector(FPGATrackSimRoad &r) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:378
IFPGATrackSimMappingSvc.h
FPGATrackSimHoughTransform_d0phi0_Tool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:61
IFPGATrackSimRoadFinderTool.h
Interface declaration for road finder tools.
IFPGATrackSimMappingSvc
Definition: IFPGATrackSimMappingSvc.h:17
FPGATrackSimHoughTransform_d0phi0_Tool::m_imageSize_y
Gaudi::Property< unsigned int > m_imageSize_y
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:74
FPGATrackSimHoughTransform_d0phi0_Tool::Image
vector2D< std::pair< int, std::unordered_set< std::shared_ptr< const FPGATrackSimHit > > > > Image
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:109
FPGATrackSimHoughTransform_d0phi0_Tool::m_tempMin_phi
Gaudi::Property< float > m_tempMin_phi
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:68
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
x
#define x
FPGATrackSimHoughTransform_d0phi0_Tool::m_conv
Gaudi::Property< std::vector< int > > m_conv
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:75
FPGATrackSimHoughTransform_d0phi0_Tool::conv
int conv(unsigned y, unsigned x)
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:147
FPGATrackSimHoughTransform_d0phi0_Tool::m_threshold
Gaudi::Property< std::vector< int > > m_threshold
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:72
FPGATrackSimHoughTransform_d0phi0_Tool::m_stereo
Gaudi::Property< bool > m_stereo
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:82
FPGATrackSimHoughTransform_d0phi0_Tool::addRoad
void addRoad(const std::unordered_set< std::shared_ptr< const FPGATrackSimHit >> &hits, unsigned x, unsigned y)
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:454
FPGATrackSimHoughTransform_d0phi0_Tool::getRoads
virtual StatusCode getRoads(const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits, std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads) override
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:150
FPGATrackSimVectors.h
Defines several vector wrappers for homogenous multi-dimensional vectors, declared as 1D arrays for l...
vector2D
Definition: FPGATrackSimVectors.h:28
FPGATrackSimHoughTransform_d0phi0_Tool::m_step_y
double m_step_y
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:102
FPGATrackSimHoughTransform_d0phi0_Tool::m_parMax
FPGATrackSimTrackPars m_parMax
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:91
FPGATrackSimHoughTransform_d0phi0_Tool::m_traceHits
Gaudi::Property< bool > m_traceHits
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:81
FPGATrackSimHoughTransform_d0phi0_Tool::m_event
int m_event
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:124
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FPGATrackSimHoughTransform_d0phi0_Tool::m_step_x
double m_step_x
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:101
AthAlgTool.h
FPGATrackSimHoughTransform_d0phi0_Tool::FPGATrackSimHoughTransform_d0phi0_Tool
FPGATrackSimHoughTransform_d0phi0_Tool(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:37
FPGATrackSimHoughTransform_d0phi0_Tool::yToXBins
std::pair< unsigned, unsigned > yToXBins(size_t yBin_min, size_t yBin_max, const std::shared_ptr< const FPGATrackSimHit > &hit) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:354
FPGATrackSimHoughTransform_d0phi0_Tool::createRoad
FPGATrackSimRoad createRoad(const std::unordered_set< std::shared_ptr< const FPGATrackSimHit >> &hits, unsigned x, unsigned y) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:411
FPGATrackSimHoughTransform_d0phi0_Tool::createLayerImage
Image createLayerImage(std::vector< unsigned > const &combine_layers, const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits, unsigned const scale) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:179
FPGATrackSimHoughTransform_d0phi0_Tool::m_tempMax_phi
Gaudi::Property< float > m_tempMax_phi
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:69
FPGATrackSimHoughTransform_d0phi0_Tool::m_convSize_x
Gaudi::Property< unsigned int > m_convSize_x
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:78
FPGATrackSimHoughTransform_d0phi0_Tool::convolute
Image convolute(Image const &image) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:247
FPGATrackSimHoughTransform_d0phi0_Tool::drawImage
void drawImage(Image const &image, std::string const &name)
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:506
FPGATrackSimHoughTransform_d0phi0_Tool::m_tempMax_d0
Gaudi::Property< float > m_tempMax_d0
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:71
FPGATrackSimHoughTransform_d0phi0_Tool
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:38
FPGATrackSimHoughTransform_d0phi0_Tool::getSubRegion
virtual int getSubRegion() const override
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:53
FPGATrackSimHoughTransform_d0phi0_Tool::finalize
virtual StatusCode finalize() override
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:140
FPGATrackSimHoughTransform_d0phi0_Tool::m_monitorFile
TFile m_monitorFile
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:126
FPGATrackSimHoughTransform_d0phi0_Tool::m_bins_y
std::vector< double > m_bins_y
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:104
FPGATrackSimHoughTransform_d0phi0_Tool::m_parMin
FPGATrackSimTrackPars m_parMin
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:90
FPGATrackSimHoughTransform_d0phi0_Tool::m_useSectors
Gaudi::Property< bool > m_useSectors
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:84
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
FPGATrackSimTrackPars::pars_index
pars_index
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
FPGATrackSimHoughTransform_d0phi0_Tool::m_bins_x
std::vector< double > m_bins_x
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:103
MyPlots.image
string image
Definition: MyPlots.py:43
FPGATrackSimHoughTransform_d0phi0_Tool::m_combineLayers
Gaudi::Property< std::vector< unsigned int > > m_combineLayers
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:76
FPGATrackSimTrackPars::IPHI
@ IPHI
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimHoughTransform_d0phi0_Tool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:46
y
#define y
h
layer_bitmask_t
uint32_t layer_bitmask_t
Definition: FPGATrackSimTypes.h:22
IFPGATrackSimBankSvc.h
FPGATrackSimHoughTransform_d0phi0_Tool::yToX
double yToX(double y, const std::shared_ptr< const FPGATrackSimHit > &h) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:336
FPGATrackSimHoughTransform_d0phi0_Tool::m_hitExtend_x
Gaudi::Property< std::vector< unsigned int > > m_hitExtend_x
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:80
FPGATrackSimHoughTransform_d0phi0_Tool::m_imageSize_x
Gaudi::Property< unsigned int > m_imageSize_x
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:73
FPGATrackSimHoughTransform_d0phi0_Tool::m_FPGATrackSimBankSvc
ServiceHandle< IFPGATrackSimBankSvc > m_FPGATrackSimBankSvc
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:60
FPGATrackSimHoughTransform_d0phi0_Tool::m_name
std::string m_name
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:125
FPGATrackSimHoughTransform_d0phi0_Tool::m_roads
std::vector< FPGATrackSimRoad > m_roads
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:119
FPGATrackSimHoughTransform_d0phi0_Tool::m_nCombineLayers
unsigned m_nCombineLayers
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:93
FPGATrackSimHoughTransform_d0phi0_Tool::m_tempMin_d0
Gaudi::Property< float > m_tempMin_d0
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:70
FPGATrackSimRoad.h
Defines a class for roads.
FPGATrackSimHoughTransform_d0phi0_Tool::m_combineLayer2D
std::vector< std::vector< unsigned > > m_combineLayer2D
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:94
FPGATrackSimHoughTransform_d0phi0_Tool::m_yBins_scaled
std::unordered_map< int, std::vector< size_t > > m_yBins_scaled
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:107
FPGATrackSimHoughTransform_d0phi0_Tool::m_par_y
FPGATrackSimTrackPars::pars_index m_par_y
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:88
FPGATrackSimHoughTransform_d0phi0_Tool::m_localMaxWindowSize
Gaudi::Property< bool > m_localMaxWindowSize
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:83
IFPGATrackSimBankSvc
Definition: IFPGATrackSimBankSvc.h:21
FPGATrackSimHoughTransform_d0phi0_Tool::createImage
Image createImage(const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:227
FPGATrackSimTypes.h
FPGATrackSimHoughTransform_d0phi0_Tool::passThreshold
bool passThreshold(Image const &image, unsigned x, unsigned y) const
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.cxx:273
FPGATrackSimTrackPars.h
Structs that store the 5 track parameters.
FPGATrackSimRoad
Definition: FPGATrackSimRoad.h:31
ServiceHandle< IFPGATrackSimBankSvc >
FPGATrackSimHoughTransform_d0phi0_Tool::m_subRegion
Gaudi::Property< int > m_subRegion
Definition: FPGATrackSimHoughTransform_d0phi0_Tool.h:67