Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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