CMS 3D CMS Logo

ZllArbitrator.cc
Go to the documentation of this file.
6 
17 
19 
20 #include <algorithm>
21 #include <memory>
22 #include <vector>
23 
25 // class definition
28 public:
29  explicit ZllArbitrator(edm::ParameterSet const&);
30  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
31 
32 private:
34 };
35 
37 // construction/destruction
39 
41  : srcZCand_{consumes<std::vector<reco::CompositeCandidate>>(
42  iConfig.getParameter<edm::InputTag>("ZCandidateCollection"))} {
43  produces<std::vector<reco::CompositeCandidate>>();
44 }
45 
47 // implementation of member functions
49 
52  iEvent.getByToken(srcZCand_, zCandidates);
53 
54  auto bestZ = std::make_unique<std::vector<reco::CompositeCandidate>>();
55  if (!zCandidates->empty()) {
56  // If you're going to hard-code numbers, at least make them constexpr.
57  double constexpr ZmassPDG{91.18}; // GeV
58 
59  auto bestZCand = std::min_element(
60  std::cbegin(*zCandidates), std::cend(*zCandidates), [ZmassPDG](auto const& firstCand, auto const& secondCand) {
61  return std::abs(firstCand.mass() - ZmassPDG) < std::abs(secondCand.mass() - ZmassPDG);
62  });
63  bestZ->push_back(*bestZCand);
64  }
65 
66  iEvent.put(std::move(bestZ));
67 }
68 
70 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int iEvent
Definition: GenABIO.cc:224
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ZllArbitrator(edm::ParameterSet const &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< std::vector< reco::CompositeCandidate > > srcZCand_
def move(src, dest)
Definition: eostools.py:511