CMS 3D CMS Logo

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

List of all members.

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
edm::EventAuxiliary const & eventAuxiliary () const
 EventContainer (optutl::CommandLineParser &parser, FuncPtr funcPtr=0)
int eventsSeen () const
Long64_t fileIndex () const
const std::string getBranchNameFor (const std::type_info &iInfo, const char *iModuleLabel, const char *iProductInstanceLabel, const char *iProcessLabel) const
bool getByLabel (const std::type_info &iInfo, const char *iModuleLabel, const char *iProductInstanceLabel, const char *iProcessLabel, void *oData) const
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++ ()
optutl::CommandLineParserparser ()
Long64_t secondaryFileIndex () const
const EventContainertoBegin ()
edm::TriggerNames const & triggerNames (edm::TriggerResults const &triggerResults) const
edm::TriggerResultsByName triggerResultsByName (std::string const &process) const
 ~EventContainer ()

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)

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(), AutoLibraryLoader::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.

                                                 : 
   m_eventsSeen (0), m_maxWanted (0), m_parserPtr (0)
{
   // get the user-defined tag
   string tag;
   if (funcPtr)
   {
      (*funcPtr) (tag);
   }

   // finish defaultt options and create fwlite::Event
   parser._finishDefaultOptions (tag);

   // Call the autoloader if not already called.
   if (! sm_autoloaderCalled)
   {
      AutoLibraryLoader::enable();
      sm_autoloaderCalled = true;      
   }

   const optutl::CommandLineParser::SVec &secondaryInputFiles = 
      parser.stringVector ("secondaryInputFiles");
   if (secondaryInputFiles.size())
   {
      m_eventBasePtr = 
         new fwlite::MultiChainEvent( parser.stringVector ("inputFiles"), 
                                      secondaryInputFiles,
                                      parser.boolValue("orderedSecondaryFiles") );
   } else {
      m_eventBasePtr = 
         new fwlite::ChainEvent( parser.stringVector ("inputFiles") );
   }

   // get whatever other info you want
   m_outputName  = parser.stringValue  ("outputFile");
   m_maxWanted   = parser.integerValue ("maxEvents");
   m_outputEvery = parser.integerValue ("outputEvery");

   // remember my parser
   m_parserPtr = &parser;

   // TH1::AddDirectory(false);
}
EventContainer::~EventContainer ( )

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

{
   // if the pointer is non-zero, then we should run the standard
   // destructor.  If it is zero, then we should do nothing
   if (! m_eventBasePtr)
   {
      return;
   } 
   // If we're still here, let's get to work.
   cout << "EventContainer Summary: Processed "
        << m_eventsSeen << " events." << endl;
   optutl::CommandLineParser &parser = this->parser();
   if (optutl::CommandLineParser::kStringVector == 
       parser.hasOption("inputFiles"))
   {
      m_histStore.write (m_outputName, 
                         parser.argVec(),
                         parser.stringVector ("inputFiles"));
   } else {
      m_histStore.write (m_outputName, 
                         parser.argVec());
   }
   delete m_eventBasePtr;
}
fwlite::EventContainer::EventContainer ( const EventContainer rhs) [inline, private]

Definition at line 130 of file EventContainer.h.

{}

Member Function Documentation

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

Referenced by bookHistograms(), and main().

bool EventContainer::atEnd ( ) const [virtual]

Implements fwlite::EventBase.

Definition at line 169 of file EventContainer.cc.

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

Referenced by main().

{
   assert (m_eventBasePtr);
   // first check to see that we haven't already processed the maxinum
   // number of events that we asked for.
   if (m_maxWanted && m_eventsSeen >= m_maxWanted)
   {
      // we're done
      return true;
   }

   return m_eventBasePtr->atEnd();
}
edm::EventAuxiliary const& fwlite::EventContainer::eventAuxiliary ( ) const [inline, virtual]

Implements edm::EventBase.

Definition at line 111 of file EventContainer.h.

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

Referenced by main().

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

Definition at line 59 of file EventContainer.h.

References m_eventsSeen.

