Skip to content

Commit

Permalink
update codes following PR #965
Browse files Browse the repository at this point in the history
  • Loading branch information
SeiyaNozaki committed Apr 12, 2022
1 parent 6bbfabc commit e08e351
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
3 changes: 3 additions & 0 deletions docs/examples/dl3_tool_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"min_theta_cut": 0.05,
"max_theta_cut": 0.32,
"fill_theta_cut": 0.32,
"min_alpha_cut": 1,
"max_alpha_cut": 45,
"fill_alpha_cut": 45,
"allowed_tels": [1]
}
}
3 changes: 3 additions & 0 deletions docs/examples/irf_tool_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"min_theta_cut": 0.05,
"max_theta_cut": 0.32,
"fill_theta_cut": 0.32,
"min_alpha_cut": 1,
"max_alpha_cut": 45,
"fill_alpha_cut": 45,
"allowed_tels": [1]
},
"DataBinning": {
Expand Down
29 changes: 22 additions & 7 deletions lstchain/io/event_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ class DL3Cuts(Component):
default_value=0.2,
).tag(config=True)

min_alpha_cut = Float(
help="Minimum alpha cut (deg) in an energy bin",
default_value=1,
).tag(config=True)

max_alpha_cut = Float(
help="Maximum alpha cut (deg) in an energy bin",
default_value=45,
).tag(config=True)

fill_alpha_cut = Float(
help="Fill value of alpha cut (deg) in an energy bin with fewer " +
"than minimum number of events present",
default_value=45,
).tag(config=True)

alpha_containment = Float(
help="Percentage containment region for alpha cuts",
default=0.68,
Expand Down Expand Up @@ -213,8 +229,7 @@ def apply_global_alpha_cut(self, data):
return data[data["alpha"].to_value(u.deg) < self.global_alpha_cut]

def energy_dependent_alpha_cuts(
self, data, energy_bins, min_value=1 * u.deg,
max_value=90 * u.deg, smoothing=None, min_events=10
self, data, energy_bins, smoothing=None
):
"""
Evaluating an optimized energy-dependent alpha cuts, in a given
Expand All @@ -227,12 +242,12 @@ def energy_dependent_alpha_cuts(
data["alpha"],
data["reco_energy"],
bins=energy_bins,
min_value=min_value,
max_value=max_value,
fill_value=data["alpha"].max(),
min_value=self.min_alpha_cut * u.deg,
max_value=self.max_alpha_cut * u.deg,
fill_value=self.fill_alpha_cut * u.deg,
percentile=100 * self.alpha_containment,
smoothing=smoothing,
min_events=min_events,
min_events=self.min_event_p_en_bin,
)
return alpha_cuts

Expand All @@ -246,7 +261,7 @@ def apply_energy_dependent_alpha_cuts(self, data, alpha_cuts):
data["alpha"],
data["reco_energy"],
alpha_cuts,
operator.le,
operator.lt,
)
return data[data["selected_alpha"]]

Expand Down
1 change: 0 additions & 1 deletion lstchain/tools/lstchain_create_irf_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ def start(self):
if self.energy_dependent_alpha:
self.alpha_cuts = self.cuts.energy_dependent_alpha_cuts(
gammas, reco_energy_bins,
min_value=1 * u.deg, max_value=90 * u.deg,
)
gammas = self.cuts.apply_energy_dependent_alpha_cuts(
gammas, self.alpha_cuts
Expand Down

0 comments on commit e08e351

Please sign in to comment.