Version: SMASH-3.1
hepmcinterface.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2021 Christian Holm Christensen
4  * Copyright (c) 2021-2023
5  * SMASH Team
6  *
7  * GNU General Public License (GPLv3 or later)
8  *
9  */
10 
11 #ifndef SRC_INCLUDE_SMASH_HEPMCINTERFACE_H_
12 #define SRC_INCLUDE_SMASH_HEPMCINTERFACE_H_
13 
14 #include <map>
15 #include <memory>
16 #include <string>
17 #include <utility>
18 #include <valarray>
19 
20 #include "HepMC3/GenCrossSection.h"
21 #include "HepMC3/GenEvent.h"
22 #include "HepMC3/GenHeavyIon.h"
23 #include "HepMC3/GenParticle.h"
24 #include "HepMC3/GenVertex.h"
25 
26 #include "action.h"
27 #include "forwarddeclarations.h"
28 #include "outputinterface.h"
29 #include "outputparameters.h"
30 namespace smash {
31 
84  public:
86  using AZ = std::pair<int, int>;
94  HepMcInterface(const std::string& name, const bool full_event);
106  void at_eventstart(const Particles& particles, const int event_number,
107  const EventInfo& event) override;
115  void at_interaction(const Action& action, const double density) override;
124  void at_eventend(const Particles& particles, const int32_t event_number,
125  const EventInfo& event) override;
126 
127  protected:
129  enum Status {
130  beam = 4, // Beam particle
131  fnal = 1, // final state `final` is a reserved word
132  dcy = 2, // Decay
133  off = 100
134  };
136  using IdMap = std::map<int, HepMC3::GenParticlePtr>;
138  using CollCounter = std::valarray<int>;
140  void clear();
142  int get_status(const ProcessType& t) const;
153  HepMC3::GenParticlePtr make_gen(int pid, int status,
154  const smash::FourVector& mom,
155  double mass = -1);
164  HepMC3::GenParticlePtr make_register(const ParticleData& p,
165  int status = Status::fnal);
175  HepMC3::GenParticlePtr find_or_make(const ParticleData& p,
176  int status = Status::fnal,
177  bool force_new = false);
185  int ion_pdg(const AZ& az) const;
187  HepMC3::GenEvent event_;
189  HepMC3::GenHeavyIonPtr ion_;
191  HepMC3::GenCrossSectionPtr xs_;
193  HepMC3::GenVertexPtr ip_;
219  int ncoll_;
225 };
226 } // namespace smash
227 
228 #endif // SRC_INCLUDE_SMASH_HEPMCINTERFACE_H_
Action is the base class for a generic process that takes a number of incoming particles and transfor...
Definition: action.h:35
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
Base class for output handlers that need the HepMC3 structure.
std::pair< int, int > AZ
Pair of Atomic weight and number.
HepMC3::GenVertexPtr ip_
The interaction point.
std::valarray< int > CollCounter
Counter of collitions per incoming particle.
int ncoll_
counter of binary collisions (e.g., where both incoming particles are from the beams.
bool full_event_
Whether the full event or only final-state particles are in the output.
HepMC3::GenParticlePtr make_gen(int pid, int status, const smash::FourVector &mom, double mass=-1)
Make an HepMC particle.
int ion_pdg(const AZ &az) const
Encode ion PDG.
int get_status(const ProcessType &t) const
Convert SMASH process type to HepMC status.
HepMC3::GenParticlePtr make_register(const ParticleData &p, int status=Status::fnal)
Find particle in mapping or generate it.
int ncoll_hard_
counter of hard binary collisions (e.g., where both incoming particles are from the beams.
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.
void clear()
Clear before an event.
IdMap map_
Mapping from ID to particle.
void at_interaction(const Action &action, const double density) override
Writes collisions to event.
Status
HepMC status codes.
HepMC3::GenParticlePtr find_or_make(const ParticleData &p, int status=Status::fnal, bool force_new=false)
Find particle in mapping or generate it.
HepMC3::GenEvent event_
The event.
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.
std::map< int, HepMC3::GenParticlePtr > IdMap
Type of mapping from SMASH ID to HepMC ID.
HepMC3::GenHeavyIonPtr ion_
The heavy-ion structure.
CollCounter coll_
Collision counter.
HepMcInterface(const std::string &name, const bool full_event)
Create HepMC particle event in memory.
HepMC3::GenCrossSectionPtr xs_
Dummy cross-section.
Abstraction of generic output.
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:58
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
constexpr int p
Proton.
Definition: action.h:24
ProcessType
ProcessTypes are used to identify the type of the process.
Definition: processbranch.h:39
Structure to contain custom data for output.