1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # ========================================================================
|
---|
4 | #
|
---|
5 | # *
|
---|
6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | # *
|
---|
11 | # * Permission to use, copy, modify and distribute this software and its
|
---|
12 | # * documentation for any purpose is hereby granted without fee,
|
---|
13 | # * provided that the above copyright notice appear in all copies and
|
---|
14 | # * that both that copyright notice and this permission notice appear
|
---|
15 | # * in supporting documentation. It is provided "as is" without express
|
---|
16 | # * or implied warranty.
|
---|
17 | # *
|
---|
18 | #
|
---|
19 | #
|
---|
20 | # Author(s): Daniela Dorner 05/2007 <mailto:daniela.dorner@unige.ch>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2010
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script runs corsika.
|
---|
28 | #
|
---|
29 |
|
---|
30 | if [ "$SOURCEFILEPATH" = "" ]
|
---|
31 | then
|
---|
32 | source `dirname $0`/sourcefile
|
---|
33 | else
|
---|
34 | source $SOURCEFILEPATH/sourcefile
|
---|
35 | fi
|
---|
36 | printprocesslog "INFO starting $0"
|
---|
37 | program=corsika
|
---|
38 | step=Corsika
|
---|
39 |
|
---|
40 | set -C
|
---|
41 |
|
---|
42 | export FLUPRO=$corsikapath'/fluka2008_3'
|
---|
43 |
|
---|
44 | # printing input card to stdout
|
---|
45 | function printinputcard()
|
---|
46 | {
|
---|
47 | # Run number
|
---|
48 | echo "RUNNR "$file
|
---|
49 | # Starting event number
|
---|
50 | echo "EVTNR 1"
|
---|
51 | # Number of simulated events
|
---|
52 | echo "NSHOW "$numevts
|
---|
53 | # Seed values for simulation
|
---|
54 | echo "SEED "$seed1" 0 0 "
|
---|
55 | echo "SEED "$seed2" 0 0 "
|
---|
56 | echo "SEED "$seed3" 0 0 "
|
---|
57 | # Primary particle
|
---|
58 | echo "PRMPAR "$primparticle
|
---|
59 | echo "ERANGE "$erange
|
---|
60 | echo "ESLOPE "$slope
|
---|
61 | # Simulation range (theta, phi, view cone, starting altitude)
|
---|
62 | echo "THETAP "$zdrange
|
---|
63 | echo "PHIP "$azrange
|
---|
64 | echo "VIEWCONE 0. "$viewconemax
|
---|
65 | echo "FIXCHI "$startalt
|
---|
66 | # Observation level, magnetic field, atmosphere
|
---|
67 | echo "OBSLEV "$obslev".E2"
|
---|
68 | # From www.noaa.gov/geomagmodels roughly for January 2009. (was 29.5 and 23.0)
|
---|
69 | # MAGNET BX BZ (BX is the horizontal component (muT) to the x-direction of
|
---|
70 | # the detector, BZ is the vertical component (muT) downwards)
|
---|
71 | echo "MAGNET "$magnet
|
---|
72 | # Rotation angle between array x-direction and magnetic north direction
|
---|
73 | # positive if array x-direction points to the west
|
---|
74 | echo "ARRANG "$magnetrot
|
---|
75 | # Atmosphere (model, true/false for atmospheric refraction of cer-photons)
|
---|
76 | # Atmosphere read from atmprof11.dat
|
---|
77 | # My current understanding is that only refraction (bending of light
|
---|
78 | # but no absorption of photons is taken into account) setting T.
|
---|
79 | echo "ATMOSPHERE "$atm" T"
|
---|
80 |
|
---|
81 | # Current boundaries in reflector program
|
---|
82 | # echo "ATMLAY 400000 1000000 4000000 10000000"
|
---|
83 |
|
---|
84 | # Boundaries as determined by CORSIKA
|
---|
85 | # Until we can read the result from the corsika fit we fix the
|
---|
86 | # values which come out of the fit. This is not ideal but forces
|
---|
87 | # things to be consistent. Be careful is using a different model -
|
---|
88 | # the fit might not be ideal.
|
---|
89 | echo "ATMLAY 775000 1650000 5000000 10500000"
|
---|
90 |
|
---|
91 | # Other parameters
|
---|
92 | echo "RADNKG 200.E2"
|
---|
93 | echo "ECUTS 0.3 0.3 0.02 0.02"
|
---|
94 | echo "ECTMAP 1.E4"
|
---|
95 | # Don't add muon particle data to output
|
---|
96 | echo "MUADDI F"
|
---|
97 | # Enable muon multiple scattering
|
---|
98 | echo "MUMULT T"
|
---|
99 | # Wavelength range (was originally 600)
|
---|
100 | echo "CWAVLG "$wavelengths
|
---|
101 | # MMCS
|
---|
102 | echo "CSCAT "$numreuse" 0. "$impactmax
|
---|
103 | # CORSIKA
|
---|
104 | # echo "CSCAT "$numreuse" "$impactmax" 0."
|
---|
105 | echo "CERSIZ 1."
|
---|
106 | # Write Cherenkov photons to cer-file
|
---|
107 | echo "CERFIL T"
|
---|
108 | # Number of telescopes
|
---|
109 | echo "CERTEL 1"
|
---|
110 | # MMCS
|
---|
111 | echo " 0. 0. 0. 0. 0. "$diameter" "$diameter
|
---|
112 | # CORSIKA (x, y, z, r)
|
---|
113 | # echo "TELESCOPE 0. 0. 0. "$diameter
|
---|
114 | # This keyword has no relevance but allows to store the
|
---|
115 | # maximum simulated impact parameter. The "magic" is that
|
---|
116 | # ceres interpretes the third and fourth argument as
|
---|
117 | # maximum simulated impact if they are identical and
|
---|
118 | # the other four arguments are 1
|
---|
119 | # echo "CERARY 1 1 "$diameter" "$diameter" 1 1"
|
---|
120 | # How the longitudinal shower development is sampled
|
---|
121 | # echo "LONGI T 10. T F"
|
---|
122 | echo "LONGI F 20 0 F F"
|
---|
123 | # Maximum number of detailed particles to print
|
---|
124 | echo "MAXPRT 0"
|
---|
125 | # Suppress file with partciles reaching ground (DATnnnnnn)
|
---|
126 | # FIXME: Should we make this switchable by the database?
|
---|
127 | echo "PAROUT F F"
|
---|
128 | # Don't write a database file
|
---|
129 | echo "DATBAS F"
|
---|
130 | # Switch off all debugging output
|
---|
131 | echo "DEBUG F 6 F 1000000"
|
---|
132 | # Output path
|
---|
133 | echo "DIRECT "$outpath
|
---|
134 | # DIRECT /dev/null
|
---|
135 | # TELFIL filename
|
---|
136 | # TELFIL | gzip
|
---|
137 | # TELESCOPE X Y Z R
|
---|
138 | # User and host (for convenience)
|
---|
139 | echo "USER "`whoami`
|
---|
140 | echo "HOST "`hostname`
|
---|
141 | # End of input card
|
---|
142 | echo "EXIT"
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | # get run # and file #
|
---|
147 | numchanged=0
|
---|
148 | while (( 0 < 21 ))
|
---|
149 | do
|
---|
150 | if ! [ $numchanged -eq 1 ]
|
---|
151 | then
|
---|
152 | if ! [ "$run" = "" ] && ! [ "$file" = "" ]
|
---|
153 | then
|
---|
154 | printprocesslog "INFO $program for run $run and file $file is already running => request new number "
|
---|
155 | fi
|
---|
156 | gettodo "1"
|
---|
157 | run=${primaries[0]}
|
---|
158 | file=${primaries[1]}
|
---|
159 | if [ "$run" = "" ] || [ "$file" = "" ]
|
---|
160 | then
|
---|
161 | printprocesslog "INFO nothing to do for $program "
|
---|
162 | fi
|
---|
163 | else
|
---|
164 | printprocesslog "INFO starting $program for run $run and file $file"
|
---|
165 | break
|
---|
166 | fi
|
---|
167 | setstatus "start"
|
---|
168 | done
|
---|
169 |
|
---|
170 | # running corsika
|
---|
171 | printprocesslog "INFO run $program for run $run and file $file"
|
---|
172 | printprocesslog "INFO create input card for run $run and file $file"
|
---|
173 |
|
---|
174 | # get values for inputcard
|
---|
175 | query="SELECT fParticleTypeKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
176 | primparticle=`sendquery`
|
---|
177 | query="SELECT fEnergyMin, fEnergyMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
178 | erange=`sendquery`
|
---|
179 | query="SELECT fNumEvents FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
180 | numevts=`sendquery`
|
---|
181 | query="SELECT fEnergySlope FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
182 | slope=`sendquery`
|
---|
183 | query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
184 | zdrange=`sendquery`
|
---|
185 | # Change from the MARS definition (Az=90 -> East) to Corsika (Az=90 -> West)
|
---|
186 | query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
187 | azrange=`sendquery`
|
---|
188 | query="SELECT fCorsikaSeed1 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
189 | seed1=`sendquery`
|
---|
190 | query="SELECT fCorsikaSeed2 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
191 | seed2=`sendquery`
|
---|
192 | query="SELECT fCorsikaSeed3 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
193 | seed3=`sendquery`
|
---|
194 | query="SELECT fImpactMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
195 | impactmax=`sendquery`
|
---|
196 | query="SELECT fViewConeMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
197 | viewconemax=`sendquery`
|
---|
198 | query="SELECT fStartingAltitude FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
199 | startalt=`sendquery`
|
---|
200 | query="SELECT fMirrorDiameter FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
201 | diameter=`sendquery`
|
---|
202 | query="SELECT fAtmosphericModelKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
203 | atm=`sendquery`
|
---|
204 | query="SELECT fObsLevel FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
205 | obslev=`sendquery`
|
---|
206 | query="SELECT fMagnetBX, fMagnetBZ FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
207 | magnet=`sendquery`
|
---|
208 | query="SELECT fMagnetRotation FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
209 | magnetrot=`sendquery`
|
---|
210 | query="SELECT fWavelengthMin, fWavelengthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
211 | wavelengths=`sendquery`
|
---|
212 | query="SELECT fNumReUseShowers FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
213 | numreuse=`sendquery`
|
---|
214 |
|
---|
215 | outpath=$mcpath"/"$program"/"`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`
|
---|
216 | makedir $outpath
|
---|
217 | logfile=$outpath/cer000`printf %06d $file | cut -c 4-6`".log"
|
---|
218 |
|
---|
219 | cd $corsikapath
|
---|
220 |
|
---|
221 | printprocesslog "INFO executing 'printinputcard | ./cc6501p-linux >| $logfile 2>&1' in directory $corsikapath "
|
---|
222 | printinputcard | ./cc6501p-linux >| $logfile 2>&1
|
---|
223 |
|
---|
224 | check1=$?
|
---|
225 | case $check1 in
|
---|
226 | 0) printprocesslog "INFO $program finished successfully for run $run file $file (return code $check1)"
|
---|
227 | if [ $file -gt 999 ]
|
---|
228 | then
|
---|
229 | corsikafilenew=$mcpath/$program/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`/cer000`printf %06d $file | cut -c 4-6`
|
---|
230 | corsikafileold=$mcpath/$program/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`/cer`printf %06d $file`
|
---|
231 | if ! mv $corsikafileold $corsikafilenew
|
---|
232 | then
|
---|
233 | printprocesslog "ERROR could not mv $corsikafileold to $corsikafilenew"
|
---|
234 | check=2
|
---|
235 | fi
|
---|
236 | fi
|
---|
237 | if ! grep 'END OF RUN' $logfile
|
---|
238 | then
|
---|
239 | printprocesslog "ERROR could not find 'END OF RUN' in $logfile => unknown error for run $run file $file "
|
---|
240 | check=2
|
---|
241 | fi
|
---|
242 | ;;
|
---|
243 | *) printprocesslog "ERROR $program failed for run $run file $file (return code $check1)"
|
---|
244 | check=$check1
|
---|
245 | ;;
|
---|
246 | esac
|
---|
247 |
|
---|
248 | # removing empty datnnnnnn file
|
---|
249 | rm -f $outpath/dat`printf %06d $file`
|
---|
250 |
|
---|
251 | setstatus "stop"
|
---|
252 |
|
---|
253 | finish
|
---|
254 |
|
---|