ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointwiseMaterialInteraction.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PointwiseMaterialInteraction.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
14 
15 namespace Acts {
16 namespace detail {
20  const Surface* surface;
21 
22  const Vector3D pos;
23  const double time;
24  const Vector3D dir;
25  const double momentum;
26  const double q;
27  const double qOverP;
28 
29  const double mass;
30  const int pdg;
33 
37 
38  double variancePhi = 0.;
39  double varianceTheta = 0.;
40  double varianceQoverP = 0.;
41 
42  double Eloss = 0.;
43  double nextP;
44 
53  template <typename propagator_state_t, typename stepper_t>
55  const propagator_state_t& state,
56  const stepper_t& stepper)
57  : surface(sSurface),
58  pos(stepper.position(state.stepping)),
59  time(stepper.time(state.stepping)),
60  dir(stepper.direction(state.stepping)),
61  momentum(stepper.momentum(state.stepping)),
62  q(stepper.charge(state.stepping)),
63  qOverP(q / momentum),
64  mass(state.options.mass),
65  pdg(state.options.absPdgCode),
66  performCovarianceTransport(state.stepping.covTransport),
67  nav(state.stepping.navDir) {}
68 
77  template <typename propagator_state_t>
79  const propagator_state_t& state,
80  MaterialUpdateStage updateStage = fullUpdate) {
81  // We are at the start surface
82  if (surface == state.navigation.startSurface) {
83  updateStage = postUpdate;
84  // Or is it the target surface ?
85  } else if (surface == state.navigation.targetSurface) {
86  updateStage = preUpdate;
87  }
88 
89  // Retrieve the material properties
90  slab =
91  state.navigation.currentSurface->surfaceMaterial()->materialProperties(
92  pos, nav, updateStage);
93 
94  // Correct the material properties for non-zero incidence
95  pathCorrection = surface->pathCorrection(state.geoContext, pos, dir);
97 
98  // Get the surface material & properties from them
99  return slab;
100  }
101 
107  void evaluatePointwiseMaterialInteraction(bool multipleScattering,
108  bool energyLoss);
109 
117  template <typename propagator_state_t, typename stepper_t>
118  void updateState(propagator_state_t& state, const stepper_t& stepper) {
119  // in forward(backward) propagation, energy decreases(increases) and
120  // variances increase(decrease)
121  const auto nextE = std::sqrt(mass * mass + momentum * momentum) -
122  std::copysign(Eloss, nav);
123  // put particle at rest if energy loss is too large
124  nextP = (mass < nextE) ? std::sqrt(nextE * nextE - mass * mass) : 0;
125  // update track parameters and covariance
126  stepper.update(state.stepping, pos, dir, nextP, time);
127  // Update covariance matrix
129  state.stepping.cov(ePHI, ePHI) =
130  updateVariance(state.stepping.cov(ePHI, ePHI), variancePhi, mode);
131  state.stepping.cov(eTHETA, eTHETA) =
132  updateVariance(state.stepping.cov(eTHETA, eTHETA), varianceTheta, mode);
133  state.stepping.cov(eQOP, eQOP) =
134  updateVariance(state.stepping.cov(eQOP, eQOP), varianceQoverP, mode);
135  }
136 
137  private:
143  void covarianceContributions(bool multipleScattering, bool energyLoss);
144 
152  double updateVariance(double variance, double change,
153  NoiseUpdateMode updateMode = addNoise) const;
154 };
155 } // namespace detail
156 } // end of namespace Acts