CMS 3D CMS Logo

MultiChainEvent.h
Go to the documentation of this file.
1 #ifndef DataFormats_FWLite_MultiChainEvent_h
2 #define DataFormats_FWLite_MultiChainEvent_h
3 // -*- C++ -*-
4 //
5 // Package: FWLite
6 // Class : MultiChainEvent
7 //
16 //
17 // Original Author: Salvatore Rappoccio
18 // Created: Thu Jul 9 22:05:56 CDT 2009
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  namespace internal {
47  class MultiProductGetter;
48  }
49 
50  class MultiChainEvent : public EventBase {
51  public:
52  typedef std::map<edm::EventID, Long64_t> sec_file_index_map;
53  typedef std::pair<edm::EventID, edm::EventID> event_id_range;
54  typedef std::map<event_id_range, Long64_t> sec_file_range_index_map;
55 
56  MultiChainEvent(std::vector<std::string> const& iFileNames1,
57  std::vector<std::string> const& iFileNames2,
58  bool useSecFileMapSorted = false);
59  ~MultiChainEvent() override;
60 
61  const MultiChainEvent& operator++() override;
62 
64  bool to(Long64_t iIndex);
65 
66  //If lumi is non-zero, Go to event by Run, Lumi, and Event number
67  //If lumi is zero, Go to event by Run and Event number
68  bool to(edm::EventID id);
71 
72  // Go to the very first Event.
73  const MultiChainEvent& toBegin() override;
74 
75  // ---------- const member functions ---------------------
76  std::string const getBranchNameFor(std::type_info const&, char const*, char const*, char const*) const override;
77 
79 
81  bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
82  //void getByBranchName(std::type_info const&, char const*, void*&) const;
83 
84  bool isValid() const;
85  operator bool() const;
86  bool atEnd() const override;
87 
88  Long64_t size() const;
89 
90  edm::EventAuxiliary const& eventAuxiliary() const override;
91 
92  std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
93  std::vector<std::string> const& getProcessHistory() const;
94  edm::ProcessHistory const& processHistory() const override;
95  TFile* getTFile() const { return event1_->getTFile(); }
96  TFile* getTFileSec() const { return event2_->getTFile(); }
97 
98  Long64_t eventIndex() const { return event1_->eventIndex(); }
99  Long64_t eventIndexSec() const { return event2_->eventIndex(); }
100 
101  fwlite::LuminosityBlock const& getLuminosityBlock() { return event1_->getLuminosityBlock(); }
102 
103  fwlite::Run const& getRun() { return event1_->getRun(); }
104 
105  Long64_t fileIndex() const override { return event1_->eventIndex(); }
106  Long64_t secondaryFileIndex() const override { return event2_->eventIndex(); }
107 
110 
111  edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
112 
113  // ---------- static member functions --------------------
114  static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
115 
116  // return the two chain events
117  ChainEvent const* primary() const { return &*event1_; }
118  ChainEvent const* secondary() const { return &*event2_; }
119 
120  // ---------- member functions ---------------------------
121 
122  edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
123 
124  std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const& pid,
125  unsigned int key) const;
126 
127  void getThinnedProducts(edm::ProductID const& pid,
128  std::vector<edm::WrapperBase const*>& foundContainers,
129  std::vector<unsigned int>& keys) const;
130 
132  unsigned int key,
133  edm::ProductID const& thinned) const;
134 
135  private:
136  MultiChainEvent(Event const&); // stop default
137 
138  const MultiChainEvent& operator=(Event const&); // stop default
139 
141  bool toSec(Long64_t iIndex);
142 
143  //Go to event from secondary files by Run, Lumi (if non-zero), and Event number
144  bool toSec(const edm::EventID& id);
147 
148  // ---------- member data --------------------------------
149 
150  std::shared_ptr<ChainEvent> event1_; // primary files
151  std::shared_ptr<ChainEvent> event2_; // secondary files
152  std::shared_ptr<internal::MultiProductGetter const> getter_;
153 
154  // speed up secondary file access with a (run range)_1 ---> index_2 map,
155  // when the files are sorted by run,event within the file.
156  // in this case, it is sufficient to store only a run-range to index mapping.
157  // with this, the solution becomes more performant.
160  };
161 
162 } // namespace fwlite
163 #endif
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
fwlite::MultiChainEvent::getProcessHistory
std::vector< std::string > const & getProcessHistory() const
Definition: MultiChainEvent.cc:297
electrons_cff.bool
bool
Definition: electrons_cff.py:366
fwlite::MultiChainEvent::eventIndex
Long64_t eventIndex() const
Definition: MultiChainEvent.h:98
TriggerResultsByName
fwlite
Definition: TFileDirectory.h:16
fwlite::MultiChainEvent::operator++
const MultiChainEvent & operator++() override
Definition: MultiChainEvent.cc:194
fwlite::MultiChainEvent::secondaryFileIndex
Long64_t secondaryFileIndex() const override
Definition: MultiChainEvent.h:106
propagate_const.h
fwlite::MultiChainEvent::atEnd
bool atEnd() const override
Definition: MultiChainEvent.cc:369
ProducerES_cfi.ProcessHistory
ProcessHistory
Definition: ProducerES_cfi.py:14
edm
HLT enums.
Definition: AlignableModifier.h:19
fwlite::MultiChainEvent::event1_
std::shared_ptr< ChainEvent > event1_
Definition: MultiChainEvent.h:150
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
fwlite::MultiChainEvent::primary
ChainEvent const * primary() const
Definition: MultiChainEvent.h:117
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
fwlite::MultiChainEvent
Definition: MultiChainEvent.h:50
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
fwlite::MultiChainEvent::isValid
bool isValid() const
Definition: MultiChainEvent.cc:366
fwlite::MultiChainEvent::getByLabel
bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const override
Definition: MultiChainEvent.cc:303
fwlite::MultiChainEvent::getBranchNameFor
const std::string getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const override
Definition: MultiChainEvent.cc:286
fwlite::MultiChainEvent::MultiChainEvent
MultiChainEvent(std::vector< std::string > const &iFileNames1, std::vector< std::string > const &iFileNames2, bool useSecFileMapSorted=false)
Definition: MultiChainEvent.cc:71
EventBase.h
fwlite::MultiChainEvent::useSecFileMapSorted_
bool useSecFileMapSorted_
Definition: MultiChainEvent.h:158
ChainEvent.h
fwlite::MultiChainEvent::getTFile
TFile * getTFile() const
Definition: MultiChainEvent.h:95
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
edm::EventAuxiliary
Definition: EventAuxiliary.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fwlite::MultiChainEvent::throwProductNotFoundException
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: MultiChainEvent.cc:422
fwlite::MultiChainEvent::getThinnedProducts
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const
Definition: MultiChainEvent.cc:341
fwlite::MultiChainEvent::getByProductID
edm::WrapperBase const * getByProductID(edm::ProductID const &) const override
Definition: MultiChainEvent.cc:318
fwlite::MultiChainEvent::getBranchDescriptions
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: MultiChainEvent.cc:293
edm::ParameterSet
Definition: ParameterSet.h:47
EDProductGetter
fwlite::MultiChainEvent::getter_
std::shared_ptr< internal::MultiProductGetter const > getter_
Definition: MultiChainEvent.h:152
fwlite::MultiChainEvent::to
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: MultiChainEvent.cc:200
fwlite::MultiChainEvent::sec_file_index_map
std::map< edm::EventID, Long64_t > sec_file_index_map
Definition: MultiChainEvent.h:52
edm::TriggerResultsByName
Definition: TriggerResultsByName.h:48
fwlite::Run
Definition: Run.h:54
edm::WrapperBase
Definition: WrapperBase.h:23
fwlite::MultiChainEvent::sec_file_range_index_map
std::map< event_id_range, Long64_t > sec_file_range_index_map
Definition: MultiChainEvent.h:54
fwlite::MultiChainEvent::operator=
const MultiChainEvent & operator=(Event const &)
fwlite::MultiChainEvent::triggerNames
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: MultiChainEvent.cc:373
fwlite::MultiChainEvent::eventIndexSec
Long64_t eventIndexSec() const
Definition: MultiChainEvent.h:99
fwlite::MultiChainEvent::secondary
ChainEvent const * secondary() const
Definition: MultiChainEvent.h:118
fwlite::MultiChainEvent::getRun
fwlite::Run const & getRun()
Definition: MultiChainEvent.h:103
fwlite::EventBase
Definition: EventBase.h:36
fwlite::MultiChainEvent::triggerResultsByName
edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const override
Definition: MultiChainEvent.cc:395
edm::OptionalThinnedKey
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
Definition: EDProductGetter.h:39
writedatasetfile.run
run
Definition: writedatasetfile.py:27
fwlite::MultiChainEvent::size
Long64_t size() const
Definition: MultiChainEvent.cc:371
fwlite::MultiChainEvent::parameterSet
edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const override
Definition: MultiChainEvent.cc:412
fwlite::Event
Definition: Event.h:87
fwlite::MultiChainEvent::toSec
bool toSec(Long64_t iIndex)
Go to the event from secondary files at index iIndex.
Definition: MultiChainEvent.cc:214
fwlite::MultiChainEvent::toBegin
const MultiChainEvent & toBegin() override
Definition: MultiChainEvent.cc:278
edm::TriggerNames
Definition: TriggerNames.h:55
fwlite::MultiChainEvent::getThinnedKeyFrom
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const
Definition: MultiChainEvent.cc:353
fwlite::MultiChainEvent::event2_
std::shared_ptr< ChainEvent > event2_
Definition: MultiChainEvent.h:151
fwlite::MultiChainEvent::fileIndex
Long64_t fileIndex() const override
Definition: MultiChainEvent.h:105
fwlite::MultiChainEvent::getLuminosityBlock
fwlite::LuminosityBlock const & getLuminosityBlock()
Definition: MultiChainEvent.h:101
internal
Definition: ROOTFilePB.pb.h:38
fwlite::MultiChainEvent::secFileMapSorted_
sec_file_range_index_map secFileMapSorted_
Definition: MultiChainEvent.h:159
edm::ProcessHistory
Definition: ProcessHistory.h:13
fwlite::ChainEvent
Definition: ChainEvent.h:46
fwlite::MultiChainEvent::event_id_range
std::pair< edm::EventID, edm::EventID > event_id_range
Definition: MultiChainEvent.h:53
fwlite::MultiChainEvent::~MultiChainEvent
~MultiChainEvent() override
Definition: MultiChainEvent.cc:176
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
crabWrapper.key
key
Definition: crabWrapper.py:19
lumi
Definition: LumiSectionData.h:20
fwlite::MultiChainEvent::getTFileSec
TFile * getTFileSec() const
Definition: MultiChainEvent.h:96
fwlite::MultiChainEvent::getThinnedProduct
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &pid, unsigned int key) const
Definition: MultiChainEvent.cc:329
class-composition.parent
parent
Definition: class-composition.py:88
edm::TriggerResults
Definition: TriggerResults.h:35
fwlite::MultiChainEvent::processHistory
edm::ProcessHistory const & processHistory() const override
Definition: MultiChainEvent.cc:299
edm::ProductID
Definition: ProductID.h:27
fwlite::MultiChainEvent::eventAuxiliary
edm::EventAuxiliary const & eventAuxiliary() const override
Definition: MultiChainEvent.cc:301