RecoEgamma
PhotonIdentification
plugins
cuts
PhoAnyPFIsoWithEACut.cc
Go to the documentation of this file.
1
#include "
PhysicsTools/SelectorUtils/interface/CutApplicatorWithEventContentBase.h
"
2
#include "
DataFormats/EgammaCandidates/interface/Photon.h
"
3
#include "
CommonTools/Egamma/interface/EffectiveAreas.h
"
4
5
class
PhoAnyPFIsoWithEACut
:
public
CutApplicatorWithEventContentBase
{
6
public
:
7
PhoAnyPFIsoWithEACut
(
const
edm::ParameterSet
&
c
);
8
9
result_type
operator()
(
const
reco::PhotonPtr
&)
const
final
;
10
11
void
setConsumes
(
edm::ConsumesCollector
&)
final
;
12
void
getEventContent
(
const
edm::EventBase
&)
final
;
13
14
double
value
(
const
reco::CandidatePtr
&
cand
)
const
final
;
15
16
CandidateType
candidateType
()
const
final {
return
PHOTON
; }
17
18
private
:
19
// Cut values
20
float
_C1_EB
;
21
float
_C2_EB
;
22
float
_C1_EE
;
23
float
_C2_EE
;
24
// Configuration
25
float
_barrelCutOff
;
26
bool
_useRelativeIso
;
27
// Effective area constants
28
EffectiveAreas
_effectiveAreas
;
29
// The isolations computed upstream
30
edm::Handle<edm::ValueMap<float>
>
_anyPFIsoMap
;
31
// The rho
32
edm::Handle<double>
_rhoHandle
;
33
34
constexpr
static
char
anyPFIsoWithEA_
[] =
"anyPFIsoWithEA"
;
35
constexpr
static
char
rhoString_
[] =
"rho"
;
36
};
37
38
constexpr
char
PhoAnyPFIsoWithEACut::anyPFIsoWithEA_
[];
39
constexpr
char
PhoAnyPFIsoWithEACut::rhoString_
[];
40
41
DEFINE_EDM_PLUGIN
(
CutApplicatorFactory
,
PhoAnyPFIsoWithEACut
,
"PhoAnyPFIsoWithEACut"
);
42
43
PhoAnyPFIsoWithEACut::PhoAnyPFIsoWithEACut
(
const
edm::ParameterSet
&
c
)
44
:
CutApplicatorWithEventContentBase
(
c
),
45
_C1_EB(
c
.getParameter<double>(
"C1_EB"
)),
46
_C2_EB(
c
.getParameter<double>(
"C2_EB"
)),
47
_C1_EE(
c
.getParameter<double>(
"C1_EE"
)),
48
_C2_EE(
c
.getParameter<double>(
"C2_EE"
)),
49
_barrelCutOff(
c
.getParameter<double>(
"barrelCutOff"
)),
50
_useRelativeIso(
c
.getParameter<
bool
>(
"useRelativeIso"
)),
51
_effectiveAreas((
c
.getParameter<
edm
::FileInPath>(
"effAreasConfigFile"
)).
fullPath
()) {
52
edm::InputTag
maptag =
c
.getParameter<
edm::InputTag
>(
"anyPFIsoMap"
);
53
contentTags_
.emplace(
anyPFIsoWithEA_
, maptag);
54
55
edm::InputTag
rhoTag
=
c
.getParameter<
edm::InputTag
>(
"rho"
);
56
contentTags_
.emplace(
rhoString_
,
rhoTag
);
57
}
58
59
void
PhoAnyPFIsoWithEACut::setConsumes
(
edm::ConsumesCollector
&
cc
) {
60
auto
anyPFIsoWithEA =
cc
.consumes<
edm::ValueMap<float>
>(
contentTags_
[
anyPFIsoWithEA_
]);
61
contentTokens_
.emplace(
anyPFIsoWithEA_
, anyPFIsoWithEA);
62
63
auto
rho
=
cc
.consumes<
double
>(
contentTags_
[
rhoString_
]);
64
contentTokens_
.emplace(
rhoString_
,
rho
);
65
}
66
67
void
PhoAnyPFIsoWithEACut::getEventContent
(
const
edm::EventBase
&
ev
) {
68
ev
.getByLabel(
contentTags_
[
anyPFIsoWithEA_
],
_anyPFIsoMap
);
69
ev
.getByLabel(
contentTags_
[
rhoString_
],
_rhoHandle
);
70
}
71
72
CutApplicatorBase::result_type
PhoAnyPFIsoWithEACut::operator()
(
const
reco::PhotonPtr
&
cand
)
const
{
73
// in case we are by-value
74
const
std::string
& inst_name =
contentTags_
.find(
anyPFIsoWithEA_
)->second.instance();
75
edm::Ptr<pat::Photon>
pat
(
cand
);
76
float
anyisoval = -1.0;
77
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
contains
(
cand
.id())) {
78
anyisoval = (*_anyPFIsoMap)[
cand
];
79
}
else
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
idSize
() == 1 &&
cand
.id() ==
edm::ProductID
()) {
80
// in case we have spoofed a ptr
81
//note this must be a 1:1 valuemap (only one product input)
82
anyisoval =
_anyPFIsoMap
->
begin
()[
cand
.key()];
83
}
else
if
(
_anyPFIsoMap
.
isValid
()) {
// throw an exception
84
anyisoval = (*_anyPFIsoMap)[
cand
];
85
}
86
87
// Figure out the cut value
88
// The value is generally pt-dependent: C1 + pt * C2
89
const
double
absEta =
std::abs
(
cand
->superCluster()->eta());
90
const
float
anyPFIsoWithEACutValue =
91
(absEta <
_barrelCutOff
?
_C1_EB
+
cand
->pt() *
_C2_EB
:
_C1_EE
+
cand
->pt() *
_C2_EE
);
92
93
// Retrieve the variable value for this particle
94
float
anyPFIso =
_anyPFIsoMap
.
isValid
() ? anyisoval :
pat
->userFloat(inst_name);
95
96
// Apply pile-up correction
97
const
double
eA =
_effectiveAreas
.
getEffectiveArea
(absEta);
98
const
double
rho
=
_rhoHandle
.
isValid
() ? *
_rhoHandle
: 0;
99
const
float
anyPFIsoWithEA =
std::max
(0.0, anyPFIso -
rho
* eA);
100
101
// Apply the cut and return the result
102
// Scale by pT if the relative isolation is requested but avoid division by 0
103
return
anyPFIsoWithEA < anyPFIsoWithEACutValue * (
_useRelativeIso
?
cand
->pt() : 1.);
104
}
105
106
double
PhoAnyPFIsoWithEACut::value
(
const
reco::CandidatePtr
&
cand
)
const
{
107
reco::PhotonPtr
pho(
cand
);
108
109
// in case we are by-value
110
const
std::string
& inst_name =
contentTags_
.find(
anyPFIsoWithEA_
)->second.instance();
111
edm::Ptr<pat::Photon>
pat
(
cand
);
112
float
anyisoval = -1.0;
113
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
contains
(
cand
.id())) {
114
anyisoval = (*_anyPFIsoMap)[
cand
];
115
}
else
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
idSize
() == 1 &&
cand
.id() ==
edm::ProductID
()) {
116
// in case we have spoofed a ptr
117
//note this must be a 1:1 valuemap (only one product input)
118
anyisoval =
_anyPFIsoMap
->
begin
()[
cand
.key()];
119
}
else
if
(
_anyPFIsoMap
.
isValid
()) {
// throw an exception
120
anyisoval = (*_anyPFIsoMap)[
cand
];
121
}
122
123
// Figure out the cut value
124
// The value is generally pt-dependent: C1 + pt * C2
125
double
absEta =
std::abs
(pho->superCluster()->eta());
126
127
// Retrieve the variable value for this particle
128
float
anyPFIso =
_anyPFIsoMap
.
isValid
() ? anyisoval :
pat
->userFloat(inst_name);
129
130
// Apply pile-up correction
131
double
eA =
_effectiveAreas
.
getEffectiveArea
(absEta);
132
double
rho
= *
_rhoHandle
;
133
float
anyPFIsoWithEA =
std::max
(0.0, anyPFIso -
rho
* eA);
134
135
// Divide by pT if the relative isolation is requested
136
if
(
_useRelativeIso
)
137
anyPFIsoWithEA /= pho->pt();
138
139
// Apply the cut and return the result
140
return
anyPFIsoWithEA;
141
}
PhoAnyPFIsoWithEACut::_C1_EE
float _C1_EE
Definition:
PhoAnyPFIsoWithEACut.cc:22
PhoAnyPFIsoWithEACut::_anyPFIsoMap
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
Definition:
PhoAnyPFIsoWithEACut.cc:30
electrons_cff.bool
bool
Definition:
electrons_cff.py:366
PhoAnyPFIsoWithEACut::_C2_EE
float _C2_EE
Definition:
PhoAnyPFIsoWithEACut.cc:23
CutApplicatorBase::PHOTON
Definition:
CutApplicatorBase.h:47
contentValuesFiles.fullPath
fullPath
Definition:
contentValuesFiles.py:64
edm
HLT enums.
Definition:
AlignableModifier.h:19
PhoAnyPFIsoWithEACut::setConsumes
void setConsumes(edm::ConsumesCollector &) final
Definition:
PhoAnyPFIsoWithEACut.cc:59
PhoAnyPFIsoWithEACut::getEventContent
void getEventContent(const edm::EventBase &) final
Definition:
PhoAnyPFIsoWithEACut.cc:67
PhoAnyPFIsoWithEACut::_C2_EB
float _C2_EB
Definition:
PhoAnyPFIsoWithEACut.cc:21
EffectiveAreas.h
watchdog.const
const
Definition:
watchdog.py:83
edm::Handle
Definition:
AssociativeIterator.h:50
CutApplicatorWithEventContentBase::contentTags_
std::unordered_map< std::string, edm::InputTag > contentTags_
Definition:
CutApplicatorWithEventContentBase.h:35
HLT_FULL_cff.rhoTag
rhoTag
Definition:
HLT_FULL_cff.py:14988
candidate_functions::CandidateCut::result_type
bool result_type
Definition:
CandidateCut.h:11
Photon.h
PhoAnyPFIsoWithEACut::anyPFIsoWithEA_
constexpr static char anyPFIsoWithEA_[]
Definition:
PhoAnyPFIsoWithEACut.cc:34
EffectiveAreas
Definition:
EffectiveAreas.h:7
PhoAnyPFIsoWithEACut::value
double value(const reco::CandidatePtr &cand) const final
Definition:
PhoAnyPFIsoWithEACut.cc:106
CutApplicatorWithEventContentBase.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition:
PluginFactory.h:124
DDAxes::rho
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition:
ParameterSet.h:47
CutApplicatorBase::CandidateType
CandidateType
Definition:
CutApplicatorBase.h:47
SiStripPI::max
Definition:
SiStripPayloadInspectorHelper.h:169
edmplugin::PluginFactory
Definition:
PluginFactory.h:34
edm::ValueMap::begin
const_iterator begin() const
Definition:
ValueMap.h:229
cand
Definition:
decayParser.h:32
PhoAnyPFIsoWithEACut::_rhoHandle
edm::Handle< double > _rhoHandle
Definition:
PhoAnyPFIsoWithEACut.cc:32
pat
Definition:
HeavyIon.h:7
PhoAnyPFIsoWithEACut::rhoString_
constexpr static char rhoString_[]
Definition:
PhoAnyPFIsoWithEACut.cc:35
cc
edm::Ptr
Definition:
AssociationVector.h:31
PhoAnyPFIsoWithEACut
Definition:
PhoAnyPFIsoWithEACut.cc:5
PhoAnyPFIsoWithEACut::operator()
result_type operator()(const reco::PhotonPtr &) const final
Definition:
PhoAnyPFIsoWithEACut.cc:72
PhoAnyPFIsoWithEACut::PhoAnyPFIsoWithEACut
PhoAnyPFIsoWithEACut(const edm::ParameterSet &c)
Definition:
PhoAnyPFIsoWithEACut.cc:43
edm::ValueMap::idSize
size_t idSize() const
Definition:
ValueMap.h:157
edm::ValueMap< float >
ev
bool ev
Definition:
Hydjet2Hadronizer.cc:95
CutApplicatorWithEventContentBase::contentTokens_
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
Definition:
CutApplicatorWithEventContentBase.h:40
edm::EventBase
Definition:
EventBase.h:46
PhoAnyPFIsoWithEACut::_effectiveAreas
EffectiveAreas _effectiveAreas
Definition:
PhoAnyPFIsoWithEACut.cc:28
PhoAnyPFIsoWithEACut::candidateType
CandidateType candidateType() const final
Definition:
PhoAnyPFIsoWithEACut.cc:16
EffectiveAreas::getEffectiveArea
const float getEffectiveArea(float eta) const
Definition:
EffectiveAreas.cc:44
PhoAnyPFIsoWithEACut::_C1_EB
float _C1_EB
Definition:
PhoAnyPFIsoWithEACut.cc:20
PhoAnyPFIsoWithEACut::_useRelativeIso
bool _useRelativeIso
Definition:
PhoAnyPFIsoWithEACut.cc:26
edm::ValueMap::contains
bool contains(ProductID id) const
Definition:
ValueMap.h:155
funct::abs
Abs< T >::type abs(const T &t)
Definition:
Abs.h:22
c
auto & c
Definition:
CAHitNtupletGeneratorKernelsImpl.h:46
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:70
edm::InputTag
Definition:
InputTag.h:15
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
edm::ProductID
Definition:
ProductID.h:27
CutApplicatorWithEventContentBase
Definition:
CutApplicatorWithEventContentBase.h:19
PhoAnyPFIsoWithEACut::_barrelCutOff
float _barrelCutOff
Definition:
PhoAnyPFIsoWithEACut.cc:25
Generated for CMSSW Reference Manual by
1.8.16