EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GaussianMixture.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GaussianMixture.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2020 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 
13 
14 #include <random>
15 
16 namespace ActsFatras {
17 namespace detail {
18 
22  bool optGaussianMixtureG4 = false;
23  double gausMixSigma1_a0 = 8.471e-1;
24  double gausMixSigma1_a1 = 3.347e-2;
25  double gausMixSigma1_a2 = -1.843e-3;
26  double gausMixEpsilon_a0 = 4.841e-2;
27  double gausMixEpsilon_a1 = 6.348e-3;
28  double gausMixEpsilon_a2 = 6.096e-4;
29  double gausMixEpsilon_b0 = -1.908e-2;
30  double gausMixEpsilon_b1 = 1.106e-1;
31  double gausMixEpsilon_b2 = -5.729e-3;
32 
41  template <typename generator_t>
42  double operator()(generator_t &generator, const Acts::MaterialSlab &slab,
43  Particle &particle) const {
46  slab, particle.pdg(), particle.mass(),
47  particle.charge() / particle.absMomentum(), particle.charge());
48  double sigma2 = sigma * sigma;
49 
50  // Gauss distribution, will be sampled with generator
51  std::normal_distribution<double> gaussDist(0., 1.);
52  // Uniform distribution, will be sampled with generator
53  std::uniform_real_distribution<double> uniformDist(0., 1.);
54 
55  // Now correct for the tail fraction
56  // d_0'
57  // beta² = (p/E)² = p²/(p² + m²) = 1/(1 + (m/p)²)
58  // 1/beta² = 1 + (m/p)²
59  double mOverP = particle.mass() / particle.absMomentum();
60  double beta2inv = 1 + mOverP * mOverP;
61  double dprime = slab.thicknessInX0() * beta2inv;
62  double log_dprime = std::log(dprime);
63  // d_0''
64  double log_dprimeprime =
65  std::log(std::pow(slab.material().Z(), 2.0 / 3.0) * dprime);
66 
67  // get epsilon
68  double epsilon =
69  log_dprimeprime < 0.5
70  ? gausMixEpsilon_a0 + gausMixEpsilon_a1 * log_dprimeprime +
71  gausMixEpsilon_a2 * log_dprimeprime * log_dprimeprime
72  : gausMixEpsilon_b0 + gausMixEpsilon_b1 * log_dprimeprime +
73  gausMixEpsilon_b2 * log_dprimeprime * log_dprimeprime;
74 
75  // the standard sigma
76  double sigma1square = gausMixSigma1_a0 + gausMixSigma1_a1 * log_dprime +
77  gausMixSigma1_a2 * log_dprime * log_dprime;
78 
79  // G4 optimised / native double Gaussian model
81  sigma2 =
82  225. * dprime / (particle.absMomentum() * particle.absMomentum());
83  }
84  // throw the random number core/tail
85  if (uniformDist(generator) < epsilon) {
86  sigma2 *= (1. - (1. - epsilon) * sigma1square) / epsilon;
87  }
88  // return back to the
89  return M_SQRT2 * std::sqrt(sigma2) * gaussDist(generator);
90  }
91 };
92 
93 } // namespace detail
94 
96 
97 } // namespace ActsFatras