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  };
36 
38  : eventLabels_(config.getUntrackedParameter<std::vector<std::string>>("eventProducts")),
39  lumiLabels_(config.getUntrackedParameter<std::vector<std::string>>("lumiProducts")),
40  runLabels_(config.getUntrackedParameter<std::vector<std::string>>("runProducts")) {
41  std::sort(eventLabels_.begin(), eventLabels_.end());
42  std::sort(lumiLabels_.begin(), lumiLabels_.end());
43  std::sort(runLabels_.begin(), runLabels_.end());
44 
46  static const std::string kWildcard("*");
47  static const std::string kPathStatus("edm::PathStatus");
48  static const std::string kEndPathStatus("edm::EndPathStatus");
49 
50  switch (branch.branchType()) {
51  case InEvent:
52  if (std::binary_search(eventLabels_.begin(), eventLabels_.end(), branch.moduleLabel()) or
53  (std::binary_search(eventLabels_.begin(), eventLabels_.end(), kWildcard) and
54  branch.className() != kPathStatus and branch.className() != kEndPathStatus))
55  this->consumes(edm::TypeToGet{branch.unwrappedTypeID(), PRODUCT_TYPE},
56  edm::InputTag{branch.moduleLabel(), branch.productInstanceName(), branch.processName()});
57  break;
58 
59  case InLumi:
60  if (std::binary_search(lumiLabels_.begin(), lumiLabels_.end(), branch.moduleLabel()) or
61  std::binary_search(lumiLabels_.begin(), lumiLabels_.end(), kWildcard))
62  this->consumes<edm::InLumi>(
63  edm::TypeToGet{branch.unwrappedTypeID(), PRODUCT_TYPE},
64  edm::InputTag{branch.moduleLabel(), branch.productInstanceName(), branch.processName()});
65  break;
66 
67  case InRun:
68  if (std::binary_search(runLabels_.begin(), runLabels_.end(), branch.moduleLabel()) or
69  std::binary_search(runLabels_.begin(), runLabels_.end(), kWildcard))
70  this->consumes<edm::InRun>(
71  edm::TypeToGet{branch.unwrappedTypeID(), PRODUCT_TYPE},
72  edm::InputTag{branch.moduleLabel(), branch.productInstanceName(), branch.processName()});
73  break;
74 
75  default:
77  << "Unexpected branch type " << branch.branchType() << "\nPlease contact a Framework developer\n";
78  }
79  });
80  }
81 
83  descriptions.setComment(
84  "This plugin depends on all the event, lumi and run products "
85  "produced by the modules listed in its configuration.");
86 
88  desc.addUntracked<std::vector<std::string>>("eventProducts", {})
89  ->setComment(
90  "List of modules whose event products this module will depend on. "
91  "Use \"*\" to depend on all event products.");
92  desc.addUntracked<std::vector<std::string>>("lumiProducts", {})
93  ->setComment(
94  "List of modules whose lumi products this module will depend on. "
95  "Use \"*\" to depend on all event products.");
96  desc.addUntracked<std::vector<std::string>>("runProducts", {})
97  ->setComment(
98  "List of modules whose run products this module will depend on. "
99  "Use \"*\" to depend on all event products.");
100  descriptions.addWithDefaultLabel(desc);
101  }
102 
103 } // namespace edm
104 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
edm::GenericConsumer::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: GenericConsumer.cc:82
edm::PRODUCT_TYPE
Definition: ProductKindOfType.h:5
edm::GenericConsumer::GenericConsumer
GenericConsumer(ParameterSet const &)
Definition: GenericConsumer.cc:37
edm::GenericConsumer::~GenericConsumer
~GenericConsumer() override=default
edm::errors::LogicError
Definition: EDMException.h:37
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:169
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::global::EDAnalyzerBase::callWhenNewProductsRegistered
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: EDAnalyzerBase.h:71
edm::InRun
Definition: BranchType.h:11
edm::GenericConsumer
Definition: GenericConsumer.cc:22
config
Definition: config.py:1
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionNode.h
edm::InEvent
Definition: BranchType.h:11
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
edm::InLumi
Definition: BranchType.h:11
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::GenericConsumer::analyze
void analyze(StreamID, Event const &, EventSetup const &) const override
Definition: GenericConsumer.cc:27
edm::EventSetup
Definition: EventSetup.h:58
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
edm::GenericConsumer::eventLabels_
std::vector< std::string > eventLabels_
Definition: GenericConsumer.cc:32
edm::GenericConsumer::runLabels_
std::vector< std::string > runLabels_
Definition: GenericConsumer.cc:34
Exception
Definition: hltDiff.cc:245
or
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
edm::BranchDescription
Definition: BranchDescription.h:32
ParameterSet.h
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:155
edm::TypeToGet
Definition: TypeToGet.h:32
edm::Event
Definition: Event.h:73
EDAnalyzer.h
edm::InputTag
Definition: InputTag.h:15
edm::GenericConsumer::lumiLabels_
std::vector< std::string > lumiLabels_
Definition: GenericConsumer.cc:33
edm::global::EDAnalyzer
Definition: EDAnalyzer.h:32
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87