CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
fwlite::EventContainer Class Reference

#include <EventContainer.h>

Inheritance diagram for fwlite::EventContainer:
fwlite::EventBase edm::EventBase

Public Types

typedef void(* FuncPtr) (std::string &)
 
typedef std::map< std::string, std::string > SSMap
 

Public Member Functions

void add (TH1 *histPtr, const std::string &directory="")
 
bool atEnd () const override
 
edm::EventAuxiliary const & eventAuxiliary () const override
 
 EventContainer (optutl::CommandLineParser &parser, FuncPtr funcPtr=nullptr)
 
int eventsSeen () const
 
Long64_t fileIndex () const override
 
const std::string getBranchNameFor (const std::type_info &iInfo, const char *iModuleLabel, const char *iProductInstanceLabel, const char *iProcessLabel) const override
 
bool getByLabel (const std::type_info &iInfo, const char *iModuleLabel, const char *iProductInstanceLabel, const char *iProcessLabel, void *oData) const override
 
template<class T >
bool getByLabel (const edm::InputTag &tag, edm::Handle< T > &handle) const
 
TH1 * hist (const std::string &name)
 
TH1 * hist (const char *name)
 
TH1 * hist (const TString &name)
 
const EventContaineroperator++ () override
 
optutl::CommandLineParserparser ()
 
Long64_t secondaryFileIndex () const override
 
const EventContainertoBegin () override
 
edm::TriggerNames const & triggerNames (edm::TriggerResults const &triggerResults) const override
 
edm::TriggerResultsByName triggerResultsByName (edm::TriggerResults const &triggerResults) const override
 
 ~EventContainer () override
 
- Public Member Functions inherited from fwlite::EventBase
 EventBase ()
 
virtual edm::WrapperBase const * getByProductID (edm::ProductID const &) const =0
 
 ~EventBase () override
 
- Public Member Functions inherited from edm::EventBase
int bunchCrossing () const
 
 EventBase ()
 
edm::EventAuxiliary::ExperimentType experimentType () const
 
template<typename T >
bool get (ProductID const &, Handle< T > &) const
 
template<>
bool getByLabel (edm::InputTag const &tag, Handle< FWGenericObject > &result) const
 Specialize the getByLabel method to work with a Handle<FWGenericObject> More...
 
template<typename T >
bool getByLabel (InputTag const &, Handle< T > &) const
 
template<typename T >
bool getByToken (edm::EDGetTokenT< T > const &token, edm::Handle< T > &result) const
 
edm::EventID id () const
 
bool isRealData () const
 
edm::LuminosityBlockNumber_t luminosityBlock () const
 
int orbitNumber () const
 
virtual edm::ParameterSet const * parameterSet (edm::ParameterSetID const &psID) const =0
 
virtual ProcessHistory const & processHistory () const =0
 
edm::Timestamp time () const
 

Private Member Functions

 EventContainer (const EventContainer &rhs)
 

Private Attributes

fwlite::EventBasem_eventBasePtr
 
int m_eventsSeen
 
TH1Store m_histStore
 
int m_maxWanted
 
int m_outputEvery
 
std::string m_outputName
 
optutl::CommandLineParserm_parserPtr
 

Static Private Attributes

static bool sm_autoloaderCalled = false
 

Friends

std::ostream & operator<< (std::ostream &o_stream, const EventContainer &rhs)
 

Additional Inherited Members

- Static Protected Member Functions inherited from fwlite::EventBase
template<typename T >
static edm::EDGetTokenT< TmakeTokenUsing (unsigned int iIndex)
 
- Static Protected Member Functions inherited from edm::EventBase
static edm::ParameterSet const * parameterSetForID_ (edm::ParameterSetID const &psID)
 
static TriggerNames const * triggerNames_ (edm::TriggerResults const &triggerResults)
 

Detailed Description

Definition at line 21 of file EventContainer.h.

Member Typedef Documentation

◆ FuncPtr

typedef void(* fwlite::EventContainer::FuncPtr) (std::string &)

Definition at line 28 of file EventContainer.h.

◆ SSMap

typedef std::map<std::string, std::string> fwlite::EventContainer::SSMap

Definition at line 27 of file EventContainer.h.

Constructor & Destructor Documentation

◆ EventContainer() [1/2]

