CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
LHESource Class Reference

#include <LHESource.h>

Inheritance diagram for LHESource:
edm::ProducerSourceFromFiles edm::ProducerSourceBase edm::FromFiles edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 LHESource (const edm::ParameterSet &params, const edm::InputSourceDescription &desc)
 
virtual ~LHESource ()
 
- Public Member Functions inherited from edm::ProducerSourceFromFiles
virtual bool noFiles () const override
 
 ProducerSourceFromFiles (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
virtual ~ProducerSourceFromFiles ()
 
- Public Member Functions inherited from edm::ProducerSourceBase
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
EventID const & eventID () const
 
LuminosityBlockNumber_t luminosityBlock () const
 
unsigned int numberEventsInLumi () const
 
unsigned int numberEventsInRun () const
 
unsigned int numberEventsInThisLumi () const
 
unsigned int numberEventsInThisRun () const
 
TimeValue_t presentTime () const
 
 ProducerSourceBase (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
virtual ~ProducerSourceBase ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
boost::shared_ptr
< BranchIDListHelper
branchIDListHelper () const
 Accessor for branchIDListHelper. More...
 
void closeFile (FileBlock *, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp, bool cleaningUpAfterException)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp, bool cleaningUpAfterException)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
 InputSource (InputSource const &)=delete
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
InputSourceoperator= (InputSource const &)=delete
 
bool primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
boost::shared_ptr
< LuminosityBlockPrincipal
readAndCacheLumi (HistoryAppender &historyAppender)
 Read next luminosity block (new lumi) More...
 
boost::shared_ptr< RunPrincipalreadAndCacheRun (HistoryAppender &historyAppender)
 Read next run (new run) More...
 
void readAndMergeLumi (boost::shared_ptr< LuminosityBlockPrincipal > lbp)
 Read next luminosity block (same as a prior lumi) More...
 
void readAndMergeRun (boost::shared_ptr< RunPrincipal > rp)
 Read next run (same as a prior run) More...
 
EventPrincipalreadEvent (EventPrincipal &ep)
 
EventPrincipalreadEvent (EventPrincipal &ep, EventID const &)
 Read a specific event. More...
 
std::unique_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
bool skipForForking ()
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

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::EventPrincipalreadEvent_ (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::LHEEventpartonLevel
 
edm::ProcessHistoryID phid_
 
std::auto_ptr< lhef::LHEReaderreader
 
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
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ProducerSourceFromFiles
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::ProducerSourceBase
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
bool eventCached () const
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
bool newLumi () const
 
bool newRun () const
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetEventCached ()
 
void resetLuminosityBlockAuxiliary (bool isNewLumi=true) const
 
void resetNewLumi ()
 
void resetNewRun ()
 
void resetRunAuxiliary (bool isNewRun=true) const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setEventCached ()
 Called by the framework to merge or ached() const {return eventCached_;}. More...
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setNewLumi ()
 
void setNewRun ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Detailed Description

Definition at line 31 of file LHESource.h.

Constructor & Destructor Documentation

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.

34  :
35  ProducerSourceFromFiles(params, desc, false),
36  reader(new LHEReader(fileNames(), params.getUntrackedParameter<unsigned int>("skipEvents", 0))),
37  wasMerged(false),
39  phid_(),
41 {
42  nextEvent();
44  // Initialize metadata, and save the process history ID for use every event.
46 
47  // These calls are not wanted, because the principals are used for putting the products.
48  //produces<LHEEventProduct>();
49  //produces<LHERunInfoProduct, edm::InRun>();
50 }
T getUntrackedParameter(std::string const &, T const &) const
boost::shared_ptr< lhef::LHERunInfo > runInfo
Definition: LHESource.h:52
edm::ProcessHistoryID phid_
Definition: LHESource.h:58
edm::LHEProvenanceHelper lheProvenanceHelper_
Definition: LHESource.h:57
boost::shared_ptr< edm::RunPrincipal > runPrincipal_
Definition: LHESource.h:59
ProducerSourceFromFiles(ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
std::vector< std::string > const & fileNames() const
Definition: FromFiles.h:22
void nextEvent()
Definition: LHESource.cc:61
bool wasMerged
Definition: LHESource.h:56
ProductRegistry & productRegistryUpdate() const
Definition: InputSource.h:316
ProcessHistoryID lheInit(ProductRegistry &productRegistry)
std::auto_ptr< lhef::LHEReader > reader
Definition: LHESource.h:49
void lheAugment(lhef::LHERunInfo const *runInfo)
LHESource::~LHESource ( )
virtual

Definition at line 52 of file LHESource.cc.

53 {
54 }

Member Function Documentation

void LHESource::beginRun ( edm::Run run)
overrideprivatevirtual

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.

99 {
100  if (runInfoLast) {
102 
103  std::auto_ptr<LHERunInfoProduct> product(
104  new LHERunInfoProduct(*runInfo->getHEPRUP()));
105  std::for_each(runInfo->getHeaders().begin(),
106  runInfo->getHeaders().end(),
107  boost::bind(
109  product.get(), _1));
110  std::for_each(runInfo->getComments().begin(),
111  runInfo->getComments().end(),
112  boost::bind(&LHERunInfoProduct::addComment,
113  product.get(), _1));
114 
115  // keep a copy around in case of merging
116  runInfoProducts.push_back(new LHERunInfoProduct(*product));
117  wasMerged = false;
118 
121 
122  runInfo.reset();
123  }
124 }
boost::shared_ptr< lhef::LHERunInfo > runInfo
Definition: LHESource.h:52
void addHeader(const Header &header)
edm::LHEProvenanceHelper lheProvenanceHelper_
Definition: LHESource.h:57
boost::shared_ptr< edm::RunPrincipal > runPrincipal_
Definition: LHESource.h:59
boost::shared_ptr< lhef::LHERunInfo > runInfoLast
Definition: LHESource.h:51
void addComment(const std::string &line)
bool wasMerged
Definition: LHESource.h:56
boost::ptr_deque< LHERunInfoProduct > runInfoProducts
Definition: LHESource.h:55
ConstBranchDescription runProductBranchDescription_
void LHESource::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::InputSource.

Definition at line 56 of file LHESource.cc.

References reader.

57 {
58  reader.reset();
59 }
std::auto_ptr< lhef::LHEReader > reader
Definition: LHESource.h:49
void LHESource::endRun ( edm::Run run)
overrideprivatevirtual

Reimplemented from edm::ProducerSourceBase.

Definition at line 126 of file LHESource.cc.

References lheProvenanceHelper_, runInfoProducts, runPrincipal_, and edm::LHEProvenanceHelper::runProductBranchDescription_.

127 {
128  if (!runInfoProducts.empty()) {
129  std::auto_ptr<LHERunInfoProduct> product(
130  runInfoProducts.pop_front().release());
133  }
134  runPrincipal_.reset();
135 }
edm::LHEProvenanceHelper lheProvenanceHelper_
Definition: LHESource.h:57
boost::shared_ptr< edm::RunPrincipal > runPrincipal_
Definition: LHESource.h:59
boost::ptr_deque< LHERunInfoProduct > runInfoProducts
Definition: LHESource.h:55
ConstBranchDescription runProductBranchDescription_
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().

62 {
63  if (partonLevel) {
64  return;
65  }
66 
67  bool newFileOpened = false;
68  partonLevel = reader->next(&newFileOpened);
69 
70  if(newFileOpened) incrementFileIndex();
71  if (!partonLevel) {
72  return;
73  }
74 
75  boost::shared_ptr<LHERunInfo> runInfoThis = partonLevel->getRunInfo();
76  if (runInfoThis != runInfoLast) {
77  runInfo = runInfoThis;
78  runInfoLast = runInfoThis;
79  }
80 }
boost::shared_ptr< lhef::LHERunInfo > runInfo
Definition: LHESource.h:52
void incrementFileIndex()
Definition: FromFiles.h:27
boost::shared_ptr< lhef::LHEEvent > partonLevel
Definition: LHESource.h:53
boost::shared_ptr< lhef::LHERunInfo > runInfoLast
Definition: LHESource.h:51
std::auto_ptr< lhef::LHEReader > reader
Definition: LHESource.h:49
virtual void LHESource::produce ( edm::Event )
inlineprivatevirtual

Implements edm::ProducerSourceBase.

Definition at line 45 of file LHESource.h.

45 {}
edm::EventPrincipal * LHESource::readEvent_ ( edm::EventPrincipal eventPrincipal)
overrideprivatevirtual

Reimplemented from edm::ProducerSourceBase.

Definition at line 147 of file LHESource.cc.

References LHEEventProduct::addComment(), LHERunInfoProduct::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.

147  {
149  EventSourceSentry sentry(*this);
151  aux.setProcessHistoryID(phid_);
152  eventPrincipal.fillEventPrincipal(aux);
153 
154  std::auto_ptr<LHEEventProduct> product(
155  new LHEEventProduct(*partonLevel->getHEPEUP(),
156  partonLevel->originalXWGTUP())
157  );
158  if (partonLevel->getPDF()) {
159  product->setPDF(*partonLevel->getPDF());
160  }
161  std::for_each(partonLevel->weights().begin(),
162  partonLevel->weights().end(),
163  boost::bind(&LHEEventProduct::addWeight,
164  product.get(), _1));
165  std::for_each(partonLevel->getComments().begin(),
166  partonLevel->getComments().end(),
167  boost::bind(&LHEEventProduct::addComment,
168  product.get(), _1));
169 
172 
173  if (runInfo) {
174  std::auto_ptr<LHERunInfoProduct> product(
175  new LHERunInfoProduct(*runInfo->getHEPRUP()));
176  std::for_each(runInfo->getHeaders().begin(),
177  runInfo->getHeaders().end(),
178  boost::bind(
180  product.get(), _1));
181  std::for_each(runInfo->getComments().begin(),
182  runInfo->getComments().end(),
183  boost::bind(&LHERunInfoProduct::addComment,
184  product.get(), _1));
185 
186  if (!runInfoProducts.empty()) {
187  runInfoProducts.front().mergeProduct(*product);
188  if (!wasMerged) {
189  runInfoProducts.pop_front();
190  runInfoProducts.push_front(product);
191  wasMerged = true;
192  }
193  }
194 
195  runInfo.reset();
196  }
197 
198  partonLevel.reset();
199 
201  return &eventPrincipal;
202 }
void fillEventPrincipal(EventAuxiliary const &aux, boost::shared_ptr< EventSelectionIDVector > eventSelectionIDs=boost::shared_ptr< EventSelectionIDVector >(), boost::shared_ptr< BranchListIndexes > branchListIndexes=boost::shared_ptr< BranchListIndexes >(), boost::shared_ptr< BranchMapper > mapper=boost::shared_ptr< BranchMapper >(new BranchMapper), DelayedReader *reader=0)
boost::shared_ptr< lhef::LHERunInfo > runInfo
Definition: LHESource.h:52
void addHeader(const Header &header)
void addComment(const std::string &line)
edm::ProcessHistoryID phid_
Definition: LHESource.h:58
edm::LHEProvenanceHelper lheProvenanceHelper_
Definition: LHESource.h:57
void addWeight(const WGT &wgt)
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:238
boost::shared_ptr< lhef::LHEEvent > partonLevel
Definition: LHESource.h:53
void put(ConstBranchDescription const &bd, WrapperOwningHolder const &edp, ProductProvenance const &productProvenance)
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:199
void resetEventCached()
Definition: InputSource.h:350
void addComment(const std::string &line)
bool wasMerged
Definition: LHESource.h:56
TimeValue_t presentTime() const
ConstBranchDescription eventProductBranchDescription_
EventID const & eventID() const
ProductProvenance eventProductProvenance_
boost::ptr_deque< LHERunInfoProduct > runInfoProducts
Definition: LHESource.h:55
bool eventCached() const
Definition: InputSource.h:347
boost::shared_ptr< edm::LuminosityBlockPrincipal > LHESource::readLuminosityBlock_ ( boost::shared_ptr< edm::LuminosityBlockPrincipal lumiPrincipal)
overrideprivatevirtual

Reimplemented from edm::InputSource.

Definition at line 92 of file LHESource.cc.

References edm::InputSource::luminosityBlockAuxiliary(), and phid_.

92  {
93  luminosityBlockAuxiliary()->setProcessHistoryID(phid_);
94  lumiPrincipal->fillLuminosityBlockPrincipal();
95  return lumiPrincipal;
96 }
edm::ProcessHistoryID phid_
Definition: LHESource.h:58
boost::shared_ptr< LuminosityBlockAuxiliary > luminosityBlockAuxiliary() const
Called by the framework to merge or insert lumi in principal cache.
Definition: InputSource.h:247
boost::shared_ptr< edm::RunPrincipal > LHESource::readRun_ ( boost::shared_ptr< edm::RunPrincipal runPrincipal)
overrideprivatevirtual

Reimplemented from edm::InputSource.

Definition at line 84 of file LHESource.cc.

References phid_, edm::InputSource::runAuxiliary(), edm::InputSource::runPrincipal(), and runPrincipal_.

84  {
85  runAuxiliary()->setProcessHistoryID(phid_);
86  runPrincipal->fillRunPrincipal();
88  return runPrincipal;
89 }
edm::ProcessHistoryID phid_
Definition: LHESource.h:58
boost::shared_ptr< edm::RunPrincipal > runPrincipal_
Definition: LHESource.h:59
boost::shared_ptr< RunAuxiliary > runAuxiliary() const
Called by the framework to merge or insert run in principal cache.
Definition: InputSource.h:244
boost::shared_ptr< RunPrincipal > const runPrincipal() const
bool LHESource::setRunAndEventInfo ( edm::EventID ,
edm::TimeValue_t  
)
overrideprivatevirtual

Implements edm::ProducerSourceBase.

Definition at line 137 of file LHESource.cc.

References nextEvent(), and partonLevel.

138 {
139  nextEvent();
140  if (!partonLevel) {
141  return false;
142  }
143  return true;
144 }
boost::shared_ptr< lhef::LHEEvent > partonLevel
Definition: LHESource.h:53
void nextEvent()
Definition: LHESource.cc:61

Member Data Documentation

edm::LHEProvenanceHelper LHESource::lheProvenanceHelper_
private

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_().