19 : m_file(filename), m_stream(0), m_isstream(false)
22 HEPMC3_ERROR(
"ReaderHEPEVT: could not open input file: "<<filename )
33 : m_stream(&stream), m_isstream(true)
36 HEPMC3_ERROR(
"ReaderHEPEVT: could not open input stream ")
48 const size_t max_buffer_size=512*512;
49 char buf[max_buffer_size];
56 if (nn<0)
return true;
66 const size_t max_e_buffer_size=512;
67 char buf_e[max_e_buffer_size];
73 if( strlen(buf_e) == 0 )
return false;
74 std::stringstream st_e(buf_e);
79 if (!(st_e>>attr))
break;
80 if (attr==
' ')
continue;
84 eventline=static_cast<bool>(st_e>>m_i>>m_p);
96 const size_t max_p_buffer_size=512;
97 const size_t max_v_buffer_size=512;
98 char buf_p[max_p_buffer_size];
99 char buf_v[max_v_buffer_size];
104 if( strlen(buf_p) == 0 )
return false;
108 if( strlen(buf_v) == 0 )
return false;
110 std::stringstream st_p(buf_p);
111 std::stringstream st_v(buf_v);
114 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])) {
HEPMC3_ERROR(
"ReaderHEPEVT: HEPMC3_ERROR reading particle momenta");
return false;}
115 if (!static_cast<bool>(st_v>>fltcodes2[0]>>fltcodes2[1]>>fltcodes2[2]>>fltcodes2[3])) {
HEPMC3_ERROR(
"ReaderHEPEVT: HEPMC3_ERROR reading particle vertex");
return false;}
119 if (!static_cast<bool>(st_p>>intcodes[0]>>intcodes[1]>>intcodes[4]>>intcodes[5]>>fltcodes1[0]>>fltcodes1[1]>>fltcodes1[2]>>fltcodes1[4])) {
HEPMC3_ERROR(
"ReaderHEPEVT: HEPMC3_ERROR reading particle momenta");
return false;}
122 fltcodes1[3]=std::sqrt(fltcodes1[0]*fltcodes1[0]+fltcodes1[1]*fltcodes1[1]+fltcodes1[2]*fltcodes1[2]+fltcodes1[4]*fltcodes1[4]);
150 shared_ptr<GenRunInfo> g=make_shared<GenRunInfo>();
151 std::vector<std::string> weightnames;
152 weightnames.push_back(
"0");
153 std::vector<double> wts;
155 g->set_weight_names(weightnames);
169 if( !
m_file.is_open())
return;
void set_run_info(shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
bool failed() override
Get stream error state.
bool skip(const int) override
skip events
Definition of class ReaderHEPEVT.
void close() override
Close file stream.
std::map< std::string, std::string > m_options
options
bool m_isstream
toggles usage of m_file or m_stream
ReaderHEPEVT(const std::string &filename)
Default constructor.
bool read_event(GenEvent &evt) override
Read event from file.
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.
const std::vector< double > & weights() const
Get event weight values as a vector.
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.
static void zero_everything()
Check for problems with HEPEVT common block.
Fortran common block HEPEVT.
static void set_number_entries(const int &noentries)
Set number of entries.
static bool HEPEVT_to_GenEvent(GenEvent *evt)
Convert HEPEVT to GenEvent.
virtual bool read_hepevt_particle(int i)
read particle from file
static void set_event_number(const int &evtno)
Set event number.
char * hepevtbuffer
Pointer to HEPEVT Fortran common block/C struct.
void set_run_info(shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
#define HEPMC3_ERROR(MESSAGE)
Macro for printing error messages.
static void set_status(const int &index, const int &status)
Set status code.
std::ifstream m_file
Input file.
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.