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"
10#include "HepMC3/ReaderFactory.h"
11#include "HepMC3TestUtils.h"
12using namespace HepMC3;
13int 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}
Definition of class GenEvent.
Definition of class ReaderAsciiHepMC2.
Definition of class WriterAsciiHepMC2.
Definition of class WriterAscii.
Stores event-related information.
Definition: GenEvent.h:41
GenEvent I/O serialization for structured text files.
GenEvent I/O serialization for structured text files.
Definition: WriterAscii.h:25
HepMC3 main namespace.
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...