EventContainer::EventContainer ( optutl::CommandLineParser parser,
FuncPtr  funcPtr = nullptr 
)

Definition at line 23 of file EventContainer.cc.

References optutl::CommandLineParser::_finishDefaultOptions(), optutl::VariableMapCont::boolValue(), FWLiteEnabler::enable(), optutl::VariableMapCont::integerValue(), m_eventBasePtr, m_maxWanted, m_outputEvery, m_outputName, m_parserPtr, parser(), sm_autoloaderCalled, optutl::VariableMapCont::stringValue(), optutl::VariableMapCont::stringVector(), and makeGlobalPositionRcd_cfg::tag.

24  : m_eventsSeen(0), m_maxWanted(0), m_parserPtr(nullptr) {
25  // get the user-defined tag
26  string tag;
27  if (funcPtr) {
28  (*funcPtr)(tag);
29  }
30 
31  // finish defaultt options and create fwlite::Event
33 
34  // Call the autoloader if not already called.
35  if (!sm_autoloaderCalled) {
37  sm_autoloaderCalled = true;
38  }
39 
40  const optutl::CommandLineParser::SVec& secondaryInputFiles = parser.stringVector("secondaryInputFiles");
41  if (!secondaryInputFiles.empty()) {
43  parser.stringVector("inputFiles"), secondaryInputFiles, parser.boolValue("orderedSecondaryFiles"));
44  } else {
46  }
47 
48  // get whatever other info you want
49  m_outputName = parser.stringValue("outputFile");
50  m_maxWanted = parser.integerValue("maxEvents");
51  m_outputEvery = parser.integerValue("outputEvery");
52 
53  // remember my parser
55 
56  // TH1::AddDirectory(false);
57 }
void _finishDefaultOptions(std::string tag="")
std::string & stringValue(std::string key)
static bool sm_autoloaderCalled
std::vector< std::string > SVec
int & integerValue(std::string key)
fwlite::EventBase * m_eventBasePtr
static void enable()
enable automatic library loading
optutl::CommandLineParser * m_parserPtr
SVec & stringVector(std::string key)
bool & boolValue(std::string key)
optutl::CommandLineParser & parser()

◆ ~EventContainer()

EventContainer::~EventContainer ( )
override

Definition at line 59 of file EventContainer.cc.

References optutl::CommandLineParser::argVec(), gather_cfg::cout, optutl::VariableMapCont::hasOption(), optutl::VariableMapCont::kStringVector, m_eventBasePtr, m_eventsSeen, m_histStore, m_outputName, parser(), optutl::VariableMapCont::stringVector(), and TH1Store::write().

59  {
60  // if the pointer is non-zero, then we should run the standard
61  // destructor. If it is zero, then we should do nothing
62  if (!m_eventBasePtr) {
63  return;
64  }
65  // If we're still here, let's get to work.
66  cout << "EventContainer Summary: Processed " << m_eventsSeen << " events." << endl;
68  if (optutl::CommandLineParser::kStringVector == parser.hasOption("inputFiles")) {
70  } else {
72  }
73  delete m_eventBasePtr;
74 }
fwlite::EventBase * m_eventBasePtr
void write(const std::string &filename, const SVec &argsVec=kEmptyVec, const SVec &inputFilesVec=kEmptyVec) const
SVec & stringVector(std::string key)
const SVec argVec() const
optutl::CommandLineParser & parser()
OptionType hasOption(std::string key)

◆ EventContainer() [2/2]

fwlite::EventContainer::EventContainer ( const EventContainer rhs)
inlineprivate

Definition at line 119 of file EventContainer.h.

119 {}

Member Function Documentation

◆ add()

void EventContainer::add ( TH1 *  histPtr,
const std::string &  directory = "" 
)

Definition at line 76 of file EventContainer.cc.

References TH1Store::add(), createBeamHaloJobs::directory, and m_histStore.

Referenced by bookHistograms(), main(), and counter.Counter::register().

76 { m_histStore.add(histPtr, directory); }
void add(TH1 *histPtr, const std::string &directory="")
Definition: TH1Store.cc:30

◆ atEnd()

bool EventContainer::atEnd ( ) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 124 of file EventContainer.cc.

