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 }
43 
44 namespace fwlite {
45 
46  class ChainEvent : public EventBase
47 {
48 
49  public:
50 
51  ChainEvent(std::vector<std::string> const& iFileNames);
52  ~ChainEvent() override;
53 
54  ChainEvent const& operator++() override;
55 
57  bool to(Long64_t iIndex);
58 
59  // If lumi is non-zero, go to event by Run, Lumi and Event number
60  // If lumi is 0, go to event by Run and Event number only.
61  bool to(const edm::EventID &id);
64 
65  // Go to the very first Event.
66  ChainEvent const& toBegin() override;
67 
68  // ---------- const member functions ---------------------
69  std::string const getBranchNameFor(std::type_info const&,
70  char const*,
71  char const*,
72  char const*) const override;
73 
75 
76  // This function should only be called by fwlite::Handle<>
77  bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
78  //void getByBranchName(std::type_info const&, char const*, void*&) const;
79 
80  bool isValid() const;
81  operator bool() const;
82  bool atEnd() const override;
83 
84  Long64_t size() const;
85 
86  edm::EventAuxiliary const& eventAuxiliary() const override;
87 
88  std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
89  std::vector<std::string> const& getProcessHistory() const;
90  edm::ProcessHistory const& processHistory() const override;
91  TFile* getTFile() const {
92  return event_->getTFile();
93  }
94 
95  // These functions return the index of the file that the current event
96  // resides in. Note that the file index is based on the vector of files
97  // which were actually opened, not the vector of input files in the
98  // constructor. These two may differ in the case some input files contain
99  // 0 events. To get the path of the file where the current event resides
100  // in, fwlite::ChainEvent::getTFile()->GetPath() is preferred.
101  Long64_t eventIndex() const { return eventIndex_; }
102  Long64_t fileIndex() const override { return eventIndex_; }
103 
104  void setGetter(std::shared_ptr<edm::EDProductGetter const> getter){
105  event_->setGetter(getter);
106  }
107 
108  Event const* event() const { return &*event_; }
109 
110  edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const override;
111  void fillParameterSetRegistry() const ;
112  edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const& triggerResults) const override;
113 
114  edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
115 
116  // ---------- static member functions --------------------
117  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
118 
119  // ---------- member functions ---------------------------
120 
121  edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
122  edm::WrapperBase const* getThinnedProduct(edm::ProductID const& pid, unsigned int& key) const;
123 
124  void getThinnedProducts(edm::ProductID const& pid,
125  std::vector<edm::WrapperBase const*>& foundContainers,
126  std::vector<unsigned int>& keys) const;
127 
128  fwlite::LuminosityBlock const& getLuminosityBlock();
129  fwlite::Run const& getRun();
130 
131  private:
132 
133  friend class MultiChainEvent;
134 
135  ChainEvent(Event const&); // stop default
136 
137  ChainEvent const& operator=(Event const&); // stop default
138 
139  void findSizes();
140  void switchToFile(Long64_t);
141  // ---------- member data --------------------------------
142  std::vector<std::string> fileNames_;
145  Long64_t eventIndex_;
146  std::vector<Long64_t> accumulatedSize_;
148 
149 };
150 
151 }
152 #endif
size
Write out results.
edm::propagate_const< std::shared_ptr< Event > > event_
Definition: ChainEvent.h:144
unsigned long long EventNumber_t
TFile * getTFile() const
Definition: ChainEvent.h:91
Long64_t eventIndex_
Definition: ChainEvent.h:145
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:129
std::vector< Long64_t > accumulatedSize_
Definition: ChainEvent.h:146
static std::string const triggerResults("TriggerResults")
edm::propagate_const< std::shared_ptr< TFile > > file_
Definition: ChainEvent.h:143
edm::propagate_const< std::shared_ptr< edm::EDProductGetter > > getter_
Definition: ChainEvent.h:147
HLT enums.
Long64_t fileIndex() const override
Definition: ChainEvent.h:102
void event_()
unsigned int RunNumber_t
Long64_t eventIndex() const
Definition: ChainEvent.h:101
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:50
Event const * event() const
Definition: ChainEvent.h:108
std::vector< std::string > fileNames_
Definition: ChainEvent.h:142
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
void setGetter(std::shared_ptr< edm::EDProductGetter const > getter)
Definition: ChainEvent.h:104
Definition: event.py:1