source: trunk/Mars/datacenter/scripts/runreflector@ 10038

Last change on this file since 10038 was 9355, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.8 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# get sequence #
62gettodo "1"
63run=${primaries[0]}
64# get reflector runnumber
65query="SELECT fReflectorRunNumber FROM MCRunData where fMCRunNumber="$run
66reflectorrunno=`sendquery`
67
68# lock sequ
69lockfile=$lockpath/lock-$table-$column-$reflectorrunno.txt
70checklock
71
72printprocesslog "INFO starting $program for run $run"
73
74setstatus "start"
75
76printprocesslog "INFO create input card... "
77
78# get values for inputcard
79query="SELECT fReflectorSeed, fReflectorSeed+1 FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
80seeds=`sendquery`
81query="SELECT fObservationModeKEY FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
82wobble=`sendquery`
83query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
84date=`sendquery`
85query="SELECT fParticleTypeName FROM MCCorsikaRunData "
86query=$query" LEFT JOIN ParticleType ON MCCorsikaRunData.fParticleTypeKEY=ParticleType.fParticleTypeKEY "
87query=$query" LEFT JOIN MCReflectorRunData ON MCCorsikaRunData.fCorsikaRunNumber=MCReflectorRunData.fCorsikaRunNumber "
88query=$query" WHERE fReflectorRunNumber="$reflectorrunno
89particle=`sendquery`
90outpath=$mcpath"/"$program"/"$date
91date2=`echo $date | sed -e 's/\///g'`
92outfile=$outpath"/"$date2"_"`printf %06d $reflectorrunno`"_"$particle".rfl"
93query="SELECT fCorsikaRunNumber FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
94infile=$mcpath"/corsika/"$date"/cer"`printf %06d \`sendquery\``
95
96makedir $outpath
97if ls $outfile >/dev/null 2>&1
98then
99 rm -v $outfile
100fi
101logfile=$outpath/$program"-"`printf %06d $reflectorrunno`".log"
102
103cd $detectordir/ReflectorII
104
105echo "INPUTCARD:" >| $logfile 2>&1
106printinputcard >> $logfile 2>&1
107echo "" >> $logfile 2>&1
108echo "" >> $logfile 2>&1
109printinputcard | ./reflector >> $logfile 2>&1
110
111check1=$?
112
113echo "the reflector returned: "$check1
114
115case $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 ;;
122esac
123
124setstatus "stop"
125
126finish
127
Note: See TracBrowser for help on using the repository browser.