File indexing completed on 2021-08-02 04:38:20
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 "FWCore/Utilities/interface/thread_safety_macros.h"
0067
0068
0069 namespace edm {
0070 class WrapperBase;
0071 class ProductRegistry;
0072 class BranchDescription;
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 Event : public EventBase {
0088 public:
0089
0090
0091
0092
0093
0094
0095
0096
0097 Event(
0098 TFile* iFile, bool useCache = true, std::function<void(TBranch const&)> baFunc = [](TBranch const&) {});
0099
0100 Event(Event const&) = delete;
0101
0102 Event const& operator=(Event const&) = delete;
0103
0104 ~Event() override;
0105
0106
0107 Event const& operator++() override;
0108
0109
0110 Long64_t indexFromEventId(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
0111
0112
0113 bool to(Long64_t iIndex);
0114
0115
0116 bool to(const edm::EventID& id);
0117 bool to(edm::RunNumber_t run, edm::EventNumber_t event);
0118 bool to(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event);
0119
0120
0121 Event const& toBegin() override;
0122
0123
0124
0125 std::string const getBranchNameFor(std::type_info const&,
0126 char const* iModuleLabel,
0127 char const* iProductInstanceLabel,
0128 char const* iProcessName) const override;
0129
0130 using fwlite::EventBase::getByLabel;
0131
0132 bool getByLabel(std::type_info const&, char const*, char const*, char const*, void*) const override;
0133
0134
0135
0136 void draw(Option_t* opt);
0137 Long64_t draw(char const* varexp,
0138 const TCut& selection,
0139 Option_t* option = "",
0140 Long64_t nentries = 1000000000,
0141 Long64_t firstentry = 0);
0142 Long64_t draw(char const* varexp,
0143 char const* selection,
0144 Option_t* option = "",
0145 Long64_t nentries = 1000000000,
0146 Long64_t firstentry = 0);
0147 Long64_t scan(char const* varexp = "",
0148 char const* selection = "",
0149 Option_t* option = "",
0150 Long64_t nentries = 1000000000,
0151 Long64_t firstentry = 0);
0152
0153 bool isValid() const;
0154 operator bool() const;
0155 bool atEnd() const override;
0156
0157
0158 Long64_t size() const;
0159
0160 edm::EventAuxiliary const& eventAuxiliary() const override;
0161
0162 std::vector<edm::BranchDescription> const& getBranchDescriptions() const {
0163 return branchMap_.getBranchDescriptions();
0164 }
0165 std::vector<std::string> const& getProcessHistory() const;
0166 TFile* getTFile() const { return branchMap_.getFile(); }
0167
0168 edm::ParameterSet const* parameterSet(edm::ParameterSetID const& psID) const override;
0169
0170 edm::WrapperBase const* getByProductID(edm::ProductID const&) const override;
0171 std::optional<std::tuple<edm::WrapperBase const*, unsigned int>> getThinnedProduct(edm::ProductID const& pid,
0172 unsigned int key) const;
0173 void getThinnedProducts(edm::ProductID const& pid,
0174 std::vector<edm::WrapperBase const*>& foundContainers,
0175 std::vector<unsigned int>& keys) const;
0176 edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const& parent,
0177 unsigned int key,
0178 edm::ProductID const& thinned) const;
0179
0180 edm::TriggerNames const& triggerNames(edm::TriggerResults const& triggerResults) const override;
0181
0182 edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const& triggerResults) const override;
0183
0184 edm::ProcessHistory const& processHistory() const override { return history(); }
0185
0186 fwlite::LuminosityBlock const& getLuminosityBlock() const;
0187 fwlite::Run const& getRun() const;
0188
0189
0190 static void throwProductNotFoundException(std::type_info const&, char const*, char const*, char const*);
0191
0192 private:
0193 friend class internal::ProductGetter;
0194 friend class ChainEvent;
0195 friend class EventHistoryGetter;
0196
0197 edm::ProcessHistory const& history() const;
0198 void updateAux(Long_t eventIndex) const;
0199 void fillParameterSetRegistry() const;
0200 void setGetter(std::shared_ptr<edm::EDProductGetter const> getter) { return dataHelper_.setGetter(getter); }
0201
0202
0203
0204 CMS_SA_ALLOW mutable TFile* file_;
0205
0206 TTree* eventHistoryTree_;
0207
0208 CMS_SA_ALLOW mutable std::shared_ptr<fwlite::LuminosityBlock> lumi_;
0209 CMS_SA_ALLOW mutable std::shared_ptr<fwlite::Run> run_;
0210 CMS_SA_ALLOW mutable fwlite::BranchMapReader branchMap_;
0211
0212
0213 CMS_SA_ALLOW mutable std::vector<char const*> labels_;
0214 CMS_SA_ALLOW mutable edm::ProcessHistoryMap historyMap_;
0215 CMS_SA_ALLOW mutable std::vector<edm::EventProcessHistoryID> eventProcessHistoryIDs_;
0216 CMS_SA_ALLOW mutable std::vector<std::string> procHistoryNames_;
0217 CMS_SA_ALLOW mutable edm::EventAuxiliary aux_;
0218 CMS_SA_ALLOW mutable EntryFinder entryFinder_;
0219 edm::EventAuxiliary const* pAux_;
0220 edm::EventAux const* pOldAux_;
0221 TBranch* auxBranch_;
0222 int fileVersion_;
0223 CMS_SA_ALLOW mutable bool parameterSetRegistryFilled_;
0224
0225 fwlite::DataGetterHelper dataHelper_;
0226 CMS_SA_ALLOW mutable std::shared_ptr<RunFactory> runFactory_;
0227 };
0228
0229 }
0230 #endif