41 std::string output_path;
42 std::string config_file_path;
45 while ( !args.empty() ) {
46 std::string arg = args.front();
49 if ( arg ==
"-o" || arg ==
"--output" ) {
51 std::cerr <<
"marley xsec: missing argument after '" << arg <<
"'\n";
54 output_path = args.front();
57 else if ( arg ==
"-f" || arg ==
"--force" ) {
60 else if ( arg ==
"-h" || arg ==
"--help" ) {
62 args.push_front(
"xsec" );
65 else if ( arg.front() ==
'-' ) {
66 std::cerr <<
"marley xsec: unrecognized option '" << arg <<
"'\n";
69 else if ( config_file_path.empty() ) {
70 config_file_path = arg;
73 std::cerr <<
"marley xsec: unexpected extra argument '"
79 if ( output_path.empty() ) {
80 std::cerr <<
"marley xsec: missing required output file\n";
81 args.push_front(
"xsec" );
86 if ( config_file_path.empty() ) {
87 std::cerr <<
"marley xsec: missing required configuration file\n";
88 args.push_front(
"xsec" );
94 std::ifstream temp_stream( output_path );
96 bool overwrite = marley_utils::prompt_yes_no(
97 "Really overwrite " + output_path +
'?');
99 std::cout <<
"Total cross section dump aborted.\n";
105 std::ofstream out_file( output_path );
110 double KEmin = DEFAULT_KE_MIN;
111 double KEmax = DEFAULT_KE_MAX;
112 int num_steps = DEFAULT_NUM_STEPS;
113 int projectile_pdg = DEFAULT_PDG;
117 if ( json.has_key(
"xsec") ) {
120 if ( xsec_settings.has_key(
"KEmin") ) {
122 KEmin = xsec_settings.at(
"KEmin").to_double( ok );
124 + xsec_settings.at(
"KEmin").to_string() +
" encountered in the"
125 " \"xsec\" section of the job configuration file.");
128 if ( xsec_settings.has_key(
"KEmax") ) {
130 KEmax = xsec_settings.at(
"KEmax").to_double( ok );
132 + xsec_settings.at(
"KEmax").to_string() +
" encountered in the"
133 " \"xsec\" section of the job configuration file.");
136 if ( xsec_settings.has_key(
"steps") ) {
138 num_steps = xsec_settings.at(
"steps").to_long( ok );
140 + xsec_settings.at(
"steps").to_string() +
" encountered in the"
141 " \"xsec\" section of the job configuration file.");
144 if ( xsec_settings.has_key(
"pdg") ) {
146 projectile_pdg = xsec_settings.at(
"pdg").to_long( ok );
148 + xsec_settings.at(
"pdg").to_string() +
" encountered in the"
149 " \"xsec\" section of the job configuration file.");
154 int steps = num_steps;
157 double xsec = gen.
total_xs( projectile_pdg, KE );
158 xsec *= marley_utils::hbar_c2 * marley_utils::fm2_to_minus40_cm2 * 1e2;
160 out_file << KE <<
' ' << xsec <<
'\n';
162 MARLEY_LOG( INFO,
"app" ) <<
"KE = " << KE
163 <<
" MeV, abundance-weighted total xsec = "
164 << xsec <<
" × 10^{-42} cm^2 / atom";
167 double delta = ( KEmax - KEmin ) / ( steps - 1 );
168 for (
int s = 0; s < steps; ++s ) {
169 KE = KEmin + s * delta;
170 double xsec = gen.
total_xs( projectile_pdg, KE );
171 xsec *= marley_utils::hbar_c2 * marley_utils::fm2_to_minus40_cm2 * 1e2;
173 out_file << KE <<
' ' << xsec <<
'\n';
175 MARLEY_LOG( INFO,
"app" ) <<
"KE = " << KE
176 <<
" MeV, abundance-weighted total xsec = "
177 << xsec <<
" × 10^{-42} cm^2 / atom";
double total_xs(int pdg_a, double KEa, int pdg_atom) const
Computes the total cross section at fixed energy for all configured reactions involving a particular ...