source: branches/MarsGapdTimeJitter/datacenter/scripts/processmcsequences@ 18234

Last change on this file since 18234 was 8758, checked in by hoehne, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.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 12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2007
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 muxcheck=`grep Epoch $sequfile | cut -c 18-32`
62 case $muxcheck in
63 "MC_up_to_April06")
64 callistorc=$setuppath/callisto/callisto.rc
65 ;;
66 "MC_old")
67 callistorc=$setuppath/callisto/callisto.rc
68 ;;
69 "MC_April_May06")
70 callistorc=$setuppath/callisto/callisto.rc
71 ;;
72 "MC_post_June06")
73 callistorc=$setuppath/callisto/callisto.rc
74 ;;
75 "MC_MuxFADCs")
76 callistorc=$setuppath/callisto/callisto_mux.rc
77 ;;
78 "MC_MuxFADCs_NEW")
79 callistorc=$setuppath/callisto/callisto_mux.rc
80 ;;
81 *)
82 echo "No epoch found"
83 printprocesslog "ERROR no epoch found in $sequfile for setting the right callisto.rc, using standard callisto.rc, epoch: $epoch"
84 finish >> $scriptlog 2>&1
85 ;;
86 esac
87
88 caloutpath=$mccalpath/$no/$sequno
89 makedir $caloutpath >> $scriptlog 2>&1
90
91 # continue with next sequence if sequence is already processed
92 # or processing of sequence is just running
93 if ls $caloutpath/.done >> $scriptlog 2>&1
94 then
95 continue
96 fi
97 if ls $caloutpath/.doing >> $scriptlog 2>&1
98 then
99 continue
100 fi
101
102 # lock file
103 touch $caloutpath/.doing
104 echo "processing sequ $sequfile" >> $scriptlog 2>&1
105 # find callisto.rc file
106 if [ -e $caloutpath/callisto.rc ]
107 then
108 echo "found callisto.rc in $caloutpath -> using this" >> $scriptlog 2>&1
109 callistorcseq=$caloutpath/callisto.rc
110 else
111 echo "no callisto.rc found in $caloutpath -> making link " >> $scriptlog 2>&1
112 ln -vs $callistorc $caloutpath/callisto.rc >> $scriptlog 2>&1
113 callistorcseq=$caloutpath/callisto.rc
114 fi
115 # calibrate data
116 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
117 ./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
118 check1=$?
119 # if calibration worked -> run star for sequence
120 case $check1 in
121 0) echo " check1=$check1 -> everything ok..." >> $scriptlog 2>&1
122 printprocesslog "INFO calibrated mc sequence $sequno successfully"
123 touch $caloutpath/.done
124 rm $caloutpath/.doing
125 imgoutpath=$mcimgpath/$no/$sequno
126 makedir $imgoutpath >> $scriptlog 2>&1
127
128 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
129 ./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
130 check2=$?
131
132 case $check2 in
133 0) echo " check2=$check2 -> everything ok..." >> $scriptlog 2>&1
134 printprocesslog "INFO run star successfully for mc sequence $sequno"
135 touch $imgoutpath/.done
136 ;;
137 *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
138 printprocesslog "ERROR star failed for mc sequence $sequno"
139 ;;
140 esac
141 ;;
142 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
143 printprocesslog "ERROR callisto failed for mc sequence $sequno"
144 ;;
145 esac
146done
147
148finish >> $scriptlog 2>&1
149
Note: See TracBrowser for help on using the repository browser.