CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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 EDProduct;
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(const std::vector<std::string>& iFileNames);
00052       virtual ~ChainEvent();
00053 
00054       const ChainEvent& 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       const ChainEvent& toBegin();
00067 
00068       // ---------- const member functions ---------------------
00069       virtual const std::string getBranchNameFor(const std::type_info&,
00070                                                  const char*,
00071                                                  const char*,
00072                                                  const char*) const;
00073 
00074       // This function should only be called by fwlite::Handle<>
00075       virtual bool getByLabel(const std::type_info&, const char*,
00076                               const char*, const char*, void*) const;
00077       //void getByBranchName(const std::type_info&, const char*, 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       const std::vector<edm::BranchDescription>& getBranchDescriptions() const;
00088       const std::vector<std::string>& getProcessHistory() const;
00089       edm::ProcessHistory const& processHistory() const;
00090 
00091       TFile* getTFile() const {
00092         return event_->getTFile();
00093       }
00094 
00095       Long64_t eventIndex() const { return eventIndex_; }
00096       virtual Long64_t fileIndex() const { return eventIndex_; }
00097 
00098       void setGetter( boost::shared_ptr<edm::EDProductGetter> getter ){
00099          event_->setGetter( getter );
00100       }
00101 
00102       Event const * event() const { return &*event_; }
00103 
00104       virtual edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const;
00105       void fillParameterSetRegistry() const;
00106       virtual edm::TriggerResultsByName triggerResultsByName(std::string const& process) const;
00107 
00108       // ---------- static member functions --------------------
00109       static void throwProductNotFoundException(const std::type_info&, const char*, const char*, const char*);
00110 
00111       // ---------- member functions ---------------------------
00112 
00113       edm::EDProduct const* getByProductID(edm::ProductID const&) const;
00114       fwlite::LuminosityBlock const& getLuminosityBlock();
00115       fwlite::Run             const& getRun();
00116 
00117    private:
00118 
00119       friend class MultiChainEvent;
00120 
00121       ChainEvent(const Event&); // stop default
00122 
00123       const ChainEvent& operator=(const Event&); // stop default
00124 
00125       void findSizes();
00126       void switchToFile(Long64_t);
00127       // ---------- member data --------------------------------
00128       std::vector<std::string> fileNames_;
00129       boost::shared_ptr<TFile> file_;
00130       boost::shared_ptr<Event> event_;
00131       Long64_t eventIndex_;
00132       std::vector<Long64_t> accumulatedSize_;
00133       boost::shared_ptr<edm::EDProductGetter> getter_;
00134 
00135 };
00136 
00137 }
00138 #endif /*__CINT__ */
00139 #endif