source: trunk/MagicSoft/Mars/datacenter/scripts/runcorsika@ 9198

Last change on this file since 9198 was 9183, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.4 KB
Line 
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:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2008
23#
24#
25# ========================================================================
26#
27# This script runs corsika.
28#
29
30source `dirname $0`/sourcefile
31printprocesslog "INFO starting $0"
32program=corsika
33column=fCorsikaFileAvail
34
35set -C
36
37# printing input card to stdout
38function printinputcard()
39{
40 echo "RUNNR "$corsikarunno
41 echo "PRMPAR "$primparticle
42 echo "ERANGE "$erange
43 echo "EVTNR 1"
44 echo "NSHOW "$numevts
45 echo "ESLOPE "$slope
46 echo "THETAP "$zdrange
47 echo "PHIP "$azrange
48 echo "VIEWCONE 0. "$viewconemax
49 echo "DIRECT "$outpath
50 echo "SEED "$seed1" 0 0 "
51 echo "SEED "$seed2" 0 0 "
52 echo "SEED "$seed3" 0 0 "
53 echo "OBSLEV 2200.E2"
54 echo "RADNKG 200.E2"
55 echo "MAGNET 29.5 23.0"
56 echo "ECUTS 0.3 0.3 0.02 0.02"
57 echo "MUADDI F"
58 echo "MUMULT T"
59 echo "LONGI T 10. T F"
60 echo "MAXPRT 0"
61 echo "ECTMAP 1.E4"
62 echo "STEPFC 0.1"
63 echo "DEBUG F 6 F 1000000"
64 echo "CWAVLG 290. 600."
65 echo "CSCAT "$reuse" 0. "$impactmax
66 echo "CERSIZ 1."
67 echo "CERFIL T"
68 echo "FIXCHI "$startalt
69 echo "DATBAS F"
70 echo "CERTEL 1"
71 echo " 0. 0. 0. 0. 0. "$diameter" 1700."
72 echo "USER "`whoami`
73 echo "ATMOSPHERE 11 T"
74 echo "EXIT"
75}
76
77
78scriptlog=$runlogpath/run$program-$datetime.log
79date >> $scriptlog 2>&1
80
81# get sequence #
82gettodo "1" >> $scriptlog 2>&1
83run=${primaries[0]}
84# get corsika runno
85query="SELECT fCorsikaRunNumber FROM MCRunData where fMCRunNumber="$run
86# to be changed later again, when additional tables are available
87#corsikarunno=`sendquery`
88corsikarunno=$run
89
90# lock sequ
91lockfile=$lockpath/lock-$table-$column-$corsikarunno.txt
92checklock >> $scriptlog 2>&1
93
94echo "run $program for run $run..." >> $scriptlog 2>&1
95printprocesslog "INFO starting $program for run $run"
96
97setstatus "start" >> $scriptlog 2>&1
98
99echo "run $program for run $run " >> $scriptlog 2>&1
100echo "create input card... " >> $scriptlog 2>&1
101
102# get values for inputcard
103query="SELECT fParticleTypeKEY FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
104primparticle=`sendquery`
105query="SELECT fEnergyMin, fEnergyMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
106erange=`sendquery`
107query="SELECT fNumEvents FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
108numevts=`sendquery`
109query="SELECT fEnergySlope FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
110slope=`sendquery`
111query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
112zdrange=`sendquery`
113query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
114azrange=`sendquery`
115query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
116date=`sendquery`
117outpath=$mcpath"/"$program"/"$date
118query="SELECT fCorsikaSeed FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
119seed1=`sendquery`
120query="SELECT fCorsikaSeed+1 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
121seed2=`sendquery`
122query="SELECT fCorsikaSeed+2 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
123seed3=`sendquery`
124query="SELECT fImpactMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
125impactmax=`sendquery`
126query="SELECT fViewConeMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
127viewconemax=`sendquery`
128query="SELECT fNumReUseShower FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
129reuse=`sendquery`
130query="SELECT fStartingAltitude FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
131startalt=`sendquery`
132query="SELECT fMirrorDiameter FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
133diameter=`sendquery`
134
135echo "" >> $scriptlog 2>&1
136echo "INPUTCARD:" >> $scriptlog 2>&1
137echo "----------" >> $scriptlog 2>&1
138echo "" >> $scriptlog 2>&1
139echo "" >> $scriptlog 2>&1
140printinputcard >> $scriptlog 2>&1
141
142logfile=$outpath/$program"-"`printf %06d $corsikarunno`".log"
143makedir $outpath >> $scriptlog 2>&1
144
145cd $corsikapath
146
147echo "INPUTCARD:" >| $logfile 2>&1
148printinputcard >> $logfile 2>&1
149echo "" >> $logfile 2>&1
150echo "" >> $logfile 2>&1
151printinputcard | ./cc6501p-linux >> $logfile 2>&1
152
153check1=$?
154
155case $check1 in
156 0) echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
157 printprocesslog "INFO $program finished successfully for corsika run number $corsikarunno"
158 ;;
159 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
160 printprocesslog "ERROR $program failed for corsika run number $corsikarunno"
161 com=$Fcorsika
162 check=$check1
163 ;;
164esac
165
166setstatus "stop" >> $scriptlog 2>&1
167
168finish >> $scriptlog 2>&1
169
Note: See TracBrowser for help on using the repository browser.