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=0)
 
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 std::string const getBranchNameFor (std::type_info const &, char const *, char const *, char const *) const =0
 
virtual bool getByLabel (std::type_info const &, char const *, char const *, char const *, void *) const =0
 
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<typename T >
bool getByLabel (InputTag 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...
 
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 22 of file EventContainer.h.

Member Typedef Documentation

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

Definition at line 31 of file EventContainer.h.

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

Definition at line 30 of file EventContainer.h.

Constructor & Destructor Documentation

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

Definition at line 24 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 GlobalPosition_Frontier_DevDB_cff::tag.

25  :
26  m_eventsSeen (0), m_maxWanted (0), m_parserPtr (nullptr)
27 {
28  // get the user-defined tag
29  string tag;
30  if (funcPtr)
31  {
32  (*funcPtr) (tag);
33  }
34 
35  // finish defaultt options and create fwlite::Event
36  parser._finishDefaultOptions (tag);
37 
38  // Call the autoloader if not already called.
39  if (! sm_autoloaderCalled)
40  {
42  sm_autoloaderCalled = true;
43  }
44 
45  const optutl::CommandLineParser::SVec &secondaryInputFiles =
46  parser.stringVector ("secondaryInputFiles");
47  if (!secondaryInputFiles.empty())
48  {
50  new fwlite::MultiChainEvent( parser.stringVector ("inputFiles"),
51  secondaryInputFiles,
52  parser.boolValue("orderedSecondaryFiles") );
53  } else {
55  new fwlite::ChainEvent( parser.stringVector ("inputFiles") );
56  }
57 
58  // get whatever other info you want
59  m_outputName = parser.stringValue ("outputFile");
60  m_maxWanted = parser.integerValue ("maxEvents");
61  m_outputEvery = parser.integerValue ("outputEvery");
62 
63  // remember my parser
65 
66  // TH1::AddDirectory(false);
67 }
void _finishDefaultOptions(std::string tag="")
std::string & stringValue(std::string key)
std::vector< std::string > SVec
static bool sm_autoloaderCalled
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 ( )
override

Definition at line 69 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().

70 {
71  // if the pointer is non-zero, then we should run the standard
72  // destructor. If it is zero, then we should do nothing
73  if (! m_eventBasePtr)
74  {
75  return;
76  }
77  // If we're still here, let's get to work.
78  cout << "EventContainer Summary: Processed "
79  << m_eventsSeen << " events." << endl;
82  parser.hasOption("inputFiles"))
83  {
85  parser.argVec(),
86  parser.stringVector ("inputFiles"));
87  } else {
89  parser.argVec());
90  }
91  delete m_eventBasePtr;
92 }
void write(const std::string &filename, const SVec &argsVec=kEmptyVec, const SVec &inputFilesVec=kEmptyVec) const
fwlite::EventBase * m_eventBasePtr
const SVec argVec() const
SVec & stringVector(std::string key)
optutl::CommandLineParser & parser()
OptionType hasOption(std::string key)
fwlite::EventContainer::EventContainer ( const EventContainer rhs)
inlineprivate

Definition at line 130 of file EventContainer.h.

130 {}

Member Function Documentation

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

Definition at line 95 of file EventContainer.cc.

References TH1Store::add(), and m_histStore.

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

96 {
97  m_histStore.add (histPtr, directory);
98 }
void add(TH1 *histPtr, const std::string &directory="")
Definition: TH1Store.cc:39
bool EventContainer::atEnd ( ) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 169 of file EventContainer.cc.

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

Referenced by hist(), and main().

170 {
171  assert (m_eventBasePtr);
172  // first check to see that we haven't already processed the maxinum
173  // number of events that we asked for.
175  {
176  // we're done
177  return true;
178  }
179 
180  return m_eventBasePtr->atEnd();
181 }
fwlite::EventBase * m_eventBasePtr
virtual bool atEnd() const =0
edm::EventAuxiliary const& fwlite::EventContainer::eventAuxiliary ( ) const
inlineoverridevirtual

Implements edm::EventBase.

Definition at line 111 of file EventContainer.h.

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

Referenced by main().

112  { return m_eventBasePtr->eventAuxiliary(); }
fwlite::EventBase * m_eventBasePtr
virtual edm::EventAuxiliary const & eventAuxiliary() const =0
int fwlite::EventContainer::eventsSeen ( ) const
inline
Long64_t fwlite::EventContainer::fileIndex ( ) const
inlineoverridevirtual

Reimplemented from fwlite::EventBase.

Definition at line 106 of file EventContainer.h.

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

107  { return m_eventBasePtr->fileIndex(); }
virtual Long64_t fileIndex() const
Definition: EventBase.h:66
fwlite::EventBase * m_eventBasePtr
const std::string EventContainer::getBranchNameFor ( const std::type_info &  iInfo,
const char *  iModuleLabel,
const char *  iProductInstanceLabel,
const char *  iProcessLabel 
) const
override

Definition at line 129 of file EventContainer.cc.

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

Referenced by hist().

