File indexing completed on 2024-05-11 03:34:10
0001 #ifndef FWCore_Framework_limited_EDFilterBase_h
0002 #define FWCore_Framework_limited_EDFilterBase_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <memory>
0023
0024
0025 #include "FWCore/Framework/interface/ProducerBase.h"
0026 #include "FWCore/Framework/interface/EDConsumerBase.h"
0027 #include "FWCore/Framework/interface/Frameworkfwd.h"
0028 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0030 #include "FWCore/Concurrency/interface/LimitedTaskQueue.h"
0031 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0032
0033
0034
0035 namespace edm {
0036 class ModuleCallingContext;
0037 class PreallocationConfiguration;
0038 class StreamID;
0039 class ActivityRegistry;
0040 class ThinnedAssociationsHelper;
0041 class EventForTransformer;
0042 class ServiceWeakToken;
0043
0044 namespace maker {
0045 template <typename T>
0046 class ModuleHolderT;
0047 }
0048
0049 namespace limited {
0050
0051 class EDFilterBase : public ProducerBase, public EDConsumerBase {
0052 public:
0053 template <typename T>
0054 friend class edm::maker::ModuleHolderT;
0055 template <typename T>
0056 friend class edm::WorkerT;
0057 typedef EDFilterBase ModuleType;
0058
0059 EDFilterBase(ParameterSet const& pset);
0060 ~EDFilterBase() override;
0061
0062 static void fillDescriptions(ConfigurationDescriptions& descriptions);
0063 static void prevalidate(ConfigurationDescriptions& descriptions);
0064 static const std::string& baseType();
0065
0066
0067 ModuleDescription const& moduleDescription() const { return moduleDescription_; }
0068
0069 virtual bool wantsProcessBlocks() const noexcept = 0;
0070 virtual bool wantsInputProcessBlocks() const noexcept = 0;
0071 virtual bool wantsGlobalRuns() const noexcept = 0;
0072 virtual bool wantsGlobalLuminosityBlocks() const noexcept = 0;
0073 virtual bool wantsStreamRuns() const noexcept = 0;
0074 virtual bool wantsStreamLuminosityBlocks() const noexcept = 0;
0075
0076 unsigned int concurrencyLimit() const { return queue_.concurrencyLimit(); }
0077
0078 LimitedTaskQueue& queue() { return queue_; }
0079
0080 private:
0081 bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0082 void doTransformAsync(WaitingTaskHolder iTask,
0083 size_t iTransformIndex,
0084 EventPrincipal const& iEvent,
0085 ActivityRegistry*,
0086 ModuleCallingContext,
0087 ServiceWeakToken const&) noexcept;
0088
0089
0090 void preActionBeforeRunEventAsync(WaitingTaskHolder,
0091 ModuleCallingContext const&,
0092 Principal const&) const noexcept {}
0093
0094 void doPreallocate(PreallocationConfiguration const&);
0095 void doBeginJob();
0096 void doEndJob();
0097
0098 void doBeginStream(StreamID id);
0099 void doEndStream(StreamID id);
0100 void doStreamBeginRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0101 void doStreamEndRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0102 void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0103 void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0104
0105 void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0106 void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0107 void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0108 void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0109 void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0110 void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0111 void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0112
0113 void doRespondToOpenInputFile(FileBlock const&) {}
0114 void doRespondToCloseInputFile(FileBlock const&) {}
0115 void doRespondToCloseOutputFile() { clearInputProcessBlockCaches(); }
0116 void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0117
0118 void registerProductsAndCallbacks(EDFilterBase* module, ProductRegistry* reg) {
0119 registerProducts(module, reg, moduleDescription_);
0120 }
0121 std::string workerType() const { return "WorkerT<EDProducer>"; }
0122
0123 virtual bool filter(StreamID, Event&, EventSetup const&) const = 0;
0124 virtual void beginJob() {}
0125 virtual void endJob() {}
0126
0127 virtual void preallocStreams(unsigned int);
0128 virtual void preallocRuns(unsigned int);
0129 virtual void preallocRunsSummary(unsigned int);
0130 virtual void preallocLumis(unsigned int);
0131 virtual void preallocLumisSummary(unsigned int);
0132 virtual void preallocate(PreallocationConfiguration const&);
0133 virtual void doBeginStream_(StreamID id);
0134 virtual void doEndStream_(StreamID id);
0135 virtual void doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c);
0136 virtual void doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c);
0137 virtual void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c);
0138 virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0139 virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0140 virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0141
0142 virtual void doBeginProcessBlock_(ProcessBlock const&);
0143 virtual void doAccessInputProcessBlock_(ProcessBlock const&);
0144 virtual void doEndProcessBlock_(ProcessBlock const&);
0145 virtual void doBeginRun_(Run const& rp, EventSetup const& c);
0146 virtual void doBeginRunSummary_(Run const& rp, EventSetup const& c);
0147 virtual void doEndRunSummary_(Run const& rp, EventSetup const& c);
0148 virtual void doEndRun_(Run const& rp, EventSetup const& c);
0149 virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0150 virtual void doBeginLuminosityBlockSummary_(LuminosityBlock const& rp, EventSetup const& c);
0151 virtual void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c);
0152 virtual void doEndLuminosityBlock_(LuminosityBlock const& lb, EventSetup const& c);
0153
0154 virtual void doBeginProcessBlockProduce_(ProcessBlock&);
0155 virtual void doEndProcessBlockProduce_(ProcessBlock&);
0156 virtual void doBeginRunProduce_(Run& rp, EventSetup const& c);
0157 virtual void doEndRunProduce_(Run& rp, EventSetup const& c);
0158 virtual void doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0159 virtual void doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0160
0161 virtual size_t transformIndex_(edm::BranchDescription const& iBranch) const noexcept;
0162 virtual ProductResolverIndex transformPrefetch_(std::size_t iIndex) const noexcept;
0163 virtual void transformAsync_(WaitingTaskHolder iTask,
0164 std::size_t iIndex,
0165 edm::EventForTransformer& iEvent,
0166 edm::ActivityRegistry* iAct,
0167 ServiceWeakToken const& iToken) const noexcept;
0168
0169 virtual void clearInputProcessBlockCaches();
0170
0171 bool hasAcquire() const noexcept { return false; }
0172 bool hasAccumulator() const noexcept { return false; }
0173
0174 void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0175 ModuleDescription moduleDescription_;
0176 std::unique_ptr<std::vector<BranchID>[]> previousParentages_;
0177 std::unique_ptr<ParentageID[]> previousParentageIds_;
0178
0179 LimitedTaskQueue queue_;
0180 };
0181
0182 }
0183 }
0184
0185 #endif