source: trunk/MagicSoft/Mars/datacenter/scripts/runreflector@ 9046

Last change on this file since 9046 was 8526, checked in by Daniela Dorner, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.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-2007
23#
24#
25# ========================================================================
26#
27# This script runs the reflector.
28#
29
30source `dirname $0`/sourcefile
31printprocesslog "INFO starting $0"
32program=reflector
33column=fReflectorFileAvail
34detectordir=/home/msmeyer/MC/MagicSoft/Simulation/Detector
35
36set -C
37
38# printing input card to stdout
39function 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
63scriptlog=$runlogpath/run$program-$datetime.log
64date >> $scriptlog 2>&1
65
66# get sequence #
67gettodo >> $scriptlog 2>&1
68run=$process
69# get reflector runnumber
70query="SELECT fReflectorRunNumber FROM MCRunData where fMCRunNumber="$run
71reflectorrunno=`sendquery`
72
73# lock sequ
74lockfile=$lockpath/lock-$table-$column-$reflectorrunno.txt
75checklock >> $scriptlog 2>&1
76
77echo "run $program for run $run..." >> $scriptlog 2>&1
78printprocesslog "INFO starting $program for run $run"
79
80primvar=$run
81setstatus "start" >> $scriptlog 2>&1
82
83echo "run $program for run $run "
84echo "create input card... "
85
86# get values for inputcard
87query="SELECT fReflectorSeed, fReflectorSeed+1 FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
88seeds=`sendquery`
89query="SELECT fObservationModeKEY FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
90wobble=`sendquery`
91query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
92date=`sendquery`
93query="SELECT fParticleTypeName FROM MCCorsikaRunData "
94query=$query" LEFT JOIN ParticleType ON MCCorsikaRunData.fParticleTypeKEY=ParticleType.fParticleTypeKEY "
95query=$query" LEFT JOIN MCReflectorRunData ON MCCorsikaRunData.fCorsikaRunNumber=MCReflectorRunData.fCorsikaRunNumber "
96query=$query" WHERE fReflectorRunNumber="$reflectorrunno
97particle=`sendquery`
98outpath=$mcpath"/"$program"/"$date
99date2=`echo $date | sed -e 's/\///g'`
100outfile=$outpath"/"$date2"_"`printf %06d $reflectorrunno`"_"$particle".rfl"
101query="SELECT fCorsikaRunNumber FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
102infile=$mcpath"/corsika/"$date"/cer"`printf %06d \`sendquery\``
103
104echo "" >> $scriptlog 2>&1
105echo "INPUTCARD:" >> $scriptlog 2>&1
106echo "----------" >> $scriptlog 2>&1
107echo "" >> $scriptlog 2>&1
108echo "" >> $scriptlog 2>&1
109printinputcard >> $scriptlog 2>&1
110
111makedir $outpath >> $scriptlog 2>&1
112if ls $outfile >/dev/null 2>&1
113then
114 rm -v $outfile
115fi
116logfile=$outpath/$program"-"`printf %06d $reflectorrunno`".log"
117
118cd $detectordir/ReflectorII
119
120echo "INPUTCARD:" >> $logfile 2>&1
121printinputcard >> $logfile 2>&1
122echo "" >> $logfile 2>&1
123echo "" >> $logfile 2>&1
124printinputcard | ./reflector
125
126check1=$?
127
128echo "the reflector returned: "$check1
129
130case $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 ;;
139esac
140
141setstatus "stop" >> $scriptlog 2>&1
142
143finish >> $scriptlog 2>&1
144
Note: See TracBrowser for help on using the repository browser.