CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 #if !defined(__CINT__) && !defined(__MAKECINT__)
21 // system include files
22 #include <memory>
23 #include <string>
24 #include <typeinfo>
25 #include <vector>
26 
27 // 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  virtual ~ChainEvent();
53 
54  ChainEvent const& operator++();
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();
67 
68  // ---------- const member functions ---------------------
69  virtual std::string const getBranchNameFor(std::type_info const&,
70  char const*,
71  char const*,
72  char const*) const;
73 
75 
76  // This function should only be called by fwlite::Handle<>
77  virtual bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const;
78  //void getByBranchName(std::type_info const&, char const*, void*&) const;
79 
80  bool isValid() const;
81  operator bool() const;
82  virtual bool atEnd() const;
83 
84  Long64_t size() const;
85 
86  virtual edm::EventAuxiliary const& eventAuxiliary() const;
87 
88  std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
89  std::vector<std::string> const& getProcessHistory() const;
90  virtual edm::ProcessHistory const& processHistory() const;
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  virtual Long64_t fileIndex() const { return eventIndex_; }
103 
104  void setGetter(std::shared_ptr<edm::EDProductGetter> getter){
105  event_->setGetter(getter);
106  }
107 
108  Event const* event() const { return &*event_; }
109 
111  void fillParameterSetRegistry() const;
113 
114  // ---------- static member functions --------------------
115  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
116 
117  // ---------- member functions ---------------------------
118 
119  virtual edm::WrapperBase const* getByProductID(edm::ProductID const&) const;
120  edm::WrapperBase const* getThinnedProduct(edm::ProductID const& pid, unsigned int& key) const;
121 
123  std::vector<edm::WrapperBase const*>& foundContainers,
124  std::vector<unsigned int>& keys) const;
125 
127  fwlite::Run const& getRun();
128 
129  private:
130 
131  friend class MultiChainEvent;
132 
133  ChainEvent(Event const&); // stop default
134 
135  ChainEvent const& operator=(Event const&); // stop default
136 
137  void findSizes();
138  void switchToFile(Long64_t);
139  // ---------- member data --------------------------------
140  std::vector<std::string> fileNames_;
141  std::shared_ptr<TFile> file_;
142  std::shared_ptr<Event> event_;
143  Long64_t eventIndex_;
144  std::vector<Long64_t> accumulatedSize_;
145  std::shared_ptr<edm::EDProductGetter> getter_;
146 
147 };
148 
149 }
150 #endif /*__CINT__ */
151 #endif
std::shared_ptr< TFile > file_
Definition: ChainEvent.h:141
edm::WrapperBase const * getThinnedProduct(edm::ProductID const &pid, unsigned int &key) const
Definition: ChainEvent.cc:282
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: ChainEvent.cc:319
virtual edm::TriggerResultsByName triggerResultsByName(std::string const &process) const
Definition: ChainEvent.cc:331
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const
Definition: ChainEvent.cc:286
Long64_t size() const
Definition: ChainEvent.cc:313
virtual edm::EventAuxiliary const & eventAuxiliary() const
Definition: ChainEvent.cc:252
void switchToFile(Long64_t)
Definition: ChainEvent.cc:212
tuple lumi
Definition: fjr2json.py:35
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const
Definition: ChainEvent.cc:268
unsigned long long EventNumber_t
TFile * getTFile() const
Definition: ChainEvent.h:91
Long64_t eventIndex_
Definition: ChainEvent.h:143
virtual ~ChainEvent()
Definition: ChainEvent.cc:76
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
unsigned int LuminosityBlockNumber_t
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: ChainEvent.cc:339
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const
Definition: ChainEvent.cc:225
virtual edm::WrapperBase const * getByProductID(edm::ProductID const &) const
Definition: ChainEvent.cc:277
fwlite::LuminosityBlock const & getLuminosityBlock()
Definition: ChainEvent.cc:257
void fillParameterSetRegistry() const
Definition: ChainEvent.cc:325
std::vector< std::string > const & getProcessHistory() const
Definition: ChainEvent.cc:240
static std::string const triggerResults
Definition: EdmProvDump.cc:40
fwlite::Run const & getRun()
Definition: ChainEvent.cc:262
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: ChainEvent.cc:115
virtual bool atEnd() const
Definition: ChainEvent.cc:303
std::vector< Long64_t > accumulatedSize_
Definition: ChainEvent.h:144
std::shared_ptr< Event > event_
Definition: ChainEvent.h:142
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: ChainEvent.cc:234
tuple pid
Definition: sysUtil.py:22
ChainEvent const & toBegin()
Definition: ChainEvent.cc:200
ChainEvent const & operator++()
Definition: ChainEvent.cc:97
unsigned int RunNumber_t
Long64_t eventIndex() const
Definition: ChainEvent.h:101
virtual edm::ProcessHistory const & processHistory() const
Definition: ChainEvent.cc:246
tuple process
Definition: LaserDQM_cfg.py:3
Event const * event() const
Definition: ChainEvent.h:108
bool isValid() const
Definition: ChainEvent.cc:293
void setGetter(std::shared_ptr< edm::EDProductGetter > getter)
Definition: ChainEvent.h:104
std::shared_ptr< edm::EDProductGetter > getter_
Definition: ChainEvent.h:145
virtual Long64_t fileIndex() const
Definition: ChainEvent.h:102
std::vector< std::string > fileNames_
Definition: ChainEvent.h:140
ChainEvent const & operator=(Event const &)
ChainEvent(std::vector< std::string > const &iFileNames)
Definition: ChainEvent.cc:35