CMS 3D CMS Logo

TransformIntProducer.cc
Go to the documentation of this file.
4 #include "DataFormats/TestObjects/interface/ToyProducts.h"
6 
7 namespace edmtest {
8  class TransformIntProducer : public edm::global::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  noPut_(iPSet.getParameter<bool>("noPut")) {
15  putToken_ = produces<IntProduct>();
16  bool check = iPSet.getUntrackedParameter<bool>("checkTransformNotCalled");
17  registerTransform(
18  putToken_,
19  [offset = transformOffset_, check](auto const& iFrom) {
20  if (check) {
21  throw cms::Exception("TransformShouldNotBeCalled");
22  }
23  return IntProduct(iFrom.value + offset);
24  },
25  "transform");
26  }
27 
28  void produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const override {
29  if (not noPut_) {
30  iEvent.emplace(putToken_, iEvent.get(getToken_).value + offset_);
31  }
32  }
35  pset.add<edm::InputTag>("get");
36  pset.add<unsigned int>("offset", 0);
37  pset.add<unsigned int>("transformOffset", 1);
38  pset.addUntracked<bool>("checkTransformNotCalled", false);
39  pset.add<bool>("noPut", false);
40 
41  desc.addDefault(pset);
42  }
43 
44  private:
47  const unsigned int offset_;
48  const unsigned int transformOffset_;
49  const bool noPut_;
50  };
51 } // namespace edmtest
52 
const edm::EDGetTokenT< IntProduct > getToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
void produce(edm::StreamID, edm::Event &iEvent, edm::EventSetup const &) const override
int iEvent
Definition: GenABIO.cc:224
edm::EDPutTokenT< IntProduct > putToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TransformIntProducer(edm::ParameterSet const &iPSet)
static void fillDescriptions(edm::ConfigurationDescriptions &desc)
HLT enums.