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 | setstatus "start" >> $scriptlog 2>&1
|
---|
81 |
|
---|
82 | echo "run $program for run $run "
|
---|
83 | echo "create input card... "
|
---|
84 |
|
---|
85 | # get values for inputcard
|
---|
86 | query="SELECT fReflectorSeed, fReflectorSeed+1 FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
87 | seeds=`sendquery`
|
---|
88 | query="SELECT fObservationModeKEY FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
89 | wobble=`sendquery`
|
---|
90 | query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
91 | date=`sendquery`
|
---|
92 | query="SELECT fParticleTypeName FROM MCCorsikaRunData "
|
---|
93 | query=$query" LEFT JOIN ParticleType ON MCCorsikaRunData.fParticleTypeKEY=ParticleType.fParticleTypeKEY "
|
---|
94 | query=$query" LEFT JOIN MCReflectorRunData ON MCCorsikaRunData.fCorsikaRunNumber=MCReflectorRunData.fCorsikaRunNumber "
|
---|
95 | query=$query" WHERE fReflectorRunNumber="$reflectorrunno
|
---|
96 | particle=`sendquery`
|
---|
97 | outpath=$mcpath"/"$program"/"$date
|
---|
98 | date2=`echo $date | sed -e 's/\///g'`
|
---|
99 | outfile=$outpath"/"$date2"_"`printf %06d $reflectorrunno`"_"$particle".rfl"
|
---|
100 | query="SELECT fCorsikaRunNumber FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
|
---|
101 | infile=$mcpath"/corsika/"$date"/cer"`printf %06d \`sendquery\``
|
---|
102 |
|
---|
103 | echo "" >> $scriptlog 2>&1
|
---|
104 | echo "INPUTCARD:" >> $scriptlog 2>&1
|
---|
105 | echo "----------" >> $scriptlog 2>&1
|
---|
106 | echo "" >> $scriptlog 2>&1
|
---|
107 | echo "" >> $scriptlog 2>&1
|
---|
108 | printinputcard >> $scriptlog 2>&1
|
---|
109 |
|
---|
110 | makedir $outpath >> $scriptlog 2>&1
|
---|
111 | if ls $outfile >/dev/null 2>&1
|
---|
112 | then
|
---|
113 | rm -v $outfile
|
---|
114 | fi
|
---|
115 | logfile=$outpath/$program"-"`printf %06d $reflectorrunno`".log"
|
---|
116 |
|
---|
117 | cd $detectordir/ReflectorII
|
---|
118 |
|
---|
119 | echo "INPUTCARD:" >> $logfile 2>&1
|
---|
120 | printinputcard >> $logfile 2>&1
|
---|
121 | echo "" >> $logfile 2>&1
|
---|
122 | echo "" >> $logfile 2>&1
|
---|
123 | printinputcard | ./reflector
|
---|
124 |
|
---|
125 | check1=$?
|
---|
126 |
|
---|
127 | echo "the reflector returned: "$check1
|
---|
128 |
|
---|
129 | case $check1 in
|
---|
130 | 22) echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
|
---|
131 | printprocesslog "INFO $program finished successfully for sequence $sequence"
|
---|
132 | ;;
|
---|
133 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
134 | printprocesslog "ERROR $program failed for sequence $sequence"
|
---|
135 | com=$Freflector
|
---|
136 | check=$check1
|
---|
137 | ;;
|
---|
138 | esac
|
---|
139 |
|
---|
140 | setstatus "stop" >> $scriptlog 2>&1
|
---|
141 |
|
---|
142 | finish >> $scriptlog 2>&1
|
---|
143 |
|
---|