CMS 3D CMS Logo

ExistingDictionaryTestModules.cc
Go to the documentation of this file.
1 // The purpose of this EDProducer is to test the existence of
2 // dictionaries for certain types, especially those from the standard
3 // library.
4 
10 #include "DataFormats/TestObjects/interface/ToyProducts.h"
11 
12 #include <cassert>
13 #include <memory>
14 #include <vector>
15 
16 namespace edm {
17  class EventSetup;
18 }
19 
20 namespace edmtest {
22  public:
24  : intToken_{produces<int>()},
25  vecUniqIntToken_{produces<std::vector<std::unique_ptr<int>>>()},
26  vecUniqIntProdToken_{produces<std::vector<std::unique_ptr<IntProduct>>>()} {}
27 
28  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
30  descriptions.addDefault(desc);
31  }
32 
33  void produce(edm::StreamID id, edm::Event& iEvent, edm::EventSetup const&) const override {
34  iEvent.emplace(intToken_, 1);
35 
36  std::vector<std::unique_ptr<int>> foo;
37  foo.emplace_back(std::make_unique<int>(1));
39 
40  std::vector<std::unique_ptr<IntProduct>> foo2;
41  foo2.emplace_back(std::make_unique<IntProduct>(1));
42  iEvent.emplace(vecUniqIntProdToken_, std::move(foo2));
43  }
44 
45  private:
49  };
50 
52  public:
54  : intToken_{consumes(iConfig.getParameter<edm::InputTag>("src"))},
55  vecUniqIntToken_{consumes(iConfig.getParameter<edm::InputTag>("src"))},
56  vecUniqIntProdToken_{consumes(iConfig.getParameter<edm::InputTag>("src"))},
57  testVecUniqInt_{iConfig.getParameter<bool>("testVecUniqInt")} {}
58 
59  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
61  desc.add<edm::InputTag>("src", edm::InputTag{"prod"});
62  desc.add<bool>("testVecUniqInt", true);
63  descriptions.addDefault(desc);
64  }
65 
66  void analyze(edm::StreamID id, edm::Event const& iEvent, edm::EventSetup const&) const override {
67  assert(iEvent.get(intToken_) == 1);
68 
69  const auto& vecUniqInt = iEvent.get(vecUniqIntToken_);
70  assert(vecUniqInt.size() == 1);
71  for (const auto& elem : vecUniqInt) {
72  if (testVecUniqInt_) {
73  assert(elem.get() != nullptr);
74  assert(*elem == 1);
75  } else {
76  if (elem) {
77  edm::LogError("ExistingDictionaryTestAnalyzer")
78  << "I am now getting a valid pointer, please update the test";
79  }
80  }
81  }
82 
83  const auto& vecUniqIntProd = iEvent.get(vecUniqIntProdToken_);
84  assert(vecUniqIntProd.size() == 1);
85  for (const auto& elem : vecUniqIntProd) {
86  assert(elem.get() != nullptr);
87  assert(elem->value == 1);
88  }
89  }
90 
91  private:
95  const bool testVecUniqInt_;
96  };
97 } // namespace edmtest
98 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ExistingDictionaryTestAnalyzer(edm::ParameterSet const &iConfig)
const edm::EDGetTokenT< std::vector< std::unique_ptr< int > > > vecUniqIntToken_
void produce(edm::StreamID id, edm::Event &iEvent, edm::EventSetup const &) const override
const edm::EDPutTokenT< std::vector< std::unique_ptr< int > > > vecUniqIntToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Log< level::Error, false > LogError
assert(be >=bs)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< std::vector< std::unique_ptr< IntProduct > > > vecUniqIntProdToken_
void analyze(edm::StreamID id, edm::Event const &iEvent, edm::EventSetup const &) const override
const edm::EDPutTokenT< std::vector< std::unique_ptr< IntProduct > > > vecUniqIntProdToken_
HLT enums.
def move(src, dest)
Definition: eostools.py:511