Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
generate-woods-saxon.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file generate-woods-saxon.cxx
1 #include <cmath>
2 #include <iostream>
3 #include <random>
4 #include <string>
5 
6 // Generate Woods-Saxon numbers using the same method as in actual trento code.
7 
8 int main(int /* argc */, char* argv[]) {
9  double R;
10  double a;
11  int N;
12 
13  try {
14  R = std::stod(std::string{argv[1]});
15  a = std::stod(std::string{argv[2]});
16  N = std::stoi(std::string{argv[3]});
17  }
18  catch (const std::exception&) {
19  std::cerr << "usage: " << argv[0] << " R a n_samples\n";
20  return 1;
21  }
22 
23  std::mt19937_64 engine{std::random_device{}()};
24  std::piecewise_linear_distribution<double>
25  woods_saxon_dist{1000, 0, R+10.*a, [&R, &a](double r) {
26  return r*r/(1. + std::exp((r-R)/a));
27  }};
28 
29  for (int i = 0; i < N; ++i)
30  std::cout << woods_saxon_dist(engine) << '\n';
31 
32  return 0;
33 }