11 #include "smash/config.h" 
   13 #include "HepMC3/GenRunInfo.h" 
   14 #include "HepMC3/Print.h" 
   15 #include "HepMC3/Setup.h" 
   22       event_(HepMC3::Units::GEV, HepMC3::Units::MM),
 
   26       full_event_(full_event) {
 
   27   logg[
LOutput].debug() << 
"Name of output: " << name << 
" " 
   28                         << (
full_event_ ? 
"full event" : 
"final state only")
 
   29                         << 
" output" << std::endl;
 
   30   ion_ = std::make_shared<HepMC3::GenHeavyIon>();
 
   31   ion_->set(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1.0, -1.0, -1.0, -1.0, -1.0,
 
   34   xs_ = std::make_shared<HepMC3::GenCrossSection>();
 
   36   std::shared_ptr<HepMC3::GenRunInfo> run_info =
 
   37       std::make_shared<HepMC3::GenRunInfo>();
 
   38   std::vector<std::string> weightnames;
 
   39   weightnames.push_back(
"Default");
 
   40   run_info->set_weight_names(weightnames);
 
   41   HepMC3::GenRunInfo::ToolInfo tool;
 
   43   tool.version = VERSION_MAJOR;
 
   44   tool.version = tool.version + GIT_BRANCH;
 
   45   tool.description = 
"";
 
   46   run_info->tools().push_back(tool);
 
   47   event_.set_run_info(run_info);
 
   48   HepMC3::Setup::set_debug_level(
logg[
LOutput].isEnabled<einhard::DEBUG>() ? 5
 
   53                                    const int event_number,
 
   59   ion_->impact_parameter = 
event.impact_parameter;
 
   60   xs_->set_cross_section(1, 1);  
 
   61   event_.set_event_number(event_number);
 
   65   ip_ = std::make_shared<HepMC3::GenVertex>();
 
   73   bool is_coll = (
event.impact_parameter >= 0.0);
 
   75   for (
auto& data : particles) {
 
   77       if (!data.is_neutron() && !data.is_proton()) {
 
   78         throw std::runtime_error(
 
   79             "Particle of PID=" + std::to_string(data.pdgcode().get_decimal()) +
 
   80             " is not a valid HepMC beam particle!");
 
   84         p_proj += data.momentum();
 
   86         az_proj.second += data.type().charge();
 
   88         p_targ += data.momentum();
 
   90         az_targ.second += data.type().charge();
 
  106       ip_->add_particle_out(op);
 
  108       ip_->add_particle_in(op);
 
  112   coll_.resize(az_proj.first + az_targ.first);
 
  119     ip_->add_particle_in(proj);
 
  120     ip_->add_particle_in(targ);
 
  126   HepMC3::GenVertexPtr vp;
 
  132     vp = std::make_shared<HepMC3::GenVertex>(
 
  133         HepMC3::FourVector(v.
x1(), v.
x2(), v.
x3(), v.
x0()));
 
  135     vp->add_attribute(
"weight", std::make_shared<HepMC3::FloatAttribute>(
 
  147       ip->set_status(status);
 
  148       vp->add_particle_in(ip);
 
  169   event_.weights() = std::vector<double>(1, 1);
 
  173   ion_->Ncoll_hard = -1;
 
  178   ion_->Npart_proj = -1;
 
  182   ion_->Npart_targ = -1;
 
  187   for (
auto& 
p : particles) {
 
  190       ip_->add_particle_out(h);
 
  191     } 
else if (
map_.find(
p.id()) == 
map_.end()) {
 
  192       throw std::runtime_error(
"Dangling particle " + std::to_string(
p.id()));
 
  211   return static_cast<int>(t) + 
static_cast<int>(Status::off);
 
  217   auto p = std::make_shared<HepMC3::GenParticle>(
 
  218       HepMC3::FourVector(mom.
x1(), mom.
x2(), mom.
x3(), mom.
x0()), pid, status);
 
  220     p->set_generated_mass(mass);
 
  227   auto h = 
make_gen(
p.pdgcode().get_decimal(), status, 
p.momentum(),
 
  239     auto it = 
map_.find(
id);
 
  240     if (it != 
map_.end()) {
 
  249   if (az.second == 1 && az.first == 1)
 
  251   if (az.second == 1 && az.first == 0)
 
  254   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
Process Types are used to identify the type of the process.
static constexpr int LOutput
Structure to contain custom data for output.
bool empty_event
True if no collisions happened.