Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:07

0001 // TRENTO: Reduced Thickness Event-by-event Nuclear Topology
0002 // Copyright 2015 Jonah E. Bernhard, J. Scott Moreland
0003 // TRENTO3D: Three-dimensional extension of TRENTO by Weiyao Ke
0004 // MIT License
0005 
0006 #ifndef EVENT_H
0007 #define EVENT_H
0008 
0009 #include <functional>
0010 #include <map>
0011 
0012 #ifdef NDEBUG
0013 #define BOOST_DISABLE_ASSERTS
0014 #endif
0015 #include <boost/multi_array.hpp>
0016 
0017 #include "fwd_decl.h"
0018 #include "rapidity_profile.h"
0019 #include "nucleon.h"
0020 
0021 namespace trento {
0022 
0023 class NucleonProfile;
0024 
0025 /// \rst
0026 /// The primary computation class, responsible for constructing nuclear
0027 /// thickness functions and calculating event observables.  Designed to be
0028 /// created once and used many times by repeatedly calling ``compute()``.
0029 /// Stores its observables internally and provides inspector methods.
0030 ///
0031 /// Example::
0032 ///
0033 ///   Event event{var_map};
0034 ///   for (int n = 0; n < nevents; ++n) {
0035 ///     event.compute(nucleusA, nucleusB, nucleon_profile);
0036 ///     do_something(
0037 ///       event.npart(),
0038 ///       event.multiplicity(),
0039 ///       event.eccentricity(),
0040 ///       event.reduced_thickness_grid()
0041 ///     );
0042 ///   }
0043 ///
0044 /// \endrst
0045 
0046 class Event {
0047  public:
0048   /// Instantiate from the configuration.
0049   explicit Event(const VarMap& var_map);
0050 
0051   /// \rst
0052   /// Compute thickness functions and event observables for a pair of
0053   /// ``Nucleus`` objects and a ``NucleonProfile``.  The nuclei must have
0054   /// already sampled nucleon positions and participants before passing to this
0055   /// function.
0056   /// \endrst
0057   void compute(const Nucleus& nucleusA, const Nucleus& nucleusB,
0058                NucleonProfile& profile);
0059 
0060   /// Alias for a 2-dimensional grid
0061   using Grid = boost::multi_array<double, 2>;
0062 
0063   /// Alias for a 3-dimensional grid
0064   using Grid3D = boost::multi_array<double, 3>;
0065 
0066   /// Number of nucleon participants.
0067   const int& npart() const
0068   { return npart_; }
0069 
0070   /// WK: Number of binary collision.
0071   const int& ncoll() const
0072   { return ncoll_; }
0073 
0074   /// \rst
0075   /// Multiplicity---or more specifically, total entropy.  May be interpreted
0076   /// as `dS/dy` or `dS/d\eta` at midrapidity.
0077   /// \endrst
0078   const double& multiplicity() const
0079   { return multiplicity_; }
0080 
0081   /// \rst
0082   /// Eccentricity harmonics `\varepsilon_n` for *n* = 2--5.
0083   /// Returns a map of `(n : \varepsilon_n)` pairs, so e.g.::
0084   ///
0085   ///   double e2 = event.eccentricity().at(2);
0086   ///
0087   /// \endrst
0088   const std::map<int, double>& eccentricity() const
0089   { return eccentricity_; }
0090 
0091   /// The entropy (particle) density grid as a three-dimensional array.
0092   const Grid3D& density_grid() const {
0093     if (is3D())
0094       return density_;
0095     else
0096       return TR_;
0097   }
0098 
0099   /// returns grid steps
0100   const double& dxy() const
0101   { return dxy_; }
0102 
0103   const double& deta() const
0104   { return deta_; }
0105 
0106   const std::map<int, double>& participant_plane() const
0107   { return psi_; }
0108 
0109 
0110   /// WK: The TAB grid for hard process vertex sampling
0111   const Grid& TAB_grid() const
0112   { return TAB_; }
0113 
0114   /// WK: clear and increase TAB
0115   void clear_TAB(void);
0116   void accumulate_TAB(Nucleon& A, Nucleon& B, NucleonProfile& profile);
0117 
0118   /// WK:
0119   const bool& with_ncoll() const
0120   { return with_ncoll_; }
0121 
0122   const std::pair<double, double> mass_center_index() const
0123 { return std::make_pair(ixcm_, iycm_); }
0124 
0125  private:
0126   /// Compute a nuclear thickness function (TA or TB) onto a grid for a given
0127   /// nucleus and nucleon profile.  This destroys any data previously contained
0128   /// by the grid.
0129   void compute_nuclear_thickness(
0130       const Nucleus& nucleus, NucleonProfile& profile, Grid& TX);
0131 
0132   /// Compute the reduced thickness function (TR) after computing TA and TB.
0133   /// Template parameter GenMean sets the actual function that returns TR(TA, TB).
0134   /// It is determined at runtime based on the configuration.
0135   template <typename GenMean>
0136   void compute_reduced_thickness(GenMean gen_mean);
0137 
0138   /// An instantation of compute_reduced_thickness<GenMean> with a bound
0139   /// argument for GenMean.  Created in the ctor.  Implemented this way to
0140   /// allow the compiler to fully inline the GenMean function and only require a
0141   /// single "virtual" function call per event.
0142   std::function<void()> compute_reduced_thickness_;
0143 
0144   /// Compute observables that require a second pass over the reduced thickness grid.
0145   void compute_observables();
0146 
0147   // Returns true if running in 3D mode, false otherwise.
0148   bool is3D() const;
0149 
0150   /// Normalization factor.
0151   const double norm_;
0152 
0153   /// Beam energy sqrt(s) and beam rapidity y.
0154   const double beam_energy_, exp_ybeam_;
0155 
0156   /// Rapidity distribution cumulant coefficients.
0157   const double mean_coeff_, std_coeff_, skew_coeff_;
0158   const int skew_type_;
0159 
0160   /// Grid step size.
0161   const double dxy_, deta_;
0162 
0163   /// Number of grid steps.
0164   const int nsteps_, neta_;
0165 
0166   /// Grid xy maximum (half width).
0167   const double xymax_, etamax_;
0168 
0169   /// fast eta to y transformer.
0170   fast_eta2y eta2y_;
0171 
0172   /// cumulant generating approach
0173   cumulant_generating cgf_;
0174 
0175   /// Reduced thickness and entropy (particle) density grids
0176   Grid3D TR_, density_;
0177 
0178   /// Nuclear thickness grids TA, TB and reduced thickness grid TR.
0179   Grid TA_, TB_, TAB_;
0180 
0181   /// Center of mass coordinates in "units" of grid index (not fm).
0182   double ixcm_, iycm_;
0183 
0184   /// Number of participants.
0185   int npart_;
0186 
0187   /// WK: Number of binary collisions.
0188   int ncoll_;
0189 
0190   /// Multiplicity (total entropy).
0191   double multiplicity_;
0192 
0193   /// Eccentricity harmonics.
0194   std::map<int, double> eccentricity_;
0195 
0196   /// WK: Initial density event planes.
0197   std::map<int, double> psi_;
0198 
0199   /// WK:
0200   bool with_ncoll_;
0201 };
0202 
0203 }  // namespace trento
0204 
0205 #endif  // EVENT_H