15 #include "HepMC3/ReaderAscii.h"
16 #include "HepPID/ParticleName.hh"
21 int main(
int argc,
char* argv[]) {
24 std::cout <<
"Preparing reader " << std::flush;
25 HepMC3::ReaderAscii reader(
"test.hepmc3");
26 if (simReader.
status(reader)) {
27 std::cout <<
"succesful" << std::endl;
29 std::cout <<
"failed" << std::endl;
32 std::shared_ptr<HepMC3::GenEvent> genevt(
new HepMC3::GenEvent());
34 std::cout <<
"Reading event " << std::flush;
35 if (simReader.
readEvent(reader, genevt)) {
36 std::cout <<
"succesful" << std::endl;
38 std::cout <<
"failed" << std::endl;
40 std::cout << std::endl;
44 std::cout <<
"Event data:" << std::endl;
45 std::cout <<
"Units: ";
47 std::cout <<
"[GEV], ";
49 std::cout <<
"[MeV], ";
51 std::cout <<
"[mm]" << std::endl;
53 std::cout <<
"[cm]" << std::endl;
55 std::cout <<
"Event position: " << evtPos(0) <<
", " << evtPos(1) <<
", "
56 << evtPos(2) << std::endl;
57 std::cout <<
"Event time: " << simEvent.
eventTime(genevt) << std::endl;
59 std::cout <<
"Beam particles: ";
60 std::vector<std::unique_ptr<FW::SimParticle>> beam = simEvent.
beams(genevt);
62 std::cout <<
"none" << std::endl;
64 for (
auto& pbeam : beam)
65 std::cout << HepPID::particleName(pbeam->pdg()) <<
" ";
66 std::cout << std::endl;
69 std::cout << std::endl <<
"Vertices: ";
70 std::vector<std::unique_ptr<FW::SimVertex>> vertices =
73 std::cout <<
"none" << std::endl;
75 std::cout << std::endl;
76 for (
auto& vertex : vertices) {
77 for (
auto&
particle : vertex->incoming)
78 std::cout << HepPID::particleName(
particle.pdg()) <<
" ";
80 for (
auto&
particle : vertex->outgoing)
81 std::cout << HepPID::particleName(
particle.pdg()) <<
" ";
82 std::cout <<
"\t@(" << vertex->time() <<
", " << vertex->position()(0)
83 <<
", " << vertex->position()(1) <<
", "
84 << vertex->position()(2) <<
")" << std::endl;
86 std::cout << std::endl;
89 std::cout <<
"Total particle record:" << std::endl;
90 std::vector<std::unique_ptr<FW::SimParticle>> particles =
93 std::cout << HepPID::particleName(
particle->pdg())
94 <<
"\tID:" <<
particle->particleId() <<
", momentum: ("
97 <<
"), mass: " <<
particle->mass() << std::endl;
99 std::cout << std::endl <<
"Initial to final state: ";
100 std::vector<std::unique_ptr<FW::SimParticle>> fState =
102 for (
auto& pbeam : beam)
103 std::cout << HepPID::particleName(pbeam->pdg()) <<
" ";
105 for (
auto&
fs : fState)
106 std::cout << HepPID::particleName(
fs->pdg()) <<
" ";
107 std::cout << std::endl;