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
4ffec5b4
Commit
4ffec5b4
authored
2 months ago
by
Cedric Verstege
Browse files
Options
Downloads
Patches
Plain Diff
Add uncertainty split plots
parent
e3069b81
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/Plot/PlotUncertainties.py
+65
-52
65 additions, 52 deletions
analysis/tasks/Plot/PlotUncertainties.py
with
65 additions
and
52 deletions
analysis/tasks/Plot/PlotUncertainties.py
+
65
−
52
View file @
4ffec5b4
...
@@ -10,6 +10,7 @@ from analysis.framework.tasks import AnalysisTask, ExcaliburConfig
...
@@ -10,6 +10,7 @@ from analysis.framework.tasks import AnalysisTask, ExcaliburConfig
from
analysis.framework.utils
import
DY_Sets
from
analysis.framework.utils
import
DY_Sets
from
analysis.tasks.PostProcessing
import
MergeUncertainties
from
analysis.tasks.PostProcessing
import
MergeUncertainties
from
analysis.tools.plotting.axes_ticker
import
set_ticklabels
from
analysis.tools.plotting.axes_ticker
import
set_ticklabels
from
analysis.tools.plotting.legend_helpers
import
inline_label
from
law.contrib.matplotlib
import
MatplotlibFormatter
from
law.contrib.matplotlib
import
MatplotlibFormatter
from
luigi.util
import
inherits
from
luigi.util
import
inherits
...
@@ -49,21 +50,24 @@ class PlotUncertainties(AnalysisTask):
...
@@ -49,21 +50,24 @@ class PlotUncertainties(AnalysisTask):
def
output
(
self
):
def
output
(
self
):
filelist
=
{}
filelist
=
{}
for
ybys_bin
in
ybys_bins
:
for
ybys_bin
in
ybys_bins
:
filelist
[
ybys_bin
]
=
law
.
LocalFileTarget
(
splits
=
{}
self
.
local_path
(
for
split
in
(
"
total
"
,
"
jet
"
,
"
lum
"
,
"
sf
"
,
"
stat
"
):
f
"
{
self
.
excalibur_config_version
}
_
{
self
.
selection_suffix
}
_cuts
"
,
splits
[
split
]
=
law
.
LocalFileTarget
(
f
"
{
self
.
dataset
}
-
{
self
.
input_weight
}
_unfolded_with_
{
self
.
mc_dataset
}
-
{
self
.
unfolding_weight
}
"
,
self
.
local_path
(
f
"
{
ybys_bin
}
.pdf
"
,
f
"
{
self
.
excalibur_config_version
}
_
{
self
.
selection_suffix
}
_cuts
"
,
),
f
"
{
self
.
dataset
}
-
{
self
.
input_weight
}
_unfolded_with_
{
self
.
mc_dataset
}
-
{
self
.
unfolding_weight
}
"
,
fs
=
"
local_plots
"
,
f
"
{
ybys_bin
}
_
{
split
}
.pdf
"
,
)
),
fs
=
"
local_plots
"
,
)
filelist
[
ybys_bin
]
=
splits
return
law
.
SiblingFileCollection
(
filelist
)
return
law
.
SiblingFileCollection
(
filelist
)
def
run
(
self
):
def
run
(
self
):
data_file
=
uproot
.
open
(
self
.
input
()[
"
data
"
].
abspath
)
data_file
=
uproot
.
open
(
self
.
input
()[
"
data
"
].
abspath
)
unc_file
=
uproot
.
open
(
self
.
input
()[
"
unc
"
].
abspath
)
unc_file
=
uproot
.
open
(
self
.
input
()[
"
unc
"
].
abspath
)
uncertainties
=
{
uncertainties
=
{
"
total
"
:
dict
(
label
=
"
Total
exp. unc.
"
,
color
=
"
black
"
,
linewidth
=
3
),
"
total
"
:
dict
(
label
=
"
Total
"
,
color
=
"
black
"
,
linewidth
=
3
),
"
stat
"
:
dict
(
color
=
"
#999999
"
,
label
=
"
Stat. unc.
"
),
"
stat
"
:
dict
(
color
=
"
#999999
"
,
label
=
"
Stat. unc.
"
),
"
unf
"
:
dict
(
label
=
"
MC stat.
"
,
color
=
"
#377eb8
"
,
linestyle
=
"
dashdot
"
),
"
unf
"
:
dict
(
label
=
"
MC stat.
"
,
color
=
"
#377eb8
"
,
linestyle
=
"
dashdot
"
),
"
smooth_jec_Total_calc
"
:
dict
(
color
=
"
#e41a1c
"
,
label
=
"
JES
"
),
"
smooth_jec_Total_calc
"
:
dict
(
color
=
"
#e41a1c
"
,
label
=
"
JES
"
),
...
@@ -75,54 +79,63 @@ class PlotUncertainties(AnalysisTask):
...
@@ -75,54 +79,63 @@ class PlotUncertainties(AnalysisTask):
"
prefiring
"
:
dict
(
color
=
"
#4daf4a
"
,
label
=
"
L1 Prefiring
"
),
"
prefiring
"
:
dict
(
color
=
"
#4daf4a
"
,
label
=
"
L1 Prefiring
"
),
"
bkgsf
"
:
dict
(
color
=
"
#f781bf
"
,
label
=
"
Background
"
),
"
bkgsf
"
:
dict
(
color
=
"
#f781bf
"
,
label
=
"
Background
"
),
"
lumi
"
:
dict
(
color
=
"
#984ea3
"
,
label
=
"
Lumi
"
),
"
lumi
"
:
dict
(
color
=
"
#984ea3
"
,
label
=
"
Lumi
"
),
"
PileUp
"
:
dict
(
color
=
"
#47429d
"
,
linestyle
=
"
dotted
"
,
label
=
"
PileUp
"
),
}
}
self
.
output
().
dir
.
touch
()
self
.
output
().
dir
.
touch
()
hep
.
style
.
use
(
"
CMS
"
)
hep
.
style
.
use
(
"
CMS
"
)
for
ybys
,
_d
in
ybys_bins
.
items
():
for
ybys
,
_d
in
ybys_bins
.
items
():
fig
,
ax
=
plt
.
subplots
()
for
split
in
(
"
total
"
,
"
jet
"
,
"
lum
"
,
"
sf
"
,
"
stat
"
):
hep
.
cms
.
label
(
fig
,
ax
=
plt
.
subplots
()
label
=
"
Preliminary
"
,
data
=
not
self
.
input_is_mc
,
lumi
=
138
,
loc
=
0
,
ax
=
ax
hep
.
cms
.
label
(
)
label
=
"
Preliminary
"
,
ax
.
text
(
data
=
not
self
.
input_is_mc
,
0.03
,
lumi
=
138
,
0.95
,
loc
=
0
,
_d
[
"
label
"
],
ax
=
ax
,
fontsize
=
"
small
"
,
verticalalignment
=
"
top
"
,
fontproperties
=
"
Tex Gyre Heros
"
,
transform
=
ax
.
transAxes
,
)
ax
.
set_xscale
(
"
log
"
)
ax
.
set_xlim
(
25
,
1000
)
ax
.
set_ylim
(
-
0.2
,
0.4
)
ax
.
hlines
(
0
,
25
,
1000
,
color
=
"
black
"
,
linestyle
=
"
dashed
"
)
data
,
bins
=
data_file
[
f
"
{
ybys
}
/h_zpt_
{
self
.
unfolding_weight
}
"
].
to_numpy
()
for
unc
,
unc_dict
in
uncertainties
.
items
():
up
,
_
=
unc_file
[
f
"
{
ybys
}
/h_zpt_
{
unc
}
_up
"
].
to_numpy
()
down
,
_
=
unc_file
[
f
"
{
ybys
}
/h_zpt_
{
unc
}
_down
"
].
to_numpy
()
ax
.
stairs
(
up
/
data
,
edges
=
bins
,
label
=
unc_dict
[
"
label
"
],
color
=
unc_dict
[
"
color
"
],
linestyle
=
unc_dict
.
get
(
"
linestyle
"
,
"
-
"
),
linewidth
=
unc_dict
.
get
(
"
linewidth
"
,
2
),
baseline
=
None
,
)
ax
.
stairs
(
down
/
data
,
edges
=
bins
,
color
=
unc_dict
[
"
color
"
],
linestyle
=
unc_dict
.
get
(
"
linestyle
"
,
"
-
"
),
linewidth
=
unc_dict
.
get
(
"
linewidth
"
,
2
),
baseline
=
None
,
)
)
ax
.
set_ylabel
(
"
Relative uncertainty
"
)
inline_label
(
ax
,
_d
[
"
label
"
])
ax
.
set_xlabel
(
QUANTITIES
[
"
zpt
"
][
"
label
"
])
ax
.
set_xscale
(
"
log
"
)
set_ticklabels
(
ax
)
ax
.
set_xlim
(
25
,
1000
)
ax
.
legend
(
ncol
=
2
)
ax
.
set_ylim
(
-
0.2
,
0.4
)
fig
.
tight_layout
()
ax
.
hlines
(
0
,
25
,
1000
,
color
=
"
black
"
,
linestyle
=
"
dashed
"
)
MatplotlibFormatter
.
dump
(
self
.
output
().
targets
[
ybys
],
fig
)
data
,
bins
=
data_file
[
f
"
{
ybys
}
/h_zpt_
{
self
.
unfolding_weight
}
"
].
to_numpy
()
for
unc
,
unc_dict
in
uncertainties
.
items
():
if
split
==
"
jet
"
and
unc
not
in
(
"
smooth_jec_Total_calc
"
,
"
jer
"
):
continue
elif
split
==
"
lum
"
and
unc
not
in
(
"
lumi
"
,
"
bkgsf
"
,
"
PileUp
"
):
continue
elif
split
==
"
sf
"
and
unc
not
in
(
"
muon
"
,
"
prefiring
"
):
continue
elif
split
==
"
stat
"
and
unc
not
in
(
"
stat
"
,
"
unf
"
):
continue
up
,
_
=
unc_file
[
f
"
{
ybys
}
/h_zpt_
{
unc
}
_up
"
].
to_numpy
()
down
,
_
=
unc_file
[
f
"
{
ybys
}
/h_zpt_
{
unc
}
_down
"
].
to_numpy
()
ax
.
stairs
(
up
/
data
,
edges
=
bins
,
label
=
unc_dict
[
"
label
"
],
color
=
unc_dict
[
"
color
"
],
linestyle
=
unc_dict
.
get
(
"
linestyle
"
,
"
-
"
),
linewidth
=
unc_dict
.
get
(
"
linewidth
"
,
2
),
baseline
=
None
,
)
ax
.
stairs
(
down
/
data
,
edges
=
bins
,
color
=
unc_dict
[
"
color
"
],
linestyle
=
unc_dict
.
get
(
"
linestyle
"
,
"
-
"
),
linewidth
=
unc_dict
.
get
(
"
linewidth
"
,
2
),
baseline
=
None
,
)
ax
.
set_ylabel
(
"
Relative uncertainty
"
)
ax
.
set_xlabel
(
QUANTITIES
[
"
zpt
"
][
"
label
"
])
set_ticklabels
(
ax
)
ax
.
legend
(
ncol
=
2
)
fig
.
tight_layout
()
MatplotlibFormatter
.
dump
(
self
.
output
().
targets
[
ybys
][
split
],
fig
)
plt
.
close
(
fig
)
@inherits
(
ExcaliburConfig
)
@inherits
(
ExcaliburConfig
)
...
...
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