Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-11 22:29:25

0001 #ifndef FWCore_Framework_global_EDProducerBase_h
0002 #define FWCore_Framework_global_EDProducerBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     EDProducerBase
0007 //
0008 /**\class EDProducerBase EDProducerBase.h "EDProducerBase.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 #include <memory>
0023 
0024 // user include files
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/WaitingTaskHolder.h"
0031 
0032 // forward declarations
0033 
0034 namespace edm {
0035   class ModuleCallingContext;
0036   class PreallocationConfiguration;
0037   class StreamID;
0038   class GlobalSchedule;
0039   class ActivityRegistry;
0040   class ThinnedAssociationsHelper;
0041   class WaitingTaskWithArenaHolder;
0042   class EventForTransformer;
0043 
0044   namespace maker {
0045     template <typename T>
0046     class ModuleHolderT;
0047   }
0048 
0049   namespace global {
0050 
0051     class EDProducerBase : 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 EDProducerBase ModuleType;
0058 
0059       friend class edm::GlobalSchedule;
0060 
0061       EDProducerBase();
0062       ~EDProducerBase() override;
0063 
0064       static void fillDescriptions(ConfigurationDescriptions& descriptions);
0065       static void prevalidate(ConfigurationDescriptions& descriptions);
0066       static const std::string& baseType();
0067 
0068       // Warning: the returned moduleDescription will be invalid during construction
0069       ModuleDescription const& moduleDescription() const { return moduleDescription_; }
0070 
0071       virtual bool wantsProcessBlocks() const = 0;
0072       virtual bool wantsInputProcessBlocks() const = 0;
0073       virtual bool wantsGlobalRuns() const = 0;
0074       virtual bool wantsGlobalLuminosityBlocks() const = 0;
0075       virtual bool wantsStreamRuns() const = 0;
0076       virtual bool wantsStreamLuminosityBlocks() const = 0;
0077 
0078     private:
0079       bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0080       void doAcquire(EventTransitionInfo const&,
0081                      ActivityRegistry*,
0082                      ModuleCallingContext const*,
0083                      WaitingTaskWithArenaHolder&);
0084       void doTransform(size_t iTransformIndex,
0085                        EventPrincipal const& iEvent,
0086                        ActivityRegistry*,
0087                        ModuleCallingContext const*);
0088       void doPreallocate(PreallocationConfiguration const&);
0089       void doBeginJob();
0090       void doEndJob();
0091 
0092       void doBeginStream(StreamID);
0093       void doEndStream(StreamID);
0094       void doStreamBeginRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0095       void doStreamEndRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0096       void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0097       void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0098 
0099       void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0100       void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0101       void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0102       void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0103       void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0104       void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0105       void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0106 
0107       void doRespondToOpenInputFile(FileBlock const&) {}
0108       void doRespondToCloseInputFile(FileBlock const&) {}
0109       void doRespondToCloseOutputFile() { clearInputProcessBlockCaches(); }
0110       void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0111 
0112       void registerProductsAndCallbacks(EDProducerBase* module, ProductRegistry* reg) {
0113         registerProducts(module, reg, moduleDescription_);
0114       }
0115       std::string workerType() const { return "WorkerT<EDProducer>"; }
0116 
0117       virtual void produce(StreamID, Event&, EventSetup const&) const = 0;
0118       //For now this is a placeholder
0119       /*virtual*/ void preActionBeforeRunEventAsync(WaitingTaskHolder iTask,
0120                                                     ModuleCallingContext const& iModuleCallingContext,
0121                                                     Principal const& iPrincipal) const {}
0122 
0123       virtual void beginJob() {}
0124       virtual void endJob() {}
0125 
0126       virtual void preallocStreams(unsigned int);
0127       virtual void preallocLumis(unsigned int);
0128       virtual void preallocLumisSummary(unsigned int);
0129       virtual void preallocate(PreallocationConfiguration const&);
0130       virtual void doBeginStream_(StreamID id);
0131       virtual void doEndStream_(StreamID id);
0132       virtual void doStreamBeginRun_(StreamID id, Run const& rp, EventSetup const& c);
0133       virtual void doStreamEndRun_(StreamID id, Run const& rp, EventSetup const& c);
0134       virtual void doStreamEndRunSummary_(StreamID id, Run const& rp, EventSetup const& c);
0135       virtual void doStreamBeginLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0136       virtual void doStreamEndLuminosityBlock_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0137       virtual void doStreamEndLuminosityBlockSummary_(StreamID id, LuminosityBlock const& lbp, EventSetup const& c);
0138 
0139       virtual void doBeginProcessBlock_(ProcessBlock const&);
0140       virtual void doAccessInputProcessBlock_(ProcessBlock const&);
0141       virtual void doEndProcessBlock_(ProcessBlock const&);
0142       virtual void doBeginRun_(Run const& rp, EventSetup const& c);
0143       virtual void doBeginRunSummary_(Run const& rp, EventSetup const& c);
0144       virtual void doEndRunSummary_(Run const& rp, EventSetup const& c);
0145       virtual void doEndRun_(Run const& rp, EventSetup const& c);
0146       virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0147       virtual void doBeginLuminosityBlockSummary_(LuminosityBlock const& rp, EventSetup const& c);
0148       virtual void doEndLuminosityBlockSummary_(LuminosityBlock const& lb, EventSetup const& c);
0149       virtual void doEndLuminosityBlock_(LuminosityBlock const& lb, EventSetup const& c);
0150 
0151       virtual void doBeginProcessBlockProduce_(ProcessBlock&);
0152       virtual void doEndProcessBlockProduce_(ProcessBlock&);
0153       virtual void doBeginRunProduce_(Run& rp, EventSetup const& c);
0154       virtual void doEndRunProduce_(Run& rp, EventSetup const& c);
0155       virtual void doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0156       virtual void doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0157 
0158       virtual size_t transformIndex_(edm::BranchDescription const& iBranch) const;
0159       virtual ProductResolverIndex transformPrefetch_(std::size_t iIndex) const;
0160       virtual void transform_(std::size_t iIndex, edm::EventForTransformer& iEvent) const;
0161 
0162       virtual void clearInputProcessBlockCaches();
0163       virtual bool hasAccumulator() const { return false; }
0164 
0165       virtual bool hasAcquire() const { return false; }
0166 
0167       virtual void doAcquire_(StreamID, Event const&, edm::EventSetup const&, WaitingTaskWithArenaHolder&);
0168 
0169       void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0170       ModuleDescription moduleDescription_;
0171       std::unique_ptr<std::vector<BranchID>[]> previousParentages_;
0172       std::unique_ptr<std::vector<BranchID>[]> gotBranchIDsFromAcquire_;
0173       std::unique_ptr<ParentageID[]> previousParentageIds_;
0174     };
0175 
0176   }  // namespace global
0177 }  // namespace edm
0178 
0179 #endif