-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclas12Maps.sh
executable file
·97 lines (76 loc) · 2.06 KB
/
clas12Maps.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/zsh
# example:
#
# ./clas12Maps.sh Linear torus
if [ "$#" -ne 2 ]; then
echo " " >&2
echo " Usage:" >&2
echo " " >&2
echo " $0 interpolation field" >&2
echo " " >&2
echo " interpolation: <None> or <Linear>" >&2
echo " field: <solenoid> or <torus>" >&2
echo " " >&2
exit 1
fi
interpolation=$1
if [[ $interpolation != "None" && $interpolation != "Linear" ]]; then
echo " interpolation: <None> or <Linear>" >&2
exit 1
fi
field=$2
if [[ $field != "solenoid" && $field != "torus" ]]; then
echo " field: <solenoid> or <torus>" >&2
exit 1
fi
ngreps=1
fileNamePoints=$field$interpolation".txt"
fileNameL=gemcLog$fileNamePoints
fileNameG=gemc$fileNamePoints
rm -f $fileNameG ; touch $fileNameG
rm -f $fileNameL ; touch $fileNameL
echo
echo Interpolation: $interpolation
echo Field: $field
echo FileName with Requested Vertex Points: $fileNamePoints
echo FileName with Gemc Log: $fileNameG
echo FileName with Gemc Results: $fileNameG
echo
# units in mm
npoints=10
minX=1
maxX=5000
minY=1
maxY=5000
minZ=-3000
maxZ=3000
if [[ $field == "torus" ]]; then
minX=100
maxX=2000
minY=100
maxY=2000
minZ=1000
maxZ=6000
ngreps=5
fi
xvalues=(${(f)"$(jot -r $npoints $minX $maxX)"})
yvalues=(${(f)"$(jot -r $npoints $minY $maxY)"})
zvalues=(${(f)"$(jot -r $npoints $minZ $maxZ)"})
rm -f $fileNamePoints ; touch $fileNamePoints
for i in {1..$npoints}
do
# decimal points
decimal=(${(f)"$(jot -r 3 0 1000)"})
echo "("$xvalues[$i]"."$decimal[1]", "$yvalues[$i]"."$decimal[2]", "$zvalues[$i]"."$decimal[3]")mm" >> $fileNamePoints
done
vertex=(${(f)"$(cat $fileNamePoints)"})
# first output the options in the file just to make sure.
echo running gemc once to check parameters with options $vertex[1] $interpolation $field no
echo
./runGemc.sh $vertex[1] $interpolation $field no | grep -A7 "> Magnetic Field"
echo Now running gemc for each point:
for i in {1..$npoints}
do
echo vertex $vertex[$i] $interpolation $field
./runGemc.sh $vertex[$i] $interpolation $field yes | grep -A$ngreps "Track position in magnetic field map," >> $fileNameG
done