Version: SMASH-3.1
smash::HepMcOutput Class Reference

#include <hepmcoutput.h>

SMASH output to HepMC file.

This class writes a vertex connecting all intial particles with all final particles into a HepMC outputfile. In collider mode, projectile and target are combined into single intial particles with a nuclear pdg code. The output file can be a human-readable ASCII file or a ROOT Tree binary file. HepMC version 3 is used.

More details of the output format can be found in the User Guide.

Definition at line 37 of file hepmcoutput.h.

Inheritance diagram for smash::HepMcOutput:
smash::HepMcInterface smash::OutputInterface

Public Member Functions

 HepMcOutput (const std::filesystem::path &path, std::string name, const bool full_event, std::string HepMC3_output_type)
 Create HepMC particle output. More...
 
 ~HepMcOutput ()
 Destructor renames file. More...
 
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. More...
 
- Public Member Functions inherited from smash::HepMcInterface
 HepMcInterface (const std::string &name, const bool full_event)
 Create HepMC particle event in memory. More...
 
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. More...
 
void at_interaction (const Action &action, const double density) override
 Writes collisions to event. More...
 
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. More...
 
- Public Member Functions inherited from smash::OutputInterface
 OutputInterface (std::string name)
 Construct output interface. More...
 
virtual ~OutputInterface ()=0
 Pure virtual destructor to make class abstract and prevent its instantiation. More...
 
virtual void at_eventstart (const std::vector< Particles > &, int)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int, const ThermodynamicQuantity, const DensityType, RectangularLattice< DensityOnLattice >)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventstart (const int, const ThermodynamicQuantity, const DensityType, RectangularLattice< EnergyMomentumTensor >)
 Output launched at event start after initialization, when particles are generated but not yet propagated. More...
 
virtual void at_eventend (const int, const ThermodynamicQuantity, const DensityType)
 Output launched at event end. More...
 
virtual void at_eventend (const ThermodynamicQuantity)
 Output launched at event end. More...
 
virtual void at_eventend (const Particles &, const int, const EventInfo &)
 Output launched at event end. More...
 
virtual void at_eventend (const std::vector< Particles > &, const int)
 Output launched at event end. More...
 
virtual void at_intermediate_time (const Particles &, const std::unique_ptr< Clock > &, const DensityParameters &, const EventInfo &)
 Output launched after every N'th time-step. More...
 
virtual void at_intermediate_time (const std::vector< Particles > &, const std::unique_ptr< Clock > &, const DensityParameters &)
 Output launched after every N'th timestep. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity, const DensityType, RectangularLattice< DensityOnLattice > &)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_output (const ThermodynamicQuantity, const DensityType, RectangularLattice< EnergyMomentumTensor > &)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &, const double)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (RectangularLattice< DensityOnLattice > &, const double, const std::vector< Particles > &, const DensityParameters &)
 Output to write thermodynamics from the lattice. More...
 
virtual void thermodynamics_lattice_output (const ThermodynamicQuantity, RectangularLattice< EnergyMomentumTensor > &, const double)
 Output to write energy-momentum tensor and related quantities from the lattice. More...
 
virtual void thermodynamics_output (const GrandCanThermalizer &)
 Output to write energy-momentum tensor and related quantities from the thermalizer class. More...
 
virtual void fields_output (const std::string, const std::string, RectangularLattice< std::pair< ThreeVector, ThreeVector >> &)
 Write fields in vtk output Fields are a pair of threevectors for example electric and magnetic field. More...
 
bool is_dilepton_output () const
 Get, whether this is the dilepton output? More...
 
bool is_photon_output () const
 Get, whether this is the photon output? More...
 
bool is_IC_output () const
 Get, whether this is the IC output? More...
 
const char * to_string (const ThermodynamicQuantity tq)
 Convert thermodynamic quantities to strings. More...
 
const char * to_string (const DensityType dens_type)
 Convert density types to strings. More...
 

Private Types

enum  enum_output { asciiv3 , treeroot }
 enum to identify the HepMC3 output type More...
 
typedef enum smash::HepMcOutput::enum_output type_of_HepMC3_output
 enum to identify the HepMC3 output type More...
 

Private Attributes

const std::filesystem::path filename_
 Filename of output. More...
 
std::filesystem::path filename_unfinished_
 Filename of output as long as simulation is still running. More...
 
std::unique_ptr< HepMC3::Writer > output_file_
 Pointers to the base class of HepMC3 output files. More...
 
type_of_HepMC3_output output_type_
 HepMC3 output type. More...
 

Additional Inherited Members

- Public Types inherited from smash::HepMcInterface
using AZ = std::pair< int, int >
 Pair of Atomic weight and number. More...
 
- Protected Types inherited from smash::HepMcInterface
enum  Status { beam = 4 , fnal = 1 , dcy = 2 , off = 100 }
 HepMC status codes. More...
 
using IdMap = std::map< int, HepMC3::GenParticlePtr >
 Type of mapping from SMASH ID to HepMC ID. More...
 
using CollCounter = std::valarray< int >
 Counter of collitions per incoming particle. More...
 
- Protected Member Functions inherited from smash::HepMcInterface
void clear ()
 Clear before an event. More...
 
int get_status (const ProcessType &t) const
 Convert SMASH process type to HepMC status. More...
 
HepMC3::GenParticlePtr make_gen (int pid, int status, const smash::FourVector &mom, double mass=-1)
 Make an HepMC particle. More...
 
