Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_Framework_global_EDAnalyzerBase_h
0002 #define FWCore_Framework_global_EDAnalyzerBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     EDAnalyzerBase
0007 //
0008 /**\class 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 "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0027 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0029 
0030 // forward declarations
0031 
0032 namespace edm {
0033   class ModuleCallingContext;
0034   class PreallocationConfiguration;
0035   class StreamID;
0036   class ActivityRegistry;
0037   class ThinnedAssociationsHelper;
0038 
0039   namespace maker {
0040     template <typename T>
0041     class ModuleHolderT;
0042   }
0043 
0044   namespace global {
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       typedef EDAnalyzerBase ModuleType;
0053 
0054       EDAnalyzerBase();
0055       ~EDAnalyzerBase() override;
0056 
0057       static void fillDescriptions(ConfigurationDescriptions& descriptions);
0058       static void prevalidate(ConfigurationDescriptions& descriptions);
0059       static const std::string& baseType();
0060 
0061       // Warning: the returned moduleDescription will be invalid during construction
0062       ModuleDescription const& moduleDescription() const { return moduleDescription_; }
0063 
0064       virtual bool wantsProcessBlocks() const = 0;
0065       virtual bool wantsInputProcessBlocks() const = 0;
0066       virtual bool wantsGlobalRuns() const = 0;
0067       virtual bool wantsGlobalLuminosityBlocks() const = 0;
0068       virtual bool wantsStreamRuns() const = 0;
0069       virtual bool wantsStreamLuminosityBlocks() const = 0;
0070 
0071       void callWhenNewProductsRegistered(std::function<void(BranchDescription const&)> const& func) {
0072         callWhenNewProductsRegistered_ = func;
0073       }
0074 
0075     private:
0076       bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0077       //For now this is a placeholder
0078       /*virtual*/ void preActionBeforeRunEventAsync(WaitingTaskHolder,
0079                                                     ModuleCallingContext const&,
0080                                                     Principal const&) const {}
0081 
0082       void doPreallocate(PreallocationConfiguration const&);
0083       void doBeginJob();
0084       void doEndJob();
0085 
0086       void doBeginStream(StreamID id);
0087       void doEndStream(StreamID id);
0088       void doStreamBeginRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0089       void doStreamEndRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0090       void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0091       void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0092 
0093       void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0094       void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0095       void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0096       void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0097       void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0098       void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0099       void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0100 
0101       void doRespondToOpenInputFile(FileBlock const&) {}
0102       void doRespondToCloseInputFile(FileBlock const&) {}
0103       void doRespondToCloseOutputFile() { clearInputProcessBlockCaches(); }
0104       void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0105 
0106       void registerProductsAndCallbacks(EDAnalyzerBase* module, ProductRegistry* reg);
0107       std::string workerType() const { return "WorkerT<EDAnalyzer>"; }
0108 
0109       virtual void analyze(StreamID, Event const&, EventSetup const&) const = 0;
0110       virtual void beginJob() {}
0111       virtual void endJob() {}
0112 
0113       virtual void preallocStreams(unsigned int);
0114       virtual void preallocLumis(unsigned int);
0115       virtual void preallocLumisSummary(unsigned int);
0116       virtual void preallocate(PreallocationConfiguration const&);
0117       virtual void doBeginStream_(StreamID id);
0118       virtual void doEndStream_(StreamID id);
0119       virtual void doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c);
0120       virtual void doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c);
0121       virtual void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c);
0122       virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0123       virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0124       virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0125 
0126       virtual void doBeginProcessBlock_(ProcessBlock const&);
0127       virtual void doAccessInputProcessBlock_(ProcessBlock const&);
0128       virtual void doEndProcessBlock_(ProcessBlock const&);
0129       virtual void doBeginRun_(Run const& rp, EventSetup const& c);
0130       virtual void doBeginRunSummary_(Run const& rp, EventSetup const& c);
0131       virtual void doEndRunSummary_(Run const& rp, EventSetup const& c);
0132       virtual void doEndRun_(Run const& rp, EventSetup const& c);
0133       virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0134       virtual void doBeginLuminosityBlockSummary_(LuminosityBlock const& rp, EventSetup const& c);
0135       virtual void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c);
0136       virtual void doEndLuminosityBlock_(LuminosityBlock const& lb, EventSetup const& c);
0137 
0138       virtual void clearInputProcessBlockCaches();
0139 
0140       bool hasAcquire() const { return false; }
0141       bool hasAccumulator() const { return false; }
0142 
0143       void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0144       ModuleDescription moduleDescription_;
0145 
0146       std::function<void(BranchDescription const&)> callWhenNewProductsRegistered_;
0147     };
0148 
0149   }  // namespace global
0150 }  // namespace edm
0151 
0152 #endif