File indexing completed on 2025-01-31 02:19:07
0001 #ifndef DataFormats_FWLite_Event_h
0002 #define DataFormats_FWLite_Event_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 #include <typeinfo>
0047 #include <map>
0048 #include <vector>
0049 #include <memory>
0050 #include <cstring>
0051 #include <string>
0052 #include <functional>
0053
0054 #include "Rtypes.h"
0055
0056
0057 #include "DataFormats/FWLite/interface/EventBase.h"
0058 #include "DataFormats/FWLite/interface/EntryFinder.h"
0059 #include "DataFormats/FWLite/interface/LuminosityBlock.h"
0060 #include "DataFormats/FWLite/interface/Run.h"
0061 #include "DataFormats/FWLite/interface/InternalDataKey.h"
0062 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0063 #include "DataFormats/Provenance/interface/EventProcessHistoryID.h"
0064 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
0065 #include "DataFormats/Provenance/interface/EventID.h"
0066 #include "DataFormats/Provenance/interface/ProductDescriptionFwd.h"
0067 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0068
0069
0070 namespace edm {
0071 class WrapperBase;
0072 class ProductRegistry;
0073 class EDProductGetter;
0074 class EventAux;
0075 class Timestamp;
0076 class TriggerResults;
0077 class TriggerNames;
0078 class TriggerResultsByName;
0079 }
0080 class TCut;
0081
0082 namespace fwlite {
0083 class BranchMapReader;
0084 class HistoryGetterBase;
0085 class DataGetterHelper;
0086 class RunFactory;
0087 class ChainEvent;
0088 class MultiChainEvent;
0089
0090 class Event : public EventBase {
0091 public:
0092 friend class ChainEvent;
0093 friend class MultiChainEvent;
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103 Event(TFile* iFile, bool useCache = true, std::function<void(TBranch const&)> baFunc = [](TBranch const&) {});
0104
0105 Event(Event const&) = delete;
0106
0107 Event const& operator=(Event const&) = delete;
0108
0109 ~Event() override;
0110
0111
0112 Event const& operator++() override;
0113
0114
0115 Long64_t indexFromEventId(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
0116
0117
0118 bool to(Long64_t iIndex);
0119
0120
0121 bool to(const edm::EventID& id);
0122 bool to(edm::RunNumber_t run, edm::EventNumber_t event);
0123 bool to(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
0124
0125
0126 Event const& toBegin() override;
0127
0128
0129
0130 std::string const getBranchNameFor(std::type_info const&,
0131 char const* iModuleLabel,
0132 char const* iProductInstanceLabel,
0133 char const* iProcessName) const override;
0134
0135 template <typename T>
0136 edm::EDGetTokenT<T> consumes(edm::InputTag const& iTag) const {
0137 auto bid =
0138 dataHelper_.getBranchIDFor(typeid(T), iTag.label().c_str(), iTag.instance().c_str(), iTag.process().c_str());
0139 if (bid) {
0140 return this->makeTokenUsing<T>(bid.value().id());
0141 }
0142 return {};
0143 }
0144 using fwlite::EventBase::getByLabel;
0145
0146 bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
0147
0148
0149
0150 void draw(Option_t* opt);
0151 Long64_t draw(char const* varexp,
0152 const TCut& selection,
0153 Option_t* option = "",
0154 Long64_t nentries = 1000000000,
0155 Long64_t firstentry = 0);
0156 Long64_t draw(char const* varexp,
0157 char const* selection,
0158 Option_t* option = "",
0159 Long64_t nentries = 1000000000,
0160 Long64_t firstentry = 0);
0161 Long64_t scan(char const* varexp = "",
0162 char const* selection = "",
0163 Option_t* option = "",
0164 Long64_t nentries = 1000000000,
0165 Long64_t firstentry = 0);
0166
0167 bool isValid() const;
0168 operator bool() const;
0169 bool atEnd() const override;
0170
0171
0172 Long64_t size() const;
0173
0174 edm::EventAuxiliary const& eventAuxiliary() const override;
0175
0176 std::vector<edm::ProductDescription> const& getProductDescriptions() const {
0177 return branchMap_.getProductDescriptions();
0178 }
0179 std::vector<std::string> const& getProcessHistory() const;
0180 TFile* getTFile() const { return branchMap_.getFile(); }
0181
0182 edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
0183
0184 edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
0185 std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const& pid,
0186 unsigned int key) const;
0187 void getThinnedProducts(edm::ProductID const& pid,
0188 std::vector<edm::WrapperBase const*>& foundContainers,
0189 std::vector<unsigned int>& keys) const;
0190 edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const& parent,
0191 unsigned int key,
0192 edm::ProductID const& thinned) const;
0193
0194 edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const override;
0195
0196 edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const& triggerResults) const override;
0197
0198 edm::ProcessHistory const& processHistory() const override { return history(); }
0199
0200 fwlite::LuminosityBlock const& getLuminosityBlock() const;
0201 fwlite::Run const& getRun() const;
0202
0203
0204 static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
0205
0206 private:
0207 bool getByTokenImp(edm::EDGetToken, edm::WrapperBase const*&) const override;
0208 friend class internal::ProductGetter;
0209 friend class ChainEvent;
0210 friend class EventHistoryGetter;
0211
0212 edm::ProcessHistory const& history() const;
0213 void updateAux(Long_t eventIndex) const;
0214 void fillParameterSetRegistry() const;
0215 void setGetter(std::shared_ptr<edm::EDProductGetter const> getter) { return dataHelper_.setGetter(getter); }
0216
0217
0218
0219 CMS_SA_ALLOW mutable TFile* file_;
0220
0221 TTree* eventHistoryTree_;
0222
0223 CMS_SA_ALLOW mutable std::shared_ptr<fwlite::LuminosityBlock> lumi_;
0224 CMS_SA_ALLOW mutable std::shared_ptr<fwlite::Run> run_;
0225 CMS_SA_ALLOW mutable fwlite::BranchMapReader branchMap_;
0226
0227
0228 CMS_SA_ALLOW mutable std::vector<char const*> labels_;
0229 CMS_SA_ALLOW mutable edm::ProcessHistoryMap historyMap_;
0230 CMS_SA_ALLOW mutable std::vector<edm::EventProcessHistoryID> eventProcessHistoryIDs_;
0231 CMS_SA_ALLOW mutable std::vector<std::string> procHistoryNames_;
0232 CMS_SA_ALLOW mutable edm::EventAuxiliary aux_;
0233 CMS_SA_ALLOW mutable EntryFinder entryFinder_;
0234 edm::EventAuxiliary const* pAux_;
0235 edm::EventAux const* pOldAux_;
0236 TBranch* auxBranch_;
0237 int fileVersion_;
0238 CMS_SA_ALLOW mutable bool parameterSetRegistryFilled_;
0239
0240 fwlite::DataGetterHelper dataHelper_;
0241 CMS_SA_ALLOW mutable std::shared_ptr<RunFactory> runFactory_;
0242 };
0243
0244 }
0245 #endif