19 : m_file(filename), m_stream(0), m_isstream(false)
22 HEPMC3_ERROR(
"ReaderHEPEVT: could not open input file: "<<filename )
34 : m_stream(&stream), m_isstream(true)
37 HEPMC3_ERROR(
"ReaderHEPEVT: could not open input stream ")
49 const size_t max_buffer_size=512*512;
50 char buf[max_buffer_size];
57 if (nn<0)
return true;
67 const size_t max_e_buffer_size=512;
68 char buf_e[max_e_buffer_size];
74 if( strlen(buf_e) == 0 )
return false;
75 std::stringstream st_e(buf_e);
80 if (!(st_e>>attr))
break;
81 if (attr==
' ')
continue;
85 eventline=
static_cast<bool>(st_e>>m_i>>m_p);
97 const size_t max_p_buffer_size=512;
98 const size_t max_v_buffer_size=512;
99 char buf_p[max_p_buffer_size];
100 char buf_v[max_v_buffer_size];
105 if( strlen(buf_p) == 0 )
return false;
109 if( strlen(buf_v) == 0 )
return false;
111 std::stringstream st_p(buf_p);
112 std::stringstream st_v(buf_v);
115 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;}
116 if (!static_cast<bool>(st_v>>fltcodes2[0]>>fltcodes2[1]>>fltcodes2[2]>>fltcodes2[3])) {
HEPMC3_ERROR(
"ReaderHEPEVT: HEPMC3_ERROR reading particle vertex");
return false;}
120 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;}
123 fltcodes1[3]=std::sqrt(fltcodes1[0]*fltcodes1[0]+fltcodes1[1]*fltcodes1[1]+fltcodes1[2]*fltcodes1[2]+fltcodes1[4]*fltcodes1[4]);
151 std::shared_ptr<GenRunInfo> g=std::make_shared<GenRunInfo>();
152 std::vector<std::string> weightnames;
153 weightnames.push_back(
"0");
154 std::vector<double> wts;
156 g->set_weight_names(weightnames);
170 if( !
m_file.is_open())
return;
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.
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.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
char * hepevtbuffer
Pointer to HEPEVT Fortran common block/C struct.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
#define HEPMC3_ERROR(MESSAGE)
Macro for printing error messages.
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.
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.