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

variables to reject abnormal noise #255

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
41 changes: 40 additions & 1 deletion hax/treemakers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
from hax.minitrees import TreeMaker
from collections import defaultdict

import numpy as np

class Fundamentals(TreeMaker):
"""Simple minitree containing basic information about every event, regardless of its contents.
Expand All @@ -23,6 +23,45 @@ def extract_data(self, event):
event_duration=event.stop_time - event.start_time)


class HitRejection(TreeMaker):
"""Extra information, mainly motivated by cuts used for the first science run.
If there are no interactions in the event, all these values will be NaN.

Provides:
- n_channels_rejected: number of channels that has rejected hits
- n_hits_rejected: total number of rejected hits
- n_lone_hits: total number of lone hits, after reject noise plugin
- n_lone_hits_channels: total number of channels that has lone hit, after reject noise plugin
- n_lone_hits_before: total number of lone hits, before reject noise plugin
- n_lone_hits_channels_before: total number of channels that has lone hit, before reject noise plugin
"""
__version__ = '0.1'
branch_selection = ['n_hits_rejected*', 'lone_hits_per_channel_before*', 'lone_hits_per_channel*']

def extract_data(self, event):
result = dict()

# Rejected hits
n_hits_rejected = event.n_hits_rejected
n_hits_rejected_flag = [it > 0 for it in n_hits_rejected]
result['n_channels_rejected'] = np.sum(n_hits_rejected_flag)
result['n_hits_rejected'] = np.sum(n_hits_rejected)

# lone hit after rejection
lone_hits_per_channel = event.lone_hits_per_channel
result['n_lone_hits'] = np.sum(lone_hits_per_channel)
lone_hits_per_channel_flag = [it > 0 for it in lone_hits_per_channel]
result['n_lone_hits_channels'] = np.sum(lone_hits_per_channel_flag)

# lone hit before rejection
lone_hits_per_channel_before = event.lone_hits_per_channel_before
result['n_lone_hits_before'] = np.sum(lone_hits_per_channel_before)
lone_hits_per_channel_flag_before = [it > 0 for it in lone_hits_per_channel_before]
result['n_lone_hits_channels_before'] = np.sum(lone_hits_per_channel_flag_before)

return result


class Extended(TreeMaker):
"""Extra information, mainly motivated by cuts used for the first science run.
If there are no interactions in the event, all these values will be NaN.
Expand Down