Page MenuHomeHEPForge

HepMC2Writer.cc
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

HepMC2Writer.cc

/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019
* \copyright GPLv2 or later
*/
#include "HEJ/HepMC2Writer.hh"
#include <cassert>
#include "LHEF/LHEF.h"
#ifdef HEJ_BUILD_WITH_HepMC2
#include "HepMC/IO_GenEvent.h"
#include <utility>
#include "HepMC/GenParticle.h"
#include "HepMC/GenVertex.h"
#include "HEJ/Event.hh"
#include "HEJ/exceptions.hh"
#include "HEJ/HepMC2Interface.hh"
namespace HEJ{
struct HepMC2Writer::HepMC2WriterImpl{
HepMC2Interface hepmc_;
HepMC2WriterImpl & operator=(HepMC2WriterImpl const & other) = delete;
HepMC2WriterImpl(HepMC2WriterImpl const & other) = delete;
HepMC2WriterImpl & operator=(HepMC2WriterImpl && other) = delete;
HepMC2WriterImpl(HepMC2WriterImpl && other) = delete;
HepMC::IO_GenEvent writer_;
HepMC2WriterImpl(
std::string const & file, LHEF::HEPRUP && heprup
):
hepmc_(heprup),
writer_{file}
{}
void write(Event const & ev){
auto out_ev = hepmc_(ev);
writer_.write_event(&out_ev);
}
};
HepMC2Writer::HepMC2Writer(std::string const & file, LHEF::HEPRUP heprup):
impl_{new HepMC2WriterImpl{file, std::move(heprup)}}
{}
void HepMC2Writer::write(Event const & ev){
impl_->write(ev);
}
} // namespace HEJ
#else // no HepMC2
namespace HEJ{
class HepMC2Writer::HepMC2WriterImpl{};
HepMC2Writer::HepMC2Writer(std::string const &, LHEF::HEPRUP){
throw std::invalid_argument(
"Failed to create HepMC writer: "
"HEJ 2 was built without HepMC2 support"
);
}
void HepMC2Writer::write(Event const &){
assert(false);
}
}
#endif
namespace HEJ{
HepMC2Writer::~HepMC2Writer() = default;
}

File Metadata

Mime Type
text/x-c
Expires
Tue, Sep 30, 6:00 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6482128
Default Alt Text
HepMC2Writer.cc (1 KB)

Event Timeline