CMS 3D CMS Logo

IMATH_TrackletCalculator.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTracklet_interface_IMATH_TrackletCalculator_h
2 #define L1Trigger_TrackFindingTracklet_interface_IMATH_TrackletCalculator_h
3 
4 #include "Settings.h"
5 #include "imath.h"
6 
7 //
8 // Constants used:
9 // dphisector
10 // rmaxL6
11 // zmaxD5
12 // rmaxdisk
13 // kr, kphi1, kz
14 //
15 // rmean[], zmean[]
16 
17 namespace trklet {
18  class Globals;
19 
21  public:
22  IMATH_TrackletCalculator(Settings const& settings, imathGlobals* globals, int i1, int i2)
23  : settings_(settings), globals_(globals) {
24  if (settings_.debugTracklet()) {
25  edm::LogVerbatim("Tracklet") << "=============================================";
26  char s[1024];
27  snprintf(s, 1024, "IMATH Tracklet Calculator %i %i dphisector = %f", i1, i2, settings_.dphisector());
28  edm::LogVerbatim("Tracklet") << s;
29  snprintf(s, 1024, "rmaxL6 = %f, zmaxD5 = %f", settings_.rmax(5), settings_.zmax(4));
30  edm::LogVerbatim("Tracklet") << s;
31  snprintf(
32  s, 1024, " stub Ks: kr, kphi1, kz = %g, %g, %g", settings_.kr(), settings_.kphi1(), settings_.kz());
33  edm::LogVerbatim("Tracklet") << s;
34  snprintf(s,
35  1024,
36  " tracklet Ks: krinvpars, kphi0pars, ktpars, kzpars = %g, %g, %g, %g",
40  settings_.kz() * pow(2, settings_.z0_shift()));
41  edm::LogVerbatim("Tracklet") << s;
42  snprintf(s,
43  1024,
44  "layer proj Ks: kphiproj456, kphider, kzproj, kzder = %g, %g, %g, %g",
49  edm::LogVerbatim("Tracklet") << s;
50  snprintf(s,
51  1024,
52  " disk proj Ks: kphiprojdisk, kphiprojderdisk, krprojdisk, krprojderdisk = %g, %g, %g, %g",
57  edm::LogVerbatim("Tracklet") << s;
58  edm::LogVerbatim("Tracklet") << "=============================================";
59 
60  snprintf(s, 1024, "initializing 1/dr LUT %f %f", settings_.rmean(i1 - 1), settings_.rmean(i2 - 1));
61  edm::LogVerbatim("Tracklet") << s;
62  }
63 
68 
69  if (i1 == 1)
71  else
73 
78 
80 
85 
87 
93 
95 
101 
103 
109 
111 
117 
119  }
120 
121  ~IMATH_TrackletCalculator() = default;
122 
124 
126 
127  //max values
128  const double dz_max = 50.;
129  const double delta0_max = 0.005;
130  const double a2_max = 3.;
131  const double a2a_max = 0.1;
132  const double x6a_max = 0.02;
133  const double x6m_max = 2.;
134  const double x8_max = 1.;
135  const double x13_max = 300.;
136  const double x22_max = 0.3;
137  const double x23_max = 200.;
138  const double t_max = 4.;
139  const double z0_max = 20.;
140  const double der_phiD_max = 0.002;
141  const double t_disk_min = 1;
142  const double t_disk_max = 4;
143  const double t_layer_max = 2.5;
144 
145  //constants
146  VarParam plus1{globals_, "plus1", 1., 10};
147  VarParam plus2{globals_, "plus2", 2., 10};
148  VarParam minus1{globals_, "minus1", -1., 10};
149 
153 
154  //inputs
159 
160  //0.75 below comes from phi range for coordinate can be larger than for sector
161  VarDef phi1{globals_, "phi1", "Kphi", settings_.dphisector() / 0.75, settings_.kphi1()};
162  VarDef phi2{globals_, "phi2", "Kphi", settings_.dphisector() / 0.75, settings_.kphi1()};
163 
168 
174 
175  //calculations
176 
177  //tracklet
180 
182 
183  //R LUT
184  VarInv drinv{globals_, "drinv", &dr, 0, 18, 24, 0, VarInv::mode::both};
185 
188 
190  VarMult deltaZ{globals_, "deltaZ", &dz, &drinv};
196  VarNeg a2n{globals_, "a2n", &a2};
197  VarShift a{globals_, "a", &a2, 1};
198 
200  VarTimesC R6{globals_, "R6", &Rabs, 1. / 6., 12};
201 
203  VarMult x6a{globals_, "x6a", &delta2, &x4, 2 * x6a_max};
207 
210 
214  VarAdd z0{globals_, "z0", &z1, &z0b, 2 * z0_max};
215 
217  globals_, "rinv_final", &rinv, settings_.kphi1() / settings_.kr() * pow(2, settings_.rinv_shift())};
221 
222  //projection to r
223  VarShift x2{globals_, "x2", &delta0, 1};
224 
225  VarMult x1_0{globals_, "x1_0", &x2, &rproj0};
226  VarMult x1_1{globals_, "x1_1", &x2, &rproj1};
227  VarMult x1_2{globals_, "x1_2", &x2, &rproj2};
228  VarMult x1_3{globals_, "x1_3", &x2, &rproj3};
229 
234 
235  VarMult x12_0{globals_, "x12_0", &x8_0, &x8_0};
236  VarMult x12_1{globals_, "x12_1", &x8_1, &x8_1};
237  VarMult x12_2{globals_, "x12_2", &x8_2, &x8_2};
238  VarMult x12_3{globals_, "x12_3", &x8_3, &x8_3};
239 
244 
245  VarTimesC x20_0{globals_, "x20_0", &x12A_0, 1. / 6.};
246  VarTimesC x20_1{globals_, "x20_1", &x12A_1, 1. / 6.};
247  VarTimesC x20_2{globals_, "x20_2", &x12A_2, 1. / 6.};
248  VarTimesC x20_3{globals_, "x20_3", &x12A_3, 1. / 6.};
249 
250  VarAdd x10_0{globals_, "x10_0", &plus1, &x20_0};
251  VarAdd x10_1{globals_, "x10_1", &plus1, &x20_1};
252  VarAdd x10_2{globals_, "x10_2", &plus1, &x20_2};
253  VarAdd x10_3{globals_, "x10_3", &plus1, &x20_3};
254 
255  VarMult x22_0{globals_, "x22_0", &x8_0, &x10_0, 2 * x22_max};
256  VarMult x22_1{globals_, "x22_1", &x8_1, &x10_1, 2 * x22_max};
257  VarMult x22_2{globals_, "x22_2", &x8_2, &x10_2, 2 * x22_max};
258  VarMult x22_3{globals_, "x22_3", &x8_3, &x10_3, 2 * x22_max};
259 
264 
265  VarShift x3{globals_, "x3", &rinv, 1};
266  VarNeg der_phiL{globals_, "der_phiL", &x3};
267 
272 
274  "der_phiL_final",
275  &der_phiL,
277 
278  VarMult x11_0{globals_, "x11_0", &rproj0, &t};
279  VarMult x11_1{globals_, "x11_1", &rproj1, &t};
280  VarMult x11_2{globals_, "x11_2", &rproj2, &t};
281  VarMult x11_3{globals_, "x11_3", &rproj3, &t};
282 
283  VarMult x23_0{globals_, "x23_0", &x11_0, &x10_0, 2 * x23_max};
284  VarMult x23_1{globals_, "x23_1", &x11_1, &x10_1, 2 * x23_max};
285  VarMult x23_2{globals_, "x23_2", &x11_2, &x10_2, 2 * x23_max};
286  VarMult x23_3{globals_, "x23_3", &x11_3, &x10_3, 2 * x23_max};
287 
288  VarAdd zL_0{globals_, "zL_0", &z0, &x23_0};
289  VarAdd zL_1{globals_, "zL_1", &z0, &x23_1};
290  VarAdd zL_2{globals_, "zL_2", &z0, &x23_2};
291  VarAdd zL_3{globals_, "zL_3", &z0, &x23_3};
292 
297 
299  globals_, "der_zL_final", &t_final, settings_.kz() / settings_.kr() * pow(2, settings_.PS_zderL_shift())};
300 
301  //projection to z
302  //
303  VarInv invt{globals_, "invt", &t_final, 0., 18, 26, 1, VarInv::mode::both, 13};
304 
305  VarMult x7{globals_, "x7", &x2, &a2};
306 
312 
318 
324 
330 
336 
337  VarMult der_phiD{globals_, "der_phiD", &x7, &invt, 4 * der_phiD_max};
338 
340  "der_phiD_final",
341  &der_phiD,
343 
349 
355 
356  VarTimesC x9_0{globals_, "x9_0", &x26A_0, 1. / 6.};
357  VarTimesC x9_1{globals_, "x9_1", &x26A_1, 1. / 6.};
358  VarTimesC x9_2{globals_, "x9_2", &x26A_2, 1. / 6.};
359  VarTimesC x9_3{globals_, "x9_3", &x26A_3, 1. / 6.};
360  VarTimesC x9_4{globals_, "x9_4", &x26A_4, 1. / 6.};
361 
367 
373 
379 
381  globals_, "der_rD_final", &invt, settings_.kr() / settings_.kz() * pow(2, settings_.PS_rderD_shift())};
382 
384  // the following two are not associated with any variable yet; this is done
385  // in the constructor of this class since it depends on the layer
388 
437 
441 
442  // the following flags are used to apply the cuts in TrackletCalculator
443  // and in the output Verilog
445 
450 
455 
458 
464 
470 
473  };
474 }; // namespace trklet
475 
476 #endif
Log< level::Info, true > LogVerbatim
double kz() const
Definition: Settings.h:302
int PS_rD_shift() const
Definition: Settings.h:357
int PS_zL_shift() const
Definition: Settings.h:349
constexpr int N_DISK
Definition: Settings.h:22
int PS_rderD_shift() const
Definition: Settings.h:360
int PS_zderL_shift() const
Definition: Settings.h:352
double zmax(unsigned int iDisk) const
Definition: Settings.h:168
double kphi1() const
Definition: Settings.h:299
void add_cut(VarCut *cut, const bool call_set_cut_var=true)
Definition: imath.cc:359
int nbits() const
Definition: imath.h:244
double zlength() const
Definition: Settings.h:124
int phi0_shift() const
Definition: Settings.h:341
void initLUT(double offset)
Definition: imath.cc:142
double dphisector() const
Definition: Settings.h:290
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
int t_shift() const
Definition: Settings.h:342
void set_fval(double fval)
Definition: imath.h:449
double rinvcut() const
Definition: Settings.h:210
int z0_shift() const
Definition: Settings.h:343
int SS_phiD_shift() const
Definition: Settings.h:356
bool debugTracklet() const
Definition: Settings.h:182
int SS_phiderD_shift() const
Definition: Settings.h:359
double kr() const
Definition: Settings.h:304
double drmax() const
Definition: Settings.h:128
double z0cut() const
Definition: Settings.h:324
void add_cut(VarBase *cut, const bool call_set_parent_flag=true)
Definition: imath.cc:373
double rmaxdisk() const
Definition: Settings.h:125
IMATH_TrackletCalculator(Settings const &settings, imathGlobals *globals, int i1, int i2)
double rmax(unsigned int iLayer) const
Definition: Settings.h:165
int SS_phiderL_shift() const
Definition: Settings.h:351
int rinv_shift() const
Definition: Settings.h:340
double maxrinv() const
Definition: Settings.h:307
int SS_phiL_shift() const
Definition: Settings.h:348
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
constexpr int N_LAYER
Definition: Settings.h:21