CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
tmtt::SimpleLR4 Class Reference

#include <SimpleLR4.h>

Inheritance diagram for tmtt::SimpleLR4:
tmtt::TrackFitGeneric

Public Member Functions

L1fittedTrack fit (const L1track3D &l1track3D) override
 
 SimpleLR4 (const Settings *settings)
 
 ~SimpleLR4 () override=default
 
- Public Member Functions inherited from tmtt::TrackFitGeneric
 TrackFitGeneric (const Settings *settings, const std::string &fitterName="")
 
virtual ~TrackFitGeneric ()=default
 

Protected Attributes

float chi2cut_
 
float chi2Mult_
 
float chosenRofPhi_
 
bool debug_
 
float denominatorMult_
 
bool digitize_
 
unsigned int dividerBitsChi2_
 
unsigned int dividerBitsHelix_
 
unsigned int dividerBitsHelixZ_
 
float invPtToDPhi_
 
unsigned int minStubLayersRed_
 
float numeratorLambdaMult_
 
float numeratorPhiMult_
 
float numeratorPtMult_
 
float numeratorZ0Mult_
 
float phiMult_
 
float phiNonantWidth_
 
float phiSectorCentre_
 
float phiSectorWidth_
 
float phiTMult_
 
float qOverPtMult_
 
float resMult_
 
float rTMult_
 
unsigned int shiftingBitsDenRPhi_
 
unsigned int shiftingBitsDenRZ_
 
unsigned int shiftingBitsLambda_
 
unsigned int shiftingBitsPhi_
 
unsigned int shiftingBitsPt_
 
unsigned int shiftingBitsz0_
 
float tanLambdaMult_
 
float z0Mult_
 
float zMult_
 
- Protected Attributes inherited from tmtt::TrackFitGeneric
const std::string fitterName_
 
const Settingssettings_
 

Detailed Description

Definition at line 20 of file SimpleLR4.h.

Constructor & Destructor Documentation

◆ SimpleLR4()

tmtt::SimpleLR4::SimpleLR4 ( const Settings settings)

Definition at line 21 of file SimpleLR4.cc.

References chi2cut_, chi2Mult_, tmtt::Settings::chosenRofPhi(), chosenRofPhi_, debug_, denominatorMult_, digitize_, tmtt::Settings::digitizeSLR(), tmtt::Settings::dividerBitsHelix(), dividerBitsHelix_, tmtt::Settings::dividerBitsHelixZ(), dividerBitsHelixZ_, tmtt::Settings::enableDigitize(), nano_mu_digi_cff::float, M_PI, numeratorLambdaMult_, numeratorPhiMult_, numeratorPtMult_, numeratorZ0Mult_, tmtt::Settings::numPhiNonants(), tmtt::Settings::numPhiSectors(), phiMult_, phiNonantWidth_, tmtt::Settings::phiSBits(), phiSectorWidth_, tmtt::Settings::phiSRange(), phiTMult_, conifer::pow(), qOverPtMult_, resMult_, tmtt::Settings::rtBits(), rTMult_, tmtt::Settings::rtRange(), tmtt::TrackFitGeneric::settings_, tmtt::Settings::ShiftingBitsDenRPhi(), shiftingBitsDenRPhi_, tmtt::Settings::ShiftingBitsDenRZ(), shiftingBitsDenRZ_, tmtt::Settings::ShiftingBitsLambda(), shiftingBitsLambda_, tmtt::Settings::ShiftingBitsPhi(), shiftingBitsPhi_, tmtt::Settings::ShiftingBitsPt(), shiftingBitsPt_, tmtt::Settings::ShiftingBitsZ0(), shiftingBitsz0_, tmtt::Settings::slr_chi2cut(), tmtt::Settings::slr_chisquaredBits(), tmtt::Settings::slr_chisquaredRange(), tmtt::Settings::slr_oneOver2rBits(), tmtt::Settings::slr_oneOver2rRange(), tmtt::Settings::slr_phi0Bits(), tmtt::Settings::slr_phi0Range(), tmtt::Settings::slr_tanlambdaBits(), tmtt::Settings::slr_tanlambdaRange(), tmtt::Settings::slr_z0Bits(), tmtt::Settings::slr_z0Range(), tanLambdaMult_, z0Mult_, tmtt::Settings::zBits(), zMult_, and tmtt::Settings::zRange().

