ECCE @ 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 
11 #include <random>
12 
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,
43  const Acts::MaterialProperties &slab,
44  Particle &particle) const {
47  slab, particle.pdg(), particle.mass(),
48  particle.charge() / particle.absMomentum(), particle.charge());
49  double sigma2 = sigma * sigma;
50 
51  // Gauss distribution, will be sampled with generator
52  std::normal_distribution<double> gaussDist(0., 1.);
53  // Uniform distribution, will be sampled with generator
54  std::uniform_real_distribution<double> uniformDist(0., 1.);
55 
56  // Now correct for the tail fraction
57  // d_0'
58  // beta² = (p/E)² = p²/(p² + m²) = 1/(1 + (m/p)²)
59  // 1/beta² = 1 + (m/p)²
60  double mOverP = particle.mass() / particle.absMomentum();
61  double beta2inv = 1 + mOverP * mOverP;
62  double dprime = slab.thicknessInX0() * beta2inv;
63  double log_dprime = std::log(dprime);
64  // d_0''
65  double log_dprimeprime =
66  std::log(std::pow(slab.material().Z(), 2.0 / 3.0) * dprime);
67 
68  // get epsilon
69  double epsilon =
70  log_dprimeprime < 0.5
71  ? gausMixEpsilon_a0 + gausMixEpsilon_a1 * log_dprimeprime +
72  gausMixEpsilon_a2 * log_dprimeprime * log_dprimeprime
73  : gausMixEpsilon_b0 + gausMixEpsilon_b1 * log_dprimeprime +
74  gausMixEpsilon_b2 * log_dprimeprime * log_dprimeprime;
75 
76  // the standard sigma
77  double sigma1square = gausMixSigma1_a0 + gausMixSigma1_a1 * log_dprime +
78  gausMixSigma1_a2 * log_dprime * log_dprime;
79 
80  // G4 optimised / native double Gaussian model
82  sigma2 =
83  225. * dprime / (particle.absMomentum() * particle.absMomentum());
84  }
85  // throw the random number core/tail
86  if (uniformDist(generator) < epsilon) {
87  sigma2 *= (1. - (1. - epsilon) * sigma1square) / epsilon;
88  }
89  // return back to the
90  return M_SQRT2 * std::sqrt(sigma2) * gaussDist(generator);
91  }
92 };
93 
94 } // namespace detail
95 
97 
98 } // namespace ActsFatras