Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-03 00:58:58

0001 #ifndef FWCore_Framework_stream_EDAnalyzerAdaptorBase_h
0002 #define FWCore_Framework_stream_EDAnalyzerAdaptorBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     EDAnalyzerAdaptorBase
0007 //
0008 /**\class edm::stream::EDAnalyzerAdaptorBase EDAnalyzerAdaptorBase.h "FWCore/Framework/interface/stream/EDAnalyzerAdaptorBase.h"
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Fri, 02 Aug 2013 18:09:15 GMT
0019 //
0020 
0021 // system include files
0022 #include <array>
0023 #include <map>
0024 #include <string>
0025 #include <vector>
0026 
0027 // user include files
0028 #include "DataFormats/Provenance/interface/BranchType.h"
0029 #include "FWCore/Utilities/interface/ProductResolverIndex.h"
0030 #include "FWCore/Common/interface/FWCoreCommonFwd.h"
0031 #include "FWCore/Framework/interface/Frameworkfwd.h"
0032 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0033 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0034 #include "FWCore/ServiceRegistry/interface/ConsumesInfo.h"
0035 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0036 #include "FWCore/Utilities/interface/StreamID.h"
0037 #include "FWCore/Utilities/interface/RunIndex.h"
0038 #include "FWCore/Utilities/interface/LuminosityBlockIndex.h"
0039 #include "FWCore/Utilities/interface/ESIndices.h"
0040 #include "FWCore/Utilities/interface/Transition.h"
0041 
0042 // forward declarations
0043 
0044 namespace edm {
0045   class ModuleCallingContext;
0046   class ModuleProcessName;
0047   class ProductResolverIndexHelper;
0048   class EDConsumerBase;
0049   class PreallocationConfiguration;
0050   class ProductResolverIndexAndSkipBit;
0051   class ActivityRegistry;
0052   class ThinnedAssociationsHelper;
0053 
0054   namespace maker {
0055     template <typename T>
0056     class ModuleHolderT;
0057   }
0058 
0059   namespace eventsetup {
0060     class ESRecordsToProxyIndices;
0061   }
0062 
0063   namespace stream {
0064     class EDAnalyzerBase;
0065 
0066     class EDAnalyzerAdaptorBase {
0067     public:
0068       template <typename T>
0069       friend class edm::WorkerT;
0070       template <typename T>
0071       friend class edm::maker::ModuleHolderT;
0072 
0073       EDAnalyzerAdaptorBase();
0074       EDAnalyzerAdaptorBase(const EDAnalyzerAdaptorBase&) = delete;                   // stop default
0075       const EDAnalyzerAdaptorBase& operator=(const EDAnalyzerAdaptorBase&) = delete;  // stop default
0076       virtual ~EDAnalyzerAdaptorBase();
0077 
0078       // ---------- const member functions ---------------------
0079 
0080       // ---------- static member functions --------------------
0081 
0082       // ---------- member functions ---------------------------
0083       const ModuleDescription& moduleDescription() const { return moduleDescription_; }
0084 
0085       virtual bool wantsProcessBlocks() const = 0;
0086       virtual bool wantsInputProcessBlocks() const = 0;
0087       virtual bool wantsGlobalRuns() const = 0;
0088       virtual bool wantsGlobalLuminosityBlocks() const = 0;
0089       bool wantsStreamRuns() const { return true; }
0090       bool wantsStreamLuminosityBlocks() const { return true; }
0091 
0092       std::string workerType() const { return "WorkerT<EDAnalyzerAdaptorBase>"; }
0093       void registerProductsAndCallbacks(EDAnalyzerAdaptorBase const*, ProductRegistry* reg);
0094 
0095     protected:
0096       template <typename T>
0097       void createStreamModules(T iFunc) {
0098         unsigned int iStreamModule = 0;
0099         for (auto& m : m_streamModules) {
0100           m = iFunc(iStreamModule);
0101           setModuleDescriptionPtr(m);
0102           ++iStreamModule;
0103         }
0104       }
0105 
0106       //Same interface as EDConsumerBase
0107       void itemsToGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
0108       void itemsMayGet(BranchType, std::vector<ProductResolverIndexAndSkipBit>&) const;
0109       std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType) const;
0110 
0111       std::vector<ESProxyIndex> const& esGetTokenIndicesVector(edm::Transition iTrans) const;
0112       std::vector<ESRecordIndex> const& esGetTokenRecordIndicesVector(edm::Transition iTrans) const;
0113 
0114       void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&, bool iPrefetchMayGet);
0115       void updateLookup(eventsetup::ESRecordsToProxyIndices const&);
0116       virtual void selectInputProcessBlocks(ProductRegistry const&, ProcessBlockHelperBase const&) = 0;
0117 
0118       const EDConsumerBase* consumer() const;
0119 
0120       void modulesWhoseProductsAreConsumed(std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
0121                                            std::vector<ModuleProcessName>& modulesInPreviousProcesses,
0122                                            ProductRegistry const& preg,
0123                                            std::map<std::string, ModuleDescription const*> const& labelsToDesc,
0124                                            std::string const& processName) const;
0125 
0126       void convertCurrentProcessAlias(std::string const& processName);
0127 
0128       std::vector<ConsumesInfo> consumesInfo() const;
0129 
0130       void deleteModulesEarly();
0131 
0132     private:
0133       bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0134       void doPreallocate(PreallocationConfiguration const&);
0135       virtual void preallocLumis(unsigned int) {}
0136 
0137       //For now this is a placeholder
0138       /*virtual*/ void preActionBeforeRunEventAsync(WaitingTaskHolder,
0139                                                     ModuleCallingContext const&,
0140                                                     Principal const&) const {}
0141 
0142       virtual void setupStreamModules() = 0;
0143       virtual void doBeginJob() = 0;
0144       virtual void doEndJob() = 0;
0145 
0146       void doBeginStream(StreamID id);
0147       void doEndStream(StreamID id);
0148       void doStreamBeginRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0149       virtual void setupRun(EDAnalyzerBase*, RunIndex) = 0;
0150       void doStreamEndRun(StreamID, RunTransitionInfo const&, ModuleCallingContext const*);
0151       virtual void streamEndRunSummary(EDAnalyzerBase*, edm::Run const&, edm::EventSetup const&) = 0;
0152 
0153       void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0154       virtual void setupLuminosityBlock(EDAnalyzerBase*, LuminosityBlockIndex) = 0;
0155       void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const&, ModuleCallingContext const*);
0156       virtual void streamEndLuminosityBlockSummary(EDAnalyzerBase*,
0157                                                    edm::LuminosityBlock const&,
0158                                                    edm::EventSetup const&) = 0;
0159 
0160       virtual void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
0161       virtual void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
0162       virtual void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*) = 0;
0163       virtual void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
0164       virtual void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*) = 0;
0165       virtual void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
0166       virtual void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*) = 0;
0167 
0168       void doRespondToOpenInputFile(FileBlock const&) {}
0169       void doRespondToCloseInputFile(FileBlock const&) {}
0170       virtual void doRespondToCloseOutputFile() = 0;
0171       void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0172 
0173       bool hasAcquire() const { return false; }
0174       bool hasAccumulator() const { return false; }
0175 
0176       // ---------- member data --------------------------------
0177       void setModuleDescriptionPtr(EDAnalyzerBase* m);
0178       void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0179       ModuleDescription moduleDescription_;
0180 
0181       std::vector<EDAnalyzerBase*> m_streamModules;
0182     };
0183   }  // namespace stream
0184 }  // namespace edm
0185 #endif