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;
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  std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const& pid,
113  unsigned int key) const;
114 
115  void getThinnedProducts(edm::ProductID const& pid,
116  std::vector<edm::WrapperBase const*>& foundContainers,
117  std::vector<unsigned int>& keys) const;
118 
120  unsigned int key,
121  edm::ProductID const& thinned) const;
122 
124  fwlite::Run const& getRun();
125 
126  private:
127  friend class MultiChainEvent;
128 
129  ChainEvent(Event const&); // stop default
130 
131  ChainEvent const& operator=(Event const&); // stop default
132 
133  void findSizes();
134  void switchToFile(Long64_t);
135  // ---------- member data --------------------------------
136  std::vector<std::string> fileNames_;
139  Long64_t eventIndex_;
140  std::vector<Long64_t> accumulatedSize_;
142  };
143 
144 } // namespace fwlite
145 #endif
void setGetter(std::shared_ptr< edm::EDProductGetter const > getter)
Definition: ChainEvent.h:96
TFile * getTFile() const
Definition: ChainEvent.h:85
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:138
unsigned long long EventNumber_t
edm::WrapperBase const * getByProductID(edm::ProductID const &) const override
Definition: ChainEvent.cc:220
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:93
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &pid, unsigned int key) const
Definition: ChainEvent.cc:224
Long64_t eventIndex_
Definition: ChainEvent.h:139
void fillParameterSetRegistry() const
Definition: ChainEvent.cc:263
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:94
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: ChainEvent.cc:272
Long64_t size() const
Definition: ChainEvent.cc:253
edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const override
Definition: ChainEvent.cc:265
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:244
static std::string const triggerResults
Definition: EdmProvDump.cc:44
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: ChainEvent.cc:106
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:140
edm::EventAuxiliary const & eventAuxiliary() const override
Definition: ChainEvent.cc:206
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const *> &foundContainers, std::vector< unsigned int > &keys) const
Definition: ChainEvent.cc:229
edm::propagate_const< std::shared_ptr< TFile > > file_
Definition: ChainEvent.h:137
edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const override
Definition: ChainEvent.cc:259
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const
Definition: ChainEvent.cc:235
edm::propagate_const< std::shared_ptr< edm::EDProductGetter > > getter_
Definition: ChainEvent.h:141
bool isValid() const
Definition: ChainEvent.cc:241
HLT enums.
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: ChainEvent.cc:255
unsigned int RunNumber_t
~ChainEvent() override
Definition: ChainEvent.cc:73
Event const * event() const
Definition: ChainEvent.h:98
std::vector< std::string > fileNames_
Definition: ChainEvent.h:136
ChainEvent const & operator=(Event const &)
ChainEvent(std::vector< std::string > const &iFileNames)
Definition: ChainEvent.cc:35
Definition: event.py:1