404 using namespace smash;
406 constexpr option longopts[] = {
407 {
"config", required_argument, 0,
'c'},
408 {
"decaymodes", required_argument, 0,
'd'},
409 {
"endtime", required_argument, 0,
'e'},
410 {
"force", no_argument, 0,
'f'},
411 {
"help", no_argument, 0,
'h'},
412 {
"inputfile", required_argument, 0,
'i'},
413 {
"modus", required_argument, 0,
'm'},
414 {
"particles", required_argument, 0,
'p'},
415 {
"output", required_argument, 0,
'o'},
416 {
"list-2-to-n", no_argument, 0,
'l'},
417 {
"resonance", required_argument, 0,
'r'},
418 {
"cross-sections", required_argument, 0,
's'},
419 {
"cross-sections-fs", required_argument, 0,
'S'},
420 {
"dump-iSS", no_argument, 0,
'x'},
421 {
"version", no_argument, 0,
'v'},
422 {
"no-cache", no_argument, 0,
'n'},
423 {
"quiet", no_argument, 0,
'q'},
427 const std::string progname = bf::path(argv[0]).filename().native();
430 bool force_overwrite =
false;
432 std::vector<std::string> extra_config;
433 char *particles =
nullptr, *decaymodes =
nullptr, *modus =
nullptr,
434 *end_time =
nullptr, *pdg_string =
nullptr, *cs_string =
nullptr;
435 bool list2n_activated =
false;
436 bool resonance_dump_activated =
false;
437 bool cross_section_dump_activated =
false;
438 bool final_state_cross_sections =
false;
439 bool particles_dump_iSS_format =
false;
440 bool cache_integrals =
true;
444 bool suppress_disclaimer =
false;
445 while ((opt = getopt_long(argc, argv,
"c:d:e:fhi:m:p:o:lr:s:S:xvnq",
446 longopts,
nullptr)) != -1) {
449 extra_config.emplace_back(optarg);
455 force_overwrite =
true;
461 usage(EXIT_SUCCESS, progname);
473 output_path = optarg;
476 list2n_activated =
true;
477 suppress_disclaimer =
true;
480 resonance_dump_activated =
true;
482 suppress_disclaimer =
true;
485 final_state_cross_sections =
true;
488 cross_section_dump_activated =
true;
490 suppress_disclaimer =
true;
493 particles_dump_iSS_format =
true;
494 suppress_disclaimer =
true;
499 "Branch : %s\nSystem : %s\nCompiler : %s %s\n"
500 "Build : %s\nDate : %s\n",
501 VERSION_MAJOR, GIT_BRANCH, CMAKE_SYSTEM, CMAKE_CXX_COMPILER_ID,
502 CMAKE_CXX_COMPILER_VERSION, CMAKE_BUILD_TYPE, BUILD_DATE);
503 std::exit(EXIT_SUCCESS);
505 cache_integrals =
false;
508 suppress_disclaimer =
true;
511 usage(EXIT_FAILURE, progname);
517 std::cout << argv[0] <<
": invalid argument -- '" << argv[optind]
519 usage(EXIT_FAILURE, progname);
522 if (!suppress_disclaimer) {
528 input_path.filename());
530 for (
const auto &config : extra_config) {
545 " create ParticleType and DecayModes");
547 auto particles_and_decays =
554 "Ambiguity: particles from external file ", particles,
555 " requested, but there is also particle list in the config."
556 " Using particles from ",
565 "Ambiguity: decaymodes from external file ", decaymodes,
566 " requested, but there is also decaymodes list in the config."
567 " Using decaymodes from",
575 const std::string version(VERSION_MAJOR);
579 hash_context.
update(version);
580 hash_context.
update(particle_string);
581 hash_context.
update(decay_string);
582 const auto hash = hash_context.
finalize();
585 bf::path tabulations_path;
586 if (cache_integrals) {
587 tabulations_path = output_path.parent_path() /
"tabulations";
588 bf::create_directories(tabulations_path);
589 logg[
LMain].info() <<
"Tabulations path: " << tabulations_path;
591 tabulations_path =
"";
593 if (list2n_activated) {
597 logg[
LMain].info() <<
"Tabulations path: " << tabulations_path;
604 scat_finder.dump_reactions();
605 std::exit(EXIT_SUCCESS);
607 if (particles_dump_iSS_format) {
609 ParticleTypePtrList list;
611 for (
const auto &ptype : ParticleType::list_all()) {
612 list.push_back(&ptype);
614 std::sort(list.begin(), list.end(),
616 return a->mass() < b->mass();
619 if (ptype->pdgcode().is_lepton() || ptype->baryon_number() < 0) {
622 const auto &decay_modes = ptype->decay_modes();
623 const auto &modelist = decay_modes.decay_mode_list();
624 int ndecays = ptype->is_stable() ? 1 : modelist.size();
625 std::printf(
"%13i %s %10.5f %10.5f %5i %5i %5i %5i %5i %5i %5i %5i\n",
626 ptype->pdgcode().get_decimal(),
628 ptype->mass(), ptype->width_at_pole(),
629 ptype->pdgcode().spin_degeneracy(), ptype->baryon_number(),
630 ptype->strangeness(), ptype->pdgcode().charmness(),
631 ptype->pdgcode().bottomness(), ptype->isospin() + 1,
632 ptype->charge(), ndecays);
633 if (!ptype->is_stable()) {
634 for (
const auto &decay : modelist) {
635 auto ptypes = decay->particle_types();
636 std::printf(
"%13i %13i %20.5f %13i %13i %13i %13i %13i\n",
637 ptype->pdgcode().get_decimal(), 2, decay->weight(),
638 ptypes[0]->pdgcode().get_decimal(),
639 ptypes[1]->pdgcode().get_decimal(), 0, 0, 0);
642 std::printf(
"%13i %13i %20.5f %13i %13i %13i %13i %13i\n",
643 ptype->pdgcode().get_decimal(), 1, 1.0,
644 ptype->pdgcode().get_decimal(), 0, 0, 0, 0);
647 std::exit(EXIT_SUCCESS);
649 if (resonance_dump_activated) {
652 const auto _dummy = ExperimentBase::create(
configuration,
"");
659 std::exit(EXIT_SUCCESS);
661 if (cross_section_dump_activated) {
663 std::string arg_string(cs_string);
664 std::vector<std::string> args =
split(arg_string,
',');
665 const unsigned int n_arg = args.size();
666 if (n_arg != 2 && n_arg != 4 && n_arg < 5) {
667 throw std::invalid_argument(
"-s usage: pdg1,pdg2[,m1,m2[,sqrts1,...]]");
669 PdgCode pdg_a(args[0]), pdg_b(args[1]);
673 for (
unsigned int i = 0; i < 4 - n_arg; i++) {
677 double ma = (args[2] ==
"") ? a.
mass() : std::stod(args[2]);
678 double mb = (args[3] ==
"") ? b.
mass() : std::stod(args[3]);
679 if (a.
is_stable() && args[2] !=
"" && std::stod(args[2]) != a.
mass()) {
681 std::cerr <<
"Warning: pole mass is used for stable particle "
682 << a.
name() <<
" instead of " << args[2] << std::endl;
684 if (b.
is_stable() && args[3] !=
"" && std::stod(args[3]) != b.
mass()) {
686 std::cerr <<
"Warning: pole mass is used for stable particle "
687 << b.
name() <<
" instead of " << args[3] << std::endl;
689 const size_t plab_size = n_arg <= 4 ? 0 : n_arg - 4;
690 std::vector<double> plab;
691 plab.reserve(plab_size);
692 for (
size_t i = 4; i < n_arg; i++) {
693 plab.push_back(std::stod(args.at(i)));
700 scat_finder.dump_cross_sections(a, b, ma, mb, final_state_cross_sections,
702 std::exit(EXIT_SUCCESS);
708 configuration[
"General"][
"End_Time"] = std::abs(std::atof(end_time));
718 const bf::path lock_path = output_path /
"smash.lock";
720 if (!lock.acquire()) {
721 throw std::runtime_error(
722 "Another instance of SMASH is already writing to the specified "
723 "output directory. If you are sure this is not the case, remove \"" +
724 lock_path.native() +
"\".");
726 logg[
LMain].debug(
"output path: ", output_path);
727 if (!force_overwrite && bf::exists(output_path /
"config.yaml")) {
728 throw std::runtime_error(
729 "Output directory would get overwritten. Select a different output "
730 "directory, clean up, or tell SMASH to ignore existing files.");
735 bf::ofstream(output_path /
"config.yaml")
736 <<
"# " << VERSION_MAJOR <<
'\n'
737 <<
"# Branch : " << GIT_BRANCH <<
'\n'
738 <<
"# System : " << CMAKE_SYSTEM <<
'\n'
739 <<
"# Compiler : " << CMAKE_CXX_COMPILER_ID <<
' '
740 << CMAKE_CXX_COMPILER_VERSION <<
'\n'
741 <<
"# Build : " << CMAKE_BUILD_TYPE <<
'\n'
742 <<
"# Date : " << BUILD_DATE <<
'\n'
745 " create ParticleType and DecayModes");
760 }
catch (std::exception &e) {
761 logg[
LMain].fatal() <<
"SMASH failed with the following error:\n"
Interface to the SMASH configuration files.
bool has_value(std::initializer_list< const char * > keys) const
Returns whether there is a non-empty value behind the requested keys.
void merge_yaml(const std::string &yaml)
Merge the configuration in yaml into the existing tree.
std::string to_string() const
Returns a YAML string of the current tree.
Value take(std::initializer_list< const char * > keys)
The default interface for SMASH to read configuration values.
Value read(std::initializer_list< const char * > keys) const
Additional interface for SMASH to read configuration values without removing them.
Guard to create a file lock.
A pointer-like interface to global references to ParticleType objects.
Particle type contains the static properties of a particle species.
void dump_width_and_spectral_function() const
Prints out width and spectral function versus mass to the standard output.
const std::string & name() const
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
void update(uint8_t const *buffer, size_t buffer_size)
Add data to the SHA256 context.
Hash finalize()
Performs the final calculation of the hash and returns the digest (32 byte buffer containing 256bit h...
#define SMASH_SOURCE_LOCATION
Hackery that is required to output the location in the source code where the log statement occurs.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
void set_default_loglevel(einhard::LogLevel level)
Set the default log level (what will be returned from subsequent default_loglevel calls).
void create_all_loggers(Configuration config)
Called from main() right after the Configuration object is fully set up to create all logger objects ...
Configuration configuration(std::string overrides={})
Return a configuration object filled with data from src/config.yaml.
std::unique_ptr< ExperimentBase > experiment(const Configuration &c=configuration())
Create an experiment.
void ignore_simulation_config_values(Configuration &configuration)
Remove all config values that are only needed for simulations.
bf::path default_output_path()
ScatterActionsFinder actions_finder_for_dump(Configuration configuration)
Prepares ActionsFinder for cross-section and reaction dumps.
void check_for_unused_config_values(const Configuration &configuration)
Checks if there are unused config values.
void ensure_path_is_valid(const bf::path &path)
Ensures the output path is valid.
void print_disclaimer()
Print the disclaimer.
void initialize_particles_and_decays(Configuration &configuration, sha256::Hash hash, bf::path tabulations_path)
Initialize the particles and decays from the configuration, the hash and the path to the cashed reson...
void check_config_version_is_compatible(Configuration configuration)
Checks if the SMASH version is compatible with the version of the configuration file.
int64_t generate_63bit_seed()
Generates a seed with a truly random 63-bit value, if possible.
std::string hash_to_string(Hash hash)
Convert a SHA256 hash to a hexadecimal string.
std::string fill_left(const std::string &s, size_t width, char fill=' ')
Fill string with characters to the left until the given width is reached.
std::vector< std::string > split(const std::string &s, char delim)
Split string by delimiter.
std::pair< std::string, std::string > load_particles_and_decaymodes(const char *particles_file, const char *decaymodes_file)
Loads particles and decaymodes from provided files particles_file and decaymodes_file.
void setup_default_float_traps()
Setup the floating-point traps used throughout SMASH.
static constexpr int LMain