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

Last change on this file since 9086 was 9072, checked in by Daniela Dorner, 16 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
80setstatus "start" >> $scriptlog 2>&1
81
82echo "run $program for run $run "
83echo "create input card... "
84
85# get values for inputcard
86query="SELECT fReflectorSeed, fReflectorSeed+1 FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
87seeds=`sendquery`
88query="SELECT fObservationModeKEY FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
89wobble=`sendquery`
90query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
91date=`sendquery`
92query="SELECT fParticleTypeName FROM MCCorsikaRunData "
93query=$query" LEFT JOIN ParticleType ON MCCorsikaRunData.fParticleTypeKEY=ParticleType.fParticleTypeKEY "
94query=$query" LEFT JOIN MCReflectorRunData ON MCCorsikaRunData.fCorsikaRunNumber=MCReflectorRunData.fCorsikaRunNumber "
95query=$query" WHERE fReflectorRunNumber="$reflectorrunno
96particle=`sendquery`
97outpath=$mcpath"/"$program"/"$date
98date2=`echo $date | sed -e 's/\///g'`
99outfile=$outpath"/"$date2"_"`printf %06d $reflectorrunno`"_"$particle".rfl"
100query="SELECT fCorsikaRunNumber FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
101infile=$mcpath"/corsika/"$date"/cer"`printf %06d \`sendquery\``
102
103echo "" >> $scriptlog 2>&1
104echo "INPUTCARD:" >> $scriptlog 2>&1
105echo "----------" >> $scriptlog 2>&1
106echo "" >> $scriptlog 2>&1
107echo "" >> $scriptlog 2>&1
108printinputcard >> $scriptlog 2>&1
109
110makedir $outpath >> $scriptlog 2>&1
111if ls $outfile >/dev/null 2>&1
112then
113 rm -v $outfile
114fi
115logfile=$outpath/$program"-"`printf %06d $reflectorrunno`".log"
116
117cd $detectordir/ReflectorII
118
119echo "INPUTCARD:" >> $logfile 2>&1
120printinputcard >> $logfile 2>&1
121echo "" >> $logfile 2>&1
122echo "" >> $logfile 2>&1
123printinputcard | ./reflector
124
125check1=$?
126
127echo "the reflector returned: "$check1
128
129case $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 ;;
138esac
139
140setstatus "stop" >> $scriptlog 2>&1
141
142finish >> $scriptlog 2>&1
143
Note: See TracBrowser for help on using the repository browser.