#include <LHESource.h>
Public Member Functions | |
LHESource (const edm::ParameterSet ¶ms, const edm::InputSourceDescription &desc) | |
virtual | ~LHESource () |
Private Member Functions | |
virtual void | beginRun (edm::Run &run) override |
virtual void | endJob () override |
virtual void | endRun (edm::Run &run) override |
void | nextEvent () |
virtual void | produce (edm::Event &) |
virtual edm::EventPrincipal * | readEvent_ (edm::EventPrincipal &eventPrincipal) override |
virtual boost::shared_ptr < edm::LuminosityBlockPrincipal > | readLuminosityBlock_ (boost::shared_ptr< edm::LuminosityBlockPrincipal > lumiPrincipal) override |
virtual boost::shared_ptr < edm::RunPrincipal > | readRun_ (boost::shared_ptr< edm::RunPrincipal > runPrincipal) override |
virtual bool | setRunAndEventInfo (edm::EventID &, edm::TimeValue_t &) override |
Private Attributes | |
edm::LHEProvenanceHelper | lheProvenanceHelper_ |
boost::shared_ptr< lhef::LHEEvent > | partonLevel |
edm::ProcessHistoryID | phid_ |
std::auto_ptr< lhef::LHEReader > | reader |
boost::shared_ptr < lhef::LHERunInfo > | runInfo |
boost::shared_ptr < lhef::LHERunInfo > | runInfoLast |
boost::ptr_deque < LHERunInfoProduct > | runInfoProducts |
boost::shared_ptr < edm::RunPrincipal > | runPrincipal_ |
bool | wasMerged |
Definition at line 31 of file LHESource.h.
LHESource::LHESource | ( | const edm::ParameterSet & | params, |
const edm::InputSourceDescription & | desc | ||
) | [explicit] |
Definition at line 33 of file LHESource.cc.
References edm::LHEProvenanceHelper::lheAugment(), edm::LHEProvenanceHelper::lheInit(), lheProvenanceHelper_, nextEvent(), phid_, edm::InputSource::productRegistryUpdate(), and runInfo.
: ProducerSourceFromFiles(params, desc, false), reader(new LHEReader(fileNames(), params.getUntrackedParameter<unsigned int>("skipEvents", 0))), wasMerged(false), lheProvenanceHelper_(edm::TypeID(typeid(LHEEventProduct)), edm::TypeID(typeid(LHERunInfoProduct))), phid_(), runPrincipal_() { nextEvent(); lheProvenanceHelper_.lheAugment(runInfo.get()); // Initialize metadata, and save the process history ID for use every event. phid_ = lheProvenanceHelper_.lheInit(productRegistryUpdate()); // These calls are not wanted, because the principals are used for putting the products. //produces<LHEEventProduct>(); //produces<LHERunInfoProduct, edm::InRun>(); }
LHESource::~LHESource | ( | ) | [virtual] |
Definition at line 52 of file LHESource.cc.
{ }
void LHESource::beginRun | ( | edm::Run & | run | ) | [override, private, virtual] |
Reimplemented from edm::ProducerSourceBase.
Definition at line 98 of file LHESource.cc.
References LHERunInfoProduct::addComment(), LHERunInfoProduct::addHeader(), lheProvenanceHelper_, runInfo, runInfoLast, runInfoProducts, runPrincipal_, edm::LHEProvenanceHelper::runProductBranchDescription_, and wasMerged.
{ 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; edm::WrapperOwningHolder rdp(new edm::Wrapper<LHERunInfoProduct>(product), edm::Wrapper<LHERunInfoProduct>::getInterface()); runPrincipal_->put(lheProvenanceHelper_.runProductBranchDescription_, rdp); runInfo.reset(); } }
void LHESource::endJob | ( | void | ) | [override, private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 56 of file LHESource.cc.
References reader.
{ reader.reset(); }
void LHESource::endRun | ( | edm::Run & | run | ) | [override, private, virtual] |
Reimplemented from edm::ProducerSourceBase.
Definition at line 126 of file LHESource.cc.
References lheProvenanceHelper_, runInfoProducts, runPrincipal_, and edm::LHEProvenanceHelper::runProductBranchDescription_.
{ if (!runInfoProducts.empty()) { std::auto_ptr<LHERunInfoProduct> product( runInfoProducts.pop_front().release()); edm::WrapperOwningHolder rdp(new edm::Wrapper<LHERunInfoProduct>(product), edm::Wrapper<LHERunInfoProduct>::getInterface()); runPrincipal_->put(lheProvenanceHelper_.runProductBranchDescription_, rdp); } runPrincipal_.reset(); }
void LHESource::nextEvent | ( | ) | [private] |
Definition at line 61 of file LHESource.cc.
References edm::FromFiles::incrementFileIndex(), partonLevel, reader, runInfo, and runInfoLast.
Referenced by LHESource(), and setRunAndEventInfo().
{ if (partonLevel) { return; } bool newFileOpened = false; partonLevel = reader->next(&newFileOpened); if(newFileOpened) incrementFileIndex(); if (!partonLevel) { return; } boost::shared_ptr<LHERunInfo> runInfoThis = partonLevel->getRunInfo(); if (runInfoThis != runInfoLast) { runInfo = runInfoThis; runInfoLast = runInfoThis; } }
virtual void LHESource::produce | ( | edm::Event & | ) | [inline, private, virtual] |
edm::EventPrincipal * LHESource::readEvent_ | ( | edm::EventPrincipal & | eventPrincipal | ) | [override, private, virtual] |
Reimplemented from edm::ProducerSourceBase.
Definition at line 147 of file LHESource.cc.
References LHERunInfoProduct::addComment(), LHEEventProduct::addComment(), LHERunInfoProduct::addHeader(), LHEEventProduct::addWeight(), printConversionInfo::aux, edm::InputSource::eventCached(), edm::ProducerSourceBase::eventID(), edm::LHEProvenanceHelper::eventProductBranchDescription_, edm::LHEProvenanceHelper::eventProductProvenance_, edm::EventPrincipal::fillEventPrincipal(), lheProvenanceHelper_, partonLevel, phid_, edm::ProducerSourceBase::presentTime(), edm::InputSource::processGUID(), edm::InputSource::processingMode(), edm::EventPrincipal::put(), edm::InputSource::resetEventCached(), runInfo, runInfoProducts, edm::InputSource::RunsLumisAndEvents, edm::EventAuxiliary::setProcessHistoryID(), and wasMerged.
{ assert(eventCached() || processingMode() != RunsLumisAndEvents); EventSourceSentry sentry(*this); edm::EventAuxiliary aux(eventID(), processGUID(), edm::Timestamp(presentTime()), false); aux.setProcessHistoryID(phid_); eventPrincipal.fillEventPrincipal(aux); std::auto_ptr<LHEEventProduct> product( new LHEEventProduct(*partonLevel->getHEPEUP(), partonLevel->originalXWGTUP()) ); if (partonLevel->getPDF()) { product->setPDF(*partonLevel->getPDF()); } std::for_each(partonLevel->weights().begin(), partonLevel->weights().end(), boost::bind(&LHEEventProduct::addWeight, product.get(), _1)); std::for_each(partonLevel->getComments().begin(), partonLevel->getComments().end(), boost::bind(&LHEEventProduct::addComment, product.get(), _1)); edm::WrapperOwningHolder edp(new edm::Wrapper<LHEEventProduct>(product), edm::Wrapper<LHEEventProduct>::getInterface()); eventPrincipal.put(lheProvenanceHelper_.eventProductBranchDescription_, edp, lheProvenanceHelper_.eventProductProvenance_); 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(); resetEventCached(); return &eventPrincipal; }
boost::shared_ptr< edm::LuminosityBlockPrincipal > LHESource::readLuminosityBlock_ | ( | boost::shared_ptr< edm::LuminosityBlockPrincipal > | lumiPrincipal | ) | [override, private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 92 of file LHESource.cc.
References edm::InputSource::luminosityBlockAuxiliary(), and phid_.
{ luminosityBlockAuxiliary()->setProcessHistoryID(phid_); lumiPrincipal->fillLuminosityBlockPrincipal(); return lumiPrincipal; }
boost::shared_ptr< edm::RunPrincipal > LHESource::readRun_ | ( | boost::shared_ptr< edm::RunPrincipal > | runPrincipal | ) | [override, private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 84 of file LHESource.cc.
References phid_, edm::InputSource::runAuxiliary(), edm::InputSource::runPrincipal(), and runPrincipal_.
{ runAuxiliary()->setProcessHistoryID(phid_); runPrincipal->fillRunPrincipal(); runPrincipal_ = runPrincipal; return runPrincipal; }
bool LHESource::setRunAndEventInfo | ( | edm::EventID & | , |
edm::TimeValue_t & | |||
) | [override, private, virtual] |
Implements edm::ProducerSourceBase.
Definition at line 137 of file LHESource.cc.
References nextEvent(), and partonLevel.
{ nextEvent(); if (!partonLevel) { return false; } return true; }
Definition at line 57 of file LHESource.h.
Referenced by beginRun(), endRun(), LHESource(), and readEvent_().
boost::shared_ptr<lhef::LHEEvent> LHESource::partonLevel [private] |
Definition at line 53 of file LHESource.h.
Referenced by nextEvent(), readEvent_(), and setRunAndEventInfo().
edm::ProcessHistoryID LHESource::phid_ [private] |
Definition at line 58 of file LHESource.h.
Referenced by LHESource(), readEvent_(), readLuminosityBlock_(), and readRun_().
std::auto_ptr<lhef::LHEReader> LHESource::reader [private] |
Definition at line 49 of file LHESource.h.
Referenced by endJob(), and nextEvent().
boost::shared_ptr<lhef::LHERunInfo> LHESource::runInfo [private] |
Definition at line 52 of file LHESource.h.
Referenced by beginRun(), LHESource(), nextEvent(), and readEvent_().
boost::shared_ptr<lhef::LHERunInfo> LHESource::runInfoLast [private] |
Definition at line 51 of file LHESource.h.
Referenced by beginRun(), and nextEvent().
boost::ptr_deque<LHERunInfoProduct> LHESource::runInfoProducts [private] |
Definition at line 55 of file LHESource.h.
Referenced by beginRun(), endRun(), and readEvent_().
boost::shared_ptr<edm::RunPrincipal> LHESource::runPrincipal_ [private] |
Definition at line 59 of file LHESource.h.
Referenced by beginRun(), endRun(), and readRun_().
bool LHESource::wasMerged [private] |
Definition at line 56 of file LHESource.h.
Referenced by beginRun(), and readEvent_().