CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IMATH_TrackletCalculatorDisk.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTracklet_interface_IMATH_TrackletCalculatorDisk_h
2 #define L1Trigger_TrackFindingTracklet_interface_IMATH_TrackletCalculatorDisk_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_TrackletCalculatorDisk(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(s, 1024, "IMATH Tracklet Calculator for Disk %i %i dphisector = %f", i1, i2, settings_.dphisector());
27  edm::LogVerbatim("Tracklet") << s;
28  snprintf(s, 1024, "rmaxL6 = %f, zmaxD5 = %f", settings_.rmax(5), settings_.zmax(4));
29  edm::LogVerbatim("Tracklet") << s;
30  snprintf(
31  s, 1024, " stub Ks: kr, kphi1, kz = %g, %g, %g", settings_.kr(), settings_.kphi1(), settings_.kz());
32  edm::LogVerbatim("Tracklet") << s;
33  snprintf(s,
34  1024,
35  " tracklet Ks: krinvpars, kphi0pars, ktpars, kzpars = %g, %g, %g, %g",
39  settings_.kz() * pow(2, settings_.z0_shift()));
40  edm::LogVerbatim("Tracklet") << s;
41  snprintf(s,
42  1024,
43  "layer proj Ks: kphiproj456, kphider, kzproj, kzder = %g, %g, %g, %g",
48  edm::LogVerbatim("Tracklet") << s;
49  snprintf(s,
50  1024,
51  " disk proj Ks: kphiprojdisk, kphiprojderdisk, krprojdisk, krprojderdisk = %g, %g, %g, %g",
56  edm::LogVerbatim("Tracklet") << s;
57  edm::LogVerbatim("Tracklet") << "=============================================";
58  }
59 
60  z1mean.set_fval(settings_.zmean(abs(i1) - 1));
61  z2mean.set_fval(settings_.zmean(abs(i2) - 1));
62 
63  if (i2 < 0) { //t is negative
64  z1mean.set_fval(-settings_.zmean(abs(i1) - 1));
65  z2mean.set_fval(-settings_.zmean(abs(i2) - 1));
66  invt.set_mode(VarInv::mode::neg);
67  invt.initLUT(0.);
68  }
69 
73 
75 
79 
81 
85 
87 
91 
93 
97 
99 
103 
105  }
106 
107  ~IMATH_TrackletCalculatorDisk() = default;
108 
110 
112 
113  //max values
114  const double dz_max = 50.;
115  const double dr_max = 20.;
116  const double delta0_max = 0.005;
117  const double a2_max = 3.;
118  const double a2a_max = 0.1;
119  const double x6a_max = 0.02;
120  const double x6m_max = 2.;
121  const double x8_max = 1.;
122  const double x13_max = 300.;
123  const double x22_max = 0.3;
124  const double x23_max = 200.;
125  const double deltaZ_max = 8.;
126  const double der_phiD_max = 0.002;
127  const double t_max = 7.9;
128  const double t_disk_min = 1.;
129  const double t_disk_max = 7.9;
130  const double t_layer_max = 2.5;
131  const double z0_max = 20.;
132  const double z0a_max = 205.;
133 
134  //constants
135  VarParam plus2{globals_, "plus2", 2., 10};
136  VarParam plus1{globals_, "plus1", 1., 10};
137  VarParam minus1{globals_, "minus1", -1, 10};
138 
141 
142  //inputs
147 
148  VarDef phi1{globals_, "phi1", "Kphi", settings_.dphisector() / 0.75, settings_.kphi1()};
149  VarDef phi2{globals_, "phi2", "Kphi", settings_.dphisector() / 0.75, settings_.kphi1()};
150 
154 
158 
159  //calculations
160 
161  //tracklet
164 
166 
167  //R LUT
168  VarInv drinv{globals_, "drinv", &dr, 0, 18, 23, 0, VarInv::mode::pos};
169 
172 
175  VarMult delta1{globals_, "delta1", &r1, &delta0};
176  VarMult delta2{globals_, "delta2", &r2, &delta0};
179  VarSubtract a2{globals_, "a2", &plus2, &a2b, 3.};
180  VarNeg a2n{globals_, "a2n", &a2};
181  VarShift a{globals_, "a", &a2, 1};
182 
183  VarAdd Rabs{globals_, "Rabs", &r1, &r2};
184  VarTimesC R6{globals_, "R6", &Rabs, 1. / 6., 12};
185 
187  VarMult x6a{globals_, "x6a", &delta2, &x4, 8 * x6a_max};
189  VarAdd x6m{globals_, "x6m", &minus1, &x6b, 2.};
191 
194 
197  VarMult t{globals_, "t", &a, &deltaZ, 2 * t_max};
198  VarAdd z0{globals_, "z0", &z1abs, &z0b, 2 * z0_max};
199 
201  globals_, "rinv_final", &rinv, settings_.kphi1() / settings_.kr() * pow(2, settings_.rinv_shift())};
205 
206  //projection to r
207  VarShift x2{globals_, "x2", &delta0, 1};
208 
209  VarMult x1_0{globals_, "x1_0", &x2, &rproj0};
210  VarMult x1_1{globals_, "x1_1", &x2, &rproj1};
211  VarMult x1_2{globals_, "x1_2", &x2, &rproj2};
212 
216 
217  VarMult x12_0{globals_, "x12_0", &x8_0, &x8_0};
218  VarMult x12_1{globals_, "x12_1", &x8_1, &x8_1};
219  VarMult x12_2{globals_, "x12_2", &x8_2, &x8_2};
220 
224 
225  VarTimesC x20_0{globals_, "x20_0", &x12A_0, 1. / 6.};
226  VarTimesC x20_1{globals_, "x20_1", &x12A_1, 1. / 6.};
227  VarTimesC x20_2{globals_, "x20_2", &x12A_2, 1. / 6.};
228 
229  VarAdd x10_0{globals_, "x10_0", &plus1, &x20_0};
230  VarAdd x10_1{globals_, "x10_1", &plus1, &x20_1};
231  VarAdd x10_2{globals_, "x10_2", &plus1, &x20_2};
232 
233  VarMult x22_0{globals_, "x22_0", &x8_0, &x10_0, 2 * x22_max};
234  VarMult x22_1{globals_, "x22_1", &x8_1, &x10_1, 2 * x22_max};
235  VarMult x22_2{globals_, "x22_2", &x8_2, &x10_2, 2 * x22_max};
236 
237  VarSubtract phiL_0{globals_, "phiL_0", &phi0_final, &x22_0, -1, phi0_final.nbits() + 1};
238  VarSubtract phiL_1{globals_, "phiL_1", &phi0_final, &x22_1, -1, phi0_final.nbits() + 1};
239  VarSubtract phiL_2{globals_, "phiL_2", &phi0_final, &x22_2, -1, phi0_final.nbits() + 1};
240 
241  VarShift x3{globals_, "x3", &rinv, 1};
242  VarNeg der_phiL{globals_, "der_phiL", &x3};
243 
247 
249  "der_phiL_final",
250  &der_phiL,
252 
253  VarMult x11_0{globals_, "x11_0", &rproj0, &t};
254  VarMult x11_1{globals_, "x11_1", &rproj1, &t};
255  VarMult x11_2{globals_, "x11_2", &rproj2, &t};
256 
257  VarMult x23_0{globals_, "x23_0", &x11_0, &x10_0, 4 * x23_max};
258  VarMult x23_1{globals_, "x23_1", &x11_1, &x10_1, 4 * x23_max};
259  VarMult x23_2{globals_, "x23_2", &x11_2, &x10_2, 4 * x23_max};
260 
261  VarAdd zL_0{globals_, "zL_0", &z0, &x23_0};
262  VarAdd zL_1{globals_, "zL_1", &z0, &x23_1};
263  VarAdd zL_2{globals_, "zL_2", &z0, &x23_2};
264 
268 
270  globals_, "der_zL_final", &t_final, settings_.kz() / settings_.kr() * pow(2, settings_.PS_zderL_shift())};
271 
272  //projection to z
273  VarInv invt{globals_, "invt", &t_final, 0., 18, 26, 1, VarInv::mode::pos, 13};
274 
275  VarMult x7{globals_, "x7", &x2, &a2};
276 
277  VarSubtract x5_0{globals_, "x5_0", &zproj0, &z0};
278  VarSubtract x5_1{globals_, "x5_1", &zproj1, &z0};
279  VarSubtract x5_2{globals_, "x5_2", &zproj2, &z0};
280 
284 
288 
292 
296 
297  VarMult der_phiD{globals_, "der_phiD", &x7, &invt, 2 * der_phiD_max};
298 
300  "der_phiD_final",
301  &der_phiD,
303 
304  VarMult x26_0{globals_, "x26_0", &x25_0, &x25_0};
305  VarMult x26_1{globals_, "x26_1", &x25_1, &x25_1};
306  VarMult x26_2{globals_, "x26_2", &x25_2, &x25_2};
307 
311 
312  VarTimesC x9_0{globals_, "x9_0", &x26A_0, 1. / 6.};
313  VarTimesC x9_1{globals_, "x9_1", &x26A_1, 1. / 6.};
314  VarTimesC x9_2{globals_, "x9_2", &x26A_2, 1. / 6.};
315 
319 
323 
327 
329  globals_, "der_rD_final", &invt, settings_.kr() / settings_.kz() * pow(2, settings_.PS_rderD_shift())};
330 
333 
349  VarCut t_cut{globals_, &t, -t_max, t_max};
373 
377 
378  // the following flags are used to apply the cuts in TrackletCalculator
379  // and in the output Verilog
381 
385 
389 
392 
396 
400 
403  };
404 }; // namespace trklet
405 
406 #endif
Log< level::Info, true > LogVerbatim
double z0cut() const
Definition: Settings.h:324
constexpr int N_DISK
Definition: Settings.h:22
int SS_phiD_shift() const
Definition: Settings.h:356
double rinvcut() const
Definition: Settings.h:210
double rmaxdisk() const
Definition: Settings.h:125
double zlength() const
Definition: Settings.h:124
int PS_rderD_shift() const
Definition: Settings.h:360
int phi0_shift() const
Definition: Settings.h:341
int PS_zderL_shift() const
Definition: Settings.h:352
bool debugTracklet() const
Definition: Settings.h:182
int t_shift() const
Definition: Settings.h:342
int SS_phiL_shift() const
Definition: Settings.h:348
void initLUT(double offset)
Definition: imath.cc:142
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
void set_fval(double fval)
Definition: imath.h:448
int nbits() const
Definition: imath.h:243
int PS_zL_shift() const
Definition: Settings.h:349
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int PS_rD_shift() const
Definition: Settings.h:357
double kphi1() const
Definition: Settings.h:299
double dzmax() const
Definition: Settings.h:129
double rmax(unsigned int iLayer) const
Definition: Settings.h:165
int SS_phiderD_shift() const
Definition: Settings.h:359
void set_mode(mode m)
Definition: imath.h:999
void add_cut(VarBase *cut, const bool call_set_parent_flag=true)
Definition: imath.cc:373
int SS_phiderL_shift() const
Definition: Settings.h:351
double dphisector() const
Definition: Settings.h:290
int rinv_shift() const
Definition: Settings.h:340
double kz() const
Definition: Settings.h:302
double kr() const
Definition: Settings.h:304
IMATH_TrackletCalculatorDisk(Settings const &settings, imathGlobals *globals, int i1, int i2)
double zmax(unsigned int iDisk) const
Definition: Settings.h:168
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
int z0_shift() const
Definition: Settings.h:343
double maxrinv() const
Definition: Settings.h:307
constexpr int N_LAYER
Definition: Settings.h:21