Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
random.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file random.h
1 // TRENTO: Reduced Thickness Event-by-event Nuclear Topology
2 // Copyright 2015 Jonah E. Bernhard, J. Scott Moreland
3 // TRENTO3D: Three-dimensional extension of TRENTO by Weiyao Ke
4 // MIT License
5 
6 #ifndef RANDOM_H
7 #define RANDOM_H
8 
9 #include <limits>
10 #include <random>
11 
12 #include <boost/math/constants/constants.hpp>
13 
14 #include "fwd_decl.h"
15 
16 namespace trento { namespace random {
17 
19 using Engine = std::mt19937_64;
20 
22 extern Engine engine;
23 
25 template <typename RealType = double>
26 inline RealType canonical() {
27  return std::generate_canonical
28  <RealType, std::numeric_limits<RealType>::digits>
29  (engine);
30 }
31 
33 template <typename RealType = double>
34 inline double cos_theta() {
35  return 2 * canonical<RealType>() - 1;
36 }
37 
39 template <typename RealType = double>
40 inline double phi() {
41  return math::constants::two_pi<RealType>() * canonical<RealType>();
42 }
43 
44 }} // namespace trento::random
45 
46 #endif // RANDOM_H