source: trunk/MagicSoft/Mars/datacenter/scripts/mcsequences@ 7904

Last change on this file since 7904 was 7902, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.1 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 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
36program=mcsequences
37source `dirname $0`/sourcefile
38
39set -C
40
41scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
42makedir $scriptlogpath
43scriptlog=$scriptlogpath/$program`date +%F`.log
44
45date >> $scriptlog 2>&1
46
47# check if script is already running
48lockfile=$lockpath/lock-$program.txt
49checklock >> $scriptlog 2>&1
50
51
52mcpath=/montecarlo/rawfiles
53mcsequpath=/montecarlo/sequences
54
55# find montecarlo directories, build one sequence per directory and write sequence file
56dirs=`find $mcpath -type d`
57for dir in ${dirs[@]}
58do
59 cont=`echo $dir | cut -d/ -f6`
60 if [ "$cont" == "" ]
61 then
62 continue
63 fi
64 echo $dir >> $scriptlog 2>&1
65 files=`ls $dir`
66 calfile=`find $dir -name *_C_*`
67 pedfile=`find $dir -name *_P_*`
68 calrun=`echo $calfile | cut -d_ -f2`
69 pedrun=`echo $pedfile | cut -d_ -f2`
70 datruns=`find $dir -name *_D_* | cut -d_ -f2 | tr "\n" " "`
71# workaround due to 5digit runnumber for data with runnumber < 35487
72# firstrun=`echo $datruns | cut -c 0-8`
73 firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
74 date=`echo $dir | cut -c 22-31 | sed -e 's/\//-/g'`
75
76# workaround due to 5digit runnumber for data with runnumber < 35487
77# no=`echo $firstrun | cut -c 0-4`
78 no=`printf %08d $firstrun | cut -c 0-4`
79 no2=`printf %08d $firstrun`
80 sequpath=$mcsequpath/$no
81 makedir $sequpath >> $scriptlog 2>&1
82# sequfile=$sequpath/sequence$firstrun.txt
83 sequfile=$sequpath/sequence$no2.txt
84 echo "writing sequfile "$sequfile >> $scriptlog 2>&1
85
86 echo "Sequence: $firstrun" > $sequfile
87 echo "Night: $date" >> $sequfile
88 echo "" >> $sequfile
89 echo "CalRuns: $calrun" >> $sequfile
90 echo "PedRuns: $pedrun" >> $sequfile
91 echo "DatRuns: $datruns" >> $sequfile
92 echo "" >> $sequfile
93done
94
95
96rm -v $lockfile >> $scriptlog 2>&1
97
98set +C
99
100date >> $scriptlog 2>&1
101
Note: See TracBrowser for help on using the repository browser.