CMS 3D CMS Logo

L1TrackUnpacker.h
Go to the documentation of this file.
1 #ifndef L1Trigger_L1TTrackMatch_L1TrackUnpacker_HH
2 #define L1Trigger_L1TTrackMatch_L1TrackUnpacker_HH
3 #include <iostream>
4 #include <fstream>
5 #include <cmath>
6 #include <cstdlib>
7 #include <string>
8 #include <cstdlib>
12 
13 namespace l1trackunpacker {
14  //For precision studies
15  const unsigned int PT_INTPART_BITS{9};
16  const unsigned int ETA_INTPART_BITS{3};
17  const unsigned int kExtraGlobalPhiBit{4};
18 
19  typedef ap_ufixed<TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1, PT_INTPART_BITS, AP_TRN, AP_SAT> pt_intern;
20  typedef ap_fixed<TTTrack_TrackWord::TrackBitWidths::kTanlSize, ETA_INTPART_BITS, AP_TRN, AP_SAT> glbeta_intern;
21  typedef ap_int<TTTrack_TrackWord::TrackBitWidths::kPhiSize + kExtraGlobalPhiBit> glbphi_intern;
22  typedef ap_int<TTTrack_TrackWord::TrackBitWidths::kZ0Size> z0_intern; // 40cm / 0.1
23  typedef ap_uint<TTTrack_TrackWord::TrackBitWidths::kD0Size> d0_intern;
24 
25  inline const unsigned int DoubleToBit(double value, unsigned int maxBits, double step) {
26  unsigned int digitized_value = std::floor(std::abs(value) / step);
27  unsigned int digitized_maximum = (1 << (maxBits - 1)) - 1; // The remove 1 bit from nBits to account for the sign
28  if (digitized_value > digitized_maximum)
29  digitized_value = digitized_maximum;
30  if (value < 0)
31  digitized_value = (1 << maxBits) - digitized_value; // two's complement encoding
32  return digitized_value;
33  }
34  inline const double BitToDouble(unsigned int bits, unsigned int maxBits, double step) {
35  int isign = 1;
36  unsigned int digitized_maximum = (1 << maxBits) - 1;
37  if (bits & (1 << (maxBits - 1))) { // check the sign
38  isign = -1;
39  bits = (1 << (maxBits + 1)) - bits;
40  }
41  return (double(bits & digitized_maximum) + 0.5) * step * isign;
42  }
43 
44 } // namespace l1trackunpacker
45 #endif
const unsigned int PT_INTPART_BITS
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ap_ufixed< TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1, PT_INTPART_BITS, AP_TRN, AP_SAT > pt_intern
ap_int< TTTrack_TrackWord::TrackBitWidths::kZ0Size > z0_intern
Definition: value.py:1
const double BitToDouble(unsigned int bits, unsigned int maxBits, double step)
const unsigned int ETA_INTPART_BITS
ap_int< TTTrack_TrackWord::TrackBitWidths::kPhiSize+kExtraGlobalPhiBit > glbphi_intern
const unsigned int kExtraGlobalPhiBit
ap_fixed< TTTrack_TrackWord::TrackBitWidths::kTanlSize, ETA_INTPART_BITS, AP_TRN, AP_SAT > glbeta_intern
step
Definition: StallMonitor.cc:83
ap_uint< TTTrack_TrackWord::TrackBitWidths::kD0Size > d0_intern
const unsigned int DoubleToBit(double value, unsigned int maxBits, double step)