CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/PhysicsTools/FWLite/interface/EventContainer.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #if !defined(EventContainer_H)
00004 #define EventContainer_H
00005 
00006 #include <map>
00007 #include <string>
00008 #include <typeinfo>
00009 
00010 #include "TH1.h"
00011 #include "TFile.h"
00012 
00013 #include "FWCore/Utilities/interface/InputTag.h"
00014 #include "DataFormats/Common/interface/Handle.h"
00015 #include "PhysicsTools/FWLite/interface/CommandLineParser.h"
00016 #include "DataFormats/FWLite/interface/EventBase.h"
00017 #include "PhysicsTools/FWLite/interface/TH1Store.h"
00018 
00019 namespace fwlite
00020 {
00021 
00022    class EventContainer : public EventBase
00023    {
00024       public:
00025 
00027          // Public Constants //
00029 
00030          typedef std::map< std::string, std::string >   SSMap;
00031          typedef void ( *FuncPtr ) (std::string&);
00032 
00034          // friends //
00036          // tells particle data how to print itself out
00037          friend std::ostream& operator<< (std::ostream& o_stream, 
00038                                           const EventContainer &rhs);
00039 
00041          //            _         //
00042          // |\/|      |_         //
00043          // |  |EMBER | UNCTIONS //
00044          //                      //
00046 
00048          // Constructors and Destructor //
00050          EventContainer (optutl::CommandLineParser &parser, 
00051                          FuncPtr funcPtr = 0);
00052          ~EventContainer();
00053 
00055          // One Liners //
00057 
00058          // return number of events seen
00059          int eventsSeen () const { return m_eventsSeen; }
00060 
00062          // Regular Member Functions //
00064 
00065          // adds a histogram pointer to the map.  You can specify a
00066          // directory as well if you wish.
00067          void add (TH1 *histPtr, const std::string &directory = "");
00068 
00069          // given a string, returns corresponding histogram pointer
00070          TH1* hist (const std::string &name);
00071          TH1* hist (const char* name)
00072          { return hist( (const std::string) name); }
00073          TH1* hist (const TString &name)
00074          { return hist( (const char*) name ); }
00075 
00076          // return this containers parser
00077          optutl::CommandLineParser &parser();
00078 
00080          // Implement the two functions needed to make this an EventBase. //
00082          bool getByLabel (const std::type_info& iInfo,
00083                           const char* iModuleLabel,
00084                           const char* iProductInstanceLabel,
00085                           const char* iProcessLabel,
00086                           void* oData) const;
00087 
00088          const std::string getBranchNameFor (const std::type_info& iInfo,
00089                                              const char* iModuleLabel,
00090                                              const char* iProductInstanceLabel,
00091                                              const char* iProcessLabel) const;
00092 
00093          const EventContainer& operator++();
00094 
00095          const EventContainer& toBegin();
00096 
00097          bool atEnd() const;
00098       
00099          
00100          edm::TriggerNames const&  triggerNames(edm::TriggerResults const& triggerResults) const
00101          { return m_eventBasePtr->triggerNames(triggerResults); }
00102 
00103          edm::TriggerResultsByName triggerResultsByName(std::string const& process) const
00104          { return m_eventBasePtr->triggerResultsByName(process); }
00105 
00106          Long64_t fileIndex()          const 
00107          { return m_eventBasePtr->fileIndex(); }
00108          Long64_t secondaryFileIndex() const 
00109          { return m_eventBasePtr->secondaryFileIndex(); }
00110          
00111          edm::EventAuxiliary const& eventAuxiliary() const
00112          { return m_eventBasePtr->eventAuxiliary(); }
00113 
00114          template <class T>
00115          bool getByLabel (const edm::InputTag &tag, 
00116                           edm::Handle<T> &handle) const
00117          { return m_eventBasePtr->getByLabel (tag, handle); }
00119          // Static Member Functions //
00121 
00122 
00123       private:
00124 
00126          // Private Member Functions //
00128 
00129          // stop the copy constructor
00130          EventContainer (const EventContainer &rhs) {}
00131 
00133          // Private Member Data //
00135 
00136          fwlite::EventBase         *m_eventBasePtr;
00137          TH1Store                   m_histStore;
00138          std::string                m_outputName;
00139          int                        m_eventsSeen;
00140          int                        m_maxWanted;
00141          int                        m_outputEvery;
00142          optutl::CommandLineParser *m_parserPtr;
00143 
00145          // Private Static Member Data //
00147 
00148          static bool sm_autoloaderCalled;
00149 
00150    };
00151 }
00152 
00153 
00154 #endif // EventContainer_H