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 
30  explicit ZllArbitrator(edm::ParameterSet const&);
31  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
32 
33 private:
35 };
36 
37 
39 // construction/destruction
41 
43  : srcZCand_{consumes<std::vector<reco::CompositeCandidate>>(iConfig.getParameter<edm::InputTag>("ZCandidateCollection"))}
44 {
45  produces<std::vector<reco::CompositeCandidate>>();
46 }
47 
48 
50 // implementation of member functions
52 
54 {
56  iEvent.getByToken(srcZCand_,zCandidates);
57 
58  auto bestZ = std::make_unique<std::vector<reco::CompositeCandidate>>();
59  if (!zCandidates->empty()) {
60  // If you're going to hard-code numbers, at least make them constexpr.
61  double constexpr ZmassPDG {91.18}; // GeV
62 
63  auto bestZCand = std::min_element(std::cbegin(*zCandidates), std::cend(*zCandidates),
64  [ZmassPDG](auto const& firstCand, auto const& secondCand) {
65  return std::abs(firstCand.mass()-ZmassPDG) < std::abs(secondCand.mass()-ZmassPDG);
66  });
67  bestZ->push_back(*bestZCand);
68  }
69 
70  iEvent.put(std::move(bestZ));
71 }
72 
74 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
#define constexpr
int iEvent
Definition: GenABIO.cc:230
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ZllArbitrator(edm::ParameterSet const &)
edm::EDGetTokenT< std::vector< reco::CompositeCandidate > > srcZCand_
def move(src, dest)
Definition: eostools.py:510