Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-19 01:43:37

0001 #ifndef FWCore_Framework_one_EDAnalyzerBase_h
0002 #define FWCore_Framework_one_EDAnalyzerBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     one::EDAnalyzerBase
0007 //
0008 /**\class one::EDAnalyzerBase EDAnalyzerBase.h "FWCore/Framework/interface/one/EDAnalyzerBase.h"
0009 
0010  Description: Base class for edm::one::EDAnalyzer<>
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Thu, 01 Aug 2013 21:21:21 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 "FWCore/Framework/interface/SharedResourcesAcquirer.h"
0027 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0029 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0030 
0031 // forward declarations
0032 namespace edm {
0033 
0034   class ModuleCallingContext;
0035   class PreallocationConfiguration;
0036   class ActivityRegistry;
0037   class ThinnedAssociationsHelper;
0038 
0039   namespace maker {
0040     template <typename T>
0041     class ModuleHolderT;
0042   }
0043 
0044   namespace one {
0045 
0046     class EDAnalyzerBase : public EDConsumerBase {
0047     public:
0048       template <typename T>
0049       friend class edm::WorkerT;
0050       template <typename T>
0051       friend class edm::maker::ModuleHolderT;
0052 
0053       typedef EDAnalyzerBase ModuleType;
0054 
0055       EDAnalyzerBase();
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 = 0;
0066       virtual bool wantsInputProcessBlocks() const = 0;
0067       virtual bool wantsGlobalRuns() const = 0;
0068       virtual bool wantsGlobalLuminosityBlocks() const = 0;
0069       bool wantsStreamRuns() const { return false; }
0070       bool wantsStreamLuminosityBlocks() const { return false; };
0071 
0072       virtual SerialTaskQueue* globalRunsQueue();
0073       virtual SerialTaskQueue* globalLuminosityBlocksQueue();
0074       void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func);
0075 
0076     private:
0077       bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0078       //For now this is a placeholder
0079       /*virtual*/ void preActionBeforeRunEventAsync(WaitingTaskHolder,
0080                                                     ModuleCallingContext const&,
0081                                                     Principal const&) const {}
0082 
0083       void doPreallocate(PreallocationConfiguration const&);
0084       virtual void preallocLumis(unsigned int);
0085       void doBeginJob();
0086       void doEndJob();
0087 
0088       void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0089       void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0090       void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0091       void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0092       void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0093       void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0094       void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0095 
0096       void doRespondToOpenInputFile(FileBlock const&) {}
0097       void doRespondToCloseInputFile(FileBlock const&) {}
0098       void doRespondToCloseOutputFile() { clearInputProcessBlockCaches(); }
0099       void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0100 
0101       void registerProductsAndCallbacks(EDAnalyzerBase const* module, ProductRegistry* reg);
0102       std::string workerType() const { return "WorkerT<EDAnalyzer>"; }
0103 
0104       SharedResourcesAcquirer& sharedResourcesAcquirer() { return resourcesAcquirer_; }
0105 
0106       virtual void analyze(Event const&, EventSetup const&) = 0;
0107       virtual void beginJob() {}
0108       virtual void endJob() {}
0109 
0110       virtual void doBeginProcessBlock_(ProcessBlock const&);
0111       virtual void doAccessInputProcessBlock_(ProcessBlock const&);
0112       virtual void doEndProcessBlock_(ProcessBlock const&);
0113       virtual void doBeginRun_(Run const& rp, EventSetup const& c);
0114       virtual void doEndRun_(Run const& rp, EventSetup const& c);
0115       virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0116       virtual void doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0117 
0118       virtual void clearInputProcessBlockCaches();
0119 
0120       bool hasAcquire() const { return false; }
0121       bool hasAccumulator() const { return false; }
0122 
0123       virtual SharedResourcesAcquirer createAcquirer();
0124 
0125       void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0126       ModuleDescription moduleDescription_;
0127       std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
0128 
0129       SharedResourcesAcquirer resourcesAcquirer_;
0130     };
0131   }  // namespace one
0132 }  // namespace edm
0133 #endif