ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14namespace CP {
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
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 " +
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
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
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()) {
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 }
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
Scalar eta() const
pseudorapidity method
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define x
Define macros for attributes used to control the static checker.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging)
float getCutValue(const float pt, const float eta) const
std::unique_ptr< TF1 > m_isoFunction
bool accept(const xAOD::IParticle &x) const override
std::unique_ptr< TH1F > m_binning
std::vector< std::unique_ptr< TGraph > > m_cutGraphs
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)
IsolationCondition(const std::string &name, xAOD::Iso::IsolationType isoType, const std::string &isoDecSuffix="")
const FloatAccessor & accessor_noCloseBy(unsigned int n=0) const
const std::string & name() const
unsigned int num_types() const
xAOD::Iso::IsolationType type(unsigned int n=0) const
const FloatAccessor & accessor(unsigned int n=0) const
static AuxTypeRegistry & instance()
Return the singleton registry instance.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
STL namespace.
setRcore setEtHad setFside pt
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.