23#include "HepMC3/Attribute.h"
24#include "HepMC3/GenEvent.h"
25#include "HepMC3/GenParticle.h"
26#include "HepMC3/PrintStreams.h"
29#include "marley/CommandHandler.hh"
30#include "marley/EventFileReader.hh"
31#include "marley/hepmc3_utils.hh"
35 enum class PrintFormat {
43 std::cout <<
" particle with PDG code = " << p.
pid()
44 <<
" has total energy " << p4.e() <<
" MeV,"
45 <<
'\n' <<
" 3-momentum = (" << p4.px() <<
" MeV, " << p4.py()
46 <<
" MeV, " << p4.pz() <<
" MeV)," <<
'\n'
48 << marley_hepmc3::get_particle_charge( p )
49 <<
" times the proton charge." <<
'\n';
54 const auto initials_proj = marley_hepmc3::get_particles_with_status(
55 marley_hepmc3::NUHEPMC_PROJECTILE_STATUS, e );
56 const auto initials_targ = marley_hepmc3::get_particles_with_status(
57 marley_hepmc3::NUHEPMC_TARGET_STATUS, e );
58 const auto finals = marley_hepmc3::get_particles_with_status(
59 marley_hepmc3::NUHEPMC_FINAL_STATE_STATUS, e );
60 auto residue = marley_hepmc3::get_residue( e );
62 size_t num_initial = initials_proj.size() + initials_targ.size();
63 size_t num_final = finals.size();
65 std::cout <<
"\n*** Event " << num <<
" has "
66 << num_initial <<
" initial particles and "
67 << num_final <<
" final particles. ***" <<
'\n';
74 if ( Ex_attr ) Ex = Ex_attr->
value();
76 if ( twoJ_attr ) twoJ = twoJ_attr->
value();
78 if ( parity_attr ) parity = parity_attr->
value();
80 bool twoJ_is_odd = ( twoJ % 2 == 1 );
82 std::cout <<
"The residual nucleus initially had excitation energy "
83 << Ex <<
" MeV and spin-parity ";
84 if ( twoJ_is_odd ) std::cout << twoJ <<
"/2";
85 else std::cout << twoJ / 2;
86 std::cout << ( parity >= 0 ?
'+' :
'-' ) <<
'\n';
89 std::cout <<
"Initial particles" <<
'\n';
90 for (
const auto& particle_i : initials_proj ) {
91 print_particle_info( *particle_i );
93 for (
const auto& particle_i : initials_targ ) {
94 print_particle_info( *particle_i );
97 std::cout <<
"Final particles" <<
'\n';
98 for (
const auto& particle_f : finals ) {
99 print_particle_info( *particle_f );
107 std::string first_arg;
108 if ( !args.empty() ) first_arg = args.front();
110 if ( first_arg.empty() || first_arg ==
"-h" || first_arg ==
"--help" ) {
112 args.push_front(
"print" );
116 PrintFormat format = PrintFormat::Pretty;
117 if ( first_arg ==
"pretty" ) {
122 else if ( first_arg ==
"hepmc3" ) {
123 format = PrintFormat::HepMC3;
126 else if ( first_arg ==
"legacy" ) {
127 format = PrintFormat::Legacy;
133 if ( args.empty() ) {
134 args.push_front(
"print" );
141 for (
const auto& file_name : args ) {
144 int event_number = 0;
145 while ( reader >> ev ) {
146 if ( format == PrintFormat::Pretty ) {
147 marley_hepmc3::print_event( ev );
149 else if ( format == PrintFormat::HepMC3 ) {
154 print_event_info( ev, event_number );
Attribute that holds a real number as a double.
double value() const
get the value associated to this Attribute.
Stores event-related information.
Stores particle-related information.
const FourVector & momentum() const
Get momentum.
double generated_mass() const
Get generated mass.
int pid() const
Get PDG ID.
Attribute that holds an Integer implemented as an int.
int value() const
get the value associated to this Attribute.
static bool cmd_help(std::deque< std::string > &args)
Display top-level or command-specific help messages.
static bool cmd_print(std::deque< std::string > &args)
Print existing MARLEY events in a human-readable format.
Object that parses MARLEY output files.