Skip to content

Commit

Permalink
Merge branch '73_dev_efield2voltage' of https://github.com/grand-moth…
Browse files Browse the repository at this point in the history
…er/grand into 73_dev_efield2voltage
  • Loading branch information
mjtueros committed Feb 8, 2024
2 parents 2df60be + 7a81e16 commit e0cb796
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 83 deletions.
4 changes: 3 additions & 1 deletion sim2root/CoREASRawRoot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ The code will convert the specified CoREAS simulation into GRANDROOT format.


## How to run the whole CoreasToRawRoot + sim2root + efield2voltage
`python3 coreas_pipeline.py -d <directory with Coreas Sim>`
`python3 coreas_pipeline.py -d <directory with Coreas Sim>`\
optional: specify an output directory as well:\
`python3 coreas_pipeline.py -d <directory with Coreas Sim> -o <output directory>`\


## Overview
Expand Down
11 changes: 0 additions & 11 deletions sim2root/CoREASRawRoot/convert2root.sh

This file was deleted.

39 changes: 31 additions & 8 deletions sim2root/CoREASRawRoot/coreas_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,60 @@
print("* - * - * - * - * - * - * - * - * - *")
print(f"Converting Coreas Simulation {simID} to RawRoot format...")

# * - * - * - * - * - * - *
# Run CoreasToRawROOT.py
print("executing CoreasToRawROOT.py")
CoreasToRawROOT = [
'python3', 'CoreasToRawROOT.py', '-d', str(options.directory)
"python3", "CoreasToRawROOT.py", "-d", f"{str(options.directory)}"
]
subprocess.run(CoreasToRawROOT, check=True)
print(f"Created Coreas_{simID}.root")

print("* - * - * - * - * - * - * - * - * - *")
print(f"Converting from RawRoot to GRANDroot format...")

# Run sim2root.py
# * - * - * - * - * - * - *
print("executing sim2root.py")
# Run sim2root.py
sim2root = [
'python3', '../Common/sim2root.py', f"Coreas_{simID}.root"
"python3", f"../Common/sim2root.py", f"Coreas_{simID}.root", "-o", f"{str(options.directory)}"
]
subprocess.run(sim2root, check=True)
print(f"Created gr_Coreas_{simID}.root")
print(f"Created grandroot trees in {str(options.directory)}")
#! currently sim2root creates separate root files for each tree, so we need this for now:
sim2root_out = glob.glob(str(options.directory)+"/sim_*/tefield*")[0]

print("* - * - * - * - * - * - * - * - * - *")
print(f"Converting traces from efield to voltage...")

# * 1 * - * - * - * - * - * - *
print("executing convert_efield2voltage.py")
# Run convert_efield2voltage.py
sim2root = [
'python3', '../../scripts/convert_efield2voltage.py', f"gr_Coreas_{simID}.root",\
f"-o {options.output}/efield_gr_Coreas_{simID}.root"
voltage = [
"python3", "../../scripts/convert_efield2voltage.py", f"{sim2root_out}", "-o", f"{options.directory}/voltage_Coreas_{simID}.root"
]
subprocess.run(sim2root, check=True)
subprocess.run(voltage, check=True)
print(f"Created efield_gr_Coreas_{simID}.root")
print("********************************")

# * 2 * - * - * - * - * - * - *
print("executing convert_efield2voltage.py --no_noise")
# Run convert_efield2voltage.py
voltage = [
"python3", "../../scripts/convert_efield2voltage.py", f"{sim2root_out}", "--no_noise", "-o", f"{options.directory}/voltage_Coreas_{simID}_no_noise.root"
]
subprocess.run(voltage, check=True)
print(f"Created efield_gr_Coreas_{simID}_no_noise.root")

# * 3 * - * - * - * - * - * - *
print("executing convert_efield2voltage.py --no_noise --no_rf_chain")
# Run convert_efield2voltage.py
voltage = [
"python3", "../../scripts/convert_efield2voltage.py", f"{sim2root_out}", "--no_noise", "--no_rf_chain", "-o", f"{options.directory}/voltage_Coreas_{simID}_no_noise_no_rfchain.root"
]
subprocess.run(voltage, check=True)
print(f"Created efield_gr_Coreas_{simID}_no_noise_no_rfchain.root")

pass

print(f"Finished analyzing files in {options.directory}")
Expand Down
62 changes: 0 additions & 62 deletions sim2root/CoREASRawRoot/unzip_and_convert2root.py

This file was deleted.

20 changes: 19 additions & 1 deletion sim2root/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,27 @@ As input you need to give the ROOT file containing `RawRoot data TTrees`, as cre

i.e.

`python3 sim2root.py ../ZHAireSRawRoot/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618/Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618.RawRoot`
`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`

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.

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.

## 3a) GenerateGRANDRoot
python /ProduceGRANDRoot.py InputDirectory OutputDirectory

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

## 3b) GenerateVoltage
python ProduceVoltage.py InputDirectory OutputDiectory

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.


0 comments on commit e0cb796

Please sign in to comment.