Version: SMASH-2.0.2
hepmcoutput.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2020
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, const int total_N,
72  const int proj_N)
73  : HepMcInterface(name, full_event, total_N, proj_N),
74  filename_(path / (name + ".asciiv3")) {
76  filename_unfinished_ += +".unfinished";
77  output_file_ =
78  make_unique<HepMC3::WriterAscii>(filename_unfinished_.string());
79 }
81  logg[LOutput].debug() << "Renaming file " << filename_unfinished_ << " to "
82  << filename_ << std::endl;
83  bf::rename(filename_unfinished_, filename_);
84 }
85 
86 void HepMcOutput::at_eventend(const Particles &particles,
87  const int32_t event_number,
88  const EventInfo &event) {
89  HepMcInterface::at_eventend(particles, event_number, event);
90  logg[LOutput].debug() << "Writing event " << event_number << " with "
91  << event_.particles().size() << " particles and "
92  << event_.vertices().size() << " vertices to output "
93  << std::endl;
94  output_file_->write_event(event_);
95 }
96 
97 } // namespace smash
smash
Definition: action.h:24
smash::LOutput
static constexpr int LOutput
Definition: outputinterface.h:24
smash::HepMcInterface::event_
HepMC3::GenEvent event_
The event.
Definition: hepmcinterface.h:188
smash::HepMcOutput::filename_unfinished_
bf::path filename_unfinished_
Filename of output as long as simulation is still running.
Definition: hepmcoutput.h:66
smash::EventInfo
Structure to contain custom data for output.
Definition: outputinterface.h:36
smash::logg
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
smash::HepMcOutput::output_file_
std::unique_ptr< HepMC3::WriterAscii > output_file_
Pointer to Ascii HepMC3 output file.
Definition: hepmcoutput.h:68
smash::HepMcOutput::~HepMcOutput
~HepMcOutput()
Destructor renames file.
Definition: hepmcoutput.cc:80
smash::HepMcOutput::HepMcOutput
HepMcOutput(const bf::path &path, std::string name, const bool full_event, const int total_N, const int proj_N)
Create HepMC particle output.
Definition: hepmcoutput.cc:70
smash::HepMcInterface::at_eventend
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: hepmcinterface.cc:142
smash::HepMcInterface
Base class for output handlers that need the HepMC3 structure.
Definition: hepmcinterface.h:81
smash::Particles
Definition: particles.h:33
hepmcoutput.h
smash::HepMcOutput::at_eventend
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:86
smash::HepMcOutput::filename_
const bf::path filename_
Filename of output.
Definition: hepmcoutput.h:64