21  : TrackFitGeneric(settings) {
22  // Initialize digitization parameters
25  zMult_ = pow(2., settings_->zBits()) / settings_->zRange();
28 
32 
39 
49 
52 
55  if (digitize_)
57 
58  debug_ = false; // Enable debug printout.
59  };
unsigned int slr_oneOver2rBits() const
Definition: Settings.h:351
unsigned int shiftingBitsz0_
Definition: SimpleLR4.h:59
unsigned int shiftingBitsPhi_
Definition: SimpleLR4.h:55
bool enableDigitize() const
Definition: Settings.h:80
float tanLambdaMult_
Definition: SimpleLR4.h:39
double slr_phi0Range() const
Definition: Settings.h:356
unsigned int numPhiNonants() const
Definition: Settings.h:109
float qOverPtMult_
Definition: SimpleLR4.h:36
float numeratorPhiMult_
Definition: SimpleLR4.h:43
double slr_chi2cut() const
ChiSquare Cut.
Definition: Settings.h:290
unsigned int shiftingBitsDenRZ_
Definition: SimpleLR4.h:57
float numeratorLambdaMult_
Definition: SimpleLR4.h:42
double phiSRange() const
Definition: Settings.h:84
float resMult_
Definition: SimpleLR4.h:46
unsigned int ShiftingBitsPt() const
Number of bits to reduce the qOverPt parameter numerator calculation weight.
Definition: Settings.h:282
constexpr int pow(int x)
Definition: conifer.h:24
unsigned int ShiftingBitsZ0() const
Number of bits to reduce the tanLambda parameter calculation weight.
Definition: Settings.h:288
unsigned int dividerBitsHelix() const
Number of bits to be used in hardware to compute the division needed to calculate the helix parameter...
Definition: Settings.h:274
double zRange() const
Definition: Settings.h:88
unsigned int ShiftingBitsDenRZ() const
Number of bits to reduce the RZ helix parameter denominator calculation weight.
Definition: Settings.h:280
unsigned int shiftingBitsLambda_
Definition: SimpleLR4.h:60
unsigned int phiSBits() const
Definition: Settings.h:83
float numeratorZ0Mult_
Definition: SimpleLR4.h:41
double slr_z0Range() const
Definition: Settings.h:358
float phiTMult_
Definition: SimpleLR4.h:37
float phiNonantWidth_
Definition: SimpleLR4.h:31
unsigned int zBits() const
Definition: Settings.h:87
unsigned int ShiftingBitsLambda() const
Number of bits to reduce the tanLambda parameter calculation weight.
Definition: Settings.h:286
float denominatorMult_
Definition: SimpleLR4.h:44
float chosenRofPhi_
Definition: SimpleLR4.h:49
const Settings * settings_
float phiMult_
Definition: SimpleLR4.h:33
unsigned int slr_chisquaredBits() const
Definition: Settings.h:361
unsigned int dividerBitsHelix_
Definition: SimpleLR4.h:52
unsigned int dividerBitsHelixZ_
Definition: SimpleLR4.h:53
unsigned int ShiftingBitsPhi() const
Number of bits to reduce the PhiT parameter numerator calculation weight.
Definition: Settings.h:284
double chosenRofPhi() const
Definition: Settings.h:112
#define M_PI
float numeratorPtMult_
Definition: SimpleLR4.h:40
double slr_oneOver2rRange() const
Definition: Settings.h:352
unsigned int shiftingBitsPt_
Definition: SimpleLR4.h:58
unsigned int slr_tanlambdaBits() const
Definition: Settings.h:359
unsigned int shiftingBitsDenRPhi_
Definition: SimpleLR4.h:56
double slr_chisquaredRange() const
Definition: Settings.h:362
double slr_tanlambdaRange() const
Definition: Settings.h:360
bool digitizeSLR() const
Definition: Settings.h:272
float chi2cut_
Definition: SimpleLR4.h:47
float phiSectorWidth_
Definition: SimpleLR4.h:29
TrackFitGeneric(const Settings *settings, const std::string &fitterName="")
float chi2Mult_
Definition: SimpleLR4.h:45
unsigned int slr_phi0Bits() const
Definition: Settings.h:355
unsigned int rtBits() const
Definition: Settings.h:85
unsigned int ShiftingBitsDenRPhi() const
Number of bits to reduce the RPhi helix parameter denominator calculation weight. ...
Definition: Settings.h:277
unsigned int dividerBitsHelixZ() const
Definition: Settings.h:275
unsigned int numPhiSectors() const
Definition: Settings.h:110
unsigned int slr_z0Bits() const
Definition: Settings.h:357
double rtRange() const
Definition: Settings.h:86

◆ ~SimpleLR4()

tmtt::SimpleLR4::~SimpleLR4 ( )
overridedefault

Member Function Documentation

◆ fit()

L1fittedTrack tmtt::SimpleLR4::fit ( const L1track3D l1track3D)
overridevirtual

Reimplemented from tmtt::TrackFitGeneric.

Definition at line 65 of file SimpleLR4.cc.

