CMS 3D CMS Logo

OtherThingRefComparer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include "DataFormats/TestObjects/interface/OtherThing.h"
3 #include "DataFormats/TestObjects/interface/OtherThingCollection.h"
13 
14 namespace edmtest {
15 
17  public:
19 
20  void analyze(edm::Event const& e, edm::EventSetup const& c) override;
21 
22  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
23 
24  private:
27  };
28 
30  : token1_(consumes<OtherThingCollection>(pset.getUntrackedParameter<edm::InputTag>("first"))),
31  token2_(consumes<OtherThingCollection>(pset.getUntrackedParameter<edm::InputTag>("second"))) {}
32 
34  auto const& t1_ = e.get(token1_);
35  auto const& t2_ = e.get(token2_);
36 
37  assert(t1_.size() == t2_.size());
38 
39  {
40  auto iter2 = t2_.begin();
41  for (auto const& o1 : t1_) {
42  if (o1.ref != iter2->ref) {
43  throw cms::Exception("RefCompareFailure")
44  << "edm::Refs are not equal" << o1.ref.id() << " " << iter2->ref.id();
45  }
46  ++iter2;
47  }
48  }
49 
50  {
51  auto iter2 = t2_.begin();
52  for (auto const& o1 : t1_) {
53  if (o1.ptr != iter2->ptr) {
54  throw cms::Exception("RefCompareFailure")
55  << "edm::Ptrs are not equal" << o1.ptr.id() << " " << iter2->ptr.id();
56  }
57  ++iter2;
58  }
59  }
60  }
61 
64  desc.addUntracked<edm::InputTag>("first", edm::InputTag("OtherThing", "testUserTag"))
65  ->setComment("Where to get the first OtherThingCollection");
66  desc.addUntracked<edm::InputTag>("second", edm::InputTag("OtherThing", "testUserTag"))
67  ->setComment("Where to get the second OtherThingCollection");
68  descriptions.add("otherThingRefComparer", desc);
69  }
70 
71 } // namespace edmtest
edm::EDGetTokenT< OtherThingCollection > token1_
assert(be >=bs)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< OtherThingCollection > token2_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
OtherThingRefComparer(edm::ParameterSet const &pset)
void analyze(edm::Event const &e, edm::EventSetup const &c) override