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 building one sequence per directory. As the files are
|
---|
32 | # structured by condition, the files in one directory and such in one
|
---|
33 | # sequence have the same observation mode, psf, zbin, ...
|
---|
34 | #
|
---|
35 |
|
---|
36 | source `dirname $0`/sourcefile
|
---|
37 | printprocesslog "INFO starting $0"
|
---|
38 | program=mcsequences
|
---|
39 |
|
---|
40 | set -C
|
---|
41 |
|
---|
42 | scriptlog=$runlogpath/$program`date +%F`.log
|
---|
43 | date >> $scriptlog 2>&1
|
---|
44 |
|
---|
45 | # check if script is already running
|
---|
46 | lockfile=$lockpath/lock-$program.txt
|
---|
47 | checklock >> $scriptlog 2>&1
|
---|
48 |
|
---|
49 | # find montecarlo directories, build one sequence per directory and write sequence file
|
---|
50 | printprocesslog "INFO building one sequence per mcdirectory"
|
---|
51 | dirs=`find $mcrawpath -type d`
|
---|
52 | for dir in ${dirs[@]}
|
---|
53 | do
|
---|
54 | cont=`echo $dir | cut -d/ -f6`
|
---|
55 | if [ "$cont" == "" ]
|
---|
56 | then
|
---|
57 | continue
|
---|
58 | fi
|
---|
59 | echo $dir >> $scriptlog 2>&1
|
---|
60 | files=`ls $dir`
|
---|
61 | calfile=`find $dir -name *_C_*`
|
---|
62 | pedfile=`find $dir -name *_P_*`
|
---|
63 | calrun=`echo $calfile | cut -d_ -f2`
|
---|
64 | pedrun=`echo $pedfile | cut -d_ -f2`
|
---|
65 | datruns=`find $dir -name *_D_* | cut -d_ -f2 | tr "\n" " "`
|
---|
66 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
---|
67 | # firstrun=`echo $datruns | cut -c 0-8`
|
---|
68 | firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
|
---|
69 | date=`echo $dir | cut -c 22-31 | sed -e 's/\//-/g'`
|
---|
70 |
|
---|
71 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
---|
72 | # no=`echo $firstrun | cut -c 0-4`
|
---|
73 | no=`printf %08d $firstrun | cut -c 0-4`
|
---|
74 | no2=`printf %08d $firstrun`
|
---|
75 | sequpath=$mcsequpath/$no
|
---|
76 | makedir $sequpath >> $scriptlog 2>&1
|
---|
77 | # sequfile=$sequpath/sequence$firstrun.txt
|
---|
78 | sequfile=$sequpath/sequence$no2.txt
|
---|
79 | echo "writing sequfile "$sequfile >> $scriptlog 2>&1
|
---|
80 | printprocesslog "INFO writing sequencefile $sequfile"
|
---|
81 |
|
---|
82 | echo "Sequence: $firstrun" >| $sequfile
|
---|
83 | echo "Night: $date" >> $sequfile
|
---|
84 | echo "" >> $sequfile
|
---|
85 | echo "CalRuns: $calrun" >> $sequfile
|
---|
86 | echo "PedRuns: $pedrun" >> $sequfile
|
---|
87 | echo "DatRuns: $datruns" >> $sequfile
|
---|
88 | echo "" >> $sequfile
|
---|
89 | echo "MonteCarlo: Yes" >> $sequfile
|
---|
90 | echo "" >> $sequfile
|
---|
91 | done
|
---|
92 |
|
---|
93 | finish >> $scriptlog 2>&1
|
---|
94 |
|
---|