References funct::abs(), tmtt::L1fittedTrack::cellLocationFit(), tmtt::L1track3D::cellLocationHT(), tmtt::L1fittedTrack::cellLocationHT(), nano_mu_local_reco_cff::chi2, chi2cut_, chi2Mult_, tmtt::Settings::chosenRofPhi(), debug_, reco::deltaPhi(), bTagMiniDQMDeepCSV::denominator, denominatorMult_, tmtt::L1fittedTrack::digitaltrack(), digitize_, tmtt::L1fittedTrack::digitizeTrack(), dividerBitsHelix_, dividerBitsHelixZ_, tmtt::Settings::enableDigitize(), tmtt::L1track3D::eta(), tmtt::Utility::FIT, tmtt::Settings::houghMinPt(), tmtt::DigitalTrack::iDigi_phi0rel(), tmtt::DigitalStub::iDigi_PhiS(), tmtt::DigitalStub::iDigi_Rt(), tmtt::DigitalStub::iDigi_Z(), tmtt::L1track3D::iEtaReg(), createfilelist::int, tmtt::Settings::invPtToDphi(), invPtToDPhi_, tmtt::L1track3D::iPhiSec(), M_PI, tmtt::L1fittedTrack::matchedTP(), minStubLayersRed_, numeratorLambdaMult_, numeratorPhiMult_, numeratorPtMult_, numeratorZ0Mult_, tmtt::Utility::numLayerCut(), tmtt::L1fittedTrack::numLayers(), tmtt::Settings::numPhiSectors(), tmtt::DigitalTrack::oneOver2r(), tmtt::pair_compare(), tmtt::DigitalTrack::phi0(), tmtt::TP::phi0(), phiMult_, phiNonantWidth_, tmtt::DigitalStub::phiS(), tmtt::Settings::phiSBits(), phiSectorCentre_, phiSectorWidth_, phiTMult_, conifer::pow(), tmtt::TP::qOverPt(), tmtt::L1track3D::qOverPt(), tmtt::L1fittedTrack::qOverPt(), qOverPtMult_, tmtt::Settings::ResidualCut(), resMult_, tmtt::DigitalStub::rt_SF_TF(), tmtt::TrackFitGeneric::settings_, shiftingBitsDenRPhi_, shiftingBitsDenRZ_, shiftingBitsLambda_, shiftingBitsPhi_, shiftingBitsPt_, shiftingBitsz0_, tmtt::Settings::slr_phi0Bits(), tmtt::L1track3D::stubs(), tanLambdaMult_, tolerance, PixelMapPlotter::vRes, tmtt::DigitalStub::z(), and z0Mult_.

Referenced by trackingPlots.Iteration::modules().

