Version: SMASH-3.4
scatteractionsfinder.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2022,2025
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_SCATTERACTIONSFINDER_H_
11 #define SRC_INCLUDE_SMASH_SCATTERACTIONSFINDER_H_
12 
13 #include <memory>
14 #include <set>
15 #include <vector>
16 
17 #include "action.h"
18 #include "actionfinderfactory.h"
19 #include "configuration.h"
20 #include "scatteraction.h"
22 
23 namespace smash {
24 
25 /**
26  * \ingroup action
27  * A simple scatter finder:
28  * Just loops through all particles and checks each pair for a collision.
29  * It supports two collision criteria: a geometric and stochastic criterion.
30  */
32  public:
33  /**
34  * Constructor of the finder with the given parameters.
35  *
36  * \param[inout] config Configuration of smash from which we take:
37  * 1) A global elastic cross section [mb]. It will be used
38  * regardless of the species of the colliding particles.
39  * It won't be used if the value is negative.
40  * 2) An option determining whether all the scatterings are
41  * isotropic
42  * 3) Parameters of the string process
43  * \param[in] parameters Struct of parameters determining whether to
44  * exclude some certain types of scatterings and switching
45  * among the methods to treat with the NNbar collisions.
46  */
48  const ExperimentParameters &parameters);
49 
50  /**
51  * Determine the collision time of the two particles.
52  * Time of the closest approach is taken as collision time, if the geometric
53  * collision criterion is used. For stochastic criterion the time is
54  * distributed uniformly within the timestep.
55  *
56  * \param[in] p1 First incoming particle
57  * \param[in] p2 Second incoming particle
58  * \param[in] dt The maximum time interval at the current time step [fm]
59  * \param[in] beam_momentum [GeV] List of beam momenta for each particle;
60  * only necessary for frozen Fermi motion
61  * \return How long does it take for the two incoming particles
62  * to propagate before scattering [fm]. It's set equal
63  * to -1 if the two particles are not moving relative to each
64  * other.
65  */
66  inline double collision_time(
67  const ParticleData &p1, const ParticleData &p2, double dt,
68  const std::vector<FourVector> &beam_momentum) const {
70  return dt * random::uniform(0., 1.);
71  } else {
72  /*
73  * For frozen Fermi motion:
74  * If particles have not yet interacted and are the initial nucleons,
75  * perform action finding with beam momentum instead of Fermi motion
76  * corrected momentum. That is because the particles are propagated with
77  * the beam momentum until they interact.
78  */
79  if (p1.id() < 0 || p2.id() < 0) {
80  throw std::runtime_error("Invalid particle ID for Fermi motion");
81  }
82  const bool p1_has_no_prior_interactions =
83  (static_cast<uint64_t>(p1.id()) < // particle from
84  static_cast<uint64_t>(beam_momentum.size())) && // initial nucleus
86 
87  const bool p2_has_no_prior_interactions =
88  (static_cast<uint64_t>(p2.id()) < // particle from
89  static_cast<uint64_t>(beam_momentum.size())) && // initial nucleus
91 
92  const FourVector p1_mom = (p1_has_no_prior_interactions)
93  ? beam_momentum[p1.id()]
94  : p1.momentum();
95  const FourVector p2_mom = (p2_has_no_prior_interactions)
96  ? beam_momentum[p2.id()]
97  : p2.momentum();
99  /**
100  * JAM collision times from the closest approach
101  * in the two-particle center-of-mass-framem,
102  * see \iref{Hirano:2012yy} (5.13) and (5.14).
103  * The scatteraction is performed at the mean of these two times.
104  */
105  const FourVector delta_x = p1.position() - p2.position();
106  const double p1_sqr = p1_mom.sqr();
107  const double p2_sqr = p2_mom.sqr();
108  const double p1_dot_x = p1_mom.Dot(delta_x);
109  const double p2_dot_x = p2_mom.Dot(delta_x);
110  const double p1_dot_p2 = p1_mom.Dot(p2_mom);
111  const double denominator = std::pow(p1_dot_p2, 2) - p1_sqr * p2_sqr;
112  if (unlikely(std::abs(denominator) < really_small * really_small)) {
113  return -1.0;
114  }
115 
116  const double time_1 = (p2_sqr * p1_dot_x - p1_dot_p2 * p2_dot_x) *
117  p1_mom.x0() / denominator;
118  const double time_2 = -(p1_sqr * p2_dot_x - p1_dot_p2 * p1_dot_x) *
119  p2_mom.x0() / denominator;
120  return (time_1 + time_2) / 2;
121  } else {
122  /**
123  * UrQMD collision time in computational frame,
124  * see \iref{Bass:1998ca} (3.28):
125  * position of particle 1: \f$r_1\f$ [fm]
126  * position of particle 2: \f$r_2\f$ [fm]
127  * velocity of particle 1: \f$v_1\f$
128  * velocity of particle 1: \f$v_2\f$
129  * \f[t_{coll} = - (r_1 - r_2) . (v_1 - v_2) / (v_1 - v_2)^2\f] [fm]
130  */
131  const ThreeVector dv_times_e1e2 =
132  p1_mom.threevec() * p2_mom.x0() - p2_mom.threevec() * p1_mom.x0();
133  const double dv_times_e1e2_sqr = dv_times_e1e2.sqr();
134  if (dv_times_e1e2_sqr < really_small) {
135  return -1.0;
136  }
137  const ThreeVector dr =
138  p1.position().threevec() - p2.position().threevec();
139  return -(dr * dv_times_e1e2) *
140  (p1_mom.x0() * p2_mom.x0() / dv_times_e1e2_sqr);
141  }
142  }
143  }
144 
145  /**
146  * Search for all the possible collisions within one cell. This function is
147  * only used for counting the primary collisions at the beginning of each
148  * time step. (Although it's also called afterwards for searching the
149  * secondary collisions among the outgoing particles, no new actions will be
150  * found since the scattered pairs cannot scatter again.)
151  *
152  * \param[in] search_list A list of particles within one cell
153  * \param[in] dt The maximum time interval at the current time step [fm]
154  * \param[in] gcell_vol Volume of searched grid cell [fm^3]
155  * \param[in] beam_momentum [GeV] List of beam momenta for each particle;
156  * only necessary for frozen Fermi motion
157  * \return A list of possible scatter actions
158  */
159  ActionList find_actions_in_cell(
160  const ParticleList &search_list, double dt, const double gcell_vol,
161  const std::vector<FourVector> &beam_momentum) const override;
162 
163  /**
164  * Search for all the possible collisions among the neighboring cells. This
165  * function is only used for counting the primary collisions at the beginning
166  * of each time step.
167  *
168  * \param[in] search_list A list of particles within the current cell
169  * \param[in] neighbors_list A list of particles within the neighboring cell
170  * \param[in] dt The maximum time interval at the current time step [fm]
171  * \param[in] beam_momentum [GeV] List of beam momenta for each particle;
172  * only necessary for frozen Fermi motion
173  * \return A list of possible scatter actions
174  */
175  ActionList find_actions_with_neighbors(
176  const ParticleList &search_list, const ParticleList &neighbors_list,
177  double dt, const std::vector<FourVector> &beam_momentum) const override;
178 
179  /**
180  * Search for all the possible secondary collisions between the outgoing
181  * particles and the rest.
182  *
183  * \param[in] search_list A list of particles within the current cell
184  * \param[in] surrounding_list The whole particle list
185  * \param[in] dt The maximum time interval at the current time step [fm]
186  * \param[in] beam_momentum [GeV] List of beam momenta for each particle;
187  * only necessary for frozen Fermi motion
188  * \return A list of possible scatter actions
189  */
191  const ParticleList &search_list, const Particles &surrounding_list,
192  double dt, const std::vector<FourVector> &beam_momentum) const override;
193 
194  /// No scatterings should be found when the event is over.
195  ActionList find_final_actions(const Particles &) const override { return {}; }
196 
197  /**
198  * If there is only one particle sort, no decays
199  * (only elastic scatterings are possible),
200  * scatterings are isotropic and cross-section fixed to elastic_parameter_
201  * independently on momenta, then maximal cross-section is elastic_parameter_.
202  * This knowledge can be used for improving performance.
203  *
204  * \return A boolean indicating whether all the scatterings are elastic
205  * and isotropic
206  */
207  inline bool is_constant_elastic_isotropic() const {
208  return ParticleType::list_all().size() == 1 &&
211  }
212 
213  /**
214  * The maximal distance over which particles can interact in case of the
215  * geometric criterion, related to the number of test particles and the
216  * maximal cross section.
217  *
218  * \param[in] testparticles Number of test particles.
219  *
220  * \return Maximal transverse distance squared. [fm\f$^{2}\f$]
221  * Particle pairs whose transverse distance is larger than this
222  * are not checked for collisions in case of the default geometric
223  * collision criterion.
224  */
225  double max_transverse_distance_sqr(int testparticles) const {
229  testparticles * fm2_mb * M_1_PI;
230  }
231 
232  /**
233  * Prints out all the 2-> n (n > 1) reactions with non-zero cross-sections
234  * between all possible pairs of particle types.
235  */
236  void dump_reactions() const;
237 
238  /**
239  * Print out partial cross-sections of all processes that can occur in
240  * the collision of a(mass = m_a) and b(mass = m_b).
241  *
242  * \param[in] a The specie of the first incoming particle.
243  * \param[in] b The specie of the second incoming particle.
244  * \param[in] m_a Mass of species a [GeV].
245  * \param[in] m_b Mass of species b [GeV].
246  * \param[in] final_state Whether the final state cross sections should be
247  * printed.
248  * \param[in] plab Optional momenta in lab frame to be evaluated [GeV].
249  * Ignored if empty.
250  */
251  void dump_cross_sections(const ParticleType &a, const ParticleType &b,
252  double m_a, double m_b, bool final_state,
253  std::vector<double> &plab) const;
254 
255  /**
256  * \return Pointer to the string process class object.
257  * If string is turned off, the null pointer is returned.
258  */
261  return string_process_interface_.get();
262  } else {
263  return NULL;
264  }
265  }
266 
267  private:
268  /**
269  * Check for a single pair of particles (id_a, id_b) if a collision will
270  * happen in the next timestep and create a corresponding Action object
271  * in that case.
272  *
273  * Two criteria for the collision decision are supported: 1. The default
274  * geometric criterion from UrQMD \iref{Bass:1998ca} (3.27). 2. A stochastic
275  * collision criterion as introduced in \iref{Staudenmaier:2021lrg}.
276  *
277  * \param[in] data_a First incoming particle
278  * \param[in] data_b Second incoming particle
279  * \param[in] dt Maximum time interval within which a collision can happen
280  * \param[in] beam_momentum [GeV] List of beam momenta for each particle;
281  * only necessary for frozen Fermi motion
282  * \param[in] gcell_vol (optional) volume of grid cell in which the collision
283  * is checked
284  * \return A null pointer if no collision happens or an action which contains
285  * the information of the outgoing particles.
286  *
287  * Note: gcell_vol is optional, since only find_actions_in_cell has (and
288  * needs) this information for the stochastic collision criterion.
289  */
290  ActionPtr check_collision_two_part(
291  const ParticleData &data_a, const ParticleData &data_b, double dt,
292  const std::vector<FourVector> &beam_momentum = {},
293  const double gcell_vol = 0.0) const;
294 
295  /**
296  * Check for multiple i.e. more than 2 particles if a collision will happen in
297  * the next timestep and create a corresponding Action object in that case.
298  *
299  * This is only possible for the stochastic collision criterion, which is
300  * introduced in \iref{Staudenmaier:2021lrg}. Following the same general idea
301  * as for the 2-particle scatterings, probabilities for multi-particle
302  * scatterings can be derived.
303  *
304  * \param[in] plist List of incoming particles
305  * \param[in] dt Maximum time interval within which a collision can happen
306  * \param[in] gcell_vol volume of grid cell in which the collision is checked
307  * \return A null pointer if no collision happens or an action which contains
308  * the information of the outgoing particles.
309  */
310  ActionPtr check_collision_multi_part(const ParticleList &plist, double dt,
311  const double gcell_vol) const;
312 
313  /// Struct collecting several parameters.
315  /// Class that deals with strings, interfacing Pythia.
316  std::unique_ptr<StringProcess> string_process_interface_;
317  /// Do all collisions isotropically.
318  const bool isotropic_;
319  /**
320  * Box length: needed to determine coordinates of collision
321  * correctly in case of collision through the wall.
322  * Ignored if negative.
323  */
324  const double box_length_;
325  /// Parameter for formation time
327 };
328 
329 /**
330  * Gather all relevant parameters for a \c ScatterActionsFinder either getting
331  * them from an \c ExperimentParameters instance or extracting them from
332  * a \c Configuration .
333  *
334  * \param[in] parameters The parameters of the considered experiment
335  * \param[inout] config SMASH input configuration
336  * \return A \c ScatterActionsFinderParameters appropriately filled.
337  */
339  Configuration &config, const ExperimentParameters &parameters);
340 
341 } // namespace smash
342 
343 #endif // SRC_INCLUDE_SMASH_SCATTERACTIONSFINDER_H_
ActionFinderInterface is the abstract base class for all action finders, i.e.
Interface to the SMASH configuration files.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
double sqr() const
calculate the square of the vector (which is a scalar)
Definition: fourvector.h:460
ThreeVector threevec() const
Definition: fourvector.h:329
double Dot(const FourVector &a) const
calculate the scalar product with another four-vector
Definition: fourvector.h:456
double x0() const
Definition: fourvector.h:313
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:59
const FourVector & momentum() const
Get the particle's 4-momentum.
Definition: particledata.h:171
int32_t id() const
Get the id of the particle.
Definition: particledata.h:77
HistoryData get_history() const
Get history information.
Definition: particledata.h:143
const FourVector & position() const
Get the particle's position in Minkowski space.
Definition: particledata.h:217
Particle type contains the static properties of a particle species.
Definition: particletype.h:100
static const ParticleTypeList & list_all()
Definition: particletype.cc:51
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
Helper class for ScatterActionsFinder.
const double elastic_parameter
Elastic cross section parameter (in mb).
const bool strings_switch
Indicates whether string fragmentation is switched on.
const bool two_to_one
Enables resonance production.
const CollisionCriterion coll_crit
Specifies which collision criterion is used.
A simple scatter finder: Just loops through all particles and checks each pair for a collision.
ScatterActionsFinder(Configuration &config, const ExperimentParameters &parameters)
Constructor of the finder with the given parameters.
ScatterActionsFinderParameters finder_parameters_
Struct collecting several parameters.
ActionList find_actions_in_cell(const ParticleList &search_list, double dt, const double gcell_vol, const std::vector< FourVector > &beam_momentum) const override
Search for all the possible collisions within one cell.
void dump_cross_sections(const ParticleType &a, const ParticleType &b, double m_a, double m_b, bool final_state, std::vector< double > &plab) const
Print out partial cross-sections of all processes that can occur in the collision of a(mass = m_a) an...
StringProcess * get_process_string_ptr()
const bool isotropic_
Do all collisions isotropically.
double max_transverse_distance_sqr(int testparticles) const
The maximal distance over which particles can interact in case of the geometric criterion,...
ActionPtr check_collision_two_part(const ParticleData &data_a, const ParticleData &data_b, double dt, const std::vector< FourVector > &beam_momentum={}, const double gcell_vol=0.0) const
Check for a single pair of particles (id_a, id_b) if a collision will happen in the next timestep and...
const double string_formation_time_
Parameter for formation time.
std::unique_ptr< StringProcess > string_process_interface_
Class that deals with strings, interfacing Pythia.
void dump_reactions() const
Prints out all the 2-> n (n > 1) reactions with non-zero cross-sections between all possible pairs of...
bool is_constant_elastic_isotropic() const
If there is only one particle sort, no decays (only elastic scatterings are possible),...
ActionList find_final_actions(const Particles &) const override
No scatterings should be found when the event is over.
ActionPtr check_collision_multi_part(const ParticleList &plist, double dt, const double gcell_vol) const
Check for multiple i.e.
const double box_length_
Box length: needed to determine coordinates of collision correctly in case of collision through the w...
ActionList find_actions_with_surrounding_particles(const ParticleList &search_list, const Particles &surrounding_list, double dt, const std::vector< FourVector > &beam_momentum) const override
Search for all the possible secondary collisions between the outgoing particles and the rest.
ActionList find_actions_with_neighbors(const ParticleList &search_list, const ParticleList &neighbors_list, double dt, const std::vector< FourVector > &beam_momentum) const override
Search for all the possible collisions among the neighboring cells.
double collision_time(const ParticleData &p1, const ParticleData &p2, double dt, const std::vector< FourVector > &beam_momentum) const
Determine the collision time of the two particles.
String excitation processes used in SMASH.
Definition: stringprocess.h:46
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
double sqr() const
Definition: threevector.h:275
@ Stochastic
Stochastic Criteiron.
@ Covariant
Covariant Criterion.
#define unlikely(x)
Tell the branch predictor that this expression is likely false.
Definition: macros.h:16
T uniform(T min, T max)
Definition: random.h:91
Definition: action.h:24
ScatterActionsFinderParameters create_finder_parameters(Configuration &config, const ExperimentParameters &parameters)
Gather all relevant parameters for a ScatterActionsFinder either getting them from an ExperimentParam...
constexpr double really_small
Numerical error tolerance.
Definition: constants.h:41
constexpr double fm2_mb
mb <-> fm^2 conversion factor.
Definition: constants.h:32
Helper structure for Experiment.
int32_t collisions_per_particle
Collision counter per particle, zero only for initially present particles.
Definition: particledata.h:33