Version: SMASH-2.0
listmodus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2020
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_LISTMODUS_H_
8 #define SRC_INCLUDE_SMASH_LISTMODUS_H_
9 
10 #include <cmath>
11 #include <cstdint>
12 #include <list>
13 #include <string>
14 #include <utility>
15 
16 #include "forwarddeclarations.h"
17 #include "modusdefault.h"
18 
19 namespace smash {
20 
56 class ListModus : public ModusDefault {
57  public:
68  explicit ListModus(Configuration modus_config,
69  const ExperimentParameters &parameters);
70 
72  ListModus() : shift_id_(0) {}
73 
86  double initial_conditions(Particles *particles,
87  const ExperimentParameters &parameters);
98  void backpropagate_to_same_time(Particles &particles);
99 
131  void try_create_particle(Particles &particles, PdgCode pdgcode, double t,
132  double x, double y, double z, double mass, double E,
133  double px, double py, double pz);
134 
138  struct LoadFailure : public std::runtime_error {
139  using std::runtime_error::runtime_error;
140  };
141 
143  bool is_list() const { return true; }
144 
145  protected:
147  double start_time_ = 0.;
148 
149  private:
152 
155 
158 
160  const int shift_id_;
161 
164 
166  int file_id_;
167 
172 
182  bool file_has_events_(bf::path filepath, std::streampos last_position);
183 
185  std::streampos last_read_position_;
186 
195  bf::path file_path_(const int file_id);
196 
204  std::string next_event_();
205 
212  friend std::ostream &operator<<(std::ostream &, const ListModus &);
213 };
214 
215 } // namespace smash
216 
217 #endif // SRC_INCLUDE_SMASH_LISTMODUS_H_
smash
Definition: action.h:24
smash::ListModus::LoadFailure
Definition: listmodus.h:138
smash::ListModus::particle_list_file_directory_
std::string particle_list_file_directory_
File directory of the particle list.
Definition: listmodus.h:151
modusdefault.h
smash::ListModus::initial_conditions
double initial_conditions(Particles *particles, const ExperimentParameters &parameters)
Generates initial state of the particles in the system according to a list.
Definition: listmodus.cc:227
smash::ListModus::n_warns_mass_consistency_
int n_warns_mass_consistency_
Counter for energy-momentum conservation warnings to avoid spamming.
Definition: listmodus.h:171
smash::ListModus::is_list
bool is_list() const
Definition: listmodus.h:143
smash::ListModus::current_particle_list_file_
std::string current_particle_list_file_
File name of current file.
Definition: listmodus.h:157
smash::ListModus::file_id_
int file_id_
file_id_ is the id of the current file
Definition: listmodus.h:166
smash::ListModus::operator<<
friend std::ostream & operator<<(std::ostream &, const ListModus &)
Definition: listmodus.cc:129
smash::ListModus::backpropagate_to_same_time
void backpropagate_to_same_time(Particles &particles)
Judge whether formation times are the same for all the particles; Don't do anti-freestreaming if all ...
Definition: listmodus.cc:135
smash::Configuration
Interface to the SMASH configuration files.
Definition: configuration.h:464
forwarddeclarations.h
smash::ListModus::start_time_
double start_time_
Starting time for the List; changed to the earliest formation time.
Definition: listmodus.h:147
smash::ListModus
Definition: listmodus.h:56
smash::PdgCode
Definition: pdgcode.h:108
smash::ModusDefault
Definition: modusdefault.h:44
smash::ListModus::try_create_particle
void try_create_particle(Particles &particles, PdgCode pdgcode, double t, double x, double y, double z, double mass, double E, double px, double py, double pz)
Tries to add a new particle to particles and performs consistency checks: (i) The PDG code is legal a...
Definition: listmodus.cc:172
smash::Particles
Definition: particles.h:33
smash::ListModus::file_has_events_
bool file_has_events_(bf::path filepath, std::streampos last_position)
Check if the file given by filepath has events left after streampos last_position.
Definition: listmodus.cc:330
smash::ListModus::n_warns_precision_
int n_warns_precision_
Counter for mass-check warnings to avoid spamming.
Definition: listmodus.h:169
smash::ListModus::last_read_position_
std::streampos last_read_position_
last read position in current file
Definition: listmodus.h:185
smash::ListModus::next_event_
std::string next_event_()
Read the next event.
Definition: listmodus.cc:292
smash::ExperimentParameters
Helper structure for Experiment.
Definition: experimentparameters.h:24
smash::ListModus::particle_list_file_prefix_
std::string particle_list_file_prefix_
File prefix of the particle list.
Definition: listmodus.h:154
smash::ListModus::event_id_
int event_id_
event_id_ = the unique id of the current event
Definition: listmodus.h:163
smash::ListModus::shift_id_
const int shift_id_
shift_id is the start number of file_id_
Definition: listmodus.h:160
smash::ListModus::ListModus
ListModus()
Construct an empty list. Useful for convenient JetScape connection.
Definition: listmodus.h:72
smash::ListModus::file_path_
bf::path file_path_(const int file_id)
Return the absolute file path based on given integer.
Definition: listmodus.cc:266