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");
27  if (iBranch.moduleLabel() == chosenLabel) {
28  if (iBranch.branchType() != InEvent) {
30  << "SwitchProducer does not support non-event branches. Got " << iBranch.branchType()
31  << " for SwitchProducer with label " << moduleLabel << " whose chosen case is " << chosenLabel << ".";
32  }
33 
34  // With consumes, create the connection to the chosen case EDProducer for prefetching
36  edm::InputTag{iBranch.moduleLabel(), iBranch.productInstanceName(), iBranch.processName()});
37  // With produces, create a producer-like BranchDescription
38  // early-enough for it to be flagged as non-OnDemand in case
39  // the SwithcProducer is on a Path
40  this->produces(iBranch.unwrappedTypeID(), iBranch.productInstanceName()).setSwitchAlias(iBranch.moduleLabel());
41  }
42  });
43  }
44 
47  desc.add<std::vector<std::string>>("@all_cases");
48  desc.addUntracked<std::string>("@chosen_case");
49  descriptions.addDefault(desc);
50  }
51 } // namespace edm
52 
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
T getParameter(std::string const &) const
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:79
T getUntrackedParameter(std::string const &, T const &) const
BranchType const & branchType() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::string const & processName() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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)
HLT enums.
void produce(StreamID, Event &e, EventSetup const &c) const final
~SwitchProducer() override=default