From 25b3c24819aec00fe9c389b5ebff6b53c74794c9 Mon Sep 17 00:00:00 2001 From: mjtueros <51415063+mjtueros@users.noreply.github.com> Date: Mon, 29 Jan 2024 07:40:51 -0300 Subject: [PATCH 1/7] Update README.md --- sim2root/README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sim2root/README.md b/sim2root/README.md index 9f9e76bd..5c187123 100644 --- a/sim2root/README.md +++ b/sim2root/README.md @@ -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 /grand/sim2root/ZHAireSRawRoot/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618 /grand/sim2root/Common/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618 + +## 3b) GenerateVoltage +python ProduceVoltage.py InputDirectory OutputDiectory + +python /grand/sim2root/Common/ProduceVoltage/ProduceVoltage.py /grand/sim2root/Common/sim_Xiaodushan_20221026_1200_1_SIBYLL23d_GP300_1618 /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. From c19ce18409aa0ddcac693c554559beaa340e34ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelena=20K=C3=B6hler?= Date: Wed, 31 Jan 2024 15:21:24 +0100 Subject: [PATCH 2/7] delete unused script --- .../CoREASRawRoot/unzip_and_convert2root.py | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 sim2root/CoREASRawRoot/unzip_and_convert2root.py diff --git a/sim2root/CoREASRawRoot/unzip_and_convert2root.py b/sim2root/CoREASRawRoot/unzip_and_convert2root.py deleted file mode 100644 index f0c674c8..00000000 --- a/sim2root/CoREASRawRoot/unzip_and_convert2root.py +++ /dev/null @@ -1,62 +0,0 @@ -# author: @jelenakhlr -import os -import tarfile -import tempfile -import subprocess -from optparse import OptionParser - -path_to_grandlib = "/pbs/home/j/jpeterei/grandlib_dev_io_root/grand/" #! modfiy this path if necessary - -parser = OptionParser() -parser.add_option("--directory", "--dir", "-d", type="str", - help="Specify the full path to the directory of the MULTIPLE simulation sets.") -parser.add_option("--file", "-f", type="str", - help="Specify the full path to the SINGLE simulation set you want to analyze.") -(options, args) = parser.parse_args() - - -# # Create a temporary directory -temp_dir = "/sps/grand/jelena/stshp+GP13/temp/" -out_dir = "/sps/grand/jelena/stshp+GP13/root/" -print("Created temp directory", temp_dir) - -if __name__ == '__main__': - # Check that the user has specified a directory or a single file. - if options.directory: - input_directory = options.directory - for filename in os.listdir(input_directory): - if filename.endswith('.tar.gz'): - print(f"file {filename} unzipped to {temp_dir}") - file_path = os.path.join(input_directory, filename) - - # Extract the .tar.gz file into the temporary directory - with tarfile.open(file_path, 'r:gz') as tar: - tar.extractall(path=temp_dir) - elif options.file: - file_path = options.file - input_directory = os.path.dirname(file_path) - if file_path.endswith('.tar.gz'): - print(f"file {file_path} unzipped to {temp_dir}") - # Extract the .tar.gz file into the temporary directory - with tarfile.open(file_path, 'r:gz') as tar: - tar.extractall(path=temp_dir) - else: - print(f"ERROR: {file_path} is not a .tar.gz file") - exit() - else: - parser.print_help() - - - # Perform the analysis on the contents of the temporary directory. - print("Converting to GRANDroot format...") - coreas_pipeline = [ - 'python3', f'{path_to_grandlib}sim2root/CoREASRawRoot/coreas_pipeline.py', '-d', f"{temp_dir}*/run??/",\ - '-o', f'{outdir}' - ] - # python3 /pbs/home/j/jpeterei/grandlib_dev_io_root/grand/sim2root/CoREASRawRoot/coreas_pipeline.py -d /sps/grand/jelena/stshp+GP13/temp/*/run??/ -o /sps/grand/jelena/stshp+GP13/root/ - subprocess.run(coreas_pipeline, check=True) - print(f"Coreas simulations in GRANDroot format saved to {out_dir}") - - # Delete the temporary directory and its contents - # subprocess.run(['rm', '-r', temp_dir], check=True) - # print("Removed temp directory") From 2b22d2f78f81e7d400a768399e12bcbe170f3210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelena=20K=C3=B6hler?= Date: Wed, 31 Jan 2024 15:22:38 +0100 Subject: [PATCH 3/7] delete unused script --- sim2root/CoREASRawRoot/convert2root.sh | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 sim2root/CoREASRawRoot/convert2root.sh diff --git a/sim2root/CoREASRawRoot/convert2root.sh b/sim2root/CoREASRawRoot/convert2root.sh deleted file mode 100644 index 62b91fd9..00000000 --- a/sim2root/CoREASRawRoot/convert2root.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -#SBATCH --job-name=2root -#SBATCH --output=2root.out - -# Request resources (e.g., CPU cores, memory, and time) -#SBATCH --nodes=1 # Number of compute nodes -#SBATCH --ntasks=1 # Number of CPU cores -#SBATCH --mem=4G # Memory per node -#SBATCH --time=1:00:00 # Maximum job duration (hours:minutes:seconds) - -python3 unzip_and_convert2root.py -f /sps/grand/jelena/stshp+GP13/archive/proton_run01.tar.gz From 9a3f28216ec939e483eb3f15c3ce743213ae6847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelena=20K=C3=B6hler?= Date: Wed, 31 Jan 2024 16:27:02 +0100 Subject: [PATCH 4/7] update coreas pipeline for current voltage converter --- sim2root/CoREASRawRoot/coreas_pipeline.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sim2root/CoREASRawRoot/coreas_pipeline.py b/sim2root/CoREASRawRoot/coreas_pipeline.py index 1f53a605..4a0ef72f 100644 --- a/sim2root/CoREASRawRoot/coreas_pipeline.py +++ b/sim2root/CoREASRawRoot/coreas_pipeline.py @@ -51,10 +51,11 @@ 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") @@ -62,24 +63,27 @@ 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)}", "-se", f"{simID}" ] 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...") + # * - * - * - * - * - * - * 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("********************************") pass From 487273250c8688386141e633c0775a0cee787f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelena=20K=C3=B6hler?= Date: Wed, 31 Jan 2024 16:32:16 +0100 Subject: [PATCH 5/7] update readme on coreas pipeline usage --- sim2root/CoREASRawRoot/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sim2root/CoREASRawRoot/README.md b/sim2root/CoREASRawRoot/README.md index 425a02a0..460ffccf 100644 --- a/sim2root/CoREASRawRoot/README.md +++ b/sim2root/CoREASRawRoot/README.md @@ -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 ` +`python3 coreas_pipeline.py -d `\ +optional: specify an output directory as well:\ +`python3 coreas_pipeline.py -d -o `\ ## Overview From 8351153895c180d5dbced489040040fe18322205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelena=20K=C3=B6hler?= Date: Thu, 1 Feb 2024 14:27:27 +0100 Subject: [PATCH 6/7] add voltage versions "no noise" and "no noise + no rf chain" to the coreas pipeline --- sim2root/CoREASRawRoot/coreas_pipeline.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sim2root/CoREASRawRoot/coreas_pipeline.py b/sim2root/CoREASRawRoot/coreas_pipeline.py index 4a0ef72f..195e24c6 100644 --- a/sim2root/CoREASRawRoot/coreas_pipeline.py +++ b/sim2root/CoREASRawRoot/coreas_pipeline.py @@ -77,7 +77,7 @@ print("* - * - * - * - * - * - * - * - * - *") print(f"Converting traces from efield to voltage...") - # * - * - * - * - * - * - * + # * 1 * - * - * - * - * - * - * print("executing convert_efield2voltage.py") # Run convert_efield2voltage.py voltage = [ @@ -86,6 +86,25 @@ 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}") From 7a81e16ddcb835d29dd627167a33631c09e49532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelena=20K=C3=B6hler?= <108803123+jelenakhlr@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:20:36 +0100 Subject: [PATCH 7/7] removing -se from coreas_pipeline.py because a) I used it wrong and b) it's not even needed --- sim2root/CoREASRawRoot/coreas_pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim2root/CoREASRawRoot/coreas_pipeline.py b/sim2root/CoREASRawRoot/coreas_pipeline.py index 195e24c6..92850663 100644 --- a/sim2root/CoREASRawRoot/coreas_pipeline.py +++ b/sim2root/CoREASRawRoot/coreas_pipeline.py @@ -67,7 +67,7 @@ print("executing sim2root.py") # Run sim2root.py sim2root = [ - "python3", f"../Common/sim2root.py", f"Coreas_{simID}.root", "-o", f"{str(options.directory)}", "-se", f"{simID}" + "python3", f"../Common/sim2root.py", f"Coreas_{simID}.root", "-o", f"{str(options.directory)}" ] subprocess.run(sim2root, check=True) print(f"Created grandroot trees in {str(options.directory)}")