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  template <typename T>
69  return event_->consumes<T>(iTag);
70  }
72 
73  // This function should only be called by fwlite::Handle<>
74  bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
75  //void getByBranchName(std::type_info const&, char const*, void*&) const;
76 
77  bool isValid() const;
78  operator bool() const;
79  bool atEnd() const override;
80 
81  Long64_t size() const;
82 
83  edm::EventAuxiliary const& eventAuxiliary() const override;
84 
85  std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
86  std::vector<std::string> const& getProcessHistory() const;
87  edm::ProcessHistory const& processHistory() const override;
88  TFile* getTFile() const { return event_->getTFile(); }
89 
90  // These functions return the index of the file that the current event
91  // resides in. Note that the file index is based on the vector of files
92  // which were actually opened, not the vector of input files in the
93  // constructor. These two may differ in the case some input files contain
94  // 0 events. To get the path of the file where the current event resides
95  // in, fwlite::ChainEvent::getTFile()->GetPath() is preferred.
96  Long64_t eventIndex() const { return eventIndex_; }
97  Long64_t fileIndex() const override { return eventIndex_; }
98 
99  void setGetter(std::shared_ptr<edm::EDProductGetter const> getter) { event_->setGetter(getter); }
100 
101  Event const* event() const { return &*event_; }
102 
104  void fillParameterSetRegistry() const;
106 
107  edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
108 
109  // ---------- static member functions --------------------
110  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
111 
112  // ---------- member functions ---------------------------
113 
114  edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
115  std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const& pid,
116  unsigned int key) const;
117 
118  void getThinnedProducts(edm::ProductID const& pid,
119  std::vector<edm::WrapperBase const*>& foundContainers,
120  std::vector<unsigned int>& keys) const;
121 
123  unsigned int key,
124  edm::ProductID const& thinned) const;
125 
127  fwlite::Run const& getRun();
128 
129  private:
130  bool getByTokenImp(edm::EDGetToken, edm::WrapperBase const*&) const override;
131 
132  friend class MultiChainEvent;
133 
134  ChainEvent(Event const&); // stop default
135 
136  ChainEvent const& operator=(Event const&); // stop default
137 
138  void findSizes();
139  void switchToFile(Long64_t);
140  // ---------- member data --------------------------------
141  std::vector<std::string> fileNames_;
144  Long64_t eventIndex_;
145  std::vector<Long64_t> accumulatedSize_;
147  };
148 
149 } // namespace fwlite
150 #endif
void setGetter(std::shared_ptr< edm::EDProductGetter const > getter)
Definition: ChainEvent.h:99
TFile * getTFile() const
Definition: ChainEvent.h:88
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
fwlite::LuminosityBlock const & getLuminosityBlock()
Definition: ChainEvent.cc:208
void switchToFile(Long64_t)
Definition: ChainEvent.cc:180
fwlite::Run const & getRun()
Definition: ChainEvent.cc:210
edm::propagate_const< std::shared_ptr< Event > > event_
Definition: ChainEvent.h:143
unsigned long long EventNumber_t
edm::WrapperBase const * getByProductID(edm::ProductID const &) const override
Definition: ChainEvent.cc:224
std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const override
Definition: ChainEvent.cc:191
Long64_t eventIndex() const
Definition: ChainEvent.h:96
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &pid, unsigned int key) const
Definition: ChainEvent.cc:228
Long64_t eventIndex_
Definition: ChainEvent.h:144
void fillParameterSetRegistry() const
Definition: ChainEvent.cc:267
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
unsigned int LuminosityBlockNumber_t
ChainEvent const & toBegin() override
Definition: ChainEvent.cc:170
Long64_t fileIndex() const override
Definition: ChainEvent.h:97
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: ChainEvent.cc:276
Long64_t size() const
Definition: ChainEvent.cc:257
edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const override
Definition: ChainEvent.cc:269
edm::ProcessHistory const & processHistory() const override
Definition: ChainEvent.cc:204
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: ChainEvent.cc:198
std::vector< std::string > const & getProcessHistory() const
Definition: ChainEvent.cc:202
bool atEnd() const override
Definition: ChainEvent.cc:248
static std::string const triggerResults
Definition: EdmProvDump.cc:47
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: ChainEvent.cc:106
edm::EDGetTokenT< T > consumes(edm::InputTag const &iTag) const
Definition: ChainEvent.h:68
bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const override
Definition: ChainEvent.cc:212
ChainEvent const & operator++() override
Definition: ChainEvent.cc:91
std::vector< Long64_t > accumulatedSize_
Definition: ChainEvent.h:145
edm::EventAuxiliary const & eventAuxiliary() const override
Definition: ChainEvent.cc:206
bool getByTokenImp(edm::EDGetToken, edm::WrapperBase const *&) const override
Definition: ChainEvent.cc:220
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const *> &foundContainers, std::vector< unsigned int > &keys) const
Definition: ChainEvent.cc:233
edm::propagate_const< std::shared_ptr< TFile > > file_
Definition: ChainEvent.h:142
edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const override
Definition: ChainEvent.cc:263
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const
Definition: ChainEvent.cc:239
edm::propagate_const< std::shared_ptr< edm::EDProductGetter > > getter_
Definition: ChainEvent.h:146
bool isValid() const
Definition: ChainEvent.cc:245
HLT enums.
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: ChainEvent.cc:259
unsigned int RunNumber_t
~ChainEvent() override
Definition: ChainEvent.cc:73
long double T
Event const * event() const
Definition: ChainEvent.h:101
std::vector< std::string > fileNames_
Definition: ChainEvent.h:141
ChainEvent const & operator=(Event const &)
ChainEvent(std::vector< std::string > const &iFileNames)
Definition: ChainEvent.cc:35
Definition: event.py:1