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 
23  const Vector3D pos = Vector3D(0., 0., 0);
25  const double time = 0.0;
27  const Vector3D dir = Vector3D(0., 0., 0);
29  const double momentum;
31  const double q;
33  const double qOverP;
35  const double mass;
37  const int pdg;
42 
48  double variancePhi = 0.;
50  double varianceTheta = 0.;
52  double varianceQoverP = 0.;
54  double Eloss = 0.;
56  double nextP;
57 
66  template <typename propagator_state_t, typename stepper_t>
68  const propagator_state_t& state,
69  const stepper_t& stepper)
70  : surface(sSurface),
71  pos(stepper.position(state.stepping)),
72  time(stepper.time(state.stepping)),
73  dir(stepper.direction(state.stepping)),
74  momentum(stepper.momentum(state.stepping)),
75  q(stepper.charge(state.stepping)),
76  qOverP(q / momentum),
77  mass(state.options.mass),
78  pdg(state.options.absPdgCode),
79  performCovarianceTransport(state.stepping.covTransport),
80  nav(state.stepping.navDir) {}
81 
90  template <typename propagator_state_t>
91  bool evaluateMaterialSlab(const propagator_state_t& state,
92  MaterialUpdateStage updateStage = fullUpdate) {
93  // We are at the start surface
94  if (surface == state.navigation.startSurface) {
95  updateStage = postUpdate;
96  // Or is it the target surface ?
97  } else if (surface == state.navigation.targetSurface) {
98  updateStage = preUpdate;
99  }
100 
101  // Retrieve the material properties
102  slab = state.navigation.currentSurface->surfaceMaterial()->materialSlab(
103  pos, nav, updateStage);
104 
105  // Correct the material properties for non-zero incidence
106  pathCorrection = surface->pathCorrection(state.geoContext, pos, dir);
108 
109  // Get the surface material & properties from them
110  return slab;
111  }
112 
118  void evaluatePointwiseMaterialInteraction(bool multipleScattering,
119  bool energyLoss);
120 
128  template <typename propagator_state_t, typename stepper_t>
129  void updateState(propagator_state_t& state, const stepper_t& stepper) {
130  // in forward(backward) propagation, energy decreases(increases) and
131  // variances increase(decrease)
132  const auto nextE = std::sqrt(mass * mass + momentum * momentum) -
133  std::copysign(Eloss, nav);
134  // put particle at rest if energy loss is too large
135  nextP = (mass < nextE) ? std::sqrt(nextE * nextE - mass * mass) : 0;
136  // update track parameters and covariance
137  stepper.update(state.stepping, pos, dir, nextP, time);
138  // Update covariance matrix
140  state.stepping.cov(eBoundPhi, eBoundPhi) = updateVariance(
141  state.stepping.cov(eBoundPhi, eBoundPhi), variancePhi, mode);
142  state.stepping.cov(eBoundTheta, eBoundTheta) = updateVariance(
143  state.stepping.cov(eBoundTheta, eBoundTheta), varianceTheta, mode);
144  state.stepping.cov(eBoundQOverP, eBoundQOverP) = updateVariance(
145  state.stepping.cov(eBoundQOverP, eBoundQOverP), varianceQoverP, mode);
146  }
147 
148  private:
154  void covarianceContributions(bool multipleScattering, bool energyLoss);
155 
163  double updateVariance(double variance, double change,
164  NoiseUpdateMode updateMode = addNoise) const;
165 };
166 } // namespace detail
167 } // end of namespace Acts