Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:20:26

0001 #include <cmath>
0002 #include <iostream>
0003 #include <random>
0004 #include <string>
0005 
0006 // Generate Woods-Saxon numbers using the same method as in actual trento code.
0007 
0008 int main(int /* argc */, char* argv[]) {
0009   double R;
0010   double a;
0011   int N;
0012 
0013   try {
0014     R = std::stod(std::string{argv[1]});
0015     a = std::stod(std::string{argv[2]});
0016     N = std::stoi(std::string{argv[3]});
0017   }
0018   catch (const std::exception&) {
0019     std::cerr << "usage: " << argv[0] << " R a n_samples\n";
0020     return 1;
0021   }
0022 
0023   std::mt19937_64 engine{std::random_device{}()};
0024   std::piecewise_linear_distribution<double>
0025     woods_saxon_dist{1000, 0, R+10.*a, [&R, &a](double r) {
0026       return r*r/(1. + std::exp((r-R)/a));
0027     }};
0028 
0029   for (int i = 0; i < N; ++i)
0030     std::cout << woods_saxon_dist(engine) << '\n';
0031 
0032   return 0;
0033 }