CMS 3D CMS Logo

TransformIntStreamProducer.cc
Go to the documentation of this file.
4 #include "DataFormats/TestObjects/interface/ToyProducts.h"
6 
7 namespace edmtest {
8  class TransformIntStreamProducer : public edm::stream::EDProducer<edm::Transformer> {
9  public:
11  : getToken_(consumes(iPSet.getParameter<edm::InputTag>("get"))),
12  offset_(iPSet.getParameter<unsigned int>("offset")),
13  transformOffset_(iPSet.getParameter<unsigned int>("transformOffset")) {
14  putToken_ = produces<IntProduct>();
15  bool check = iPSet.getUntrackedParameter<bool>("checkTransformNotCalled");
16  registerTransform(
17  putToken_,
18  [offset = transformOffset_, check](auto const& iFrom) {
19  if (check) {
20  throw cms::Exception("TransformShouldNotBeCalled");
21  }
22  return IntProduct(iFrom.value + offset);
23  },
24  "transform");
25  }
26 
27  void produce(edm::Event& iEvent, edm::EventSetup const&) override {
28  iEvent.emplace(putToken_, iEvent.get(getToken_).value + offset_);
29  }
32  pset.add<edm::InputTag>("get");
33  pset.add<unsigned int>("offset", 0);
34  pset.add<unsigned int>("transformOffset", 1);
35  pset.addUntracked<bool>("checkTransformNotCalled", false);
36 
37  desc.addDefault(pset);
38  }
39 
40  private:
43  const unsigned int offset_;
44  const unsigned int transformOffset_;
45  };
46 } // namespace edmtest
47 
void produce(edm::Event &iEvent, edm::EventSetup const &) override
T getUntrackedParameter(std::string const &, T const &) const
TransformIntStreamProducer(edm::ParameterSet const &iPSet)
int iEvent
Definition: GenABIO.cc:224
static void fillDescriptions(edm::ConfigurationDescriptions &desc)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< IntProduct > getToken_
HLT enums.
edm::EDPutTokenT< IntProduct > putToken_