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  edm::WrapperBase const* getThinnedProduct(edm::ProductID const& pid, unsigned int& key) const;
125 
126  void getThinnedProducts(edm::ProductID const& pid,
127  std::vector<edm::WrapperBase const*>& foundContainers,
128  std::vector<unsigned int>& keys) const;
129 
130  private:
131  MultiChainEvent(Event const&); // stop default
132 
133  const MultiChainEvent& operator=(Event const&); // stop default
134 
136  bool toSec(Long64_t iIndex);
137 
138  //Go to event from secondary files by Run, Lumi (if non-zero), and Event number
139  bool toSec(const edm::EventID& id);
142 
143  // ---------- member data --------------------------------
144 
145  std::shared_ptr<ChainEvent> event1_; // primary files
146  std::shared_ptr<ChainEvent> event2_; // secondary files
147  std::shared_ptr<internal::MultiProductGetter const> getter_;
148 
149  // speed up secondary file access with a (run range)_1 ---> index_2 map,
150  // when the files are sorted by run,event within the file.
151  // in this case, it is sufficient to store only a run-range to index mapping.
152  // with this, the solution becomes more performant.
155  };
156 
157 } // namespace fwlite
158 #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:290
electrons_cff.bool
bool
Definition: electrons_cff.py:372
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:187
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:348
edm
HLT enums.
Definition: AlignableModifier.h:19
fwlite::MultiChainEvent::event1_
std::shared_ptr< ChainEvent > event1_
Definition: MultiChainEvent.h:145
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
TrackTriggerSetup_cfi.ProcessHistory
ProcessHistory
Definition: TrackTriggerSetup_cfi.py:162
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:345
fwlite::MultiChainEvent::getByLabel
bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const override
Definition: MultiChainEvent.cc:296
fwlite::MultiChainEvent::getBranchNameFor
const std::string getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const override
Definition: MultiChainEvent.cc:279
fwlite::MultiChainEvent::MultiChainEvent
MultiChainEvent(std::vector< std::string > const &iFileNames1, std::vector< std::string > const &iFileNames2, bool useSecFileMapSorted=false)
Definition: MultiChainEvent.cc:64
EventBase.h
fwlite::MultiChainEvent::useSecFileMapSorted_
bool useSecFileMapSorted_
Definition: MultiChainEvent.h:153
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:401
fwlite::MultiChainEvent::getThinnedProducts
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const
Definition: MultiChainEvent.cc:333
fwlite::MultiChainEvent::getByProductID
edm::WrapperBase const * getByProductID(edm::ProductID const &) const override
Definition: MultiChainEvent.cc:311
fwlite::MultiChainEvent::getBranchDescriptions
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: MultiChainEvent.cc:286
fwlite::MultiChainEvent::getThinnedProduct
edm::WrapperBase const * getThinnedProduct(edm::ProductID const &pid, unsigned int &key) const
Definition: MultiChainEvent.cc:322
edm::ParameterSet
Definition: ParameterSet.h:36
EDProductGetter
fwlite::MultiChainEvent::getter_
std::shared_ptr< internal::MultiProductGetter const > getter_
Definition: MultiChainEvent.h:147
fwlite::MultiChainEvent::to
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: MultiChainEvent.cc:193
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:352
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:374
writedatasetfile.run
run
Definition: writedatasetfile.py:27
fwlite::MultiChainEvent::size
Long64_t size() const
Definition: MultiChainEvent.cc:350
fwlite::MultiChainEvent::parameterSet
edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const override
Definition: MultiChainEvent.cc:391
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:207
fwlite::MultiChainEvent::toBegin
const MultiChainEvent & toBegin() override
Definition: MultiChainEvent.cc:271
edm::TriggerNames
Definition: TriggerNames.h:55
fwlite::MultiChainEvent::event2_
std::shared_ptr< ChainEvent > event2_
Definition: MultiChainEvent.h:146
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:39
fwlite::MultiChainEvent::secFileMapSorted_
sec_file_range_index_map secFileMapSorted_
Definition: MultiChainEvent.h:154
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:169
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
edm::TriggerResults
Definition: TriggerResults.h:35
fwlite::MultiChainEvent::processHistory
edm::ProcessHistory const & processHistory() const override
Definition: MultiChainEvent.cc:292
edm::ProductID
Definition: ProductID.h:27
fwlite::MultiChainEvent::eventAuxiliary
edm::EventAuxiliary const & eventAuxiliary() const override
Definition: MultiChainEvent.cc:294