CMS 3D CMS Logo

IMATH_TrackletCalculatorOverlap.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTracklet_interface_IMATH_TrackletCalculatorOverlap_h
2 #define L1Trigger_TrackFindingTracklet_interface_IMATH_TrackletCalculatorOverlap_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 
20  public:
21  IMATH_TrackletCalculatorOverlap(Settings const& settings, imathGlobals* globals, int i1, int i2)
22  : settings_(settings), globals_(globals) {
23  if (settings_.debugTracklet()) {
24  edm::LogVerbatim("Tracklet") << "=============================================";
25  char s[1024];
26  snprintf(
27  s, 1024, "IMATH Tracklet Calculator for Overlap %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 
63 
64  if (i2 < 0) { //t is negative
66  invt.set_mode(VarInv::mode::neg);
67  invt.initLUT(0.);
68  }
69 
73 
75 
79 
81 
86 
88 
93 
95 
100 
102 
107 
109  }
110 
112 
114 
116 
117  //max values
118  const double dz_max = 50.;
119  const double dr_max = 40;
120  const double delta0_max = 0.005;
121  const double a2_max = 3.;
122  const double a2a_max = 0.1;
123  const double x6a_max = 0.02;
124  const double x6m_max = 2.;
125  const double x8_max = 1.;
126  const double x13_max = 300.;
127  const double x22_max = 0.3;
128  const double x23_max = 200.;
129  const double deltaZ_max = 8.;
130  const double der_phiD_max = 0.002;
131  const double t_max = 7.9;
132  const double t_disk_min = 1.;
133  const double t_disk_max = 7.9;
134  const double t_layer_max = 2.5;
135  const double z0_max = 20.;
136 
137  // constants
138  //
139  VarParam plus2{globals_, "plus2", 2., 10};
140  VarParam plus1{globals_, "plus1", 1., 10};
141  VarParam minus1{globals_, "minus1", -1, 10};
142  //
143  //
146 
147  //inputs
152 
153  VarDef phi1{globals_, "phi1", "Kphi", settings_.dphisector() / 0.75, settings_.kphi1()};
154  VarDef phi2{globals_, "phi2", "Kphi", settings_.dphisector() / 0.75, settings_.kphi1()};
155 
156  VarDef rproj0{globals_, "rproj0", "Kr", settings_.rmax(N_LAYER - 1), settings_.kr()};
157  VarDef rproj1{globals_, "rproj1", "Kr", settings_.rmax(N_LAYER - 1), settings_.kr()};
158  VarDef rproj2{globals_, "rproj2", "Kr", settings_.rmax(N_LAYER - 1), settings_.kr()};
159 
160  VarDef zproj0{globals_, "zproj0", "Kz", settings_.zmax(N_DISK - 1), settings_.kz()};
161  VarDef zproj1{globals_, "zproj1", "Kz", settings_.zmax(N_DISK - 1), settings_.kz()};
162  VarDef zproj2{globals_, "zproj2", "Kz", settings_.zmax(N_DISK - 1), settings_.kz()};
163  VarDef zproj3{globals_, "zproj3", "Kz", settings_.zmax(N_DISK - 1), settings_.kz()};
164 
165  //calculations
166 
167  //tracklet
170 
172 
173  //R LUT
174  VarInv drinv{globals_, "drinv", &dr, 0, 18, 23, 0, VarInv::mode::pos};
175 
178 
182  VarMult delta2{globals_, "delta2", &r2, &delta0};
186  VarNeg a2n{globals_, "a2n", &a2};
187  VarShift a{globals_, "a", &a2, 1};
188 
189  VarAdd Rabs{globals_, "Rabs", &r1abs, &r2};
190  VarTimesC R6{globals_, "R6", &Rabs, 1. / 6., 12};
191 
193  VarMult x6a{globals_, "x6a", &delta2, &x4, 32 * x6a_max};
197 
200 
204  VarAdd z0{globals_, "z0", &z1, &z0b, 16 * z0_max};
205 
207  globals_, "rinv_final", &rinv, settings_.kphi1() / settings_.kr() * pow(2, settings_.rinv_shift())};
211 
212  //projection to r
213  VarShift x2{globals_, "x2", &delta0, 1};
214 
215  VarMult x1_0{globals_, "x1_0", &x2, &rproj0};
216  VarMult x1_1{globals_, "x1_1", &x2, &rproj1};
217  VarMult x1_2{globals_, "x1_2", &x2, &rproj2};
218 
219  VarMult x8_0{globals_, "x8_0", &x1_0, &a2n, 2 * x8_max};
220  VarMult x8_1{globals_, "x8_1", &x1_1, &a2n, 2 * x8_max};
221  VarMult x8_2{globals_, "x8_2", &x1_2, &a2n, 2 * x8_max};
222 
223  VarMult x12_0{globals_, "x12_0", &x8_0, &x8_0};
224  VarMult x12_1{globals_, "x12_1", &x8_1, &x8_1};
225  VarMult x12_2{globals_, "x12_2", &x8_2, &x8_2};
226 
230 
231  VarTimesC x20_0{globals_, "x20_0", &x12A_0, 1. / 6.};
232  VarTimesC x20_1{globals_, "x20_1", &x12A_1, 1. / 6.};
233  VarTimesC x20_2{globals_, "x20_2", &x12A_2, 1. / 6.};
234 
235  VarAdd x10_0{globals_, "x10_0", &plus1, &x20_0};
236  VarAdd x10_1{globals_, "x10_1", &plus1, &x20_1};
237  VarAdd x10_2{globals_, "x10_2", &plus1, &x20_2};
238 
239  VarMult x22_0{globals_, "x22_0", &x8_0, &x10_0, 4 * x22_max};
240  VarMult x22_1{globals_, "x22_1", &x8_1, &x10_1, 4 * x22_max};
241  VarMult x22_2{globals_, "x22_2", &x8_2, &x10_2, 4 * x22_max};
242 
246 
247  VarShift x3{globals_, "x3", &rinv, 1};
248  VarNeg der_phiL{globals_, "der_phiL", &x3};
249 
253 
255  "der_phiL_final",
256  &der_phiL,
258 
259  VarMult x11_0{globals_, "x11_0", &rproj0, &t};
260  VarMult x11_1{globals_, "x11_1", &rproj1, &t};
261  VarMult x11_2{globals_, "x11_2", &rproj2, &t};
262 
263  VarMult x23_0{globals_, "x23_0", &x11_0, &x10_0, 2 * x23_max};
264  VarMult x23_1{globals_, "x23_1", &x11_1, &x10_1, 2 * x23_max};
265  VarMult x23_2{globals_, "x23_2", &x11_2, &x10_2, 2 * x23_max};
266 
267  VarAdd zL_0{globals_, "zL_0", &z0, &x23_0};
268  VarAdd zL_1{globals_, "zL_1", &z0, &x23_1};
269  VarAdd zL_2{globals_, "zL_2", &z0, &x23_2};
270 
274 
276  globals_, "der_zL_final", &t_final, settings_.kz() / settings_.kr() * pow(2, settings_.PS_zderL_shift())};
277 
278  //projection to z
279  VarInv invt{globals_, "invt", &t_final, 0., 18, 26, 1, VarInv::mode::pos, 13};
280 
281  VarMult x7{globals_, "x7", &x2, &a2};
282 
287 
292 
297 
302 
307 
308  VarMult der_phiD{globals_, "der_phiD", &x7, &invt, 8 * der_phiD_max};
309 
311  "der_phiD_final",
312  &der_phiD,
314 
319 
324 
325  VarTimesC x9_0{globals_, "x9_0", &x26A_0, 1. / 6.};
326  VarTimesC x9_1{globals_, "x9_1", &x26A_1, 1. / 6.};
327  VarTimesC x9_2{globals_, "x9_2", &x26A_2, 1. / 6.};
328  VarTimesC x9_3{globals_, "x9_3", &x26A_3, 1. / 6.};
329 
334 
339 
344 
346  globals_, "der_rD_final", &invt, settings_.kr() / settings_.kz() * pow(2, settings_.PS_rderD_shift())};
347 
351 
395 
399 
400  // the following flags are used to apply the cuts in TrackletCalculator
401  // and in the output Verilog
403 
407 
411 
414 
419 
424 
427  };
428 }; // namespace trklet
429 #endif
IMATH_TrackletCalculatorOverlap(Settings const &settings, imathGlobals *globals, int i1, int i2)
Log< level::Info, true > LogVerbatim
double kz() const
Definition: Settings.h:342
int PS_rD_shift() const
Definition: Settings.h:397
int PS_zL_shift() const
Definition: Settings.h:389
constexpr int N_DISK
Definition: Settings.h:26
int PS_rderD_shift() const
Definition: Settings.h:400
int PS_zderL_shift() const
Definition: Settings.h:392
double zmax(unsigned int iDisk) const
Definition: Settings.h:177
double kphi1() const
Definition: Settings.h:339
int nbits() const
Definition: imath.h:244
double zlength() const
Definition: Settings.h:133
int phi0_shift() const
Definition: Settings.h:381
double dzmax() const
Definition: Settings.h:138
void initLUT(double offset)
Definition: imath.cc:142
double dphisector() const
Definition: Settings.h:329
double rmean(unsigned int iLayer) const
Definition: Settings.h:173
int t_shift() const
Definition: Settings.h:382
void set_fval(double fval)
Definition: imath.h:449
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double rinvcut() const
Definition: Settings.h:222
int z0_shift() const
Definition: Settings.h:383
double zmean(unsigned int iDisk) const
Definition: Settings.h:176
int SS_phiD_shift() const
Definition: Settings.h:396
bool debugTracklet() const
Definition: Settings.h:194
int SS_phiderD_shift() const
Definition: Settings.h:399
double kr() const
Definition: Settings.h:344
void set_mode(mode m)
Definition: imath.h:1000
double drmax() const
Definition: Settings.h:137
double z0cut() const
Definition: Settings.h:364
void add_cut(VarBase *cut, const bool call_set_parent_flag=true)
Definition: imath.cc:373
double rmaxdisk() const
Definition: Settings.h:134
double rmax(unsigned int iLayer) const
Definition: Settings.h:174
int SS_phiderL_shift() const
Definition: Settings.h:391
int rinv_shift() const
Definition: Settings.h:380
double maxrinv() const
Definition: Settings.h:347
int SS_phiL_shift() const
Definition: Settings.h:388
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
constexpr int N_LAYER
Definition: Settings.h:25