Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RDStar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Felix Metzner
RDStar
Commits
1822535b
Commit
1822535b
authored
4 years ago
by
Patrick Ecker
Browse files
Options
Downloads
Patches
Plain Diff
fixed an issue with the output
parent
9af86511
Branches
Branches containing commit
No related tags found
1 merge request
!63
Low level cut study
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rdstar/studies/low_level_cut_study/low_level_cut_study.py
+8
-7
8 additions, 7 deletions
rdstar/studies/low_level_cut_study/low_level_cut_study.py
rdstar/studies/low_level_cut_study/plotting.py
+25
-7
25 additions, 7 deletions
rdstar/studies/low_level_cut_study/plotting.py
with
33 additions
and
14 deletions
rdstar/studies/low_level_cut_study/low_level_cut_study.py
+
8
−
7
View file @
1822535b
...
...
@@ -121,16 +121,17 @@ class LowLevelCutsEvaluationTask(utilities.BaseOfflineTask):
def
run_evaluation
(
self
,
dry_run
:
bool
=
False
)
->
Dict
[
str
,
os
.
fspath
]:
output_dir
=
os
.
path
.
join
(
self
.
cut_evaluation_dir
,
self
.
n_tuple
)
output
=
{}
llcp
=
LowLevelCutPlotter
(
n_tuple
=
self
.
n_tuple
,
target_path
=
output_dir
)
output
=
llcp
.
generate_output_dict
()
if
not
dry_run
:
df
=
pd
.
read_hdf
(
self
.
input_dict
[
f
"
{
self
.
n_tuple
}
_total
"
])
assert
isinstance
(
df
,
pd
.
DataFrame
)
llcp
=
LowLevelCutPlotter
(
n_tuple
=
self
.
n_tuple
,
df
=
df
)
plot_dict
=
llcp
.
plot_on
(
target_path
=
output_dir
)
output
.
update
(
plot_dict
)
llcp
.
get_df
(
df
=
df
)
plot_dict
=
llcp
.
plot_on
()
assert
plot_dict
==
llcp
.
generate_output_dict
()
return
output
...
...
This diff is collapsed.
Click to expand it.
rdstar/studies/low_level_cut_study/plotting.py
+
25
−
7
View file @
1822535b
...
...
@@ -14,12 +14,15 @@ from rdstar.studies.low_level_cut_study.low_level_cut_defintions import fsp_cut_
class
LowLevelCutPlotter
:
def
__init__
(
self
,
n_tuple
:
str
,
df
:
pd
.
DataFrame
)
->
None
:
def
__init__
(
self
,
n_tuple
:
str
,
target_path
:
os
.
fspath
)
->
None
:
self
.
n_tuple
=
n_tuple
self
.
df
=
df
self
.
target_path
=
target_path
self
.
df
=
None
self
.
cut_dicts
=
fsp_cut_dict
self
.
cut_dicts
.
update
(
D_cut_dict
)
print
(
self
.
cut_dicts
)
def
get_df
(
self
,
df
:
pd
.
DataFrame
)
->
None
:
self
.
df
=
df
def
apply_cuts
(
self
,
pivot
:
CutInfo
,
cut_infos
:
List
[
CutInfo
])
->
pd
.
DataFrame
:
df_temp
=
copy
.
copy
(
self
.
df
)
...
...
@@ -30,7 +33,17 @@ class LowLevelCutPlotter:
return
df_temp
def
plot_on
(
self
,
target_path
:
os
.
fspath
)
->
Dict
[
str
,
os
.
fspath
]:
def
generate_output_dict
(
self
)
->
Dict
[
str
,
os
.
fspath
]:
output
=
{}
relevant_keys
=
[
key
for
key
in
self
.
cut_dicts
if
key
.
startswith
(
self
.
n_tuple
)]
for
key
in
relevant_keys
:
for
cut_info
in
self
.
cut_dicts
[
key
][
"
cuts
"
]:
save_path
=
os
.
path
.
join
(
self
.
target_path
,
f
"
{
key
}
_
{
cut_info
.
cut_name
}
_evaluation.pdf
"
)
output
.
update
({
f
"
{
key
}
_
{
cut_info
.
cut_name
}
_evaluation
"
:
save_path
})
return
output
def
plot_on
(
self
)
->
Dict
[
str
,
os
.
fspath
]:
output
=
{}
relevant_keys
=
[
key
for
key
in
self
.
cut_dicts
if
key
.
startswith
(
self
.
n_tuple
)]
for
key
in
relevant_keys
:
...
...
@@ -47,6 +60,9 @@ class LowLevelCutPlotter:
df
.
query
(
channel_cut
,
inplace
=
True
)
if
len
(
df
)
==
0
:
save_path
=
os
.
path
.
join
(
self
.
target_path
,
f
"
{
key
}
_
{
new_cut_info
.
cut_name
}
_evaluation.pdf
"
)
output
.
update
({
f
"
{
key
}
_
{
new_cut_info
.
cut_name
}
_evaluation
"
:
save_path
})
plt
.
savefig
(
save_path
)
continue
fig
,
ax
=
plt
.
subplots
()
...
...
@@ -71,7 +87,7 @@ class LowLevelCutPlotter:
plt
.
title
(
cut_info
.
cut_str
,
loc
=
"
center
"
)
plt
.
title
(
channel
,
loc
=
"
right
"
)
plt
.
legend
(
loc
=
"
best
"
)
save_path
=
os
.
path
.
join
(
target_path
,
f
"
{
key
}
_
{
new_cut_info
.
cut_name
}
_evaluation.pdf
"
)
save_path
=
os
.
path
.
join
(
self
.
target_path
,
f
"
{
key
}
_
{
new_cut_info
.
cut_name
}
_evaluation.pdf
"
)
output
.
update
({
f
"
{
key
}
_
{
new_cut_info
.
cut_name
}
_evaluation
"
:
save_path
})
plt
.
savefig
(
save_path
)
#plt.show()
...
...
@@ -81,6 +97,8 @@ class LowLevelCutPlotter:
if
__name__
==
'
__main__
'
:
#df = pd.read_hdf("/ceph/pecker/rdstar/low_level_cut_study/CombinedNTuples/e_ntuple_total.h5")
df
=
pd
.
read_hdf
(
"
/ceph/pecker/rdstar/low_level_cut_study/CombinedNTuples/dcharged_ntuple_total.h5
"
)
llcp
=
LowLevelCutPlotter
(
n_tuple
=
"
dcharged_ntuple
"
,
df
=
df
)
llcp
=
LowLevelCutPlotter
(
n_tuple
=
"
dcharged_ntuple
"
,
target_path
=
""
)
print
(
llcp
.
generate_output_dict
())
llcp
.
get_df
(
df
=
df
)
#llcp.apply_cuts(pivot=fsp_cut_dict["e_ntuple"]["cuts"][0], cut_infos=fsp_cut_dict["e_ntuple"]["cuts"])
llcp
.
plot_on
(
target_path
=
""
)
\ No newline at end of file
llcp
.
plot_on
()
\ No newline at end of file
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