Skip to content

Commit 637be33

Browse files
authored
Merge pull request #29 from JBernete/patch-1
Update generate_DL2_file.py
2 parents 04e4bcf + 61159ae commit 637be33

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

DL2/generate_DL2_file.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ def cli(filenames, cut_level, debug, output, layout, event_type):
110110

111111
if event_type > 0:
112112
logging.info(f"Number of events within event_type file: {len(event_types)}")
113+
ratio = np.sum(event_types == -1) / len(event_types)
113114
logging.info(
114-
f"Ratio of training to simulated events: {np.sum(event_types == -1) / len(event_types)}"
115+
f"Ratio of training to simulated events: {ratio}"
115116
)
116117
logging.info(f"len(data_mask): {len(data_mask)}")
117118
data_mask[data_mask] = event_types == event_type
@@ -121,6 +122,7 @@ def cli(filenames, cut_level, debug, output, layout, event_type):
121122

122123
else:
123124
logging.info(f"Surviving events: {np.count_nonzero(data_mask)} (cut level {cut_level})")
125+
ratio = 0
124126

125127
# columns readable without transformation
126128
EVENTS_COLUMNS = {
@@ -187,7 +189,10 @@ def cli(filenames, cut_level, debug, output, layout, event_type):
187189
# Store the histogram of simulated events vs MC_ENERGY
188190
energy_low = u.Quantity(10 ** bin_edges[:-1], u.TeV, copy=False)
189191
energy_high = u.Quantity(10 ** bin_edges[1:], u.TeV, copy=False)
190-
num_events = bin_content
192+
# If there are events used in the event-types training, that proportion must be
193+
# excluded from the number of events in the simulation, so the IRFs can be
194+
# then computed properly
195+
num_events = bin_content * (1 - ratio)
191196

192197
simulated_events = Table()
193198
simulated_events["MC_ENERG_LO"] = energy_low

0 commit comments

Comments
 (0)