Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SmashWrapper.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SmashWrapper.h
1 /*******************************************************************************
2  * Copyright (c) The JETSCAPE Collaboration, 2018
3  *
4  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
5  *
6  * For the list of contributors see AUTHORS.
7  *
8  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
9  *
10  * or via email to bugs.jetscape@gmail.com
11  *
12  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
13  * See COPYING for details.
14  ******************************************************************************/
15 // -----------------------------------------
16 // This is a wrapper for SMASH hadronic afterburner with the JETSCAPE framework
17 // -----------------------------------------
18 
19 #ifndef SMASHWRAPPER_H
20 #define SMASHWRAPPER_H
21 
22 #include "smash/configuration.h"
23 #include "smash/experiment.h"
24 #include "smash/listmodus.h"
25 
26 #include "Afterburner.h"
27 #include "JetScapeWriter.h"
28 
29 using namespace Jetscape;
30 
36 class AfterburnerModus : public smash::ListModus {
37 public:
38  // Unlike for ListModus there is no need to get any data from the config
39  AfterburnerModus(smash::Configuration config, const smash::ExperimentParameters &) {
40  JSINFO << "Constructing AfterburnerModus";
41  config.clear();
42  }
43  void reset_event_numbering() { event_number_ = 0; }
44  // The converter is not static, because modus holds int variables
45  // for the number of warnings, which are used in try_create_particle,
46  // called by this function. Maybe I (oliiny) will change this design in SMASH
47  // later, but now I have to put this converter inside the AfterburnerModus.
48  void JS_hadrons_to_smash_particles(
49  const std::vector<shared_ptr<Hadron>> &JS_hadrons,
50  smash::Particles &smash_particles);
51 
52  // This function overrides the function from ListModus.
53  double initial_conditions(smash::Particles *particles,
54  const smash::ExperimentParameters &) {
55  JS_hadrons_to_smash_particles(jetscape_hadrons_[event_number_], *particles);
56  backpropagate_to_same_time(*particles);
57  event_number_++;
58  return start_time_;
59  }
60  std::vector<std::vector<shared_ptr<Hadron>>> jetscape_hadrons_;
61 
62 private:
63  int event_number_ = 0;
64 };
65 
66 class SmashWrapper : public Afterburner {
67 private:
68  bool only_final_decays_ = false;
69  double end_time_ = -1.0;
70  shared_ptr<smash::Experiment<AfterburnerModus>> smash_experiment_;
71 
72  // Allows the registration of the module so that it is available to be used by the Jetscape framework.
74 
75 public:
76  void
77  smash_particles_to_JS_hadrons(const smash::Particles &smash_particles,
78  std::vector<shared_ptr<Hadron>> &JS_hadrons);
79  SmashWrapper();
80  void InitTask();
81  void ExecuteTask();
82  void WriteTask(weak_ptr<JetScapeWriter> w);
83 };
84 
85 #endif // SMASHWRAPPER_H