Version: SMASH-2.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>;
92  HepMcInterface(const std::string& name, const bool full_event);
104  void at_eventstart(const Particles& particles, const int event_number,
105  const EventInfo& event) override;
113  void at_interaction(const Action& action, const double density) override;
122  void at_eventend(const Particles& particles, const int32_t event_number,
123  const EventInfo& event) override;
124 
125  protected:
127  enum Status {
128  beam = 4, // Beam particle
129  fnal = 1, // final state `final` is a reserved word
130  dcy = 2, // Decay
131  off = 100
132  };
134  using IdMap = std::map<int, HepMC3::GenParticlePtr>;
136  using CollCounter = std::valarray<int>;
138  void clear();
140  int get_status(const ProcessType& t) const;
151  HepMC3::GenParticlePtr make_gen(int pid, int status,
152  const smash::FourVector& mom,
153  double mass = -1);
162  HepMC3::GenParticlePtr make_register(const ParticleData& p,
163  int status = Status::fnal);
173  HepMC3::GenParticlePtr find_or_make(const ParticleData& p,
174  int status = Status::fnal,
175  bool force_new = false);
183  int ion_pdg(const AZ& az) const;
185  HepMC3::GenEvent event_;
187  HepMC3::GenHeavyIonPtr ion_;
189  HepMC3::GenCrossSectionPtr xs_;
191  HepMC3::GenVertexPtr ip_;
217  int ncoll_;
223 };
224 } // namespace smash
225 
226 #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
Process Types are used to identify the type of the process.
Definition: processbranch.h:25
Structure to contain custom data for output.