CMS 3D CMS Logo

TrackletLUT.h
Go to the documentation of this file.
1 // TrackletLUT
3 // This class writes out the variuos look up tables
4 // for all modules.
6 //
7 // This class has methods to build the LUT (LookUp Tables) used by the track finding
8 // It also provides a method to write out the file for use by the firmware implementation
9 //
10 //
11 #ifndef L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h
12 #define L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h
13 
14 #include <string>
15 #include <vector>
16 #include <string>
17 
19 
20 class Setup;
21 
22 namespace trklet {
23 
24  class Settings;
25 
26  class TrackletLUT {
27  public:
28  TrackletLUT(const Settings& settings);
29 
31  name_ = other.name_;
32  table_ = other.table_;
33  nbits_ = other.nbits_;
34  positive_ = other.positive_;
35 
36  return *this;
37  }
38 
39  ~TrackletLUT() = default;
40 
41  enum MatchType {
42  barrelphi, // write LUT for barrel phi
43  barrelz, // write LUT for barrel z
44  disk2Sphi, // write LUT for disk 2S phi
45  disk2Sr, // write LUT for disk 2S r
46  diskPSphi, // write LUT for disk PS phi
47  diskPSr, // write LUT for disk PS r
48  alphainner, // write alpha corrections LUT for 2S (inner)
49  alphaouter, // write alpha corrections LUT for 2S (outer)
50  rSSinner, // write r LUT for 2S (inner)
51  rSSouter // write r LUT for 2S (inner)
52  };
53 
54  //region only used for name - should be removed
55  void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region);
56 
57  //Builds LUT that for each TP returns if the phi differences between inner and outer
58  //stub is consistent with the pT cut and the stub pair should be kept.
59  void initTPlut(bool fillInner,
60  unsigned int iSeed,
61  unsigned int layerdisk1,
62  unsigned int layerdisk2,
63  unsigned int nbitsfinephidiff,
64  unsigned int iTP);
65 
66  //Builds a lut for the TP ro decide if the region should be used. This is used in the
67  //first stage of the TP to decide which regions in the outer layer an inner stub needs
68  //to be combined with
69  void initTPregionlut(unsigned int iSeed,
70  unsigned int layerdisk1,
71  unsigned int layerdisk2,
72  unsigned int iAllStub,
73  unsigned int nbitsfinephidiff,
74  unsigned int nbitsfinephi,
75  const TrackletLUT& tplutinner,
76  unsigned int iTP);
77 
78  //Stub pt consistency for tracklet engine
79  void initteptlut(bool fillInner,
80  bool fillTEMem,
81  unsigned int iSeed,
82  unsigned int layerdisk1,
83  unsigned int layerdisk2,
84  unsigned int innerphibits,
85  unsigned int outerphibits,
86  double innerphimin,
87  double innerphimax,
88  double outerphimin,
89  double outerphimax,
90  const std::string& innermem,
91  const std::string& outermem);
92 
93  //This LUT uses the phi derivative known in the projection to calculate the corresponding bend
94  void initProjectionBend(double k_phider, unsigned int idisk, unsigned int nrbits, unsigned int nphiderbits);
95 
96  //This LUT implements consistence check for match engine to check that stub bend is consistent with projection
97  void initBendMatch(unsigned int layerdisk);
98 
99  void initProjectionDiskRadius(int nrbits);
100 
102 
103  //In the VMR we used the position of the stub (r, z) to calculate the bin and fine rz position the stub has
104  //region only used for name - should be removed
105  void initVMRTable(unsigned int layerdisk, VMRTableType type, int region = -1);
106 
107  //Used in barrel to calculate the phi position of a stub at the nominal radis of the layer based on the stub radial
108  //psotion and bend
109  void initPhiCorrTable(unsigned int layerdisk, unsigned int rbits);
110 
111  //writes out the LUT in standared format for firmware
112  void writeTable() const;
113 
114  //Evaluate the LUT
115  int lookup(unsigned int index) const;
116 
117  unsigned int size() const { return table_.size(); }
118 
119  private:
122 
123  //Determine bend/bend cuts in LUT regions
124  std::vector<const tt::SensorModule*> getSensorModules(unsigned int layerdisk,
125  bool isPS,
126  std::array<double, 2> tan_range = {{-1, -1}},
127  unsigned int nzbins = 1,
128  unsigned int zbin = 0);
129 
130  std::array<double, 2> getTanRange(const std::vector<const tt::SensorModule*>& sensorModules);
131 
132  std::vector<std::array<double, 2>> getBendCut(unsigned int layerdisk,
133  const std::vector<const tt::SensorModule*>& sensorModules,
134  bool isPS,
135  double FEbendcut = 0);
136 
137  int getphiCorrValue(
138  unsigned int layerdisk, double bend, unsigned int irbin, double rmean, double dr, double drmax) const;
139 
140  int getVMRLookup(unsigned int layerdisk, double z, double r, double dz, double dr, int iseed = -1) const;
141 
143 
144  std::vector<int> table_;
145 
146  unsigned int nbits_;
147 
148  bool positive_;
149  };
150 }; // namespace trklet
151 #endif
void initBendMatch(unsigned int layerdisk)
Definition: TrackletLUT.cc:901
void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region)
Definition: TrackletLUT.cc:190
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:44
void initProjectionBend(double k_phider, unsigned int idisk, unsigned int nrbits, unsigned int nphiderbits)
Definition: TrackletLUT.cc:801
void initteptlut(bool fillInner, bool fillTEMem, unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int innerphibits, unsigned int outerphibits, double innerphimin, double innerphimax, double outerphimin, double outerphimax, const std::string &innermem, const std::string &outermem)
Definition: TrackletLUT.cc:559
const Settings & settings_
Definition: TrackletLUT.h:120
int lookup(unsigned int index) const
int getphiCorrValue(unsigned int layerdisk, double bend, unsigned int irbin, double rmean, double dr, double drmax) const
TrackletLUT(const Settings &settings)
Definition: TrackletLUT.cc:12
void initPhiCorrTable(unsigned int layerdisk, unsigned int rbits)
std::array< double, 2 > getTanRange(const std::vector< const tt::SensorModule *> &sensorModules)
Definition: TrackletLUT.cc:90
TrackletLUT & operator=(const TrackletLUT &other)
Definition: TrackletLUT.h:30
std::string name_
Definition: TrackletLUT.h:142
unsigned int size() const
Definition: TrackletLUT.h:117
~TrackletLUT()=default
int iseed
Definition: AMPTWrapper.h:134
void initTPlut(bool fillInner, unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int nbitsfinephidiff, unsigned int iTP)
Definition: TrackletLUT.cc:286
unsigned int nbits_
Definition: TrackletLUT.h:146
void initTPregionlut(unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int iAllStub, unsigned int nbitsfinephidiff, unsigned int nbitsfinephi, const TrackletLUT &tplutinner, unsigned int iTP)
Definition: TrackletLUT.cc:501
std::vector< std::array< double, 2 > > getBendCut(unsigned int layerdisk, const std::vector< const tt::SensorModule *> &sensorModules, bool isPS, double FEbendcut=0)
Definition: TrackletLUT.cc:116
int getVMRLookup(unsigned int layerdisk, double z, double r, double dz, double dr, int iseed=-1) const
std::vector< int > table_
Definition: TrackletLUT.h:144
void initProjectionDiskRadius(int nrbits)
Definition: TrackletLUT.cc:854
std::vector< const tt::SensorModule * > getSensorModules(unsigned int layerdisk, bool isPS, std::array< double, 2 > tan_range={{-1, -1}}, unsigned int nzbins=1, unsigned int zbin=0)
Definition: TrackletLUT.cc:15
const tt::Setup * setup_
Definition: TrackletLUT.h:121
void initVMRTable(unsigned int layerdisk, VMRTableType type, int region=-1)
Definition: TrackletLUT.cc:998
void writeTable() const