File indexing completed on 2024-05-11 03:34:12
0001 #ifndef FWCore_Framework_stream_EDAnalyzerAdaptorBase_h
0002 #define FWCore_Framework_stream_EDAnalyzerAdaptorBase_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <array>
0023 #include <map>
0024 #include <string>
0025 #include <vector>
0026
0027
0028 #include "DataFormats/Provenance/interface/BranchType.h"
0029 #include "FWCore/Utilities/interface/ProductResolverIndex.h"
0030 #include "FWCore/Common/interface/FWCoreCommonFwd.h"
0031 #include "FWCore/Framework/interface/Frameworkfwd.h"
0032 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0033 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0034 #include "FWCore/ServiceRegistry/interface/ConsumesInfo.h"
0035 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0036 #include "FWCore/Utilities/interface/StreamID.h"
0037 #include "FWCore/Utilities/interface/RunIndex.h"
0038 #include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
0039 #include "FWCore/Utilities/interface/ESIndices.h"
0040 #include "FWCore/Utilities/interface/Transition.h"
0041
0042
0043
0044 namespace edm {
0045 class ModuleCallingContext;
0046 class ModuleProcessName;
0047 class ProductResolverIndexHelper;
0048 class EDConsumerBase;
0049 class PreallocationConfiguration;
0050 class ProductResolverIndexAndSkipBit;
0051 class ActivityRegistry;
0052 class ThinnedAssociationsHelper;
0053
0054 namespace maker {
0055 template <typename T>
0056 class ModuleHolderT;
0057 }
0058
0059 namespace eventsetup {
0060 class ESRecordsToProductResolverIndices;
0061 }
0062
0063 namespace stream {
0064 class EDAnalyzerBase;
0065
0066 class EDAnalyzerAdaptorBase {
0067 public:
0068 template <typename T>
0069 friend class edm::WorkerT;
0070 template <typename T>
0071 friend class edm::maker::ModuleHolderT;
0072
0073 EDAnalyzerAdaptorBase();
0074 EDAnalyzerAdaptorBase(const EDAnalyzerAdaptorBase&) = delete;
0075 const EDAnalyzerAdaptorBase& operator=(const EDAnalyzerAdaptorBase&) = delete;
0076 virtual ~EDAnalyzerAdaptorBase();
0077
0078
0079
0080
0081
0082
0083 const ModuleDescription& moduleDescription() const { return moduleDescription_; }
0084
0085 virtual bool wantsProcessBlocks() const noexcept = 0;
0086 virtual bool wantsInputProcessBlocks() const noexcept = 0;
0087 virtual bool wantsGlobalRuns() const noexcept = 0;
0088 virtual bool wantsGlobalLuminosityBlocks() const noexcept = 0;
0089 virtual bool wantsStreamRuns() const noexcept = 0;
0090 virtual bool wantsStreamLuminosityBlocks() const noexcept = 0;
0091
0092 std::string workerType() const { return "WorkerT<EDAnalyzerAdaptorBase>"; }
0093 void registerProductsAndCallbacks(EDAnalyzerAdaptorBase const*, ProductRegistry* reg);
0094
0095 protected:
0096 template <typename T>
0097 void createStreamModules(T iFunc) {
0098 unsigned int iStreamModule = 0;
0099 for (auto& m : m_streamModules) {
0100 m = iFunc(iStreamModule);
0101 setModuleDescriptionPtr(m);
0102 ++iStreamModule;
0103 }
0104 }
0105
0106
0107 void itemsToGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
0108 void itemsMayGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
0109 std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType) const;
0110
0111 std::vector<ESResolverIndex> const& esGetTokenIndicesVector(edm::Transition iTrans) const;
0112 std::vector<ESRecordIndex> const& esGetTokenRecordIndicesVector(edm::Transition iTrans) const;
0113
0114 void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&, bool iPrefetchMayGet);
0115 void updateLookup(eventsetup::ESRecordsToProductResolverIndices const&);
0116 virtual void selectInputProcessBlocks(ProductRegistry const&, ProcessBlockHelperBase const&) = 0;
0117
0118 const EDConsumerBase* consumer() const;
0119
0120 void modulesWhoseProductsAreConsumed(std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
0121 std::vector<ModuleProcessName>& modulesInPreviousProcesses,
0122 ProductRegistry const& preg,
0123 std::map<std::string, ModuleDescription const*> const& labelsToDesc,
0124 std::string const& processName) const;
0125
0126 void convertCurrentProcessAlias(std::string const& processName);
0127
0128 std::vector<ConsumesInfo> consumesInfo() const;
0129
0130 void deleteModulesEarly();
0131
0132 private:
0133 bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0134 void doPreallocate(PreallocationConfiguration const&);
0135 virtual void preallocRuns(unsigned int) {}
0136 virtual void preallocLumis(unsigned int) {}
0137
0138
0139 void preActionBeforeRunEventAsync(WaitingTaskHolder,
0140 ModuleCallingContext const&,
0141 Principal const&) const noexcept {}
0142
0143 virtual void setupStreamModules() = 0;
0144 virtual void doBeginJob() = 0;
0145 virtual void doEndJob() = 0;
0146
0147 void doBeginStream(StreamID id);
0148 void doEndStream(StreamID id);
0149 void doStreamBeginRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0150 virtual void setupRun(EDAnalyzerBase*, RunIndex) = 0;
0151 void doStreamEndRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0152 virtual void streamEndRunSummary(EDAnalyzerBase*, edm::Run const&, edm::EventSetup const&) = 0;
0153
0154 void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0155 virtual void setupLuminosityBlock(EDAnalyzerBase*, LuminosityBlockIndex) = 0;
0156 void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0157 virtual void streamEndLuminosityBlockSummary(EDAnalyzerBase*,
0158 edm::LuminosityBlock const&,
0159 edm::EventSetup const&) = 0;
0160
0161 virtual void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
0162 virtual void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
0163 virtual void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
0164 virtual void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
0165 virtual void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
0166 virtual void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
0167 virtual void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
0168
0169 void doRespondToOpenInputFile(FileBlock const&) {}
0170 void doRespondToCloseInputFile(FileBlock const&) {}
0171 virtual void doRespondToCloseOutputFile() = 0;
0172 void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0173
0174 bool hasAcquire() const noexcept { return false; }
0175 bool hasAccumulator() const noexcept { return false; }
0176
0177
0178 void setModuleDescriptionPtr(EDAnalyzerBase* m);
0179 void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0180 ModuleDescription moduleDescription_;
0181
0182 std::vector<EDAnalyzerBase*> m_streamModules;
0183 };
0184 }
0185 }
0186 #endif