19 : m_file(filename), m_stream(0), m_isstream(false), m_vertices_positions_present(true)
22 ERROR(
"ReaderHEPEVT: could not open input file: "<<filename )
33 : m_stream(&stream), m_isstream(true), m_vertices_positions_present(true)
36 ERROR(
"ReaderHEPEVT: could not open input stream ")
48 const size_t max_e_buffer_size=512;
49 char buf_e[max_e_buffer_size];
55 if( strlen(buf_e) == 0 )
return false;
56 std::stringstream st_e(buf_e);
61 if (!(st_e>>attr))
break;
62 if (attr==
' ')
continue;
66 eventline=
static_cast<bool>(st_e>>m_i>>m_p);
78 const size_t max_p_buffer_size=512;
79 const size_t max_v_buffer_size=512;
80 char buf_p[max_p_buffer_size];
81 char buf_v[max_v_buffer_size];
86 if( strlen(buf_p) == 0 )
return false;
89 if( strlen(buf_v) == 0 )
return false;
91 std::stringstream st_p(buf_p);
92 std::stringstream st_v(buf_v);
95 if (!static_cast<bool>(st_p>>intcodes[0]>>intcodes[1]>>intcodes[2]>>intcodes[3]>>intcodes[4]>>intcodes[5]>>fltcodes1[0]>>fltcodes1[1]>>fltcodes1[2]>>fltcodes1[3]>>fltcodes1[4])) {
ERROR(
"ReaderHEPEVT: Error reading particle momenta");
return false;}
96 if (!static_cast<bool>(st_v>>fltcodes2[0]>>fltcodes2[1]>>fltcodes2[2]>>fltcodes2[3])) {
ERROR(
"ReaderHEPEVT: Error reading particle vertex");
return false;}
100 if (!static_cast<bool>(st_p>>intcodes[0]>>intcodes[1]>>intcodes[4]>>intcodes[5]>>fltcodes1[0]>>fltcodes1[1]>>fltcodes1[2]>>fltcodes1[4])) {
ERROR(
"ReaderHEPEVT: Error reading particle momenta");
return false;}
103 fltcodes1[3]=std::sqrt(fltcodes1[0]*fltcodes1[0]+fltcodes1[1]*fltcodes1[1]+fltcodes1[2]*fltcodes1[2]+fltcodes1[4]*fltcodes1[4]);
131 shared_ptr<GenRunInfo> g=make_shared<GenRunInfo>();
132 std::vector<std::string> weightnames;
133 weightnames.push_back(
"0");
134 std::vector<double> wts;
136 g->set_weight_names(weightnames);
156 if( !
m_file.is_open())
return;
void set_run_info(shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
void close()
Close file stream.
Definition of class ReaderHEPEVT.
#define ERROR(MESSAGE)
Macro for printing error messages.
bool m_isstream
toggles usage of m_file or m_stream
ReaderHEPEVT(const std::string &filename)
Default constructor.
static void set_mass(const int &index, double mass)
Set mass.
static void set_children(const int &index, const int &firstchild, const int &lastchild)
Set children.
void set_vertices_positions_present(bool iflong)
set flag if vertex positions are available
static void set_hepevt_address(char *c)
Set Fortran block address.
static void set_position(const int &index, const double &x, const double &y, const double &z, const double &t)
Set position in time-space.
virtual bool read_hepevt_event_header()
Find and read event header line from file.
static void set_parents(const int &index, const int &firstparent, const int &lastparent)
Set parents.
static void set_id(const int &index, const int &id)
Set PDG particle id.
Stores event-related information.
bool m_vertices_positions_present
true if vertex positions are available
static void zero_everything()
Set all entries in HEPEVT to zero.
Fortran common block HEPEVT.
bool read_event(GenEvent &evt, bool iflong)
Read event from file.
static void set_number_entries(const int &noentries)
Set number of entries.
bool get_vertices_positions_present() const
get flag if vertex positions are available
static bool HEPEVT_to_GenEvent(GenEvent *evt)
Convert HEPEVT to GenEvent.
static void set_event_number(const int &evtno)
Set event number.
char * hepevtbuffer
Pointer to HEPEVT Fortran common block/C struct.
virtual bool read_hepevt_particle(int i, bool iflong=true)
read particle from file
void set_run_info(shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
const std::vector< double > & weights() const
Get event weight values as a vector.
static void set_status(const int &index, const int &status)
Set status code.
std::ifstream m_file
Input file.
bool failed()
Get stream error state.
void clear()
Remove contents of this event.
static void set_momentum(const int &index, const double &px, const double &py, const double &pz, const double &e)
Set 4-momentum.
Definition of class HEPEVT_Wrapper.
std::istream * m_stream
For ctor when reading from stdin.
static int number_entries()
Get number of entries.