ATLAS Offline Software
ComponentParameters.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
11 //
13 
16 {
17  auto clonedState = Trk::MultiComponentState();
18  clonedState.reserve(in.size());
19  for (const ComponentParameters& component : in) {
20  clonedState.push_back({component.params->uniqueClone(), component.weight});
21  }
22  return clonedState;
23 }
24 
27  double errorScaleLocX,
28  double errorScaleLocY,
29  double errorScalePhi,
30  double errorScaleTheta,
31  double errorScaleQoverP)
32 {
33  AmgSymMatrix(5) coefficients;
34  coefficients(0, 0) = (errorScaleLocX * errorScaleLocX);
35  coefficients(1, 1) = (errorScaleLocY * errorScaleLocY);
36  coefficients(2, 2) = (errorScalePhi * errorScalePhi);
37  coefficients(3, 3) = (errorScaleTheta * errorScaleTheta);
38  coefficients(4, 4) = (errorScaleQoverP * errorScaleQoverP);
39  coefficients.fillSymmetric(0, 1, (errorScaleLocX * errorScaleLocY));
40  coefficients.fillSymmetric(0, 2, (errorScaleLocX * errorScalePhi));
41  coefficients.fillSymmetric(0, 3, (errorScaleLocX * errorScaleTheta));
42  coefficients.fillSymmetric(0, 4, (errorScaleLocX * errorScaleQoverP));
43  coefficients.fillSymmetric(1, 2, (errorScaleLocY * errorScalePhi));
44  coefficients.fillSymmetric(1, 3, (errorScaleLocY * errorScaleTheta));
45  coefficients.fillSymmetric(1, 4, (errorScaleLocY * errorScaleQoverP));
46  coefficients.fillSymmetric(2, 3, (errorScalePhi * errorScaleTheta));
47  coefficients.fillSymmetric(2, 4, (errorScalePhi * errorScaleQoverP));
48  coefficients.fillSymmetric(3, 4, (errorScaleTheta * errorScaleQoverP));
49 
50  for (ComponentParameters& component : in) {
51  Trk::TrackParameters* trackParameters = component.params.get();
52  const AmgSymMatrix(5)* originalMatrix = trackParameters->covariance();
53  // If no covariance skip
54  if (!originalMatrix) {
55  continue;
56  }
57  AmgSymMatrix(5) newCovarianceMatrix =
58  (*originalMatrix).cwiseProduct(coefficients);
59  trackParameters->updateParameters(trackParameters->parameters(),
60  newCovarianceMatrix);
61  }
62  return { std::move(in) };
63 }
64 
65 bool
67 {
68  bool allHaveCovariance = true;
69  for (const ComponentParameters& component : in) {
70  const AmgSymMatrix(5)* originalMatrix = component.params->covariance();
71  if (!originalMatrix) {
72  allHaveCovariance = false;
73  break;
74  }
75  }
76  return allHaveCovariance;
77 }
78 
79 void
81  double norm)
82 {
83  // Determine total weighting of state
84  double sumWeights = 0.;
85  for (const ComponentParameters& component : in) {
86  sumWeights += component.weight;
87  }
88  if (sumWeights == 0) {
89  return;
90  }
91  double normalise = norm / sumWeights;
92  for (ComponentParameters& component : in) {
93  component.weight = component.weight * normalise;
94  }
95 }
Trk::MultiComponentStateHelpers::allHaveCovariance
bool allHaveCovariance(const MultiComponentState &in)
Check to see if all components have covariance Matrix.
Definition: ComponentParameters.cxx:66
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
Trk::ParametersCommon::updateParameters
void updateParameters(const AmgVector(DIM) &, const AmgSymMatrix(DIM) &)
Update parameters and covariance , passing covariance by ref.
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:52
Trk::MultiComponentStateHelpers::clone
MultiComponentState clone(const MultiComponentState &in)
Clone TrackParameters method.
Definition: ComponentParameters.cxx:15
Trk::MultiComponentState
std::vector< ComponentParameters > MultiComponentState
Definition: ComponentParameters.h:27
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::MultiComponentStateHelpers::WithScaledError
MultiComponentState WithScaledError(MultiComponentState &&in, double errorScaleLocX, double errorScaleLocY, double errorScalePhi, double errorScaleTheta, double errorScaleQoverP)
Scale the covariance matrix components by individual factors.
Definition: ComponentParameters.cxx:26
Trk::MultiComponentStateHelpers::renormaliseState
void renormaliseState(MultiComponentState &, double norm=1)
Performing renormalisation of total state weighting to one.
Definition: ComponentParameters.cxx:80
Trk::ComponentParameters
Definition: ComponentParameters.h:22
ComponentParameters.h
Definition of component parameters for use in a mixture of many components. In this regime each track...