CMS 3D CMS Logo

TrackConverter.h
Go to the documentation of this file.
1 #ifndef PHASE2GMT_TRACKCONVERTER
2 #define PHASE2GMT_TRACKCONVERTER
3 
4 #include "ConvertedTTTrack.h"
5 #include "Constants.h"
8 
9 namespace Phase2L1GMT {
10 
12  public:
13  TrackConverter(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter<int>("verbose")) {}
15 
17  std::vector<ConvertedTTTrack> out;
18  out.reserve(tracks.size());
19  for (const auto& t : tracks)
20  out.push_back(convert(t));
21  return out;
22  }
23 
24  private:
25  int verbose_;
26  typedef ap_uint<96> wordtype;
27 
29 
30  uint ptLookup(uint absCurv) {
31  for (auto i : ptShifts) {
32  if (absCurv >= uint(i[0]) && absCurv < uint(i[1])) {
33  if (i[2] < 0)
34  return i[4];
35  else
36  return (absCurv >> i[2]) + i[3];
37  }
38  }
39  return 0;
40  }
41 
42  uint etaLookup(uint absTanL) {
43  for (auto i : etaShifts) {
44  if (absTanL >= uint(i[0]) && absTanL < uint(i[1])) {
45  if (i[2] < 0)
46  return i[4];
47  else
48  return (absTanL >> i[2]) + i[3];
49  }
50  }
51  return 0;
52  }
53 
55  uint charge = (track->rInv() < 0) ? 1 : 0;
56  int curvature = track->rInv() * (1 << (BITSTTCURV - 1)) / maxCurv_;
57  int phi = track->phi() * (1 << (BITSPHI - 1)) / (M_PI);
58  int tanLambda = track->tanL() * (1 << (BITSTTTANL - 1)) / maxTanl_;
59  int z0 = track->z0() * (1 << (BITSZ0 - 1)) / maxZ0_;
60  int d0 = track->d0() * (1 << (BITSD0 - 1)) / maxD0_;
61  //calculate pt
62  uint absCurv = curvature > 0 ? (curvature) : (-curvature);
63  uint pt = ptLUT[ptLookup(absCurv)];
65  uint absTanL = tanLambda > 0 ? (tanLambda) : (-tanLambda);
66  uint absEta = etaLUT[etaLookup(absTanL)];
67  int eta = tanLambda > 0 ? (absEta) : (-absEta);
68 
69  ap_int<BITSPHI> phiSec = ap_int<BITSPHI>(phi) -
70  ap_int<BITSPHI>((track->phiSector() * 40 * M_PI / 180.) * (1 << (BITSPHI - 1)) / (M_PI));
71  ap_int<BITSPHI> phiCorrected = ap_int<BITSPHI>(phiSec + track->phiSector() * 910);
72 
73  wordtype word = 0;
74  int bstart = 0;
75  bstart = wordconcat<wordtype>(word, bstart, curvature, BITSTTCURV);
76  bstart = wordconcat<wordtype>(word, bstart, phiSec, BITSTTPHI);
77  bstart = wordconcat<wordtype>(word, bstart, tanLambda, BITSTTTANL);
78  bstart = wordconcat<wordtype>(word, bstart, z0, BITSZ0);
79  bstart = wordconcat<wordtype>(word, bstart, d0, BITSD0);
80  bstart = wordconcat<wordtype>(word, bstart, uint(track->chi2()), 4);
81 
82  ConvertedTTTrack convertedTrack(charge, curvature, absEta, pt, eta, phiCorrected.to_int(), z0, d0, quality, word);
83  convertedTrack.setOfflineQuantities(track->momentum().transverse(), track->eta(), track->phi());
84  if (verbose_)
85  convertedTrack.print();
86  convertedTrack.setTrkPtr(track);
87  return convertedTrack;
88  }
89  };
90 } // namespace Phase2L1GMT
91 
92 #endif
const float maxZ0_
Definition: Constants.h:71
TrackConverter(const edm::ParameterSet &iConfig)
const int BITSZ0
Definition: Constants.h:27
const float maxD0_
Definition: Constants.h:72
ConvertedTTTrack convert(const edm::Ptr< TTTrack< Ref_Phase2TrackerDigi_ > > &track)
T curvature(T InversePt, const MagneticField &field)
const int BITSTTPHI
Definition: Constants.h:12
string quality
uint64_t word
const float maxCurv_
Definition: Constants.h:68
const int etaShifts[4][5]
Definition: Constants.h:118
std::vector< ConvertedTTTrack > convertTracks(const std::vector< edm::Ptr< l1t::TrackerMuon::L1TTTrackType > > &tracks)
uint etaLookup(uint absTanL)
const int BITSPHI
Definition: Constants.h:25
const int BITSD0
Definition: Constants.h:28
const int BITSTTCURV
Definition: Constants.h:10
uint ptLookup(uint absCurv)
#define M_PI
const float maxTanl_
Definition: Constants.h:70
static constexpr float d0
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
const ap_uint< BITSPT > ptLUT[1858]
Definition: Constants.h:18
const int BITSTTTANL
Definition: Constants.h:13
void setOfflineQuantities(float pt, float eta, float phi)
const int ptShifts[9][5]
Definition: Constants.h:8
uint generateQuality(const edm::Ptr< TTTrack< Ref_Phase2TrackerDigi_ > > &track)
const uint etaLUT[4082]
Definition: Constants.h:121