Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-29 23:10:39

0001 #ifndef FWCore_Framework_EDProducer_h
0002 #define FWCore_Framework_EDProducer_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 EDProducer: The base class of "modules" whose main purpose is to insert new
0007 EDProducts into an Event.
0008 
0009 
0010 ----------------------------------------------------------------------*/
0011 
0012 #include "FWCore/Framework/interface/ProducerBase.h"
0013 #include "FWCore/Framework/interface/EDConsumerBase.h"
0014 #include "FWCore/Framework/interface/SharedResourcesAcquirer.h"
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0018 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0019 #include "FWCore/Utilities/interface/deprecated_macro.h"
0020 
0021 #include <string>
0022 #include <vector>
0023 
0024 namespace edm {
0025 
0026   class ModuleCallingContext;
0027   class PreallocationConfiguration;
0028   class ActivityRegistry;
0029   class ThinnedAssociationsHelper;
0030 
0031   namespace maker {
0032     template <typename T>
0033     class ModuleHolderT;
0034   }
0035 
0036   /**
0037    * The legacy EDProducer class is deprecated. We annotate the
0038    * constructor only with the CMS_DEPRECATED, because with gcc it
0039    * turns out to flag deriving classes more reliably than annotating
0040    * the entire class.
0041    */
0042   class EDProducer : public ProducerBase, public EDConsumerBase {
0043   public:
0044     template <typename T>
0045     friend class maker::ModuleHolderT;
0046     template <typename T>
0047     friend class WorkerT;
0048     typedef EDProducer ModuleType;
0049 
0050     CMS_DEPRECATED EDProducer();
0051     ~EDProducer() override;
0052 
0053     static void fillDescriptions(ConfigurationDescriptions& descriptions);
0054     static void prevalidate(ConfigurationDescriptions& descriptions);
0055     static const std::string& baseType();
0056 
0057     // Warning: the returned moduleDescription will be invalid during construction
0058     ModuleDescription const& moduleDescription() const { return moduleDescription_; }
0059 
0060     static bool wantsProcessBlocks() { return false; }
0061     static bool wantsInputProcessBlocks() { return false; }
0062     static bool wantsGlobalRuns() { return true; }
0063     static bool wantsGlobalLuminosityBlocks() { return true; }
0064     static bool wantsStreamRuns() { return false; }
0065     static bool wantsStreamLuminosityBlocks() { return false; };
0066 
0067     SerialTaskQueue* globalRunsQueue() { return &runQueue_; }
0068     SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_; }
0069 
0070   private:
0071     bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0072     //Needed by WorkerT but not supported
0073     void preActionBeforeRunEventAsync(WaitingTaskHolder, ModuleCallingContext const&, Principal const&) const {}
0074 
0075     void doPreallocate(PreallocationConfiguration const&) {}
0076     void doBeginJob();
0077     void doEndJob();
0078     void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
0079     void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
0080     void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) {}
0081     void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0082     void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0083     void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0084     void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0085     void doRespondToOpenInputFile(FileBlock const& fb);
0086     void doRespondToCloseInputFile(FileBlock const& fb);
0087     void doRespondToCloseOutputFile() {}
0088     void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0089     void registerProductsAndCallbacks(EDProducer* module, ProductRegistry* reg) {
0090       registerProducts(module, reg, moduleDescription_);
0091     }
0092 
0093     std::string workerType() const { return "WorkerT<EDProducer>"; }
0094 
0095     SharedResourcesAcquirer& sharedResourcesAcquirer() { return resourceAcquirer_; }
0096 
0097     virtual void produce(Event&, EventSetup const&) = 0;
0098     virtual void beginJob() {}
0099     virtual void endJob() {}
0100 
0101     virtual void beginRun(Run const& /* iR */, EventSetup const& /* iE */) {}
0102     virtual void endRun(Run const& /* iR */, EventSetup const& /* iE */) {}
0103     virtual void beginLuminosityBlock(LuminosityBlock const& /* iL */, EventSetup const& /* iE */) {}
0104     virtual void endLuminosityBlock(LuminosityBlock const& /* iL */, EventSetup const& /* iE */) {}
0105     virtual void respondToOpenInputFile(FileBlock const&) {}
0106     virtual void respondToCloseInputFile(FileBlock const&) {}
0107 
0108     bool hasAcquire() const { return false; }
0109     bool hasAccumulator() const { return false; }
0110 
0111     void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0112     ModuleDescription moduleDescription_;
0113     std::vector<BranchID> previousParentage_;
0114     SharedResourcesAcquirer resourceAcquirer_;
0115     SerialTaskQueue runQueue_;
0116     SerialTaskQueue luminosityBlockQueue_;
0117     ParentageID previousParentageId_;
0118   };
0119 }  // namespace edm
0120 
0121 #endif