RecoEgamma
PhotonIdentification
plugins
cuts
PhoAnyPFIsoWithEAAndQuadScalingCut.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
PhoAnyPFIsoWithEAAndQuadScalingCut
:
public
CutApplicatorWithEventContentBase
{
6
public
:
7
PhoAnyPFIsoWithEAAndQuadScalingCut
(
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
_C3_EB
;
23
float
_C1_EE
;
24
float
_C2_EE
;
25
float
_C3_EE
;
26
// Configuration
27
float
_barrelCutOff
;
28
bool
_useRelativeIso
;
29
// Effective area constants
30
EffectiveAreas
_effectiveAreas
;
31
// The isolations computed upstream
32
edm::Handle<edm::ValueMap<float>
>
_anyPFIsoMap
;
33
// The rho
34
edm::Handle<double>
_rhoHandle
;
35
36
constexpr
static
char
anyPFIsoWithEA_
[] =
"anyPFIsoWithEA"
;
37
constexpr
static
char
rhoString_
[] =
"rho"
;
38
};
39
40
constexpr
char
PhoAnyPFIsoWithEAAndQuadScalingCut::anyPFIsoWithEA_
[];
41
constexpr
char
PhoAnyPFIsoWithEAAndQuadScalingCut::rhoString_
[];
42
43
DEFINE_EDM_PLUGIN
(
CutApplicatorFactory
,
PhoAnyPFIsoWithEAAndQuadScalingCut
,
"PhoAnyPFIsoWithEAAndQuadScalingCut"
);
44
45
PhoAnyPFIsoWithEAAndQuadScalingCut::PhoAnyPFIsoWithEAAndQuadScalingCut
(
const
edm::ParameterSet
&
c
)
46
:
CutApplicatorWithEventContentBase
(
c
),
47
_C1_EB(
c
.getParameter<double>(
"C1_EB"
)),
48
_C2_EB(
c
.getParameter<double>(
"C2_EB"
)),
49
_C3_EB(
c
.getParameter<double>(
"C3_EB"
)),
50
_C1_EE(
c
.getParameter<double>(
"C1_EE"
)),
51
_C2_EE(
c
.getParameter<double>(
"C2_EE"
)),
52
_C3_EE(
c
.getParameter<double>(
"C3_EE"
)),
53
_barrelCutOff(
c
.getParameter<double>(
"barrelCutOff"
)),
54
_useRelativeIso(
c
.getParameter<
bool
>(
"useRelativeIso"
)),
55
_effectiveAreas((
c
.getParameter<
edm
::FileInPath>(
"effAreasConfigFile"
)).
fullPath
()) {
56
edm::InputTag
maptag =
c
.getParameter<
edm::InputTag
>(
"anyPFIsoMap"
);
57
contentTags_
.emplace(
anyPFIsoWithEA_
, maptag);
58
59
edm::InputTag
rhoTag
=
c
.getParameter<
edm::InputTag
>(
"rho"
);
60
contentTags_
.emplace(
rhoString_
,
rhoTag
);
61
}
62
63
void
PhoAnyPFIsoWithEAAndQuadScalingCut::setConsumes
(
edm::ConsumesCollector
&
cc
) {
64
auto
anyPFIsoWithEA =
cc
.consumes<
edm::ValueMap<float>
>(
contentTags_
[
anyPFIsoWithEA_
]);
65
contentTokens_
.emplace(
anyPFIsoWithEA_
, anyPFIsoWithEA);
66
67
auto
rho
=
cc
.consumes<
double
>(
contentTags_
[
rhoString_
]);
68
contentTokens_
.emplace(
rhoString_
,
rho
);
69
}
70
71
void
PhoAnyPFIsoWithEAAndQuadScalingCut::getEventContent
(
const
edm::EventBase
&
ev
) {
72
ev
.getByLabel(
contentTags_
[
anyPFIsoWithEA_
],
_anyPFIsoMap
);
73
ev
.getByLabel(
contentTags_
[
rhoString_
],
_rhoHandle
);
74
}
75
76
CutApplicatorBase::result_type
PhoAnyPFIsoWithEAAndQuadScalingCut::operator()
(
const
reco::PhotonPtr
&
cand
)
const
{
77
// in case we are by-value
78
const
std::string
& inst_name =
contentTags_
.find(
anyPFIsoWithEA_
)->second.instance();
79
edm::Ptr<pat::Photon>
pat
(
cand
);
80
float
anyisoval = -1.0;
81
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
contains
(
cand
.id())) {
82
anyisoval = (*_anyPFIsoMap)[
cand
];
83
}
else
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
idSize
() == 1 &&
cand
.id() ==
edm::ProductID
()) {
84
// in case we have spoofed a ptr
85
//note this must be a 1:1 valuemap (only one product input)
86
anyisoval =
_anyPFIsoMap
->
begin
()[
cand
.key()];
87
}
else
if
(
_anyPFIsoMap
.
isValid
()) {
// throw an exception
88
anyisoval = (*_anyPFIsoMap)[
cand
];
89
}
90
91
// Figure out the cut value
92
// The value is generally pt-dependent: C1 + pt * C2
93
const
float
pt
=
cand
->pt();
94
95
// In this version of the isolation cut we apply
96
// exponential pt scaling to the barrel isolation cut,
97
// and linear pt scaling to the endcap isolation cut.
98
double
absEta =
std::abs
(
cand
->superCluster()->eta());
99
const
float
isolationCutValue =
100
(absEta <
_barrelCutOff
?
_C1_EB
+
pt
*
_C2_EB
+
pt
*
pt
*
_C3_EB
:
_C1_EE
+
pt
*
_C2_EE
+
pt
*
pt
*
_C3_EE
);
101
102
// Retrieve the variable value for this particle
103
float
anyPFIso =
_anyPFIsoMap
.
isValid
() ? anyisoval :
pat
->userFloat(inst_name);
104
105
// Apply pile-up correction
106
double
eA =
_effectiveAreas
.
getEffectiveArea
(absEta);
107
double
rho
= *
_rhoHandle
;
108
float
anyPFIsoWithEA =
std::max
(0.0, anyPFIso -
rho
* eA);
109
110
// Divide by pT if the relative isolation is requested
111
if
(
_useRelativeIso
)
112
anyPFIsoWithEA /=
pt
;
113
114
// Apply the cut and return the result
115
return
anyPFIsoWithEA < isolationCutValue;
116
}
117
118
double
PhoAnyPFIsoWithEAAndQuadScalingCut::value
(
const
reco::CandidatePtr
&
cand
)
const
{
119
reco::PhotonPtr
pho(
cand
);
120
121
// in case we are by-value
122
const
std::string
& inst_name =
contentTags_
.find(
anyPFIsoWithEA_
)->second.instance();
123
edm::Ptr<pat::Photon>
pat
(
cand
);
124
float
anyisoval = -1.0;
125
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
contains
(
cand
.id())) {
126
anyisoval = (*_anyPFIsoMap)[
cand
];
127
}
else
if
(
_anyPFIsoMap
.
isValid
() &&
_anyPFIsoMap
->
idSize
() == 1 &&
cand
.id() ==
edm::ProductID
()) {
128
// in case we have spoofed a ptr
129
//note this must be a 1:1 valuemap (only one product input)
130
anyisoval =
_anyPFIsoMap
->
begin
()[
cand
.key()];
131
}
else
if
(
_anyPFIsoMap
.
isValid
()) {
// throw an exception
132
anyisoval = (*_anyPFIsoMap)[
cand
];
133
}
134
135
// Figure out the cut value
136
// The value is generally pt-dependent: C1 + pt * C2
137
const
float
pt
= pho->pt();
138
139
// In this version of the isolation cut we apply
140
// exponential pt scaling to the barrel isolation cut,
141
// and linear pt scaling to the endcap isolation cut.
142
double
absEta =
std::abs
(pho->superCluster()->eta());
143
144
// Retrieve the variable value for this particle
145
float
anyPFIso =
_anyPFIsoMap
.
isValid
() ? anyisoval :
pat
->userFloat(inst_name);
146
147
// Apply pile-up correction
148
double
eA =
_effectiveAreas
.
getEffectiveArea
(absEta);
149
double
rho
= *
_rhoHandle
;
150
float
anyPFIsoWithEA =
std::max
(0.0, anyPFIso -
rho
* eA);
151
152
// Divide by pT if the relative isolation is requested
153
if
(
_useRelativeIso
)
154
anyPFIsoWithEA /=
pt
;
155
156
// Apply the cut and return the result
157
return
anyPFIsoWithEA;
158
}
PhoAnyPFIsoWithEAAndQuadScalingCut::_barrelCutOff
float _barrelCutOff
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:27
electrons_cff.bool
bool
Definition:
electrons_cff.py:366
PhoAnyPFIsoWithEAAndQuadScalingCut::_C1_EB
float _C1_EB
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:20
CutApplicatorBase::PHOTON
Definition:
CutApplicatorBase.h:47
DiDispStaMuonMonitor_cfi.pt
pt
Definition:
DiDispStaMuonMonitor_cfi.py:39
contentValuesFiles.fullPath
fullPath
Definition:
contentValuesFiles.py:64
edm
HLT enums.
Definition:
AlignableModifier.h:19
PhoAnyPFIsoWithEAAndQuadScalingCut::rhoString_
constexpr static char rhoString_[]
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:37
PhoAnyPFIsoWithEAAndQuadScalingCut::operator()
result_type operator()(const reco::PhotonPtr &) const final
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:76
PhoAnyPFIsoWithEAAndQuadScalingCut::getEventContent
void getEventContent(const edm::EventBase &) final
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:71
PhoAnyPFIsoWithEAAndQuadScalingCut::_C2_EE
float _C2_EE
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:24
PhoAnyPFIsoWithEAAndQuadScalingCut::_rhoHandle
edm::Handle< double > _rhoHandle
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:34
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:14993
candidate_functions::CandidateCut::result_type
bool result_type
Definition:
CandidateCut.h:11
Photon.h
PhoAnyPFIsoWithEAAndQuadScalingCut::_C2_EB
float _C2_EB
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:21
EffectiveAreas
Definition:
EffectiveAreas.h:7
PhoAnyPFIsoWithEAAndQuadScalingCut::_C1_EE
float _C1_EE
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:23
PhoAnyPFIsoWithEAAndQuadScalingCut::_useRelativeIso
bool _useRelativeIso
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:28
CutApplicatorWithEventContentBase.h
PhoAnyPFIsoWithEAAndQuadScalingCut::_C3_EE
float _C3_EE
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:25
PhoAnyPFIsoWithEAAndQuadScalingCut
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:5
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition:
PluginFactory.h:124
PhoAnyPFIsoWithEAAndQuadScalingCut::_C3_EB
float _C3_EB
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:22
DDAxes::rho
PhoAnyPFIsoWithEAAndQuadScalingCut::_anyPFIsoMap
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:32
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
pat
Definition:
HeavyIon.h:7
PhoAnyPFIsoWithEAAndQuadScalingCut::_effectiveAreas
EffectiveAreas _effectiveAreas
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:30
cc
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Ptr
Definition:
AssociationVector.h:31
PhoAnyPFIsoWithEAAndQuadScalingCut::PhoAnyPFIsoWithEAAndQuadScalingCut
PhoAnyPFIsoWithEAAndQuadScalingCut(const edm::ParameterSet &c)
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:45
edm::ValueMap::idSize
size_t idSize() const
Definition:
ValueMap.h:157
edm::ValueMap< float >
ev
bool ev
Definition:
Hydjet2Hadronizer.cc:97
CutApplicatorWithEventContentBase::contentTokens_
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
Definition:
CutApplicatorWithEventContentBase.h:40
edm::EventBase
Definition:
EventBase.h:46
PhoAnyPFIsoWithEAAndQuadScalingCut::anyPFIsoWithEA_
constexpr static char anyPFIsoWithEA_[]
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:36
EffectiveAreas::getEffectiveArea
const float getEffectiveArea(float eta) const
Definition:
EffectiveAreas.cc:44
PhoAnyPFIsoWithEAAndQuadScalingCut::candidateType
CandidateType candidateType() const final
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:16
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:56
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
PhoAnyPFIsoWithEAAndQuadScalingCut::setConsumes
void setConsumes(edm::ConsumesCollector &) final
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:63
CutApplicatorWithEventContentBase
Definition:
CutApplicatorWithEventContentBase.h:19
PhoAnyPFIsoWithEAAndQuadScalingCut::value
double value(const reco::CandidatePtr &cand) const final
Definition:
PhoAnyPFIsoWithEAAndQuadScalingCut.cc:118
Generated for CMSSW Reference Manual by
1.8.16