65  {
66  if (debug_)
67  PrintL1trk() << "=============== FITTING SimpleLR TRACK ====================";
68 
70  settings_,
71  l1track3D.iPhiSec(),
72  l1track3D.iEtaReg(),
73  std::abs(l1track3D.qOverPt()),
74  l1track3D.eta());
75 
77 
78  double phiCentreSec0 = -0.5 * phiNonantWidth_ + 0.5 * phiSectorWidth_;
79  phiSectorCentre_ = phiSectorWidth_ * double(l1track3D.iPhiSec()) - phiCentreSec0;
80 
81  if (digitize_)
83 
84  // Inizialise track fit parameters
85  double qOverPt = 0.;
86  double phiT = 0.;
87  double phi0 = 0.;
88  double z0 = 0.;
89  double zT = 0.;
90  double tanLambda = 0.;
91 
92  // Inizialise Sums
93  double SumRPhi = 0.;
94  double SumR = 0.;
95  double SumPhi = 0.;
96  double SumR2 = 0.;
97  double SumRZ = 0.;
98  double SumZ = 0.;
99 
100  unsigned int numStubs = 0;
101  // Calc helix parameters on Rphi Plane (STEP 1)
102  // This loop calculates the sums needed to calculate the numerators and the denominator to compute the helix parameters in the R-Phi plane (q/pT, phiT)
103  for (Stub* stub : l1track3D.stubs()) {
104  numStubs++;
105 
106  if (digitize_) {
107  const DigitalStub* digiStub = stub->digitalStub();
108 
109  SumRPhi = SumRPhi + digiStub->rt_SF_TF() * digiStub->phiS();
110  SumR = SumR + digiStub->rt_SF_TF();
111  SumPhi = SumPhi + digiStub->phiS();
112  SumR2 = SumR2 + digiStub->rt_SF_TF() * digiStub->rt_SF_TF();
113  if (debug_)
114  PrintL1trk() << "Input stub (digi): phiS " << digiStub->iDigi_PhiS() << " rT " << digiStub->iDigi_Rt()
115  << " z " << digiStub->iDigi_Z();
116  } else {
117  float phi = 0;
118  if (l1track3D.iPhiSec() == 0 and stub->phi() > 0) {
119  phi = stub->phi() - 2 * M_PI;
120  } else if (l1track3D.iPhiSec() == settings_->numPhiSectors() and stub->phi() < 0) {
121  phi = stub->phi() + 2 * M_PI;
122  } else {
123  phi = stub->phi();
124  }
125  SumRPhi = SumRPhi + stub->r() * phi;
126  SumR = SumR + stub->r();
127  SumPhi = SumPhi + phi;
128  SumR2 = SumR2 + stub->r() * stub->r();
129  if (debug_)
130  PrintL1trk() << "InputStub (float): phi " << phi << " r " << stub->r() << " z " << stub->z();
131  }
132  }
133 
134  double numeratorPt, digiNumeratorPt;
135  double denominator, digiDenominator;
136  double numeratorPhi, digiNumeratorPhi;
137  double reciprocal, digiReciprocal;
138  double numeratorZ0;
139  double numeratorLambda;
140 
141  digiNumeratorPt = (numStubs * SumRPhi - SumR * SumPhi);
142  digiDenominator = (numStubs * SumR2 - SumR * SumR);
143  digiNumeratorPhi = (SumR2 * SumPhi - SumR * SumRPhi);
144 
145  if (!digitize_) {
146  qOverPt = (numStubs * SumRPhi - SumR * SumPhi) / (numStubs * SumR2 - SumR * SumR);
147  phi0 = (SumR2 * SumPhi - SumR * SumRPhi) / (numStubs * SumR2 - SumR * SumR);
148  } else {
149  digiNumeratorPt /= pow(2., shiftingBitsPt_);
150  digiNumeratorPt = floor(digiNumeratorPt * numeratorPtMult_);
151  numeratorPt = digiNumeratorPt / numeratorPtMult_;
152 
153  digiNumeratorPhi /= pow(2., shiftingBitsPhi_);
154  digiNumeratorPhi = floor(digiNumeratorPhi * numeratorPhiMult_);
155  numeratorPhi = digiNumeratorPhi / numeratorPhiMult_;
156 
157  digiDenominator /= pow(2., shiftingBitsDenRPhi_);
158  digiDenominator = (floor(digiDenominator * denominatorMult_) + 0.5);
159  denominator = digiDenominator / denominatorMult_;
160  digiReciprocal = (pow(2., dividerBitsHelix_) - 1) / (denominator); // To be moved
161  digiReciprocal = floor(digiReciprocal / denominatorMult_);
162  reciprocal = digiReciprocal * denominatorMult_;
163 
164  qOverPt = numeratorPt * reciprocal / pow(2., dividerBitsHelix_ + shiftingBitsDenRPhi_ - shiftingBitsPt_);
165  phiT = numeratorPhi * reciprocal / pow(2., dividerBitsHelix_ + shiftingBitsDenRPhi_ - shiftingBitsPhi_);
166 
167  qOverPt = floor(qOverPt * qOverPtMult_) / (qOverPtMult_);
168  phiT = floor(phiT * phiTMult_) / phiTMult_;
169  }
170 
171  if (debug_) {
172  if (digitize_) {
173  PrintL1trk() << setw(10) << "Input helix (digi): qOverPt = " << qOverPt << " (" << floor(qOverPt * qOverPtMult_)
174  << "), phiT = " << phiT << " (" << floor(phiT * phiTMult_) << ") ";
175  } else {
176  PrintL1trk() << "Input Helix (float): qOverPt = " << qOverPt << " phi0 " << phi0;
177  }
178  }
179 
180  // ================== RESIDUAL CALCULATION ON RPHI ========================
181  std::vector<std::pair<Stub*, double> > vRes;
182  unsigned int psStubs = 0;
183  for (Stub* stub : l1track3D.stubs()) {
184  if (stub->psModule())
185  psStubs++;
186  double ResPhi;
187 
188  if (digitize_) {
189  const DigitalStub* digiStub = stub->digitalStub();
190 
191  ResPhi =
192  digiStub->iDigi_PhiS() * pow(2., shiftingBitsDenRPhi_ - shiftingBitsPt_) -
193  floor(phiT * phiTMult_) *
195  floor(qOverPt * qOverPtMult_) * digiStub->iDigi_Rt();
196 
197  ResPhi = floor(ResPhi) / resMult_;
198  }
199 
200  else {
201  ResPhi = reco::deltaPhi(stub->phi(), phi0 + qOverPt * stub->r());
202  }
203 
204  double Res = std::abs(ResPhi);
205 
206  std::pair<Stub*, double> ResStubPair(stub, Res);
207  vRes.push_back(ResStubPair);
208  if (debug_) {
209  if (stub->assocTP() != nullptr)
210  PrintL1trk() << " Stub rphi residual " << Res << " TP " << stub->assocTP()->index();
211  else
212  PrintL1trk() << " Stub rphi residual " << Res << " TP nullptr";
213  }
214  }
215 
216  double largestResidual = 9999.;
217  // Find largest residuals
218  while (vRes.size() > minStubLayersRed_ and largestResidual > settings_->ResidualCut()) {
219  std::vector<std::pair<Stub*, double> >::iterator maxResIt = max_element(vRes.begin(), vRes.end(), pair_compare);
220  largestResidual = (*maxResIt).second;
221  if (debug_)
222  PrintL1trk() << "Largest Residual " << largestResidual;
223 
224  if (largestResidual > settings_->ResidualCut()) {
225  if ((*maxResIt).first->psModule()) {
226  if (psStubs > 2) {
227  if (debug_)
228  PrintL1trk() << "removing PS residual " << (*maxResIt).second;
229  vRes.erase(maxResIt);
230  psStubs--;
231  } else {
232  if (debug_)
233  PrintL1trk() << "residual " << (*maxResIt).second << " set to -1. ";
234  (*maxResIt).second = -1.;
235  }
236  } else {
237  vRes.erase(maxResIt);
238  if (debug_)
239  PrintL1trk() << "removing residual " << (*maxResIt).second;
240  }
241  }
242  }
243 
244  std::vector<Stub*> fitStubs;
245  fitStubs.reserve(vRes.size());
246  for (std::pair<Stub*, double> ResStubPair : vRes) {
247  fitStubs.push_back(ResStubPair.first);
248  }
249 
250  phiT = 0.;
251  zT = 0.;
252 
253  SumRPhi = 0.;
254  SumR = 0.;
255  SumPhi = 0.;
256  SumR2 = 0.;
257  SumRZ = 0.;
258  SumZ = 0.;
259  double SumR_ps = 0.;
260  double SumR2_ps = 0.;
261 
262  numStubs = 0;
263  psStubs = 0;
264 
265  for (const Stub* stub : fitStubs) {
266  if (stub->psModule())
267  psStubs++;
268 
269  numStubs++;
270  if (digitize_) {
271  const DigitalStub* digiStub = stub->digitalStub();
272  SumRPhi += digiStub->rt_SF_TF() * digiStub->phiS();
273  SumR += digiStub->rt_SF_TF();
274  SumPhi += digiStub->phiS();
275  SumR2 += digiStub->rt_SF_TF() * digiStub->rt_SF_TF();
276  if (stub->psModule()) {
277  SumRZ += digiStub->rt_SF_TF() * digiStub->z();
278  SumZ += digiStub->z();
279  SumR_ps += digiStub->rt_SF_TF();
280  SumR2_ps += digiStub->rt_SF_TF() * digiStub->rt_SF_TF();
281  }
282  if (debug_) {
283  PrintL1trk() << "phiS " << digiStub->iDigi_PhiS() << " rT " << digiStub->iDigi_Rt() << " z "
284  << digiStub->iDigi_Z();
285  }
286  } else {
287  float phi = 0;
288  if (l1track3D.iPhiSec() == 0 and stub->phi() > 0) {
289  phi = stub->phi() - 2 * M_PI;
290  } else if (l1track3D.iPhiSec() == settings_->numPhiSectors() and stub->phi() < 0) {
291  phi = stub->phi() + 2 * M_PI;
292  } else {
293  phi = stub->phi();
294  }
295 
296  SumRPhi += stub->r() * phi;
297  SumR += stub->r();
298  SumPhi += phi;
299  SumR2 += stub->r() * stub->r();
300  if (stub->psModule()) {
301  SumRZ += stub->r() * stub->z();
302  SumZ += stub->z();
303  SumR_ps += stub->r();
304  SumR2_ps += stub->r() * stub->r();
305  }
306  if (debug_)
307  PrintL1trk() << "phi " << phi << " r " << stub->r() << " z " << stub->z();
308  }
309  }
310 
311  numeratorZ0 = (SumR2_ps * SumZ - SumR_ps * SumRZ);
312  numeratorLambda = (psStubs * SumRZ - SumR_ps * SumZ);
313  numeratorPt = (numStubs * SumRPhi - SumR * SumPhi);
314  denominator = (numStubs * SumR2 - SumR * SumR);
315  double denominatorZ = (psStubs * SumR2_ps - SumR_ps * SumR_ps);
316  numeratorPhi = (SumR2 * SumPhi - SumR * SumRPhi);
317  double reciprocalZ;
318  if (!digitize_) {
319  z0 = numeratorZ0 / denominatorZ;
320  tanLambda = numeratorLambda / denominatorZ;
321  qOverPt = (numStubs * SumRPhi - SumR * SumPhi) / (numStubs * SumR2 - SumR * SumR);
322  phi0 = (SumR2 * SumPhi - SumR * SumRPhi) / (numStubs * SumR2 - SumR * SumR);
323  } else {
324  numeratorPt /= pow(2., shiftingBitsPt_);
325  numeratorPt = floor(numeratorPt * numeratorPtMult_) / numeratorPtMult_;
326 
327  numeratorPhi /= pow(2., shiftingBitsPhi_);
328  numeratorPhi = floor(numeratorPhi * numeratorPhiMult_) / numeratorPhiMult_;
329 
330  numeratorLambda /= pow(2., shiftingBitsLambda_);
331  numeratorLambda = floor(numeratorLambda * numeratorLambdaMult_) / numeratorLambdaMult_;
332 
333  numeratorZ0 /= pow(2., shiftingBitsz0_);
334  numeratorZ0 = floor(numeratorZ0 * numeratorZ0Mult_) / numeratorZ0Mult_;
335 
338  reciprocal = (pow(2., dividerBitsHelix_) - 1) / (denominator);
339  reciprocal = floor(reciprocal / denominatorMult_) * denominatorMult_;
340 
341  denominatorZ /= pow(2., shiftingBitsDenRZ_);
342  denominatorZ = (floor(denominatorZ * denominatorMult_) + 0.5) / denominatorMult_;
343  reciprocalZ = (pow(2., dividerBitsHelixZ_) - 1) / (denominatorZ);
344  reciprocalZ = floor(reciprocalZ / denominatorMult_) * denominatorMult_;
345 
346  qOverPt = numeratorPt * reciprocal / pow(2., dividerBitsHelix_ + shiftingBitsDenRPhi_ - shiftingBitsPt_);
347  phiT = numeratorPhi * reciprocal / pow(2., dividerBitsHelix_ + shiftingBitsDenRPhi_ - shiftingBitsPhi_);
348 
349  tanLambda =
350  numeratorLambda * reciprocalZ / pow(2., dividerBitsHelixZ_ + shiftingBitsDenRZ_ - shiftingBitsLambda_);
351  zT = numeratorZ0 * reciprocalZ / pow(2., dividerBitsHelixZ_ + shiftingBitsDenRZ_ - shiftingBitsz0_);
352 
353  phi0 = phiSectorCentre_ + phiT - qOverPt * settings_->chosenRofPhi();
354  z0 = zT - tanLambda * settings_->chosenRofPhi();
355 
356  qOverPt = floor(qOverPt * qOverPtMult_) / qOverPtMult_;
357  phiT = floor(phiT * phiTMult_) / phiTMult_;
358  }
359 
360  if (debug_ and digitize_) {
361  PrintL1trk() << "HT mbin " << int(l1track3D.cellLocationHT().first) - 16 << " cbin "
362  << int(l1track3D.cellLocationHT().second) - 32 << " iPhi " << l1track3D.iPhiSec() << " iEta "
363  << l1track3D.iEtaReg();
364  PrintL1trk() << "Second Helix variables: numeratorPt = " << numeratorPt << ", numeratorPhi = " << numeratorPhi
365  << ", numeratorZ0 = " << numeratorZ0 << " numeratorLambda = " << numeratorLambda
366  << " denominator = " << denominator << " reciprocal = " << reciprocal
367  << " denominatorZ = " << denominatorZ << " reciprocalZ = " << reciprocalZ;
368  PrintL1trk() << setw(10) << "Final Helix parameters: qOverPt = " << qOverPt << " ("
369  << floor(qOverPt * qOverPtMult_) << "), phiT = " << phiT << " (" << floor(phiT * phiTMult_)
370  << "), zT = " << zT << " (" << floor(zT * z0Mult_) << "), tanLambda = " << tanLambda << " ("
371  << floor(tanLambda * tanLambdaMult_) << ")"
372  << " z0 " << z0;
373  } else if (debug_) {
374  PrintL1trk() << setw(10) << "Final Helix parameters: qOverPt = " << qOverPt << ", phi0 = " << phi0
375  << ", z0 = " << z0 << ", tanLambda = " << tanLambda;
376  }
377 
378  double chi2_phi = 0.;
379  double chi2_z = 0.;
380 
381  for (const Stub* stub : fitStubs) {
382  double ResPhi = 0.;
383  double ResZ = 0.;
384  if (digitize_) {
385  const DigitalStub* digiStub = stub->digitalStub();
386  ResPhi = digiStub->phiS() - phiT - qOverPt * digiStub->rt_SF_TF();
387  ResZ = digiStub->z() - zT - tanLambda * digiStub->rt_SF_TF();
388  } else {
389  ResPhi = reco::deltaPhi(stub->phi(), phi0 + qOverPt * stub->r());
390  ResZ = stub->z() - z0 - tanLambda * stub->r();
391  }
392 
393  double RPhiSigma = 0.0002;
394  float RZSigma = stub->sigmaZ() + std::abs(tanLambda) * stub->sigmaR();
395 
396  if (not stub->barrel())
397  RPhiSigma = 0.0004;
398 
399  if (digitize_) {
400  RPhiSigma = floor(RPhiSigma * phiMult_) / phiMult_;
401  }
402 
403  ResPhi /= RPhiSigma;
404  ResZ /= RZSigma;
405 
406  chi2_phi += std::abs(ResPhi * ResPhi);
407  chi2_z += std::abs(ResZ * ResZ);
408  if (debug_) {
409  PrintL1trk() << "Stub ResPhi " << ResPhi * RPhiSigma << " ResSigma " << RPhiSigma << " Res " << ResPhi
410  << " chi2 " << chi2_phi;
411  PrintL1trk() << "Stub ResZ " << ResZ * RZSigma << " ResSigma " << RZSigma << " Res " << ResZ << " chi2 "
412  << chi2_z;
413  }
414  }
415  qOverPt /= invPtToDPhi_;
416 
417  bool accepted = false;
418 
419  //double chi2 = chi2_phi; // Ignore r-z residuals due to poor 2S resolution?
420  double chi2 = chi2_phi + chi2_z;
421  if (digitize_)
422  chi2 = floor(chi2 * chi2Mult_) / chi2Mult_;
423 
424  constexpr unsigned int nHelixPar = 4;
425  float dof = 2 * fitStubs.size() - nHelixPar;
426  float chi2dof = chi2 / dof;
427  if (chi2 < chi2cut_)
428  accepted = true;
429 
430  if (debug_)
431  PrintL1trk() << "qOverPt " << qOverPt << " phiT " << phiT;
432 
433  // This condition can only happen if cfg param TrackFitCheat = True.
434  if (fitStubs.size() < minStubLayersRed_)
435  accepted = false;
436 
437  // Kinematic cuts -- NOT YET IN FIRMWARE!!!
438  constexpr float tolerance = 0.1;
439  if (std::abs(qOverPt) > 1. / (settings_->houghMinPt() - tolerance))
440  accepted = false;
441  if (std::abs(z0) > 20.)
442  accepted = false;
443 
444  if (accepted) {
445  // Create the L1fittedTrack object
446  const unsigned int hitPattern = 0; // FIX: Needs setting
447  L1fittedTrack fitTrk(
448  settings_, &l1track3D, fitStubs, hitPattern, qOverPt, 0., phi0, z0, tanLambda, chi2_phi, chi2_z, nHelixPar);
449 
450  if (settings_->enableDigitize())
451  fitTrk.digitizeTrack("SimpleLR4");
452 
453  if (debug_ and digitize_) {
454  PrintL1trk() << "Digitized parameters ";
455  PrintL1trk() << "HT mbin " << int(l1track3D.cellLocationHT().first) - 16 << " cbin "
456  << int(l1track3D.cellLocationHT().second) - 32 << " iPhi " << l1track3D.iPhiSec() << " iEta "
457  << l1track3D.iEtaReg();
458  PrintL1trk() << setw(10) << "First Helix parameters: qOverPt = " << fitTrk.qOverPt() << " oneOver2r "
459  << fitTrk.digitaltrack()->oneOver2r() << " ("
460  << floor(fitTrk.digitaltrack()->oneOver2r() * qOverPtMult_)
461  << "), phi0 = " << fitTrk.digitaltrack()->phi0() << " (" << fitTrk.digitaltrack()->iDigi_phi0rel()
462  << "), zT = " << zT << " (" << floor(zT * z0Mult_) << "), tanLambda = " << tanLambda << " ("
463  << floor(tanLambda * tanLambdaMult_) << ")";
464  }
465 
466  if (debug_) {
467  PrintL1trk() << "FitTrack helix parameters " << int(fitTrk.cellLocationFit().first) - 16 << ", "
468  << int(fitTrk.cellLocationFit().second) - 32 << " HT parameters "
469  << int(fitTrk.cellLocationHT().first) - 16 << ", " << int(fitTrk.cellLocationHT().second) - 32;
470 
471  if (fitTrk.matchedTP() != nullptr) {
472  PrintL1trk() << "True track: chi2/ndf " << chi2dof;
473  PrintL1trk() << "TP qOverPt " << fitTrk.matchedTP()->qOverPt() << " phi0 " << fitTrk.matchedTP()->phi0();
474  if (!accepted)
475  PrintL1trk() << "Track rejected " << chi2 << " chi2/ndof " << chi2dof;
476  } else {
477  PrintL1trk() << "Fake track!!! " << chi2 << " chi2/ndof " << chi2dof;
478  }
479  PrintL1trk() << "layers in track " << fitTrk.numLayers();
480  }
481 
482  return fitTrk;
483 
484  } else {
485  L1fittedTrack rejectedTrk;
486  return rejectedTrk;
487  }
488  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
double invPtToDphi() const
Definition: Settings.h:397
unsigned int shiftingBitsz0_
Definition: SimpleLR4.h:59
unsigned int shiftingBitsPhi_
Definition: SimpleLR4.h:55
bool enableDigitize() const
Definition: Settings.h:80
float tanLambdaMult_
Definition: SimpleLR4.h:39
float qOverPtMult_
Definition: SimpleLR4.h:36
float numeratorPhiMult_
Definition: SimpleLR4.h:43
const double tolerance
unsigned int shiftingBitsDenRZ_
Definition: SimpleLR4.h:57
float numeratorLambdaMult_
Definition: SimpleLR4.h:42
float resMult_
Definition: SimpleLR4.h:46
constexpr int pow(int x)
Definition: conifer.h:24
unsigned int minStubLayersRed_
Definition: SimpleLR4.h:50
unsigned int shiftingBitsLambda_
Definition: SimpleLR4.h:60
unsigned int phiSBits() const
Definition: Settings.h:83
float numeratorZ0Mult_
Definition: SimpleLR4.h:41
static bool pair_compare(std::pair< const Stub *, float > a, std::pair< const Stub *, float > b)
Definition: SimpleLR4.cc:61
float invPtToDPhi_
Definition: SimpleLR4.h:48
float phiTMult_
Definition: SimpleLR4.h:37
float phiNonantWidth_
Definition: SimpleLR4.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float denominatorMult_
Definition: SimpleLR4.h:44
const Settings * settings_
float phiMult_
Definition: SimpleLR4.h:33
unsigned int dividerBitsHelix_
Definition: SimpleLR4.h:52
unsigned int dividerBitsHelixZ_
Definition: SimpleLR4.h:53
double chosenRofPhi() const
Definition: Settings.h:112
#define M_PI
float numeratorPtMult_
Definition: SimpleLR4.h:40
unsigned int shiftingBitsPt_
Definition: SimpleLR4.h:58
unsigned int shiftingBitsDenRPhi_
Definition: SimpleLR4.h:56
double ResidualCut() const
Cut on RPhi Residual (radians)
Definition: Settings.h:292
double houghMinPt() const
Definition: Settings.h:135
float chi2cut_
Definition: SimpleLR4.h:47
float phiSectorWidth_
Definition: SimpleLR4.h:29
float chi2Mult_
Definition: SimpleLR4.h:45
unsigned int slr_phi0Bits() const
Definition: Settings.h:355
unsigned int numLayerCut(Utility::AlgoStep algo, const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, float invPt, float eta=0.)
Definition: Utility.cc:141
unsigned int numPhiSectors() const
Definition: Settings.h:110
float phiSectorCentre_
Definition: SimpleLR4.h:30

