Skip to content

Commit

Permalink
Turn off add_eps_to_hist in NR and ER (#152)
Browse files Browse the repository at this point in the history
* turn off add_eps_to_hist

* force nr and er to be NOT add_eps_to_hist

* warning

* default add_eps_to_hist False with annotation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* will the default Flase save it?

* warning into init

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
FaroutYLq and pre-commit-ci[bot] authored Mar 15, 2024
1 parent 713ff3d commit ba4c14e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion appletree/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class Component:

rate_name: str = ""
norm_type: str = ""
add_eps_to_hist: bool = True
add_eps_to_hist: bool = (
True # add_eps_to_hist==True was introduced as only a workaround for likelihood blowup problem when using meshgrid binning
)
force_no_eff: bool = False

def __init__(self, name: Optional[str] = None, llh_name: Optional[str] = None, **kwargs):
Expand All @@ -51,6 +53,13 @@ def __init__(self, name: Optional[str] = None, llh_name: Optional[str] = None, *
if "bins" in kwargs.keys() and "bins_type" in kwargs.keys():
self.set_binning(**kwargs)

if self.bins_type != "meshgrid" and self.add_eps_to_hist:
warn(
"It is empirically dangerous to have add_eps_to_hist==True,\
when your bins_type is not meshgrid! It may lead to very bad fit with\
lots of eff==0."
)

def set_binning(self, **kwargs):
"""Set binning of component."""
if "bins" not in kwargs.keys() or "bins_type" not in kwargs.keys():
Expand Down
2 changes: 2 additions & 0 deletions appletree/components/er.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class ERBand(ComponentSim):
norm_type = "on_pdf"
add_eps_to_hist = False

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -19,6 +20,7 @@ def __init__(self, *args, **kwargs):

class ERPeak(ComponentSim):
norm_type = "on_pdf"
add_eps_to_hist = False

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions appletree/components/nr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class NR(ComponentSim):
norm_type = "on_pdf"
add_eps_to_hist = False

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit ba4c14e

Please sign in to comment.