Skip to content

Commit

Permalink
move az transform into func
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusOrsoe committed Sep 17, 2024
1 parent 6cac966 commit 8cb660b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ def __call__(self, event: pd.DataFrame) -> pd.DataFrame:
"""Extract event-level truth information."""
# Extract data
visible_inelasticity = compute_visible_inelasticity(event)
muon_zenith, muon_azimuth = get_muon_direction(event)
muon_zenith, muon_azimuth = get_muon_direction(
event, self._transform_az
)
res = super().__call__(event=event)
# transform azimuth from [-pi, pi] to [0, 2pi] if wanted
if self._transform_az:
if len(res["initial_state_azimuth"]) > 0:
azimuth = np.asarray(res["initial_state_azimuth"]) + np.pi
azimuth = azimuth.tolist() # back to list
res["initial_state_azimuth"] = azimuth
muon_azimuth += np.pi
res["visible_inelasticity"] = [visible_inelasticity]
res["muon_azimuth"] = [muon_azimuth]
res["muon_zenith"] = [muon_zenith]
Expand Down
6 changes: 5 additions & 1 deletion src/graphnet/data/extractors/prometheus/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def compute_visible_inelasticity(mc_truth: pd.DataFrame) -> float:
return visible_inelasticity


def get_muon_direction(mc_truth: pd.DataFrame) -> Tuple[float, float]:
def get_muon_direction(
mc_truth: pd.DataFrame, transform_az: bool = False
) -> Tuple[float, float]:
"""Get angles of muon in nu_mu CC events."""
final_type_1, final_type_2 = abs(mc_truth["final_state_type"])
if mc_truth["interaction"] != 1:
Expand All @@ -77,6 +79,8 @@ def get_muon_direction(mc_truth: pd.DataFrame) -> Tuple[float, float]:
muon_azimuth = mc_truth["final_state_azimuth"][
abs(mc_truth["final_state_type"]) == 13
][0]
if transform_az:
muon_azimuth += np.pi
return muon_zenith, muon_azimuth


Expand Down

0 comments on commit 8cb660b

Please sign in to comment.