Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for scaling true energy in IRFs to assess energy-scale systematics #1261

Merged
merged 35 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b85e538
Update event_selection.py
deborahDOR May 27, 2024
14d53d1
Update lstchain_create_irf_files.py
deborahDOR May 27, 2024
ee2ff27
Update irf_dl3_tool_config.json
deborahDOR May 27, 2024
0ac1de3
Update event_selection.py
deborahDOR May 27, 2024
e0b8f9a
Update lstchain_create_irf_files.py
deborahDOR May 27, 2024
00dbe27
Update irf_dl3_tool_config.json
deborahDOR Jun 7, 2024
de4b751
Update lstchain_create_irf_files.py
deborahDOR Jun 7, 2024
e06e0ac
Update lstchain_create_irf_files.py
deborahDOR Jun 7, 2024
eb1c4ab
Update lstchain_create_irf_files.py
deborahDOR Jun 11, 2024
eac6f10
Update lstchain_create_irf_files.py
deborahDOR Jun 12, 2024
319258a
Update lstchain_create_irf_files.py
deborahDOR Jun 12, 2024
f28019d
Update test_tools.py
deborahDOR Jul 2, 2024
d9673e1
Update test_tools.py
deborahDOR Jul 2, 2024
c239f72
Create irf_dl3_tool_config_mod.json
deborahDOR Jul 2, 2024
3d0a153
Update test_tools.py
deborahDOR Jul 3, 2024
13c085a
Merge branch 'main' into energy_systematics_in_irfs
chaimain Jul 3, 2024
b8fb8c5
Update test_tools.py
deborahDOR Jul 3, 2024
7a92409
Delete docs/examples/irf_dl3_tool_config_mod.json
deborahDOR Jul 3, 2024
be83a58
Update lstchain_create_irf_files.py
deborahDOR Jul 3, 2024
f8614a2
Update test_tools.py
deborahDOR Jul 4, 2024
a41fa4f
Update lstchain_create_irf_files.py
deborahDOR Jul 4, 2024
dc361ce
Update lstchain_create_irf_files.py
deborahDOR Jul 4, 2024
9a0605a
Update test_tools.py
deborahDOR Jul 4, 2024
221aaf7
Update test_tools.py
deborahDOR Jul 4, 2024
264f39c
[skip ci] typo
morcuended Jul 4, 2024
ce611f5
Improve the exploration of Simtel config history to handle more LST M…
gabemery Jul 3, 2024
8b7d8f6
Fix test
gabemery Jul 3, 2024
b28556c
Convert to float
gabemery Jul 3, 2024
edfaf39
Remove try block without handled exception.
gabemery Jul 4, 2024
b0820e6
Add warning log message
gabemery Jul 4, 2024
c137ade
Move comment about NSB extraction from simtel file to the function do…
gabemery Jul 5, 2024
037f900
Run black and add the missing pytest marker
chaimain Jul 8, 2024
66a99d7
Update test_tools.py by running black and adding a missing pytest marker
chaimain Jul 8, 2024
980aabe
Update test_tools.py
chaimain Jul 8, 2024
e999002
Run pyflakes to clean up rebase issues
chaimain Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/examples/irf_dl3_tool_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"true_energy_min": 0.005,
"true_energy_max": 500,
"true_energy_n_bins": 25,
"scale_true_energy": 1.0,
"reco_energy_min": 0.005,
"reco_energy_max": 500,
"reco_energy_n_bins": 25,
Expand Down
5 changes: 5 additions & 0 deletions lstchain/io/event_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ class DataBinning(Component):
default_value=25,
).tag(config=True)

scale_true_energy= Float(
help="Scaling value for True energy",
default_value=1.0,
).tag(config=True)

reco_energy_min = Float(
help="Minimum value for Reco Energy bins in TeV units",
default_value=0.005,
Expand Down
29 changes: 27 additions & 2 deletions lstchain/tools/lstchain_create_irf_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
If you want to generate source-dependent IRFs, source-dep flag should be activated.
The global alpha cut used to generate IRFs is stored as AL_CUT in the HDU header.

Modified IRFs with true energy scaled by a given factor can be created to evaluate
the systematic uncertainty in the light collection efficiency. This can be done by
setting a value different from one for the "scale_true_energy" argument present in
the DataBinning Component of the configuration file of the IRF creation Tool.
(The true energy of the MC events will be scaled before filling the IRFs histograms
when pyirf commands are used. The effects expected are a non-diagonal energy dispersion
matrix and a different spectrum).


"""

from astropy import table
Expand Down Expand Up @@ -136,7 +145,13 @@
--global-alpha-cut 10
--source-dep

"""
To build modified IRFs by specifying a scaling factor applying to the true energy (without using a config file):
> lstchain_create_irf_files
-g /path/to/DL2_MC_gamma_file.h5
-o /path/to/irf.fits.gz
--point-like (Only for point_like IRFs)
chaimain marked this conversation as resolved.
Show resolved Hide resolved
--scaling_true_energy 1.15
"""

input_gamma_dl2 = traits.Path(
help="Input MC gamma DL2 file",
Expand Down Expand Up @@ -221,6 +236,7 @@
"global-alpha-cut": "DL3Cuts.global_alpha_cut",
"allowed-tels": "DL3Cuts.allowed_tels",
"overwrite": "IRFFITSWriter.overwrite",
"scale_true_energy": "DataBinning.scale_true_energy"
chaimain marked this conversation as resolved.
Show resolved Hide resolved
}

flags = {
Expand Down Expand Up @@ -317,6 +333,12 @@
p["geomag_params"],
) = read_mc_dl2_to_QTable(p["file"])


if self.data_bin.scale_true_energy != 1.0:
p["events"]["true_energy"] *= self.data_bin.scale_true_energy
p["simulation_info"].energy_min *= self.data_bin.scale_true_energy
p["simulation_info"].energy_max *= self.data_bin.scale_true_energy

Check warning on line 340 in lstchain/tools/lstchain_create_irf_files.py

View check run for this annotation

Codecov / codecov/patch

lstchain/tools/lstchain_create_irf_files.py#L338-L340

Added lines #L338 - L340 were not covered by tests

p["mc_type"] = check_mc_type(p["file"])

self.log.debug(
Expand Down Expand Up @@ -527,7 +549,10 @@
geomag_params["GEOMAG_DELTA"].to_value(u.deg),
"deg",
)

extra_headers["ETRUE_SCALE"]= (
self.data_bin.scale_true_energy
)

if self.point_like:
self.log.info("Generating point_like IRF HDUs")
else:
Expand Down