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 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 
12 
13 namespace Fatras {
14 
15 const double log_2 = std::log(2.);
16 
23 struct BetheHeitler {
24 
26  bool betheHeitler = true;
27 
29  double scaleFactor = 1.;
30 
42  template <typename generator_t, typename detector_t, typename particle_t>
43  std::vector<particle_t> operator()(generator_t &generator,
44  const detector_t &detector,
45  particle_t &particle) const {
46 
47  // Do nothing if the flag is set to false
48  if (not betheHeitler) {
49  return {};
50  }
51 
52  double tInX0 = detector.thickness() / detector.material().X0();
53 
54  // Take a random gamma-distributed value - depending on t/X0
55  GammaDist gDist = GammaDist(tInX0 / log_2, 1.);
56 
57  double u = gDist(generator);
58  double z = std::exp(-1. * u);
59  double sampledEnergyLoss = std::abs(scaleFactor * particle.E() * (z - 1.));
60 
61  // apply the energy loss
62  particle.energyLoss(sampledEnergyLoss);
63 
64  // @TODO return photons, needs particle_creator_t
65  return {};
66  }
67 };
68 
69 } // namespace Fatras