Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BetheHeitler.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BetheHeitler.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2021 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 #include <array>
16 #include <cmath>
17 #include <random>
18 
19 namespace ActsFatras {
20 
26 struct BetheHeitler {
29 
31  double scaleFactor = 1.;
32 
33  // Simplified angle evaluation
35 
44  Particle bremPhoton(const Particle &particle, Scalar gammaE, Scalar rndPsi,
45  Scalar rndTheta1, Scalar rndTheta2,
46  Scalar rndTheta3) const;
47 
56  template <typename generator_t>
57  std::array<Particle, 1> operator()(generator_t &generator,
58  const Acts::MaterialSlab &slab,
59  Particle &particle) const {
60  // Take a random gamma-distributed value - depending on t/X0
61  std::gamma_distribution<double> gDist(slab.thicknessInX0() / std::log(2.0),
62  1.0);
63 
64  const auto u = gDist(generator);
65  const auto z = std::exp(-u); // MARK: fpeMask(FLTUND, 1, #2346)
66  const auto sampledEnergyLoss =
67  std::abs(scaleFactor * particle.energy() * (z - 1.));
68 
69  std::uniform_real_distribution<Scalar> uDist(0., 1.);
70  // Build the produced photon
71  Particle photon =
72  bremPhoton(particle, sampledEnergyLoss, uDist(generator),
73  uDist(generator), uDist(generator), uDist(generator));
74  // Recoil input momentum
75  particle.setDirection(particle.direction() * particle.absoluteMomentum() -
76  photon.energy() * photon.direction());
77 
78  // apply the energy loss
79  particle.correctEnergy(-sampledEnergyLoss);
80 
81  return {photon};
82  }
83 };
84 
85 } // namespace ActsFatras