source: trunk/MagicSoft/Mars/mtemp/mwuerzburg/scripts/runmerpp@ 4083

Last change on this file since 4083 was 4083, checked in by merck, 21 years ago
Merck: first commit of runmerpp
  • Property svn:executable set to *
File size: 3.6 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): Martin Merck 05/2004 <mailto:merck@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2004
23#
24#
25# ========================================================================
26
27#/////////////////////////////////////////////////////////////////////////////
28#
29# runmerpp
30#
31# This scripts is used to run merpp on a full Period of data. It will run merpp
32# on the raw-data file. Then it will update the root file by merpping in the CC
33# and CACO data.
34# As for some rawdata files no CaCo data files exist (due to DAQ restarting a run)
35# we need to use the previous CaCo file. This will add to much dc-current infos
36# to the merpped file, but will gaurantee that the right dc-currents are always
37# available.
38#
39# TODO:
40# Due to problems with the DB the automatic DB update option is still disabled.
41#i
42# ------------------------------------
43# Which Period to use
44INDIR=/data/MAGIC/Period015
45# ------------------------------------
46#
47# For each day of this Period
48#
49DATES=`ls -d -1 $INDIR/rawdata2/20* | cut -d/ -f6 '-'`
50for DATE in $DATES
51do
52 OUTDIR=$INDIR/rootdata2/$DATE
53# Create Output Directory
54 if [ ! -d $OUTDIR ]
55 then
56 echo $DATE
57 mkdir $OUTDIR
58 fi
59
60#
61# Loop over all raw files for this day
62#
63 RAWFILES=`ls -1 $INDIR/rawdata2/$DATE/*.raw`
64 LOGFILE=$OUTDIR/merpp.log
65 TIME=`date`
66 echo "-----------------------------------------------------------------" > $LOGFILE
67 echo " MERPP run started $TIME" >> $LOGFILE
68 echo "-----------------------------------------------------------------" >> $LOGFILE
69
70 PREVIOUS_CACO=
71 for i in $RAWFILES
72 do
73 TIMER=$SECONDS
74 IN_FILE=$i
75 RUN_NUM=`echo $i | cut -d_ -f4`
76 CC_FILE=`ls -1 $INDIR/ccdata/$DATE/*$RUN_NUM*.rep`
77 CACO_FILE=`ls -1 $INDIR/cacodata/$DATE/*$RUN_NUM*.txt 2> /dev/null`
78 OUT_FILE=$OUTDIR/`echo $i | cut -d/ -s -f7 '-' | cut -d. -s -f1 '-'`.root
79# merpp -a -f --sql=mysql://hercules:d99swMT\!@hercules $IN_FILE $OUT_FILE >> $LOGFILE
80
81# MERPP the raw data file
82 merpp -a -f $IN_FILE $OUT_FILE >> $LOGFILE
83
84# MERPP the CC report file
85 merpp -a -u $CC_FILE $OUT_FILE >> $LOGFILE
86
87# If a CACO file exists for this run
88# MERPP the CACO file.
89 if [ -n "$CACO_FILE" ]
90 then
91 merpp -a -u $CACO_FILE $OUT_FILE >> $LOGFILE
92 PERVIOUS_CACO=$CACOFILE
93 fi
94
95# If no CACO file is available for this run
96# we use the previous CACO file
97# CACO only nows when CC starts a new run and creates 1 file for this run
98# however the DAQ may create more subruns due to errors or limitaation on the
99# filesize. The relevant CACO information should be in the CACO file created
100# when CC started this run (e.g. the previous CACO file)
101 if [ -z "$CACO_FILE" ]
102 then
103 if [ -n "$PREVIOUS_CACO" ]
104 then
105 merpp -a -u $PREVIOUS_CACO $OUT_FILE >> $LOGFILE
106 fi
107 fi
108 echo "Processed file $IN_FILE in $(( $SECONDS - $TIMER)) secs."
109 done
110done
Note: See TracBrowser for help on using the repository browser.