CMS 3D CMS Logo

Event.h
Go to the documentation of this file.
1 #ifndef DataFormats_FWLite_Event_h
2 #define DataFormats_FWLite_Event_h
3 // -*- C++ -*-
4 //
5 // Package: FWLite
6 // Class : Event
7 //
40 //
41 // Original Author: Chris Jones
42 // Created: Tue May 8 15:01:20 EDT 2007
43 //
44 // system include files
45 #include <typeinfo>
46 #include <map>
47 #include <vector>
48 #include <memory>
49 #include <cstring>
50 #include <string>
51 #include <functional>
52 
53 #include "Rtypes.h"
54 
55 // user include files
65 
66 // forward declarations
67 namespace edm {
68  class WrapperBase;
69  class ProductRegistry;
70  class BranchDescription;
71  class EDProductGetter;
72  class EventAux;
73  class Timestamp;
74  class TriggerResults;
75  class TriggerNames;
77 }
78 class TCut;
79 
80 namespace fwlite {
81  class BranchMapReader;
82  class HistoryGetterBase;
83  class DataGetterHelper;
84  class RunFactory;
85  class Event : public EventBase
86  {
87 
88  public:
89  // NOTE: Does NOT take ownership so iFile must remain around
90  // at least as long as Event.
91  // useCache and baFunc (branch-access-function) are passed to
92  // DataGetterHelper and help with external management of TTreeCache
93  // associated with the file. By default useCache is true and internal
94  // DataGetterHelper caching is enabled. When user sets useCache to
95  // false no cache is created unless user attaches and controls it
96  // himself.
97  Event(TFile* iFile, bool useCache=true,
98  std::function<void (TBranch const&)> baFunc=[](TBranch const&){});
99  ~Event() override;
100 
102  Event const& operator++() override;
103 
106 
108  bool to (Long64_t iIndex);
109 
111  bool to(const edm::EventID &id);
112  bool to(edm::RunNumber_t run, edm::EventNumber_t event);
114 
116  Event const& toBegin() override;
117 
118  // ---------- const member functions ---------------------
120  std::string const getBranchNameFor(std::type_info const&,
121  char const* iModuleLabel,
122  char const* iProductInstanceLabel,
123  char const* iProcessName) const override;
124 
127  bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
128  //void getByBranchName(std::type_info const&, char const*, void*&) const;
129 
131  void draw(Option_t* opt);
132  Long64_t draw(char const* varexp, const TCut& selection, Option_t* option = "", Long64_t nentries = 1000000000, Long64_t firstentry = 0);
133  Long64_t draw(char const* varexp, char const* selection, Option_t* option = "", Long64_t nentries = 1000000000, Long64_t firstentry = 0);
134  Long64_t scan(char const* varexp = "", char const* selection = "", Option_t* option = "", Long64_t nentries = 1000000000, Long64_t firstentry = 0);
135 
136  bool isValid() const;
137  operator bool () const;
138  bool atEnd() const override;
139 
141  Long64_t size() const;
142 
143  edm::EventAuxiliary const& eventAuxiliary() const override;
144 
145  std::vector<edm::BranchDescription> const& getBranchDescriptions() const {
146  return branchMap_.getBranchDescriptions();
147  }
148  std::vector<std::string> const& getProcessHistory() const;
149  TFile* getTFile() const {
150  return branchMap_.getFile();
151  }
152 
153  edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
154 
155  edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
156  edm::WrapperBase const* getThinnedProduct(edm::ProductID const& pid, unsigned int& key) const;
157  void getThinnedProducts(edm::ProductID const& pid,
158  std::vector<edm::WrapperBase const*>& foundContainers,
159  std::vector<unsigned int>& keys) const;
160 
161  edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const override;
162 
163  edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const& triggerResults) const override;
164 
165  edm::ProcessHistory const& processHistory() const override {return history();}
166 
167  fwlite::LuminosityBlock const& getLuminosityBlock() const;
168  fwlite::Run const& getRun() const;
169 
170  // ---------- static member functions --------------------
171  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
172 
173 
174  private:
176  friend class ChainEvent;
177  friend class EventHistoryGetter;
178 
179  Event(Event const&) = delete; // stop default
180 
181  Event const& operator=(Event const&) = delete; // stop default
182 
183  edm::ProcessHistory const& history() const;
184  void updateAux(Long_t eventIndex) const;
185  void fillParameterSetRegistry() const;
186  void setGetter(std::shared_ptr<edm::EDProductGetter const> getter) { return dataHelper_.setGetter(getter);}
187 
188  // ---------- member data --------------------------------
189  mutable TFile* file_;
190  // TTree* eventTree_;
192  // Long64_t eventIndex_;
193  mutable std::shared_ptr<fwlite::LuminosityBlock> lumi_;
194  mutable std::shared_ptr<fwlite::Run> run_;
196 
197  //takes ownership of the strings used by the DataKey keys in data_
198  mutable std::vector<char const*> labels_;
200  mutable std::vector<edm::EventProcessHistoryID> eventProcessHistoryIDs_;
201  mutable std::vector<std::string> procHistoryNames_;
206  TBranch* auxBranch_;
209 
211  mutable std::shared_ptr<RunFactory> runFactory_;
212  };
213 
214 }
215 #endif
size
Write out results.
edm::ProcessHistoryMap historyMap_
Definition: Event.h:199
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:210
selection
main part
Definition: corrVsCorr.py:100
unsigned long long EventNumber_t
std::shared_ptr< fwlite::Run > run_
Definition: Event.h:194
bool firstentry
Definition: mps_merge.py:77
TTree * eventHistoryTree_
Definition: Event.h:191
int fileVersion_
Definition: Event.h:207
unsigned int LuminosityBlockNumber_t
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
def draw(name, histos, styles=_defaultStyles, legendLabels=[], kwargs)
T const * getThinnedProduct(RefCore const &ref, unsigned int &thinnedKey, EDProductGetter const *prodGetter)
Definition: RefCoreGet.h:129
bool parameterSetRegistryFilled_
Definition: Event.h:208
std::vector< std::string > procHistoryNames_
Definition: Event.h:201
edm::ProcessHistory const & processHistory() const override
Definition: Event.h:165
edm::EventAuxiliary const * pAux_
Definition: Event.h:204
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: Event.h:145
void setGetter(std::shared_ptr< edm::EDProductGetter const > getter)
Definition: Event.h:186
std::shared_ptr< fwlite::LuminosityBlock > lumi_
Definition: Event.h:193
fwlite::BranchMapReader branchMap_
Definition: Event.h:195
static std::string const triggerResults("TriggerResults")
TFile * file_
Definition: Event.h:189
edm::EventAuxiliary aux_
Definition: Event.h:202
std::vector< edm::EventProcessHistoryID > eventProcessHistoryIDs_
Definition: Event.h:200
HLT enums.
EntryFinder entryFinder_
Definition: Event.h:203
std::vector< char const * > labels_
Definition: Event.h:198
TFile * getTFile() const
Definition: Event.h:149
unsigned int RunNumber_t
static void throwProductNotFoundException(char const *where, errors::ErrorCodes error, BranchID const &bid)
Definition: Principal.cc:48
TBranch * auxBranch_
Definition: Event.h:206
edm::EventAux const * pOldAux_
Definition: Event.h:205
std::shared_ptr< RunFactory > runFactory_
Definition: Event.h:211
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
Definition: event.py:1