Member Data Documentation

◆ chi2cut_

float tmtt::SimpleLR4::chi2cut_
protected

Definition at line 47 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ chi2Mult_

float tmtt::SimpleLR4::chi2Mult_
protected

Definition at line 45 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ chosenRofPhi_

float tmtt::SimpleLR4::chosenRofPhi_
protected

Definition at line 49 of file SimpleLR4.h.

Referenced by SimpleLR4().

◆ debug_

bool tmtt::SimpleLR4::debug_
protected

Definition at line 63 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ denominatorMult_

float tmtt::SimpleLR4::denominatorMult_
protected

Definition at line 44 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ digitize_

bool tmtt::SimpleLR4::digitize_
protected

Definition at line 61 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ dividerBitsChi2_

unsigned int tmtt::SimpleLR4::dividerBitsChi2_
protected

Definition at line 54 of file SimpleLR4.h.

◆ dividerBitsHelix_

unsigned int tmtt::SimpleLR4::dividerBitsHelix_
protected

Definition at line 52 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ dividerBitsHelixZ_

unsigned int tmtt::SimpleLR4::dividerBitsHelixZ_
protected

Definition at line 53 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ invPtToDPhi_

float tmtt::SimpleLR4::invPtToDPhi_
protected

Definition at line 48 of file SimpleLR4.h.

