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 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
edm::BranchDescription::productInstanceName
std::string const & productInstanceName() const
Definition: BranchDescription.h:81
edm::PRODUCT_TYPE
Definition: ProductKindOfType.h:5
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::SwitchProducer::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: SwitchProducer.cc:46
edm::SwitchProducer::SwitchProducer
SwitchProducer(ParameterSet const &iConfig)
Definition: SwitchProducer.cc:23
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::ProducerBase::callWhenNewProductsRegistered
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:84
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::BranchDescription::processName
std::string const & processName() const
Definition: BranchDescription.h:73
edm::BranchDescription::unwrappedTypeID
TypeID unwrappedTypeID() const
Definition: BranchDescription.h:98
edm::InEvent
Definition: BranchType.h:11
edm::SwitchProducer
Definition: SwitchProducer.cc:15
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
edm::SwitchProducer::produce
void produce(StreamID, Event &e, EventSetup const &c) const final
Definition: SwitchProducer.cc:20
edm::BranchDescription::branchType
BranchType const & branchType() const
Definition: BranchDescription.h:122
edm::EventSetup
Definition: EventSetup.h:58
edm::SwitchProducer::~SwitchProducer
~SwitchProducer() override=default
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::ProductRegistryHelper::produces
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
Definition: ProductRegistryHelper.h:108
edm::BranchDescription::moduleLabel
std::string const & moduleLabel() const
Definition: BranchDescription.h:72
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::BranchDescription
Definition: BranchDescription.h:32
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:155
EDProducer.h
edm::TypeToGet
Definition: TypeToGet.h:32
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15
edm::errors::UnimplementedFeature
Definition: EDMException.h:38
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37