Loading [MathJax]/jax/input/TeX/config.js
ATLAS Offline Software
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
v
w
x
z
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
v
w
x
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
GitLab
LXR
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Reconstruction
Jet
JetMomentTools
Root
NNJvtBinning.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
JetMomentTools/NNJvtBinning.h
"
5
#include "nlohmann/json.hpp"
6
#include "
xAODBase/IParticle.h
"
7
8
#include <algorithm>
9
#include <map>
10
#include <regex>
11
#include <stdexcept>
12
#include <string>
13
14
namespace
{
15
static
constexpr
float
GeV
= 1
e3
;
// AnalysisBase has no SystemOfUnits.h
16
}
17
18
namespace
JetPileupTag
{
19
20
void
to_json
(
nlohmann::json
&j,
const
NNJvtBinning
&
binning
) {
21
j =
nlohmann::json
{{
"ptbin_edges"
,
binning
.ptEdges}, {
"etabin_edges"
,
binning
.etaEdges}};
22
}
23
24
void
from_json
(
const
nlohmann::json
&j,
NNJvtBinning
&
binning
) {
25
j.at(
"ptbin_edges"
).get_to(
binning
.ptEdges);
26
j.at(
"etabin_edges"
).get_to(
binning
.etaEdges);
27
// pT values are stored in GeV but we should use CLHEP values wherever possible
28
for
(
float
&
value
:
binning
.ptEdges)
29
value
*=
GeV
;
30
}
31
32
void
to_json
(
nlohmann::json
&j,
const
NNJvtCutMap
&cutMap) {
33
to_json
(j, cutMap.
edges
);
34
std::map<std::string, float>
cuts
;
35
for
(std::size_t ptIdx = 0; ptIdx < cutMap.
cutMap
.size(); ++ptIdx)
36
for
(std::size_t etaIdx = 0; etaIdx < cutMap.
cutMap
.at(ptIdx).
size
(); ++etaIdx)
37
cuts
[
"("
+
std::to_string
(ptIdx) +
", "
+
std::to_string
(etaIdx) +
")"
] =
38
cutMap.
cutMap
.at(ptIdx).at(etaIdx);
39
j[
"cuts"
] = cutMap;
40
}
41
42
void
from_json
(
const
nlohmann::json
&j,
NNJvtCutMap
&cutMap) {
43
j.get_to(cutMap.
edges
);
44
cutMap.
cutMap
.resize(cutMap.
edges
.
ptEdges
.size() - 1);
45
for
(
auto
&
v
: cutMap.
cutMap
)
46
v
.resize(cutMap.
edges
.
etaEdges
.size() - 1);
47
std::regex
expr(R
"(\((\d+),\s*(\d+)\))");
48
for
(
const
auto
&[
bin
,
cut
] : j[
"cuts"
].
get
<std::map<std::string, float>>()) {
49
std::smatch sm;
50
if
(!std::regex_match(
bin
, sm, expr))
51
throw
std::invalid_argument(
"Invalid bin descriptor: "
+
bin
);
52
cutMap.
cutMap
.at(std::stoi(sm[1])).at(std::stoi(sm[2])) =
cut
;
53
}
54
}
55
56
NNJvtBinning
NNJvtBinning::fromJSON
(std::istream &is) {
57
nlohmann::json
j;
58
is >> j;
59
return
j.get<
NNJvtBinning
>();
60
}
61
62
std::string
NNJvtBinning::toJSON
()
const
{
63
return
nlohmann::json
(*this).dump();
64
}
65
66
bool
67
NNJvtBinning::operator()
(
float
pt
,
float
eta, std::size_t &ptBin, std::size_t &
etaBin
)
const
{
68
ptBin =
std::distance
(
69
ptEdges
.begin(), std::lower_bound(
ptEdges
.begin(),
ptEdges
.end(),
pt
));
70
etaBin
=
std::distance
(
71
etaEdges
.begin(), std::lower_bound(
etaEdges
.begin(),
etaEdges
.end(), eta));
72
// 0 => below the lowest bin edge, size() => above the highest bin edge
73
// Use lowest pt bin for any jets with lower pt
74
if
(ptBin == 0)
75
ptBin = 1;
76
if
(ptBin ==
ptEdges
.size())
77
ptBin = SIZE_MAX;
78
else
79
ptBin -= 1;
80
if
(
etaBin
== 0 ||
etaBin
==
etaEdges
.size())
81
etaBin
= SIZE_MAX;
82
else
83
etaBin
-= 1;
84
85
return
ptBin != SIZE_MAX &&
etaBin
!= SIZE_MAX;
86
}
87
88
bool
NNJvtBinning::operator()
(
89
const
xAOD::IParticle
&particle, std::size_t &ptBin, std::size_t &
etaBin
)
const
{
90
return
this->
operator()
(particle.
pt
(), particle.eta(), ptBin,
etaBin
);
91
}
92
93
NNJvtCutMap
NNJvtCutMap::fromJSON
(std::istream &is) {
94
nlohmann::json
j;
95
is >> j;
96
return
j.get<
NNJvtCutMap
>();
97
}
98
99
std::string
NNJvtCutMap::toJSON
()
const
{
100
return
nlohmann::json
(*this).dump();
101
}
102
103
float
NNJvtCutMap::operator()
(
float
pt
,
float
eta)
const
{
104
std::size_t ptBin,
etaBin
;
105
if
(!
edges
(
pt
, eta, ptBin,
etaBin
))
106
return
-1;
107
return
this->
operator()
(ptBin,
etaBin
);
108
}
109
110
float
NNJvtCutMap::operator()
(
const
xAOD::IParticle
&particle)
const
{
111
std::size_t ptBin,
etaBin
;
112
if
(!
edges
(particle, ptBin,
etaBin
))
113
return
-1;
114
return
this->
operator()
(ptBin,
etaBin
);
115
}
116
117
float
NNJvtCutMap::operator()
(std::size_t ptBin, std::size_t
etaBin
)
const
{
118
return
cutMap
.at(ptBin).at(
etaBin
);
119
}
120
}
// namespace JetPileupTag
JetPileupTag::NNJvtBinning::operator()
bool operator()(float pt, float eta, std::size_t &ptBin, std::size_t &etaBin) const
Get the correct bin for the provided pt/eta values.
Definition:
NNJvtBinning.cxx:67
JetPileupTag::NNJvtCutMap::toJSON
std::string toJSON() const
Definition:
NNJvtBinning.cxx:99
GeV
#define GeV
Definition:
PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
AddEmptyComponent.binning
binning
Definition:
AddEmptyComponent.py:34
JetPileupTag::NNJvtCutMap
The NNJvt cut maps.
Definition:
NNJvtBinning.h:50
JetPileupTag::NNJvtBinning
Helper struct to hold the bin edges for the NN Jvt cut maps.
Definition:
NNJvtBinning.h:23
IParticle.h
json
nlohmann::json json
Definition:
HistogramDef.cxx:9
test_pyathena.pt
pt
Definition:
test_pyathena.py:11
bin
Definition:
BinsDiffFromStripMedian.h:43
athena.value
value
Definition:
athena.py:124
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition:
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
JetPileupTag::NNJvtBinning::etaEdges
std::vector< float > etaEdges
Definition:
NNJvtBinning.h:25
JetPileupTag
Definition:
JetVertexNNTagger.h:41
PrepareReferenceFile.regex
regex
Definition:
PrepareReferenceFile.py:43
JetPileupTag::NNJvtCutMap::fromJSON
static NNJvtCutMap fromJSON(std::istream &is)
Definition:
NNJvtBinning.cxx:93
python.setupRTTAlg.size
int size
Definition:
setupRTTAlg.py:39
JetPileupTag::NNJvtBinning::toJSON
std::string toJSON() const
Definition:
NNJvtBinning.cxx:62
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition:
L2StandAloneMuon_v1.cxx:148
CheckAppliedSFs.e3
e3
Definition:
CheckAppliedSFs.py:264
JetPileupTag::NNJvtCutMap::edges
NNJvtBinning edges
Definition:
NNJvtBinning.h:51
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition:
BindingsTest.py:13
plotBeamSpotVert.cuts
string cuts
Definition:
plotBeamSpotVert.py:93
JetPileupTag::NNJvtCutMap::operator()
float operator()(float pt, float eta) const
Get the correct cut value for the provided pt/eta.
Definition:
NNJvtBinning.cxx:103
xAOD::IParticle::pt
virtual double pt() const =0
The transverse momentum ( ) of the particle.
JetPileupTag::NNJvtBinning::ptEdges
std::vector< float > ptEdges
Definition:
NNJvtBinning.h:24
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition:
GeometryDefs.h:34
python.PyAthena.v
v
Definition:
PyAthena.py:154
JetPileupTag::to_json
void to_json(nlohmann::json &j, const NNJvtBinning &binning)
Definition:
NNJvtBinning.cxx:20
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition:
hcg.cxx:127
JetPileupTag::NNJvtCutMap::cutMap
std::vector< std::vector< float > > cutMap
Definition:
NNJvtBinning.h:52
JetPileupTag::GeV
constexpr float GeV
Definition:
JetVertexNNTagger.h:44
JetPileupTag::from_json
void from_json(const nlohmann::json &j, NNJvtBinning &binning)
Definition:
NNJvtBinning.cxx:24
JetPileupTag::NNJvtBinning::fromJSON
static NNJvtBinning fromJSON(std::istream &is)
Definition:
NNJvtBinning.cxx:56
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition:
GeoPrimitivesHelpers.h:54
NNJvtBinning.h
Generated on Sun May 11 2025 21:15:15 for ATLAS Offline Software by
1.8.18