References cms::cuda::assert(), fwlite::EventBase::atEnd(), m_eventBasePtr, m_eventsSeen, and m_maxWanted.

Referenced by main().

124  {
126  // first check to see that we haven't already processed the maxinum
127  // number of events that we asked for.
129  // we're done
130  return true;
131  }
132 
133  return m_eventBasePtr->atEnd();
134 }
assert(be >=bs)
fwlite::EventBase * m_eventBasePtr
virtual bool atEnd() const =0

◆ eventAuxiliary()

edm::EventAuxiliary const& fwlite::EventContainer::eventAuxiliary ( ) const
inlineoverridevirtual

Implements edm::EventBase.

Definition at line 103 of file EventContainer.h.

References edm::EventBase::eventAuxiliary(), and m_eventBasePtr.

Referenced by main().

103 { return m_eventBasePtr->eventAuxiliary(); }
virtual edm::EventAuxiliary const & eventAuxiliary() const =0
fwlite::EventBase * m_eventBasePtr

◆ eventsSeen()

int fwlite::EventContainer::eventsSeen ( ) const
inline

Definition at line 54 of file EventContainer.h.

References m_eventsSeen.

54 { return m_eventsSeen; }

◆ fileIndex()

Long64_t fwlite::EventContainer::fileIndex ( ) const
inlineoverridevirtual

Reimplemented from fwlite::EventBase.

Definition at line 100 of file EventContainer.h.

References fwlite::EventBase::fileIndex(), and m_eventBasePtr.

100 { return m_eventBasePtr->fileIndex(); }
virtual Long64_t fileIndex() const
Definition: EventBase.h:56
fwlite::EventBase * m_eventBasePtr

◆ getBranchNameFor()

const std::string EventContainer::getBranchNameFor ( const std::type_info &  iInfo,
const char *  iModuleLabel,
const char *  iProductInstanceLabel,
const char *  iProcessLabel 
) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 94 of file EventContainer.cc.

References cms::cuda::assert(), fwlite::EventBase::getBranchNameFor(), and m_eventBasePtr.

97  {
99  return m_eventBasePtr->getBranchNameFor(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel);
100 }
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const =0
assert(be >=bs)
fwlite::EventBase * m_eventBasePtr

◆ getByLabel() [1/2]

bool EventContainer::getByLabel ( const std::type_info &  iInfo,
const char *  iModuleLabel,
const char *  iProductInstanceLabel,
const char *  iProcessLabel,
void *  oData 
) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 85 of file EventContainer.cc.

References cms::cuda::assert(), fwlite::EventBase::getByLabel(), and m_eventBasePtr.

Referenced by main().

89  {
91  return m_eventBasePtr->getByLabel(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel, oData);
92 }
assert(be >=bs)
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
fwlite::EventBase * m_eventBasePtr

◆ getByLabel() [2/2]

template<class T >
bool fwlite::EventContainer::getByLabel ( const edm::InputTag tag,
edm::Handle< T > &  handle 
) const
inline

Definition at line 106 of file EventContainer.h.

References fwlite::EventBase::getByLabel(), patZpeak::handle, m_eventBasePtr, and makeGlobalPositionRcd_cfg::tag.

106  {
108  }
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
fwlite::EventBase * m_eventBasePtr

◆ hist() [1/3]

TH1* fwlite::EventContainer::hist ( const std::string &  name)

Referenced by main().

◆ hist() [2/3]

TH1* fwlite::EventContainer::hist ( const char *  name)
inline

◆ hist() [3/3]

TH1* fwlite::EventContainer::hist ( const TString &  name)
inline

Definition at line 67 of file EventContainer.h.

References hist(), and mergeVDriftHistosByStation::name.

Referenced by hist().

67 { return hist((const char*)name); }
TH1 * hist(const std::string &name)

◆ operator++()

const EventContainer & EventContainer::operator++ ( void  )
overridevirtual

Implements fwlite::EventBase.

Definition at line 102 of file EventContainer.cc.

References cms::cuda::assert(), gather_cfg::cout, m_eventBasePtr, m_eventsSeen, and m_outputEvery.

102  {
104 
105  m_eventBasePtr->operator++();
106  ++m_eventsSeen;
107  if (m_outputEvery && m_eventsSeen % m_outputEvery == 0) {
108  cout << "Processing Event: " << m_eventsSeen << endl;
109  }
110  return *this;
111 }
assert(be >=bs)
fwlite::EventBase * m_eventBasePtr

