Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /*******************************************************************************
0002  * Copyright (c) The JETSCAPE Collaboration, 2018
0003  *
0004  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
0005  *
0006  * For the list of contributors see AUTHORS.
0007  *
0008  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
0009  *
0010  * or via email to bugs.jetscape@gmail.com
0011  *
0012  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
0013  * See COPYING for details.
0014  ******************************************************************************/
0015 // -----------------------------------------
0016 // This is a wrapper for SMASH hadronic afterburner with the JETSCAPE framework
0017 // -----------------------------------------
0018 
0019 #ifndef SMASHWRAPPER_H
0020 #define SMASHWRAPPER_H
0021 
0022 #include "smash/configuration.h"
0023 #include "smash/experiment.h"
0024 #include "smash/listmodus.h"
0025 
0026 #include "Afterburner.h"
0027 #include "JetScapeWriter.h"
0028 
0029 using namespace Jetscape;
0030 
0031 /**
0032  * An Afterburner modus, which acts similarly to SMASH ListModus,
0033  * initializes from Jetscape hadrons, not from file. Needed to use
0034  * SMASH as a 3rd party Afterburner.
0035  */
0036 class AfterburnerModus : public smash::ListModus {
0037 public:
0038   // Unlike for ListModus there is no need to get any data from the config
0039   AfterburnerModus(smash::Configuration config, const smash::ExperimentParameters &) {
0040     JSINFO << "Constructing AfterburnerModus";
0041     config.clear();
0042   }
0043   void reset_event_numbering() { event_number_ = 0; }
0044   // The converter is not static, because modus holds int variables
0045   // for the number of warnings, which are used in try_create_particle,
0046   // called by this function. Maybe I (oliiny) will change this design in SMASH
0047   // later, but now I have to put this converter inside the AfterburnerModus.
0048   void JS_hadrons_to_smash_particles(
0049       const std::vector<shared_ptr<Hadron>> &JS_hadrons,
0050       smash::Particles &smash_particles);
0051 
0052   // This function overrides the function from ListModus.
0053   double initial_conditions(smash::Particles *particles,
0054                             const smash::ExperimentParameters &) {
0055     JS_hadrons_to_smash_particles(jetscape_hadrons_[event_number_], *particles);
0056     backpropagate_to_same_time(*particles);
0057     event_number_++;
0058     return start_time_;
0059   }
0060   std::vector<std::vector<shared_ptr<Hadron>>> jetscape_hadrons_;
0061 
0062 private:
0063   int event_number_ = 0;
0064 };
0065 
0066 class SmashWrapper : public Afterburner {
0067 private:
0068   bool only_final_decays_ = false;
0069   double end_time_ = -1.0;
0070   shared_ptr<smash::Experiment<AfterburnerModus>> smash_experiment_;
0071 
0072   // Allows the registration of the module so that it is available to be used by the Jetscape framework.
0073   static RegisterJetScapeModule<SmashWrapper> reg;
0074 
0075 public:
0076   void
0077   smash_particles_to_JS_hadrons(const smash::Particles &smash_particles,
0078                                 std::vector<shared_ptr<Hadron>> &JS_hadrons);
0079   SmashWrapper();
0080   void InitTask();
0081   void ExecuteTask();
0082   void WriteTask(weak_ptr<JetScapeWriter> w);
0083 };
0084 
0085 #endif // SMASHWRAPPER_H