CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DataFormats/FWLite/interface/ChainEvent.h

Go to the documentation of this file.
00001 #ifndef DataFormats_FWLite_ChainEvent_h
00002 #define DataFormats_FWLite_ChainEvent_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     FWLite
00006 // Class  :     ChainEvent
00007 //
00016 //
00017 // Original Author:  Chris Jones
00018 //         Created:  Tue May  8 15:01:20 EDT 2007
00019 //
00020 #if !defined(__CINT__) && !defined(__MAKECINT__)
00021 // system include files
00022 #include <string>
00023 #include <typeinfo>
00024 #include <vector>
00025 #include "boost/shared_ptr.hpp"
00026 
00027 // user include files
00028 #include "DataFormats/FWLite/interface/Event.h"
00029 #include "DataFormats/FWLite/interface/EventBase.h"
00030 
00031 // forward declarations
00032 namespace edm {
00033   class WrapperHolder;
00034   class ProductRegistry;
00035   class ProcessHistory;
00036   class BranchDescription;
00037   class EDProductGetter;
00038   class EventAux;
00039   class TriggerResults;
00040   class TriggerNames;
00041   class TriggerResultsByName;
00042 }
00043 
00044 namespace fwlite {
00045 
00046    class ChainEvent : public EventBase
00047 {
00048 
00049    public:
00050 
00051       ChainEvent(std::vector<std::string> const& iFileNames);
00052       virtual ~ChainEvent();
00053 
00054       ChainEvent const& operator++();
00055 
00057       bool to(Long64_t iIndex);
00058 
00059       // If lumi is non-zero, go to event by Run, Lumi and Event number
00060       // If lumi is 0, go to event by Run and Event number only.
00061       bool to(const edm::EventID &id);
00062       bool to(edm::RunNumber_t run, edm::EventNumber_t event);
00063       bool to(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
00064 
00065       // Go to the very first Event.
00066       ChainEvent const& toBegin();
00067 
00068       // ---------- const member functions ---------------------
00069       virtual std::string const getBranchNameFor(std::type_info const&,
00070                                                  char const*,
00071                                                  char const*,
00072                                                  char const*) const;
00073 
00074       // This function should only be called by fwlite::Handle<>
00075       virtual bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const;
00076       virtual bool getByLabel(std::type_info const&, char const*, char const*, char const*, edm::WrapperHolder&) const;
00077       //void getByBranchName(std::type_info const&, char const*, void*&) const;
00078 
00079       bool isValid() const;
00080       operator bool() const;
00081       virtual bool atEnd() const;
00082 
00083       Long64_t size() const;
00084 
00085       virtual edm::EventAuxiliary const& eventAuxiliary() const;
00086 
00087       std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
00088       std::vector<std::string> const& getProcessHistory() const;
00089       virtual edm::ProcessHistory const& processHistory() const;
00090       TFile* getTFile() const {
00091         return event_->getTFile();
00092       }
00093 
00094       Long64_t eventIndex() const { return eventIndex_; }
00095       virtual Long64_t fileIndex() const { return eventIndex_; }
00096 
00097       void setGetter(boost::shared_ptr<edm::EDProductGetter> getter){
00098          event_->setGetter(getter);
00099       }
00100 
00101       Event const* event() const { return &*event_; }
00102 
00103       virtual edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const;
00104       void fillParameterSetRegistry() const;
00105       virtual edm::TriggerResultsByName triggerResultsByName(std::string const& process) const;
00106 
00107       // ---------- static member functions --------------------
00108       static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
00109 
00110       // ---------- member functions ---------------------------
00111 
00112       edm::WrapperHolder getByProductID(edm::ProductID const&) const;
00113       fwlite::LuminosityBlock const& getLuminosityBlock();
00114       fwlite::Run             const& getRun();
00115 
00116    private:
00117 
00118       friend class MultiChainEvent;
00119 
00120       ChainEvent(Event const&); // stop default
00121 
00122       ChainEvent const& operator=(Event const&); // stop default
00123 
00124       void findSizes();
00125       void switchToFile(Long64_t);
00126       // ---------- member data --------------------------------
00127       std::vector<std::string> fileNames_;
00128       boost::shared_ptr<TFile> file_;
00129       boost::shared_ptr<Event> event_;
00130       Long64_t eventIndex_;
00131       std::vector<Long64_t> accumulatedSize_;
00132       boost::shared_ptr<edm::EDProductGetter> getter_;
00133 
00134 };
00135 
00136 }
00137 #endif /*__CINT__ */
00138 #endif