CMS 3D CMS Logo

SwitchProducer.cc
Go to the documentation of this file.
4 
5 namespace edm {
16  public:
17  explicit SwitchProducer(ParameterSet const& iConfig);
18  ~SwitchProducer() override = default;
19  static void fillDescriptions(ConfigurationDescriptions& descriptions);
20  void produce(StreamID, Event& e, EventSetup const& c) const final {}
21  };
22 
24  auto const& moduleLabel = iConfig.getParameter<std::string>("@module_label");
25  auto const& chosenLabel = iConfig.getUntrackedParameter<std::string>("@chosen_case");
26  auto const& processName = iConfig.getUntrackedParameter<std::string>("@process_name");
28  if (iBranch.moduleLabel() == chosenLabel and iBranch.processName() == processName) {
29  if (iBranch.branchType() != InEvent) {
31  << "SwitchProducer does not support non-event branches. Got " << iBranch.branchType()
32  << " for SwitchProducer with label " << moduleLabel << " whose chosen case is " << chosenLabel << ".";
33  }
34 
35  // With consumes, create the connection to the chosen case EDProducer for prefetching
37  edm::InputTag{iBranch.moduleLabel(), iBranch.productInstanceName(), iBranch.processName()});
38  // With produces, create a producer-like BranchDescription
39  // early-enough for it to be flagged as non-OnDemand in case
40  // the SwithcProducer is on a Path
41  this->produces(iBranch.unwrappedTypeID(), iBranch.productInstanceName()).setSwitchAlias(iBranch.moduleLabel());
42  }
43  });
44  }
45 
48  desc.add<std::vector<std::string>>("@all_cases");
49  desc.addUntracked<std::string>("@chosen_case");
50  desc.addUntracked<std::string>("@process_name");
51  descriptions.addDefault(desc);
52  }
53 } // namespace edm
54 
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:88
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
BranchType const & branchType() const
TypeID unwrappedTypeID() const
std::string const & processName() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
SwitchProducer(ParameterSet const &iConfig)
std::string const & productInstanceName() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLT enums.
void produce(StreamID, Event &e, EventSetup const &c) const final
std::string const & moduleLabel() const
~SwitchProducer() override=default