24 m_file= fopen(filename.c_str(),
"r");
34 #define READERHEPEVTBUFFERSIZE 255
37 char buf_e[READERHEPEVTBUFFERSIZE];
42 if (fgets(buf_e,READERHEPEVTBUFFERSIZE,
m_file)==
nullptr)
break;
43 std::stringstream st_e(buf_e);
48 if (!(st_e>>attr))
break;
49 if (attr==
' ')
continue;
53 eventline=
static_cast<bool>(st_e>>m_i>>m_p);
65 char buf_p[READERHEPEVTBUFFERSIZE];
66 char buf_v[READERHEPEVTBUFFERSIZE];
70 if (fgets(buf_p,READERHEPEVTBUFFERSIZE,
m_file)==
nullptr)
return false;
71 if (iflong)
if (fgets(buf_v,READERHEPEVTBUFFERSIZE,
m_file)==
nullptr)
return false;
72 std::stringstream st_p(buf_p);
73 std::stringstream st_v(buf_v);
76 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;}
77 if (!static_cast<bool>(st_v>>fltcodes2[0]>>fltcodes2[1]>>fltcodes2[2]>>fltcodes2[3])) {
ERROR(
"ReaderHEPEVT: Error reading particle vertex");
return false;}
81 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;}
84 fltcodes1[3]=std::sqrt(fltcodes1[0]*fltcodes1[0]+fltcodes1[1]*fltcodes1[1]+fltcodes1[2]*fltcodes1[2]+fltcodes1[4]*fltcodes1[4]);
113 shared_ptr<GenRunInfo> g=make_shared<GenRunInfo>();
114 std::vector<std::string> weightnames;
115 weightnames.push_back(
"0");
116 std::vector<double> wts;
118 g->set_weight_names(weightnames);
void set_run_info(shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
void close()
Close file stream.
FILE * m_file
File to read.
Definition of class ReaderHEPEVT.
#define ERROR(MESSAGE)
Macro for printing error messages.
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.
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.
int m_events_count
Event count.
Stores event-related information.
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.
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.
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.
static int number_entries()
Get number of entries.