Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-11 03:34:11

0001 #ifndef FWCore_Framework_one_EDFilterBase_h
0002 #define FWCore_Framework_one_EDFilterBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     one::EDFilterBase
0007 //
0008 /**\class one::EDFilterBase EDFilterBase.h "FWCore/Framework/interface/one/EDFilterBase.h"
0009 
0010  Description: Base class for edm::one::EDFilter<>
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Thu, 02 May 2013 21:21:21 GMT
0019 //
0020 
0021 // system include files
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/ProducerBase.h"
0025 #include "FWCore/Framework/interface/EDConsumerBase.h"
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/SharedResourcesAcquirer.h"
0028 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0030 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0031 
0032 // forward declarations
0033 namespace edm {
0034 
0035   class ModuleCallingContext;
0036   class PreallocationConfiguration;
0037   class ActivityRegistry;
0038   class ThinnedAssociationsHelper;
0039   class EventForTransformer;
0040   class ServiceWeakToken;
0041 
0042   namespace maker {
0043     template <typename T>
0044     class ModuleHolderT;
0045   }
0046 
0047   namespace one {
0048 
0049     class EDFilterBase : public ProducerBase, public EDConsumerBase {
0050     public:
0051       template <typename T>
0052       friend class edm::maker::ModuleHolderT;
0053       template <typename T>
0054       friend class edm::WorkerT;
0055       typedef EDFilterBase ModuleType;
0056 
0057       EDFilterBase();
0058       ~EDFilterBase() override;
0059 
0060       static void fillDescriptions(ConfigurationDescriptions& descriptions);
0061       static void prevalidate(ConfigurationDescriptions& descriptions);
0062       static const std::string& baseType();
0063 
0064       // Warning: the returned moduleDescription will be invalid during construction
0065       ModuleDescription const& moduleDescription() const { return moduleDescription_; }
0066 
0067       virtual bool wantsProcessBlocks() const noexcept = 0;
0068       virtual bool wantsInputProcessBlocks() const noexcept = 0;
0069       virtual bool wantsGlobalRuns() const noexcept = 0;
0070       virtual bool wantsGlobalLuminosityBlocks() const noexcept = 0;
0071       bool wantsStreamRuns() const noexcept { return false; }
0072       bool wantsStreamLuminosityBlocks() const noexcept { return false; };
0073 
0074       virtual SerialTaskQueue* globalRunsQueue();
0075       virtual SerialTaskQueue* globalLuminosityBlocksQueue();
0076 
0077     private:
0078       bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0079       void doTransformAsync(WaitingTaskHolder iTask,
0080                             size_t iTransformIndex,
0081                             EventPrincipal const& iEvent,
0082                             ActivityRegistry*,
0083                             ModuleCallingContext,
0084                             ServiceWeakToken const&) noexcept;
0085       //For now this is a placeholder
0086       /*virtual*/ void preActionBeforeRunEventAsync(WaitingTaskHolder,
0087                                                     ModuleCallingContext const&,
0088                                                     Principal const&) const noexcept {}
0089 
0090       void doPreallocate(PreallocationConfiguration const&);
0091       virtual void preallocRuns(unsigned int);
0092       virtual void preallocLumis(unsigned int);
0093       void doBeginJob();
0094       void doEndJob();
0095 
0096       void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0097       void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0098       void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0099       void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0100       void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0101       void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0102       void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0103 
0104       void doRespondToOpenInputFile(FileBlock const&) {}
0105       void doRespondToCloseInputFile(FileBlock const&) {}
0106       void doRespondToCloseOutputFile() { clearInputProcessBlockCaches(); }
0107       void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0108 
0109       void registerProductsAndCallbacks(EDFilterBase* module, ProductRegistry* reg) {
0110         registerProducts(module, reg, moduleDescription_);
0111       }
0112       std::string workerType() const { return "WorkerT<EDFilter>"; }
0113 
0114       SharedResourcesAcquirer& sharedResourcesAcquirer() { return resourcesAcquirer_; }
0115 
0116       virtual bool filter(Event&, EventSetup const&) = 0;
0117       virtual void beginJob() {}
0118       virtual void endJob() {}
0119 
0120       virtual void preallocThreads(unsigned int) {}
0121 
0122       virtual void doBeginProcessBlock_(ProcessBlock const&);
0123       virtual void doAccessInputProcessBlock_(ProcessBlock const&);
0124       virtual void doEndProcessBlock_(ProcessBlock const&);
0125       virtual void doBeginRun_(Run const& rp, EventSetup const& c);
0126       virtual void doEndRun_(Run const& rp, EventSetup const& c);
0127       virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0128       virtual void doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0129 
0130       virtual void doBeginProcessBlockProduce_(ProcessBlock&);
0131       virtual void doEndProcessBlockProduce_(ProcessBlock&);
0132       virtual void doBeginRunProduce_(Run& rp, EventSetup const& c);
0133       virtual void doEndRunProduce_(Run& rp, EventSetup const& c);
0134       virtual void doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0135       virtual void doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0136 
0137       virtual size_t transformIndex_(edm::BranchDescription const& iBranch) const noexcept;
0138       virtual ProductResolverIndex transformPrefetch_(std::size_t iIndex) const noexcept;
0139       virtual void transformAsync_(WaitingTaskHolder iTask,
0140                                    std::size_t iIndex,
0141                                    edm::EventForTransformer& iEvent,
0142                                    edm::ActivityRegistry* iAct,
0143                                    ServiceWeakToken const& iToken) const noexcept;
0144 
0145       virtual void clearInputProcessBlockCaches();
0146 
0147       bool hasAcquire() const noexcept { return false; }
0148       bool hasAccumulator() const noexcept { return false; }
0149 
0150       virtual SharedResourcesAcquirer createAcquirer();
0151 
0152       void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0153       ModuleDescription moduleDescription_;
0154       std::vector<BranchID> previousParentage_;
0155       ParentageID previousParentageId_;
0156 
0157       SharedResourcesAcquirer resourcesAcquirer_;
0158     };
0159 
0160   }  // namespace one
0161 }  // namespace edm
0162 
0163 #endif