HepMC3::GenParticlePtr make_register (const ParticleData &p, int status=Status::fnal)
 Find particle in mapping or generate it. More...
 
HepMC3::GenParticlePtr find_or_make (const ParticleData &p, int status=Status::fnal, bool force_new=false)
 Find particle in mapping or generate it. More...
 
int ion_pdg (const AZ &az) const
 Encode ion PDG. More...
 
- Protected Attributes inherited from smash::HepMcInterface
HepMC3::GenEvent event_
 The event. More...
 
HepMC3::GenHeavyIonPtr ion_
 The heavy-ion structure. More...
 
HepMC3::GenCrossSectionPtr xs_
 Dummy cross-section. More...
 
HepMC3::GenVertexPtr ip_
 The interaction point. More...
 
IdMap map_
 Mapping from ID to particle. More...
 
CollCounter coll_
 Collision counter. More...
 
int ncoll_
 counter of binary collisions (e.g., where both incoming particles are from the beams. More...
 
int ncoll_hard_
 counter of hard binary collisions (e.g., where both incoming particles are from the beams. More...
 
bool full_event_
 Whether the full event or only final-state particles are in the output. More...
 
- Protected Attributes inherited from smash::OutputInterface
const bool is_dilepton_output_
 Is this the dilepton output? More...
 
const bool is_photon_output_
 Is this the photon output? More...
 
const bool is_IC_output_
 Is this the IC output? More...
 

Member Typedef Documentation

◆ type_of_HepMC3_output

enum to identify the HepMC3 output type

Member Enumeration Documentation

◆ enum_output

enum to identify the HepMC3 output type

Enumerator
asciiv3 
treeroot 

Definition at line 72 of file hepmcoutput.h.

enum smash::HepMcOutput::enum_output type_of_HepMC3_output
enum to identify the HepMC3 output type

Constructor & Destructor Documentation

◆ HepMcOutput()

smash::HepMcOutput::HepMcOutput ( const std::filesystem::path &  path,
std::string  name,
const bool  full_event,
std::string  HepMC3_output_type 
)

Create HepMC particle output.

Parameters
[in]pathOutput path.
[in]nameName of the output.
[in]full_eventWhether the full event or only final-state particles are printed in the output
[in]HepMC3_output_type"root" or "asciiv3"

Definition at line 250 of file hepmcoutput.cc.

252  : HepMcInterface(name, full_event),
253  filename_(path / (name + "." + HepMC3_output_type)) {
255  filename_unfinished_ += +".unfinished";
256 #ifdef SMASH_USE_HEPMC_ROOTIO
257  if (HepMC3_output_type == "asciiv3") {
258 #endif
259  output_file_ = std::make_unique<HepMC3::WriterAscii>(
260  filename_unfinished_.string(), event_.run_info());
262 #ifdef SMASH_USE_HEPMC_ROOTIO
263  } else {
264  output_file_ = std::make_unique<HepMC3::WriterRootTree>(
265  filename_unfinished_.string(), event_.run_info());
267  }
268 #endif
269 }
HepMC3::GenEvent event_
The event.
HepMcInterface(const std::string &name, const bool full_event)
Create HepMC particle event in memory.
const std::filesystem::path filename_
Filename of output.
Definition: hepmcoutput.h:66
std::filesystem::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: hepmcoutput.h:68
type_of_HepMC3_output output_type_
HepMC3 output type.
Definition: hepmcoutput.h:74
std::unique_ptr< HepMC3::Writer > output_file_
Pointers to the base class of HepMC3 output files.
Definition: hepmcoutput.h:70

◆ ~HepMcOutput()

smash::HepMcOutput::~HepMcOutput ( )

Destructor renames file.

Definition at line 270 of file hepmcoutput.cc.

270  {
271  logg[LOutput].debug() << "Renaming file " << filename_unfinished_ << " to "
272  << filename_ << std::endl;
273  output_file_->close();
274  std::filesystem::rename(filename_unfinished_, filename_);
275 }
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
static constexpr int LOutput

Member Function Documentation

◆ at_eventend()

void smash::HepMcOutput::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.

Store impact parameter and write event.

Parameters
[in]particlesCurrent list of particles.
[in]event_numberNumber of event.
[in]eventEvent info, see event_info

Definition at line 277 of file hepmcoutput.cc.

279  {
280  HepMcInterface::at_eventend(particles, event_number, event);
281  logg[LOutput].debug() << "Writing event " << event_number << " with "
282  << event_.particles().size() << " particles and "
283  << event_.vertices().size() << " vertices to output "
284  << std::endl;
285  output_file_->write_event(event_);
286 }
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.

Member Data Documentation

◆ filename_

const std::filesystem::path smash::HepMcOutput::filename_
private

Filename of output.

Definition at line 66 of file hepmcoutput.h.

◆ filename_unfinished_

std::filesystem::path smash::HepMcOutput::filename_unfinished_
private

Filename of output as long as simulation is still running.

Definition at line 68 of file hepmcoutput.h.

◆ output_file_

std::unique_ptr<HepMC3::Writer> smash::HepMcOutput::output_file_
private

Pointers to the base class of HepMC3 output files.

Definition at line 70 of file hepmcoutput.h.

◆ output_type_

type_of_HepMC3_output smash::HepMcOutput::output_type_
private

HepMC3 output type.

Definition at line 74 of file hepmcoutput.h.


The documentation for this class was generated from the following files: