6 #ifndef HEPMC3_READERGZ_H 7 #define HEPMC3_READERGZ_H 39 std::ifstream file(filename);
41 printf(
"Error in ReaderGZ: could not open file%s\n",filename.c_str());
44 magic_t my_magic = {0x1f, 0x8b, 0x08, 0x08};
46 file.read((
char *) file_magic.
bytes,
sizeof(file_magic));
53 printf(
"Error in ReaderGZ: make sure %s is a gziped file!\n",filename.c_str());
75 std::shared_ptr<Reader>
deduce_reader(std::istream & stream_test,std::istream & stream) {
76 std::vector<std::string> head;
77 head.push_back(std::string(
""));
78 head.push_back(std::string(
""));
81 while (getline(stream_test,head[goodcount])&&goodcount<1&&count<10) {
82 if (head[goodcount].length()) goodcount++;
85 if (count>10&&goodcount<2)
87 printf(
"Info in ReaderGZ::deduce_reader: The first %i lines in stream do not contain readable information\n",count);
88 return shared_ptr<Reader>(
nullptr);
90 printf(
"Info in ReaderGZ::deduce_reader: Attempt ReaderAscii for stream\n");
91 if( strncmp(head.at(0).c_str(),
"HepMC::Version",14) == 0 && strncmp(head.at(1).c_str(),
"HepMC::Asciiv3",14)==0 )
93 printf(
"Info in ReaderGZ::deduce_reader: Attempt ReaderAsciiHepMC2 for stream\n");
94 if( strncmp(head.at(0).c_str(),
"HepMC::Version",14) == 0 && strncmp(head.at(1).c_str(),
"HepMC::IO_GenEvent",18)==0 )
96 printf(
"Info in deduce_reader: Attempt ReaderLHEF for stream\n");
97 if( strncmp(head.at(0).c_str(),
"<LesHouchesEvents",17) == 0)
99 printf(
"Info in deduce_reader: Attempt ReaderHEPEVT for stream\n");
100 std::stringstream st_e(head.at(0).c_str());
110 if (attr==
' ')
continue;
115 HEPEVT=
static_cast<bool>(st_e>>m_i>>m_p);
119 printf(
"Info in deduce_reader: All attempts failed for stream\n");
120 return shared_ptr<Reader>(
nullptr);
GenEvent I/O parsing for structured text files compressed with gzip.
GenEvent I/O parsing and serialization for LHEF files.
Definition of class ReaderHEPEVT.
Union to hold first 4 byts of file, i.e. magic bytes.
Definition of interface Reader.
GenEvent I/O parsing for structured text files.
bool read_event(GenEvent &evt)
Read event.
GenEvent I/O parsing and serialization for HEPEVT files.
Parser for HepMC2 I/O files.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
ReaderGZ(const std::string &filename)
Construcor.
Definition of class ReaderAscii.
Fortran common block HEPEVT.
igzstream m_gzstream
Stream to read.
igzstream m_gzstream_test
Stream to test.
Definition of class GenEvent.
std::shared_ptr< Reader > deduce_reader(std::istream &stream_test, std::istream &stream)
THis function will deduce the type of input file based on the name/URL and it's content and will retu...
Base class for all I/O readers.
Definition of class ReaderLHEF.
std::shared_ptr< Reader > m_reader
Actual reader.