#include <LHESource.h>
Public Member Functions | |
LHESource (const edm::ParameterSet ¶ms, const edm::InputSourceDescription &desc) | |
virtual | ~LHESource () |
Protected Member Functions | |
virtual void | beginRun (edm::Run &run) |
virtual void | endJob () |
virtual void | endRun (edm::Run &run) |
virtual void | nextEvent () |
virtual bool | produce (edm::Event &event) |
Protected Attributes | |
boost::shared_ptr< lhef::LHEEvent > | partonLevel |
std::auto_ptr< lhef::LHEReader > | reader |
boost::shared_ptr < lhef::LHERunInfo > | runInfo |
boost::shared_ptr < lhef::LHERunInfo > | runInfoLast |
boost::ptr_deque < LHERunInfoProduct > | runInfoProducts |
bool | wasMerged |
Definition at line 24 of file LHESource.h.
LHESource::LHESource | ( | const edm::ParameterSet & | params, |
const edm::InputSourceDescription & | desc | ||
) | [explicit] |
Definition at line 32 of file LHESource.cc.
: ExternalInputSource(params, desc, false), reader(new LHEReader(fileNames(), params.getUntrackedParameter<unsigned int>("skipEvents", 0))), wasMerged(false) { produces<LHEEventProduct>(); produces<LHERunInfoProduct, edm::InRun>(); }
LHESource::~LHESource | ( | ) | [virtual] |
Definition at line 42 of file LHESource.cc.
{ }
void LHESource::beginRun | ( | edm::Run & | run | ) | [protected, virtual] |
Reimplemented from edm::ConfigurableInputSource.
Definition at line 67 of file LHESource.cc.
References LHERunInfoProduct::addComment(), LHERunInfoProduct::addHeader(), nextEvent(), edm::Run::put(), runInfo, runInfoLast, runInfoProducts, and wasMerged.
{ nextEvent(); if (runInfoLast) { runInfo = runInfoLast; std::auto_ptr<LHERunInfoProduct> product( new LHERunInfoProduct(*runInfo->getHEPRUP())); std::for_each(runInfo->getHeaders().begin(), runInfo->getHeaders().end(), boost::bind( &LHERunInfoProduct::addHeader, product.get(), _1)); std::for_each(runInfo->getComments().begin(), runInfo->getComments().end(), boost::bind(&LHERunInfoProduct::addComment, product.get(), _1)); // keep a copy around in case of merging runInfoProducts.push_back(new LHERunInfoProduct(*product)); wasMerged = false; run.put(product); runInfo.reset(); } }
void LHESource::endJob | ( | void | ) | [protected, virtual] |
Reimplemented from edm::InputSource.
Definition at line 46 of file LHESource.cc.
References reader.
{ reader.reset(); }
void LHESource::endRun | ( | edm::Run & | run | ) | [protected, virtual] |
Reimplemented from edm::ConfigurableInputSource.
Definition at line 95 of file LHESource.cc.
References edm::Run::put(), and runInfoProducts.
{ if (!runInfoProducts.empty()) { std::auto_ptr<LHERunInfoProduct> product( runInfoProducts.pop_front().release()); run.put(product); } }
void LHESource::nextEvent | ( | ) | [protected, virtual] |
Definition at line 51 of file LHESource.cc.
References partonLevel, reader, runInfo, and runInfoLast.
Referenced by beginRun(), and produce().
{ if (partonLevel) return; partonLevel = reader->next(); if (!partonLevel) return; boost::shared_ptr<LHERunInfo> runInfoThis = partonLevel->getRunInfo(); if (runInfoThis != runInfoLast) { runInfo = runInfoThis; runInfoLast = runInfoThis; } }
bool LHESource::produce | ( | edm::Event & | event | ) | [protected, virtual] |
Implements edm::ConfigurableInputSource.
Definition at line 104 of file LHESource.cc.
References LHERunInfoProduct::addComment(), LHEEventProduct::addComment(), LHERunInfoProduct::addHeader(), nextEvent(), partonLevel, runInfo, runInfoProducts, and wasMerged.
{ nextEvent(); if (!partonLevel) return false; std::auto_ptr<LHEEventProduct> product( new LHEEventProduct(*partonLevel->getHEPEUP())); if (partonLevel->getPDF()) product->setPDF(*partonLevel->getPDF()); std::for_each(partonLevel->getComments().begin(), partonLevel->getComments().end(), boost::bind(&LHEEventProduct::addComment, product.get(), _1)); event.put(product); if (runInfo) { std::auto_ptr<LHERunInfoProduct> product( new LHERunInfoProduct(*runInfo->getHEPRUP())); std::for_each(runInfo->getHeaders().begin(), runInfo->getHeaders().end(), boost::bind( &LHERunInfoProduct::addHeader, product.get(), _1)); std::for_each(runInfo->getComments().begin(), runInfo->getComments().end(), boost::bind(&LHERunInfoProduct::addComment, product.get(), _1)); if (!runInfoProducts.empty()) { runInfoProducts.front().mergeProduct(*product); if (!wasMerged) { runInfoProducts.pop_front(); runInfoProducts.push_front(product); wasMerged = true; } } runInfo.reset(); } partonLevel.reset(); return true; }
boost::shared_ptr<lhef::LHEEvent> LHESource::partonLevel [protected] |
Definition at line 42 of file LHESource.h.
Referenced by nextEvent(), and produce().
std::auto_ptr<lhef::LHEReader> LHESource::reader [protected] |
Definition at line 38 of file LHESource.h.
Referenced by endJob(), and nextEvent().
boost::shared_ptr<lhef::LHERunInfo> LHESource::runInfo [protected] |
Definition at line 41 of file LHESource.h.
Referenced by beginRun(), nextEvent(), and produce().
boost::shared_ptr<lhef::LHERunInfo> LHESource::runInfoLast [protected] |
Definition at line 40 of file LHESource.h.
Referenced by beginRun(), and nextEvent().
boost::ptr_deque<LHERunInfoProduct> LHESource::runInfoProducts [protected] |
Definition at line 44 of file LHESource.h.
Referenced by beginRun(), endRun(), and produce().
bool LHESource::wasMerged [protected] |
Definition at line 45 of file LHESource.h.
Referenced by beginRun(), and produce().