CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/FWLite/interface/MultiChainEvent.h

Go to the documentation of this file.
00001 #ifndef DataFormats_FWLite_MultiChainEvent_h
00002 #define DataFormats_FWLite_MultiChainEvent_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     FWLite
00006 // Class  :     MultiChainEvent
00007 //
00016 //
00017 // Original Author:  Salvatore Rappoccio
00018 //         Created:  Thu Jul  9 22:05:56 CDT 2009
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/EventBase.h"
00029 #include "DataFormats/FWLite/interface/ChainEvent.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   namespace internal {
00047     class MultiProductGetter;
00048   }
00049 
00050 class MultiChainEvent: public EventBase
00051 {
00052 
00053    public:
00054 
00055       typedef std::map<edm::EventID, Long64_t>      sec_file_index_map;
00056       typedef std::pair<edm::EventID, edm::EventID> event_id_range;
00057       typedef std::map<event_id_range, Long64_t>    sec_file_range_index_map;
00058 
00059       MultiChainEvent(const std::vector<std::string>& iFileNames1,
00060                       const std::vector<std::string>& iFileNames2,
00061                       bool useSecFileMapSorted = false );
00062       virtual ~MultiChainEvent();
00063 
00064       const MultiChainEvent& operator++();
00065 
00067       bool to(Long64_t iIndex);
00068 
00069       //If lumi is non-zero, Go to event by Run, Lumi, and Event number
00070       //If lumi is zero, Go to event by Run and Event number
00071       bool to(edm::EventID id);
00072       bool to(edm::RunNumber_t run, edm::EventNumber_t event);
00073       bool to(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
00074 
00075       // Go to the very first Event.
00076       const MultiChainEvent& toBegin();
00077 
00078       // ---------- const member functions ---------------------
00079       virtual const std::string getBranchNameFor(const std::type_info&,
00080                                                  const char*,
00081                                                  const char*,
00082                                                  const char*) const;
00083 
00085       virtual bool getByLabel(const std::type_info&, const char*,
00086                               const char*, const char*, void*) const;
00087       //void getByBranchName(const std::type_info&, const char*, void*&) const;
00088 
00089       bool isValid() const;
00090       operator bool() const;
00091       bool atEnd() const;
00092 
00093       Long64_t size() const;
00094 
00095       virtual edm::EventAuxiliary const& eventAuxiliary() const;
00096 
00097       const std::vector<edm::BranchDescription>& getBranchDescriptions() const;
00098       const std::vector<std::string>& getProcessHistory() const;
00099       edm::ProcessHistory const& processHistory() const;
00100 
00101       TFile* getTFile() const {
00102         return event1_->getTFile();
00103       }
00104       TFile* getTFileSec() const {
00105         return event2_->getTFile();
00106       }
00107 
00108       Long64_t eventIndex()    const { return event1_->eventIndex(); }
00109       Long64_t eventIndexSec() const { return event2_->eventIndex(); }
00110 
00111       fwlite::LuminosityBlock const& getLuminosityBlock() {
00112         return event1_->getLuminosityBlock();
00113       }
00114 
00115       fwlite::Run const& getRun() {
00116         return event1_->getRun();
00117       }
00118 
00119 
00120       virtual Long64_t fileIndex()          const
00121       { return event1_->eventIndex(); }
00122       virtual Long64_t secondaryFileIndex() const
00123       { return event2_->eventIndex(); }
00124 
00125       virtual edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const;
00126       virtual edm::TriggerResultsByName triggerResultsByName(std::string const& process) const;
00127 
00128       // ---------- static member functions --------------------
00129       static void throwProductNotFoundException(const std::type_info&, const char*, const char*, const char*);
00130 
00131       // return the two chain events
00132       ChainEvent const * primary  () const { return &*event1_;}
00133       ChainEvent const * secondary() const { return &*event2_;}
00134 
00135       // ---------- member functions ---------------------------
00136 
00137       edm::EDProduct const* getByProductID(edm::ProductID const&) const;
00138 
00139 
00140    private:
00141 
00142       MultiChainEvent(const Event&); // stop default
00143 
00144       const MultiChainEvent& operator= (const Event&); // stop default
00145 
00147       bool toSec(Long64_t iIndex);
00148 
00149       //Go to event from secondary files by Run, Lumi (if non-zero), and  Event number
00150       bool toSec(const edm::EventID &id);
00151       bool toSec(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
00152       bool toSec(edm::RunNumber_t run, edm::EventNumber_t event);
00153 
00154 
00155       // ---------- member data --------------------------------
00156 
00157       boost::shared_ptr<ChainEvent> event1_;  // primary files
00158       boost::shared_ptr<ChainEvent> event2_;  // secondary files
00159       boost::shared_ptr<internal::MultiProductGetter> getter_;
00160 
00161       // speed up secondary file access with a (run range)_1 ---> index_2 map,
00162       // when the files are sorted by run,event within the file.
00163       // in this case, it is sufficient to store only a run-range to index mapping.
00164       // with this, the solution becomes more performant.
00165       bool                     useSecFileMapSorted_;
00166       sec_file_range_index_map secFileMapSorted_;
00167 };
00168 
00169 }
00170 #endif /*__CINT__ */
00171 #endif