CMS 3D CMS Logo

L1TkEtMissEmuTrackTransform.h
Go to the documentation of this file.
1 #ifndef L1Trigger_L1TTrackMatch_L1TkEtMissEmuTrackTransform_HH
2 #define L1Trigger_L1TTrackMatch_L1TkEtMissEmuTrackTransform_HH
3 
9 
10 /*
11 ** class : L1TkEtMissEmuTrackTransform
12 ** author : Christopher Brown
13 ** date : 19/02/2021
14 ** modified :16/06/2021
15 ** brief : Converts TTrack_trackword to internal Et word including vertex
16 
17 ** :
18 */
19 
20 // Internal Word used by EtMiss Emulation, producer expects this wordtype
24 
29 
34 
35  unsigned int Sector; //Phi sector
36  bool EtaSector; //Positve or negative eta
37 
38  float phi; // Used to debug cos phi LUT
39 };
40 
42 public:
43  L1TkEtMissEmuTrackTransform() = default;
44  ~L1TkEtMissEmuTrackTransform() = default;
45 
46  void generateLUTs(); // Generate internal LUTs needed for track transfrom
47 
48  // Transform track and vertex, allow for vertex word or vertex collections
49  template <class track, class vertex>
51 
52  // Converts local int phi to global int phi
54 
55  // Function to count stubs in hitpattern
57 
58  std::vector<l1tmetemu::global_phi_t> generatePhiSliceLUT(unsigned int N);
59 
60  std::vector<l1tmetemu::global_phi_t> getPhiQuad() const { return phiQuadrants; }
61  std::vector<l1tmetemu::global_phi_t> getPhiShift() const { return phiShift; }
62 
63  void setGTTinput(bool input) { GTTinput_ = input; }
64 
65 private:
66  std::vector<l1tmetemu::global_phi_t> phiQuadrants;
67  std::vector<l1tmetemu::global_phi_t> phiShift;
68 
69  bool GTTinput_ = false;
70 };
71 
72 // Template to allow vertex word or vertex from vertex finder depending on simulation vs emulation
73 template <class track, class vertex>
75  InternalEtWord Outword;
76 
77  unsigned int temp_pt;
78  unsigned int temp_eta;
79 
80  if (GTTinput_) {
81  if ((track_ref.getRinvWord() & (1 << (TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1))) != 0) {
82  // Only Want Magnitude of Pt for sums so perform absolute value
83  temp_pt = abs((1 << (TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1)) - track_ref.getRinvWord());
84  } else {
85  temp_pt = track_ref.getRinvWord();
86  }
88  temp_pt * 2, TTTrack_TrackWord::TrackBitWidths::kRinvSize, l1tmetemu::kInternalPtWidth);
89 
90  if ((track_ref.getTanlWord() & (1 << (TTTrack_TrackWord::TrackBitWidths::kTanlSize - 1))) != 0) {
91  // Only Want Magnitude of Eta for cuts and track to vertex association so
92  // perform absolute value
93  temp_eta = abs((1 << (TTTrack_TrackWord::TrackBitWidths::kTanlSize)) - track_ref.getTanlWord());
94  } else {
95  temp_eta = track_ref.getTanlWord();
96  }
98  temp_eta, TTTrack_TrackWord::TrackBitWidths::kTanlSize, l1tmetemu::kInternalEtaWidth);
99 
100  } else {
101  track_ref.setTrackWordBits();
102  // Change track word digitization to digitization expected by track MET
103  Outword.pt = l1tmetemu::digitizeSignedValue<TTTrack_TrackWord::rinv_t>(
104  track_ref.momentum().perp(), l1tmetemu::kInternalPtWidth, l1tmetemu::kStepPt);
105 
106  Outword.eta = l1tmetemu::digitizeSignedValue<TTTrack_TrackWord::tanl_t>(
107  abs(track_ref.momentum().eta()), l1tmetemu::kInternalEtaWidth, l1tmetemu::kStepEta);
108  }
109 
110  Outword.chi2rphidof = track_ref.getChi2RPhiWord();
111  Outword.chi2rzdof = track_ref.getChi2RZWord();
112  Outword.bendChi2 = track_ref.getBendChi2Word();
113  Outword.nstubs = countNStub(track_ref.getHitPatternWord());
114  Outword.Hitpattern = track_ref.getHitPatternWord();
115  Outword.Sector = track_ref.phiSector();
116  Outword.EtaSector = (track_ref.getTanlWord() & (1 << (TTTrack_TrackWord::TrackBitWidths::kTanlSize - 1)));
117  Outword.phi = track_ref.phi();
118  Outword.globalPhi = localToGlobalPhi(track_ref.getPhiWord(), phiShift[track_ref.phiSector()]);
119 
120  unsigned int temp_pv = l1tmetemu::digitizeSignedValue<TTTrack_TrackWord::z0_t>(
121  PV.z0(),
122  TTTrack_TrackWord::TrackBitWidths::kZ0Size,
123  TTTrack_TrackWord::stepZ0); // Convert vertex to integer representation
124  //Rescale to internal representations
126  track_ref.getZ0Word(), TTTrack_TrackWord::TrackBitWidths::kZ0Size, l1tmetemu::kInternalVTXWidth);
128  temp_pv, TTTrack_TrackWord::TrackBitWidths::kZ0Size, l1tmetemu::kInternalVTXWidth);
129 
130  return Outword;
131 }
132 
133 #endif
TTTrack_TrackWord::chi2rphi_t chi2rphidof
~L1TkEtMissEmuTrackTransform()=default
std::vector< l1tmetemu::global_phi_t > getPhiShift() const
ap_uint< kInternalVTXWidth > z_t
std::vector< l1tmetemu::global_phi_t > generatePhiSliceLUT(unsigned int N)
const double kStepEta
const double kStepPt
TTTrack_TrackWord::chi2rz_t chi2rzdof
static std::string const input
Definition: EdmProvDump.cc:47
const unsigned int kInternalVTXWidth
std::vector< l1tmetemu::global_phi_t > phiQuadrants
unsigned int transformSignedValue(unsigned int bits, unsigned int oldnBits, unsigned int newnBits)
std::vector< l1tmetemu::global_phi_t > getPhiQuad() const
TTTrack_TrackWord::hit_t Hitpattern
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ap_uint< kInternalEtaWidth > eta_t
ap_uint< TrackBitWidths::kHitPatternSize > hit_t
ap_uint< TrackBitWidths::kChi2RZSize > chi2rz_t
const unsigned int kInternalPtWidth
ap_uint< kInternalPhiWidth+kGlobalPhiExtra > global_phi_t
#define N
Definition: blowfish.cc:9
l1tmetemu::nstub_t nstubs
l1tmetemu::global_phi_t globalPhi
l1tmetemu::global_phi_t localToGlobalPhi(TTTrack_TrackWord::phi_t local_phi, l1tmetemu::global_phi_t sector_shift)
TTTrack_TrackWord::bendChi2_t bendChi2
const unsigned int kInternalEtaWidth
ap_uint< 3 > nstub_t
std::vector< l1tmetemu::global_phi_t > phiShift
static constexpr double stepZ0
l1tmetemu::nstub_t countNStub(TTTrack_TrackWord::hit_t Hitpattern)
ap_uint< TrackBitWidths::kChi2RPhiSize > chi2rphi_t
InternalEtWord transformTrack(track &track_ref, vertex &PV)
ap_uint< kInternalPtWidth > pt_t
ap_uint< TrackBitWidths::kBendChi2Size > bendChi2_t
ap_uint< TrackBitWidths::kPhiSize > phi_t