◆ parser()

optutl::CommandLineParser & EventContainer::parser ( )

Definition at line 78 of file EventContainer.cc.

References cms::cuda::assert(), and m_parserPtr.

Referenced by bookHistograms(), calcSampleName(), EventContainer(), and ~EventContainer().

78  {
80  return *m_parserPtr;
81 }
assert(be >=bs)
optutl::CommandLineParser * m_parserPtr

◆ secondaryFileIndex()

Long64_t fwlite::EventContainer::secondaryFileIndex ( ) const
inlineoverridevirtual

Reimplemented from fwlite::EventBase.

Definition at line 101 of file EventContainer.h.

References m_eventBasePtr, and fwlite::EventBase::secondaryFileIndex().

101 { return m_eventBasePtr->secondaryFileIndex(); }
virtual Long64_t secondaryFileIndex() const
Definition: EventBase.h:57
fwlite::EventBase * m_eventBasePtr

◆ toBegin()

const EventContainer & EventContainer::toBegin ( )
overridevirtual

Implements fwlite::EventBase.

Definition at line 113 of file EventContainer.cc.

References cms::cuda::assert(), m_eventBasePtr, m_eventsSeen, and fwlite::EventBase::toBegin().

Referenced by main().

113  {
115  m_eventsSeen = 0;
117 
118  // If we're going to skip over any events, do it here.
119 
120  // O.k. We should be good to go.
121  return *this;
122 }
assert(be >=bs)
fwlite::EventBase * m_eventBasePtr
virtual EventBase const & toBegin()=0

◆ triggerNames()

edm::TriggerNames const& fwlite::EventContainer::triggerNames ( edm::TriggerResults const &  triggerResults) const
inlineoverridevirtual

Implements edm::EventBase.

Definition at line 92 of file EventContainer.h.

References m_eventBasePtr, edm::EventBase::triggerNames(), and triggerResults.

92  {
94  }
fwlite::EventBase * m_eventBasePtr
static std::string const triggerResults
Definition: EdmProvDump.cc:47
virtual TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const =0

◆ triggerResultsByName()

edm::TriggerResultsByName fwlite::EventContainer::triggerResultsByName ( edm::TriggerResults const &  triggerResults) const
inlineoverridevirtual

Implements edm::EventBase.

Definition at line 96 of file EventContainer.h.

References m_eventBasePtr, triggerResults, and edm::EventBase::triggerResultsByName().

96  {
98  }
fwlite::EventBase * m_eventBasePtr
static std::string const triggerResults
Definition: EdmProvDump.cc:47
virtual TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const =0

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o_stream,
const EventContainer rhs 
)
friend

Member Data Documentation

◆ m_eventBasePtr

fwlite::EventBase* fwlite::EventContainer::m_eventBasePtr
private

◆ m_eventsSeen

int fwlite::EventContainer::m_eventsSeen
private

Definition at line 128 of file EventContainer.h.

Referenced by atEnd(), eventsSeen(), operator++(), toBegin(), and ~EventContainer().

◆ m_histStore

TH1Store fwlite::EventContainer::m_histStore
private

Definition at line 126 of file EventContainer.h.

Referenced by add(), and ~EventContainer().

◆ m_maxWanted

int fwlite::EventContainer::m_maxWanted
private

Definition at line 129 of file EventContainer.h.

Referenced by atEnd(), and EventContainer().

◆ m_outputEvery

int fwlite::EventContainer::m_outputEvery
private

Definition at line 130 of file EventContainer.h.

Referenced by EventContainer(), and operator++().

◆ m_outputName

std::string fwlite::EventContainer::m_outputName
private

Definition at line 127 of file EventContainer.h.

Referenced by EventContainer(), and ~EventContainer().

◆ m_parserPtr

optutl::CommandLineParser* fwlite::EventContainer::m_parserPtr
private

Definition at line 131 of file EventContainer.h.

Referenced by EventContainer(), and parser().

◆ sm_autoloaderCalled

bool EventContainer::sm_autoloaderCalled = false
staticprivate

Definition at line 137 of file EventContainer.h.

Referenced by EventContainer().