#ifndef __UWEVENT_HH__ #define __UWEVENT_HH__ #include #include #include #include "fastjet/PseudoJet.hh" /// very crude routine for reading from UW format // $Id: UWEvent.hh 1735 2010-07-05 19:32:41Z salam $ /// /// Main event particles are stored in event; /// /// "internal" particles (those with lines starting -1) are stored /// in internal_particles /// /// The routine returns false if it reaches the end of the file /// /// Since the storage format is px,py,pz,E, the routine checks /// particle masses and if < 0, resets them = 0 by rescaling the /// energy. /// /// The particle user indices are set to the particle pdg_id bool readUWEvent(std::istream & istr, std::vector & event,\ std::vector & internal_particles ) { event.resize(0); internal_particles.resize(0); int ipart, pdgid; double px, py, pz, E; bool started = false; std::string line; while (getline(istr, line)) { // ignore blank lines and comment lines if (line.length() == 0 || line[0] == '#') continue; // now convert the line to numbers std::istringstream sstr(line.c_str()); sstr >> ipart >> px >> py >> pz >> E >> pdgid; // signal a new event if (ipart == 0) { if (started) break; else continue; } started = true; // force particle masses > 0 double pvec2 = px*px + py*py + pz*pz; if (E*E < pvec2) E = sqrt(pvec2); fastjet::PseudoJet particle(px, py, pz, E); particle.set_user_index(pdgid); if (ipart > 0) { // a final-state particle event.push_back(particle); } else { // ipart < 0 internal_particles.push_back(particle); } } return (event.size() > 0); } /// routine for reading in UW events that provides the main event /// but not the "internal" particles bool readUWEvent(std::istream & istr, std::vector & event) { std::vector internal_particles; return readUWEvent(istr, event, internal_particles); } #endif // __UWEVENT_HH__