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