ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimKeyLayerBinDesc.h
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#ifndef FPGATrackSimKeyLayerBinDesc_H
4#define FPGATrackSimKeyLayerBinDesc_H
5
25
31
32
34
35#include <cmath>
36#include <initializer_list>
37#include <string>
38#include <vector>
39
41
42class FPGATrackSimKeyLayerBinDesc : public extends<AthAlgTool, IFPGATrackSimBinDesc> {
43
44public:
46 using base_class::base_class;
47
48 virtual StatusCode initialize() override;
49
50 virtual const std::string &parNames(unsigned i) const override { return m_parNames[i]; }
51
52 // convert back and forth from pT, eta, phi, d0, z0 and internal paramater set
53 virtual const FPGATrackSimBinUtil::ParSet
54 trackParsToParSet(const FPGATrackSimTrackPars &pars) const override {
55 FPGATrackSimKeyLayerTool::KeyLyrPars keypars = m_keylyrtool.trackParsToKeyPars(pars);
57 keypars.phi1+=fieldCorrection(m_fieldCorRegion, pars.qOverPt/1000.0 ,m_keylyrtool.R1());
58 keypars.phi2+=fieldCorrection(m_fieldCorRegion, pars.qOverPt/1000.0 ,m_keylyrtool.R2());
59 }
60 keypars.phi1=remainder(keypars.phi1+m_phiOffset,2*M_PI);
61 keypars.phi2=remainder(keypars.phi2+m_phiOffset,2*M_PI);
62 return keyparsToParSet(keypars);
63 }
64
65
66
67 virtual const FPGATrackSimTrackPars parSetToTrackPars(const FPGATrackSimBinUtil::ParSet &parset) const override {
69 keypars.phi1=remainder(keypars.phi1-m_phiOffset,2*M_PI);
70 keypars.phi2=remainder(keypars.phi2-m_phiOffset,2*M_PI);
71 return m_keylyrtool.keyParsToTrackPars(keypars);
72 }
73
74 // calculate the distance in phi or eta from a track defined by parset to a
75 // hit these can be implemented as any variable in the r-phi or r-eta plane
76 // (not necessarily eta and phi).
77 virtual double phiResidual(const FPGATrackSimBinUtil::ParSet &parset, FPGATrackSimHit const *hit) const override {
78 return m_keylyrtool.deltaX(parSetToKeyPars(parset), hit->getR(), hit->getGPhi() + m_phiOffset);
79 }
80
81 virtual double etaResidual(const FPGATrackSimBinUtil::ParSet &parset, FPGATrackSimHit const *hit) const override {
82 return hit->getZ()- m_keylyrtool.zExpected(parSetToKeyPars(parset),hit->getR());
83 }
84
85 // figure out if step is r-phi or r-eta plan
86 bool stepIsRPhi(const FPGATrackSimBinStep &step) const;
87 bool stepIsREta(const FPGATrackSimBinStep &step) const;
88
89 // idx should be with the definition specifed in the step
90 // NOTE: the stored hit may be modified!
91 virtual bool hitInBin(const FPGATrackSimBinStep &step, const FPGATrackSimBinUtil::IdxSet &idx,
92 FPGATrackSimBinUtil::StoredHit &storedhit) const override;
93
94
95 // Structs to hold firmware LUTs for one bin
96 // This allows the firmware calculation to be exactly reproduced
97 // here and comapared to the original/main algorithm
98 struct phiLUTConsts {
99 double r_in;
100 double r_out;
101 double y;
102 double x1p;
103 double y1p;
104 double cosb;
105 double sinb;
106 double x_m;
107 double x_factor;
108 double w_x;
109 double w_in;
110 double dw_dr;
111 double phiShift(double phi, double r);
112 double phiWindow(double r);
113 };
115 double r_in;
116 double r_out;
117 double z_in;
118 double dz_dr;
119 double w_in;
120 double dw_dr;
121 double etaShift(double z, double r);
122 double etaWindow(double r);
123 };
124 phiLUTConsts getPhiLUTConsts(const FPGATrackSimBinStep &step, const std::vector<unsigned>& idx) const;
125 etaLUTConsts getEtaLUTConsts(const FPGATrackSimBinStep &step, const std::vector<unsigned>& idx) const;
126
127
128 // Write the relevant LUT tables for firmware
129 virtual void writeLUTs(const FPGATrackSimBinStep &step) const override;
130
131
132 private:
133 // Configurable Properties
134 Gaudi::Property<double> m_rin{this, "rin", {-1.0}, "Radius of inner layer for keylayer definition"};
135 Gaudi::Property<double> m_rout{this, "rout", {-1.0}, "Radius of outer layer for keylayer definition"};
136 Gaudi::Property<bool> m_approxMath{this, "approxMath", {false}, "Use approximate math to emulate possible firmware"};
137 Gaudi::Property<double> m_d0pad{this, "D0Pad", 0.0, "Extra phi padding from d0 resolution"};
138 Gaudi::Property<double> m_phipad{this, "PhiPad", 0.0, "Extra phi padding from phi resolution"};
139 Gaudi::Property<double> m_qptpad{this, "QPtPad", 0.0, "Extra phi padding from q/pT resolution"};
140 Gaudi::Property<double> m_z0pad{this, "Z0Pad", 0.0, "Extra eta padding from z0 resolution"};
141 Gaudi::Property<double> m_etapad{this, "EtaPad", 0.0, "Extra eta padding from eta resolution"};
142 Gaudi::Property<unsigned> m_region{this, "region", 0, "Region number, needed to write out lookup tables for test vectors"};
143 Gaudi::Property<std::vector<double>> m_slPerEtaMod{
144 this,
145 "slPerEtaMod",
146 std::vector<double>{19.0, 24.0, 29.0, 32.0, 18.1, 27.1, 24.1, 15.1, 30.8,
147 30.8, 26.2, 32.2, 32.2, 26.2, 54.6, 54.6, 40.2, 60.2},
148 "Strip length per eta eta mod"
149 };
150
151 Gaudi::Property<double> m_phiOffset{this, "PhiOffset", 0.0, "Phi offset between local and global parameters (avoids phi wrap around effects in region code)"};
152
153 Gaudi::Property<unsigned> m_fieldCorRegion { this, "fieldCorRegion", 2, "region for fieldCorrection"};
154 Gaudi::Property<bool> m_fieldCorrection {this, "fieldCorrection", true, "Use magnetic field correction for Hough transform"};
155
156
157 // convert to/from the KeyLyrPars struct and the ParSet
159 return FPGATrackSimBinUtil::ParSet({keypars.z1,keypars.z2,keypars.phi1,keypars.phi2,keypars.xm});
160 }
164
165 // Internal
167 const std::vector<std::string> m_parNames{"zR1", "zR2", "phiR1", "phiR2", "xm"};
168
169 const std::vector<unsigned> m_phipars{2, 3, 4};
170 const std::vector<unsigned> m_etapars{0, 1};
171
172};
173
174
175#endif // FPGATrackSimKeyLayerBinDesc_H
#define M_PI
Scalar phi() const
phi method
double fieldCorrection(unsigned region, double qoverpt, double r)
: FPGATrackSim-specific class to represent an hit in the detector.
Binning Classes for BinTool.
Structs that store the 5 track parameters.
Defines Parameters used for binning.
#define z
float getGPhi() const
float getZ() const
float getR() const
virtual const FPGATrackSimBinUtil::ParSet trackParsToParSet(const FPGATrackSimTrackPars &pars) const override
virtual StatusCode initialize() override
const std::vector< std::string > m_parNames
Gaudi::Property< unsigned > m_fieldCorRegion
Gaudi::Property< std::vector< double > > m_slPerEtaMod
const std::vector< unsigned > m_phipars
virtual double etaResidual(const FPGATrackSimBinUtil::ParSet &parset, FPGATrackSimHit const *hit) const override
virtual void writeLUTs(const FPGATrackSimBinStep &step) const override
phiLUTConsts getPhiLUTConsts(const FPGATrackSimBinStep &step, const std::vector< unsigned > &idx) const
bool stepIsREta(const FPGATrackSimBinStep &step) const
FPGATrackSimBinUtil::ParSet keyparsToParSet(const FPGATrackSimKeyLayerTool::KeyLyrPars &keypars) const
bool stepIsRPhi(const FPGATrackSimBinStep &step) const
const std::vector< unsigned > m_etapars
virtual double phiResidual(const FPGATrackSimBinUtil::ParSet &parset, FPGATrackSimHit const *hit) const override
FPGATrackSimKeyLayerTool::KeyLyrPars parSetToKeyPars(const FPGATrackSimBinUtil::ParSet &parset) const
etaLUTConsts getEtaLUTConsts(const FPGATrackSimBinStep &step, const std::vector< unsigned > &idx) const
virtual const std::string & parNames(unsigned i) const override
Gaudi::Property< unsigned > m_region
virtual const FPGATrackSimTrackPars parSetToTrackPars(const FPGATrackSimBinUtil::ParSet &parset) const override
virtual bool hitInBin(const FPGATrackSimBinStep &step, const FPGATrackSimBinUtil::IdxSet &idx, FPGATrackSimBinUtil::StoredHit &storedhit) const override
std::vector< std::string > remainder(const std::vector< std::string > &v1, const std::vector< std::string > &v2)
int r
Definition globals.cxx:22