Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_Framework_limited_EDAnalyzerBase_h
0002 #define FWCore_Framework_limited_EDAnalyzerBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     EDAnalyzerBase
0007 //
0008 /**\class limited::EDAnalyzerBase EDAnalyzerBase.h "EDAnalyzerBase.h"
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Thu, 18 Jul 2013 11:51:14 GMT
0019 //
0020 
0021 // system include files
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/EDConsumerBase.h"
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0028 #include "FWCore/Concurrency/interface/LimitedTaskQueue.h"
0029 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0030 
0031 // forward declarations
0032 
0033 namespace edm {
0034   class ModuleCallingContext;
0035   class PreallocationConfiguration;
0036   class StreamID;
0037   class ActivityRegistry;
0038   class ThinnedAssociationsHelper;
0039 
0040   namespace maker {
0041     template <typename T>
0042     class ModuleHolderT;
0043   }
0044 
0045   namespace limited {
0046 
0047     class EDAnalyzerBase : public EDConsumerBase {
0048     public:
0049       template <typename T>
0050       friend class edm::WorkerT;
0051       template <typename T>
0052       friend class edm::maker::ModuleHolderT;
0053       typedef EDAnalyzerBase ModuleType;
0054 
0055       EDAnalyzerBase(ParameterSet const& pset);
0056       ~EDAnalyzerBase() override;
0057 
0058       static void fillDescriptions(ConfigurationDescriptions& descriptions);
0059       static void prevalidate(ConfigurationDescriptions& descriptions);
0060       static const std::string& baseType();
0061 
0062       // Warning: the returned moduleDescription will be invalid during construction
0063       ModuleDescription const& moduleDescription() const { return moduleDescription_; }
0064 
0065       virtual bool wantsProcessBlocks() const noexcept = 0;
0066       virtual bool wantsInputProcessBlocks() const noexcept = 0;
0067       virtual bool wantsGlobalRuns() const noexcept = 0;
0068       virtual bool wantsGlobalLuminosityBlocks() const noexcept = 0;
0069       virtual bool wantsStreamRuns() const noexcept = 0;
0070       virtual bool wantsStreamLuminosityBlocks() const noexcept = 0;
0071 
0072       void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func) {
0073         callWhenNewProductsRegistered_ = func;
0074       }
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       //For now this is a placeholder
0083       /*virtual*/ void preActionBeforeRunEventAsync(WaitingTaskHolder iTask,
0084                                                     ModuleCallingContext const& iModuleCallingContext,
0085                                                     Principal const& iPrincipal) const noexcept {}
0086 
0087       void doPreallocate(PreallocationConfiguration const&);
0088       void doBeginJob();
0089       void doEndJob();
0090 
0091       void doBeginStream(StreamID id);
0092       void doEndStream(StreamID id);
0093       void doStreamBeginRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0094       void doStreamEndRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0095       void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0096       void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0097 
0098       void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0099       void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0100       void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0101       void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0102       void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0103       void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0104       void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0105 
0106       void doRespondToOpenInputFile(FileBlock const&) {}
0107       void doRespondToCloseInputFile(FileBlock const&) {}
0108       void doRespondToCloseOutputFile() { clearInputProcessBlockCaches(); }
0109       void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0110 
0111       void registerProductsAndCallbacks(EDAnalyzerBase* module, ProductRegistry* reg);
0112       std::string workerType() const { return "WorkerT<EDAnalyzer>"; }
0113 
0114       virtual void analyze(StreamID, Event const&, EventSetup const&) const = 0;
0115       virtual void beginJob() {}
0116       virtual void endJob() {}
0117 
0118       virtual void preallocStreams(unsigned int);
0119       virtual void preallocRuns(unsigned int);
0120       virtual void preallocRunsSummary(unsigned int);
0121       virtual void preallocLumis(unsigned int);
0122       virtual void preallocLumisSummary(unsigned int);
0123       virtual void preallocate(PreallocationConfiguration const&);
0124       virtual void doBeginStream_(StreamID id);
0125       virtual void doEndStream_(StreamID id);
0126       virtual void doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c);
0127       virtual void doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c);
0128       virtual void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c);
0129       virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0130       virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0131       virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0132 
0133       virtual void doBeginProcessBlock_(ProcessBlock const&);
0134       virtual void doAccessInputProcessBlock_(ProcessBlock const&);
0135       virtual void doEndProcessBlock_(ProcessBlock const&);
0136       virtual void doBeginRun_(Run const& rp, EventSetup const& c);
0137       virtual void doBeginRunSummary_(Run const& rp, EventSetup const& c);
0138       virtual void doEndRunSummary_(Run const& rp, EventSetup const& c);
0139       virtual void doEndRun_(Run const& rp, EventSetup const& c);
0140       virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0141       virtual void doBeginLuminosityBlockSummary_(LuminosityBlock const& rp, EventSetup const& c);
0142       virtual void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c);
0143       virtual void doEndLuminosityBlock_(LuminosityBlock const& lb, EventSetup const& c);
0144 
0145       virtual void clearInputProcessBlockCaches();
0146 
0147       bool hasAcquire() const noexcept { return false; }
0148       bool hasAccumulator() const noexcept { return false; }
0149 
0150       void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0151       ModuleDescription moduleDescription_;
0152 
0153       std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
0154 
0155       LimitedTaskQueue queue_;
0156     };
0157 
0158   }  // namespace limited
0159 }  // namespace edm
0160 
0161 #endif