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

Last change on this file since 8761 was 8761, checked in by hoehne, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.2 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-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
36source `dirname $0`/sourcefile
37printprocesslog "INFO starting $0"
38program=mcsequences
39
40set -C
41
42scriptlog=$runlogpath/$program-$datetime.log
43date >> $scriptlog 2>&1
44
45# check if script is already running
46lockfile=$lockpath/lock-$program.txt
47checklock >> $scriptlog 2>&1
48
49# find montecarlo directories, build one sequence per directory and write sequence file
50printprocesslog "INFO building one sequence per mcdirectory and epoch"
51dirs=`find $mcrawpath -type d`
52for dir in ${dirs[@]}
53do
54 cont=`echo $dir | cut -d/ -f6`
55# cont=`echo $dir | cut -d/ -f10`
56 if [ "$cont" == "" ]
57 then
58 continue
59 fi
60 echo $dir >> $scriptlog 2>&1
61
62 epochs=`ls -l $mcpath/camera | cut -c 52-70`
63 for epoch in ${epochs[@]}
64 do
65 echo $epoch >> $scriptlog 2>&1
66 calfile=`find $dir -lname *$epoch*.root | grep "_C_"`
67 pedfile=`find $dir -lname *$epoch*.root | grep "_P_"`
68# datfiles=`find $dir -lname '*$epoch*.root' | grep "_D_"`
69
70 calrun=`echo $calfile | cut -d_ -f2`
71 pedrun=`echo $pedfile | cut -d_ -f2`
72
73 modes=("Gamma" "GammaW1" "GammaW2" "GammaFW" "GammaDiff" "GammaHE" "GammaHEW1" "GammaHEW2" "GammaHEFW" "GammaHEDiff" "ProtonDiff" "ProtonHEDiff" "MuonDiff" "MuonHEDiff")
74 for mode in ${modes[@]}
75 do
76 datruns=`find $dir -lname *$epoch*.root | grep $mode | grep "_D_" | cut -d_ -f2 | tr "\n" " "`
77 if [ "$datruns" != "" ]
78 then
79 # workaround due to 5digit runnumber for data with runnumber < 35487
80 firstrun=`echo $datruns | cut -c 0-8`
81 # firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
82 date=`echo $dir | cut -c 28-37 | sed -e 's/\//-/g'`
83# date=`echo $dir | cut -c 57-66 | sed -e 's/\//-/g'`
84 # for tests
85 # date=`echo $dir | cut -c 57-66 | sed -e 's/\//-/g'`
86
87 # workaround due to 5digit runnumber for data with runnumber < 35487
88 no=`echo $firstrun | cut -c 0-4`
89 # no=`printf %08d $firstrun | cut -c 0-4`
90 # no2=`printf %08d $firstrun`
91 sequpath=$mcsequpath/$no
92 makedir $sequpath >> $scriptlog 2>&1
93 sequfile=$sequpath/sequence$firstrun.txt
94 # sequfile=$sequpath/sequence$no2.txt
95 echo "writing sequfile "$sequfile >> $scriptlog 2>&1
96 printprocesslog "INFO writing sequencefile $sequfile"
97
98 echo "Sequence: $firstrun" >| $sequfile
99 echo "Night: $date" >> $sequfile
100 echo "Epoch: $epoch" >> $sequfile
101 echo "Mode: $mode" >> $sequfile
102 echo "" >> $sequfile
103 echo "CalRuns: $calrun" >> $sequfile
104 echo "PedRuns: $pedrun" >> $sequfile
105 echo "DatRuns: $datruns" >> $sequfile
106 echo "" >> $sequfile
107 echo "MonteCarlo: Yes" >> $sequfile
108 echo "" >> $sequfile
109 fi
110 done
111 done
112done
113
114finish >> $scriptlog 2>&1
115
Note: See TracBrowser for help on using the repository browser.