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
a4e6c80d
Commit
a4e6c80d
authored
1 year ago
by
Felix Metzner
Browse files
Options
Downloads
Patches
Plain Diff
Updating notebooks.
parent
82789ca4
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
rdstar/offline_analysis/fitting/dedicated_fit_approach/notebooks/rdstar_fits/testing_fit_routine_rdstar.ipynb
+70
-16
70 additions, 16 deletions
...ch/notebooks/rdstar_fits/testing_fit_routine_rdstar.ipynb
with
70 additions
and
16 deletions
rdstar/offline_analysis/fitting/dedicated_fit_approach/notebooks/rdstar_fits/testing_fit_routine_rdstar.ipynb
+
70
−
16
View file @
a4e6c80d
...
...
@@ -383,7 +383,7 @@
"execution_count": null,
"id": "46ad9aa0",
"metadata": {
"scrolled":
fals
e
"scrolled":
tru
e
},
"outputs": [],
"source": [
...
...
@@ -393,7 +393,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
0d365390
",
"id": "
47f0489b
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -401,7 +401,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
4437420b
",
"id": "
87b8d35d
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -409,7 +409,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
558fe799
",
"id": "
eab32abe
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -427,7 +427,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
7f0a1da2
",
"id": "
fc925ca0
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -435,7 +435,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
2c767a7
e",
"id": "
e306c4d
e",
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -451,7 +451,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
299793eb
",
"id": "
c709b2e7
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -459,7 +459,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
8a90f4a9
",
"id": "
6242cbcf
",
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -469,7 +469,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
385984
bd",
"id": "
83f45
bd
5
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -503,7 +503,61 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3057bedc",
"id": "d5846bc5",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "e124c978",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "0642edce",
"metadata": {},
"outputs": [],
"source": [
"raise RuntimeError(\"Stop here!\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e72edbec",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "321b4a1e",
"metadata": {},
"outputs": [],
"source": [
"fit_evaluator.plot_sys_shape_effects(\n",
" fit_status_container=fit_status,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b47ce3e8",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "51facd21",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -511,7 +565,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
95712384
",
"id": "
43fa5923
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -519,7 +573,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
238d02ab
",
"id": "
a0050152
",
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -529,7 +583,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
7bbf86a3
",
"id": "
c5521db6
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -537,7 +591,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
a7d42896
",
"id": "
cf2535d4
",
"metadata": {
"scrolled": false
},
...
...
@@ -551,7 +605,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1
b67e300
",
"id": "1
6929fac
",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -559,7 +613,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
ca9ee9b6
",
"id": "
8df90af1
",
"metadata": {},
"outputs": [],
"source": []
...
...
%% Cell type:code id:6ed4ab75 tags:
```
python
%
load_ext
autoreload
%
autoreload
2
```
%% Cell type:code id:242d4a5c tags:
```
python
import
os
import
copy
import
numpy
as
np
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
from
collections
import
defaultdict
from
IPython.core.display
import
display
,
HTML
pd
.
set_option
(
'
display.max_columns
'
,
999
)
display
(
HTML
(
"
<style>.container { width:100% !important; }</style>
"
))
%
matplotlib
inline
```
%% Cell type:code id:85892d9f tags:
```
python
plt
.
switch_backend
(
'
module://ipykernel.pylab.backend_inline
'
)
```
%% Cell type:code id:f028da2e tags:
```
python
``
`
%%
Cell
type
:
code
id
:
48
d10291
tags
:
```
python
from rdstar.offline_analysis.fitting.dedicated_fit_approach.fit_setups import FitSetupCollection
```
%% Cell type:code id:0330aeca tags:
```
python
from rdstar.offline_analysis.fitting.dedicated_fit_approach.dedicated_fit_routine import FitTypeInfo
from rdstar.offline_analysis.fitting.dedicated_fit_approach.dedicated_fit_routine import RDStarFitEvaluator
```
%% Cell type:code id:ecefdaaf tags:
```
python
from rdstar.offline_analysis.fitting.dedicated_fit_approach.rdstar_systematics import BKGHandling
```
%% Cell type:code id:50112f6e tags:
```
python
```
%% Cell type:code id:46b1aef9 tags:
```
python
```
%% Cell type:code id:e1cc58ba tags:
```
python
file_dict_dir = "/ceph/fmetzner/rdstar/data_set_prod_24thMarch2022_stream0/FileDict/file_dicts"
assert os.path.isdir(file_dict_dir), file_dict_dir
```
%% Cell type:code id:f13fcbde tags:
```
python
fit_mc_cache_dir_path = "/ceph/fmetzner/rdstar/data_set_prod_24thMarch2022_stream0/FitMCDataCache"
```
%% Cell type:code id:15a96845 tags:
```
python
selection_name = "main_with_mva_selection_sec_sel_mva"
base_input_path = os.path.join(
"/ceph/fmetzner/rdstar/data_set_prod_24thMarch2022_stream0/CombinedSamples/",
selection_name,
)
assert os.path.isdir(base_input_path), base_input_path
```
%% Cell type:code id:d0c2d681 tags:
```
python
```
%% Cell type:code id:296f2310 tags:
```
python
_output_
path = "/home/fmetzner/Downloads/"
output_dir_name = "TEST_RDStarFitterResults"
base_output_path = os.path.join(_output_path, output_dir_name)
os.makedirs(base_output_path, exist_ok=True)
```
%% Cell type:code id:64c87a26 tags:
```
python
```
%% Cell type:markdown id:cb3be128 tags:
# Setup Parameters
%% Cell type:code id:9d598915 tags:
```
python
fit_cache_tag = "V3_March2024"
```
%% Cell type:code id:a18b67ae tags:
```
python
```
%% Cell type:code id:58edfbaf tags:
```
python
current_version_tag = "Results27thFeb2024"
```
%% Cell type:code id:752d2a7e tags:
```
python
use_alternative_gap_setup = True
run_minos = True
```
%% Cell type:code id:911b9585 tags:
```
python
```
%% Cell type:code id:c1759e54 tags:
```
python
rdstar_fit_setup_triplet = FitSetupCollection.rdstar_fit_setup
```
%% Cell type:code id:f658fda7 tags:
```
python
fit_base_name = "FitTest"
```
%% Cell type:code id:367d68cf tags:
```
python
fit_type_info = FitTypeInfo(
fit_type="A",
)
```
%% Cell type:code id:11a0e86f tags:
```
python
```
%% Cell type:markdown id:fb837f07 tags:
# Fitting
%% Cell type:code id:1c1f97b4 tags:
```
python
```
%% Cell type:code id:6dc7ae5c tags:
```
python
from rdstar.offline_analysis.fitting.dedicated_fit_approach.fitter_rdstar import RDStarFitter
```
%% Cell type:code id:e1926667 tags:
```
python
```
%% Cell type:code id:6473c01f tags:
```
python
fit_evaluator = RDStarFitEvaluator(
fit_setup=rdstar_fit_setup_triplet,
fit_tag=current_version_tag,
base_output_dir_path=base_output_path,
base_input_path=base_input_path,
mc_cache_version_tag=fit_cache_tag,
mc_cache_dir_path=fit_mc_cache_dir_path,
file_dict_directory_path=file_dict_dir,
use_alternative_gap_setup=use_alternative_gap_setup,
run_minos=run_minos,
)
```
%% Cell type:code id:dedf43c9 tags:
```
python
```
%% Cell type:code id:e8aeea27 tags:
```
python
fit_status = fit_evaluator.run_fit(
rerun_fit=False,
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
systematics_container=RDStarFitter.full_systematics_container,
)
```
%% Cell type:code id:37b15a2b tags:
```
python
fit_status.fitter_instance.hadron_id_rel_shape_sys_uncert_matrix.shape
```
%% Cell type:code id:010d332a tags:
```
python
```
%% Cell type:code id:c903a1f2 tags:
```
python
fit_status = fit_evaluator.get_fit(
run_if_necessary=False,
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
systematics_container=RDStarFitter.full_systematics_container,
)
```
%% Cell type:code id:46ad9aa0 tags:
```
python
fit_status.minuit_instance
```
%% Cell type:code id:
0d365390
tags:
%% Cell type:code id:
47f0489b
tags:
```
python
```
%% Cell type:code id:
4437420b
tags:
%% Cell type:code id:
87b8d35d
tags:
```
python
```
%% Cell type:code id:
558fe799
tags:
%% Cell type:code id:
eab32abe
tags:
```
python
```
%% Cell type:code id:7b4f77ad tags:
```
python
raise RuntimeError("Stop here!")
```
%% Cell type:code id:
7f0a1da2
tags:
%% Cell type:code id:
fc925ca0
tags:
```
python
```
%% Cell type:code id:
2c767a7
e tags:
%% Cell type:code id:
e306c4d
e tags:
```
python
fit_sys_eval_results = fit_evaluator.evaluate_bkg_setup_systematics_for(
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
systematics_container=fit_evaluator.full_systematics_container,
ignore_check=True,
)
```
%% Cell type:code id:
299793eb
tags:
%% Cell type:code id:
c709b2e7
tags:
```
python
```
%% Cell type:code id:
8a90f4a9
tags:
%% Cell type:code id:
6242cbcf
tags:
```
python
raise RuntimeError("Stop here!")
```
%% Cell type:code id:
385984
bd tags:
%% Cell type:code id:
83f45
bd
5
tags:
```
python
```
%% Cell type:code id:63320dee tags:
```
python
fit_sys_eval_results = fit_evaluator.evaluate_systematics_for(
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
ignore_check=True,
)
```
%% Cell type:code id:2cec57ec tags:
```
python
```
%% Cell type:code id:
3057bedc
tags:
%% Cell type:code id:
d5846bc5
tags:
```
python
```
%% Cell type:code id:
95712384
tags:
%% Cell type:code id:
e124c978
tags:
```
python
```
%% Cell type:code id:
238d02ab
tags:
%% Cell type:code id:
0642edce
tags:
```
python
raise RuntimeError("Stop here!")
```
%% Cell type:code id:
7bbf86a3
tags:
%% Cell type:code id:
e72edbec
tags:
```
python
```
%% Cell type:code id:a7d42896 tags:
%% Cell type:code id:321b4a1e tags:
```
python
fit_evaluator.plot_sys_shape_effects(
fit_status_container=fit_status,
)
```
%% Cell type:code id:b47ce3e8 tags:
```
python
```
%% Cell type:code id:51facd21 tags:
```
python
```
%% Cell type:code id:43fa5923 tags:
```
python
```
%% Cell type:code id:a0050152 tags:
```
python
raise RuntimeError("Stop here!")
```
%% Cell type:code id:c5521db6 tags:
```
python
```
%% Cell type:code id:cf2535d4 tags:
```
python
fit_evaluator.plot_nuisance_pulls(
fit_result=fit_status.fit_result,
)
```
%% Cell type:code id:1
b67e300
tags:
%% Cell type:code id:1
6929fac
tags:
```
python
```
%% Cell type:code id:
ca9ee9b6
tags:
%% Cell type:code id:
8df90af1
tags:
```
python
```
%% Cell type:code id:e19cc948 tags:
```
python
import matplotlib.pyplot as plt
from uncertainties import ufloat
from dataclasses import dataclass
from typing import Tuple, Optional, ClassVar
from templatefitter.plotter.plot_utilities import export, AxesType
from templatefitter.plotter.plot_style import KITColors, TangoColors, set_matplotlibrc_params, xlabel_pos, ylabel_pos
from rdstar.utilities import PathType
@dataclass(frozen=True)
class NuisancePullInfos:
name: str
latex_str: str
param_ids: np.ndarray
param_values: np.ndarray
param_errors: np.ndarray
def __post_init__(self) -> None:
assert self.param_ids.shape == self.param_values.shape, (self.param_ids.shape, self.param_values.shape)
assert self.param_ids.shape == self.param_errors.shape, (self.param_ids.shape, self.param_errors.shape)
@property
def number_of_nuisances(self) -> int:
return len(self.param_ids)
class NuisancePullPlotter:
output_dir_name: ClassVar[str] = "NuisancePulls"
plot_name_prefix: ClassVar[str] = "nuisance_pulls_for"
def __init__(
self,
base_output_dir_path: PathType,
) -> None:
self.output_dir_path: PathType = os.path.join(base_output_dir_path, self.output_dir_name)
def _plot_nuisance_pull(
self,
infos: NuisancePullInfos,
fig_size: Tuple[int, int] = (8, 5.5),
) -> None:
set_matplotlibrc_params()
plot_file_name: str = f"{self.plot_name_prefix}_{infos.name}"
fig, ax = plt.subplots(figsize=fig_size, dpi=300)
ax.set_xlim(-0.4, infos.number_of_nuisances - 0.6)
ax.set_ylim(-2.2, 2.2)
ls_min: int = -1
ls_max: int = infos.number_of_nuisances
ls_num: int = infos.number_of_nuisances
ax.fill_between(x=np.linspace(ls_min, ls_max, ls_num), y1=-1.0, y2=+1.0, color=TangoColors.chameleon2)
ax.fill_between(x=np.linspace(ls_min, ls_max, ls_num), y1=-2.0, y2=-1.0, color=TangoColors.butter2)
ax.fill_between(x=np.linspace(ls_min, ls_max, ls_num), y1=+1.0, y2=+2.0, color=TangoColors.butter2)
ax.errorbar(
x=np.arange(infos.number_of_nuisances),
y=[nu_v for nu_v in infos.param_values],
yerr=[nu_e for nu_e in infos.param_errors],
marker=".",
color=KITColors.kit_black,
linestyle="",
capsize=6,
)
plt.title(r"$\mathrm{Nuisance\;Parameter\;Pulls}$", fontsize=22)
plt.xlabel(infos.latex_str + r" $\mathrm{Nuisance\;Parameters}$", fontsize=18, **xlabel_pos)
plt.ylabel(r"$\mathrm{Standard\;Deviations}$", fontsize=18, **ylabel_pos)
plt.show()
```
%% Cell type:code id:beba19ec tags:
```
python
nu_plotter = NuisancePullPlotter(
base_output_dir_path="Test",
)
```
%% Cell type:code id:7eb01064 tags:
```
python
```
%% Cell type:code id:ac306fc5 tags:
```
python
_my_
nuisances = {}
for sys_name, sys_container in fit_evaluator.full_systematics_container.items():
_my_nuisances.update({sys_name: sys_container})
```
%% Cell type:code id:154b5168 tags:
```
python
additive_ff_norm_sys_info = _my_nuisances["additive_ff_norm_sys"]
```
%% Cell type:code id:b01e518a tags:
```
python
additive_ff_norm_sys_info.nuisance_param_ids
```
%% Cell type:code id:debf9720 tags:
```
python
assert additive_ff_norm_sys_info.is_active
_nu_
param_values = fit_status.fit_result.param_values[np.array(additive_ff_norm_sys_info.nuisance_param_ids)]
_nu_
param_errors = fit_status.fit_result.errors[np.array(additive_ff_norm_sys_info.nuisance_param_ids)]
pull_info = NuisancePullInfos(
name=additive_ff_norm_sys_info.systematics_key,
latex_str="test",
param_ids=np.array(additive_ff_norm_sys_info.nuisance_param_ids),
param_values=_nu_param_values,
param_errors=_nu_param_errors,
)
```
%% Cell type:code id:1a1d555d tags:
```
python
nu_plotter._plot_nuisance_pull(
infos=pull_info
)
```
%% Cell type:code id:e2fc7fe5 tags:
```
python
```
%% Cell type:code id:f7a7d24c tags:
```
python
```
%% Cell type:code id:5dd4b0a4 tags:
```
python
raise RuntimeError("Stop here!")
```
%% Cell type:code id:e8eeda04 tags:
```
python
# BEGINNING OF TEST SECTION
```
%% Cell type:code id:13236936 tags:
```
python
```
%% Cell type:code id:0c043523 tags:
```
python
evt_count_df = copy.deepcopy(fit_status.fitter_instance._mc_df)
```
%% Cell type:code id:30e625f9 tags:
```
python
```
%% Cell type:code id:d17bb2b3 tags:
```
python
```
%% Cell type:code id:1c35e17b tags:
```
python
rc_ids_map = {rc.name: rc.reco_channel_ids for rc in fit_status.fitter_instance.fit_setup_info.reco_channels}
rc_ids_map
```
%% Cell type:code id:97e1e4c7 tags:
```
python
rc_latex_label_map = {rc.name: rc.latex_label for rc in fit_status.fitter_instance.fit_setup_info.reco_channels}
rc_latex_label_map
```
%% Cell type:code id:ab072415 tags:
```
python
```
%% Cell type:code id:debd1fa8 tags:
```
python
comp_ids_map = {ci.name: ci.sig_ids for ci in fit_status.fitter_instance.fit_setup_info.components}
comp_ids_map
```
%% Cell type:code id:994e1f64 tags:
```
python
comp_latex_label_map = {ci.name: ci.latex_label for ci in fit_status.fitter_instance.fit_setup_info.components}
comp_latex_label_map
```
%% Cell type:code id:b23a322b tags:
```
python
```
%% Cell type:code id:24a474f7 tags:
```
python
_my_
w_col = fit_status.fitter_instance.fit_setup_info.weight_info.col_name
_my_
reco_col = fit_status.fitter_instance.fit_setup_info.reco_mode_col
_my_
cat_col = fit_status.fitter_instance.fit_setup_info.component_id_column_name
```
%% Cell type:code id:3eec080a tags:
```
python
```
%% Cell type:code id:a6f0080a tags:
```
python
from typing import Dict
from collections import defaultdict
```
%% Cell type:code id:afe01d0e tags:
```
python
evt_count_dict: Dict[str, Dict[str, float]] = defaultdict(dict)
evt_count_dict_w_latex: Dict[str, Dict[str, float]] = defaultdict(dict)
```
%% Cell type:code id:55871395 tags:
```
python
```
%% Cell type:code id:5500d565 tags:
```
python
for rch_name, rch_ids in rc_ids_map.items():
rch_mask = evt_count_df[
_my_
reco_col].isin(rch_ids)
for comp_name, comp_ids in comp_ids_map.items():
comp_mask = evt_count_df[
_my_
cat_col].isin(comp_ids)
# evt_count = np.sum(evt_count_df.loc[rch_mask & comp_mask, _my_w_col].values)
evt_count = np.sum(rch_mask & comp_mask)
print(rch_name, comp_name)
evt_count_dict[rch_name].update({comp_name: evt_count})
evt_count_dict_w_latex[rc_latex_label_map[rch_name]].update({comp_latex_label_map[comp_name]: evt_count})
```
%% Cell type:code id:8af2d338 tags:
```
python
evt_count_dict
```
%% Cell type:code id:2f390c65 tags:
```
python
pd.DataFrame(evt_count_dict)
# pd.DataFrame(evt_count_dict_w_latex)
```
%% Cell type:code id:0e765fd2 tags:
```
python
```
%% Cell type:code id:e52c54ed tags:
```
python
```
%% Cell type:code id:46f3dff4 tags:
```
python
fit_status.fitter_instance.eff_base_values
```
%% Cell type:code id:33de0307 tags:
```
python
```
%% Cell type:code id:901e2b67 tags:
```
python
```
%% Cell type:code id:5253994c tags:
```
python
```
%% Cell type:code id:2d427a90 tags:
```
python
# END OF TEST SECTION
```
%% Cell type:code id:cee3574e tags:
```
python
```
%% Cell type:code id:d5495224 tags:
```
python
```
%% Cell type:code id:3ff38310 tags:
```
python
```
%% Cell type:code id:f430e271 tags:
```
python
fit_status.minuit_instance
```
%% Cell type:code id:23b94930 tags:
```
python
np.sqrt(np.diag(np.array(fit_status.minuit_instance.covariance))[:2])
```
%% Cell type:code id:51bb491f tags:
```
python
np.array(fit_status.minuit_instance.values)[:2]
```
%% Cell type:code id:52519d53 tags:
```
python
```
%% Cell type:code id:35d12c1a tags:
```
python
```
%% Cell type:code id:193cca1d tags:
```
python
```
%% Cell type:code id:38d35446 tags:
```
python
```
%% Cell type:code id:907a14a7 tags:
```
python
```
%% Cell type:code id:e96c4136 tags:
```
python
fit_status_wo_fei_sys = fit_evaluator.run_fit(
rerun_fit=False,
base_name=fit_base_name + "_wo_fei_sys",
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
systematics_container=RDStarFitter.full_systematics_container.get_sys_setup_without(excluded_sys_name="multiplicative_fei_eff_sys"),
)
```
%% Cell type:code id:90c5d756 tags:
```
python
np.array(fit_status_wo_fei_sys.minuit_instance.errors[:2])
```
%% Cell type:code id:42735636 tags:
```
python
np.array(fit_status_wo_fei_sys.minuit_instance.errors[:2]) / np.array(fit_status_wo_fei_sys.minuit_instance.values)[:2]
```
%% Cell type:code id:e808d7f4 tags:
```
python
np.array(fit_status_wo_fei_sys.minuit_instance.values)[:2]
```
%% Cell type:code id:ee930d19 tags:
```
python
```
%% Cell type:code id:5142306f tags:
```
python
(np.array(fit_status.minuit_instance.errors[:2]) - np.array(fit_status_wo_fei_sys.minuit_instance.errors[:2])) / np.array(fit_status_wo_fei_sys.minuit_instance.values)[:2]
```
%% Cell type:code id:83390d48 tags:
```
python
(np.array(fit_status.minuit_instance.errors[:2]) - np.array(fit_status_wo_fei_sys.minuit_instance.errors[:2])) / np.array(fit_status.minuit_instance.values)[:2]
```
%% Cell type:code id:e4e32f52 tags:
```
python
np.array(fit_status.minuit_instance.errors[:2])
```
%% Cell type:code id:de66a845 tags:
```
python
```
%% Cell type:code id:5d466111 tags:
```
python
```
%% Cell type:code id:2e0beb0a tags:
```
python
raise RuntimeError("stop here")
```
%% Cell type:code id:3b85a439 tags:
```
python
fit_evaluator.dump_data_for_external_fitter(
output_tag=fit_cache_tag,
output_dir_path="/ceph/fmetzner/rdstar/FitDataForIlias",
#
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
systematics_container=RDStarFitter.full_systematics_container,
)
```
%% Cell type:code id:a4027d36 tags:
```
python
```
%% Cell type:code id:a2f567dc tags:
```
python
_this_
fit_name: str = fit_evaluator.get_fit_name(
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
systematics_container=RDStarFitter.full_systematics_container,
)
fit_data_file_name = f"fit_dataframe_{_this_fit_name}_{fit_cache_tag}.feather"
fit_data_file_path = os.path.join("/ceph/fmetzner/rdstar/FitDataForIlias", fit_data_file_name)
tmp_fit_data_file_path = os.path.join("/ceph/fmetzner/rdstar/FitDataForIlias", f"tmp_{fit_data_file_name}")
if os.path.exists(fit_data_file_path):
raise FileExistsError(fit_data_file_path)
assert not os.path.exists(tmp_fit_data_file_path), tmp_fit_data_file_path
_fit_
info = fit_evaluator._fit_container[
_this_
fit_name]
rdstar_fit_instance: RDStarFitter = _fit_info.fitter_instance
fit_data_frame: pd.DataFrame = copy.deepcopy(rdstar_fit_instance.internal_mc_sample_df)
fit_data_frame["sig_d_decay"] = str(fit_data_frame["sig_d_decay"])
# fit_data_frame.to_hdf(path_or_buf=tmp_fit_data_file_path, key="fitting")
fit_data_frame.reset_index(drop=True).to_feather(tmp_fit_data_file_path)
os.rename(src=tmp_fit_data_file_path, dst=fit_data_file_path)
```
%% Cell type:code id:a3de4db0 tags:
```
python
```
%% Cell type:code id:d93fb15c tags:
```
python
rdstar_fit_instance.fit_setup_info.component_id_column_name
```
%% Cell type:code id:c804ee1e tags:
```
python
[o.hist_var.df_label for o in rdstar_fit_instance.fit_setup_info.observable_infos]
```
%% Cell type:code id:fca92e20 tags:
```
python
from rdstar.offline_analysis.observables.common_observables import Cols
Cols.decay_mode_column_name
Cols.extended_sig_id_col
```
%% Cell type:code id:2cc14b96 tags:
```
python
```
%% Cell type:code id:7339ad69 tags:
```
python
```
%% Cell type:code id:6c7f7d28 tags:
```
python
_this_
fm = fit_evaluator.get_fit_manager_with(belle15_as_nominal=False)
```
%% Cell type:code id:864a6673 tags:
```
python
_this_
fdm = _this_fm._data_manager
```
%% Cell type:code id:56a3e898 tags:
```
python
[
_this_
fdm.get_file_path_for_key(sample_key=sample_key) for sample_key in _this_fdm.mc_sample_keys]
```
%% Cell type:code id:9af350ec tags:
```
python
[c for c in fit_data_frame.columns if "__coulomb_corr_factor__" in c]
```
%% Cell type:code id:aba6011a tags:
```
python
[c for c in fit_data_frame.columns if "exp" in c]
```
%% Cell type:code id:bd8ad0e5 tags:
```
python
```
%% Cell type:code id:bf369c44 tags:
```
python
```
%% Cell type:code id:8b578fd3 tags:
```
python
fit_evaluator.produce_money_plot(
base_name=fit_base_name,
fit_type_info=fit_type_info,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
sm_label=None,
np_label=None,
)
```
%% Cell type:code id:1e9a8082 tags:
```
python
for k, v in fit_evaluator._fit_container.items():
print(k, v.fit_result.errors)
```
%% Cell type:code id:a018c1e4 tags:
```
python
list(v.is_active for v in RDStarFitter.full_systematics_container.values())
```
%% Cell type:code id:030b2443 tags:
```
python
list(v.is_active for v in RDStarFitter.empty_systematics_container.values())
```
%% Cell type:code id:e22103f7 tags:
```
python
```
%% Cell type:code id:4a7ecaf0 tags:
```
python
fit_status_w_sys_b15 = fit_evaluator.get_fit(
run_if_necessary=True,
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=True,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
systematics_container=RDStarFitter.full_systematics_container,
)
```
%% Cell type:code id:543348ba tags:
```
python
fit_status_w_sys_b15.minuit_instance
```
%% Cell type:code id:cc695535 tags:
```
python
```
%% Cell type:code id:d39d7764 tags:
```
python
fit_status_wosys_b15 = fit_evaluator.get_fit(
run_if_necessary=True,
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=True,
bkg_handling_infos=RDStarFitter.basic_bkg_handler,
systematics_container=RDStarFitter.empty_systematics_container,
)
```
%% Cell type:code id:3bc73ad7 tags:
```
python
fit_status_wosys_b15.minuit_instance
```
%% Cell type:code id:65c9a0e5 tags:
```
python
```
%% Cell type:code id:4e8ed906 tags:
```
python
```
%% Cell type:code id:c3567f66 tags:
```
python
fit_status_only_with_add_mc_stats_sys = fit_evaluator.get_fit(
run_if_necessary=True,
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling=BKGHandling.BKG_FIXED,
stat_only=False,
systematics_names=tuple([]),
)
```
%% Cell type:code id:66cedd56 tags:
```
python
np.array(fit_status_only_with_add_mc_stats_sys.minuit_instance.errors)
```
%% Cell type:code id:03b59fc1 tags:
```
python
np.sqrt(np.square(4.74199783e-02) - np.square(4.54866715e-02))
```
%% Cell type:code id:eedda879 tags:
```
python
np.sqrt(np.square(2.38576550e-02) - np.square(2.29542698e-02))
```
%% Cell type:code id:05fa7e3c tags:
```
python
```
%% Cell type:code id:3981704a tags:
```
python
np.sqrt(np.square(4.76157646e-02) - np.square(4.74199783e-02))
```
%% Cell type:code id:1dc42b80 tags:
```
python
np.sqrt(np.square(2.40015210e-02) - np.square(2.38576550e-02))
```
%% Cell type:code id:0e0466e1 tags:
```
python
```
%% Cell type:code id:302c654c tags:
```
python
```
%% Cell type:code id:126c6c14 tags:
```
python
fit_status_only_stat_error = fit_evaluator.get_fit(
run_if_necessary=True,
base_name=fit_base_name,
fit_type_info=fit_type_info,
use_b2015_as_nominal=False,
bkg_handling=BKGHandling.BKG_FIXED,
stat_only=True,
systematics_names=tuple([]),
)
```
%% Cell type:code id:9f02c5c2 tags:
```
python
np.array(fit_status_only_stat_error.minuit_instance.errors)
```
%% Cell type:code id:b6084cfc tags:
```
python
np.array(fit_status_only_stat_error.minuit_instance.values)
```
%% Cell type:code id:7c9388dc tags:
```
python
```
...
...
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