Skip to content

Commit

Permalink
Modified efield2voltage to work with multievents. Added aditional exa…
Browse files Browse the repository at this point in the history
…mple event to have 2 events.
  • Loading branch information
mjtueros committed Feb 9, 2024
1 parent 4e071fc commit 1a1b527
Show file tree
Hide file tree
Showing 151 changed files with 89,317 additions and 398 deletions.
7 changes: 4 additions & 3 deletions grand/sim/efield2voltage.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ def __init__(self, f_input, f_output="", seed=None, padding_factor=1.0):

directory_path, fname = os.path.split(f_input)

f_input_TRun=directory_path+"/trun_"+ fname[8:]
f_input_TShower=directory_path+"/tshower_"+ fname[8:]
#f_input_TRun=directory_path+"/run_"+ fname[7:]
f_input_TRun=directory_path+"/run.root"
f_input_TShower=directory_path+"/shower_"+ fname[7:]

#f_input_TRunShowerSim=directory_path+"/TRunShowerSim_"+ fname[8:]
#f_input_TShowerSim=directory_path+"/TShowerSim_"+ fname[8:]

#f_input_TRunEfieldSim=directory_path+"/TRunEfieldSim_"+ fname[8:]
f_input_TEfield=directory_path+"/tefield_"+ fname[8:]
f_input_TEfield=directory_path+"/efield_"+ fname[7:]

#print(f_input_TShower)
#print(f_input_TRun)
Expand Down
126 changes: 0 additions & 126 deletions sim2root/Common/ProduceGRANDRoot/ProduceGRANDRoot.py

This file was deleted.

14 changes: 7 additions & 7 deletions sim2root/Common/ProduceVoltage/ProduceVoltage.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def VoltGRANDRoot(InputFile, OutputFile):
#stdout,stderr=p.communicate()

#Use event number as seed
EventNumber=OutputFile.split("/")[-2][-4:] #the directory name has the event number at the end
Seed= str(int(time.clock_gettime(1)))

#regular
OutputFile1=OutputFile+"_with-rf_with-noise.root"
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + EventNumber +" --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + Seed +" --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
print("About to run:"+ cmd)
p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
stdout,stderr=p.communicate()
Expand All @@ -57,7 +57,7 @@ def VoltGRANDRoot(InputFile, OutputFile):

#no-noise
OutputFile1=OutputFile+"_with-rf_no-noise.root"
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + EventNumber +" --no_noise --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + Seed +" --no_noise --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
print("About to run:"+ cmd)
p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
stdout,stderr=p.communicate()
Expand All @@ -69,7 +69,7 @@ def VoltGRANDRoot(InputFile, OutputFile):

#no-rf
OutputFile1=OutputFile+"_no-rf_with-noise.root"
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + EventNumber +" --no_rf_chain --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + Seed +" --no_rf_chain --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
print("About to run:"+ cmd)
p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
stdout,stderr=p.communicate()
Expand All @@ -82,7 +82,7 @@ def VoltGRANDRoot(InputFile, OutputFile):

#no-rf -no-noise
OutputFile1=OutputFile+"_no-rf_no-noise.root"
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + EventNumber +" --no_noise --no_rf_chain --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
cmd=Python + " " + efield2volt + " " + InputFile + " --seed " + Seed +" --no_noise --no_rf_chain --verbose error --target_sampling_rate_mhz=500 --target_duration_us=4.096" + " -o " + OutputFile1
print("About to run:"+ cmd)
p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
stdout,stderr=p.communicate()
Expand Down Expand Up @@ -111,13 +111,13 @@ def main():
inputdirectory = sys.argv[1]
outputdirectory = sys.argv[2]

rawfile=glob.glob(inputdirectory+"/tefield_*.root")[0]
rawfile=glob.glob(inputdirectory+"/efield_*.root")[0]

head,tail=os.path.split(rawfile)

InputJobName=os.path.splitext(tail)[0]

OutFileName=outputdirectory+"/"+"tvoltage_"+InputJobName[8:]
OutFileName=outputdirectory+"/"+"voltage_"+InputJobName[8:]

