13 #include "HepMC3/GenRunInfo.h"
14 #include "HepMC3/Print.h"
15 #include "HepMC3/Setup.h"
17 #include "smash/config.h"
25 event_(HepMC3::Units::GEV, HepMC3::Units::MM),
29 full_event_(full_event) {
30 logg[
LOutput].debug() <<
"Name of output: " << name <<
" "
31 << (
full_event_ ?
"full event" :
"final state only")
32 <<
" output" << std::endl;
33 ion_ = std::make_shared<HepMC3::GenHeavyIon>();
34 ion_->set(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1.0, -1.0, -1.0, -1.0, -1.0,
37 xs_ = std::make_shared<HepMC3::GenCrossSection>();
39 std::shared_ptr<HepMC3::GenRunInfo> run_info =
40 std::make_shared<HepMC3::GenRunInfo>();
41 std::vector<std::string> weightnames;
42 weightnames.push_back(
"Default");
43 run_info->set_weight_names(weightnames);
44 HepMC3::GenRunInfo::ToolInfo tool;
46 tool.version = SMASH_VERSION;
48 tool.version = tool.version + GIT_BRANCH;
50 tool.description =
"";
51 run_info->tools().push_back(tool);
52 event_.set_run_info(run_info);
53 HepMC3::Setup::set_debug_level(
logg[
LOutput].isEnabled<einhard::DEBUG>() ? 5
58 const int event_number,
64 ion_->impact_parameter =
event.impact_parameter;
65 xs_->set_cross_section(1, 1);
66 event_.set_event_number(event_number);
70 ip_ = std::make_shared<HepMC3::GenVertex>();
78 bool is_coll = (
event.impact_parameter >= 0.0);
80 for (
auto& data : particles) {
82 if (!data.is_neutron() && !data.is_proton()) {
83 throw std::runtime_error(
84 "Particle of PID=" + std::to_string(data.pdgcode().get_decimal()) +
85 " is not a valid HepMC beam particle!");
89 p_proj += data.momentum();
91 az_proj.second += data.type().charge();
93 p_targ += data.momentum();
95 az_targ.second += data.type().charge();
111 ip_->add_particle_out(op);
113 ip_->add_particle_in(op);
117 coll_.resize(az_proj.first + az_targ.first);
124 ip_->add_particle_in(proj);
125 ip_->add_particle_in(targ);
131 HepMC3::GenVertexPtr vp;
137 vp = std::make_shared<HepMC3::GenVertex>(
138 HepMC3::FourVector(v.
x1(), v.
x2(), v.
x3(), v.
x0()));
140 vp->add_attribute(
"weight", std::make_shared<HepMC3::FloatAttribute>(
152 ip->set_status(status);
153 vp->add_particle_in(ip);
169 bool is_coll = (
event.impact_parameter >= 0.0);
176 event_.weights() = std::vector<double>(1, 1);
180 ion_->Ncoll_hard = -1;
185 ion_->Npart_proj = -1;
189 ion_->Npart_targ = -1;
194 for (
auto&
p : particles) {
197 ip_->add_particle_out(h);
198 }
else if (
map_.find(
p.id()) ==
map_.end()) {
199 throw std::runtime_error(
"Dangling particle " + std::to_string(
p.id()));
218 return static_cast<int>(t) +
static_cast<int>(Status::off);
224 auto p = std::make_shared<HepMC3::GenParticle>(
225 HepMC3::FourVector(mom.
x1(), mom.
x2(), mom.
x3(), mom.
x0()), pid, status);
227 p->set_generated_mass(mass);
234 auto h =
make_gen(
p.pdgcode().get_decimal(), status,
p.momentum(),
246 auto it =
map_.find(
id);
247 if (it !=
map_.end()) {
256 if (az.second == 1 && az.first == 1)
258 if (az.second == 1 && az.first == 0)
261 return 1000 * 1000 * 1000 + az.second * 10 * 1000 + az.first * 10;
Action is the base class for a generic process that takes a number of incoming particles and transfor...
virtual ProcessType get_type() const
Get the process type.
virtual double get_total_weight() const =0
Return the total weight value, which is mainly used for the weight output entry.
const ParticleList & incoming_particles() const
Get the list of particles that go into the action.
virtual double get_partial_weight() const =0
Return the specific weight for the chosen outgoing channel, which is mainly used for the partial weig...
FourVector get_interaction_point() const
Get the interaction point.
const ParticleList & outgoing_particles() const
Get the list of particles that resulted from the action.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
std::pair< int, int > AZ
Pair of Atomic weight and number.
HepMC3::GenVertexPtr ip_
The interaction point.
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.
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.
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.
The Particles class abstracts the storage and manipulation of particles.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
ProcessType
ProcessTypes are used to identify the type of the process.
@ Decay
See here for a short description.
static constexpr int LOutput
Structure to contain custom data for output.
bool empty_event
True if no collisions happened.