Belle II Software development
|
Class to read Hepevt files and store the content in a MCParticle graph. More...
#include <HepevtReader.h>
Public Member Functions | |
BELLE2_DEFINE_EXCEPTION (HepEvtCouldNotOpenFileError, "Could not open file %1% !") | |
Exception is thrown if the HepEvt file could not be opened. | |
BELLE2_DEFINE_EXCEPTION (HepEvtInvalidDaughterIndicesError, "Line %1%: Invalid daughter indices d1=%2%, d2=%3%, N=%4% (0<=d1<=d2<=N required)") | |
Exception is thrown if the given indices of the daughters are not valid. | |
BELLE2_DEFINE_EXCEPTION (HepEvtHeaderNotValidError, "Line %1%: Event header not understood: %2%") | |
Exception is thrown if the header specifying the event header could not be parsed. | |
BELLE2_DEFINE_EXCEPTION (HepEvtConvertFieldError, "Line %1%: Could not convert field %2%: %3%") | |
Exception is thrown if a field in the HepEvt file could not be converted to a number. | |
BELLE2_DEFINE_EXCEPTION (HepEvtParticleFormatError, "Line %1%: Particle format not understood, got %2% fields !") | |
Exception is thrown if the format of a line of the HepEvt file could not be parsed. | |
BELLE2_DEFINE_EXCEPTION (HepEvtEmptyEventError, "Line %1%: Number of particles in event is %2% ! (This could mean EOF is reached.) ") | |
Exception is thrown if the number of particles for this event is 0 or less. | |
HepevtReader () | |
Constructor. | |
~HepevtReader () | |
Destructor. | |
void | open (const std::string &filename) |
Opens an ascii file and prepares it for reading. | |
void | closeCurrentInputFile () |
Closes the current input file to allow opening the next one. | |
int | getEvent (MCParticleGraph &graph, double &weight) |
Reads the next event and stores the result in the given MCParticle graph. | |
bool | skipEvents (int n) |
Skips a given number of events. | |
Public Attributes | |
int | m_nVirtual |
The number of particles in each event with a set Virtual flag. | |
bool | m_wrongSignPz |
Bool to indicate that HER and LER were swapped. | |
Protected Types | |
typedef boost::tokenizer< boost::char_separator< char > > | tokenizer |
Just a typedef for simple use of the boost::tokenizer to split the lines. | |
Protected Member Functions | |
std::string | getLine () |
Returns the current line from the Hepevt ascii file. | |
int | readEventHeader (int &eventID, double &eventWeight) |
Reads the event header from the hepevt file. | |
void | readParticle (MCParticleGraph::GraphParticle &particle) |
Reads the information for a single particle from the Hepevt file. | |
Protected Attributes | |
int | m_lineNr |
The current line number within the ascii file. | |
std::ifstream | m_input |
The input stream of the ascii file. | |
Static Protected Attributes | |
static const boost::char_separator< char > | sep |
The characters at which to split, defaults to ",; \t". | |
Class to read Hepevt files and store the content in a MCParticle graph.
The reader supports retrieving the Hepevt information from an ascii text file. Both formats, the short and the long LUND 7 format are supported.
The events are read sequentially with the option of skipping a certain number of events. Random access of events is not possible.
Definition at line 33 of file HepevtReader.h.
|
protected |
Just a typedef for simple use of the boost::tokenizer to split the lines.
Definition at line 93 of file HepevtReader.h.
|
inline |
Constructor.
Definition at line 55 of file HepevtReader.h.
|
inline |
Destructor.
Definition at line 60 of file HepevtReader.h.
BELLE2_DEFINE_EXCEPTION | ( | HepEvtEmptyEventError | , |
"Line %1%: Number of particles in event is %2% ! (This could mean EOF is reached.) " | |||
) |
Exception is thrown if the number of particles for this event is 0 or less.
|
inline |
Closes the current input file to allow opening the next one.
Definition at line 71 of file HepevtReader.h.
int getEvent | ( | MCParticleGraph & | graph, |
double & | weight | ||
) |
Reads the next event and stores the result in the given MCParticle graph.
graph | Reference to the graph which should be filled with the information from the Hepevt file. |
weight | Reference to the event weight which can be filled from the file. |
Definition at line 35 of file HepevtReader.cc.
|
protected |
Returns the current line from the Hepevt ascii file.
Definition at line 96 of file HepevtReader.cc.
void open | ( | const std::string & | filename | ) |
Opens an ascii file and prepares it for reading.
filename | The filename of the Hepevt ascii file which should be read. |
Definition at line 27 of file HepevtReader.cc.
|
protected |
Reads the event header from the hepevt file.
eventID | reference to the eventID which can be read from the file |
eventWeight | reference to the eventWeight which can be read from the file |
Definition at line 112 of file HepevtReader.cc.
|
protected |
Reads the information for a single particle from the Hepevt file.
particle | Reference to the particle which will be filled with the information from the Hepevt file. |
Definition at line 155 of file HepevtReader.cc.
bool skipEvents | ( | int | n | ) |
Skips a given number of events.
n | The number of events which should be skipped. |
Definition at line 79 of file HepevtReader.cc.
|
protected |
The input stream of the ascii file.
Definition at line 98 of file HepevtReader.h.
|
protected |
The current line number within the ascii file.
Definition at line 97 of file HepevtReader.h.
int m_nVirtual |
The number of particles in each event with a set Virtual flag.
Definition at line 88 of file HepevtReader.h.
bool m_wrongSignPz |
Bool to indicate that HER and LER were swapped.
Definition at line 89 of file HepevtReader.h.
|
staticprotected |
The characters at which to split, defaults to ",; \t".
Definition at line 95 of file HepevtReader.h.