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<TGraph*>&
19 cutGraphs, // std::vector<std::unique_ptr<TGraph>> cutGraphs,
20 std::unique_ptr<TH1F> binning, const std::string& isoDecSuffix,
21 bool invertCut)
22 : IsolationCondition(name, isoTypes, isoDecSuffix),
23 m_cutGraphs(cutGraphs),
24 m_isoFunction(std::move(isoFunction)),
25 m_binning(std::move(binning)),
26 m_invertCut(invertCut) {}
27
29
30 const float cutValue = getCutValue(x.pt(), x.eta());
31 std::vector<double> isoVars(num_types(), 0);
32
33 for (unsigned int iacc = 0; iacc < num_types(); ++iacc) {
34 const FloatAccessor& acc = accessor(iacc);
35
36 if (!acc.isAvailable(x)) {
37 // Temporary fix for missing closeByCorr variables if no primary vertex
38 // exists for the event If closeByCorr variable does not exist, fallback
39 // to the standard isolation variable 2025/02
40 const FloatAccessor& acc_noCloseBy = accessor_noCloseBy(iacc);
41 if (acc_noCloseBy.isAvailable(x)) {
42 isoVars[iacc] = acc_noCloseBy(x);
43 } else {
44 ATH_MSG_WARNING(__FILE__
45 << ":" << __LINE__ << "Accessor "
46 << SG::AuxTypeRegistry::instance().getName(acc.auxid())
47 << " is not available. Expected when using primary "
48 "AODs, post-p3793 derivations (only for *FixedRad "
49 "or FixedCutPflow* for electrons), "
50 << " pre-p3517 derivations (only for FC*), or "
51 "pre-p3830 derivations (for other electron WPs)");
52 if (!m_isoDecSuffix.empty())
53 throw std::runtime_error(
54 "IsolationConditionCombined: IsolationSelectionTool property "
55 "'IsoDecSuffix' is set to " +
57 ". Must run on derivation made with IsolationCloseByCorrection "
58 "to create the isolation variables with this suffix, or remove "
59 "'IsoDecSuffix'. ");
60 isoVars[iacc] = FLT_MAX;
61 }
62 } else
63 isoVars[iacc] = acc(x);
64 }
65
66 // In general TF1::EvalPar is non-const/not thread-safe. But for the special
67 // case of using it as TFormula it can be considered const/safe. It would be
68 // safer to change the interface to not allow a generic TF1.
69 TF1* f ATLAS_THREAD_SAFE = m_isoFunction.get();
70 const float isoValue = f->EvalPar(isoVars.data());
71
72 ATH_MSG_DEBUG("PLIV Isolation values of electron %.3f " << isoValue);
73
74 if (!m_invertCut)
75 return isoValue <= cutValue;
76 return isoValue > cutValue;
77}
78
80 const float cutValue = getCutValue(x.pt, x.eta);
81 std::vector<double> isoVars;
82 for (unsigned int itype = 0; itype < num_types(); ++itype)
83 isoVars.push_back(x.isolationValues[type(itype)]);
84 TF1* f ATLAS_THREAD_SAFE = m_isoFunction.get();
85 const float isoValue = f->EvalPar(isoVars.data());
86
87 ATH_MSG_DEBUG("PLIV Isolation values of electron %.3f " << isoValue);
88
89 if (!m_invertCut)
90 return isoValue <= cutValue;
91 return isoValue > cutValue;
92}
93
95 const float eta) const {
96 //
97 int bin = m_binning->GetXaxis()->FindBin(fabs(eta));
98 ATH_MSG_DEBUG(Form(" Electron (eta=%.3f) falls into bin %d", eta, bin - 1));
99
100 if (bin <= 0 || (unsigned int)bin > m_cutGraphs.size()) {
102 "Stored binning in file does not comply with binning of graphs for "
103 "working point "
104 << this->name() << "! Please contact the IFF group");
105 return -999;
106 }
108 Form(" Electron cut value %.3f for pt %.3f as calculated from graph %s",
109 (m_cutGraphs[bin - 1])->Eval(pt / 1000.), pt / 1000.,
110 (m_cutGraphs[bin - 1])->GetName()));
111
112 return (m_cutGraphs[bin - 1])->Eval(pt / 1000.);
113}
114
115} // 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::vector< TGraph * > m_cutGraphs
std::unique_ptr< TH1F > m_binning
IsolationConditionGraph(const std::string &name, const std::vector< std::string > &isoType, std::unique_ptr< TF1 > isoFunction, std::vector< 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.