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;
120  fwlite::Run const& getRun();
121 
122  private:
123 
124  friend class MultiChainEvent;
125 
126  ChainEvent(Event const&); // stop default
127 
128  ChainEvent const& operator=(Event const&); // stop default
129 
130  void findSizes();
131  void switchToFile(Long64_t);
132  // ---------- member data --------------------------------
133  std::vector<std::string> fileNames_;
134  std::shared_ptr<TFile> file_;
135  std::shared_ptr<Event> event_;
136  Long64_t eventIndex_;
137  std::vector<Long64_t> accumulatedSize_;
138  std::shared_ptr<edm::EDProductGetter> getter_;
139 
140 };
141 
142 }
143 #endif /*__CINT__ */
144 #endif
std::shared_ptr< TFile > file_
Definition: ChainEvent.h:134
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: ChainEvent.cc:307
virtual edm::TriggerResultsByName triggerResultsByName(std::string const &process) const
Definition: ChainEvent.cc:319
Long64_t size() const
Definition: ChainEvent.cc:301
unsigned int EventNumber_t
Definition: EventRange.h:30
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
TFile * getTFile() const
Definition: ChainEvent.h:90
Long64_t eventIndex_
Definition: ChainEvent.h:136
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:327
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:313
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:292
std::vector< Long64_t > accumulatedSize_
Definition: ChainEvent.h:137
std::shared_ptr< Event > event_
Definition: ChainEvent.h:135
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: ChainEvent.cc:233
ChainEvent const & toBegin()
Definition: ChainEvent.cc:200
ChainEvent const & operator++()
Definition: ChainEvent.cc:97
unsigned int RunNumber_t
Definition: EventRange.h:32
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:282
void setGetter(std::shared_ptr< edm::EDProductGetter > getter)
Definition: ChainEvent.h:103
std::shared_ptr< edm::EDProductGetter > getter_
Definition: ChainEvent.h:138
virtual Long64_t fileIndex() const
Definition: ChainEvent.h:101
std::vector< std::string > fileNames_
Definition: ChainEvent.h:133
ChainEvent const & operator=(Event const &)
ChainEvent(std::vector< std::string > const &iFileNames)
Definition: ChainEvent.cc:35