CMS 3D CMS Logo

FitTrack.cc
Go to the documentation of this file.
9 
12 
13 using namespace std;
14 using namespace trklet;
15 
16 FitTrack::FitTrack(string name, Settings const& settings, Globals* global)
17  : ProcessBase(name, settings, global), trackfit_(nullptr) {}
18 
20  if (settings_.writetrace()) {
21  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
22  << output;
23  }
24  if (output == "trackout") {
25  TrackFitMemory* tmp = dynamic_cast<TrackFitMemory*>(memory);
26  assert(tmp != nullptr);
27  trackfit_ = tmp;
28  return;
29  }
30 
31  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " addOutput, output = " << output << " not known";
32 }
33 
35  if (settings_.writetrace()) {
36  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
37  << input;
38  }
39  if (input.substr(0, 4) == "tpar") {
40  auto* tmp = dynamic_cast<TrackletParametersMemory*>(memory);
41  assert(tmp != nullptr);
42  seedtracklet_.push_back(tmp);
43  return;
44  }
45  if (input.substr(0, 10) == "fullmatch1") {
46  auto* tmp = dynamic_cast<FullMatchMemory*>(memory);
47  assert(tmp != nullptr);
48  fullmatch1_.push_back(tmp);
49  return;
50  }
51  if (input.substr(0, 10) == "fullmatch2") {
52  auto* tmp = dynamic_cast<FullMatchMemory*>(memory);
53  assert(tmp != nullptr);
54  fullmatch2_.push_back(tmp);
55  return;
56  }
57  if (input.substr(0, 10) == "fullmatch3") {
58  auto* tmp = dynamic_cast<FullMatchMemory*>(memory);
59  assert(tmp != nullptr);
60  fullmatch3_.push_back(tmp);
61  return;
62  }
63  if (input.substr(0, 10) == "fullmatch4") {
64  auto* tmp = dynamic_cast<FullMatchMemory*>(memory);
65  assert(tmp != nullptr);
66  fullmatch4_.push_back(tmp);
67  return;
68  }
69 
70  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " input = " << input << " not found";
71 }
72 
73 #ifdef USEHYBRID
74 void FitTrack::trackFitKF(Tracklet* tracklet,
75  std::vector<const Stub*>& trackstublist,
76  std::vector<std::pair<int, int>>& stubidslist) {
77  if (settings_.doKF()) {
78  // From full match lists, collect all the stubs associated with the tracklet seed
79 
80  // Get seed stubs first
81  trackstublist.emplace_back(tracklet->innerFPGAStub());
82  if (tracklet->getISeed() >= (int)N_TRKLSEED + 1)
83  trackstublist.emplace_back(tracklet->middleFPGAStub());
84  trackstublist.emplace_back(tracklet->outerFPGAStub());
85 
86  // Now get ALL matches (can have multiple per layer)
87  for (const auto& i : fullmatch1_) {
88  for (unsigned int j = 0; j < i->nMatches(); j++) {
89  if (i->getTracklet(j)->TCID() == tracklet->TCID()) {
90  trackstublist.push_back(i->getMatch(j).second);
91  }
92  }
93  }
94 
95  for (const auto& i : fullmatch2_) {
96  for (unsigned int j = 0; j < i->nMatches(); j++) {
97  if (i->getTracklet(j)->TCID() == tracklet->TCID()) {
98  trackstublist.push_back(i->getMatch(j).second);
99  }
100  }
101  }
102 
103  for (const auto& i : fullmatch3_) {
104  for (unsigned int j = 0; j < i->nMatches(); j++) {
105  if (i->getTracklet(j)->TCID() == tracklet->TCID()) {
106  trackstublist.push_back(i->getMatch(j).second);
107  }
108  }
109  }
110 
111  for (const auto& i : fullmatch4_) {
112  for (unsigned int j = 0; j < i->nMatches(); j++) {
113  if (i->getTracklet(j)->TCID() == tracklet->TCID()) {
114  trackstublist.push_back(i->getMatch(j).second);
115  }
116  }
117  }
118 
119  // For merge removal, loop through the resulting list of stubs to calculate their stubids
120  if (settings_.removalType() == "merge") {
121  for (const auto& it : trackstublist) {
122  int layer = it->layer().value() + 1; // Assume layer (1-6) stub first
123  if (it->layer().value() < 0) { // if disk stub, though...
124  layer = it->disk().value() + 10 * it->disk().value() / abs(it->disk().value()); //disk = +/- 11-15
125  }
126  stubidslist.push_back(std::make_pair(layer, it->phiregionaddress()));
127  }
128 
129  // And that's all we need! The rest is just for track fit (done in PurgeDuplicate)
130 
131  } else {
132  // Track fit only called here if not running duplicate removal
133  // before fit. (e.g. If skipping duplicate removal).
134  HybridFit hybridFitter(iSector_, settings_, globals_);
135  hybridFitter.Fit(tracklet, trackstublist);
136  }
137  }
138 }
139 #endif
140 
141 void FitTrack::trackFitChisq(Tracklet* tracklet, std::vector<const Stub*>&, std::vector<std::pair<int, int>>&) {
142  if (globals_->trackDerTable() == nullptr) {
143  TrackDerTable* derTablePtr = new TrackDerTable(settings_);
144 
145  derTablePtr->readPatternFile(settings_.fitPatternFile());
146  derTablePtr->fillTable();
147  if (settings_.debugTracklet()) {
148  edm::LogVerbatim("Tracklet") << "Number of entries in derivative table: " << derTablePtr->getEntries();
149  }
150  assert(derTablePtr->getEntries() != 0);
151 
152  globals_->trackDerTable() = derTablePtr;
153  }
154 
155  const TrackDerTable& derTable = *globals_->trackDerTable();
156 
157  //First step is to build list of layers and disks.
158  int layers[N_LAYER];
159  double r[N_LAYER];
160  unsigned int nlayers = 0; // layers with found stub-projections
161  int disks[N_DISK];
162  double z[N_DISK];
163  unsigned int ndisks = 0; // disks with found stub-projections
164 
165  // residuals for each stub
166  double phiresid[N_FITSTUB];
167  double zresid[N_FITSTUB];
168  double phiresidexact[N_FITSTUB];
169  double zresidexact[N_FITSTUB];
170  int iphiresid[N_FITSTUB];
171  int izresid[N_FITSTUB];
172  double alpha[N_FITSTUB];
173 
174  for (unsigned int i = 0; i < N_FITSTUB; i++) {
175  iphiresid[i] = 0;
176  izresid[i] = 0;
177  alpha[i] = 0.0;
178 
179  phiresid[i] = 0.0;
180  zresid[i] = 0.0;
181  phiresidexact[i] = 0.0;
182  zresidexact[i] = 0.0;
183  }
184 
185  std::bitset<N_LAYER> lmatches; //layer matches
186  std::bitset<N_DISK * 2> dmatches; //disk matches (2 per disk to separate 2S from PS)
187 
188  int mult = 1;
189 
190  unsigned int layermask = 0;
191  unsigned int diskmask = 0;
192  unsigned int alphaindex = 0;
193  unsigned int power = 1;
194 
195  double t = tracklet->t();
196  double rinv = tracklet->rinv();
197 
198  if (tracklet->isBarrel()) {
199  for (unsigned int l = 1; l <= N_LAYER; l++) {
200  if (l == (unsigned int)tracklet->layer() || l == (unsigned int)tracklet->layer() + 1) {
201  lmatches.set(N_LAYER - l);
202  layermask |= (1 << (N_LAYER - l));
203  layers[nlayers++] = l;
204  continue;
205  }
206  if (tracklet->match(l - 1)) {
207  const Residual& resid = tracklet->resid(l - 1);
208  lmatches.set(N_LAYER - l);
209  layermask |= (1 << (N_LAYER - l));
210  phiresid[nlayers] = resid.phiresidapprox();
211  zresid[nlayers] = resid.rzresidapprox();
212  phiresidexact[nlayers] = resid.phiresid();
213  zresidexact[nlayers] = resid.rzresid();
214  iphiresid[nlayers] = resid.fpgaphiresid().value();
215  izresid[nlayers] = resid.fpgarzresid().value();
216 
217  layers[nlayers++] = l;
218  }
219  }
220 
221  for (unsigned int d = 1; d <= N_DISK; d++) {
222  if (layermask & (1 << (d - 1)))
223  continue;
224 
225  if (mult == 1 << (3 * settings_.alphaBitsTable()))
226  continue;
227 
228  if (ndisks + nlayers >= N_FITSTUB)
229  continue;
230  if (tracklet->match(N_LAYER + d - 1)) {
231  const Residual& resid = tracklet->resid(N_LAYER + d - 1);
232  double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule());
233  if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) {
234  dmatches.set(2 * d - 1);
235  diskmask |= (1 << (2 * (N_DISK - d) + 1));
236  } else {
237  int ialpha = resid.stubptr()->alpha().value();
238  int nalpha = resid.stubptr()->alpha().nbits();
239  nalpha = nalpha - settings_.alphaBitsTable();
240  ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha);
241 
242  alphaindex += ialpha * power;
244  dmatches.set(2 * (N_DISK - d));
245  diskmask |= (1 << (2 * (N_DISK - d)));
247  }
248  alpha[ndisks] = resid.stubptr()->l1tstub()->alpha(pitch);
249  phiresid[nlayers + ndisks] = resid.phiresidapprox();
250  zresid[nlayers + ndisks] = resid.rzresidapprox();
251  phiresidexact[nlayers + ndisks] = resid.phiresid();
252  zresidexact[nlayers + ndisks] = resid.rzresid();
253  iphiresid[nlayers + ndisks] = resid.fpgaphiresid().value();
254  izresid[nlayers + ndisks] = resid.fpgarzresid().value();
255 
256  disks[ndisks++] = d;
257  }
258  }
259 
260  if (settings_.writeMonitorData("HitPattern")) {
261  if (mult <= 1 << (3 * settings_.alphaBitsTable())) {
262  globals_->ofstream("hitpattern.txt")
263  << lmatches.to_string() << " " << dmatches.to_string() << " " << mult << endl;
264  }
265  }
266  }
267 
268  if (tracklet->isDisk()) {
269  for (unsigned int l = 1; l <= 2; l++) {
270  if (tracklet->match(l - 1)) {
271  lmatches.set(N_LAYER - l);
272 
273  layermask |= (1 << (N_LAYER - l));
274  const Residual& resid = tracklet->resid(l - 1);
275  phiresid[nlayers] = resid.phiresidapprox();
276  zresid[nlayers] = resid.rzresidapprox();
277  phiresidexact[nlayers] = resid.phiresid();
278  zresidexact[nlayers] = resid.rzresid();
279  iphiresid[nlayers] = resid.fpgaphiresid().value();
280  izresid[nlayers] = resid.fpgarzresid().value();
281 
282  layers[nlayers++] = l;
283  }
284  }
285 
286  for (int d1 = 1; d1 <= N_DISK; d1++) {
287  int d = d1;
288 
289  // skip F/B5 if there's already a L2 match
290  if (d == 5 and layermask & (1 << 4))
291  continue;
292 
293  if (tracklet->fpgat().value() < 0.0)
294  d = -d1;
295  if (d1 == abs(tracklet->disk()) || d1 == abs(tracklet->disk()) + 1) {
296  dmatches.set(2 * d1 - 1);
297  diskmask |= (1 << (2 * (N_DISK - d1) + 1));
298  alpha[ndisks] = 0.0;
299  disks[ndisks++] = d;
300  continue;
301  }
302 
303  if (ndisks + nlayers >= N_FITSTUB)
304  continue;
305  if (tracklet->match(N_LAYER + abs(d) - 1)) {
306  const Residual& resid = tracklet->resid(N_LAYER + abs(d) - 1);
307  double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule());
308  if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) {
309  dmatches.set(2 * d1 - 1);
310  diskmask |= (1 << (2 * (N_DISK - d1) + 1));
311  } else {
312  int ialpha = resid.stubptr()->alpha().value();
313  int nalpha = resid.stubptr()->alpha().nbits();
314  nalpha = nalpha - settings_.alphaBitsTable();
315  ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha);
316 
317  alphaindex += ialpha * power;
319  dmatches.set(2 * (N_DISK - d1));
320  diskmask |= (1 << (2 * (N_DISK - d1)));
322  }
323 
324  alpha[ndisks] = resid.stubptr()->l1tstub()->alpha(pitch);
325  assert(std::abs(resid.phiresidapprox()) < 0.2);
326  phiresid[nlayers + ndisks] = resid.phiresidapprox();
327  zresid[nlayers + ndisks] = resid.rzresidapprox();
328  assert(std::abs(resid.phiresid()) < 0.2);
329  phiresidexact[nlayers + ndisks] = resid.phiresid();
330  zresidexact[nlayers + ndisks] = resid.rzresid();
331  iphiresid[nlayers + ndisks] = resid.fpgaphiresid().value();
332  izresid[nlayers + ndisks] = resid.fpgarzresid().value();
333 
334  disks[ndisks++] = d;
335  }
336  }
337  }
338 
339  if (tracklet->isOverlap()) {
340  for (unsigned int l = 1; l <= 2; l++) {
341  if (l == (unsigned int)tracklet->layer()) {
342  lmatches.set(N_LAYER - l);
343  layermask |= (1 << (N_LAYER - l));
344  layers[nlayers++] = l;
345  continue;
346  }
347  if (tracklet->match(l - 1)) {
348  lmatches.set(N_LAYER - l);
349  layermask |= (1 << (N_LAYER - l));
350  const Residual& resid = tracklet->resid(l - 1);
351  assert(std::abs(resid.phiresidapprox()) < 0.2);
352  phiresid[nlayers] = resid.phiresidapprox();
353  zresid[nlayers] = resid.rzresidapprox();
354  assert(std::abs(resid.phiresid()) < 0.2);
355  phiresidexact[nlayers] = resid.phiresid();
356  zresidexact[nlayers] = resid.rzresid();
357  iphiresid[nlayers] = resid.fpgaphiresid().value();
358  izresid[nlayers] = resid.fpgarzresid().value();
359 
360  layers[nlayers++] = l;
361  }
362  }
363 
364  for (unsigned int d1 = 1; d1 <= N_DISK; d1++) {
365  if (mult == 1 << (3 * settings_.alphaBitsTable()))
366  continue;
367  int d = d1;
368  if (tracklet->fpgat().value() < 0.0)
369  d = -d1;
370  if (d == tracklet->disk()) { //All seeds in PS modules
371  disks[ndisks] = tracklet->disk();
372  dmatches.set(2 * d1 - 1);
373  diskmask |= (1 << (2 * (N_DISK - d1) + 1));
374  ndisks++;
375  continue;
376  }
377 
378  if (ndisks + nlayers >= N_FITSTUB)
379  continue;
380  if (tracklet->match(N_LAYER + abs(d) - 1)) {
381  const Residual& resid = tracklet->resid(N_LAYER + abs(d) - 1);
382  double pitch = settings_.stripPitch(resid.stubptr()->l1tstub()->isPSmodule());
383  if (std::abs(resid.stubptr()->l1tstub()->alpha(pitch)) < 1e-20) {
384  dmatches.set(2 * (N_DISK - d1));
385  diskmask |= (1 << (2 * (N_DISK - d1) + 1));
386  FPGAWord tmp;
387  tmp.set(diskmask, 10);
388  } else {
389  int ialpha = resid.stubptr()->alpha().value();
390  int nalpha = resid.stubptr()->alpha().nbits();
391  nalpha = nalpha - settings_.alphaBitsTable();
392  ialpha = (1 << (settings_.alphaBitsTable() - 1)) + (ialpha >> nalpha);
393 
394  alphaindex += ialpha * power;
396  dmatches.set(2 * (N_DISK - d1));
397  diskmask |= (1 << (2 * (N_DISK - d1)));
398  FPGAWord tmp;
399  tmp.set(diskmask, 10);
401  }
402 
403  alpha[ndisks] = resid.stubptr()->l1tstub()->alpha(pitch);
404  assert(std::abs(resid.phiresidapprox()) < 0.2);
405  phiresid[nlayers + ndisks] = resid.phiresidapprox();
406  zresid[nlayers + ndisks] = resid.rzresidapprox();
407  assert(std::abs(resid.phiresid()) < 0.2);
408  phiresidexact[nlayers + ndisks] = resid.phiresid();
409  zresidexact[nlayers + ndisks] = resid.rzresid();
410  iphiresid[nlayers + ndisks] = resid.fpgaphiresid().value();
411  izresid[nlayers + ndisks] = resid.fpgarzresid().value();
412 
413  disks[ndisks++] = d;
414  }
415  }
416  }
417 
418  int rinvindex =
419  (1 << (settings_.nrinvBitsTable() - 1)) * rinv / settings_.rinvmax() + (1 << (settings_.nrinvBitsTable() - 1));
420  if (rinvindex < 0)
421  rinvindex = 0;
422  if (rinvindex >= (1 << settings_.nrinvBitsTable()))
423  rinvindex = (1 << settings_.nrinvBitsTable()) - 1;
424 
425  const TrackDer* derivatives = derTable.getDerivatives(layermask, diskmask, alphaindex, rinvindex);
426 
427  if (derivatives == nullptr) {
428  if (settings_.warnNoDer()) {
429  FPGAWord tmpl, tmpd;
430  tmpl.set(layermask, 6);
431  tmpd.set(diskmask, 10);
432  edm::LogVerbatim("Tracklet") << "No derivative for layermask, diskmask : " << layermask << " " << tmpl.str()
433  << " " << diskmask << " " << tmpd.str() << " eta = " << asinh(t);
434  }
435  return;
436  }
437 
438  double ttabi = TrackDerTable::tpar(settings_, diskmask, layermask);
439  if (t < 0.0)
440  ttabi = -ttabi;
441  double ttab = ttabi;
442 
443  if (settings_.debugTracklet()) {
444  edm::LogVerbatim("Tracklet") << "Doing trackfit in " << getName();
445  }
446 
447  int sign = 1;
448  if (t < 0.0)
449  sign = -1;
450 
451  double rstub[6];
452 
453  double realrstub[3];
454  realrstub[0] = -1.0;
455  realrstub[1] = -1.0;
456  realrstub[2] = -1.0;
457 
458  for (unsigned i = 0; i < nlayers; i++) {
459  r[i] = settings_.rmean(layers[i] - 1);
460  if (layers[i] == tracklet->layer()) {
461  if (tracklet->isOverlap()) {
462  realrstub[i] = tracklet->outerFPGAStub()->l1tstub()->r();
463  } else {
464  realrstub[i] = tracklet->innerFPGAStub()->l1tstub()->r();
465  }
466  }
467  if (layers[i] == tracklet->layer() + 1) {
468  realrstub[i] = tracklet->outerFPGAStub()->l1tstub()->r();
469  }
470  if (tracklet->match(layers[i] - 1) && layers[i] < 4) {
471  const Stub* stubptr = tracklet->resid(layers[i] - 1).stubptr();
472  realrstub[i] = stubptr->l1tstub()->r();
473  assert(std::abs(realrstub[i] - r[i]) < 5.0);
474  }
475  rstub[i] = r[i];
476  }
477  for (unsigned i = 0; i < ndisks; i++) {
478  z[i] = sign * settings_.zmean(abs(disks[i]) - 1);
479  rstub[i + nlayers] = z[i] / ttabi;
480  }
481 
482  double D[N_FITPARAM][N_FITSTUB * 2];
483  double MinvDt[N_FITPARAM][N_FITSTUB * 2];
484  int iD[N_FITPARAM][N_FITSTUB * 2];
485  int iMinvDt[N_FITPARAM][N_FITSTUB * 2];
486  double sigma[N_FITSTUB * 2];
487  double kfactor[N_FITSTUB * 2];
488 
489  unsigned int n = nlayers + ndisks;
490 
491  if (settings_.exactderivatives()) {
493  settings_, nlayers, r, ndisks, z, alpha, t, rinv, D, iD, MinvDt, iMinvDt, sigma, kfactor);
494  ttabi = t;
495  ttab = t;
496  } else {
499  settings_, nlayers, r, ndisks, z, alpha, t, rinv, D, iD, MinvDt, iMinvDt, sigma, kfactor);
500 
501  double MinvDtDummy[N_FITPARAM][N_FITSTUB * 2];
502  derivatives->fill(tracklet->fpgat().value(), MinvDtDummy, iMinvDt);
503  ttab = t;
504  } else {
505  derivatives->fill(tracklet->fpgat().value(), MinvDt, iMinvDt);
506  }
507  }
508 
509  if (!settings_.exactderivatives()) {
510  for (unsigned int i = 0; i < nlayers; i++) {
511  if (r[i] > settings_.rPS2S())
512  continue;
513  for (unsigned int ii = 0; ii < nlayers; ii++) {
514  if (r[ii] > settings_.rPS2S())
515  continue;
516 
517  double tder = derivatives->tdzcorr(i, ii);
518  double zder = derivatives->z0dzcorr(i, ii);
519 
520  double dr = realrstub[i] - r[i];
521 
522  MinvDt[2][2 * ii + 1] += dr * tder;
523  MinvDt[3][2 * ii + 1] += dr * zder;
524 
525  int itder = derivatives->itdzcorr(i, ii);
526  int izder = derivatives->iz0dzcorr(i, ii);
527 
528  int idr = dr / settings_.kr();
529 
530  iMinvDt[2][2 * ii + 1] += ((idr * itder) >> settings_.rcorrbits());
531  iMinvDt[3][2 * ii + 1] += ((idr * izder) >> settings_.rcorrbits());
532  }
533  }
534  }
535 
536  double rinvseed = tracklet->rinvapprox();
537  double phi0seed = tracklet->phi0approx();
538  double tseed = tracklet->tapprox();
539  double z0seed = tracklet->z0approx();
540 
541  double rinvseedexact = tracklet->rinv();
542  double phi0seedexact = tracklet->phi0();
543  double tseedexact = tracklet->t();
544  double z0seedexact = tracklet->z0();
545 
546  double chisqseed = 0.0;
547  double chisqseedexact = 0.0;
548 
549  double delta[2 * N_FITSTUB];
550  double deltaexact[2 * N_FITSTUB];
551  int idelta[2 * N_FITSTUB];
552 
553  for (unsigned int i = 0; i < 2 * N_FITSTUB; i++) {
554  delta[i] = 0.0;
555  deltaexact[i] = 0.0;
556  idelta[i] = 0;
557  }
558 
559  int j = 0;
560 
561  for (unsigned int i = 0; i < n; i++) {
562  if (i >= nlayers) {
563  iphiresid[i] *= (t / ttabi);
564  phiresid[i] *= (t / ttab);
565  phiresidexact[i] *= (t / ttab);
566  }
567 
568  idelta[j] = iphiresid[i];
569  delta[j] = phiresid[i];
570  if (std::abs(phiresid[i]) > 0.2) {
571  edm::LogWarning("Tracklet") << getName() << " WARNING too large phiresid: " << phiresid[i] << " "
572  << phiresidexact[i];
573  }
574  assert(std::abs(phiresid[i]) < 1.0);
575  assert(std::abs(phiresidexact[i]) < 1.0);
576  deltaexact[j++] = phiresidexact[i];
577 
578  idelta[j] = izresid[i];
579  delta[j] = zresid[i];
580  deltaexact[j++] = zresidexact[i];
581 
582  chisqseed += (delta[j - 2] * delta[j - 2] + delta[j - 1] * delta[j - 1]);
583  chisqseedexact += (deltaexact[j - 2] * deltaexact[j - 2] + deltaexact[j - 1] * deltaexact[j - 1]);
584  }
585  assert(j <= 12);
586 
587  double drinv = 0.0;
588  double dphi0 = 0.0;
589  double dt = 0.0;
590  double dz0 = 0.0;
591 
592  double drinvexact = 0.0;
593  double dphi0exact = 0.0;
594  double dtexact = 0.0;
595  double dz0exact = 0.0;
596 
597  int idrinv = 0;
598  int idphi0 = 0;
599  int idt = 0;
600  int idz0 = 0;
601 
602  double drinv_cov = 0.0;
603  double dphi0_cov = 0.0;
604  double dt_cov = 0.0;
605  double dz0_cov = 0.0;
606 
607  double drinv_covexact = 0.0;
608  double dphi0_covexact = 0.0;
609  double dt_covexact = 0.0;
610  double dz0_covexact = 0.0;
611 
612  for (unsigned int j = 0; j < 2 * n; j++) {
613  drinv -= MinvDt[0][j] * delta[j];
614  dphi0 -= MinvDt[1][j] * delta[j];
615  dt -= MinvDt[2][j] * delta[j];
616  dz0 -= MinvDt[3][j] * delta[j];
617 
618  drinv_cov += D[0][j] * delta[j];
619  dphi0_cov += D[1][j] * delta[j];
620  dt_cov += D[2][j] * delta[j];
621  dz0_cov += D[3][j] * delta[j];
622 
623  drinvexact -= MinvDt[0][j] * deltaexact[j];
624  dphi0exact -= MinvDt[1][j] * deltaexact[j];
625  dtexact -= MinvDt[2][j] * deltaexact[j];
626  dz0exact -= MinvDt[3][j] * deltaexact[j];
627 
628  drinv_covexact += D[0][j] * deltaexact[j];
629  dphi0_covexact += D[1][j] * deltaexact[j];
630  dt_covexact += D[2][j] * deltaexact[j];
631  dz0_covexact += D[3][j] * deltaexact[j];
632 
633  idrinv += ((iMinvDt[0][j] * idelta[j]));
634  idphi0 += ((iMinvDt[1][j] * idelta[j]));
635  idt += ((iMinvDt[2][j] * idelta[j]));
636  idz0 += ((iMinvDt[3][j] * idelta[j]));
637 
638  if (false && j % 2 == 0) {
639  edm::LogVerbatim("Tracklet") << "DEBUG CHI2FIT " << j << " " << rinvseed << " + " << MinvDt[0][j] * delta[j]
640  << " " << MinvDt[0][j] << " " << delta[j] * rstub[j / 2] * 10000 << " \n"
641  << j << " " << tracklet->fpgarinv().value() * settings_.krinvpars() << " + "
642  << ((iMinvDt[0][j] * idelta[j])) * settings_.krinvpars() / 1024.0 << " "
643  << iMinvDt[0][j] * settings_.krinvpars() / settings_.kphi() / 1024.0 << " "
644  << idelta[j] * settings_.kphi() * rstub[j / 2] * 10000 << " " << idelta[j];
645  }
646  }
647 
648  double deltaChisqexact =
649  drinvexact * drinv_covexact + dphi0exact * dphi0_covexact + dtexact * dt_covexact + dz0exact * dz0_covexact;
650 
651  int irinvseed = tracklet->fpgarinv().value();
652  int iphi0seed = tracklet->fpgaphi0().value();
653 
654  int itseed = tracklet->fpgat().value();
655  int iz0seed = tracklet->fpgaz0().value();
656 
657  int irinvfit = irinvseed + ((idrinv + (1 << settings_.fitrinvbitshift())) >> settings_.fitrinvbitshift());
658 
659  int iphi0fit = iphi0seed + (idphi0 >> settings_.fitphi0bitshift());
660  int itfit = itseed + (idt >> settings_.fittbitshift());
661 
662  int iz0fit = iz0seed + (idz0 >> settings_.fitz0bitshift());
663 
664  double rinvfit = rinvseed - drinv;
665  double phi0fit = phi0seed - dphi0;
666 
667  double tfit = tseed - dt;
668  double z0fit = z0seed - dz0;
669 
670  double rinvfitexact = rinvseedexact - drinvexact;
671  double phi0fitexact = phi0seedexact - dphi0exact;
672 
673  double tfitexact = tseedexact - dtexact;
674  double z0fitexact = z0seedexact - dz0exact;
675 
676  double chisqfitexact = chisqseedexact + deltaChisqexact;
677 
679  bool NewChisqDebug = false;
680  double chisqfit = 0.0;
681  uint ichisqfit = 0;
682 
683  double phifactor;
684  double rzfactor;
685  double iphifactor;
686  double irzfactor;
687  int k = 0; // column index of D matrix
688 
689  if (NewChisqDebug) {
690  edm::LogVerbatim("Tracklet") << "OG chisq: \n"
691  << "drinv/cov = " << drinv << "/" << drinv_cov << " \n"
692  << "dphi0/cov = " << drinv << "/" << dphi0_cov << " \n"
693  << "dt/cov = " << drinv << "/" << dt_cov << " \n"
694  << "dz0/cov = " << drinv << "/" << dz0_cov << "\n";
695  std::string myout = "D[0][k]= ";
696  for (unsigned int i = 0; i < 2 * n; i++) {
697  myout += std::to_string(D[0][i]);
698  myout += ", ";
699  }
700  edm::LogVerbatim("Tracklet") << myout;
701  }
702 
703  for (unsigned int i = 0; i < n; i++) { // loop over stubs
704 
705  phifactor = rstub[k / 2] * delta[k] / sigma[k] + D[0][k] * drinv + D[1][k] * dphi0 + D[2][k] * dt + D[3][k] * dz0;
706  iphifactor = kfactor[k] * rstub[k / 2] * idelta[k] * (1 << settings_.chisqphifactbits()) / sigma[k] -
707  iD[0][k] * idrinv - iD[1][k] * idphi0 - iD[2][k] * idt - iD[3][k] * idz0;
708 
709  if (NewChisqDebug) {
710  edm::LogVerbatim("Tracklet") << "delta[k]/sigma = " << delta[k] / sigma[k] << " delta[k] = " << delta[k] << "\n"
711  << "sum = " << phifactor - delta[k] / sigma[k] << " drinvterm = " << D[0][k] * drinv
712  << " dphi0term = " << D[1][k] * dphi0 << " dtterm = " << D[2][k] * dt
713  << " dz0term = " << D[3][k] * dz0 << "\n phifactor = " << phifactor;
714  }
715 
716  chisqfit += phifactor * phifactor;
717  ichisqfit += iphifactor * iphifactor / (1 << (2 * settings_.chisqphifactbits() - 4));
718 
719  k++;
720 
721  rzfactor = delta[k] / sigma[k] + D[0][k] * drinv + D[1][k] * dphi0 + D[2][k] * dt + D[3][k] * dz0;
722  irzfactor = kfactor[k] * idelta[k] * (1 << settings_.chisqzfactbits()) / sigma[k] - iD[0][k] * idrinv -
723  iD[1][k] * idphi0 - iD[2][k] * idt - iD[3][k] * idz0;
724 
725  if (NewChisqDebug) {
726  edm::LogVerbatim("Tracklet") << "delta[k]/sigma = " << delta[k] / sigma[k] << " delta[k] = " << delta[k] << "\n"
727  << "sum = " << rzfactor - delta[k] / sigma[k] << " drinvterm = " << D[0][k] * drinv
728  << " dphi0term = " << D[1][k] * dphi0 << " dtterm = " << D[2][k] * dt
729  << " dz0term = " << D[3][k] * dz0 << "\n rzfactor = " << rzfactor;
730  }
731 
732  chisqfit += rzfactor * rzfactor;
733  ichisqfit += irzfactor * irzfactor / (1 << (2 * settings_.chisqzfactbits() - 4));
734 
735  k++;
736  }
737 
738  if (settings_.writeMonitorData("ChiSq")) {
739  globals_->ofstream("chisq.txt") << asinh(itfit * settings_.ktpars()) << " " << chisqfit << " " << ichisqfit / 16.0
740  << endl;
741  }
742 
743  // Chisquare per DOF capped out at 11 bits, so 15 is an educated guess
744  if (ichisqfit >= (1 << 15)) {
745  if (NewChisqDebug) {
746  edm::LogVerbatim("Tracklet") << "CHISQUARE (" << ichisqfit << ") LARGER THAN 11 BITS!";
747  }
748  ichisqfit = (1 << 15) - 1;
749  }
750 
751  // Eliminate lower bits to fit in 8 bits
752  ichisqfit = ichisqfit >> 7;
753  // Probably redundant... enforce 8 bit cap
754  if (ichisqfit >= (1 << 8))
755  ichisqfit = (1 << 8) - 1;
756 
757  double phicrit = phi0fit - asin(0.5 * settings_.rcrit() * rinvfit);
758  bool keep = (phicrit > settings_.phicritmin()) && (phicrit < settings_.phicritmax());
759 
760  if (!keep) {
761  return;
762  }
763 
764  // NOTE: setFitPars in Tracklet.h now accepts chi2 r-phi and chi2 r-z values. This class only has access
765  // to the composite chi2. When setting fit parameters on a tracklet, this places all of the chi2 into the
766  // r-phi fit, and sets the r-z fit value to zero.
767  //
768  // This is also true for the call to setFitPars in trackFitFake.
769  tracklet->setFitPars(rinvfit,
770  phi0fit,
771  0.0,
772  tfit,
773  z0fit,
774  chisqfit,
775  0.0,
776  rinvfitexact,
777  phi0fitexact,
778  0.0,
779  tfitexact,
780  z0fitexact,
781  chisqfitexact,
782  0.0,
783  irinvfit,
784  iphi0fit,
785  0,
786  itfit,
787  iz0fit,
788  ichisqfit,
789  0,
790  0);
791 }
792 
793 void FitTrack::trackFitFake(Tracklet* tracklet, std::vector<const Stub*>&, std::vector<std::pair<int, int>>&) {
794  tracklet->setFitPars(tracklet->rinvapprox(),
795  tracklet->phi0approx(),
796  tracklet->d0approx(),
797  tracklet->tapprox(),
798  tracklet->z0approx(),
799  0.0,
800  0.0,
801  tracklet->rinv(),
802  tracklet->phi0(),
803  tracklet->d0(),
804  tracklet->t(),
805  tracklet->z0(),
806  0.0,
807  0.0,
808  tracklet->fpgarinv().value(),
809  tracklet->fpgaphi0().value(),
810  tracklet->fpgad0().value(),
811  tracklet->fpgat().value(),
812  tracklet->fpgaz0().value(),
813  0,
814  0,
815  0);
816  return;
817 }
818 
819 std::vector<Tracklet*> FitTrack::orderedMatches(vector<FullMatchMemory*>& fullmatch) {
820  std::vector<Tracklet*> tmp;
821 
822  std::vector<unsigned int> indexArray;
823  for (auto& imatch : fullmatch) {
824  //check that we have correct order
825  if (imatch->nMatches() > 1) {
826  for (unsigned int j = 0; j < imatch->nMatches() - 1; j++) {
827  assert(imatch->getTracklet(j)->TCID() <= imatch->getTracklet(j + 1)->TCID());
828  }
829  }
830 
831  if (settings_.debugTracklet() && imatch->nMatches() != 0) {
832  edm::LogVerbatim("Tracklet") << "orderedMatches: " << imatch->getName() << " " << imatch->nMatches();
833  }
834 
835  indexArray.push_back(0);
836  }
837 
838  int bestIndex = -1;
839  do {
840  int bestTCID = -1;
841  bestIndex = -1;
842  for (unsigned int i = 0; i < fullmatch.size(); i++) {
843  if (indexArray[i] >= fullmatch[i]->nMatches()) {
844  //skip as we were at the end
845  continue;
846  }
847  int TCID = fullmatch[i]->getTracklet(indexArray[i])->TCID();
848  if (TCID < bestTCID || bestTCID < 0) {
849  bestTCID = TCID;
850  bestIndex = i;
851  }
852  }
853  if (bestIndex != -1) {
854  tmp.push_back(fullmatch[bestIndex]->getTracklet(indexArray[bestIndex]));
855  indexArray[bestIndex]++;
856  }
857  } while (bestIndex != -1);
858 
859  for (unsigned int i = 0; i < tmp.size(); i++) {
860  if (i > 0) {
861  //This allows for equal TCIDs. This means that we can e.g. have a track seeded in L1L2 that projects to both L3 and D4.
862  //The algorithm will pick up the first hit and drop the second.
863  if (tmp[i - 1]->TCID() > tmp[i]->TCID()) {
864  edm::LogVerbatim("Tracklet") << "Wrong TCID ordering in " << getName() << " : " << tmp[i - 1]->TCID() << " "
865  << tmp[i]->TCID();
866  }
867  }
868  }
869 
870  return tmp;
871 }
872 
873 // Adds the fitted track to the output memories to be used by pure Tracklet algo.
874 // (Also used by Hybrid algo with non-exact Old KF emulation)
875 // Also create output streams, that bypass these memories, (so can include gaps in time),
876 // to be used by Hybrid case with exact New KF emulation.
877 
878 void FitTrack::execute(deque<string>& streamTrackRaw,
879  vector<deque<StubStreamData>>& streamsStubRaw,
880  unsigned int iSector) {
881  // merge
882  const std::vector<Tracklet*>& matches1 = orderedMatches(fullmatch1_);
883  const std::vector<Tracklet*>& matches2 = orderedMatches(fullmatch2_);
884  const std::vector<Tracklet*>& matches3 = orderedMatches(fullmatch3_);
885  const std::vector<Tracklet*>& matches4 = orderedMatches(fullmatch4_);
886 
887  iSector_ = iSector;
888 
889  if (settings_.debugTracklet() && (matches1.size() + matches2.size() + matches3.size() + matches4.size()) > 0) {
890  for (auto& imatch : fullmatch1_) {
891  edm::LogVerbatim("Tracklet") << imatch->getName() << " " << imatch->nMatches();
892  }
893  edm::LogVerbatim("Tracklet") << getName() << " matches : " << matches1.size() << " " << matches2.size() << " "
894  << matches3.size() << " " << matches4.size();
895  }
896 
897  unsigned int indexArray[4];
898  for (unsigned int i = 0; i < 4; i++) {
899  indexArray[i] = 0;
900  }
901 
902  unsigned int countAll = 0;
903  unsigned int countFit = 0;
904 
905  Tracklet* bestTracklet = nullptr;
906  do {
907  countAll++;
908  bestTracklet = nullptr;
909 
910  if (indexArray[0] < matches1.size()) {
911  if (bestTracklet == nullptr) {
912  bestTracklet = matches1[indexArray[0]];
913  } else {
914  if (matches1[indexArray[0]]->TCID() < bestTracklet->TCID())
915  bestTracklet = matches1[indexArray[0]];
916  }
917  }
918 
919  if (indexArray[1] < matches2.size()) {
920  if (bestTracklet == nullptr) {
921  bestTracklet = matches2[indexArray[1]];
922  } else {
923  if (matches2[indexArray[1]]->TCID() < bestTracklet->TCID())
924  bestTracklet = matches2[indexArray[1]];
925  }
926  }
927 
928  if (indexArray[2] < matches3.size()) {
929  if (bestTracklet == nullptr) {
930  bestTracklet = matches3[indexArray[2]];
931  } else {
932  if (matches3[indexArray[2]]->TCID() < bestTracklet->TCID())
933  bestTracklet = matches3[indexArray[2]];
934  }
935  }
936 
937  if (indexArray[3] < matches4.size()) {
938  if (bestTracklet == nullptr) {
939  bestTracklet = matches4[indexArray[3]];
940  } else {
941  if (matches4[indexArray[3]]->TCID() < bestTracklet->TCID())
942  bestTracklet = matches4[indexArray[3]];
943  }
944  }
945 
946  if (bestTracklet == nullptr)
947  break;
948 
949  //Counts total number of matched hits
950  int nMatches = 0;
951 
952  //Counts unique hits in each layer
953  int nMatchesUniq = 0;
954  bool match = false;
955 
956  while (indexArray[0] < matches1.size() && matches1[indexArray[0]] == bestTracklet) {
957  indexArray[0]++;
958  nMatches++;
959  match = true;
960  }
961 
962  if (match)
963  nMatchesUniq++;
964  match = false;
965 
966  while (indexArray[1] < matches2.size() && matches2[indexArray[1]] == bestTracklet) {
967  indexArray[1]++;
968  nMatches++;
969  match = true;
970  }
971 
972  if (match)
973  nMatchesUniq++;
974  match = false;
975 
976  while (indexArray[2] < matches3.size() && matches3[indexArray[2]] == bestTracklet) {
977  indexArray[2]++;
978  nMatches++;
979  match = true;
980  }
981 
982  if (match)
983  nMatchesUniq++;
984  match = false;
985 
986  while (indexArray[3] < matches4.size() && matches4[indexArray[3]] == bestTracklet) {
987  indexArray[3]++;
988  nMatches++;
989  match = true;
990  }
991 
992  if (match)
993  nMatchesUniq++;
994 
995  if (settings_.debugTracklet()) {
996  edm::LogVerbatim("Tracklet") << getName() << " : nMatches = " << nMatches << " nMatchesUniq = " << nMatchesUniq
997  << " " << asinh(bestTracklet->t());
998  }
999 
1000  std::vector<const Stub*> trackstublist;
1001  std::vector<std::pair<int, int>> stubidslist;
1002  // Track Builder cut of >= 4 layers with stubs.
1003  if ((bestTracklet->getISeed() >= (int)N_SEED_PROMPT && nMatchesUniq >= 1) ||
1004  nMatchesUniq >= 2) { //For seeds index >=8 (triplet seeds), there are three stubs associated from start.
1005  countFit++;
1006 
1007 #ifdef USEHYBRID
1008  if (settings_.fakefit()) {
1009  trackFitFake(bestTracklet, trackstublist, stubidslist);
1010  } else {
1011  trackFitKF(bestTracklet, trackstublist, stubidslist);
1012  }
1013 #else
1014  if (settings_.fakefit()) {
1015  trackFitFake(bestTracklet, trackstublist, stubidslist);
1016  } else {
1017  trackFitChisq(bestTracklet, trackstublist, stubidslist);
1018  }
1019 #endif
1020 
1021  if (settings_.removalType() == "merge") {
1022  trackfit_->addStubList(trackstublist);
1023  trackfit_->addStubidsList(stubidslist);
1024  bestTracklet->setTrackIndex(trackfit_->nTracks());
1025  trackfit_->addTrack(bestTracklet);
1026  } else if (bestTracklet->fit()) {
1027  assert(trackfit_ != nullptr);
1028  if (settings_.writeMonitorData("Seeds")) {
1029  ofstream fout("seeds.txt", ofstream::app);
1030  fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_"
1031  << " " << bestTracklet->getISeed() << endl;
1032  fout.close();
1033  }
1034  bestTracklet->setTrackIndex(trackfit_->nTracks());
1035  trackfit_->addTrack(bestTracklet);
1036  }
1037  }
1038 
1039  // store bit and clock accurate TB output
1040  if (settings_.storeTrackBuilderOutput() && bestTracklet) {
1041  // add gap if enough layer to form track
1042  if (!bestTracklet->fit()) {
1043  static const string invalid = "0";
1044  streamTrackRaw.emplace_back(invalid);
1045  for (auto& stream : streamsStubRaw)
1046  stream.emplace_back(StubStreamData());
1047  continue;
1048  }
1049  // convert Track word
1050  const string rinv = bestTracklet->fpgarinv().str();
1051  const string phi0 = bestTracklet->fpgaphi0().str();
1052  const string z0 = bestTracklet->fpgaz0().str();
1053  const string t = bestTracklet->fpgat().str();
1054  const int seedType = bestTracklet->getISeed();
1055  const string seed = TTBV(seedType, settings_.nbitsseed()).str();
1056  const string valid("1");
1057  streamTrackRaw.emplace_back(valid + seed + rinv + phi0 + z0 + t);
1058 
1059  unsigned int ihit(0);
1060  for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
1061  if (bestTracklet->match(ilayer)) {
1062  const Residual& resid = bestTracklet->resid(ilayer);
1063  // create bit accurate 64 bit word
1064  const string valid("1");
1065  string r = resid.stubptr()->r().str();
1066  const string& phi = resid.fpgaphiresid().str();
1067  const string& rz = resid.fpgarzresid().str();
1068  const L1TStub* stub = resid.stubptr()->l1tstub();
1069  static constexpr int widthDisk2Sidentifier = 8;
1070  bool disk2S = (stub->disk() != 0) && (stub->isPSmodule() == 0);
1071  if (disk2S)
1072  r = string(widthDisk2Sidentifier, '0') + r;
1073  // store seed, L1TStub, and bit accurate 64 bit word in clock accurate output
1074  streamsStubRaw[ihit++].emplace_back(seedType, *stub, valid + r + phi + rz);
1075  }
1076  }
1077  // fill all layer with no stubs with gaps
1078  while (ihit < streamsStubRaw.size()) {
1079  streamsStubRaw[ihit++].emplace_back();
1080  }
1081  }
1082 
1083  } while (bestTracklet != nullptr && countAll < settings_.maxStep("TB"));
1084 
1085  if (settings_.writeMonitorData("FT")) {
1086  globals_->ofstream("fittrack.txt") << getName() << " " << countAll << " " << countFit << endl;
1087  }
1088 }
Log< level::Info, true > LogVerbatim
float dt
Definition: AMPTWrapper.h:136
const FPGAWord & fpgarinv() const
Definition: Tracklet.h:132
int chisqzfactbits() const
Definition: Settings.h:393
double t() const
Definition: Tracklet.h:123
double phiresid() const
Definition: Residual.h:47
double tdzcorr(int i, int j) const
Definition: TrackDer.h:66
float alpha
Definition: AMPTWrapper.h:105
const Stub * innerFPGAStub()
Definition: Tracklet.h:61
int nrinvBitsTable() const
Definition: Settings.h:219
constexpr int N_DISK
Definition: Settings.h:22
unsigned int maxStep(std::string module) const
Definition: Settings.h:116
double z0dzcorr(int i, int j) const
Definition: TrackDer.h:67
const FPGAWord & r() const
Definition: Stub.h:60
double rPS2S() const
Definition: Settings.h:334
std::string name_
Definition: ProcessBase.h:38
const Residual & resid(unsigned int layerdisk)
Definition: Tracklet.h:110
static void calculateDerivatives(Settings const &settings, unsigned int nlayers, double r[N_LAYER], unsigned int ndisks, double z[N_DISK], double alpha[N_DISK], double t, double rinv, double D[N_FITPARAM][N_FITSTUB *2], int iD[N_FITPARAM][N_FITSTUB *2], double MinvDt[N_FITPARAM][N_FITSTUB *2], int iMinvDt[N_FITPARAM][N_FITSTUB *2], double sigma[N_FITSTUB *2], double kfactor[N_FITSTUB *2])
const Stub * outerFPGAStub()
Definition: Tracklet.h:65
int disk() const
Definition: Tracklet.cc:782
bool isOverlap() const
Definition: Tracklet.h:203
int alphaBitsTable() const
Definition: Settings.h:218
tuple disks
Definition: alignBH_cfg.py:13
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
void addTrack(Tracklet *tracklet)
std::vector< TrackletParametersMemory * > seedtracklet_
Definition: FitTrack.h:47
double rzresid() const
Definition: Residual.h:52
const FPGAWord & fpgaphiresid() const
Definition: Residual.h:32
int getEntries() const
Definition: TrackDerTable.h:37
const FPGAWord & fpgaz0() const
Definition: Tracklet.h:136
double rinvmax() const
Definition: Settings.h:214
unsigned int nbitsseed() const
Definition: Settings.h:285
const FPGAWord & fpgaphi0() const
Definition: Tracklet.h:133
Settings const & settings_
Definition: ProcessBase.h:40
double phi0() const
Definition: Tracklet.h:121
Globals * globals_
Definition: ProcessBase.h:41
std::string to_string(const V &value)
Definition: OMSAccess.h:71
bool exactderivatives() const
Definition: Settings.h:233
bool exactderivativesforfloating() const
Definition: Settings.h:234
double ktpars() const
Definition: Settings.h:402
bool writetrace() const
Definition: Settings.h:183
void trackFitKF(Tracklet *tracklet, std::vector< const Stub *> &trackstublist, std::vector< std::pair< int, int >> &stubidslist)
double krinvpars() const
Definition: Settings.h:397
void trackFitChisq(Tracklet *tracklet, std::vector< const Stub *> &, std::vector< std::pair< int, int >> &)
Definition: FitTrack.cc:141
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
const FPGAWord & fpgat() const
Definition: Tracklet.h:135
void setTrackIndex(int index)
Definition: Tracklet.cc:813
assert(be >=bs)
void addOutput(MemoryBase *memory, std::string output) override
Definition: FitTrack.cc:19
int itdzcorr(int i, int j) const
Definition: TrackDer.h:78
int TCID() const
Definition: Tracklet.h:214
void addStubList(std::vector< const Stub *> stublist)
int fittbitshift() const
Definition: Settings.h:386
int fitz0bitshift() const
Definition: Settings.h:387
constexpr std::array< uint8_t, layerIndexSize > layer
static std::string const input
Definition: EdmProvDump.cc:50
unsigned int isPSmodule() const
Definition: L1TStub.h:96
TrackFitMemory * trackfit_
Definition: FitTrack.h:55
std::vector< Tracklet * > orderedMatches(std::vector< FullMatchMemory *> &fullmatch)
Definition: FitTrack.cc:819
bool fit() const
Definition: Tracklet.h:197
int rcorrbits() const
Definition: Settings.h:390
std::vector< FullMatchMemory * > fullmatch4_
Definition: FitTrack.h:51
const FPGAWord & fpgarzresid() const
Definition: Residual.h:37
const Stub * middleFPGAStub()
Definition: Tracklet.h:63
double phi0approx() const
Definition: Tracklet.h:127
static double tpar(Settings const &settings, int diskmask, int layermask)
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
double rinv() const
Definition: Tracklet.h:120
double phicritmin() const
Definition: Settings.h:303
constexpr unsigned int N_TRKLSEED
Definition: Settings.h:973
double stripPitch(bool isPSmodule) const
Definition: Settings.h:270
void addInput(MemoryBase *memory, std::string input) override
Definition: FitTrack.cc:34
void fill(int t, double MinvDt[N_FITPARAM][N_FITSTUB *2], int iMinvDt[N_FITPARAM][N_FITSTUB *2]) const
Definition: TrackDer.cc:42
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int value() const
Definition: FPGAWord.h:24
unsigned int nTracks() const
std::string removalType() const
Definition: Settings.h:239
double tapprox() const
Definition: Tracklet.h:129
bool fakefit() const
Definition: Settings.h:243
unsigned int iSector_
Definition: FitTrack.h:53
L1TStub * l1tstub()
Definition: Stub.h:77
int disk() const
Definition: L1TStub.h:46
const TrackDer * getDerivatives(int index) const
Definition: TrackDerTable.h:24
std::string const & fitPatternFile() const
Definition: Settings.h:66
const FPGAWord & fpgad0() const
Definition: Tracklet.h:134
bool writeMonitorData(std::string module) const
Definition: Settings.h:109
bool isBarrel() const
Definition: Tracklet.h:202
double phiresidapprox() const
Definition: Residual.h:57
d
Definition: ztail.py:151
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
ii
Definition: cuy.py:589
std::vector< FullMatchMemory * > fullmatch1_
Definition: FitTrack.h:48
double alpha(double pitch) const
Definition: L1TStub.cc:78
bool debugTracklet() const
Definition: Settings.h:182
double rzresidapprox() const
Definition: Residual.h:62
double rinvapprox() const
Definition: Tracklet.h:126
double d0() const
Definition: Tracklet.h:122
double kr() const
Definition: Settings.h:316
constexpr unsigned int power(unsigned int base, unsigned int exponent)
std::vector< FullMatchMemory * > fullmatch2_
Definition: FitTrack.h:49
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
bool storeTrackBuilderOutput() const
Definition: Settings.h:245
double z0approx() const
Definition: Tracklet.h:130
int nbits() const
Definition: FPGAWord.h:25
void execute(std::deque< std::string > &streamTrackRaw, std::vector< std::deque< StubStreamData >> &stubStream, unsigned int iSector)
Definition: FitTrack.cc:878
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:49
int iz0dzcorr(int i, int j) const
Definition: TrackDer.h:79
int getISeed() const
Definition: Tracklet.cc:801
void set(int value, int nbits, bool positive=true, int line=-1, const char *file=nullptr)
Definition: FPGAWord.cc:14
constexpr unsigned int N_FITPARAM
Definition: Settings.h:977
void readPatternFile(std::string fileName)
const Stub * stubptr() const
Definition: Residual.h:67
double d0approx() const
Definition: Tracklet.h:128
double z0() const
Definition: Tracklet.h:124
const FPGAWord & alpha() const
Definition: Stub.h:64
double r() const
Definition: L1TStub.h:60
bool match(unsigned int layerdisk)
Definition: Tracklet.h:105
int isDisk() const
Definition: Tracklet.h:204
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
constexpr unsigned int N_FITSTUB
Definition: Settings.h:978
int fitrinvbitshift() const
Definition: Settings.h:384
void setFitPars(double rinvfit, double phi0fit, double d0fit, double tfit, double z0fit, double chisqrphifit, double chisqrzfit, double rinvfitexact, double phi0fitexact, double d0fitexact, double tfitexact, double z0fitexact, double chisqrphifitexact, double chisqrzfitexact, int irinvfit, int iphi0fit, int id0fit, int itfit, int iz0fit, int ichisqrphifit, int ichisqrzfit, int hitpattern, const std::vector< const L1TStub *> &l1stubs=std::vector< const L1TStub *>())
Definition: Tracklet.cc:515
double phicritmax() const
Definition: Settings.h:304
int chisqphifactbits() const
Definition: Settings.h:392
TrackDerTable *& trackDerTable()
Definition: Globals.h:40
void addStubidsList(std::vector< std::pair< int, int >> stubidslist)
Log< level::Warning, false > LogWarning
const unsigned int kfactor
void trackFitFake(Tracklet *tracklet, std::vector< const Stub *> &, std::vector< std::pair< int, int >> &)
Definition: FitTrack.cc:793
int layer() const
Definition: Tracklet.cc:773
static constexpr float d1
double kphi() const
Definition: Settings.h:310
#define str(s)
tmp
align.sh
Definition: createJobs.py:716
int fitphi0bitshift() const
Definition: Settings.h:385
bool doKF() const
Definition: Settings.h:241
std::string const & getName() const
Definition: ProcessBase.h:22
std::vector< FullMatchMemory * > fullmatch3_
Definition: FitTrack.h:50
std::string str() const
Definition: FPGAWord.cc:54
bool warnNoDer() const
Definition: Settings.h:186
constexpr unsigned int N_SEED_PROMPT
Definition: Settings.h:25
constexpr int N_LAYER
Definition: Settings.h:21
double rcrit() const
Definition: Settings.h:299