CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
TFile * getTFileSec() const
const MultiChainEvent & toBegin() override
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Long64_t eventIndexSec() const
std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const override
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const override
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const
ChainEvent const * secondary() const
unsigned long long EventNumber_t
Long64_t secondaryFileIndex() const override
fwlite::Run const & getRun()
ChainEvent const * primary() const
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const =0
unsigned int LuminosityBlockNumber_t
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &pid, unsigned int key) const
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Long64_t size() const
bool toSec(Long64_t iIndex)
Go to the event from secondary files at index iIndex.
bool atEnd() const override
std::map< edm::EventID, Long64_t > sec_file_index_map
std::vector< std::string > const & getProcessHistory() const
Long64_t fileIndex() const override
tuple key
prepare the HTCondor submission files and eventually submit them
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
static std::string const triggerResults
Definition: EdmProvDump.cc:44
edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const override
list lumi
Definition: dqmdumpme.py:53
std::map< event_id_range, Long64_t > sec_file_range_index_map
sec_file_range_index_map secFileMapSorted_
edm::ProcessHistory const & processHistory() const override
edm::EventAuxiliary const & eventAuxiliary() const override
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const
edm::WrapperBase const * getByProductID(edm::ProductID const &) const override
std::shared_ptr< internal::MultiProductGetter const > getter_
bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const override
MultiChainEvent(std::vector< std::string > const &iFileNames1, std::vector< std::string > const &iFileNames2, bool useSecFileMapSorted=false)
std::pair< edm::EventID, edm::EventID > event_id_range
const MultiChainEvent & operator=(Event const &)
std::shared_ptr< ChainEvent > event2_
unsigned int RunNumber_t
TFile * getTFile() const
const MultiChainEvent & operator++() override
Long64_t eventIndex() const
fwlite::LuminosityBlock const & getLuminosityBlock()
std::shared_ptr< ChainEvent > event1_