39 int fd = open(filename.c_str(), O_RDONLY);
42 perror(filename.c_str());
46 m_inf_zcstream = std::unique_ptr<google::protobuf::io::FileInputStream>(
47 new google::protobuf::io::FileInputStream(fd));
65 HEPMC3_ERROR_LEVEL(100,
"Cannot initialize Readerprotobuf on istream which is not good().")
69 m_in_zcistream = std::unique_ptr<google::protobuf::io::IstreamInputStream>(
70 new google::protobuf::io::IstreamInputStream(&stream));
83 const void *MagicIntro =
nullptr;
88 if (strncmp(
static_cast<const char *
>(MagicIntro),
98 HEPMC3_ERROR_LEVEL(100,
"Readerprotobuf: Problem parsing start of file, expected to find Header, but instead found message type: "<<
m_md_pb.message_type())
103 HEPMC3_ERROR_LEVEL(100,
"Readerprotobuf: Problem parsing start of file, expected to find RunInfo, but instead found message type: "<<
m_md_pb.message_type())
124 if (
m_md_pb.message_type() == HepMC3_pb::MessageDigest::Footer) {
136 if (
m_md_pb.message_type() != HepMC3_pb::MessageDigest::Header) {
156 if (
m_md_pb.message_type() != HepMC3_pb::MessageDigest::RunInfo) {
178 if (
m_md_pb.message_type() != HepMC3_pb::MessageDigest::Event) {
195 for (
int nn = n; nn > 0; --nn) {
#define HEPMC3_ERROR_LEVEL(LEVEL, MESSAGE)
Macro for printing error messages.
Definition of static class Print.
Definition of class Readerprotobuf.
Declaration of the Verrion functions and some macros.
Stores event-related information.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
void read_data(const GenEventData &data)
Fill GenEvent based on GenEventData.
virtual void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
virtual std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
GenEvent I/O parsing and serialization for protobuf-based binary files.
HepMC3_pb::GenRunInfoData m_gri_pb
GenRunInfo data.
bool read_event(GenEvent &evt) override
Read event from file.
std::istream * m_in_stream
The stream object that is read from.
bool failed() override
Get stream error state.
Readerprotobuf(const std::string &filename)
filename constructor
HepMC3_pb::MessageDigest m_md_pb
Message digest.
bool skip(const int n) override
skips the next n events
HepMC3_pb::Header m_hdr_pb
Header.
void close() override
Close file stream.
bool read_GenEvent(bool skip, GenEvent &evt)
Parse the next protobuf message as a GenEvent message.
HepMC3_pb::GenEventData m_evt_pb
GenEventInfo data.
std::unique_ptr< google::protobuf::io::IstreamInputStream > m_in_zcistream
Stream input.
bool read_digest()
Read the next protobuf message digest.
bool read_GenRunInfo()
Parse the next protobuf message as a GenRunInfo message.
std::unique_ptr< google::protobuf::io::FileInputStream > m_inf_zcstream
File input.
bool read_Header()
Parse the next protobuf message as a Header message.
bool read_file_start()
Parse the front matter of the protobuf message stream before the events.
std::shared_ptr< std::istream > m_shared_stream
Passed in shared_ptr to an input stream.
google::protobuf::io::ZeroCopyInputStream * m_in_zcstream
Zero copy input stream.
static size_t const MDBytesLength
Constant.
size_t const ProtobufMagicHeaderBytes
Size of the protobuf file header.
std::string const ProtobufMagicHeader
Header of the protobuf file.
Definition of utility functions for protobufIO.