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-2007
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script runs the reflector.
|
---|
28 | #
|
---|
29 |
|
---|
30 | source `dirname $0`/sourcefile
|
---|
31 | printprocesslog "INFO starting $0"
|
---|
32 | program=reflector
|
---|
33 | column=fReflectorFileAvail
|
---|
34 | detectordir=/home/msmeyer/MC/MagicSoft/Simulation/Detector
|
---|
35 |
|
---|
36 | set -C
|
---|
37 |
|
---|
38 | # printing input card to stdout
|
---|
39 | function printinputcard()
|
---|
40 | {
|
---|
41 | echo $reflectorversion
|
---|
42 | echo "verbose_level 4"
|
---|
43 | echo "seeds "$seeds
|
---|
44 | echo "fixed_target 0. 0. "
|
---|
45 | echo "telescopes_layout 1 1"
|
---|
46 | echo "telescope_position 0.0 0.0"
|
---|
47 | if [ $wobble -eq 2 ]
|
---|
48 | then
|
---|
49 | echo "wobble_mode 1"
|
---|
50 | else
|
---|
51 | echo "wobble_mode 0"
|
---|
52 | fi
|
---|
53 | echo "ct_file $detectordir/Data/magic.def"
|
---|
54 | echo "reflectivity_file $detectordir/Data/reflectivity.dat"
|
---|
55 | echo "axisdev_file $detectordir/Data/axisdev.dat"
|
---|
56 | echo "output_file "$outfile
|
---|
57 | echo "atm_model ATM_MagicWinter"
|
---|
58 | echo "cer_files "
|
---|
59 | echo $infile
|
---|
60 | }
|
---|
61 |
|
---|
62 |
|
---|
63 | scriptlog=$runlogpath/run$program-$datetime.log
|
---|
64 | date >> $scriptlog 2>&1
|
---|
65 |
|
---|
66 | # get sequence #
|
---|
67 | gettodo >> $scriptlog 2>&1
|
---|
68 | run=$process
|
---|
69 | # get reflector runnumber
|
---|
70 | query="SELECT fReflectorRunNumber FROM MCRunData where fMCRunNumber="$run
|
---|
71 | reflectorrunno=`sendquery`
|
---|
72 |
|
---|
73 | # lock sequ
|
---|
74 | lockfile=$lockpath/lock-$table-$column-$reflectorrunno.txt
|
---|
75 | checklock >> $scriptlog 2>&1
|
---|
76 |
|
---|
77 | echo "run $program for run $run..." >> $scriptlog 2>&1
|
---|
78 | printprocesslog "INFO starting $program for run $run"
|
---|
79 |
|
---|
80 | primvar=$run
|
---|
81 | setstatus "start" >> $scriptlog 2>&1
|
---|
82 |
|
---|
83 | echo "run $program for run $run "
|
---|
84 | echo "create input card... "
|
---|
85 |
|
---|
86 | # get values for inputcard
|
---|
87 | query="SELECT fReflectorSeed, fReflectorSeed+1 FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
88 | seeds=`sendquery`
|
---|
89 | query="SELECT fObservationModeKEY FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
90 | wobble=`sendquery`
|
---|
91 | query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
92 | date=`sendquery`
|
---|
93 | query="SELECT fParticleTypeName FROM MCCorsikaRunData "
|
---|
94 | query=$query" LEFT JOIN ParticleType ON MCCorsikaRunData.fParticleTypeKEY=ParticleType.fParticleTypeKEY "
|
---|
95 | query=$query" LEFT JOIN MCReflectorRunData ON MCCorsikaRunData.fCorsikaRunNumber=MCReflectorRunData.fCorsikaRunNumber "
|
---|
96 | query=$query" WHERE fReflectorRunNumber="$reflectorrunno
|
---|
97 | particle=`sendquery`
|
---|
98 | outpath=$mcpath"/"$program"/"$date
|
---|
99 | date2=`echo $date | sed -e 's/\///g'`
|
---|
100 | outfile=$outpath"/"$date2"_"`printf %06d $reflectorrunno`"_"$particle".rfl"
|
---|
101 | query="SELECT fCorsikaRunNumber FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
102 | infile=$mcpath"/corsika/"$date"/cer"`printf %06d \`sendquery\``
|
---|
103 |
|
---|
104 | echo "" >> $scriptlog 2>&1
|
---|
105 | echo "INPUTCARD:" >> $scriptlog 2>&1
|
---|
106 | echo "----------" >> $scriptlog 2>&1
|
---|
107 | echo "" >> $scriptlog 2>&1
|
---|
108 | echo "" >> $scriptlog 2>&1
|
---|
109 | printinputcard >> $scriptlog 2>&1
|
---|
110 |
|
---|
111 | makedir $outpath >> $scriptlog 2>&1
|
---|
112 | if ls $outfile >/dev/null 2>&1
|
---|
113 | then
|
---|
114 | rm -v $outfile
|
---|
115 | fi
|
---|
116 | logfile=$outpath/$program"-"`printf %06d $reflectorrunno`".log"
|
---|
117 |
|
---|
118 | cd $detectordir/ReflectorII
|
---|
119 |
|
---|
120 | echo "INPUTCARD:" >> $logfile 2>&1
|
---|
121 | printinputcard >> $logfile 2>&1
|
---|
122 | echo "" >> $logfile 2>&1
|
---|
123 | echo "" >> $logfile 2>&1
|
---|
124 | printinputcard | ./reflector
|
---|
125 |
|
---|
126 | check1=$?
|
---|
127 |
|
---|
128 | echo "the reflector returned: "$check1
|
---|
129 |
|
---|
130 | case $check1 in
|
---|
131 | 22) echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
|
---|
132 | printprocesslog "INFO $program finished successfully for sequence $sequence"
|
---|
133 | ;;
|
---|
134 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
135 | printprocesslog "ERROR $program failed for sequence $sequence"
|
---|
136 | com=$Freflector
|
---|
137 | check=$check1
|
---|
138 | ;;
|
---|
139 | esac
|
---|
140 |
|
---|
141 | setstatus "stop" >> $scriptlog 2>&1
|
---|
142 |
|
---|
143 | finish >> $scriptlog 2>&1
|
---|
144 |
|
---|