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 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 | mcpath=/montecarlo/rawfiles
|
---|
50 | mcsequpath=/montecarlo/sequences
|
---|
51 |
|
---|
52 | # find montecarlo directories, build one sequence per directory and write sequence file
|
---|
53 | printprocesslog "INFO building one sequence per mcdirectory"
|
---|
54 | dirs=`find $mcpath -type d`
|
---|
55 | for dir in ${dirs[@]}
|
---|
56 | do
|
---|
57 | cont=`echo $dir | cut -d/ -f6`
|
---|
58 | if [ "$cont" == "" ]
|
---|
59 | then
|
---|
60 | continue
|
---|
61 | fi
|
---|
62 | echo $dir >> $scriptlog 2>&1
|
---|
63 | files=`ls $dir`
|
---|
64 | calfile=`find $dir -name *_C_*`
|
---|
65 | pedfile=`find $dir -name *_P_*`
|
---|
66 | calrun=`echo $calfile | cut -d_ -f2`
|
---|
67 | pedrun=`echo $pedfile | cut -d_ -f2`
|
---|
68 | datruns=`find $dir -name *_D_* | cut -d_ -f2 | tr "\n" " "`
|
---|
69 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
---|
70 | # firstrun=`echo $datruns | cut -c 0-8`
|
---|
71 | firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
|
---|
72 | date=`echo $dir | cut -c 22-31 | sed -e 's/\//-/g'`
|
---|
73 |
|
---|
74 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
---|
75 | # no=`echo $firstrun | cut -c 0-4`
|
---|
76 | no=`printf %08d $firstrun | cut -c 0-4`
|
---|
77 | no2=`printf %08d $firstrun`
|
---|
78 | sequpath=$mcsequpath/$no
|
---|
79 | makedir $sequpath >> $scriptlog 2>&1
|
---|
80 | # sequfile=$sequpath/sequence$firstrun.txt
|
---|
81 | sequfile=$sequpath/sequence$no2.txt
|
---|
82 | echo "writing sequfile "$sequfile >> $scriptlog 2>&1
|
---|
83 | printprocesslog "INFO writing sequencefile $sequfile"
|
---|
84 |
|
---|
85 | echo "Sequence: $firstrun" > $sequfile
|
---|
86 | echo "Night: $date" >> $sequfile
|
---|
87 | echo "" >> $sequfile
|
---|
88 | echo "CalRuns: $calrun" >> $sequfile
|
---|
89 | echo "PedRuns: $pedrun" >> $sequfile
|
---|
90 | echo "DatRuns: $datruns" >> $sequfile
|
---|
91 | echo "" >> $sequfile
|
---|
92 | done
|
---|
93 |
|
---|
94 | finish >> $scriptlog 2>&1
|
---|
95 |
|
---|