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 
edm::StreamID
Definition: StreamID.h:30
ZllArbitrator::srcZCand_
edm::EDGetTokenT< std::vector< reco::CompositeCandidate > > srcZCand_
Definition: ZllArbitrator.cc:33
ZllArbitrator::produce
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition: ZllArbitrator.cc:50
Muon.h
PFTauDiscriminator.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
ZllArbitrator
Definition: ZllArbitrator.cc:27
Jet.h
edm::Handle
Definition: AssociativeIterator.h:50
ZllArbitrator::ZllArbitrator
ZllArbitrator(edm::ParameterSet const &)
Definition: ZllArbitrator.cc:40
MakerMacros.h
Photon.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GsfElectron.h
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
Electron.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
StringCutObjectSelector.h
PFTau.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
View.h
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15