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 } // namespace edm
43 
44 namespace fwlite {
45 
46  class ChainEvent : public EventBase {
47  public:
48  ChainEvent(std::vector<std::string> const& iFileNames);
49  ~ChainEvent() override;
50 
51  ChainEvent const& operator++() override;
52 
54  bool to(Long64_t iIndex);
55 
56  // If lumi is non-zero, go to event by Run, Lumi and Event number
57  // If lumi is 0, go to event by Run and Event number only.
58  bool to(const edm::EventID& id);
61 
62  // Go to the very first Event.
63  ChainEvent const& toBegin() override;
64 
65  // ---------- const member functions ---------------------
66  std::string const getBranchNameFor(std::type_info const&, char const*, char const*, char const*) const override;
67 
69 
70  // This function should only be called by fwlite::Handle<>
71  bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
72  //void getByBranchName(std::type_info const&, char const*, void*&) const;
73 
74  bool isValid() const;
75  operator bool() const;
76  bool atEnd() const override;
77 
78  Long64_t size() const;
79 
80  edm::EventAuxiliary const& eventAuxiliary() const override;
81 
82  std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
83  std::vector<std::string> const& getProcessHistory() const;
84  edm::ProcessHistory const& processHistory() const override;
85  TFile* getTFile() const { return event_->getTFile(); }
86 
87  // These functions return the index of the file that the current event
88  // resides in. Note that the file index is based on the vector of files
89  // which were actually opened, not the vector of input files in the
90  // constructor. These two may differ in the case some input files contain
91  // 0 events. To get the path of the file where the current event resides
92  // in, fwlite::ChainEvent::getTFile()->GetPath() is preferred.
93  Long64_t eventIndex() const { return eventIndex_; }
94  Long64_t fileIndex() const override { return eventIndex_; }
95 
96  void setGetter(std::shared_ptr<edm::EDProductGetter const> getter) { event_->setGetter(getter); }
97 
98  Event const* event() const { return &*event_; }
99 
101  void fillParameterSetRegistry() const;
103 
104  edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
105 
106  // ---------- static member functions --------------------
107  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
108 
109  // ---------- member functions ---------------------------
110 
111  edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
112  std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const& pid,
113  unsigned int key) const;
114 
115  void getThinnedProducts(edm::ProductID const& pid,
116  std::vector<edm::WrapperBase const*>& foundContainers,
117  std::vector<unsigned int>& keys) const;
118 
120  unsigned int key,
121  edm::ProductID const& thinned) const;
122 
124  fwlite::Run const& getRun();
125 
126  private:
127  friend class MultiChainEvent;
128 
129  ChainEvent(Event const&); // stop default
130 
131  ChainEvent const& operator=(Event const&); // stop default
132 
133  void findSizes();
134  void switchToFile(Long64_t);
135  // ---------- member data --------------------------------
136  std::vector<std::string> fileNames_;
139  Long64_t eventIndex_;
140  std::vector<Long64_t> accumulatedSize_;
142  };
143 
144 } // namespace fwlite
145 #endif
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
electrons_cff.bool
bool
Definition: electrons_cff.py:393
TriggerResultsByName
fwlite::ChainEvent::triggerResultsByName
edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const override
Definition: ChainEvent.cc:262
fwlite::ChainEvent::eventAuxiliary
edm::EventAuxiliary const & eventAuxiliary() const override
Definition: ChainEvent.cc:203
fwlite::ChainEvent::getByProductID
edm::WrapperBase const * getByProductID(edm::ProductID const &) const override
Definition: ChainEvent.cc:217
fwlite::ChainEvent::event
Event const * event() const
Definition: ChainEvent.h:98
fwlite::ChainEvent::operator=
ChainEvent const & operator=(Event const &)
fwlite
Definition: TFileDirectory.h:16
fwlite::ChainEvent::getThinnedProducts
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const
Definition: ChainEvent.cc:226
propagate_const.h
fwlite::ChainEvent::getByLabel
bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const override
Definition: ChainEvent.cc:209
ProducerES_cfi.ProcessHistory
ProcessHistory
Definition: ProducerES_cfi.py:14
edm
HLT enums.
Definition: AlignableModifier.h:19
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
fwlite::ChainEvent::fileIndex
Long64_t fileIndex() const override
Definition: ChainEvent.h:94
fwlite::ChainEvent::throwProductNotFoundException
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: ChainEvent.cc:269
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
fwlite::MultiChainEvent
Definition: MultiChainEvent.h:50
fwlite::ChainEvent::switchToFile
void switchToFile(Long64_t)
Definition: ChainEvent.cc:177
fwlite::ChainEvent::ChainEvent
ChainEvent(std::vector< std::string > const &iFileNames)
Definition: ChainEvent.cc:35
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
fwlite::ChainEvent::isValid
bool isValid() const
Definition: ChainEvent.cc:238
edm::propagate_const
Definition: propagate_const.h:32
EventBase.h
fwlite::ChainEvent::event_
edm::propagate_const< std::shared_ptr< Event > > event_
Definition: ChainEvent.h:138
fwlite::ChainEvent::fileNames_
std::vector< std::string > fileNames_
Definition: ChainEvent.h:136
fwlite::ChainEvent::accumulatedSize_
std::vector< Long64_t > accumulatedSize_
Definition: ChainEvent.h:140
edm::Hash< ParameterSetType >
fwlite::EventBase::getByLabel
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
fwlite::ChainEvent::triggerNames
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: ChainEvent.cc:252
edm::EventAuxiliary
Definition: EventAuxiliary.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fwlite::ChainEvent::processHistory
edm::ProcessHistory const & processHistory() const override
Definition: ChainEvent.cc:201
fwlite::ChainEvent::file_
edm::propagate_const< std::shared_ptr< TFile > > file_
Definition: ChainEvent.h:137
edm::ParameterSet
Definition: ParameterSet.h:47
EDProductGetter
fwlite::ChainEvent::toBegin
ChainEvent const & toBegin() override
Definition: ChainEvent.cc:167
fwlite::ChainEvent::getBranchDescriptions
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: ChainEvent.cc:195
fwlite::ChainEvent::operator++
ChainEvent const & operator++() override
Definition: ChainEvent.cc:88
fwlite::ChainEvent::to
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: ChainEvent.cc:103
fwlite::ChainEvent::getRun
fwlite::Run const & getRun()
Definition: ChainEvent.cc:207
edm::TriggerResultsByName
Definition: TriggerResultsByName.h:48
fwlite::Run
Definition: Run.h:54
edm::WrapperBase
Definition: WrapperBase.h:23
fwlite::ChainEvent::getProcessHistory
std::vector< std::string > const & getProcessHistory() const
Definition: ChainEvent.cc:199
fwlite::ChainEvent::eventIndex_
Long64_t eventIndex_
Definition: ChainEvent.h:139
fwlite::EventBase
Definition: EventBase.h:36
fwlite::ChainEvent::setGetter
void setGetter(std::shared_ptr< edm::EDProductGetter const > getter)
Definition: ChainEvent.h:96
edm::OptionalThinnedKey
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
Definition: EDProductGetter.h:39
fwlite::ChainEvent::getBranchNameFor
const std::string getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const override
Definition: ChainEvent.cc:188
writedatasetfile.run
run
Definition: writedatasetfile.py:27
fwlite::Event
Definition: Event.h:87
fwlite::ChainEvent::getThinnedProduct
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &pid, unsigned int key) const
Definition: ChainEvent.cc:221
Event.h
fwlite::ChainEvent::findSizes
void findSizes()
fwlite::ChainEvent::getThinnedKeyFrom
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const
Definition: ChainEvent.cc:232
edm::TriggerNames
Definition: TriggerNames.h:55
fwlite::ChainEvent::eventIndex
Long64_t eventIndex() const
Definition: ChainEvent.h:93
fwlite::ChainEvent::atEnd
bool atEnd() const override
Definition: ChainEvent.cc:241
fwlite::ChainEvent::parameterSet
edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const override
Definition: ChainEvent.cc:256
fwlite::ChainEvent::~ChainEvent
~ChainEvent() override
Definition: ChainEvent.cc:70
edm::ProcessHistory
Definition: ProcessHistory.h:13
fwlite::ChainEvent
Definition: ChainEvent.h:46
fwlite::ChainEvent::size
Long64_t size() const
Definition: ChainEvent.cc:250
fwlite::ChainEvent::fillParameterSetRegistry
void fillParameterSetRegistry() const
Definition: ChainEvent.cc:260
fwlite::LuminosityBlock
Definition: LuminosityBlock.h:57
event
Definition: event.py:1
edm::EventID
Definition: EventID.h:31
HLTObjectsMonitor_cfi.TriggerResults
TriggerResults
Definition: HLTObjectsMonitor_cfi.py:9
fwlite::ChainEvent::getter_
edm::propagate_const< std::shared_ptr< edm::EDProductGetter > > getter_
Definition: ChainEvent.h:141
crabWrapper.key
key
Definition: crabWrapper.py:19
lumi
Definition: LumiSectionData.h:20
fwlite::ChainEvent::getLuminosityBlock
fwlite::LuminosityBlock const & getLuminosityBlock()
Definition: ChainEvent.cc:205
class-composition.parent
parent
Definition: class-composition.py:88
edm::TriggerResults
Definition: TriggerResults.h:35
edm::ProductID
Definition: ProductID.h:27
fwlite::ChainEvent::getTFile
TFile * getTFile() const
Definition: ChainEvent.h:85