logging.info("About to produce voltage for GRANDRoot file from "+rawfile)
logging.debug("output file will be in:"+OutFileName)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 12 additions & 17 deletions sim2root/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Welcome to Sim2Root
# Welcome to Sim2Root
originally developed as GrandRawRoot in https://github.com/jelenakhlr/GrandRawRoot

## authors
Expand All @@ -16,7 +16,7 @@ Common files are stored in the Common/ directory, Zharies specifics can be found
# How to run Sim2Root
If you want to convert an air shower simulation to the _GRANDRoot_ file format, follow these steps:

*step 1:* convert air shower simulation to the _RawRoot_ file format\
*step 1:* convert air shower simulation to the _rawroot_ file format\
For CoREAS follow the instructions under *1.a)*, for ZHAireS follow the instructions under *1.b)*.

*step 2:* convert your newly created _RawRoot_ file to the _GRANDRoot_ file format
Expand Down Expand Up @@ -59,31 +59,26 @@ To let ZHAIRESRawToRawROOT make the choices for you. This is equivalent to runni
## 2) Common/sim2root.py
Inside `Common/` you can find the final converter, `sim2root.py`

As input you need to give the ROOT file containing `RawRoot data TTrees`, as created with `CoreasToRawROOT` or `ZHAireSRawToRawROOT`.
As input you need to give the ROOT file containing `rawroot data TTrees`, as created with `CoreasToRawROOT` or `ZHAireSRawToRawROOT`.

i.e.

`python3 sim2root.py ../ZHAireSRawRoot/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618/Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618.RawRoot -fo sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618`
`python3 python ../grand/sim2root/Common/sim2root.py <your path>*/*.rawroot -s Xiaodushan -d 20221026 -t 180000 -e DC2Alpha


additional options are available on command line, see sim2root --help for more information

# 3) Simulation Pipe example (note that this assumes one event per directoy, and is not working on files with more than 1 event)
You will find two scripts illustrating how to use RawRoot files as starting point of a simulation pipe are in the "Common" directory.
Output File names are still not conforming to grand specifications.
additional options are available on command line, see sim2root --help for more information

The example shows how to use the example RawRoot file given in /grand/sim2root/ZHAireSRawRoot/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618 to produce the grandroot files including
4 tvoltage files with the antenna response with and without the rf chain. You can use the RawRoot file of your liking.
# 3) Simulation Pipe example

## 3a) GenerateGRANDRoot
python /ProduceGRANDRoot.py InputDirectory OutputDirectory
The example shows how to use the two example rawroot file given in /grand/sim2root/ZHAireSRawRoot/

python ProduceGRANDRoot.py <your path here>/grand/sim2root/ZHAireSRawRoot/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618 <your path here>/grand/sim2root/Common/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618
You can use the rawroot file of your liking. Now sim2root supports multiple events on the command line, so you just can make

## 3b) GenerateVoltage
python ProduceVoltage.py InputDirectory OutputDiectory
python ../grand/sim2root/Common/sim2root.py */*.rawroot -s Xiaodushan -d 20221026 -t 180000 -e DC2Alpha

python <your path here>/grand/sim2root/Common/ProduceVoltage/ProduceVoltage.py <your path here>/grand/sim2root/Common/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618 <your path here>/grand/sim2root/Common/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618

Note that in this example we set the InputDiretory to be the same as the Outputdirectory to get all the files in the same place.
python ../grand/scripts/convert_efield2voltage.py --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 ./sim_Xiaodushan_20221026_180000_RUN0_CD_DC2Alpha_0000/efield_0-1_L0_0000.root -o ./OutputFile-no_rf_chain.root --no_rf_chain --verbose=info


see the –help of convert_efiedl2voltage to see how that works.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Event Simulation Parameters##################################################################
EventName: GP300_Xi_Sib_Proton_3.87_79.4_310.0_13790
Primary: Proton
PrimaryEnergy: 3.8677e+09 GeV
Zenith: 79.43 deg
Azimuth: 310.00 deg Magnetic
Core Position: 6216.527 3102.476 0.000
ArrayName: GP300
EventWeight: 1.000
EventUnixTime: 0
EventUnixNanosecond: 0
#Core positions tested before generating the event ###########################################
#End of EventParameters####################################################################
Binary file not shown.
Loading

0 comments on commit 1a1b527

Please sign in to comment.