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 | user=`whoami`
|
---|
37 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
38 |
|
---|
39 | set -C
|
---|
40 |
|
---|
41 | scriptlogpath=$logpath/run/mcsequences/`date +%Y/%m/%d`
|
---|
42 | makedir $scriptlogpath
|
---|
43 | scriptlog=$scriptlogpath/mcsequences`date +%F`.log
|
---|
44 |
|
---|
45 | date >> $scriptlog 2>&1
|
---|
46 |
|
---|
47 | # check if script is already running
|
---|
48 | lockfile=$lockpath/lock-mcsequences.txt
|
---|
49 | date > $lockfile >> $scriptlog 2>&1
|
---|
50 | checklock0=$?
|
---|
51 | case $checklock0 in
|
---|
52 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
53 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
54 | echo "-> linkmc is running -> exit" >> $scriptlog 2>&1
|
---|
55 | date >> $scriptlog 2>&1
|
---|
56 | exit;;
|
---|
57 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
58 | esac
|
---|
59 |
|
---|
60 |
|
---|
61 | mcpath=/montecarlo/rawfiles
|
---|
62 | mcsequpath=/montecarlo/sequences
|
---|
63 |
|
---|
64 | # find montecarlo directories, build one sequence per directory and write sequence file
|
---|
65 | dirs=`find $mcpath -type d`
|
---|
66 | for dir in ${dirs[@]}
|
---|
67 | do
|
---|
68 | cont=`echo $dir | cut -d/ -f6`
|
---|
69 | if [ "$cont" == "" ]
|
---|
70 | then
|
---|
71 | continue
|
---|
72 | fi
|
---|
73 | echo $dir >> $scriptlog 2>&1
|
---|
74 | files=`ls $dir`
|
---|
75 | calfile=`find $dir -name *_C_*`
|
---|
76 | pedfile=`find $dir -name *_P_*`
|
---|
77 | calrun=`echo $calfile | cut -d_ -f2`
|
---|
78 | pedrun=`echo $pedfile | cut -d_ -f2`
|
---|
79 | datruns=`find $dir -name *_D_* | cut -d_ -f2 | tr "\n" " "`
|
---|
80 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
---|
81 | # firstrun=`echo $datruns | cut -c 0-8`
|
---|
82 | firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
|
---|
83 | date=`echo $dir | cut -c 22-31 | sed -e 's/\//-/g'`
|
---|
84 |
|
---|
85 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
---|
86 | # no=`echo $firstrun | cut -c 0-4`
|
---|
87 | no=`printf %08d $firstrun | cut -c 0-4`
|
---|
88 | no2=`printf %08d $firstrun`
|
---|
89 | sequpath=$mcsequpath/$no
|
---|
90 | makedir $sequpath >> $scriptlog 2>&1
|
---|
91 | # sequfile=$sequpath/sequence$firstrun.txt
|
---|
92 | sequfile=$sequpath/sequence$no2.txt
|
---|
93 | echo "writing sequfile "$sequfile >> $scriptlog 2>&1
|
---|
94 |
|
---|
95 | echo "Sequence: $firstrun" > $sequfile
|
---|
96 | echo "Night: $date" >> $sequfile
|
---|
97 | echo "" >> $sequfile
|
---|
98 | echo "CalRuns: $calrun" >> $sequfile
|
---|
99 | echo "PedRuns: $pedrun" >> $sequfile
|
---|
100 | echo "DatRuns: $datruns" >> $sequfile
|
---|
101 | echo "" >> $sequfile
|
---|
102 | done
|
---|
103 |
|
---|
104 |
|
---|
105 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
106 |
|
---|
107 | set +C
|
---|
108 |
|
---|
109 | date >> $scriptlog 2>&1
|
---|
110 |
|
---|