Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZJet Analysis
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cedric Verstege
ZJet Analysis
Commits
e8a0002f
Commit
e8a0002f
authored
3 months ago
by
Cedric Verstege
Browse files
Options
Downloads
Patches
Plain Diff
Update NP corrections
parent
ae7993e8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
analysis/tasks/Theory/NPCorrections.py
+97
-7
97 additions, 7 deletions
analysis/tasks/Theory/NPCorrections.py
with
97 additions
and
7 deletions
analysis/tasks/Theory/NPCorrections.py
+
97
−
7
View file @
e8a0002f
...
...
@@ -11,6 +11,7 @@ import luigi
import
mplhep
as
hep
from
analysis.framework.quantities
import
QUANTITIES
,
ybys_bins
from
analysis.tools.plotting.legend_helpers
import
merge_legend_handles_labels
from
analysis.tools.plotting.styles
import
colormap_5_no_grey
from
law.contrib.matplotlib
import
MatplotlibFormatter
from
law.decorator
import
safe_output
...
...
@@ -27,6 +28,8 @@ def json_numpy_obj_hook(dct):
if
isinstance
(
dct
,
dict
)
and
"
__ndarray__
"
in
dct
:
data
=
base64
.
b64decode
(
dct
[
"
__ndarray__
"
])
return
np
.
frombuffer
(
data
,
dct
[
"
dtype
"
]).
reshape
(
dct
[
"
shape
"
])
elif
isinstance
(
dct
,
dict
)
and
"
ndarray
"
in
dct
:
return
np
.
array
(
dct
[
"
ndarray
"
])
return
dct
...
...
@@ -49,7 +52,7 @@ class NPCalc(law.ExternalTask):
targets
=
{}
for
ybys
in
ybys_bins
:
targets
[
ybys
]
=
law
.
LocalFileTarget
(
"
/work/
mhorzela/mc-run/data
/PlotNPCorr/
"
"
/work/
cverstege/QCD_shared/store
/PlotNPCorr/
"
+
f
"
{
self
.
generator
.
value
}
/
{
self
.
generator_settings
}
/
"
+
f
"
withNP-NPoff-Ratio-Plots/m-ZPt-um-RAW/ZplusJet_3_AK
{
self
.
jet_radius
}{
ybys
}
.json
"
,
)
...
...
@@ -103,12 +106,46 @@ class NPCorrections(law.Task):
[
correction_dicts
[
setting
][
"
ys
"
]
for
setting
in
correction_dicts
if
setting
in
(
"
sherpa_LHC-ZJetMerging
"
,
"
herwig_LHC-NLO-ZplusJet
"
)
if
setting
in
(
"
sherpa_LHC-ZJetMerging
"
,
"
sherpa_LHC-NLO-ZplusJet
"
,
"
herwig_LHC-NLO-ZplusJet
"
,
)
],
)
up
=
np
.
max
(
corrections
,
axis
=
0
)
down
=
np
.
min
(
corrections
,
axis
=
0
)
corrections_all
=
np
.
stack
(
[
correction_dicts
[
setting
][
"
ys
"
]
for
setting
in
correction_dicts
],
)
uncertainties
=
np
.
nan_to_num
(
np
.
stack
(
[
correction_dicts
[
setting
][
"
yerrs
"
]
for
setting
in
correction_dicts
if
setting
in
(
"
sherpa_LHC-ZJetMerging
"
,
"
sherpa_LHC-NLO-ZplusJet
"
,
"
herwig_LHC-NLO-ZplusJet
"
,
)
],
)
)
uncertainties_all
=
np
.
nan_to_num
(
np
.
stack
(
[
correction_dicts
[
setting
][
"
yerrs
"
]
for
setting
in
correction_dicts
],
)
)
up
=
np
.
max
(
corrections
+
uncertainties
,
axis
=
0
)
down
=
np
.
min
(
corrections
-
uncertainties
,
axis
=
0
)
val
=
(
up
+
down
)
/
2
up_all
=
np
.
max
(
corrections_all
+
uncertainties_all
,
axis
=
0
)
down_all
=
np
.
min
(
corrections_all
-
uncertainties_all
,
axis
=
0
)
val_all
=
(
up_all
+
down_all
)
/
2
# plot the corrections
fig
,
ax
=
plt
.
subplots
()
...
...
@@ -120,6 +157,7 @@ class NPCorrections(law.Task):
yerr
=
[
val
-
down
,
up
-
val
],
label
=
r
"
NP correction $\pm$ uncertainty
"
,
edges
=
False
,
zorder
=-
2
,
)
hep
.
histplot
(
val
,
...
...
@@ -129,8 +167,29 @@ class NPCorrections(law.Task):
edges
=
False
,
color
=
"
black
"
,
linewidth
=
4
,
zorder
=-
1
,
)
for
setting
in
self
.
input
().
keys
():
hep
.
histplot
(
val_all
,
bins
=
_d
[
"
zpt_binning
"
],
histtype
=
"
band
"
,
yerr
=
[
val_all
-
down_all
,
up_all
-
val_all
],
label
=
r
"
NP correction (alt) $\pm$ uncertainty
"
,
edges
=
False
,
hatch
=
"
\\\\
"
,
zorder
=-
12
,
)
hep
.
histplot
(
val_all
,
bins
=
_d
[
"
zpt_binning
"
],
histtype
=
"
step
"
,
label
=
r
"
NP correction (alt) $\pm$ uncertainty
"
,
edges
=
False
,
color
=
"
grey
"
,
linewidth
=
3
,
zorder
=-
11
,
)
for
setting
,
color
in
zip
(
self
.
input
().
keys
(),
colormap_5_no_grey
):
label
=
""
if
"
sherpa
"
in
setting
:
label
+=
"
Sherpa
"
...
...
@@ -145,10 +204,15 @@ class NPCorrections(law.Task):
hep
.
histplot
(
correction_dicts
[
setting
][
"
ys
"
],
bins
=
_d
[
"
zpt_binning
"
],
histtype
=
"
step
"
,
histtype
=
"
errorbar
"
,
yerr
=
correction_dicts
[
setting
][
"
yerrs
"
],
edges
=
False
,
linewidth
=
2
,
label
=
label
,
markersize
=
16
,
elinewidth
=
3
,
capsize
=
4
,
color
=
color
,
)
ax
.
set_ylabel
(
"
NP correction
"
)
ax
.
set_xlabel
(
QUANTITIES
[
"
zpt
"
][
"
label
"
])
...
...
@@ -194,11 +258,37 @@ class NPCorrections(law.Task):
len
(
val
),
_d
[
"
zpt_binning
"
],
)
for
i
,
(
v
,
u
,
d
)
in
enumerate
(
zip
(
val
,
up
,
down
),
start
=
1
):
root_hist_alt
=
ROOT
.
TH1D
(
"
h_genzpt_npcorr_alt
"
,
f
"
{
ybys
}
_genzpt_npcorr_alt
"
,
len
(
val
),
_d
[
"
zpt_binning
"
],
)
root_hist_up_alt
=
ROOT
.
TH1D
(
"
h_genzpt_npcorr_alt_up
"
,
f
"
{
ybys
}
_genzpt_npcorr_alt_up
"
,
len
(
val
),
_d
[
"
zpt_binning
"
],
)
root_hist_down_alt
=
ROOT
.
TH1D
(
"
h_genzpt_npcorr_alt_down
"
,
f
"
{
ybys
}
_genzpt_npcorr_alt_down
"
,
len
(
val
),
_d
[
"
zpt_binning
"
],
)
for
i
,
(
v
,
u
,
d
,
va
,
ua
,
da
)
in
enumerate
(
zip
(
val
,
up
,
down
,
val_all
,
up_all
,
down_all
),
start
=
1
):
root_hist
.
SetBinContent
(
i
,
v
)
root_hist_up
.
SetBinContent
(
i
,
u
)
root_hist_down
.
SetBinContent
(
i
,
d
)
root_hist_alt
.
SetBinContent
(
i
,
va
)
root_hist_up_alt
.
SetBinContent
(
i
,
ua
)
root_hist_down_alt
.
SetBinContent
(
i
,
da
)
root_hist
.
Write
()
root_hist_up
.
Write
()
root_hist_down
.
Write
()
root_hist_alt
.
Write
()
root_hist_up_alt
.
Write
()
root_hist_down_alt
.
Write
()
out_file
.
Close
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment