CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:85
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
BranchType const & branchType() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::string const & processName() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void addDefault(ParameterSetDescription const &psetDescription)
std::string const & moduleLabel() const
std::string const & productInstanceName() const
static void fillDescriptions(ConfigurationDescriptions &descriptions)
SwitchProducer(ParameterSet const &iConfig)
TypeID unwrappedTypeID() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(StreamID, Event &e, EventSetup const &c) const final
~SwitchProducer() override=default