-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze_scalers.sh
executable file
·35 lines (27 loc) · 1 KB
/
analyze_scalers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
# Folder with the root files
root_files="./replay_root_files"
# Folder where the output PDFs will go
output_folder="./scaler_outfiles"
# Create it if it doesn't exist
[ ! -d "$output_folder" ] && mkdir -p -- "$output_folder"
for file in "$root_files"/*; do
# Start subshell, because I'm new to changing IFS so I don't know all the
# side effects. This avoids them entirely, by only changing IFS for the
# part I need.
run_number=$(
# Set the In Field Separator to underscore, so the filename can be
# easily split into pieces
IFS=_
# Converts the variable into positional parameters, so we can
# slice out the desired value. Trim the leading path as well, so we
# only get the filename.
set ${file##*/}
# Echo only the run number, captured by the command substitutuon
echo "$4"
)
# Construct the output PDF name
output_pdf="$output_folder/run_${run_number}_scaler.pdf"
# Run root on the original filename, and pass the output PDF
root -q "compare_scalers.C(\"$file\", \"$output_pdf\")"
done