CMS 3D CMS Logo

GenericConsumer.cc
Go to the documentation of this file.
1 /*
2  * This plugin depends on all the event, lumi and run products produced by the modules listed in its configuration:
3  * - eventProducts: depend on the event products from these modules
4  * - lumiProducts: depend on the lumi products from these modules
5  * - runProducts: depend on the run products from these modules
6  *
7  * Use "*" to depend on all the products in a given branch.
8  */
9 
10 #include <algorithm>
11 #include <string>
12 #include <vector>
13 
20 
21 namespace edm {
23  public:
24  explicit GenericConsumer(ParameterSet const&);
25  ~GenericConsumer() override = default;
26 
27  void analyze(StreamID, Event const&, EventSetup const&) const override {}
28 
29  static void fillDescriptions(ConfigurationDescriptions& descriptions);
30 
31  private:
32  std::vector<std::string> eventLabels_;
33  std::vector<std::string> lumiLabels_;
34  std::vector<std::string> runLabels_;
35  std::vector<std::string> processLabels_;
36  };
37 
39  : eventLabels_(config.getUntrackedParameter<std::vector<std::string>>("eventProducts")),
40  lumiLabels_(config.getUntrackedParameter<std::vector<std::string>>("lumiProducts")),
41  runLabels_(config.getUntrackedParameter<std::vector<std::string>>("runProducts")),
42  processLabels_(config.getUntrackedParameter<std::vector<std::string>>("processProducts")) {
43  std::sort(eventLabels_.begin(), eventLabels_.end());
44  std::sort(lumiLabels_.begin(), lumiLabels_.end());
45  std::sort(runLabels_.begin(), runLabels_.end());
46  std::sort(processLabels_.begin(), processLabels_.end());
47 
49  static const std::string kWildcard("*");
50  static const std::string kPathStatus("edm::PathStatus");
51  static const std::string kEndPathStatus("edm::EndPathStatus");
52 
53  switch (branch.branchType()) {
54  case InEvent:
55  if (std::binary_search(eventLabels_.begin(), eventLabels_.end(), branch.moduleLabel()) or
56  (std::binary_search(eventLabels_.begin(), eventLabels_.end(), kWildcard) and
57  branch.className() != kPathStatus and branch.className() != kEndPathStatus))
58  this->consumes(edm::TypeToGet{branch.unwrappedTypeID(), PRODUCT_TYPE},
59  edm::InputTag{branch.moduleLabel(), branch.productInstanceName(), branch.processName()});
60  break;
61 
62  case InLumi:
63  if (std::binary_search(lumiLabels_.begin(), lumiLabels_.end(), branch.moduleLabel()) or
64  std::binary_search(lumiLabels_.begin(), lumiLabels_.end(), kWildcard))
65  this->consumes<edm::InLumi>(
66  edm::TypeToGet{branch.unwrappedTypeID(), PRODUCT_TYPE},
67  edm::InputTag{branch.moduleLabel(), branch.productInstanceName(), branch.processName()});
68  break;
69 
70  case InRun:
71  if (std::binary_search(runLabels_.begin(), runLabels_.end(), branch.moduleLabel()) or
72  std::binary_search(runLabels_.begin(), runLabels_.end(), kWildcard))
73  this->consumes<edm::InRun>(
74  edm::TypeToGet{branch.unwrappedTypeID(), PRODUCT_TYPE},
75  edm::InputTag{branch.moduleLabel(), branch.productInstanceName(), branch.processName()});
76  break;
77 
78  case InProcess:
79  if (std::binary_search(processLabels_.begin(), processLabels_.end(), branch.moduleLabel()) or
80  std::binary_search(processLabels_.begin(), processLabels_.end(), kWildcard))
81  this->consumes<edm::InProcess>(
82  edm::TypeToGet{branch.unwrappedTypeID(), PRODUCT_TYPE},
83  edm::InputTag{branch.moduleLabel(), branch.productInstanceName(), branch.processName()});
84  break;
85  default:
87  << "Unexpected branch type " << branch.branchType() << "\nPlease contact a Framework developer\n";
88  }
89  });
90  }
91 
93  descriptions.setComment(
94  "This plugin depends on all the event, lumi and run products "
95  "produced by the modules listed in its configuration.");
96 
98  desc.addUntracked<std::vector<std::string>>("eventProducts", {})
99  ->setComment(
100  "List of modules whose event products this module will depend on. "
101  "Use \"*\" to depend on all event products.");
102  desc.addUntracked<std::vector<std::string>>("lumiProducts", {})
103  ->setComment(
104  "List of modules whose lumi products this module will depend on. "
105  "Use \"*\" to depend on all lumi products.");
106  desc.addUntracked<std::vector<std::string>>("runProducts", {})
107  ->setComment(
108  "List of modules whose run products this module will depend on. "
109  "Use \"*\" to depend on all run products.");
110  desc.addUntracked<std::vector<std::string>>("processProducts", {})
111  ->setComment(
112  "List of modules whose process products this module will depend on. "
113  "Use \"*\" to depend on all process products.");
114  descriptions.addWithDefaultLabel(desc);
115  }
116 
117 } // namespace edm
118 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
~GenericConsumer() override=default
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
GenericConsumer(ParameterSet const &)
Definition: config.py:1
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(StreamID, Event const &, EventSetup const &) const override
std::vector< std::string > eventLabels_
void setComment(std::string const &value)
std::vector< std::string > runLabels_
HLT enums.
std::vector< std::string > processLabels_
std::vector< std::string > lumiLabels_