Referenced by fit().

◆ minStubLayersRed_

unsigned int tmtt::SimpleLR4::minStubLayersRed_
protected

Definition at line 50 of file SimpleLR4.h.

Referenced by fit().

◆ numeratorLambdaMult_

float tmtt::SimpleLR4::numeratorLambdaMult_
protected

Definition at line 42 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ numeratorPhiMult_

float tmtt::SimpleLR4::numeratorPhiMult_
protected

Definition at line 43 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ numeratorPtMult_

float tmtt::SimpleLR4::numeratorPtMult_
protected

Definition at line 40 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ numeratorZ0Mult_

float tmtt::SimpleLR4::numeratorZ0Mult_
protected

Definition at line 41 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ phiMult_

float tmtt::SimpleLR4::phiMult_
protected

Definition at line 33 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ phiNonantWidth_

float tmtt::SimpleLR4::phiNonantWidth_
protected

Definition at line 31 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ phiSectorCentre_

float tmtt::SimpleLR4::phiSectorCentre_
protected

Definition at line 30 of file SimpleLR4.h.

Referenced by fit().

◆ phiSectorWidth_

float tmtt::SimpleLR4::phiSectorWidth_
protected

Definition at line 29 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ phiTMult_

float tmtt::SimpleLR4::phiTMult_
protected

