Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev_sim2root' into dev_sim2root
Browse files Browse the repository at this point in the history
  • Loading branch information
lwpiotr committed Apr 15, 2024
2 parents 1b1b5bc + e94bcd4 commit 3d79ac5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/convert_voltage2adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_noise_trace(data_dir,

noise_trace[trace_idx] = trace
trace_idx += 1

df.Close()
return noise_trace


Expand Down
2 changes: 1 addition & 1 deletion sim2root/Common/sim2root.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def get_tree_du_id_and_xyz(trawefield,shower_core):
# Get the ids and positions from all the events

#trawefield has the antenna positions in array coordinates, cartesian. Origin is at the delcared latitude, longitude and altitude of the site.
print("Warning: using flat earth approximation for coordinates!. Core:",shower_core)
print("Warning: using flat earth approximation for coordinates!.Event:",trawefield.event_number," Core:",shower_core)
count = trawefield.draw("du_id:du_x:du_y:du_z", "", "goff")
du_ids = np.array(np.frombuffer(trawefield.get_v1(), dtype=np.float64, count=count)).astype(int)
du_xs = np.array(np.frombuffer(trawefield.get_v2(), dtype=np.float64, count=count)).astype(np.float32)
Expand Down
20 changes: 15 additions & 5 deletions sim2root/ZHAireSRawRoot/ZHAireSRawToRawROOT.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def ZHAireSRawToRawROOT(InputFolder, OutputFileName="GRANDConvention", RunID="Su
tracefiles=glob.glob(InputFolder+ending_e)
tracefiles=sorted(tracefiles, key=lambda x:int(x.split(".trace")[0].split("/a")[-1]))

if(SimEfieldInfo and len(tracefiles)>0):
if(SimEfieldInfo ):

RawEfield = RawTrees.RawEfieldTree(OutputFileName)

Expand All @@ -437,7 +437,15 @@ def ZHAireSRawToRawROOT(InputFolder, OutputFileName="GRANDConvention", RunID="Su
#RefrIndex=R0*np.exp(Atmostable.T[0]*RefractionIndexParameters[1]/1000)
Atmosrefractivity=R0*np.exp(Atmosaltitude*RefractionIndexParameters[1]/1000.0)

AntennaN,IDs,antx,anty,antz,antt=AiresInfo.GetAntennaInfoFromSry(sryfile[0])

if(len(tracefiles)>0):
AntennaN,IDs,antx,anty,antz,antt=AiresInfo.GetAntennaInfoFromSry(sryfile[0])
else:
IDs=[-1]
antx=[-1]
anty=[-1]
antz=[-1]
antt=[-1]
#############################################################################################################################
# Fill RawEfield part
############################################################################################################################
Expand Down Expand Up @@ -474,8 +482,10 @@ def ZHAireSRawToRawROOT(InputFolder, OutputFileName="GRANDConvention", RunID="Su
############################################################################################################################

if(IDs[0]==-1 and antx[0]==-1 and anty[0]==-1 and antz[0]==-1 and antt[0]==-1):
logging.critical("hey, no antennas found in event sry "+ str(EventID)+" SimEfield not produced")

logging.critical("hey, no antennas found in event sry "+ str(EventID)+" bin size "+str(RawEfield.t_bin_size))

RawEfield.fill()
RawEfield.write()
else:

#convert to 32 bits so it takes less space
Expand Down Expand Up @@ -652,7 +662,7 @@ def ZHAireSRawToRawROOT(InputFolder, OutputFileName="GRANDConvention", RunID="Su
#print("Wrote RawEfield")

else:
logging.critical("no trace files found in "+InputFolder+"Skipping SimEfield") #TODO: handle this exeption more elegantly
logging.critical("no trace files found in "+InputFolder+" Skipping SimEfield") #TODO: handle this exeption more elegantly


#############################################################################################################################
Expand Down

0 comments on commit 3d79ac5

Please sign in to comment.