133 {
134  assert (m_eventBasePtr);
135  return m_eventBasePtr->getBranchNameFor( iInfo,
136  iModuleLabel,
137  iProductInstanceLabel,
138  iProcessLabel );
139 }
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const =0
fwlite::EventBase * m_eventBasePtr
bool EventContainer::getByLabel ( const std::type_info &  iInfo,
const char *  iModuleLabel,
const char *  iProductInstanceLabel,
const char *  iProcessLabel,
void *  oData 
) const
override

Definition at line 114 of file EventContainer.cc.

References fwlite::EventBase::getByLabel(), m_eventBasePtr, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by hist(), and main().

119 {
120  assert (m_eventBasePtr);
121  return m_eventBasePtr->getByLabel( iInfo,
122  iModuleLabel,
123  iProductInstanceLabel,
124  iProcessLabel,
125  oData );
126 }
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
fwlite::EventBase * m_eventBasePtr
template<class T >
bool fwlite::EventContainer::getByLabel ( const edm::InputTag tag,
edm::Handle< T > &  handle 
) const
inline

Definition at line 115 of file EventContainer.h.

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

117  { return m_eventBasePtr->getByLabel (tag, handle); }
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
fwlite::EventBase * m_eventBasePtr
TH1* fwlite::EventContainer::hist ( const std::string &  name)

Referenced by eventsSeen(), hist(), main(), and parser().

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

Definition at line 71 of file EventContainer.h.

References hist(), and AlCaHLTBitMon_QueryRunRegistry::string.

72  { return hist( (const std::string) name); }
TH1 * hist(const std::string &name)
TH1* fwlite::EventContainer::hist ( const TString &  name)
inline

Definition at line 73 of file EventContainer.h.

References atEnd(), getBranchNameFor(), getByLabel(), hist(), operator++(), parser(), AlCaHLTBitMon_QueryRunRegistry::string, and toBegin().

74  { return hist( (const char*) name ); }
TH1 * hist(const std::string &name)
const EventContainer & EventContainer::operator++ ( void  )
overridevirtual

Implements fwlite::EventBase.

Definition at line 142 of file EventContainer.cc.

References gather_cfg::cout, m_eventBasePtr, m_eventsSeen, and m_outputEvery.

Referenced by hist().

143 {
144  assert (m_eventBasePtr);
145 
146  m_eventBasePtr->operator++();
147  ++m_eventsSeen;
148  if (m_outputEvery && m_eventsSeen % m_outputEvery == 0 )
149  {
150  cout << "Processing Event: " << m_eventsSeen << endl;
151  }
152  return *this;
153 }
fwlite::EventBase * m_eventBasePtr
optutl::CommandLineParser & EventContainer::parser ( )

Definition at line 101 of file EventContainer.cc.

References TH1Store::hist(), hist(), m_histStore, m_parserPtr, and dataset::name.

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

102 {
103  assert (m_parserPtr);
104  return *m_parserPtr;
105 }
optutl::CommandLineParser * m_parserPtr
Long64_t fwlite::EventContainer::secondaryFileIndex ( ) const
inlineoverridevirtual

Reimplemented from fwlite::EventBase.

Definition at line 108 of file EventContainer.h.

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

109  { return m_eventBasePtr->secondaryFileIndex(); }
virtual Long64_t secondaryFileIndex() const
Definition: EventBase.h:67
fwlite::EventBase * m_eventBasePtr
const EventContainer & EventContainer::toBegin ( )
overridevirtual

Implements fwlite::EventBase.

Definition at line 156 of file EventContainer.cc.

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

Referenced by hist(), and main().

157 {
158  assert (m_eventBasePtr);
159  m_eventsSeen = 0;
161 
162  // If we're going to skip over any events, do it here.
163 
164  // O.k. We should be good to go.
165  return *this;
166 }
fwlite::EventBase * m_eventBasePtr
virtual EventBase const & toBegin()=0
edm::TriggerNames const& fwlite::EventContainer::triggerNames ( edm::TriggerResults const &  triggerResults) const
inlineoverridevirtual

Implements edm::EventBase.

Definition at line 100 of file EventContainer.h.

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

fwlite::EventBase * m_eventBasePtr
static std::string const triggerResults
Definition: EdmProvDump.cc:41
virtual TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const =0
edm::TriggerResultsByName fwlite::EventContainer::triggerResultsByName ( edm::TriggerResults const &  triggerResults) const
inlineoverridevirtual

Implements edm::EventBase.

Definition at line 103 of file EventContainer.h.

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

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

Friends And Related Function Documentation

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

Member Data Documentation

fwlite::EventBase* fwlite::EventContainer::m_eventBasePtr
private
int fwlite::EventContainer::m_eventsSeen
private

Definition at line 139 of file EventContainer.h.

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

TH1Store fwlite::EventContainer::m_histStore
private

Definition at line 137 of file EventContainer.h.

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

int fwlite::EventContainer::m_maxWanted
private

Definition at line 140 of file EventContainer.h.

Referenced by atEnd(), and EventContainer().

int fwlite::EventContainer::m_outputEvery
private

Definition at line 141 of file EventContainer.h.

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

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

Definition at line 138 of file EventContainer.h.

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

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

Definition at line 142 of file EventContainer.h.

Referenced by EventContainer(), and parser().

bool EventContainer::sm_autoloaderCalled = false
staticprivate

Definition at line 148 of file EventContainer.h.

Referenced by EventContainer().