File indexing completed on 2024-04-06 12:04:09
0001 #ifndef DataFormats_FWLite_ChainEvent_h
0002 #define DataFormats_FWLite_ChainEvent_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <memory>
0022 #include <string>
0023 #include <typeinfo>
0024 #include <vector>
0025
0026
0027 #include "DataFormats/FWLite/interface/Event.h"
0028 #include "DataFormats/FWLite/interface/EventBase.h"
0029 #include "FWCore/Utilities/interface/propagate_const.h"
0030
0031
0032 namespace edm {
0033 class WrapperBase;
0034 class ProductRegistry;
0035 class ProcessHistory;
0036 class BranchDescription;
0037 class EDProductGetter;
0038 class EventAux;
0039 class TriggerResults;
0040 class TriggerNames;
0041 class TriggerResultsByName;
0042 }
0043
0044 namespace fwlite {
0045
0046 class ChainEvent : public EventBase {
0047 public:
0048 ChainEvent(std::vector<std::string> const& iFileNames);
0049 ~ChainEvent() override;
0050
0051 ChainEvent const& operator++() override;
0052
0053
0054 bool to(Long64_t iIndex);
0055
0056
0057
0058 bool to(const edm::EventID& id);
0059 bool to(edm::RunNumber_t run, edm::EventNumber_t event);
0060 bool to(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
0061
0062
0063 ChainEvent const& toBegin() override;
0064
0065
0066 std::string const getBranchNameFor(std::type_info const&, char const*, char const*, char const*) const override;
0067 template <typename T>
0068 edm::EDGetTokenT<T> consumes(edm::InputTag const& iTag) const {
0069 return event_->consumes<T>(iTag);
0070 }
0071 using fwlite::EventBase::getByLabel;
0072
0073
0074 bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
0075
0076
0077 bool isValid() const;
0078 operator bool() const;
0079 bool atEnd() const override;
0080
0081 Long64_t size() const;
0082
0083 edm::EventAuxiliary const& eventAuxiliary() const override;
0084
0085 std::vector<edm::BranchDescription> const& getBranchDescriptions() const;
0086 std::vector<std::string> const& getProcessHistory() const;
0087 edm::ProcessHistory const& processHistory() const override;
0088 TFile* getTFile() const { return event_->getTFile(); }
0089
0090
0091
0092
0093
0094
0095
0096 Long64_t eventIndex() const { return eventIndex_; }
0097 Long64_t fileIndex() const override { return eventIndex_; }
0098
0099 void setGetter(std::shared_ptr<edm::EDProductGetter const> getter) { event_->setGetter(getter); }
0100
0101 Event const* event() const { return &*event_; }
0102
0103 edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const override;
0104 void fillParameterSetRegistry() const;
0105 edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const& triggerResults) const override;
0106
0107 edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
0108
0109
0110 static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
0111
0112
0113
0114 edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
0115 std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const& pid,
0116 unsigned int key) const;
0117
0118 void getThinnedProducts(edm::ProductID const& pid,
0119 std::vector<edm::WrapperBase const*>& foundContainers,
0120 std::vector<unsigned int>& keys) const;
0121
0122 edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const& parent,
0123 unsigned int key,
0124 edm::ProductID const& thinned) const;
0125
0126 fwlite::LuminosityBlock const& getLuminosityBlock();
0127 fwlite::Run const& getRun();
0128
0129 private:
0130 bool getByTokenImp(edm::EDGetToken, edm::WrapperBase const*&) const override;
0131
0132 friend class MultiChainEvent;
0133
0134 ChainEvent(Event const&);
0135
0136 ChainEvent const& operator=(Event const&);
0137
0138 void findSizes();
0139 void switchToFile(Long64_t);
0140
0141 std::vector<std::string> fileNames_;
0142 edm::propagate_const<std::shared_ptr<TFile>> file_;
0143 edm::propagate_const<std::shared_ptr<Event>> event_;
0144 Long64_t eventIndex_;
0145 std::vector<Long64_t> accumulatedSize_;
0146 edm::propagate_const<std::shared_ptr<edm::EDProductGetter>> getter_;
0147 };
0148
0149 }
0150 #endif