19#include "BDSBunchType.hh"
21#include "BDSException.hh"
22#include "BDSUtilities.hh"
33 new std::map<BDSBunchType, std::string> ({
34 {BDSBunchType::reference,
"reference"},
35 {BDSBunchType::gaussmatrix,
"gaussmatrix"},
36 {BDSBunchType::gauss,
"gauss"},
37 {BDSBunchType::gausstwiss,
"gausstwiss"},
38 {BDSBunchType::circle,
"circle"},
39 {BDSBunchType::square,
"square"},
40 {BDSBunchType::ring,
"ring"},
41 {BDSBunchType::eshell,
"eshell"},
42 {BDSBunchType::halo,
"halo"},
43 {BDSBunchType::composite,
"composite"},
44 {BDSBunchType::userfile,
"userfile"},
45 {BDSBunchType::ptc,
"ptc"},
46 {BDSBunchType::sixtrack,
"sixtrack"},
47 {BDSBunchType::eventgeneratorfile,
"eventgeneratorfile"},
48 {BDSBunchType::sphere,
"sphere"},
49 {BDSBunchType::compositesde,
"compositespacedirectionenergy"},
50 {BDSBunchType::box,
"box"},
51 {BDSBunchType::halosigma,
"halosigma"},
52 {BDSBunchType::bdsimsampler,
"bdsimsampler"}
57 std::map<G4String, BDSBunchType> types;
59 types[
"reference"] = BDSBunchType::reference;
60 types[
"gaussmatrix"] = BDSBunchType::gaussmatrix;
61 types[
"gauss"] = BDSBunchType::gauss;
62 types[
"gausstwiss"] = BDSBunchType::gausstwiss;
63 types[
"circle"] = BDSBunchType::circle;
64 types[
"square"] = BDSBunchType::square;
65 types[
"ring"] = BDSBunchType::ring;
66 types[
"eshell"] = BDSBunchType::eshell;
67 types[
"halo"] = BDSBunchType::halo;
68 types[
"composite"] = BDSBunchType::composite;
69 types[
"userfile"] = BDSBunchType::userfile;
70 types[
"ptc"] = BDSBunchType::ptc;
71 types[
"sixtrack"] = BDSBunchType::sixtrack;
72 types[
"eventgeneratorfile"] = BDSBunchType::eventgeneratorfile;
73 types[
"sphere"] = BDSBunchType::sphere;
74 types[
"compositespacedirectionenergy"] = BDSBunchType::compositesde;
75 types[
"compositesde"] = BDSBunchType::compositesde;
76 types[
"box"] = BDSBunchType::box;
77 types[
"halosigma"] = BDSBunchType::halosigma;
78 types[
"bdsimsampler"] = BDSBunchType::bdsimsampler;
82 auto result = types.find(distrType);
83 if (result == types.end())
85 G4String message =
"\"" + distrType +
"\" is not a valid distribution\n";
86 message +=
"Available distributions are:\n";
87 for (
const auto& it : types)
88 {message += it.first +
"\n";}
93 G4cout << __METHOD_NAME__ <<
"determined distribution to be " << result->second << G4endl;
95 return result->second;
General exception with possible name of object and message.
Improve type-safety of native enum data type in C++.
static std::map< BDSTypeSafeEnum< def, inner >, std::string > * dictionary
G4String LowerCase(const G4String &str)
Utility function to simplify lots of syntax changes for pedantic g4 changes.
BDSBunchType DetermineBunchType(G4String distrType)
Function that gives corresponding enum value for string (case-insensitive).