HepMC3 event record library
testConvert1.cc
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2020 The HepMC collaboration (see AUTHORS for details)
5 //
7 #include "HepMCCompatibility.h"
8 #include "HepMC3TestUtils.h"
9 int main()
10 {
11  HepMC3::ReaderAsciiHepMC2 inputA("inputConvert1.hepmc");
12  if(inputA.failed()) return 1;
13  std::ofstream outputA("frominputConvert1.hepmc");
14  outputA.precision(12);
15  HepMC::write_HepMC_IO_block_begin(outputA);
16  while( !inputA.failed() )
17  {
18  HepMC3::GenEvent evt(HepMC3::Units::GEV,HepMC3::Units::MM);
19  inputA.read_event(evt);
20  if( inputA.failed() ) {
21  printf("End of file reached. Exit.\n");
22  break;
23  }
24  HepMC::GenEvent* evt3=ConvertHepMCGenEvent_3to2(evt);
25  if (!evt3) return 3;
26  evt3->write(outputA);
27  evt.clear();
28  delete evt3;
29  }
30  inputA.close();
31  HepMC::write_HepMC_IO_block_end( outputA );
32  outputA.close();
33  return COMPARE_ASCII_FILES("frominputConvert1.hepmc","inputConvert1.hepmc");
34 }
Parser for HepMC2 I/O files.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
Definition: GenEvent.h:41
HepMC::GenEvent * ConvertHepMCGenEvent_3to2(const HepMC3::GenEvent &evt)
Please note the HEPMC_HAS_CENTRALITY should be defined externaly.
int main(int argc, char **argv)
Implementation of compatibility layer (in-memory conversion functions) between HePMC2 and HepMC3...