#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);
}
ReaderAscii input_file (argv[1]);
WriterAscii output_file(argv[2]);
int events_parsed = 0;
while(!input_file.failed()) {
GenEvent evt(Units::GEV,Units::MM);
input_file.read_event(evt);
if( input_file.failed() ) break;
output_file.write_event(evt);
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;
std::shared_ptr<GenCrossSection> cs = evt.attribute<GenCrossSection>("GenCrossSection");
std::shared_ptr<GenHeavyIon> hi = evt.attribute<GenHeavyIon>("GenHeavyIon");
std::shared_ptr<GenPdfInfo> pi = evt.attribute<GenPdfInfo>("GenPdfInfo");
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;
}
input_file.close();
output_file.close();
return 0;
}
Definition of class GenEvent.
Definition of static class Print.
Definition of class ReaderAscii.
Definition of class WriterAscii.
int main(int argc, char **argv)