20 static constexpr
int LCollider = LogArea::Collider::id;
27 const std::string particle_list_file_directory =
28 config.
take({
"Custom",
"File_Directory"});
30 const std::string particle_list_file_name =
31 config.
take({
"Custom",
"File_Name"});
34 throw std::runtime_error(
35 "Your Particle List is already filled before reading in from the "
37 "Something went wrong. Please check your config.");
46 std::map<PdgCode, int> particle_list = config.
take({
"Particles"});
47 for (
const auto& particle : particle_list) {
48 if (particle.first ==
pdg::p) {
50 }
else if (particle.first ==
pdg::n) {
53 throw std::runtime_error(
54 "Your nucleus can only contain protons and/or neutrons."
55 "Please check what particles you have specified in the config");
63 const std::string path =
64 file_path(particle_list_file_directory, particle_list_file_name);
68 }
else if (!same_file) {
69 filestream_ = std::make_unique<std::ifstream>(path);
85 for (
const auto& it : vec) {
87 if (it.isospin == 1) {
89 }
else if (it.isospin == 0) {
92 throw std::runtime_error(
93 "Your particles charges are not 1 = proton or 0 = neutron.\n"
94 "Check whether your list is correct or there is an error.");
98 double current_mass = current_type.
mass();
100 particles_.back().set_4momentum(current_mass, 0.0, 0.0, 0.0);
122 return nucleon_position;
132 for (
auto i =
begin(); i !=
end(); i++) {
134 i->set_4momentum(i->pole_mass(), 0.0, 0.0, 0.0);
147 logg[
LCollider].warn() <<
"Fermi motion activated with a custom nucleus.\n";
148 logg[
LCollider].warn() <<
"Be aware that generating the Fermi momenta\n"
149 <<
"assumes nucleons distributed according to a\n"
150 <<
"Woods-Saxon distribution.";
154 const std::string& file_name) {
155 if (file_directory.back() ==
'/') {
156 return file_directory + file_name;
158 return file_directory +
'/' + file_name;
163 std::ifstream& infile)
const {
164 int proton_counter = 0;
165 int neutron_counter = 0;
167 std::vector<Nucleoncustom> custom_nucleus;
170 std::getline(infile, line);
174 infile.seekg(0, infile.beg);
175 std::getline(infile, line);
178 std::istringstream iss(line);
179 if (!(iss >> nucleon.
x >> nucleon.
y >> nucleon.
z >>
181 throw std::runtime_error(
182 "SMASH could not read in a line from your initial nuclei input file."
183 "\nCheck if your file has the following format: x y z "
184 "spinprojection isospin");
188 }
else if (nucleon.
isospin == 0) {
191 custom_nucleus.push_back(nucleon);
195 throw std::runtime_error(
196 "Number of protons and/or neutrons in the nuclei input file does not "
197 "correspond to the number specified in the config.\nCheck the config "
198 "and your input file.");
200 return custom_nucleus;
Interface to the SMASH configuration files.
Value take(std::initializer_list< const char * > keys)
The default interface for SMASH to read configuration values.
size_t index_
Index needed to read out vector in distribute nucleon.
std::string file_path(const std::string &file_directory, const std::string &file_name)
Generates the name of the stream file.
static std::unique_ptr< std::ifstream > filestream_shared_
Filestream variable used if projectile and target are read in from the same file and they use the sam...
int number_of_protons_
Number of protons per nucleus.
ThreeVector distribute_nucleon() override
Returns position of a nucleon as given in the external file.
void arrange_nucleons() override
Sets the positions of the nucleons inside a nucleus.
CustomNucleus(Configuration &config, int testparticles, bool same_file)
Constructor that needs configuration parameters from input file and the number of testparticles.
std::vector< Nucleoncustom > custom_nucleus_
Vector contianing Data for one nucleus given in the particlelist.
int number_of_neutrons_
Number of neutrons per nucleus.
int number_of_nucleons_
Number of nucleons per nucleus Set initally to zero to be modified in the constructor.
std::unique_ptr< std::ifstream > filestream_
Filestream variable used if projectile and target are read in from different files and they therefore...
std::vector< Nucleoncustom > readfile(std::ifstream &infile) const
The returned vector contains Data for one nucleus given in the particlelist.
void generate_fermi_momenta() override
Generates Fermi momenta as it is done in the mother class but in addition prints a warning that the F...
void fill_from_list(const std::vector< Nucleoncustom > &vec)
Fills Particlelist from vector containing data for one nucleus.
std::unique_ptr< std::ifstream > * used_filestream_
Pointer to the used filestream pointer.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
double euler_theta_
Euler angel theta.
void random_euler_angles()
Randomly generate Euler angles.
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
virtual void set_parameters_automatic()
Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number.
double euler_phi_
Euler angel phi.
std::vector< ParticleData > particles_
Particles associated with this nucleus.
double euler_psi_
Euler angel psi.
void align_center()
Shifts the nucleus so that its center is at (0,0,0)
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Particle type contains the static properties of a particle species.
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
The ThreeVector class represents a physical three-vector with the components .
void rotate(double phi, double theta, double psi)
Rotate vector by the given Euler angles phi, theta, psi.
Collection of useful constants that are known at compile time.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
static constexpr int LCollider
Contains data for one nucleon that is read in from the list.
bool isospin
to differentiate between protons isospin=1 and neutrons isospin=0
bool spinprojection
spinprojection of the nucleon