File indexing completed on 2024-12-21 03:54:41
0001 #include "FWCore/Framework/interface/global/EDProducer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008
0009 #include "FWCore/Utilities/interface/EDPutToken.h"
0010
0011 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0012
0013 class BranchIDListsModifierProducer : public edm::global::EDProducer<> {
0014 public:
0015 BranchIDListsModifierProducer(edm::ParameterSet const& iPSet);
0016
0017 void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0018
0019 static void fillDescriptions(edm::ConfigurationDescriptions& iDesc);
0020
0021 private:
0022 edm::EDPutTokenT<int> const token_;
0023 edm::EDPutTokenT<edmtest::ATransientIntProduct> extraToken_;
0024 bool const extraProduct_;
0025 };
0026
0027 BranchIDListsModifierProducer::BranchIDListsModifierProducer(edm::ParameterSet const& iPSet)
0028 : token_(produces()), extraProduct_(iPSet.getUntrackedParameter<bool>("makeExtraProduct")) {
0029 if (extraProduct_) {
0030 extraToken_ = produces("extra");
0031 }
0032 }
0033
0034 void BranchIDListsModifierProducer::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const {
0035 iEvent.emplace(token_, 1);
0036 if (extraProduct_) {
0037 iEvent.emplace(extraToken_, 2);
0038 }
0039 }
0040
0041 void BranchIDListsModifierProducer::fillDescriptions(edm::ConfigurationDescriptions& iDesc) {
0042 edm::ParameterSetDescription ps;
0043 ps.setComment(
0044 "Module which can cause the BranchIDLists to change even when the top level PSet remains the same.\n"
0045 "Used for multi-file merge tests.");
0046
0047 ps.addUntracked<bool>("makeExtraProduct", false)->setComment("If set to true will produce an extra product");
0048
0049 iDesc.addDefault(ps);
0050 }
0051
0052 DEFINE_FWK_MODULE(BranchIDListsModifierProducer);