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
31 
32 // forward declarations
33 namespace edm {
34  class WrapperBase;
35  class ProductRegistry;
36  class ProcessHistory;
37  class BranchDescription;
38  class EDProductGetter;
39  class EventAux;
40  class TriggerResults;
41  class TriggerNames;
43 }
44 
45 namespace fwlite {
46 
47  class ChainEvent : public EventBase
48 {
49 
50  public:
51 
52  ChainEvent(std::vector<std::string> const& iFileNames);
53  virtual ~ChainEvent();
54 
55  ChainEvent const& operator++();
56 
58  bool to(Long64_t iIndex);
59 
60  // If lumi is non-zero, go to event by Run, Lumi and Event number
61  // If lumi is 0, go to event by Run and Event number only.
62  bool to(const edm::EventID &id);
65 
66  // Go to the very first Event.
67  ChainEvent const& toBegin();
68 
69  // ---------- const member functions ---------------------
70  virtual std::string const getBranchNameFor(std::type_info const&,
71  char const*,
72  char const*,
73  char const*) const;
74 
75  // This function should only be called by fwlite::Handle<>
76  virtual bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const;
77  //void getByBranchName(std::type_info const&, char const*, void*&) const;
78 
79  bool isValid() const;
80  operator bool() const;
81  virtual bool atEnd() const;
82 
83  Long64_t size() const;
84 
85  virtual edm::EventAuxiliary const& eventAuxiliary() const;
86 
87  std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
88  std::vector<std::string> const& getProcessHistory() const;
89  virtual edm::ProcessHistory const& processHistory() const;
90  TFile* getTFile() const {
91  return event_->getTFile();
92  }
93 
94  // These functions return the index of the file that the current event
95  // resides in. Note that the file index is based on the vector of files
96  // which were actually opened, not the vector of input files in the
97  // constructor. These two may differ in the case some input files contain
98  // 0 events. To get the path of the file where the current event resides
99  // in, fwlite::ChainEvent::getTFile()->GetPath() is preferred.
100  Long64_t eventIndex() const { return eventIndex_; }
101  virtual Long64_t fileIndex() const { return eventIndex_; }
102 
103  void setGetter(std::shared_ptr<edm::EDProductGetter> getter){
104  event_->setGetter(getter);
105  }
106 
107  Event const* event() const { return &*event_; }
108 
110  void fillParameterSetRegistry() const;
112 
113  // ---------- static member functions --------------------
114  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
115 
116  // ---------- member functions ---------------------------
117 
118  edm::WrapperBase const* getByProductID(edm::ProductID const&) const;
119  edm::WrapperBase const* getThinnedProduct(edm::ProductID const& pid, unsigned int& key) const;
120 
122  std::vector<edm::WrapperBase const*>& foundContainers,
123  std::vector<unsigned int>& keys) const;
124 
126  fwlite::Run const& getRun();
127 
128  private:
129 
130  friend class MultiChainEvent;
131 
132  ChainEvent(Event const&); // stop default
133 
134  ChainEvent const& operator=(Event const&); // stop default
135 
136  void findSizes();
137  void switchToFile(Long64_t);
138  // ---------- member data --------------------------------
139  std::vector<std::string> fileNames_;
140  std::shared_ptr<TFile> file_;
141  std::shared_ptr<Event> event_;
142  Long64_t eventIndex_;
143  std::vector<Long64_t> accumulatedSize_;
144  std::shared_ptr<edm::EDProductGetter> getter_;
145 
146 };
147 
148 }
149 #endif /*__CINT__ */
150 #endif
std::shared_ptr< TFile > file_
Definition: ChainEvent.h:140
edm::WrapperBase const * getThinnedProduct(edm::ProductID const &pid, unsigned int &key) const
Definition: ChainEvent.cc:281
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: ChainEvent.cc:317
virtual edm::TriggerResultsByName triggerResultsByName(std::string const &process) const
Definition: ChainEvent.cc:329
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const
Definition: ChainEvent.cc:285
Long64_t size() const
Definition: ChainEvent.cc:311
virtual edm::EventAuxiliary const & eventAuxiliary() const
Definition: ChainEvent.cc:251
void switchToFile(Long64_t)
Definition: ChainEvent.cc:211
tuple lumi
Definition: fjr2json.py:35
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const
Definition: ChainEvent.cc:267
unsigned long long EventNumber_t
TFile * getTFile() const
Definition: ChainEvent.h:90
Long64_t eventIndex_
Definition: ChainEvent.h:142
virtual ~ChainEvent()
Definition: ChainEvent.cc:76
unsigned int LuminosityBlockNumber_t
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: ChainEvent.cc:337
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const
Definition: ChainEvent.cc:224
edm::WrapperBase const * getByProductID(edm::ProductID const &) const
Definition: ChainEvent.cc:276
tuple TriggerResults
Definition: old-fu_pass.py:28
fwlite::LuminosityBlock const & getLuminosityBlock()
Definition: ChainEvent.cc:256
void fillParameterSetRegistry() const
Definition: ChainEvent.cc:323
std::vector< std::string > const & getProcessHistory() const
Definition: ChainEvent.cc:239
static std::string const triggerResults
Definition: EdmProvDump.cc:41
fwlite::Run const & getRun()
Definition: ChainEvent.cc:261
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: ChainEvent.cc:115
virtual bool atEnd() const
Definition: ChainEvent.cc:302
std::vector< Long64_t > accumulatedSize_
Definition: ChainEvent.h:143
std::shared_ptr< Event > event_
Definition: ChainEvent.h:141
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: ChainEvent.cc:233
tuple pid
Definition: sysUtil.py:22
ChainEvent const & toBegin()
Definition: ChainEvent.cc:200
ChainEvent const & operator++()
Definition: ChainEvent.cc:97
list key
Definition: combine.py:13
unsigned int RunNumber_t
Long64_t eventIndex() const
Definition: ChainEvent.h:100
virtual edm::ProcessHistory const & processHistory() const
Definition: ChainEvent.cc:245
tuple process
Definition: LaserDQM_cfg.py:3
Event const * event() const
Definition: ChainEvent.h:107
bool isValid() const
Definition: ChainEvent.cc:292
void setGetter(std::shared_ptr< edm::EDProductGetter > getter)
Definition: ChainEvent.h:103
std::shared_ptr< edm::EDProductGetter > getter_
Definition: ChainEvent.h:144
virtual Long64_t fileIndex() const
Definition: ChainEvent.h:101
std::vector< std::string > fileNames_
Definition: ChainEvent.h:139
ChainEvent const & operator=(Event const &)
ChainEvent(std::vector< std::string > const &iFileNames)
Definition: ChainEvent.cc:35