11#! /usr/bin/env bash
22
3- if [[ $* == * " -h" * ]]; then
4- echo " Script to generate LUTs from LUT writer, arguments:"
5- echo " 1) tag of the LUT writer [default]"
6- echo " 2) Magnetic field in T [0.5]"
7- echo " 3) Minimum radius of the track in cm [100]"
8- echo " 4) Path where the LUT writers are located [\$ DELPHESO2_ROOT/lut/]"
9- echo " 5) Output path where to write the LUTs [.]"
10- echo " 6) Particles to consider [\" 0 1 2 3 4\" ]"
11- exit 0
12- fi
13-
143WHAT=default
154FIELD=0.5
165RMIN=100.
17- OUT_PATH=.
186WRITER_PATH=$DELPHESO2_ROOT /lut/
7+ OUT_PATH=.
8+ OUT_TAG=
199PARTICLES=" 0 1 2 3 4"
2010
21- [ -z " $1 " ] || WHAT=$1
22- [ -z " $2 " ] || FIELD=$2
23- [ -z " $3 " ] || RMIN=$3
24- [ -z " $4 " ] || WRITER_PATH=$4
25- [ -z " $5 " ] || OUT_PATH=$5
26- [ -z " $6 " ] || PARTICLES=$6
11+ # Get the options
12+ while getopts " :t:B:R:p:o:T:P:h" option; do
13+ case $option in
14+ h) # display Help
15+ echo " Script to generate LUTs from LUT writer, arguments:"
16+ echo " Syntax: ./create_luts.sh [-h|t|B|R|p|o|T|P]"
17+ echo " options:"
18+ echo " -t tag of the LUT writer [default]"
19+ echo " -B Magnetic field in T [0.5]"
20+ echo " -R Minimum radius of the track in cm [100]"
21+ echo " -p Path where the LUT writers are located [\$ DELPHESO2_ROOT/lut/]"
22+ echo " -o Output path where to write the LUTs [.]"
23+ echo " -T Tag to append to LUTs [\"\" ]"
24+ echo " -P Particles to consider [\" 0 1 2 3 4\" ]"
25+ echo " -h Show this help"
26+ exit
27+ ;;
28+ t)
29+ WHAT=$OPTARG
30+ echo " > Setting LUT writer to ${WHAT} "
31+ ;;
32+ B)
33+ FIELD=$OPTARG
34+ echo " > Setting B field to ${FIELD} "
35+ ;;
36+ R)
37+ RMIN=$OPTARG
38+ echo " > Setting minimum radius to ${RMIN} "
39+ ;;
40+ p)
41+ WRITER_PATH=$OPTARG
42+ echo " > Setting LUT writer path to ${WRITER_PATH} "
43+ ;;
44+ o)
45+ OUT_PATH=$OPTARG
46+ echo " > Setting LUT output path to ${OUT_PATH} "
47+ ;;
48+ T)
49+ OUT_TAG=$OPTARG
50+ echo " > Setting LUT output tag to ${OUT_TAG} "
51+ ;;
52+ P)
53+ PARTICLES=$OPTARG
54+ echo " > Setting LUT particles to ${PARTICLES} "
55+ ;;
56+ \? ) # Invalid option
57+ echo " Error: Invalid option, use [-h|t|B|R|p|o|T|P]"
58+ exit
59+ ;;
60+ esac
61+ done
2762
2863cp " ${WRITER_PATH} /lutWrite.$WHAT .cc" . || { echo " cannot find lut writer: ${WRITER_PATH} /lutWrite.$WHAT .cc" ; exit 1; }
2964cp " ${WRITER_PATH} /DetectorK/DetectorK.cxx" .
3065cp " ${WRITER_PATH} /DetectorK/DetectorK.h" .
3166cp -r " ${WRITER_PATH} /fwdRes" .
3267cp " ${WRITER_PATH} /lutWrite.cc" .
33- cp " ${WRITER_PATH} /lutCovm.hh" .
3468
35- echo " --- creating LUTs: config = $WHAT , field = $FIELD T, min tracking radius = $RMIN cm"
69+ echo " --- creating LUTs: config = ${ WHAT} , field = ${ FIELD} T, min tracking radius = ${ RMIN} cm"
3670
3771for i in $PARTICLES ; do
3872 root -l -b << EOF
@@ -50,7 +84,7 @@ for i in $PARTICLES; do
5084 const float field = ${FIELD} f;
5185 const float rmin = ${RMIN} ;
5286 const int i = ${i} ;
53- lutWrite_${WHAT} ("${OUT_PATH} /lutCovm." + pn[i] + ".dat", pc[i], field, rmin);
87+ lutWrite_${WHAT} ("${OUT_PATH} /lutCovm." + pn[i] + "${OUT_TAG} .dat", pc[i], field, rmin);
5488
5589EOF
5690done
@@ -67,7 +101,7 @@ for i in $PARTICLES; do
67101 fi
68102done
69103
70- if [[ ! -z $NullSize ]]; then
104+ if [[ -n $NullSize ]]; then
71105 echo " Created null sized LUTs!!"
72106 exit 1
73107fi
0 commit comments