Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-04-24 01:28:01

0001 #ifndef FWCore_ServiceRegistry_PathsAndConsumesOfModulesBase_h
0002 #define FWCore_ServiceRegistry_PathsAndConsumesOfModulesBase_h
0003 
0004 /**\class edm::PathsAndConsumesOfModulesBase
0005 
0006  Description: Contains information about paths and end paths
0007  as well as the modules on them. Also contains information
0008  about all modules that might run. Also contains information
0009  about the products a module is declared to consume and the
0010  dependences between modules which can be derived from
0011  those declarations. Also contains similar information
0012  related to EventSetup modules.
0013 
0014  Usage: This is typically passed as an argument to the
0015  callback method for the LookupInitializationComplete
0016  signal that a Service may watch.
0017 */
0018 //
0019 // Original Author: W. David Dagenhart
0020 //         Created: 11/5/2014
0021 
0022 #include "FWCore/ServiceRegistry/interface/ServiceRegistryfwd.h"
0023 #include "FWCore/Utilities/interface/BranchType.h"
0024 #include "FWCore/Utilities/interface/Transition.h"
0025 
0026 #include <string>
0027 #include <vector>
0028 
0029 namespace edm {
0030 
0031   class ModuleDescription;
0032 
0033   namespace eventsetup {
0034     struct ComponentDescription;
0035   }  // namespace eventsetup
0036 
0037   class PathsAndConsumesOfModulesBase {
0038   public:
0039     virtual ~PathsAndConsumesOfModulesBase();
0040 
0041     std::vector<std::string> const& paths() const { return doPaths(); }
0042     std::vector<std::string> const& endPaths() const { return doEndPaths(); }
0043 
0044     std::vector<ModuleDescription const*> const& allModules() const { return doAllModules(); }
0045 
0046     ModuleDescription const* moduleDescription(unsigned int moduleID) const { return doModuleDescription(moduleID); }
0047 
0048     std::vector<ModuleDescription const*> const& modulesOnPath(unsigned int pathIndex) const {
0049       return doModulesOnPath(pathIndex);
0050     }
0051 
0052     std::vector<ModuleDescription const*> const& modulesOnEndPath(unsigned int endPathIndex) const {
0053       return doModulesOnEndPath(endPathIndex);
0054     }
0055 
0056     // The ED modules in the returned vector will be from the current process
0057     // (not a prior process, and it will never include the source even
0058     // though the source can make products) and these modules will declare
0059     // they produce (they might or might not really produce) at least one
0060     // product associated with the branchType that the module corresponding
0061     // to the moduleID argument declares it consumes (includes declarations using
0062     // consumes or maybeConsumes). Note that if a module declares
0063     // it consumes a module label that is an EDAlias, the corresponding module
0064     // description will be included in the returned vector (but the label in the
0065     // module description is not the EDAlias label).
0066     std::vector<ModuleDescription const*> const& modulesWhoseProductsAreConsumedBy(
0067         unsigned int moduleID, BranchType branchType = InEvent) const {
0068       return doModulesWhoseProductsAreConsumedBy(moduleID, branchType);
0069     }
0070 
0071     // The EventSetup modules in the returned vector are associated with
0072     // the ED module identified by the moduleID argument. The other
0073     // argument named transition could for example be beginRun. The
0074     // returned EventSetup modules produce the data products consumed
0075     // by the ED module during the specified transition. In cases
0076     // where more than one module produces a product, only the preferred
0077     // producer is included. There may be some consumed products without
0078     // a producing module.
0079     std::vector<eventsetup::ComponentDescription const*> const& esModulesWhoseProductsAreConsumedBy(
0080         unsigned int moduleID, Transition transition) const {
0081       return doESModulesWhoseProductsAreConsumedBy(moduleID, transition);
0082     }
0083 
0084     // These next two functions return the declared consumes information
0085     // for a single EDModule (the one associated with the moduleID).
0086     // ModuleConsumesInfo objects for all transitions are in the same vector,
0087     // although the elements contain a member that indicates the branch type
0088     // for ED products and the transition associated with the consumes call
0089     // for EventSetup products.
0090     // Note the other functions above return a reference to
0091     // an object that is held in memory throughout the job, while the
0092     // following function returns a newly created object each time.  We
0093     // do not expect this to be called during a normal production job where
0094     // performance and memory are important. These objects are bigger
0095     // than just a pointer.
0096     std::vector<ModuleConsumesInfo> moduleConsumesInfos(unsigned int moduleID) const;
0097 
0098     std::vector<ModuleConsumesESInfo> moduleConsumesESInfos(unsigned int moduleID) const;
0099 
0100     unsigned int largestModuleID() const { return doLargestModuleID(); }
0101 
0102     // The returned vector contains an entry for every EventSetup module.
0103     std::vector<eventsetup::ComponentDescription const*> const& allESModules() const { return doAllESModules(); }
0104 
0105     eventsetup::ComponentDescription const* componentDescription(unsigned int esModuleID) const {
0106       return doComponentDescription(esModuleID);
0107     }
0108 
0109     // The returned container indicates which EventSetup modules depend on which other
0110     // EventSetup modules. Each entry in the outer vector corresponds to an entry
0111     // in the vector returned by allESModules (same size and order).
0112     // The inner vector will contain an entry for each EventSetup module that can produce
0113     // a consumed data product. In the case of "may consumes", the producers for
0114     // all the products that might be consumed are included. The inner vector
0115     // includes producers for all produce methods together in the same vector and
0116     // has had duplicates removed.
0117     std::vector<std::vector<eventsetup::ComponentDescription const*>> const&
0118     esModulesWhoseProductsAreConsumedByESModule() const {
0119       return doESModulesWhoseProductsAreConsumedByESModule();
0120     }
0121 
0122     // Returns a container of information for one EventSetup module. The outer vector
0123     // is indexed by the produceMethodID, which is a counter of setWhatProduced calls in
0124     // the order they occur in the ESProducer constructor. The inner vector has
0125     // elements that correspond to the individual calls to the consumes function.
0126     // In an individual element, an empty module type indicates there is no
0127     // ESProducer or ESSource to produce the consumed data.
0128     // There is also a flag to indicate a module labeled mismatch.
0129     // "May consumes" elements are different because there can be multiple entries
0130     // for one "may consumes" function call, one for each available product that
0131     // matches the EventSetupRecordKey type and product type. If there are no
0132     // matches there is still one entry with a flag indicating there were
0133     // no matches.
0134     std::vector<std::vector<ESModuleConsumesInfo>> esModuleConsumesInfos(unsigned int esModuleID) const;
0135 
0136   private:
0137     virtual std::vector<std::string> const& doPaths() const = 0;
0138     virtual std::vector<std::string> const& doEndPaths() const = 0;
0139     virtual std::vector<ModuleDescription const*> const& doAllModules() const = 0;
0140     virtual ModuleDescription const* doModuleDescription(unsigned int moduleID) const = 0;
0141     virtual std::vector<ModuleDescription const*> const& doModulesOnPath(unsigned int pathIndex) const = 0;
0142     virtual std::vector<ModuleDescription const*> const& doModulesOnEndPath(unsigned int endPathIndex) const = 0;
0143     virtual std::vector<ModuleDescription const*> const& doModulesWhoseProductsAreConsumedBy(
0144         unsigned int moduleID, BranchType branchType) const = 0;
0145     virtual std::vector<eventsetup::ComponentDescription const*> const& doESModulesWhoseProductsAreConsumedBy(
0146         unsigned int moduleID, Transition) const = 0;
0147     virtual std::vector<ModuleConsumesInfo> doModuleConsumesInfos(unsigned int moduleID) const = 0;
0148     virtual std::vector<ModuleConsumesESInfo> doModuleConsumesESInfos(unsigned int moduleID) const = 0;
0149     virtual unsigned int doLargestModuleID() const = 0;
0150     virtual std::vector<eventsetup::ComponentDescription const*> const& doAllESModules() const = 0;
0151     virtual eventsetup::ComponentDescription const* doComponentDescription(unsigned int esModuleID) const = 0;
0152     virtual std::vector<std::vector<eventsetup::ComponentDescription const*>> const&
0153     doESModulesWhoseProductsAreConsumedByESModule() const = 0;
0154     virtual std::vector<std::vector<ESModuleConsumesInfo>> doESModuleConsumesInfos(unsigned int esModuleID) const = 0;
0155   };
0156 }  // namespace edm
0157 #endif