#include <LHEReader.h>
Classes | |
class | FileSource |
class | Source |
class | StringSource |
class | XMLHandler |
Public Member Functions | |
LHEReader (const edm::ParameterSet ¶ms) | |
LHEReader (const std::vector< std::string > &fileNames, unsigned int skip=0) | |
LHEReader (const std::string &inputs, unsigned int skip=0) | |
boost::shared_ptr< LHEEvent > | next (bool *newFileOpened=nullptr) |
~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 |
const std::string | strName |
Definition at line 18 of file LHEReader.h.
lhef::LHEReader::LHEReader | ( | const edm::ParameterSet & | params | ) |
Definition at line 319 of file LHEReader.cc.
{ }
lhef::LHEReader::LHEReader | ( | const std::vector< std::string > & | fileNames, |
unsigned int | skip = 0 |
||
) |
Definition at line 328 of file LHEReader.cc.
: fileURLs(fileNames), strName(""), firstEvent(firstEvent), maxEvents(-1), curIndex(0), handler(new XMLHandler()) { }
lhef::LHEReader::LHEReader | ( | const std::string & | inputs, |
unsigned int | skip = 0 |
||
) |
Definition at line 335 of file LHEReader.cc.
: strName(inputs), firstEvent(firstEvent), maxEvents(-1), curIndex(0), handler(new XMLHandler()) { }
lhef::LHEReader::~LHEReader | ( | ) |
Definition at line 342 of file LHEReader.cc.
{ }
boost::shared_ptr< LHEEvent > lhef::LHEReader::next | ( | bool * | newFileOpened = nullptr | ) |
Definition at line 346 of file LHEReader.cc.
References lhef::LHERunInfo::addHeader(), curDoc, curIndex, curRunInfo, curSource, 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, lhef::logFileAction(), maxEvents, and strName.
{ while(curDoc.get() || curIndex < fileURLs.size() || (fileURLs.size() == 0 && strName != "" ) ) { if (!curDoc.get()) { if ( fileURLs.size() > 0 ) { logFileAction(" Initiating request to open LHE file ", fileURLs[curIndex]); curSource.reset(new FileSource(fileURLs[curIndex])); logFileAction(" Successfully opened LHE file ", fileURLs[curIndex]); if ( newFileOpened != nullptr ) *newFileOpened = true; ++curIndex; } else if ( strName != "" ) { curSource.reset(new StringSource(strName)); } 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(); logFileAction(" Closed LHE file ", fileURLs[curIndex - 1]); } 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 42 of file LHEReader.h.
Referenced by next().
unsigned int lhef::LHEReader::curIndex [private] |
Definition at line 39 of file LHEReader.h.
Referenced by next().
boost::shared_ptr<LHERunInfo> lhef::LHEReader::curRunInfo [private] |
Definition at line 43 of file LHEReader.h.
Referenced by next().
std::auto_ptr<Source> lhef::LHEReader::curSource [private] |
Definition at line 41 of file LHEReader.h.
Referenced by next().
const std::vector<std::string> lhef::LHEReader::fileURLs [private] |
Definition at line 33 of file LHEReader.h.
Referenced by next().
unsigned int lhef::LHEReader::firstEvent [private] |
Definition at line 37 of file LHEReader.h.
Referenced by next().
std::auto_ptr<XMLHandler> lhef::LHEReader::handler [private] |
Definition at line 44 of file LHEReader.h.
Referenced by next().
int lhef::LHEReader::maxEvents [private] |
Definition at line 38 of file LHEReader.h.
Referenced by next().
const std::string lhef::LHEReader::strName [private] |
Definition at line 36 of file LHEReader.h.
Referenced by next().