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
 
template<class T >
bool getByLabel (const edm::InputTag &tag, edm::Handle< T > &handle) const
 
bool getByLabel (const std::type_info &iInfo, const char *iModuleLabel, const char *iProductInstanceLabel, const char *iProcessLabel, void *oData) const override
 
TH1 * hist (const char *name)
 
TH1 * hist (const std::string &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
 
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 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.

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 }

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.

◆ ~EventContainer()

EventContainer::~EventContainer ( )
override

Definition at line 59 of file EventContainer.cc.

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 }

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

◆ 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.

76 { m_histStore.add(histPtr, directory); }

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

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

◆ atEnd()

bool EventContainer::atEnd ( ) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 124 of file EventContainer.cc.

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 }

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

Referenced by main().

◆ eventAuxiliary()

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

Implements edm::EventBase.

Definition at line 103 of file EventContainer.h.

103 { return m_eventBasePtr->eventAuxiliary(); }

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

Referenced by main().

◆ eventsSeen()

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

Definition at line 54 of file EventContainer.h.

54 { return m_eventsSeen; }

References m_eventsSeen.

◆ fileIndex()

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

Reimplemented from fwlite::EventBase.

Definition at line 100 of file EventContainer.h.

100 { return m_eventBasePtr->fileIndex(); }

References fwlite::EventBase::fileIndex(), and 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.

97  {
99  return m_eventBasePtr->getBranchNameFor(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel);
100 }

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

◆ getByLabel() [1/2]

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

◆ getByLabel() [2/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.

89  {
91  return m_eventBasePtr->getByLabel(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel, oData);
92 }

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

Referenced by main().

◆ hist() [1/3]

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

Definition at line 66 of file EventContainer.h.

66 { return hist((const std::string)name); }

References hist(), Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by hist().

◆ hist() [2/3]

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

Referenced by main().

◆ hist() [3/3]

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

Definition at line 67 of file EventContainer.h.

67 { return hist((const char*)name); }

References hist(), and Skims_PA_cff::name.

Referenced by hist().

◆ operator++()

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

Implements fwlite::EventBase.

Definition at line 102 of file EventContainer.cc.

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 }

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

◆ parser()

optutl::CommandLineParser & EventContainer::parser ( )

Definition at line 78 of file EventContainer.cc.

78  {
80  return *m_parserPtr;
81 }

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

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

◆ secondaryFileIndex()

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

Reimplemented from fwlite::EventBase.

Definition at line 101 of file EventContainer.h.

101 { return m_eventBasePtr->secondaryFileIndex(); }

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

◆ toBegin()

const EventContainer & EventContainer::toBegin ( )
overridevirtual

Implements fwlite::EventBase.

Definition at line 113 of file EventContainer.cc.

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 }

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

Referenced by main().

◆ triggerNames()

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

Implements edm::EventBase.

Definition at line 92 of file EventContainer.h.

92  {
94  }

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

◆ triggerResultsByName()

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

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

edm::EventBase::triggerResultsByName
virtual TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const =0
optutl::VariableMapCont::stringValue
std::string & stringValue(std::string key)
Definition: VariableMapCont.cc:163
fwlite::EventContainer::m_maxWanted
int m_maxWanted
Definition: EventContainer.h:129
optutl::VariableMapCont::kStringVector
Definition: VariableMapCont.h:69
optutl::VariableMapCont::hasOption
OptionType hasOption(std::string key)
Definition: VariableMapCont.h:100
patZpeak.handle
handle
Definition: patZpeak.py:23
gather_cfg.cout
cout
Definition: gather_cfg.py:144
fwlite::EventBase::secondaryFileIndex
virtual Long64_t secondaryFileIndex() const
Definition: EventBase.h:57
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
cms::cuda::assert
assert(be >=bs)
edm::EventBase::triggerNames
virtual TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const =0
fwlite::MultiChainEvent
Definition: MultiChainEvent.h:50
fwlite::EventBase::toBegin
virtual EventBase const & toBegin()=0
fwlite::EventBase::fileIndex
virtual Long64_t fileIndex() const
Definition: EventBase.h:56
fwlite::EventContainer::m_outputName
std::string m_outputName
Definition: EventContainer.h:127
optutl::CommandLineParser::argVec
const SVec argVec() const
Definition: CommandLineParser.h:46
fwlite::EventContainer::m_eventsSeen
int m_eventsSeen
Definition: EventContainer.h:128
fwlite::EventContainer::sm_autoloaderCalled
static bool sm_autoloaderCalled
Definition: EventContainer.h:137
fwlite::EventBase::getByLabel
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
fwlite::EventContainer::m_eventBasePtr
fwlite::EventBase * m_eventBasePtr
Definition: EventContainer.h:125
edm::EventBase::eventAuxiliary
virtual edm::EventAuxiliary const & eventAuxiliary() const =0
fwlite::EventContainer::m_outputEvery
int m_outputEvery
Definition: EventContainer.h:130
FWLiteEnabler::enable
static void enable()
enable automatic library loading
Definition: FWLiteEnabler.cc:46
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
fwlite::EventBase::getBranchNameFor
virtual const std::string getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const =0
optutl::CommandLineParser::_finishDefaultOptions
void _finishDefaultOptions(std::string tag="")
Definition: CommandLineParser.cc:583
fwlite::EventContainer::parser
optutl::CommandLineParser & parser()
Definition: EventContainer.cc:78
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fwlite::EventBase::atEnd
virtual bool atEnd() const =0
fwlite::EventContainer::m_parserPtr
optutl::CommandLineParser * m_parserPtr
Definition: EventContainer.h:131
TH1Store::write
void write(const std::string &filename, const SVec &argsVec=kEmptyVec, const SVec &inputFilesVec=kEmptyVec) const
optutl::VariableMapCont::SVec
std::vector< std::string > SVec
Definition: VariableMapCont.h:21
createBeamHaloJobs.directory
string directory
Definition: createBeamHaloJobs.py:211
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
optutl::VariableMapCont::stringVector
SVec & stringVector(std::string key)
Definition: VariableMapCont.cc:203
TH1Store::add
void add(TH1 *histPtr, const std::string &directory="")
Definition: TH1Store.cc:30
fwlite::EventContainer::hist
TH1 * hist(const std::string &name)
fwlite::EventContainer::m_histStore
TH1Store m_histStore
Definition: EventContainer.h:126
optutl::VariableMapCont::integerValue
int & integerValue(std::string key)
Definition: VariableMapCont.cc:143
fwlite::ChainEvent
Definition: ChainEvent.h:46
optutl::VariableMapCont::boolValue
bool & boolValue(std::string key)
Definition: VariableMapCont.cc:173
optutl::CommandLineParser
Definition: CommandLineParser.h:10