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 | source `dirname $0`/sourcefile
|
---|
31 | printprocesslog "INFO starting $0"
|
---|
32 | program=corsika
|
---|
33 | step=Corsika
|
---|
34 |
|
---|
35 | set -C
|
---|
36 |
|
---|
37 | export FLUPRO=$corsikapath'/fluka2008_3'
|
---|
38 |
|
---|
39 | # printing input card to stdout
|
---|
40 | function printinputcard()
|
---|
41 | {
|
---|
42 | # Run number
|
---|
43 | echo "RUNNR "$file
|
---|
44 | # Starting event number
|
---|
45 | echo "EVTNR 1"
|
---|
46 | # Number of simulated events
|
---|
47 | echo "NSHOW "$numevts
|
---|
48 | # Seed values for simulation
|
---|
49 | echo "SEED "$seed1" 0 0 "
|
---|
50 | echo "SEED "$seed2" 0 0 "
|
---|
51 | echo "SEED "$seed3" 0 0 "
|
---|
52 | # Primary particle
|
---|
53 | echo "PRMPAR "$primparticle
|
---|
54 | echo "ERANGE "$erange
|
---|
55 | echo "ESLOPE "$slope
|
---|
56 | # Simulation range (theta, phi, view cone, starting altitude)
|
---|
57 | echo "THETAP "$zdrange
|
---|
58 | echo "PHIP "$azrange
|
---|
59 | echo "VIEWCONE 0. "$viewconemax
|
---|
60 | echo "FIXCHI "$startalt
|
---|
61 | # Observation level, magnetic field, atmosphere
|
---|
62 | echo "OBSLEV "$obslev".E2"
|
---|
63 | # From www.noaa.gov/geomagmodels roughly for January 2009. (was 29.5 and 23.0)
|
---|
64 | # MAGNET BX BZ (BX is the horizontal component (muT) to the x-direction of
|
---|
65 | # the detector, BZ is the vertical component (muT) downwards)
|
---|
66 | echo "MAGNET "$magnet
|
---|
67 | # Rotation angle between array x-direction and magnetic north direction
|
---|
68 | # positive if array x-direction points to the west
|
---|
69 | echo "ARRANG "$magnetrot
|
---|
70 | # Atmosphere (model, true/false for atmospheric refraction of cer-photons)
|
---|
71 | # Atmosphere read from atmprof11.dat
|
---|
72 | # My current understanding is that only refraction (bending of light
|
---|
73 | # but no absorption of photons is taken into account) setting T.
|
---|
74 | echo "ATMOSPHERE "$atm" T"
|
---|
75 |
|
---|
76 | # Current boundaries in reflector program
|
---|
77 | # echo "ATMLAY 400000 1000000 4000000 10000000"
|
---|
78 |
|
---|
79 | # Boundaries as determined by CORSIKA
|
---|
80 | # Until we can read the result from the corsika fit we fix the
|
---|
81 | # values which come out of the fit. This is not ideal but forces
|
---|
82 | # things to be consistent. Be careful is using a different model -
|
---|
83 | # the fit might not be ideal.
|
---|
84 | echo "ATMLAY 775000 1650000 5000000 10500000"
|
---|
85 |
|
---|
86 | # Other parameters
|
---|
87 | echo "RADNKG 200.E2"
|
---|
88 | echo "ECUTS 0.3 0.3 0.02 0.02"
|
---|
89 | echo "ECTMAP 1.E4"
|
---|
90 | echo "STEPFC 0.1"
|
---|
91 | # Don't add muon particle data to output
|
---|
92 | echo "MUADDI F"
|
---|
93 | # Enable muon multiple scattering
|
---|
94 | echo "MUMULT T"
|
---|
95 | # Wavelength range (was originally 600)
|
---|
96 | echo "CWAVLG "$wavelengths
|
---|
97 | # MMCS
|
---|
98 | echo "CSCAT 1 0. "$impactmax
|
---|
99 | # CORSIKA
|
---|
100 | # echo "CSCAT "$reuse" "$impactmax" 0."
|
---|
101 | echo "CERSIZ 1."
|
---|
102 | # Write Cherenkov photons to cer-file
|
---|
103 | echo "CERFIL T"
|
---|
104 | # Number of telescopes
|
---|
105 | echo "CERTEL 1"
|
---|
106 | # MMCS
|
---|
107 | echo " 0. 0. 0. 0. 0. "$diameter" "$diameter
|
---|
108 | # CORSIKA (x, y, z, r)
|
---|
109 | # echo "TELESCOPE 0. 0. 0. "$diameter
|
---|
110 | # This keyword has no relevance but allows to store the
|
---|
111 | # maximum simulated impact parameter. The "magic" is that
|
---|
112 | # ceres interpretes the third and fourth argument as
|
---|
113 | # maximum simulated impact if they are identical and
|
---|
114 | # the other four arguments are 1
|
---|
115 | # echo "CERARY 1 1 "$diameter" "$diameter" 1 1"
|
---|
116 | # How the longitudinal shower development is sampled
|
---|
117 | # echo "LONGI T 10. T F"
|
---|
118 | echo "LONGI F 20 0 F F"
|
---|
119 | # Maximum number of detailed particles to print
|
---|
120 | echo "MAXPRT 0"
|
---|
121 | # Suppress file with partciles reaching ground (DATnnnnnn)
|
---|
122 | # FIXME: Should we make this switchable by the database?
|
---|
123 | echo "PAROUT F F"
|
---|
124 | # Don't write a database file
|
---|
125 | echo "DATBAS F"
|
---|
126 | # Switch off all debugging output
|
---|
127 | echo "DEBUG F 6 F 1000000"
|
---|
128 | # Output path
|
---|
129 | echo "DIRECT "$outpath
|
---|
130 | # DIRECT /dev/null
|
---|
131 | # TELFIL filename
|
---|
132 | # TELFIL | gzip
|
---|
133 | # TELESCOPE X Y Z R
|
---|
134 | # User and host (for convenience)
|
---|
135 | echo "USER "`whoami`
|
---|
136 | echo "HOST "`hostname`
|
---|
137 | # End of input card
|
---|
138 | echo "EXIT"
|
---|
139 | }
|
---|
140 |
|
---|
141 |
|
---|
142 | # get sequence #
|
---|
143 | gettodo "1"
|
---|
144 | run=${primaries[0]}
|
---|
145 | file=${primaries[1]}
|
---|
146 |
|
---|
147 | # lock sequ
|
---|
148 | lockfile=$lockpath/lock-$step-$run.$file.txt
|
---|
149 | checklock
|
---|
150 |
|
---|
151 | printprocesslog "INFO starting $program for run $run and file $file"
|
---|
152 |
|
---|
153 | setstatus "start"
|
---|
154 |
|
---|
155 | printprocesslog "INFO run $program for run $run and file $file"
|
---|
156 | printprocesslog "INFO create input card for run $run and file $file"
|
---|
157 |
|
---|
158 | # get values for inputcard
|
---|
159 | query="SELECT fParticleTypeKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
160 | primparticle=`sendquery`
|
---|
161 | query="SELECT fEnergyMin, fEnergyMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
162 | erange=`sendquery`
|
---|
163 | query="SELECT fNumEvents FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
164 | numevts=`sendquery`
|
---|
165 | query="SELECT fEnergySlope FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
166 | slope=`sendquery`
|
---|
167 | query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
168 | zdrange=`sendquery`
|
---|
169 | # Change from the MARS definition (Az=90 -> East) to Corsika (Az=90 -> West)
|
---|
170 | query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
171 | azrange=`sendquery`
|
---|
172 | query="SELECT fCorsikaSeed1 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
173 | seed1=`sendquery`
|
---|
174 | query="SELECT fCorsikaSeed2 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
175 | seed2=`sendquery`
|
---|
176 | query="SELECT fCorsikaSeed3 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
177 | seed3=`sendquery`
|
---|
178 | query="SELECT fImpactMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
179 | impactmax=`sendquery`
|
---|
180 | query="SELECT fViewConeMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
181 | viewconemax=`sendquery`
|
---|
182 | query="SELECT fStartingAltitude FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
183 | startalt=`sendquery`
|
---|
184 | query="SELECT fMirrorDiameter FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
185 | diameter=`sendquery`
|
---|
186 | query="SELECT fAtmosphericModelKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
187 | atm=`sendquery`
|
---|
188 | query="SELECT fObsLevel FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
189 | obslev=`sendquery`
|
---|
190 | query="SELECT fMagnetBX, fMagnetBZ FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
191 | magnet=`sendquery`
|
---|
192 | query="SELECT fMagnetRotation FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
193 | magnetrot=`sendquery`
|
---|
194 | query="SELECT fWavelengthMin, fWavelengthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
195 | wavelengths=`sendquery`
|
---|
196 |
|
---|
197 | outpath=$mcpath"/"$program"/"`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`
|
---|
198 | makedir $outpath
|
---|
199 | logfile=$outpath/cer000`printf %06d $file | cut -c 4-6`".log"
|
---|
200 |
|
---|
201 | cd $corsikapath
|
---|
202 |
|
---|
203 | printprocesslog "INFO executing 'printinputcard | ./cc6501p-linux >| $logfile 2>&1' in directory $corsikapath "
|
---|
204 | printinputcard | ./cc6501p-linux >| $logfile 2>&1
|
---|
205 |
|
---|
206 | check1=$?
|
---|
207 | case $check1 in
|
---|
208 | 0) printprocesslog "INFO $program finished successfully for run $run file $file (check1=$check1)"
|
---|
209 | ;;
|
---|
210 | *) printprocesslog "ERROR $program failed for run $run file $file (check1=$check1)"
|
---|
211 | com=$Fcorsika
|
---|
212 | check=$check1
|
---|
213 | ;;
|
---|
214 | esac
|
---|
215 |
|
---|
216 | # removing empty datnnnnnn file
|
---|
217 | rm -f $outpath/dat`printf %06d $file`
|
---|
218 |
|
---|
219 | setstatus "stop"
|
---|
220 |
|
---|
221 | finish
|
---|
222 |
|
---|