1 #ifndef L1_TRACK_TRIGGER_TRACK_WORD_H
2 #define L1_TRACK_TRIGGER_TRACK_WORD_H
30 namespace tttrack_trackword {
32 const unsigned int,
const double,
const double,
const unsigned int,
const double,
const unsigned int);
88 static constexpr
double minPhi0 = -0.7853981696;
90 static constexpr
double minZ0 = -20.46912512;
91 static constexpr
double minD0 = -16.;
95 static constexpr
double stepTanL = (1. / (1 << 12));
97 static constexpr
double stepD0 = (1. / (1 << 8));
100 static constexpr std::array<double, 1 << TrackBitWidths::kChi2RPhiSize>
chi2RPhiBins = {
101 {0.0, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 10.0, 15.0, 20.0, 35.0, 60.0, 200.0}};
102 static constexpr std::array<double, 1 << TrackBitWidths::kChi2RZSize>
chi2RZBins = {
103 {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 20.0, 50.0}};
104 static constexpr std::array<double, 1 << TrackBitWidths::kBendChi2Size>
bendChi2Bins = {
105 {0.0, 0.75, 1.0, 1.5, 2.25, 3.5, 5.0, 20.0}};
112 typedef ap_uint<TrackBitWidths::kValidSize>
valid_t;
115 typedef ap_uint<TrackBitWidths::kRinvSize>
rinv_t;
116 typedef ap_uint<TrackBitWidths::kPhiSize>
phi_t;
117 typedef ap_uint<TrackBitWidths::kTanlSize>
tanl_t;
118 typedef ap_uint<TrackBitWidths::kZ0Size>
z0_t;
119 typedef ap_uint<TrackBitWidths::kD0Size>
d0_t;
123 typedef ap_uint<TrackBitWidths::kChi2RZSize>
chi2rz_t;
125 typedef ap_uint<TrackBitWidths::kHitPatternSize>
hit_t;
131 typedef ap_uint<TrackBitWidths::kTrackWordSize>
tkword_t;
143 unsigned int hitPattern,
144 unsigned int mvaQuality,
145 unsigned int mvaOther,
146 unsigned int sector);
153 unsigned int chi2RPhi,
155 unsigned int bendChi2,
156 unsigned int hitPattern,
157 unsigned int mvaQuality,
158 unsigned int mvaOther);
179 return getTrackWord()(TrackBitLocations::kChi2RPhiMSB, TrackBitLocations::kChi2RPhiLSB);
182 return getTrackWord()(TrackBitLocations::kChi2RZMSB, TrackBitLocations::kChi2RZLSB);
185 return getTrackWord()(TrackBitLocations::kBendChi2MSB, TrackBitLocations::kBendChi2LSB);
188 return getTrackWord()(TrackBitLocations::kHitPatternMSB, TrackBitLocations::kHitPatternLSB);
191 return getTrackWord()(TrackBitLocations::kMVAQualityMSB, TrackBitLocations::kMVAQualityLSB);
194 return getTrackWord()(TrackBitLocations::kMVAOtherMSB, TrackBitLocations::kMVAOtherLSB);
237 unsigned int hitPattern,
238 unsigned int mvaQuality,
239 unsigned int mvaOther,
240 unsigned int sector);
248 unsigned int chi2RPhi,
250 unsigned int bendChi2,
251 unsigned int hitPattern,
252 unsigned int mvaQuality,
253 unsigned int mvaOther);
255 void setTrackWord(ap_uint<TrackBitWidths::kValidSize> valid,
256 ap_uint<TrackBitWidths::kRinvSize> rInv,
257 ap_uint<TrackBitWidths::kPhiSize> phi0,
258 ap_uint<TrackBitWidths::kTanlSize> tanl,
259 ap_uint<TrackBitWidths::kZ0Size> z0,
260 ap_uint<TrackBitWidths::kD0Size>
d0,
261 ap_uint<TrackBitWidths::kChi2RPhiSize> chi2RPhi,
262 ap_uint<TrackBitWidths::kChi2RZSize> chi2RZ,
263 ap_uint<TrackBitWidths::kBendChi2Size> bendChi2,
264 ap_uint<TrackBitWidths::kHitPatternSize> hitPattern,
265 ap_uint<TrackBitWidths::kMVAQualitySize> mvaQuality,
266 ap_uint<TrackBitWidths::kMVAOtherSize> mvaOther);
274 float localPhi(
float globalPhi,
unsigned int sector)
const {
282 int digitizedValue = std::floor(value / lsb);
285 int digitizedMaximum = (1 << (nBits - 1)) - 1;
286 int digitizedMinimum = -1. * (digitizedMaximum + 1);
289 digitizedValue = std::clamp(digitizedValue, digitizedMinimum, digitizedMaximum);
292 unsigned int twosValue = digitizedValue;
293 if (digitizedValue < 0) {
294 twosValue += (1 << nBits);
300 template <
typename T>
303 return (
up - bins.begin() - 1);
310 assert((twosValue >> nBits) == 0);
313 int digitizedValue = twosValue;
314 if (twosValue & (1 << (nBits - 1))) {
315 digitizedValue -= (1 << nBits);
319 return (
double(digitizedValue) + 0.5) * lsb;
unsigned int getD0Bits() const
constexpr double deltaPhi(double phi1, double phi2)
ap_uint< TrackBitWidths::kTrackWordSize > tkword_t
unsigned int getPhiBits() const
static constexpr std::array< double, 1<< TrackBitWidths::kChi2RPhiSize > chi2RPhiBins
bendChi2_t getBendChi2Word() const
ap_uint< TrackBitWidths::kMVAQualitySize > qualityMVA_t
double getBendChi2() const
bool singleDigitizationSchemeTest(const double floatingPointValue, const unsigned int nBits, const double lsb) const
unsigned int getBendChi2Bits() const
double undigitizeSignedValue(unsigned int twosValue, unsigned int nBits, double lsb) const
static constexpr double sectorWidth
static constexpr double minZ0
hit_t getHitPatternWord() const
unsigned int getMVAQuality() const
static constexpr double minD0
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
unsigned int getHitPattern() const
static constexpr double stepD0
unsigned int getMVAQualityBits() const
void infoTestDigitizationScheme(const unsigned int, const double, const double, const unsigned int, const double, const unsigned int)
static constexpr std::array< double, 1<< TrackBitWidths::kBendChi2Size > bendChi2Bins
unsigned int getMVAOtherBits() const
static constexpr double minTanl
static constexpr double minRinv
chi2rz_t getChi2RZWord() const
constexpr unsigned int getBin(double value, const T &bins) const
otherMVA_t getMVAOtherWord() const
tanl_t getTanlWord() const
ap_uint< TrackBitWidths::kZ0Size > z0_t
void setTrackWord(unsigned int valid, const GlobalVector &momentum, const GlobalPoint &POCA, double rInv, double chi2RPhi, double chi2RZ, double bendChi2, unsigned int hitPattern, unsigned int mvaQuality, unsigned int mvaOther, unsigned int sector)
static constexpr double stepRinv
unsigned int digitizeSignedValue(double value, unsigned int nBits, double lsb) const
ap_uint< TrackBitWidths::kMVAOtherSize > otherMVA_t
unsigned int getValidBits() const
void testDigitizationScheme() const
unsigned int getChi2RZBits() const
TTTrack_TrackWord(const TTTrack_TrackWord &word)
valid_t getValidWord() const
ap_uint< TrackBitWidths::kValidSize > valid_t
ap_uint< TrackBitWidths::kRinvSize > rinv_t
Abs< T >::type abs(const T &t)
static constexpr double stepTanL
std::bitset< TrackBitWidths::kTrackWordSize > tkword_bs_t
unsigned int getRinvBits() const
ap_uint< TrackBitWidths::kHitPatternSize > hit_t
ap_uint< TrackBitWidths::kChi2RZSize > chi2rz_t
unsigned int getHitPatternBits() const
static constexpr double minPhi0
unsigned int getMVAOther() const
static constexpr float d0
chi2rphi_t getChi2RPhiWord() const
static constexpr double stepPhi0
unsigned int getZ0Bits() const
static constexpr unsigned int nSectors
float localPhi(float globalPhi, unsigned int sector) const
unsigned int getChi2RPhiBits() const
unsigned int getTanlBits() const
ap_uint< TrackBitWidths::kTanlSize > tanl_t
static constexpr std::array< double, 1<< TrackBitWidths::kChi2RZSize > chi2RZBins
tkword_t getTrackWord() const
ap_uint< TrackBitWidths::kD0Size > d0_t
TTTrack_TrackWord & operator=(const TTTrack_TrackWord &word)
static constexpr double stepZ0
qualityMVA_t getMVAQualityWord() const
ap_uint< TrackBitWidths::kChi2RPhiSize > chi2rphi_t
double getChi2RPhi() const
ap_uint< TrackBitWidths::kBendChi2Size > bendChi2_t
ap_uint< TrackBitWidths::kPhiSize > phi_t
rinv_t getRinvWord() const