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

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