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

add proton decay event labelling #58

Merged
merged 1 commit into from
Sep 7, 2023
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
3 changes: 2 additions & 1 deletion pynuml/labels/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .standard import StandardLabels
from .simple import SimpleLabels
from .flavor import FlavorLabels
from .flavor import FlavorLabels
from .pdk import PDKLabels
33 changes: 33 additions & 0 deletions pynuml/labels/pdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pandas as pd

class PDKLabels:
def __init__(self):
self._labels = ('nu', 'pdk')

@property
def labels(self):
return self._labels

def label(self, idx: int):
if not 0 <= label < len(self._labels):
raise Exception(f'index {idx} out of range for {len(self._labels)} labels.')
return self._labels[idx]

def index(self, name: str):
if name not in self._labels:
raise Exception(f'"{name}" is not the name of a class.')
return self._labels.index(name)

@property
def nu(self):
return self.index('nu')

@property
def pdk(self):
return self.index('pdk')

def __call__(self, event: pd.Series):
if 12 <= abs(event.nu_pdg) <= 16:
return self.nu
else:
return self.pdk