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

Last change on this file since 7835 was 7835, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.2 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
34program=processmcsequences
35source /home/`whoami`/Mars/datacenter/scripts/sourcefile
36
37set -C
38
39scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
40makedir $scriptlogpath
41scriptlog=$scriptlogpath/$program`date +%F-%H-%M-%S`.log
42
43date >> $scriptlog 2>&1
44
45# check if script is already running
46lockfile=$lockpath/lock-$program.txt
47checklock >> $scriptlog 2>&1
48
49mcpath=/montecarlo/rawfiles
50mccalpath=/montecarlo/callisto
51mcimgpath=/montecarlo/star
52mcsequpath=/montecarlo/sequences
53callistorc=$setuppath/callisto/callisto.rc
54
55cd $mars
56
57# find montecarlo sequence files
58sequfiles=`find $mcsequpath -type f`
59for sequfile in ${sequfiles[@]}
60do
61 sequno=`echo $sequfile | cut -c 36-43`
62 no=`echo $sequno | cut -c 0-4`
63 date=`grep Night $sequfile | cut -c 18-29 | sed -e 's/-/\//g'`
64 caloutpath=$mccalpath/$no/$sequno
65 makedir $caloutpath >> $scriptlog 2>&1
66
67 # continue with next sequence, if sequence is already processed
68 # or processing of sequence is just running
69 if ls $caloutpath/.done >> $scriptlog 2>&1
70 then
71 continue
72 fi
73 if ls $caloutpath/.doing >> $scriptlog 2>&1
74 then
75 continue
76 fi
77
78 # lock file
79 touch $caloutpath/.doing
80 echo "processing sequ $sequfile" >> $scriptlog 2>&1
81 # find callisto.rc file
82 if [ -e $caloutpath/callisto.rc ]
83 then
84 echo "found callisto.rc in $caloutpath -> using this " >> $scriptlog 2>&1
85 callistorcseq=$caloutpath/callisto.rc
86 else
87 echo "no callisto.rc found in $caloutpath -> making link " >> $scriptlog 2>&1
88 ln -vs $callistorc $caloutpath/callisto.rc >> $scriptlog 2>&1
89 callistorcseq=$caloutpath/callisto.rc
90 fi
91 # calibrate data
92 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
93 ./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
94 check1=$?
95 # if calibration worked -> run star for sequence
96 case $check1 in
97 0) echo "check1=$check1 -> everything ok..." >> $scriptlog 2>&1
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 touch $imgoutpath/.done
109 ;;
110 *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
111 ;;
112 esac
113 ;;
114 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
115 esac
116done
117
118rm -v $lockfile >> $scriptlog 2>&1
119
120set +C
121
122date >> $scriptlog 2>&1
123
Note: See TracBrowser for help on using the repository browser.