ATLAS Offline Software
FitParameters.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  local parameter values used during fitter
7  ***************************************************************************/
8 
10 
11 #include <cmath>
12 #include <iomanip>
13 #include <iostream>
14 
15 #include "GaudiKernel/MsgStream.h"
16 #include "GaudiKernel/SystemOfUnits.h"
20 #include "TrkSurfaces/Surface.h"
23 
24 namespace Trk {
25 
27  : m_cosPhi1(0.),
28  m_cosTheta1(0.),
29  m_d0(perigee.parameters()[Trk::d0]),
30  m_differences{},
31  m_extremeMomentum(false),
32  m_finalCovariance(nullptr),
33  m_firstAlignmentParameter(0),
34  m_firstScatteringParameter(0),
35  m_fitEnergyDeposit(false),
36  m_fitMomentum(true),
37  m_fullCovariance(nullptr),
38  m_minEnergyDeposit(0.),
39  m_numberAlignments(0),
40  m_numberOscillations(0),
41  m_numberParameters(0),
42  m_numberScatterers(0),
43  m_oldDifference(0.),
44  m_perigee(&perigee),
45  m_phiInstability(false),
46  m_qOverP1(0.),
47  m_sinPhi1(0.),
48  m_sinTheta1(0.),
49  m_surface(&perigee.associatedSurface()),
50  m_vertex(perigee.associatedSurface().center()),
51  m_z0(perigee.position().z()) {
52  Amg::Vector3D momentum = perigee.momentum();
53  double ptInv0 = 1. / momentum.perp();
54  m_cosPhi = ptInv0 * momentum.x();
55  m_sinPhi = ptInv0 * momentum.y();
56  m_cotTheta = ptInv0 * momentum.z();
57  m_sinTheta = 1. / std::sqrt(1. + m_cotTheta * m_cotTheta);
58  m_cosTheta = m_cotTheta * m_sinTheta;
59  m_qOverP = perigee.charge() * ptInv0 * m_sinTheta;
60  m_position = Amg::Vector3D(m_vertex.x() - m_d0 * m_sinPhi,
61  m_vertex.y() + m_d0 * m_cosPhi, m_z0);
62 }
63 
64 FitParameters::FitParameters(double d0, double z0, double cosPhi, double sinPhi,
65  double cotTheta, double ptInv0,
66  const PerigeeSurface& surface)
67  : m_cosPhi(cosPhi),
68  m_cosPhi1(0.),
69  m_cosTheta1(0.),
70  m_cotTheta(cotTheta),
71  m_d0(d0),
72  m_extremeMomentum(false),
73  m_finalCovariance(nullptr),
74  m_firstAlignmentParameter(0),
75  m_firstScatteringParameter(0),
76  m_fitEnergyDeposit(false),
77  m_fitMomentum(true),
78  m_fullCovariance(nullptr),
79  m_minEnergyDeposit(0.),
80  m_numberAlignments(0),
81  m_numberOscillations(0),
82  m_numberParameters(0),
83  m_numberScatterers(0),
84  m_oldDifference(0.),
85  m_perigee(nullptr),
86  m_phiInstability(false),
87  m_qOverP1(0.),
88  m_sinPhi(sinPhi),
89  m_sinPhi1(0.),
90  m_sinTheta1(0.),
91  m_surface(&surface),
92  m_vertex(surface.center()),
93  m_z0(z0) {
94  m_sinTheta = 1. / std::sqrt(1. + m_cotTheta * m_cotTheta);
97  m_z0 = z0;
99  m_vertex.y() + m_d0 * m_cosPhi, m_z0);
100 }
101 
102 
103 void FitParameters::addAlignment(bool constrained, double angle,
104  double offset) {
107  if (constrained) {
110  }
112 }
113 
114 void FitParameters::addScatterer(double phi, double theta) {
118 }
119 
120 const Surface* FitParameters::associatedSurface(void) const {
121  if (!m_perigee)
122  return nullptr;
123  return &m_perigee->associatedSurface();
124 }
125 
126 void FitParameters::covariance(Amg::MatrixX* finalCovariance,
127  const Amg::MatrixX* fullCovariance) {
130 }
131 
132 void FitParameters::d0(double value) {
133  m_d0 = value;
135  m_vertex.y() + m_d0 * m_cosPhi, m_z0);
136 }
137 
141 }
142 
143 void FitParameters::fitEnergyDeposit(double minEnergyDeposit) {
144  m_fitEnergyDeposit = true;
145  m_minEnergyDeposit = minEnergyDeposit;
146 }
147 
150 }
151 
156  0.);
157 }
158 
159 void FitParameters::numberAlignments(int numberAlignments) {
160  m_numberAlignments = 0;
162  return;
163  m_alignmentAngle = std::vector<double>(numberAlignments, 0.);
164  m_alignmentAngleConstraint = std::vector<double>(numberAlignments, 0.);
165  m_alignmentOffset = std::vector<double>(numberAlignments, 0.);
166  m_alignmentOffsetConstraint = std::vector<double>(numberAlignments, 0.);
167 }
168 
169 void FitParameters::numberParameters(int numberParameters) {
174 }
175 
176 void FitParameters::numberScatterers(int numberScatterers) {
177  m_numberScatterers = 0;
179  return;
180  m_scattererPhi = std::vector<double>(numberScatterers, 0.);
181  m_scattererTheta = std::vector<double>(numberScatterers, 0.);
182 }
183 
185  const Amg::VectorX& parameters) const {
187  difference(0, 0) = parameters(0) - m_d0;
188  difference(0, 1) = parameters(1) - m_z0;
189  difference(0, 2) = parameters(3) * m_cosPhi - parameters(2) * m_sinPhi;
190 
191  // FIXME: diff is now delta(theta) : check sign
192  // difference[0][3] = parameters[4] - m_cotTheta;
193  difference(0, 3) = std::sin(parameters(4)) * m_cosTheta -
196  return difference;
197 }
198 
199 void FitParameters::performCutStep(double cutStep) {
200  // revert parameters to previous parameter change with cutStep*value
201  // i.e. 0 < cutstep < 1 such that cutStep = 0 gives complete reversion
202 
203  Amg::VectorX cutDifferences(m_differences);
204  cutDifferences *= (cutStep - 1.);
205  Amg::VectorX oldDifferences(m_differences);
206  oldDifferences *= cutStep;
207 
208  // leave phi alone when unstable
209  if (m_phiInstability) {
210  cutDifferences(2) = 0.;
211  oldDifferences(2) = (m_differences)(2);
212  }
213 
214  // apply cut
215  update(cutDifferences);
216  m_differences = Amg::VectorX(oldDifferences);
217 
219  m_oldDifference = 0.;
220  // std::cout << " after cutstep " << std::endl;
221 }
222 
223 Perigee* FitParameters::perigee(void) const {
224  // copy 'final' covariance
226  double pT = std::abs(m_sinTheta / m_qOverP);
227  double charge = 1.;
228  if (m_qOverP < 0.)
229  charge = -1.;
231 
232  if (m_surface) {
233  return new Perigee(m_position, momentum, charge,
234  dynamic_cast<const Trk::PerigeeSurface&>(*m_surface),
235  std::move(covMatrix));
236  } else {
237  return new Perigee(m_position, momentum, charge, m_vertex,
238  std::move(covMatrix));
239  }
240 }
241 
242 bool FitParameters::phiInstability(void) const {
243  return m_phiInstability;
244 }
245 
246 void FitParameters::print(MsgStream& log) const {
247  log << std::setiosflags(std::ios::fixed | std::ios::right) << std::setw(16)
248  << std::setprecision(1) << m_position.perp() << " perigee radius"
249  << std::setw(10) << std::setprecision(3) << m_d0 << " d0" << std::setw(11)
250  << std::setprecision(3) << m_position.z() << " z0" << std::setw(11)
251  << std::setprecision(6) << std::atan2(m_sinPhi, m_cosPhi) << " phi"
252  << std::setw(11) << std::setprecision(6) << std::acos(m_cosTheta)
253  << " theta" << std::setw(13) << std::setprecision(3)
254  << m_sinTheta / (m_qOverP * Gaudi::Units::GeV) << " pT (GeV)";
255 }
256 
257 void FitParameters::printCovariance(MsgStream& log) const {
258  double error00 = 0.;
260  if (cov(0, 0) > 0.)
261  error00 = std::sqrt(cov(0, 0));
262  double error11 = 0.;
263  if (cov(1, 1) > 0.)
264  error11 = std::sqrt(cov(1, 1));
265  double error22 = 0.;
266  if (cov(2, 2) > 0.)
267  error22 = std::sqrt(cov(2, 2));
268  double error33 = 0.;
269  if (cov(3, 3) > 0.)
270  error33 = std::sqrt(cov(3, 3));
271  double error44 = 0.;
272  if (cov(4, 4) > 0.)
273  error44 = std::sqrt(cov(4, 4));
274  double correl02 = 0.;
275  double denom02 = cov(0, 0) * cov(2, 2);
276  if (denom02 > 0.)
277  correl02 = cov(0, 2) / std::sqrt(denom02);
278  double correl13 = 0.;
279  double denom13 = cov(1, 1) * cov(3, 3);
280  if (denom13 > 0.)
281  correl13 = cov(1, 3) / std::sqrt(denom13);
282  log << std::setiosflags(std::ios::fixed | std::ios::right) << std::setw(10)
283  << std::setprecision(3) << error00 << std::setw(14)
284  << std::setprecision(3) << error11 << std::setw(14)
285  << std::setprecision(6) << error22 << std::setw(15)
286  << std::setprecision(6) << error33 << std::setw(19)
287  << std::setprecision(3)
288  << (error44 * m_sinTheta) / (m_qOverP * m_qOverP * Gaudi::Units::GeV)
289  << " (covariance)" << std::setw(9) << std::setprecision(3) << correl02
290  << " Cd0phi" << std::setw(8) << std::setprecision(3) << correl13
291  << " Cz0theta" << std::endl;
292 }
293 
294 void FitParameters::printVerbose(MsgStream& log) const {
295  log << std::endl;
296 
297  if (m_differences.size() != 0) {
299  log << " dParams ====" << std::setiosflags(std::ios::fixed)
300  << std::setw(10) << std::setprecision(4) << differences(0) << " (0) "
301  << std::setw(10) << std::setprecision(4) << differences(1) << " (1) "
302  << std::setw(10) << std::setprecision(5) << differences(2) << " (2) "
303  << std::setw(10) << std::setprecision(5) << differences(3) << " (3) "
304  << std::setw(13) << std::setprecision(9)
305  << differences(4) * Gaudi::Units::GeV / Gaudi::Units::TeV << " (4) ";
306  if (m_fitEnergyDeposit)
307  log << std::setiosflags(std::ios::fixed) << std::setw(13)
308  << std::setprecision(9)
309  << differences(5) * Gaudi::Units::GeV / Gaudi::Units::TeV << " (5) ";
310  log << std::endl;
311 
312  if (m_numberAlignments) {
313  log << " dAlign ==== ";
314  unsigned param = m_firstAlignmentParameter;
315  for (int scat = 0; scat < m_numberAlignments; ++scat) {
316  ++param;
317  if (scat % 5 == 0 && scat > 0)
318  log << std::endl << " ";
319  log << std::setiosflags(std::ios::fixed) << std::setw(10)
320  << std::setprecision(6) << differences(param);
321  ++param;
322  log << std::setiosflags(std::ios::fixed) << std::setw(10)
323  << std::setprecision(6) << differences(param) << " ("
324  << std::setw(2) << scat << "A) ";
325  }
326  log << std::endl;
327  }
328 
329  if (m_numberScatterers) {
330  log << " dScat ==== ";
331  unsigned param = m_firstScatteringParameter;
332  for (int scat = 0; scat < m_numberScatterers; ++scat) {
333  ++param;
334  if (scat % 5 == 0 && scat > 0)
335  log << std::endl << " ";
336  log << std::setiosflags(std::ios::fixed) << std::setw(10)
337  << std::setprecision(6) << differences(param);
338  ++param;
339  log << std::setiosflags(std::ios::fixed) << std::setw(10)
340  << std::setprecision(6) << differences(param) << " ("
341  << std::setw(2) << scat << "S) ";
342  }
343  log << std::endl;
344  }
345  }
346 
347  log << std::setiosflags(std::ios::fixed | std::ios::right)
348  << " parameters: " << std::setw(12) << std::setprecision(4) << m_d0
349  << " transverse impact " << std::setw(10) << std::setprecision(4)
350  << m_position.z() << " z0 " << std::setw(10) << std::setprecision(6)
351  << std::atan2(m_sinPhi, m_cosPhi) << std::setw(10) << std::setprecision(6)
352  << m_cotTheta << " phi,cotTheta " << std::setw(13)
353  << std::setprecision(9) << m_qOverP / m_sinTheta << " inverse pT "
354  << std::setw(12) << std::setprecision(6)
355  << m_sinTheta / (m_qOverP * Gaudi::Units::GeV) << " signed pT ";
356  if (m_fitEnergyDeposit) {
357  // TODO: should give fitted energy loss
358  log << std::endl
359  << " E before/after energy deposit" << std::setw(12)
360  << std::setprecision(3) << 1. / std::abs(m_qOverP * Gaudi::Units::GeV)
361  << std::setw(12) << std::setprecision(3)
362  << 1. / std::abs(m_qOverP1 * Gaudi::Units::GeV);
363  }
364  if (m_numberAlignments) {
365  log << std::endl << " alignment number, angle, offset: ";
366  for (int align = 0; align < m_numberAlignments; ++align) {
367  log << std::setiosflags(std::ios::fixed) << std::setw(6) << align
368  << std::setw(10) << std::setprecision(6) << m_alignmentAngle[align]
369  << std::setw(10) << std::setprecision(6) << m_alignmentOffset[align];
370  if ((align + 1) % 5 == 0)
371  log << std::endl << " ";
372  }
373  }
374  if (m_numberScatterers) {
375  log << std::endl << " scatterer number, delta(phi), delta(theta): ";
376  for (int scat = 0; scat < m_numberScatterers; ++scat) {
377  log << std::setiosflags(std::ios::fixed) << std::setw(6) << scat
378  << std::setw(10) << std::setprecision(6) << m_scattererPhi[scat]
379  << std::setw(10) << std::setprecision(6) << m_scattererTheta[scat];
380  if ((scat + 1) % 5 == 0)
381  log << std::endl << " ";
382  }
383  }
384  log << std::endl;
385 }
386 
387 void FitParameters::qOverP(double value) {
388  m_qOverP = value;
389 }
390 
391 void FitParameters::qOverP1(double value) {
392  m_qOverP1 = value;
393 }
394 
396  // method is needed to complement copy in places where design uses
397  // a reference to a FitParameter pointer
398  // essentially a copy, with history of previous iteration removed
399  m_cosPhi = parameters.m_cosPhi;
400  m_cosPhi1 = parameters.m_cosPhi1;
401  m_cosTheta = parameters.m_cosTheta;
402  m_cosTheta1 = parameters.m_cosTheta1;
403  m_cotTheta = parameters.m_cotTheta;
404  m_d0 = parameters.m_d0;
405  m_extremeMomentum = parameters.m_extremeMomentum;
406  m_finalCovariance = parameters.m_finalCovariance;
407  m_firstScatteringParameter = parameters.m_firstScatteringParameter;
408  m_firstScatteringParameter = parameters.m_firstScatteringParameter;
409  m_fitEnergyDeposit = parameters.m_fitEnergyDeposit;
410  m_fitMomentum = parameters.m_fitMomentum;
411  m_fullCovariance = parameters.m_fullCovariance;
412  m_minEnergyDeposit = parameters.m_minEnergyDeposit;
413  m_numberAlignments = parameters.m_numberAlignments;
414  m_numberOscillations = parameters.m_numberOscillations;
415  m_numberParameters = parameters.m_numberParameters;
416  m_numberScatterers = parameters.m_numberScatterers;
417  m_oldDifference = parameters.m_oldDifference;
418  m_perigee = parameters.m_perigee;
419  m_phiInstability = parameters.m_phiInstability;
420  m_position = parameters.m_position;
421  m_qOverP = parameters.m_qOverP;
422  m_qOverP1 = parameters.m_qOverP1;
423  m_sinPhi = parameters.m_sinPhi;
424  m_sinPhi1 = parameters.m_sinPhi1;
425  m_sinTheta = parameters.m_sinTheta;
426  m_sinTheta1 = parameters.m_sinTheta1;
427  m_vertex = parameters.vertex();
428  m_z0 = parameters.m_z0;
429  for (int s = 0; s != m_numberAlignments; ++s) {
430  m_alignmentAngle[s] = parameters.m_alignmentAngle[s];
431  m_alignmentAngleConstraint[s] = parameters.m_alignmentAngleConstraint[s];
432  m_alignmentOffset[s] = parameters.m_alignmentOffset[s];
433  m_alignmentOffsetConstraint[s] = parameters.m_alignmentOffsetConstraint[s];
434  }
435  for (int s = 0; s != m_numberScatterers; ++s) {
436  m_scattererPhi[s] = parameters.m_scattererPhi[s];
437  m_scattererTheta[s] = parameters.m_scattererTheta[s];
438  }
439 
440  // restore difference history
441  if (parameters.m_differences.size() != 0) {
442  m_differences = Amg::VectorX(parameters.m_differences);
443  } else {
445  m_differences.setZero();
446  }
447 
449  m_oldDifference = 0.;
450 }
451 
452 ScatteringAngles FitParameters::scatteringAngles(
453  const FitMeasurement& fitMeasurement, int scatterer) const {
454  // scattering sigma used in chi2 computation
455  double scattererSigmaTheta = 1. / fitMeasurement.weight();
456  double scattererSigmaPhi =
457  scattererSigmaTheta /
458  fitMeasurement.intersection(FittedTrajectory).direction().perp();
459  if (scatterer < 0) {
460  return {0., 0., scattererSigmaPhi, scattererSigmaTheta};
461  } else {
462  return {m_scattererPhi[scatterer], m_scattererTheta[scatterer],
463  scattererSigmaPhi, scattererSigmaTheta};
464  }
465 }
466 
468  m_phiInstability = true;
469 }
470 
472  // create momentum
473  double pT = std::abs(m_sinTheta / m_qOverP);
474  double charge = 1.;
475  if (m_qOverP < 0.)
476  charge = -1.;
478 
479  return new Perigee(m_position, momentum, charge, m_vertex);
480 }
481 
483  MsgStream& log, const FitMeasurement& measurement, bool withCovariance) {
484  // make checks necessary for the TrackParameters to be computed
485  // 1) a Surface is required
486  if (!measurement.surface()) {
487  log << MSG::WARNING
488  << "FitParameters::trackParameters - measurement lacks Surface"
489  << endmsg;
490  return nullptr;
491  }
492 
493  // 2) a SurfaceIntersection is required
494  if (!measurement.hasIntersection(FittedTrajectory)) {
495  log << MSG::WARNING
496  << "FitParameters::trackParameters - invalid measurement" << endmsg;
497  return nullptr;
498  }
499 
500  // 3) the intersection position has to lie sufficiently close to the Surface
501  const TrackSurfaceIntersection& intersection =
502  measurement.intersection(FittedTrajectory);
503  Amg::Vector2D localPos;
504  if (!measurement.surface()->globalToLocal(
505  intersection.position(), intersection.direction(), localPos)) {
506  log << MSG::WARNING
507  << "FitParameters::trackParameters - globalToLocal failure" << endmsg;
508  return nullptr;
509  }
510 
511  // cache parameters at EnergyDeposit
512  if (measurement.isEnergyDeposit()) {
517  m_qOverP1 = measurement.qOverP();
518  }
519 
520  // propagate full covariance to form localCovariance
521  std::optional<AmgSymMatrix(5)> covMatrix = std::nullopt;
522  if (withCovariance && (measurement.isDrift() || measurement.isCluster() ||
523  measurement.isPerigee())) {
525  double sigma = 1. / measurement.weight();
526  double sigma2 = 1. / measurement.weight2();
527  int lastParameter = measurement.lastParameter();
528  Amg::MatrixX jacobian = Amg::MatrixX::Zero(5, lastParameter);
529  for (int i = 0; i != lastParameter; ++i) {
530  jacobian(0, i) = sigma * measurement.derivative(i);
531  jacobian(1, i) = sigma2 * measurement.derivative2(i);
532  }
533 
534  // phi,theta derivs into jac
535  jacobian(2, 2) = 1.;
536  jacobian(3, 3) = 1.;
538  while (++i < lastParameter) {
539  jacobian(2, i) = 1.;
540  ++i;
541  jacobian(3, i) = 1.;
542  }
543 
544  // only if fit to curvature
545  if (m_fitMomentum && m_qOverP) {
546  double sinTheta = direction.perp();
547  if (m_fitEnergyDeposit && measurement.afterCalo()) {
548  double deltaPhi =
549  (direction.y() * m_cosPhi1 - direction.x() * m_sinPhi1) / sinTheta;
550  double deltaTheta =
552  jacobian(0, 5) *= Gaudi::Units::TeV;
553  jacobian(1, 5) *= Gaudi::Units::TeV;
554  jacobian(2, 5) = deltaPhi / measurement.qOverP();
555  jacobian(3, 5) = deltaTheta / measurement.qOverP();
556  jacobian(4, 5) = measurement.qOverP() / m_qOverP1;
557  } else {
558  double deltaPhi =
559  (direction.y() * m_cosPhi - direction.x() * m_sinPhi) / sinTheta;
560  double deltaTheta =
562  jacobian(0, 4) *= Gaudi::Units::TeV;
563  jacobian(1, 4) *= Gaudi::Units::TeV;
564  jacobian(2, 4) = deltaPhi / measurement.qOverP();
565  jacobian(3, 4) = deltaTheta / measurement.qOverP();
566  jacobian(4, 4) = measurement.qOverP() / m_qOverP;
567  }
568  } else {
569  jacobian(4, 4) = 1.;
570  }
571 
572  // similarity transform
573  covMatrix = AmgSymMatrix(5)(
574  jacobian * m_fullCovariance->block(0, 0, lastParameter, lastParameter) *
575  jacobian.transpose());
576  }
577 
578  double phi = intersection.direction().phi();
579  double theta = intersection.direction().theta();
580  if (measurement.isFlipped()) {
581  if (phi > 0.) {
582  phi -= M_PI;
583  } else {
584  phi += M_PI;
585  }
586  theta = M_PI - theta;
587  }
588 
589  if (!measurement.surface()) {
590  log << MSG::WARNING
591  << "FitParameters::trackParameters - unrecognized surface" << endmsg;
592  return nullptr;
593  }
594  // finally can create the appropriate TrackParameters based on the surface
595  return measurement.surface()
596  ->createUniqueTrackParameters(localPos[locR], localPos[locZ], phi, theta,
597  measurement.qOverP(), std::move(covMatrix))
598  .release();
599 }
600 
601 void FitParameters::update(const Amg::VectorX& differences) {
602  // keep update values in case of cutStep procedure
605  } else {
607  }
610 
611  // misalignment parameters
614  int align = m_firstAlignmentParameter;
615  for (int i = 0; i != m_numberAlignments; ++i) {
616  (*a++) += differences(++align);
617  (*o++) += differences(++align);
618  }
619 
620  // scattering angles
623  int scat = m_firstScatteringParameter;
624  for (int i = 0; i != m_numberScatterers; ++i) {
625  (*p++) += differences(++scat);
626  (*t++) += differences(++scat);
627  }
628 
629  // qOverP, cotTheta
630  if (m_fitMomentum)
633 
634  // impose charge conservation and decreasing energy
635  if (m_fitEnergyDeposit) {
637  double deposit = 1. / std::abs(m_qOverP) - 1. / std::abs(m_qOverP1);
638  if (std::abs(deposit) < std::abs(m_minEnergyDeposit) ||
639  deposit * m_minEnergyDeposit < 0. || m_qOverP * m_qOverP1 < 0.) {
640  m_qOverP = 1. / (1. / std::abs(m_qOverP1) + m_minEnergyDeposit);
641  if (m_qOverP1 < 0.)
642  m_qOverP = -m_qOverP;
643  }
644  }
645 
646  // protect phi against some rounding instabilities
647  double sinDPhi = differences(2);
648  double cosDPhi = 0.;
649  if (std::abs(sinDPhi) < 1.0) {
650  cosDPhi = std::sqrt(1. - sinDPhi * sinDPhi);
651  } else {
652  if (sinDPhi > 0.) {
653  sinDPhi = 1.0;
654  } else {
655  sinDPhi = -1.0;
656  }
657  }
658 
659  double cosPhi = m_cosPhi * cosDPhi - m_sinPhi * sinDPhi;
660  m_sinPhi = m_sinPhi * cosDPhi + m_cosPhi * sinDPhi;
661  m_cosPhi = cosPhi;
662  m_z0 += differences(1);
663  m_d0 += differences(0);
664  m_sinTheta = 1. / std::sqrt(1. + m_cotTheta * m_cotTheta);
667  m_vertex.y() + m_d0 * m_cosPhi, m_z0);
668 }
669 
670 void FitParameters::update(Amg::Vector3D position, Amg::Vector3D direction,
671  double qOverP,
672  const Amg::MatrixX& leadingCovariance) {
673  // update parameters after leading material corrections
675  m_sinTheta = direction.perp();
676  double sinThetaInv = 1. / m_sinTheta;
677  m_cotTheta = sinThetaInv * m_cosTheta;
678  m_cosPhi = sinThetaInv * direction.x();
679  m_sinPhi = sinThetaInv * direction.y();
680  m_cotTheta = sinThetaInv * direction.z();
681  m_cosTheta = direction.z();
682  m_qOverP = qOverP;
683  m_z0 = position.z();
684  m_d0 = (m_vertex.x() - position.x()) * m_sinPhi -
685  (m_vertex.y() - position.y()) * m_cosPhi;
686 
687  // update covariance
688  // (*m_finalCovariance) += leadingCovariance; // ??
689  for (int i = 0; i != 5; ++i) {
690  for (int j = 0; j != 5; ++j) {
691  (*m_finalCovariance)(i, j) += leadingCovariance(i, j);
692  }
693  }
694 }
695 
696 } // namespace Trk
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Trk::FitParameters::m_perigee
const Perigee * m_perigee
Definition: FitParameters.h:138
Trk::FitParameters::m_cosTheta
double m_cosTheta
Definition: FitParameters.h:119
Trk::FitParameters::m_firstAlignmentParameter
int m_firstAlignmentParameter
Definition: FitParameters.h:127
Trk::FitMeasurement::intersection
const TrackSurfaceIntersection & intersection(ExtrapolationType type) const
Definition: FitMeasurement.h:359
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
Trk::FitParameters::m_scattererTheta
std::vector< double > m_scattererTheta
Definition: FitParameters.h:144
Trk::FitParameters::m_alignmentAngle
std::vector< double > m_alignmentAngle
Definition: FitParameters.h:113
ScatteringAngles.h
Trk::FitParameters::m_numberParameters
int m_numberParameters
Definition: FitParameters.h:135
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
Trk::FitParameters::m_scattererPhi
std::vector< double > m_scattererPhi
Definition: FitParameters.h:143
pdg_comparison.sigma
sigma
Definition: pdg_comparison.py:324
Trk::FitParameters::z0
double z0(void) const
Definition: FitParameters.h:289
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:30
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
Trk::FitParameters::m_alignmentOffsetConstraint
std::vector< double > m_alignmentOffsetConstraint
Definition: FitParameters.h:116
Trk::FitParameters::m_vertex
Amg::Vector3D m_vertex
Definition: FitParameters.h:150
Trk::FitParameters::m_sinTheta1
double m_sinTheta1
Definition: FitParameters.h:148
Trk::FitParameters::m_cosPhi1
double m_cosPhi1
Definition: FitParameters.h:118
Trk::FitMeasurement::hasIntersection
bool hasIntersection(ExtrapolationType type) const
Definition: FitMeasurement.h:355
Surface.h
Trk::FitParameters::fitMomentum
bool fitMomentum(void) const
Definition: FitParameters.h:225
Trk::FitParameters::direction
Amg::Vector3D direction(void) const
Definition: FitParameters.h:200
Trk::FitParameters::m_fitMomentum
bool m_fitMomentum
Definition: FitParameters.h:130
Trk::FitParameters::m_fullCovariance
const Amg::MatrixX * m_fullCovariance
Definition: FitParameters.h:131
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::FitParameters::m_z0
double m_z0
Definition: FitParameters.h:151
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
Trk::FitParameters::fitEnergyDeposit
bool fitEnergyDeposit(void) const
Definition: FitParameters.h:221
Trk::FitMeasurement::surface
const Surface * surface(void) const
Definition: FitMeasurement.h:585
Trk::FitMeasurement::isDrift
bool isDrift(void) const
Definition: FitMeasurement.h:373
Trk::FitParameters::print
void print(MsgStream &log) const
Definition: FitParameters.cxx:248
Trk::FitMeasurement::derivative
double derivative(int param) const
Definition: FitMeasurement.h:284
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::FitParameters::m_sinPhi
double m_sinPhi
Definition: FitParameters.h:145
Trk::FitParameters::sinTheta
double sinTheta(void) const
Definition: FitParameters.h:277
Trk::z0
@ z0
Definition: ParamDefs.h:64
athena.value
value
Definition: athena.py:124
Trk::FitParameters::m_sinPhi1
double m_sinPhi1
Definition: FitParameters.h:146
python.SystemOfUnits.TeV
int TeV
Definition: SystemOfUnits.py:158
Trk::TrackSurfaceIntersection
Definition: TrackSurfaceIntersection.h:32
Trk::FitParameters::m_cosTheta1
double m_cosTheta1
Definition: FitParameters.h:120
Trk::locR
@ locR
Definition: ParamDefs.h:44
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::FitParameters::setPhiInstability
void setPhiInstability(void)
Definition: FitParameters.cxx:469
Trk::Perigee
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:33
ParamDefs.h
Trk::FitParameters::ptInv0
double ptInv0(void) const
Definition: FitParameters.h:249
FitParameters.h
Trk::FitParameters::perigee
Perigee * perigee(void) const
Definition: FitParameters.cxx:225
Trk::FitParameters::m_minEnergyDeposit
double m_minEnergyDeposit
Definition: FitParameters.h:132
ExtrapolationType.h
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
Trk::FitParameters::qOverP1
double qOverP1(void) const
Definition: FitParameters.h:261
Trk::ParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
Trk::FitParameters::m_qOverP
double m_qOverP
Definition: FitParameters.h:141
Trk::FitParameters::numberScatterers
int numberScatterers(void) const
Definition: FitParameters.h:245
Trk::FitParameters::extremeMomentum
bool extremeMomentum(void) const
Definition: FitParameters.h:205
Trk::FitParameters::finalCovariance
const Amg::MatrixX * finalCovariance(void) const
Definition: FitParameters.h:209
Trk::FitParameters::numberParameters
int numberParameters(void) const
Definition: FitParameters.h:241
Trk::FitMeasurement::derivative2
double derivative2(int param) const
Definition: FitMeasurement.h:296
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::FitParameters::intersection
TrackSurfaceIntersection intersection(void) const
Definition: FitParameters.cxx:154
Trk::locZ
@ locZ
local cylindrical
Definition: ParamDefs.h:42
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
Trk::FitParameters::m_differences
Amg::VectorX m_differences
Definition: FitParameters.h:123
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::FitParameters::m_fitEnergyDeposit
bool m_fitEnergyDeposit
Definition: FitParameters.h:129
Trk::FitParameters::m_surface
const Surface * m_surface
Definition: FitParameters.h:149
Trk::TrackSurfaceIntersection::position
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.
Definition: TrackSurfaceIntersection.h:80
Trk::Surface::createUniqueTrackParameters
virtual ChargedTrackParametersUniquePtr createUniqueTrackParameters(double l1, double l2, double phi, double theat, double qop, std::optional< AmgSymMatrix(5)> cov=std::nullopt) const =0
Use the Surface as a ParametersBase constructor, from local parameters - charged.
Trk::FitParameters::printCovariance
void printCovariance(MsgStream &log) const
Definition: FitParameters.cxx:259
Trk::FitParameters::m_position
Amg::Vector3D m_position
Definition: FitParameters.h:140
Trk::FitMeasurement::weight2
double weight2(void) const
Definition: FitMeasurement.h:601
Trk::FitParameters::m_numberScatterers
int m_numberScatterers
Definition: FitParameters.h:136
Trk::theta
@ theta
Definition: ParamDefs.h:66
Trk::FitMeasurement
Definition: FitMeasurement.h:40
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
xAOD::covMatrix
covMatrix
Definition: TrackMeasurement_v1.cxx:19
Trk::FitParameters::m_d0
double m_d0
Definition: FitParameters.h:122
Trk::FitParameters::update
void update(const Amg::VectorX &differences)
Definition: FitParameters.cxx:603
Trk::FitParameters::position
const Amg::Vector3D & position(void) const
Definition: FitParameters.h:253
Trk::FitParameters::startingPerigee
Perigee * startingPerigee(void) const
Definition: FitParameters.cxx:473
Trk::FitParameters::difference
double difference(int param) const
Definition: FitParameters.h:188
Trk::FitParameters::qOverP
double qOverP(void) const
Definition: FitParameters.h:257
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::FitParameters::m_cosPhi
double m_cosPhi
Definition: FitParameters.h:117
Trk::FitParameters::cosPhi
double cosPhi(void) const
Definition: FitParameters.h:172
Trk::FitParameters::covariance
void covariance(Amg::MatrixX *finalCovariance, const Amg::MatrixX *fullCovariance)
Definition: FitParameters.cxx:128
Trk::FitParameters::m_sinTheta
double m_sinTheta
Definition: FitParameters.h:147
Trk::FitParameters::m_alignmentOffset
std::vector< double > m_alignmentOffset
Definition: FitParameters.h:115
Trk::FitParameters::trackParameters
TrackParameters * trackParameters(MsgStream &log, const FitMeasurement &measurement, bool withCovariance=false)
Definition: FitParameters.cxx:484
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::FitMeasurement::isEnergyDeposit
bool isEnergyDeposit(void) const
Definition: FitMeasurement.h:377
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
Trk::FitMeasurement::isCluster
bool isCluster(void) const
Definition: FitMeasurement.h:368
Trk::d0
@ d0
Definition: ParamDefs.h:63
Trk::FittedTrajectory
@ FittedTrajectory
Definition: ExtrapolationType.h:19
Trk::FitParameters::m_extremeMomentum
bool m_extremeMomentum
Definition: FitParameters.h:125
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Trk::FitMeasurement::afterCalo
bool afterCalo(void) const
Definition: FitMeasurement.h:243
Trk::FitParameters::m_numberAlignments
int m_numberAlignments
Definition: FitParameters.h:133
Trk::FitParameters::scatteringAngles
ScatteringAngles scatteringAngles(const FitMeasurement &fitMeasurement, int scatterer=-1) const
Definition: FitParameters.cxx:454
Trk::FitParameters::fullCovariance
const Amg::MatrixX * fullCovariance(void) const
Definition: FitParameters.h:229
Trk::FitParameters::parameterDifference
const Amg::MatrixX parameterDifference(const Amg::VectorX &parameters) const
Definition: FitParameters.cxx:186
Trk::FitParameters::d0
double d0(void) const
Definition: FitParameters.h:184
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::FitParameters::m_oldDifference
double m_oldDifference
Definition: FitParameters.h:137
Trk::TrackSurfaceIntersection::direction
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.
Definition: TrackSurfaceIntersection.h:88
Trk::FitMeasurement::isFlipped
bool isFlipped(void) const
Definition: FitMeasurement.h:381
Trk::FitParameters::m_firstScatteringParameter
int m_firstScatteringParameter
Definition: FitParameters.h:128
a
TList * a
Definition: liststreamerinfos.cxx:10
Trk::FitParameters::m_alignmentAngleConstraint
std::vector< double > m_alignmentAngleConstraint
Definition: FitParameters.h:114
Trk::FitParameters::m_numberOscillations
int m_numberOscillations
Definition: FitParameters.h:134
Trk::Surface::globalToLocal
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const =0
Specified by each surface type: GlobalToLocal method without dynamic memory allocation - boolean chec...
Trk::FitMeasurement::lastParameter
unsigned lastParameter(void) const
Definition: FitMeasurement.h:427
Trk::FitParameters::printVerbose
void printVerbose(MsgStream &log) const
Definition: FitParameters.cxx:296
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
TRT::Track::cotTheta
@ cotTheta
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:65
Trk::FitParameters::m_phiInstability
bool m_phiInstability
Definition: FitParameters.h:139
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
Trk::FitParameters::addAlignment
void addAlignment(bool constrained, double localAngle, double localOffset)
Definition: FitParameters.cxx:105
Trk::FitParameters::numberAlignments
int numberAlignments(void) const
Definition: FitParameters.h:233
Trk::phi
@ phi
Definition: ParamDefs.h:75
Trk::FitParameters::m_qOverP1
double m_qOverP1
Definition: FitParameters.h:142
Trk::FitParameters
Definition: FitParameters.h:29
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Trk::FitParameters::FitParameters
FitParameters(const Perigee &perigee)
Definition: FitParameters.cxx:28
TrackSurfaceIntersection.h
Trk::FitMeasurement::qOverP
double qOverP(void) const
Definition: FitMeasurement.h:486
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::FitParameters::addScatterer
void addScatterer(double phi, double theta)
Definition: FitParameters.cxx:116
Trk::FitMeasurement::weight
double weight(void) const
Definition: FitMeasurement.h:597
Trk::FitParameters::m_finalCovariance
Amg::MatrixX * m_finalCovariance
Definition: FitParameters.h:126
Trk::FitParameters::associatedSurface
const Surface * associatedSurface(void) const
Definition: FitParameters.cxx:122
Trk::FitParameters::phiInstability
bool phiInstability(void) const
Definition: FitParameters.cxx:244
Trk::FitMeasurement::isPerigee
bool isPerigee(void) const
Definition: FitMeasurement.h:397
Trk::FitParameters::reset
void reset(const FitParameters &parameters)
Definition: FitParameters.cxx:397
Trk::FitParameters::m_cotTheta
double m_cotTheta
Definition: FitParameters.h:121
Trk::FitParameters::differences
const Amg::VectorX & differences(void) const
Definition: FitParameters.h:196
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
Trk::FitParameters::performCutStep
void performCutStep(double cutStep)
Definition: FitParameters.cxx:201
ParameterType.h