source: trunk/Mars/datacenter/scripts/runceres@ 15658

Last change on this file since 15658 was 14792, checked in by lyard, 12 years ago
Added fits output for MC data
  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/bash
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 06/2010 <mailto:daniela.dorner@unige.ch>
21#
22# Copyright: MAGIC Software Development, 2000-2010
23#
24#
25# ========================================================================
26#
27# This script is launching ceres for corsika runs.
28#
29# The ceres.rc and other setup files are stored in the setup directory.
30#
31
32source `dirname $0`/sourcefile
33printprocesslog "INFO starting $0"
34program=ceres
35step=Ceres
36
37set -C
38
39# get run #
40numchanged=0
41while (( 0 < 21 ))
42do
43 if ! [ $numchanged -eq 1 ]
44 then
45 if ! [ "$run" = "" ] && ! [ "$cereskey" = "" ]
46 then
47 printprocesslog "INFO $program for run $run cereskey $cereskey is already running => request new number "
48 fi
49 gettodo "1"
50 run=${primaries[0]}
51 cereskey=${primaries[1]}
52 if [ "$run" = "" ] || [ "$cereskey" = "" ]
53 then
54 printprocesslog "INFO nothing to do for $program "
55 fi
56 else
57 printprocesslog "INFO starting $program for run $run cereskey $cereskey"
58 break
59 fi
60 setstatus "start"
61done
62
63cd $mars
64
65# run ceres for run
66
67setupfile=$setuppath/$program/`printf %03d $cereskey`/ceres.rc
68
69query="SELECT fRunTypeKEY FROM CeresInfo WHERE fRunNumber="$run" AND fCeresSetupKEY="$cereskey" GROUP BY fRunNumber"
70runkey=`sendquery`
71
72case $runkey in
73 2) printprocesslog "INFO run $run is a data run (key="$runkey")"
74 printprocesslog "INFO getting file numbers for run "$run
75 query="SELECT CONCAT('"$mcpath"/corsika/', LEFT(LPAD(CeresInfo.fRunNumber, 8, '0'), 4),"
76 query=$query" '/', RIGHT(LPAD(CeresInfo.fRunNumber, 8, '0'), 4), '/cer000', "
77 query=$query" RIGHT(LPAD(CeresInfo.fFileNumber, 6, '0'), 3)) from CeresInfo "
78 query=$query" WHERE fRunNumber="$run" AND fCeresSetupKEY="$cereskey
79 inputfiles=`sendquery`
80 outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`
81 makedir $outpath
82 log=$outpath/ceres`printf %08d $run `
83 command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run $inputfiles"
84 printprocesslog "INFO executing "$command
85 $command
86 check1=$?
87 ;;
88 3) printprocesslog "INFO run $run is a pedestal run (key="$runkey")"
89 drun=`echo "$run + 2 " | bc -l`
90 outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $drun | cut -c 1-4`/`printf %08d $drun | cut -c 5-8`
91 makedir $outpath
92 log=$outpath/ceres`printf %08d $run `
93 command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run pedestal"
94 printprocesslog "INFO executing "$command
95 $command
96 check1=$?
97 ;;
98 4) printprocesslog "INFO run $run is a calibration run (key="$runkey")"
99 drun=`echo "$run + 1 " | bc -l`
100 outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $drun | cut -c 1-4`/`printf %08d $drun | cut -c 5-8`
101 makedir $outpath
102 log=$outpath/ceres`printf %08d $run `
103 command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run calibration"
104 printprocesslog "INFO executing "$command
105 $command
106 check1=$?
107 ;;
108 *) printprocesslog "WARN not valid fRunTypeKEY ("$runkey") was queried from the DB."
109 check="no"
110 ;;
111esac
112
113case $check1 in
114 0) printprocesslog "INFO $program finished successfully for run $run, cereskey $cereskey, runtype $runkey (check1=$check1)"
115 ;;
116 *) printprocesslog "ERROR $program failed for run $run, cereskey $cereskey, runtype $runkey (check1=$check1)"
117 check=$check1
118 ;;
119esac
120
121setstatus "stop"
122
123finish
124
Note: See TracBrowser for help on using the repository browser.