source: tags/Mars-V1.1/datacenter/scripts/processmcsequences

Last change on this file was 8080, checked in by snruegam, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.6 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 12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2006
23#
24#
25# ========================================================================
26#
27# This script is an intermediate solution to process the montecarlo files.
28# As soon as the montecarlo database is running, this script shall be
29# exchanged.
30#
31# The script is processing the montecarlo sequences: callisto and star
32#
33
34source `dirname $0`/sourcefile
35printprocesslog "INFO starting $0"
36program=processmcsequences
37
38set -C
39
40scriptlog=$runlogpath/$program`date +%F-%H-%M-%S`.log
41date >> $scriptlog 2>&1
42
43# check if script is already running
44lockfile=$lockpath/lock-$program.txt
45checklock >> $scriptlog 2>&1
46
47mccalpath=$mcpath/callisto
48mcimgpath=$mcpath/star
49callistorc=$setuppath/callisto/callisto.rc
50
51cd $mars
52
53# find montecarlo sequence files
54printprocesslog "INFO processing mc sequences"
55sequfiles=`find $mcsequpath -type f`
56for sequfile in ${sequfiles[@]}
57do
58 sequno=`echo $sequfile | cut -c 42-49`
59 no=`echo $sequno | cut -c 0-4`
60 date=`grep Night $sequfile | cut -c 18-29 | sed -e 's/-/\//g'`
61 caloutpath=$mccalpath/$no/$sequno
62 makedir $caloutpath >> $scriptlog 2>&1
63
64 # continue with next sequence if sequence is already processed
65 # or processing of sequence is just running
66 if ls $caloutpath/.done >> $scriptlog 2>&1
67 then
68 continue
69 fi
70 if ls $caloutpath/.doing >> $scriptlog 2>&1
71 then
72 continue
73 fi
74
75 # lock file
76 touch $caloutpath/.doing
77 echo "processing sequ $sequfile" >> $scriptlog 2>&1
78 # find callisto.rc file
79 if [ -e $caloutpath/callisto.rc ]
80 then
81 echo "found callisto.rc in $caloutpath -> using this" >> $scriptlog 2>&1
82 callistorcseq=$caloutpath/callisto.rc
83 else
84 echo "no callisto.rc found in $caloutpath -> making link " >> $scriptlog 2>&1
85 ln -vs $callistorc $caloutpath/callisto.rc >> $scriptlog 2>&1
86 callistorcseq=$caloutpath/callisto.rc
87 fi
88 # calibrate data
89 echo "./callisto -mc -f -b -q --ind=$mcrawpath/$date --log=$caloutpath/callisto$sequno.log --html=$caloutpath/callisto$sequno.html --out=$caloutpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null" >> $scriptlog 2>&1
90 ./callisto -mc -f -b -q --ind=$mcrawpath/$date --log=$caloutpath/callisto$sequno.log --html=$caloutpath/callisto$sequno.html --out=$caloutpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
91 check1=$?
92 # if calibration worked -> run star for sequence
93 case $check1 in
94 0) echo " check1=$check1 -> everything ok..." >> $scriptlog 2>&1
95 printprocesslog "INFO calibrated mc sequence $sequno successfully"
96 touch $caloutpath/.done
97 rm $caloutpath/.doing
98 imgoutpath=$mcimgpath/$no/$sequno
99 makedir $imgoutpath >> $scriptlog 2>&1
100
101 echo "./star -b -q -v4 -f -mc --log=$imgoutpath/star$sequno.log --html=$imgoutpath/star$sequno.html --ind=$caloutpath --out=$imgoutpath $sequfile 2>> $scriptlog> /dev/null" >> $scriptlog 2>&1
102 ./star -b -q -v4 -f -mc --log=$imgoutpath/star$sequno.log --html=$imgoutpath/star$sequno.html --ind=$caloutpath --out=$imgoutpath $sequfile 2>> $scriptlog> /dev/null
103 check2=$?
104
105 case $check2 in
106 0) echo " check2=$check2 -> everything ok..." >> $scriptlog 2>&1
107 printprocesslog "INFO run star successfully for mc sequence $sequno"
108 touch $imgoutpath/.done
109 ;;
110 *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
111 printprocesslog "ERROR star failed for mc sequence $sequno"
112 ;;
113 esac
114 ;;
115 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
116 printprocesslog "ERROR callisto failed for mc sequence $sequno"
117 ;;
118 esac
119done
120
121finish >> $scriptlog 2>&1
122
Note: See TracBrowser for help on using the repository browser.