Validation
RecoTau
plugins
ZllArbitrator.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/global/EDProducer.h
"
2
#include "
FWCore/Framework/interface/Event.h
"
3
#include "
FWCore/Framework/interface/MakerMacros.h
"
4
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
5
#include "
FWCore/Utilities/interface/InputTag.h
"
6
7
#include "
DataFormats/Common/interface/View.h
"
8
#include "
DataFormats/Math/interface/deltaR.h
"
9
#include "
DataFormats/MuonReco/interface/Muon.h
"
10
#include "
DataFormats/EgammaCandidates/interface/Electron.h
"
11
#include "
DataFormats/EgammaCandidates/interface/GsfElectron.h
"
12
#include "
DataFormats/EgammaCandidates/interface/Photon.h
"
13
#include "
DataFormats/JetReco/interface/Jet.h
"
14
#include "
DataFormats/TauReco/interface/PFTau.h
"
15
#include "
DataFormats/TauReco/interface/PFTauDiscriminator.h
"
16
#include "
DataFormats/TrackReco/interface/Track.h
"
17
18
#include "
CommonTools/Utils/interface/StringCutObjectSelector.h
"
19
20
#include <algorithm>
21
#include <memory>
22
#include <vector>
23
25
// class definition
27
class
ZllArbitrator
:
public
edm::global::EDProducer
<> {
28
public
:
29
explicit
ZllArbitrator
(
edm::ParameterSet
const
&);
30
void
produce
(
edm::StreamID
,
edm::Event
&,
edm::EventSetup
const
&)
const override
;
31
32
private
:
33
edm::EDGetTokenT<std::vector<reco::CompositeCandidate>
>
srcZCand_
;
34
};
35
37
// construction/destruction
39
40
ZllArbitrator::ZllArbitrator
(
edm::ParameterSet
const
& iConfig)
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
50
void
ZllArbitrator::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
edm::EventSetup
const
&)
const
{
51
edm::Handle<std::vector<reco::CompositeCandidate>
> zCandidates;
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
69
using
BestMassZArbitrationProducer
=
ZllArbitrator
;
70
71
DEFINE_FWK_MODULE
(
BestMassZArbitrationProducer
);
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
Generated for CMSSW Reference Manual by
1.8.16