Test of file I/O.
#include <iostream>
int main(int argc, char **argv) {
if( argc<3 ) {
std::cout << "Usage: " << argv[0] << " <HepMC3_input_file> <output_file>" << std::endl;
exit(-1);
}
int events_parsed = 0;
if( input_file.
failed() )
break;
if(events_parsed==0) {
std::cout << " First event: " << std::endl;
Print::listing(evt);
Print::content(evt);
std::cout << " Testing attribute reading for the first event: " << std::endl;
if(cs) {
std::cout << " Has GenCrossSection: ";
Print::line(cs);
}
else std::cout << " No GenCrossSection " << std::endl;
if(pi) {
std::cout << " Has GenPdfInfo: ";
Print::line(pi);
}
else std::cout << " No GenPdfInfo " << std::endl;
if(hi) {
std::cout << " Has GenHeavyIon: ";
Print::line(hi);
}
else std::cout << " No GenHeavyIon " << std::endl;
}
++events_parsed;
if( events_parsed%100 == 0 ) std::cout<<"Events parsed: "<<events_parsed<<std::endl;
}
return 0;
}
Definition of class GenEvent.
Definition of static class Print.
Definition of class ReaderAscii.
Definition of class WriterAscii.
Stores additional information about cross-section.
Stores event-related information.
std::shared_ptr< T > attribute(const std::string &name, const int &id=0) const
Get attribute of type T.
Stores additional information about Heavy Ion generator.
Stores additional information about PDFs.
GenEvent I/O parsing for structured text files.
bool read_event(GenEvent &evt) override
Load event from file.
bool failed() override
Return status of the stream.
void close() override
Close file stream.
GenEvent I/O serialization for structured text files.
void close() override
Close file stream.
void write_event(const GenEvent &evt) override
Write event to file.