{ return m_eventsSeen; }
Long64_t fwlite::EventContainer::fileIndex ( ) const [inline, virtual]

Reimplemented from fwlite::EventBase.

Definition at line 106 of file EventContainer.h.

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

         { return m_eventBasePtr->fileIndex(); }
const std::string EventContainer::getBranchNameFor ( const std::type_info &  iInfo,
const char *  iModuleLabel,
const char *  iProductInstanceLabel,
const char *  iProcessLabel 
) const [virtual]

Implements fwlite::EventBase.

Definition at line 129 of file EventContainer.cc.

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

{
   assert (m_eventBasePtr);
   return m_eventBasePtr->getBranchNameFor( iInfo,
                                            iModuleLabel,
                                            iProductInstanceLabel,
                                            iProcessLabel );
}
template<class T >
bool fwlite::EventContainer::getByLabel ( const edm::InputTag tag,
edm::Handle< T > &  handle 
) const [inline]

Reimplemented from edm::EventBase.

Definition at line 115 of file EventContainer.h.

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

         { return m_eventBasePtr->getByLabel (tag, handle); }
bool EventContainer::getByLabel ( const std::type_info &  iInfo,
const char *  iModuleLabel,
const char *  iProductInstanceLabel,
const char *  iProcessLabel,
void *  oData 
) const [virtual]

Implements fwlite::EventBase.

Definition at line 114 of file EventContainer.cc.

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

Referenced by main().

{
   assert (m_eventBasePtr);
   return m_eventBasePtr->getByLabel( iInfo, 
                                      iModuleLabel, 
                                      iProductInstanceLabel,
                                      iProcessLabel, 
                                      oData );
}
TH1* fwlite::EventContainer::hist ( const char *  name) [inline]

Definition at line 71 of file EventContainer.h.

References hist().

Referenced by hist().

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

Definition at line 73 of file EventContainer.h.

References hist().

Referenced by hist().

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

Referenced by main().

const EventContainer & EventContainer::operator++ ( void  ) [virtual]

Implements fwlite::EventBase.

Definition at line 142 of file EventContainer.cc.

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

{
   assert (m_eventBasePtr);

   m_eventBasePtr->operator++();
   ++m_eventsSeen;
   if (m_outputEvery && m_eventsSeen % m_outputEvery == 0 ) 
   {
      cout << "Processing Event: " << m_eventsSeen << endl;
   }
   return *this;   
}
optutl::CommandLineParser & EventContainer::parser ( )

Definition at line 101 of file EventContainer.cc.

References m_parserPtr.

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

{
   assert (m_parserPtr);
   return *m_parserPtr;
}
Long64_t fwlite::EventContainer::secondaryFileIndex ( ) const [inline, virtual]

Reimplemented from fwlite::EventBase.

Definition at line 108 of file EventContainer.h.

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

const EventContainer & EventContainer::toBegin ( ) [virtual]

Implements fwlite::EventBase.

Definition at line 156 of file EventContainer.cc.

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

Referenced by main().

{
   assert (m_eventBasePtr);
   m_eventsSeen = 0;
   m_eventBasePtr->toBegin();

   // If we're going to skip over any events, do it here.

   // O.k.  We should be good to go.
   return *this;
}
edm::TriggerNames const& fwlite::EventContainer::triggerNames ( edm::TriggerResults const &  triggerResults) const [inline, virtual]

Implements edm::EventBase.

Definition at line 100 of file EventContainer.h.

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

edm::TriggerResultsByName fwlite::EventContainer::triggerResultsByName ( std::string const &  process) const [inline, virtual]

Friends And Related Function Documentation

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

Member Data Documentation

Definition at line 139 of file EventContainer.h.

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

Definition at line 137 of file EventContainer.h.

Referenced by ~EventContainer().

Definition at line 140 of file EventContainer.h.

Referenced by atEnd(), and EventContainer().

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

Definition at line 142 of file EventContainer.h.

Referenced by EventContainer(), and parser().

bool EventContainer::sm_autoloaderCalled = false [static, private]

Definition at line 148 of file EventContainer.h.

Referenced by EventContainer().