HepMC3 event record library
testConvert1.cc
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2021 The HepMC collaboration (see AUTHORS for details)
5//
8#include "HepMC3TestUtils.h"
9int 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}
Implementation of compatibility layer (in-memory conversion functions) between HepMC2 and HepMC3.
HepMC::GenEvent * ConvertHepMCGenEvent_3to2(const HepMC3::GenEvent &evt)
Please note the HEPMC_HAS_CENTRALITY should be defined externaly.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
Definition: GenEvent.h:41
Parser for HepMC2 I/O files.