Skip to content

Commit

Permalink
Fixed bugs in CoreasToRawRoot with t_pre, t_post, t_0 and xmax_grams
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMino committed Jul 1, 2024
1 parent 243854d commit 02f9251
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
6 changes: 3 additions & 3 deletions sim2root/CoREASRawRoot/CoreasToRawROOT.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ def CoreasToRawRoot(file, simID=None):

# define time params:
t_length = len(timestamp)
t_0 = timestamp[0] + t_length/2
t_0 = timestamp[0] + t_length/2 * TimeBinSize
t_pre = 800#ns
t_pre = t_length/2
t_post = t_length/2
t_pre = t_length/2 * TimeBinSize
t_post = t_length/2 * TimeBinSize

# add to ROOT tree
# in Zhaires converter: AntennaN[ant_ID]
Expand Down
20 changes: 2 additions & 18 deletions sim2root/CoREASRawRoot/CorsikaInfoFuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,7 @@ def read_long(pathLongFile):
TODO: fix hillas_parameter - something's not working yet
"""
with open(pathLongFile, mode="r") as file:
# create a temporary file to write the corrected contents
temp_file = io.StringIO()

for line in file:
# use a regex to search for a minus sign that is not part of an exponent
if search(r"(?<!e)(-)(?=\d)", line):
# if the minus sign is not part of an exponent, replace it with a space and a minus sign
line = line.replace("-", " -")
# write the corrected line to the temporary file
temp_file.write(line)

# set the file pointer to the beginning of the temporary file
temp_file.seek(0)

# read the contents of the temporary file into a list of strings
lines = temp_file.readlines()

lines=file.readlines


n_steps = int(lines[0].rstrip().split()[3])
Expand All @@ -310,7 +294,7 @@ def read_long(pathLongFile):
hillas_parameters = []
for line in lines:
if bool(search("PARAMETERS", line)):
parts = re.split(r"\s+", line)
parts = line.split()
param1, param2, xmax, param4, param5, param6 = parts[2], parts[3], parts[4], parts[5], parts[6], parts[7]
hillas_parameters.append(xmax)
if bool(search("CHI", line)):
Expand Down

0 comments on commit 02f9251

Please sign in to comment.