7 #include "HepMC/ReaderHEPEVT.h" 8 #include "HepMC/HEPEVT_Wrapper.h" 20 m_file= fopen(filename.c_str(),
"r");
21 if (!
m_file) {
m_failed=
true; ERROR(
"ReaderHEPEVT: file opening failed" ); }
30 #define READERHEPEVTBUFFERSIZE 255 33 char buf_e[READERHEPEVTBUFFERSIZE];
38 if (fgets(buf_e,READERHEPEVTBUFFERSIZE,
m_file)==NULL)
break;
39 std::stringstream st_e(buf_e);
44 if (!(st_e>>attr))
break;
45 if (attr==
' ')
continue;
49 eventline=
static_cast<bool>(st_e>>m_i>>m_p);
61 char buf_p[READERHEPEVTBUFFERSIZE];
62 char buf_v[READERHEPEVTBUFFERSIZE];
66 if (fgets(buf_p,READERHEPEVTBUFFERSIZE,
m_file)==NULL)
return false;
67 if (iflong)
if (fgets(buf_v,READERHEPEVTBUFFERSIZE,
m_file)==NULL)
return false;
68 std::stringstream st_p(buf_p);
69 std::stringstream st_v(buf_v);
72 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;}
73 if (!static_cast<bool>(st_v>>fltcodes2[0]>>fltcodes2[1]>>fltcodes2[2]>>fltcodes2[3])) { ERROR(
"ReaderHEPEVT: Error reading particle vertex");
return false;}
77 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;}
80 fltcodes1[3]=std::sqrt(fltcodes1[0]*fltcodes1[0]+fltcodes1[1]*fltcodes1[1]+fltcodes1[2]*fltcodes1[2]+fltcodes1[4]*fltcodes1[4]);
112 shared_ptr<GenRunInfo> g=make_shared<GenRunInfo>();
113 std::vector<std::string> weightnames;
114 weightnames.push_back(
"0");
115 std::vector<double> wts;
117 g->set_weight_names(weightnames);
static void set_number_entries(int noentries)
Set number of entries.
static void set_status(int index, int status)
Set status code.
char * hepevtbuffer
Pointer to HEPEVT Fortran common block/C struct.
static void set_parents(int index, int firstparent, int lastparent)
Set parents.
static void set_hepevt_address(char *c)
Set Fortran block address.
void close()
Close file stream.
int m_events_count
Event count.
virtual bool read_hepevt_particle(int i, bool iflong=true)
read particle from file
void clear()
Remove contents of this event.
void set_run_info(shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
FILE * m_file
File to read.
Stores event-related information.
static void set_id(int index, int id)
Set PDG particle id.
virtual bool read_hepevt_event_header()
Find and read event header line from file.
bool failed()
Get stream error state.
Fortran common block HEPEVT.
static void set_event_number(int evtno)
Set event number.
static void set_children(int index, int firstchild, int lastchild)
Set children.
static void set_mass(int index, double mass)
Set mass.
static int number_entries()
Get number of entries.
Definition of template class SmartPointer.
ReaderHEPEVT(const std::string &filename)
Default constructor.
static void zero_everything()
Set all entries in HEPEVT to zero.
static void set_position(int index, double x, double y, double z, double t)
Set position in time-space.
bool read_event(GenEvent &evt, bool iflong)
Read event from file.
void set_run_info(shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
static void set_momentum(int index, double px, double py, double pz, double e)
Set 4-momentum.
const std::vector< double > & weights() const
Get event weight values as a vector.
static bool HEPEVT_to_GenEvent(GenEvent *evt)
Convert HEPEVT to GenEvent.