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

Filters In truth table, osc_weight in retro table #184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 24 additions & 13 deletions src/graphnet/data/i3extractor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import List
from typing import List, Any, Union
import numpy as np
import matplotlib.path as mpath
try:
Expand Down Expand Up @@ -279,11 +279,23 @@ def __call__(self, frame, padding_value=-1) -> dict:
'SubrunID': frame['I3EventHeader'].sub_run_id,
'EventID': frame['I3EventHeader'].event_id,
'SubEventID': frame['I3EventHeader'].sub_event_id,
'DeepCoreFilter_13': padding_value,
'CascadeFilter_13': padding_value,
'MuonFilter_13': padding_value,
'OnlineL2Filter_17': padding_value,
'dbang_decay_length': padding_value,
'track_length': padding_value,
'stopped_muon': padding_value,
}

if frame['I3EventHeader'].sub_event_stream == 'InIceSplit': #only inicesplit p frames have filters calculated
output.update({
'DeepCoreFilter_13': int(bool(frame['FilterMask']['DeepCoreFilter_13'])),
'CascadeFilter_13': int(bool(frame['FilterMask']['CascadeFilter_13'])),
'MuonFilter_13': int(bool(frame['FilterMask']['MuonFilter_13'])),
'OnlineL2Filter_17': int(bool(frame['FilterMask']['OnlineL2Filter_17'])),
})

if is_mc == True and is_noise == False:
MCInIcePrimary, interaction_type, elasticity = get_primary_particle_interaction_type_and_elasticity(frame, sim_type)
output.update({
Expand Down Expand Up @@ -380,27 +392,26 @@ def __call__(self, frame) -> dict:
for classifier in classifiers:
if frame_has_key(frame, classifier):
output.update({classifier : frame[classifier].value})
#output.update({
# 'L7_MuonClassifier_FullSky_ProbNu': frame["L7_MuonClassifier_FullSky_ProbNu"].value,
# 'L4_MuonClassifier_Data_ProbNu': frame["L4_MuonClassifier_Data_ProbNu"].value,
# 'L4_NoiseClassifier_ProbNu': frame["L4_NoiseClassifier_ProbNu"].value,
# 'L7_PIDClassifier_FullSky_ProbTrack': frame["L7_PIDClassifier_FullSky_ProbTrack"].value,
#})

if frame_is_montecarlo(frame):
if frame_contains_retro(frame):
if frame_is_noise(frame):
output.update({
'osc_weight': frame["I3MCWeightDict"]["weight"],
'osc_weight': frame["noise_weight"]["weight"],
})
Comment on lines -391 to 400
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RasmusOrsoe, does this change affect you? Perhaps it would be better to introduce a new output variable called noise_weight or similar?

Copy link
Collaborator

@RasmusOrsoe RasmusOrsoe Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @asogaard. This looks suspicious, so thanks for pointing it out!

However, I think this is a change following an offline conversation I had with Leon. The I3MCWeightDict weight weighs events to physical rates. If I remember correctly, this weight is not stored in ["I3MCWeightDict"] for pure noise events, and I think this is why Leon is adding it from a different field for noise events. @BozianuLeon can you confirm?

edit: Since osc_weight is our physical event weight, then I think it is completely fine to do what Leon does here - granted Leon can confirm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm what you are saying @RasmusOrsoe, this is oscNext's way of handling weights of noise events, just storing it somewhere differently. I do not think we lose any information by overwriting osc_weight here

else:
output.update({
'osc_weight': -1.,
})

output['osc_weight'] = try_get_key(frame["I3MCWeightDict"],'weight',default_value=-1)

return output


# Utilty methods
def try_get_key(frame, key, default_value=-1):
"""Return `key` in `frame` if it exists; otherwise return `default_value."""
try:
return frame[key]
except KeyError:
return default_value

def frame_contains_retro(frame):
return frame_has_key(frame, "L7_reconstructed_zenith")

Expand Down
2 changes: 1 addition & 1 deletion src/graphnet/data/sqlite_dataconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def any_pulsemap_is_non_empty(self, data_dict: OrderedDict) -> bool:
there are any, from the pulsemap key(s) (e.g SplitInIcePulses). If at least
one of the pulsemaps is non-empty then return true.
"""
pulsemap_dicts = map(data_dict.get, self._pulsemap)
pulsemap_dicts = map(data_dict.get, self._pulsemaps)
return any(d['dom_x'] for d in pulsemap_dicts)

def _run_sql_code(self, database: str, code: str):
Expand Down