Read and write event files in the hepmc2
format, also known as
IO_GenEvent
.
This crate is inspired by the code for the ReaderAsciiHepMC2
in the
HepMC3 library, version
3.2.0. The aim is to be fully compatible, but be aware that the
current tests are not exhaustive.
``rust
// Read events from
eventsin.hepmc2and write them to
eventsout.hepmc2`
use hepmc2::{Reader, Writer};
use std::io::BufReader; use std::fs::File;
let input = BufReader::new(File::open("eventsin.hepmc2")?); let inevents = Reader::from(input);
let output = File::create("eventsout.hepmc2")?; let mut writer = Writer::tryfrom(output)?;
for event in in_events { let event = event?; println!("Current cross section: {}", event.xs); writer.write(&event)? } writer.finish()?; ```
License: GPL-3.0-or-later