Version: SMASH-2.0.2
hepmcinterface.h
Go to the documentation of this file.
1 
2 /*
3  *
4  * Copyright (c) 2021 Christian Holm Christensen
5  * GNU General Public License (GPLv3 or later)
6  *
7  */
8 
9 #ifndef SRC_INCLUDE_SMASH_HEPMCINTERFACE_H_
10 #define SRC_INCLUDE_SMASH_HEPMCINTERFACE_H_
11 
12 #include <map>
13 #include <memory>
14 #include <string>
15 #include <utility>
16 #include <valarray>
17 
18 #include "HepMC3/GenCrossSection.h"
19 #include "HepMC3/GenEvent.h"
20 #include "HepMC3/GenHeavyIon.h"
21 #include "HepMC3/GenParticle.h"
22 #include "HepMC3/GenVertex.h"
23 
24 #include "action.h"
25 #include "forwarddeclarations.h"
26 #include "outputinterface.h"
27 #include "outputparameters.h"
28 namespace smash {
29 
82  public:
84  using AZ = std::pair<int, int>;
94  HepMcInterface(const std::string& name, const bool full_event,
95  const int total_N, const int proj_N);
107  void at_eventstart(const Particles& particles, const int event_number,
108  const EventInfo& event) override;
116  void at_interaction(const Action& action, const double density) override;
125  void at_eventend(const Particles& particles, const int32_t event_number,
126  const EventInfo& event) override;
127 
128  protected:
130  enum Status {
131  beam = 4, // Beam particle
132  fnal = 1, // final state `final` is a reserved word
133  dcy = 2, // Decay
134  off = 100
135  };
137  using IdMap = std::map<int, HepMC3::GenParticlePtr>;
139  using CollCounter = std::valarray<int>;
141  void clear();
143  int get_status(const ProcessType& t) const;
154  HepMC3::GenParticlePtr make_gen(int pid, int status,
155  const smash::FourVector& mom,
156  double mass = -1);
165  HepMC3::GenParticlePtr make_register(const ParticleData& p,
166  int status = Status::fnal);
176  HepMC3::GenParticlePtr find_or_make(const ParticleData& p,
177  int status = Status::fnal,
178  bool force_new = false);
186  int ion_pdg(const AZ& az) const;
188  HepMC3::GenEvent event_;
190  HepMC3::GenHeavyIonPtr ion_;
192  HepMC3::GenCrossSectionPtr xs_;
194  HepMC3::GenVertexPtr ip_;
220  int ncoll_;
228  const int total_N_;
233  const int proj_N_;
236 };
237 } // namespace smash
238 
239 #endif // SRC_INCLUDE_SMASH_HEPMCINTERFACE_H_
smash
Definition: action.h:24
outputparameters.h
smash::HepMcInterface::CollCounter
std::valarray< int > CollCounter
Counter of collitions per incoming particle.
Definition: hepmcinterface.h:139
smash::HepMcInterface::map_
IdMap map_
Mapping from ID to particle.
Definition: hepmcinterface.h:196
smash::HepMcInterface::ncoll_hard_
int ncoll_hard_
counter of hard binary collisions (e.g., where both incoming particles are from the beams.
Definition: hepmcinterface.h:223
smash::HepMcInterface::at_interaction
void at_interaction(const Action &action, const double density) override
Writes collisions to event.
Definition: hepmcinterface.cc:106
smash::HepMcInterface::find_or_make
HepMC3::GenParticlePtr find_or_make(const ParticleData &p, int status=Status::fnal, bool force_new=false)
Find particle in mapping or generate it.
Definition: hepmcinterface.cc:214
smash::ParticleData
Definition: particledata.h:52
smash::HepMcInterface::event_
HepMC3::GenEvent event_
The event.
Definition: hepmcinterface.h:188
smash::HepMcInterface::total_N_
const int total_N_
Total number of nucleons in projectile and target, needed for converting nuclei to single particles.
Definition: hepmcinterface.h:228
smash::HepMcInterface::ncoll_
int ncoll_
counter of binary collisions (e.g., where both incoming particles are from the beams.
Definition: hepmcinterface.h:220
smash::HepMcInterface::make_gen
HepMC3::GenParticlePtr make_gen(int pid, int status, const smash::FourVector &mom, double mass=-1)
Make an HepMC particle.
Definition: hepmcinterface.cc:194
action.h
smash::EventInfo
Structure to contain custom data for output.
Definition: outputinterface.h:36
smash::HepMcInterface::off
@ off
Definition: hepmcinterface.h:134
forwarddeclarations.h
smash::HepMcInterface::HepMcInterface
HepMcInterface(const std::string &name, const bool full_event, const int total_N, const int proj_N)
Create HepMC particle event in memory.
Definition: hepmcinterface.cc:18
smash::HepMcInterface::xs_
HepMC3::GenCrossSectionPtr xs_
Dummy cross-section.
Definition: hepmcinterface.h:192
outputinterface.h
smash::HepMcInterface::make_register
HepMC3::GenParticlePtr make_register(const ParticleData &p, int status=Status::fnal)
Find particle in mapping or generate it.
Definition: hepmcinterface.cc:204
smash::HepMcInterface::full_event_
bool full_event_
Whether the full event or only final-state particles are in the output.
Definition: hepmcinterface.h:235
smash::HepMcInterface::at_eventend
void at_eventend(const Particles &particles, const int32_t event_number, const EventInfo &event) override
Add the final particles information of an event to the central vertex.
Definition: hepmcinterface.cc:142
smash::HepMcInterface::fnal
@ fnal
Definition: hepmcinterface.h:132
smash::OutputInterface
Abstraction of generic output.
Definition: outputinterface.h:66
smash::HepMcInterface::ip_
HepMC3::GenVertexPtr ip_
The interaction point.
Definition: hepmcinterface.h:194
smash::HepMcInterface::IdMap
std::map< int, HepMC3::GenParticlePtr > IdMap
Type of mapping from SMASH ID to HepMC ID.
Definition: hepmcinterface.h:137
smash::HepMcInterface
Base class for output handlers that need the HepMC3 structure.
Definition: hepmcinterface.h:81
smash::Particles
Definition: particles.h:33
smash::HepMcInterface::ion_pdg
int ion_pdg(const AZ &az) const
Encode ion PDG.
Definition: hepmcinterface.cc:228
smash::HepMcInterface::get_status
int get_status(const ProcessType &t) const
Convert SMASH process type to HepMC status.
Definition: hepmcinterface.cc:186
smash::HepMcInterface::clear
void clear()
Clear before an event.
Definition: hepmcinterface.cc:177
smash::HepMcInterface::ion_
HepMC3::GenHeavyIonPtr ion_
The heavy-ion structure.
Definition: hepmcinterface.h:190
smash::Action
Definition: action.h:35
smash::HepMcInterface::at_eventstart
void at_eventstart(const Particles &particles, const int event_number, const EventInfo &event) override
Add the initial particles information of an event to the central vertex.
Definition: hepmcinterface.cc:38
smash::FourVector
Definition: fourvector.h:33
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::HepMcInterface::coll_
CollCounter coll_
Collision counter.
Definition: hepmcinterface.h:217
smash::HepMcInterface::Status
Status
HepMC status codes.
Definition: hepmcinterface.h:130
smash::HepMcInterface::dcy
@ dcy
Definition: hepmcinterface.h:133
smash::HepMcInterface::proj_N_
const int proj_N_
Total number of nucleons in projectile, needed for converting nuclei to single particles.
Definition: hepmcinterface.h:233
smash::HepMcInterface::AZ
std::pair< int, int > AZ
Pair of Atomic weight and number.
Definition: hepmcinterface.h:84
smash::HepMcInterface::beam
@ beam
Definition: hepmcinterface.h:131
smash::ProcessType
ProcessType
Process Types are used to identify the type of the process.
Definition: processbranch.h:25