CMS 3D CMS Logo

ChainEvent.h
Go to the documentation of this file.
1 #ifndef DataFormats_FWLite_ChainEvent_h
2 #define DataFormats_FWLite_ChainEvent_h
3 // -*- C++ -*-
4 //
5 // Package: FWLite
6 // Class : ChainEvent
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Tue May 8 15:01:20 EDT 2007
19 //
20 // system include files
21 #include <memory>
22 #include <string>
23 #include <typeinfo>
24 #include <vector>
25 
26 // user include files
30 
31 // forward declarations
32 namespace edm {
33  class WrapperBase;
34  class ProductRegistry;
35  class ProcessHistory;
36  class BranchDescription;
37  class EDProductGetter;
38  class EventAux;
39  class TriggerResults;
40  class TriggerNames;
42 } // namespace edm
43 
44 namespace fwlite {
45 
46  class ChainEvent : public EventBase {
47  public:
48  ChainEvent(std::vector<std::string> const& iFileNames);
49  ~ChainEvent() override;
50 
51  ChainEvent const& operator++() override;
52 
54  bool to(Long64_t iIndex);
55 
56  // If lumi is non-zero, go to event by Run, Lumi and Event number
57  // If lumi is 0, go to event by Run and Event number only.
58  bool to(const edm::EventID& id);
61 
62  // Go to the very first Event.
63  ChainEvent const& toBegin() override;
64 
65  // ---------- const member functions ---------------------
66  std::string const getBranchNameFor(std::type_info const&, char const*, char const*, char const*) const override;
67 
69 
70  // This function should only be called by fwlite::Handle<>
71  bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
72  //void getByBranchName(std::type_info const&, char const*, void*&) const;
73 
74  bool isValid() const;
75  operator bool() const;
76  bool atEnd() const override;
77 
78  Long64_t size() const;
79 
80  edm::EventAuxiliary const& eventAuxiliary() const override;
81 
82  std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
83  std::vector<std::string> const& getProcessHistory() const;
84  edm::ProcessHistory const& processHistory() const override;
85  TFile* getTFile() const { return event_->getTFile(); }
86 
87  // These functions return the index of the file that the current event
88  // resides in. Note that the file index is based on the vector of files
89  // which were actually opened, not the vector of input files in the
90  // constructor. These two may differ in the case some input files contain
91  // 0 events. To get the path of the file where the current event resides
92  // in, fwlite::ChainEvent::getTFile()->GetPath() is preferred.
93  Long64_t eventIndex() const { return eventIndex_; }
94  Long64_t fileIndex() const override { return eventIndex_; }
95 
96  void setGetter(std::shared_ptr<edm::EDProductGetter const> getter) { event_->setGetter(getter); }
97 
98  Event const* event() const { return &*event_; }
99 
101  void fillParameterSetRegistry() const;
102  edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const& triggerResults) const override;
103 
104  edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
105 
106  // ---------- static member functions --------------------
107  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
108 
109  // ---------- member functions ---------------------------
110 
111  edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
112  edm::WrapperBase const* getThinnedProduct(edm::ProductID const& pid, unsigned int& key) const;
113 
114  void getThinnedProducts(edm::ProductID const& pid,
115  std::vector<edm::WrapperBase const*>& foundContainers,
116  std::vector<unsigned int>& keys) const;
117 
118  fwlite::LuminosityBlock const& getLuminosityBlock();
119  fwlite::Run const& getRun();
120 
121  private:
122  friend class MultiChainEvent;
123 
124  ChainEvent(Event const&); // stop default
125 
126  ChainEvent const& operator=(Event const&); // stop default
127 
128  void findSizes();
129  void switchToFile(Long64_t);
130  // ---------- member data --------------------------------
131  std::vector<std::string> fileNames_;
134  Long64_t eventIndex_;
135  std::vector<Long64_t> accumulatedSize_;
137  };
138 
139 } // namespace fwlite
140 #endif
size
Write out results.
edm::propagate_const< std::shared_ptr< Event > > event_
Definition: ChainEvent.h:133
unsigned long long EventNumber_t
TFile * getTFile() const
Definition: ChainEvent.h:85
Long64_t eventIndex_
Definition: ChainEvent.h:134
unsigned int LuminosityBlockNumber_t
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
T const * getThinnedProduct(RefCore const &ref, unsigned int &thinnedKey, EDProductGetter const *prodGetter)
Definition: RefCoreGet.h:116
std::vector< Long64_t > accumulatedSize_
Definition: ChainEvent.h:135
static std::string const triggerResults("TriggerResults")
edm::propagate_const< std::shared_ptr< TFile > > file_
Definition: ChainEvent.h:132
edm::propagate_const< std::shared_ptr< edm::EDProductGetter > > getter_
Definition: ChainEvent.h:136
HLT enums.
Long64_t fileIndex() const override
Definition: ChainEvent.h:94
void event_()
unsigned int RunNumber_t
Long64_t eventIndex() const
Definition: ChainEvent.h:93
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:48
Event const * event() const
Definition: ChainEvent.h:98
std::vector< std::string > fileNames_
Definition: ChainEvent.h:131
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
void setGetter(std::shared_ptr< edm::EDProductGetter const > getter)
Definition: ChainEvent.h:96
Definition: event.py:1