Definition at line 37 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ qOverPtMult_

float tmtt::SimpleLR4::qOverPtMult_
protected

Definition at line 36 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ resMult_

float tmtt::SimpleLR4::resMult_
protected

Definition at line 46 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ rTMult_

float tmtt::SimpleLR4::rTMult_
protected

Definition at line 34 of file SimpleLR4.h.

Referenced by SimpleLR4().

◆ shiftingBitsDenRPhi_

unsigned int tmtt::SimpleLR4::shiftingBitsDenRPhi_
protected

Definition at line 56 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ shiftingBitsDenRZ_

unsigned int tmtt::SimpleLR4::shiftingBitsDenRZ_
protected

Definition at line 57 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ shiftingBitsLambda_

unsigned int tmtt::SimpleLR4::shiftingBitsLambda_
protected

Definition at line 60 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ shiftingBitsPhi_

unsigned int tmtt::SimpleLR4::shiftingBitsPhi_
protected

Definition at line 55 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ shiftingBitsPt_

unsigned int tmtt::SimpleLR4::shiftingBitsPt_
protected

Definition at line 58 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ shiftingBitsz0_

unsigned int tmtt::SimpleLR4::shiftingBitsz0_
protected

Definition at line 59 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ tanLambdaMult_

float tmtt::SimpleLR4::tanLambdaMult_
protected

Definition at line 39 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ z0Mult_

float tmtt::SimpleLR4::z0Mult_
protected

Definition at line 38 of file SimpleLR4.h.

Referenced by fit(), and SimpleLR4().

◆ zMult_

float tmtt::SimpleLR4::zMult_
protected

Definition at line 35 of file SimpleLR4.h.

Referenced by SimpleLR4().