source: trunk/MagicSoft/Mars/datacenter/scripts/processmcsequences@ 7974

Last change on this file since 7974 was 7944, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.5 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
47mcpath=/montecarlo/rawfiles
48mccalpath=/montecarlo/callisto
49mcimgpath=/montecarlo/star
50mcsequpath=/montecarlo/sequences
51callistorc=$setuppath/callisto/callisto.rc
52
53cd $mars
54
55# find montecarlo sequence files
56printprocesslog "INFO processing mc sequences"
57sequfiles=`find $mcsequpath -type f`
58for sequfile in ${sequfiles[@]}
59do
60 sequno=`echo $sequfile | cut -c 36-43`
61 no=`echo $sequno | cut -c 0-4`
62 date=`grep Night $sequfile | cut -c 18-29 | sed -e 's/-/\//g'`
63 caloutpath=$mccalpath/$no/$sequno
64 makedir $caloutpath >> $scriptlog 2>&1
65
66 # continue with next sequence, if sequence is already processed
67 # or processing of sequence is just running
68 if ls $caloutpath/.done >> $scriptlog 2>&1
69 then
70 continue
71 fi
72 if ls $caloutpath/.doing >> $scriptlog 2>&1
73 then
74 continue
75 fi
76
77 # lock file
78 touch $caloutpath/.doing
79 echo "processing sequ $sequfile" >> $scriptlog 2>&1
80 # find callisto.rc file
81 if [ -e $caloutpath/callisto.rc ]
82 then
83 echo "found callisto.rc in $caloutpath -> using this " >> $scriptlog 2>&1
84 callistorcseq=$caloutpath/callisto.rc
85 else
86 echo "no callisto.rc found in $caloutpath -> making link " >> $scriptlog 2>&1
87 ln -vs $callistorc $caloutpath/callisto.rc >> $scriptlog 2>&1
88 callistorcseq=$caloutpath/callisto.rc
89 fi
90 # calibrate data
91 echo "./callisto -mc -f -b -q --ind=$mcpath/$date --log=$caloutpath/callisto$sequno.log --html=$caloutpath/callisto$sequno.html --out=$caloutpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null" >> $scriptlog 2>&1
92 ./callisto -mc -f -b -q --ind=$mcpath/$date --log=$caloutpath/callisto$sequno.log --html=$caloutpath/callisto$sequno.html --out=$caloutpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
93 check1=$?
94 # if calibration worked -> run star for sequence
95 case $check1 in
96 0) echo " check1=$check1 -> everything ok..." >> $scriptlog 2>&1
97 printprocesslog "INFO calibrated mc sequende $sequno successfully"
98 touch $caloutpath/.done
99 rm $caloutpath/.doing
100 imgoutpath=$mcimgpath/$no/$sequno
101 makedir $imgoutpath >> $scriptlog 2>&1
102
103 ./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
104 check2=$?
105
106 case $check2 in
107 0) echo " check2=$check2 -> everything ok..." >> $scriptlog 2>&1
108 printprocesslog "INFO run star successfully for mc sequende $sequno"
109 touch $imgoutpath/.done
110 ;;
111 *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
112 printprocesslog "ERROR star failed for mc sequende $sequno"
113 ;;
114 esac
115 ;;
116 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
117 printprocesslog "ERROR callisto failed for mc sequende $sequno"
118 ;;
119 esac
120done
121
122finish >> $scriptlog 2>&1
123
Note: See TracBrowser for help on using the repository browser.