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

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