Version: SMASH-2.1
hepmcoutput.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2021
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #include "smash/hepmcoutput.h"
11 
12 #include "HepMC3/Print.h"
13 
14 namespace smash {
15 
70 HepMcOutput::HepMcOutput(const bf::path &path, std::string name,
71  const bool full_event)
72  : HepMcInterface(name, full_event), filename_(path / (name + ".asciiv3")) {
74  filename_unfinished_ += +".unfinished";
75  output_file_ = make_unique<HepMC3::WriterAscii>(filename_unfinished_.string(),
76  event_.run_info());
77 }
79  logg[LOutput].debug() << "Renaming file " << filename_unfinished_ << " to "
80  << filename_ << std::endl;
81  bf::rename(filename_unfinished_, filename_);
82 }
83 
84 void HepMcOutput::at_eventend(const Particles &particles,
85  const int32_t event_number,
86  const EventInfo &event) {
87  HepMcInterface::at_eventend(particles, event_number, event);
88  logg[LOutput].debug() << "Writing event " << event_number << " with "
89  << event_.particles().size() << " particles and "
90  << event_.vertices().size() << " vertices to output "
91  << std::endl;
92  output_file_->write_event(event_);
93 }
94 
95 } // namespace smash
Base class for output handlers that need the HepMC3 structure.
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.
HepMC3::GenEvent event_
The event.
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.
Definition: hepmcoutput.cc:84
HepMcOutput(const bf::path &path, std::string name, const bool full_event)
Create HepMC particle output.
Definition: hepmcoutput.cc:70
const bf::path filename_
Filename of output.
Definition: hepmcoutput.h:61
bf::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: hepmcoutput.h:63
~HepMcOutput()
Destructor renames file.
Definition: hepmcoutput.cc:78
std::unique_ptr< HepMC3::WriterAscii > output_file_
Pointer to Ascii HepMC3 output file.
Definition: hepmcoutput.h:65
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
Definition: action.h:24
static constexpr int LOutput
Structure to contain custom data for output.