HepMC3 event record library
testReaderFactory1.cc
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
5 //
6 #include "HepMC3/GenEvent.h"
7 #include "HepMC3/WriterAscii.h"
10 #include "HepMC3/ReaderFactory.h"
11 #include "HepMC3TestUtils.h"
12 using namespace HepMC3;
13 int main()
14 {
15  std::shared_ptr<Reader> inputA = deduce_reader("inputReaderFactory1.hepmc");
16  if(inputA->failed()) return 1;
17  WriterAscii outputA("frominputReaderFactory1.hepmc");
18  if(outputA.failed()) return 2;
19  while( !inputA->failed() )
20  {
21  GenEvent evt(Units::GEV,Units::MM);
22  inputA->read_event(evt);
23  if( inputA->failed() ) {
24  printf("End of file reached. Exit.\n");
25  break;
26  }
27  outputA.write_event(evt);
28  evt.clear();
29  }
30  inputA->close();
31  outputA.close();
32 
33 
34  std::shared_ptr<Reader> inputB = deduce_reader("frominputReaderFactory1.hepmc");
35  if(inputB->failed()) return 3;
36  WriterAsciiHepMC2 outputB("fromfrominputReaderFactory1.hepmc");
37  if(outputB.failed()) return 4;
38  while( !inputB->failed() )
39  {
40  GenEvent evt(Units::GEV,Units::MM);
41  inputB->read_event(evt);
42  if( inputB->failed() ) {
43  printf("End of file reached. Exit.\n");
44  break;
45  }
46  outputB.write_event(evt);
47  evt.clear();
48  }
49  inputB->close();
50  outputB.close();
51  return COMPARE_ASCII_FILES("fromfrominputReaderFactory1.hepmc","inputReaderFactory1.hepmc");
52 }
GenEvent I/O serialization for structured text files.
Definition of class WriterAscii.
std::shared_ptr< Reader > deduce_reader(std::istream &stream)
This function will deduce the type of input stream based on its content and will return appropriate R...
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
Definition: GenEvent.h:41
Definition of class WriterAsciiHepMC2.
int main(int argc, char **argv)
Definition of class GenEvent.
GenEvent I/O serialization for structured text files.
Definition: WriterAscii.h:25