ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
IsolationSelection
Root
IsolationConditionGraph.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <TF2.h>
6
#include <TGraph2D.h>
7
8
#include <algorithm>
9
#include <cmath>
10
11
#include "
CxxUtils/checker_macros.h
"
12
#include "
IsolationSelection/IsolationConditionGraph.h
"
13
14
namespace
CP
{
15
IsolationConditionGraph::IsolationConditionGraph
(
16
const
std::string&
name
,
const
std::vector<std::string>& isoTypes,
17
std::unique_ptr<TF1> isoFunction,
18
std::vector<std::unique_ptr<TGraph>>&& cutGraphs,
19
std::unique_ptr<TH1F> binning,
const
std::string& isoDecSuffix,
20
bool
invertCut)
21
:
IsolationCondition
(
name
, isoTypes, isoDecSuffix),
22
m_cutGraphs
(
std
::move(cutGraphs)),
23
m_isoFunction
(
std
::move(isoFunction)),
24
m_binning
(
std
::move(binning)),
25
m_invertCut
(invertCut) {}
26
27
bool
IsolationConditionGraph::accept
(
const
xAOD::IParticle
&
x
)
const
{
28
29
const
float
cutValue =
getCutValue
(
x
.pt(),
x
.eta());
30
std::vector<double> isoVars(
num_types
(), 0);
31
32
for
(
unsigned
int
iacc = 0; iacc <
num_types
(); ++iacc) {
33
const
FloatAccessor
&
acc
=
accessor
(iacc);
34
35
if
(!
acc
.isAvailable(
x
)) {
36
// Temporary fix for missing closeByCorr variables if no primary vertex
37
// exists for the event If closeByCorr variable does not exist, fallback
38
// to the standard isolation variable 2025/02
39
const
FloatAccessor
& acc_noCloseBy =
accessor_noCloseBy
(iacc);
40
if
(acc_noCloseBy.isAvailable(
x
)) {
41
isoVars[iacc] = acc_noCloseBy(
x
);
42
}
else
{
43
ATH_MSG_WARNING
(__FILE__
44
<<
":"
<< __LINE__ <<
"Accessor "
45
<<
SG::AuxTypeRegistry::instance
().getName(
acc
.auxid())
46
<<
" is not available. Expected when using primary "
47
"AODs, post-p3793 derivations (only for *FixedRad "
48
"or FixedCutPflow* for electrons), "
49
<<
" pre-p3517 derivations (only for FC*), or "
50
"pre-p3830 derivations (for other electron WPs)"
);
51
if
(!
m_isoDecSuffix
.empty())
52
throw
std::runtime_error(
53
"IsolationConditionCombined: IsolationSelectionTool property "
54
"'IsoDecSuffix' is set to "
+
55
m_isoDecSuffix
+
56
". Must run on derivation made with IsolationCloseByCorrection "
57
"to create the isolation variables with this suffix, or remove "
58
"'IsoDecSuffix'. "
);
59
isoVars[iacc] = FLT_MAX;
60
}
61
}
else
62
isoVars[iacc] =
acc
(
x
);
63
}
64
65
// In general TF1::EvalPar is non-const/not thread-safe. But for the special
66
// case of using it as TFormula it can be considered const/safe. It would be
67
// safer to change the interface to not allow a generic TF1.
68
TF1* f
ATLAS_THREAD_SAFE
=
m_isoFunction
.get();
69
const
float
isoValue = f->EvalPar(isoVars.data());
70
71
ATH_MSG_DEBUG
(
"PLIV Isolation values of electron %.3f "
<< isoValue);
72
73
if
(!
m_invertCut
)
74
return
isoValue <= cutValue;
75
return
isoValue > cutValue;
76
}
77
78
bool
IsolationConditionGraph::accept
(
const
strObj
&
x
)
const
{
79
const
float
cutValue =
getCutValue
(
x
.pt,
x
.eta);
80
std::vector<double> isoVars;
81
for
(
unsigned
int
itype = 0; itype <
num_types
(); ++itype)
82
isoVars.push_back(
x
.isolationValues[
type
(itype)]);
83
TF1* f
ATLAS_THREAD_SAFE
=
m_isoFunction
.get();
84
const
float
isoValue = f->EvalPar(isoVars.data());
85
86
ATH_MSG_DEBUG
(
"PLIV Isolation values of electron %.3f "
<< isoValue);
87
88
if
(!
m_invertCut
)
89
return
isoValue <= cutValue;
90
return
isoValue > cutValue;
91
}
92
93
float
IsolationConditionGraph::getCutValue
(
const
float
pt
,
94
const
float
eta
)
const
{
95
//
96
int
bin
=
m_binning
->GetXaxis()->FindBin(fabs(
eta
));
97
ATH_MSG_DEBUG
(Form(
" Electron (eta=%.3f) falls into bin %d"
,
eta
,
bin
- 1));
98
99
if
(
bin
<= 0 || (
unsigned
int
)
bin
>
m_cutGraphs
.size()) {
100
ATH_MSG_DEBUG
(
101
"Stored binning in file does not comply with binning of graphs for "
102
"working point "
103
<< this->
name
() <<
"! Please contact the IFF group"
);
104
return
-999;
105
}
106
ATH_MSG_DEBUG
(
107
Form(
" Electron cut value %.3f for pt %.3f as calculated from graph %s"
,
108
(
m_cutGraphs
[
bin
- 1])->Eval(
pt
/ 1000.),
pt
/ 1000.,
109
(
m_cutGraphs
[
bin
- 1])->GetName()));
110
111
return
(
m_cutGraphs
[
bin
- 1])->Eval(
pt
/ 1000.);
112
}
113
114
}
// namespace CP
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:28
IsolationConditionGraph.h
x
#define x
checker_macros.h
Define macros for attributes used to control the static checker.
AthMessaging::ATLAS_THREAD_SAFE
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging).
Definition
AthMessaging.h:141
CP::IsolationConditionGraph::getCutValue
float getCutValue(const float pt, const float eta) const
Definition
IsolationConditionGraph.cxx:93
CP::IsolationConditionGraph::m_invertCut
bool m_invertCut
Definition
IsolationConditionGraph.h:33
CP::IsolationConditionGraph::m_isoFunction
std::unique_ptr< TF1 > m_isoFunction
Definition
IsolationConditionGraph.h:31
CP::IsolationConditionGraph::accept
bool accept(const xAOD::IParticle &x) const override
Definition
IsolationConditionGraph.cxx:27
CP::IsolationConditionGraph::m_binning
std::unique_ptr< TH1F > m_binning
Definition
IsolationConditionGraph.h:32
CP::IsolationConditionGraph::m_cutGraphs
std::vector< std::unique_ptr< TGraph > > m_cutGraphs
Definition
IsolationConditionGraph.h:30
CP::IsolationConditionGraph::IsolationConditionGraph
IsolationConditionGraph(const std::string &name, const std::vector< std::string > &isoType, std::unique_ptr< TF1 > isoFunction, std::vector< std::unique_ptr< TGraph > > &&cutGraphs, std::unique_ptr< TH1F > binning, const std::string &isoDecSuffix="", bool invertCut=false)
Definition
IsolationConditionGraph.cxx:15
CP::IsolationCondition::IsolationCondition
IsolationCondition(const std::string &name, xAOD::Iso::IsolationType isoType, const std::string &isoDecSuffix="")
Definition
IsolationCondition.cxx:36
CP::IsolationCondition::m_isoDecSuffix
std::string m_isoDecSuffix
Definition
IsolationCondition.h:58
CP::IsolationCondition::accessor_noCloseBy
const FloatAccessor & accessor_noCloseBy(unsigned int n=0) const
Definition
IsolationCondition.cxx:45
CP::IsolationCondition::name
const std::string & name() const
Definition
IsolationCondition.cxx:42
CP::IsolationCondition::num_types
unsigned int num_types() const
Definition
IsolationCondition.cxx:41
CP::IsolationCondition::type
xAOD::Iso::IsolationType type(unsigned int n=0) const
Definition
IsolationCondition.cxx:43
CP::IsolationCondition::accessor
const FloatAccessor & accessor(unsigned int n=0) const
Definition
IsolationCondition.cxx:44
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition
AuxTypeRegistry.cxx:640
bin
Definition
BinsDiffFromStripMedian.h:43
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CP::FloatAccessor
SG::AuxElement::ConstAccessor< float > FloatAccessor
Definition
PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:22
std
STL namespace.
xAOD::pt
setRcore setEtHad setFside pt
Definition
TrigPhoton_v1.cxx:106
xAOD::acc
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
CP::strObj
Definition
IsolationCondition.h:23
Generated on
for ATLAS Offline Software by
1.17.0