Skip to content

Commit

Permalink
Merge branch 'dev_sim2root' of https://github.com/grand-mother/grand
Browse files Browse the repository at this point in the history
…into dev_sim2root
  • Loading branch information
mjtueros committed Dec 23, 2024
2 parents 1feb809 + 0694fa9 commit 239ac73
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions sim2root/CoREASRawRoot/CoreasToRawROOT.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## by Jelena Köhler, @jelenakhlr

import sys
import numpy as np
import os
import glob
import time #to get the unix timestamp
Expand Down Expand Up @@ -237,6 +238,15 @@ def CoreasToRawRoot(file, simID=None):
ed_sum = energy_dep[:,9]


Egamma = np.sum(ed_gamma)
Eem_ion = np.sum(ed_em_ioniz)
Eem_cut = np.sum(ed_em_cut)

# calculate electromagnetic shower energy and convert to eV
Eem = (Egamma + Eem_ion + Eem_cut) * 1e9
print("Electromagnetic shower energy:", Eem)


##############################################

EnergyInNeutrinos = 1. # placeholder
Expand All @@ -261,6 +271,9 @@ def CoreasToRawRoot(file, simID=None):
site = read_site(inp_input)
latitude, longitude, altitude = read_lat_long_alt(site)

# set altitude to simulations obslevel
altitude = CorePosition[2]

############################################################################################################################
# Part B.I.ii: Create and fill the RAW Shower Tree
############################################################################################################################
Expand All @@ -282,6 +295,7 @@ def CoreasToRawRoot(file, simID=None):
RawShower.rnd_seed = RandomSeed

RawShower.energy_in_neutrinos = EnergyInNeutrinos
RawShower.energy_em = [Eem]
RawShower.energy_primary = [Energy]
RawShower.azimuth = azimuth
RawShower.zenith = zenith
Expand Down
3 changes: 3 additions & 0 deletions sim2root/Common/raw_root_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class RawShowerTree(MotherEventTree):

###X Primary energy (GeV)
energy_primary: StdVectorListDesc = field(default=StdVectorListDesc("float"))

###X Electromagnetic energy (GeV)
energy_em: StdVectorListDesc = field(default=StdVectorListDesc("float"))

### Shower azimuth (deg, CR convention)
_azimuth: np.ndarray = field(default_factory=lambda: np.zeros(1, np.float32))
Expand Down
4 changes: 3 additions & 1 deletion sim2root/Common/sim2root.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import raw_root_trees as RawTrees # this is here in Common
import grand.manage_log as mlg
import matplotlib.pyplot as plt
from scipy.ndimage.interpolation import shift #to shift the time trance for the trigger simulation
from scipy.ndimage import shift #to shift the time trance for the trigger simulation

# specific logger definition for script because __mane__ is "__main__" !
logger = mlg.get_logger_for_script(__file__)
Expand Down Expand Up @@ -560,6 +560,8 @@ def rawshower2grandroot(trawshower, gt):
# ToDo: it should be a scalar on sim side
gt.tshower.energy_primary = trawshower.energy_primary[0]

gt.tshower.energy_em = trawshower.energy_em[0]

### Shower azimuth (deg, CR convention)
gt.tshower.azimuth = trawshower.azimuth

Expand Down

0 comments on commit 239ac73

Please sign in to comment.