#include <LHEReader.h>
Classes | |
class | FileSource |
class | Source |
class | XMLHandler |
Public Member Functions | |
LHEReader (const edm::ParameterSet ¶ms) | |
LHEReader (const std::vector< std::string > &fileNames, unsigned int skip=0) | |
boost::shared_ptr< LHEEvent > | next () |
~LHEReader () | |
Private Attributes | |
std::auto_ptr< XMLDocument > | curDoc |
unsigned int | curIndex |
boost::shared_ptr< LHERunInfo > | curRunInfo |
std::auto_ptr< Source > | curSource |
const std::vector< std::string > | fileURLs |
unsigned int | firstEvent |
std::auto_ptr< XMLHandler > | handler |
int | maxEvents |
Definition at line 18 of file LHEReader.h.
lhef::LHEReader::LHEReader | ( | const edm::ParameterSet & | params | ) |
Definition at line 288 of file LHEReader.cc.
{ }
lhef::LHEReader::LHEReader | ( | const std::vector< std::string > & | fileNames, |
unsigned int | skip = 0 |
||
) |
Definition at line 296 of file LHEReader.cc.
: fileURLs(fileNames), firstEvent(firstEvent), maxEvents(-1), curIndex(0), handler(new XMLHandler()) { }
lhef::LHEReader::~LHEReader | ( | ) |
Definition at line 303 of file LHEReader.cc.
{ }
boost::shared_ptr< LHEEvent > lhef::LHEReader::next | ( | void | ) |
Definition at line 307 of file LHEReader.cc.
References lhef::LHERunInfo::addHeader(), curDoc, curIndex, curRunInfo, curSource, AlCaHLTBitMon_QueryRunRegistry::data, event(), fileURLs, firstEvent, handler, lhef::LHEReader::XMLHandler::kComment, lhef::LHEReader::XMLHandler::kEvent, lhef::LHEReader::XMLHandler::kHeader, lhef::LHEReader::XMLHandler::kInit, lhef::LHEReader::XMLHandler::kNone, and maxEvents.
{ while(curDoc.get() || curIndex < fileURLs.size()) { if (!curDoc.get()) { curSource.reset(new FileSource(fileURLs[curIndex++])); handler->reset(); curDoc.reset(curSource->createReader(*handler)); curRunInfo.reset(); } XMLHandler::Object event = handler->gotObject; handler->gotObject = XMLHandler::kNone; std::istringstream data; if (event != XMLHandler::kNone) { data.str(handler->buffer); handler->buffer.clear(); } switch(event) { case XMLHandler::kNone: if (!curDoc->parse()) curDoc.reset(); break; case XMLHandler::kHeader: break; case XMLHandler::kInit: curRunInfo.reset(new LHERunInfo(data)); std::for_each(handler->headers.begin(), handler->headers.end(), boost::bind(&LHERunInfo::addHeader, curRunInfo.get(), _1)); handler->headers.clear(); break; case XMLHandler::kComment: break; case XMLHandler::kEvent: if (!curRunInfo.get()) throw cms::Exception("InvalidState") << "Got LHE event without" " initialization." << std::endl; if (firstEvent > 0) { firstEvent--; continue; } if (maxEvents == 0) return boost::shared_ptr<LHEEvent>(); else if (maxEvents > 0) maxEvents--; return boost::shared_ptr<LHEEvent>( new LHEEvent(curRunInfo, data)); } } return boost::shared_ptr<LHEEvent>(); }
std::auto_ptr<XMLDocument> lhef::LHEReader::curDoc [private] |
Definition at line 38 of file LHEReader.h.
Referenced by next().
unsigned int lhef::LHEReader::curIndex [private] |
Definition at line 35 of file LHEReader.h.
Referenced by next().
boost::shared_ptr<LHERunInfo> lhef::LHEReader::curRunInfo [private] |
Definition at line 39 of file LHEReader.h.
Referenced by next().
std::auto_ptr<Source> lhef::LHEReader::curSource [private] |
Definition at line 37 of file LHEReader.h.
Referenced by next().
const std::vector<std::string> lhef::LHEReader::fileURLs [private] |
Definition at line 30 of file LHEReader.h.
Referenced by next().
unsigned int lhef::LHEReader::firstEvent [private] |
Definition at line 33 of file LHEReader.h.
Referenced by next().
std::auto_ptr<XMLHandler> lhef::LHEReader::handler [private] |
Definition at line 40 of file LHEReader.h.
Referenced by next().
int lhef::LHEReader::maxEvents [private] |
Definition at line 34 of file LHEReader.h.
Referenced by next().