source: trunk/MagicSoft/Mars/scripts/makemovie@ 8473

Last change on this file since 8473 was 8473, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.7 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 10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2006
23#
24#
25# ========================================================================
26#
27#
28#
29##############################################################################
30#
31#
32##############################################################################
33
34#to be set by the user (if you don't use the command-line options)
35#give either sequence number or sequence file (including path)
36sequence=
37sequfile=""
38
39#path of your output directory
40outpath=movies
41#define values for callisto.rc files
42TargetLength=5
43NumEvents=500
44Threshold=3
45
46#MFEvtNumber.FileName: ganymed00001218.root
47#MFEvtNumber.Selector: ThetaSquared.fVal<0.04 && DataType.fVal>0.5
48#MMovieWrite.Filename: movie-00071431-off-all.mpg
49
50
51function usage()
52{
53 echo "Usage: $0 [options]"
54 echo "options:"
55 echo -n " --sequ sequence# "
56 echo " giving number of sequence which shall be processed "
57 echo -n " --out outpath "
58 echo " giving the path where all outputfiles are stored "
59 echo -n " --target-length seconds "
60 echo " giving the length of one event in seconds "
61 echo -n " --num-events #events "
62 echo " giving the number of events in the movie "
63 echo -n " -wobble "
64 echo " give this option for processing a wobble sequence "
65 echo -n " -mc "
66 echo " give this option for processing a montecarlo sequence "
67 echo ""
68 echo "Remarks: "
69 echo " - you can set the needed variables also in the script "
70 echo " - you have to set the outpath and either the sequence number or the sequence file"
71 echo " (if both is set, the sequence given by the sequencefile is processed)"
72 echo " - you have to execute the script from your mars directory"
73 echo " - some options for the movie can be set in the script"
74 echo " - if you don't set the outpath, the default 'movies' is used"
75 echo ""
76 exit
77}
78
79alias mymysql='mysql -u MAGIC --password=d99swMT! --host=vela MyMagic -s -e'
80
81
82while [ "$1" ]
83do
84 case $1 in
85 --sequ) shift
86 sequence=$1
87 ;;
88 --out) shift
89 outpath=$1
90 ;;
91 --target-length) shift
92 TargetLength=$1
93 ;;
94 --num-events) shift
95 NumEvents=$1
96 ;;
97 -wobble) wobble='yes'
98 ;;
99 -mc) mc='mc'
100 ;;
101 -h) usage
102 ;;
103 *) echo "unknown option $1 "
104 usage
105 exit
106 ;;
107 esac
108 shift
109done
110
111if [ "$sequence" = "" ]
112then
113 echo "WARNING sequ has not been set"
114 echo ""
115 usage
116fi
117
118# get variables
119if ! n8=`printf %08d $sequence`
120then
121 echo "your sequence number is not valid"
122 usage
123fi
124no=`echo $n8 | cut -c 1-4`
125if [ "$mc" == "mc" ]
126then
127 sequfile="/magic/montecarlo/sequences/"$no"/sequence$n8.txt"
128 calpath="/magic/montecarlo/callisto/"$no"/"$n8
129else
130 sequfile="/magic/sequences/"$no"/sequence$n8.txt"
131 calpath="/magic/data/callisto/"$no"/"$n8
132fi
133outpath2=$outpath"/temp"
134datasetfile=$outpath2"/dataset"$n8".txt"
135ganymedfile=$outpath2"/ganymed"$n8".root"
136ganymedsumfile=$outpath2"/ganymed"$n8"-summary.root"
137mkdir -pv $outpath2
138
139if ! ls $sequfile >/dev/null
140then
141 echo $sequfile" doesn't exist."
142 usage
143fi
144
145echo ""
146echo "Variables and paths from your input: "
147echo " outpath: "$outpath
148echo " sequence: "$sequence
149echo " sequfile: "$sequfile
150echo " datasetfile: "$datasetfile
151echo " ganymedfiles: "$ganymedfile", "$ganymedsumfile
152echo " inputpaths: "$calpath
153echo ""
154
155
156# write datasetfile
157echo "AnalysisNumber: "$sequence > $datasetfile
158echo "" >> $datasetfile
159echo "SequencesOn: "$sequence >> $datasetfile
160echo "" >> $datasetfile
161if [ "$mc" == "mc" ]
162then
163 echo "MonteCarlo: Yes " >> $datasetfile
164else
165 # get source name
166 query="SELECT fSourceName FROM Source LEFT JOIN Sequences ON Sequences.fSourceKEY=Source.fSourceKEY WHERE fSequenceFirst="$sequence
167 source=`mymysql "$query"`
168 echo "SourceName: "$source >> $datasetfile
169 echo "Catalog: /magic/datacenter/setup/magic_favorites_dc.edb" >> $datasetfile
170fi
171if [ "$wobble" == "yes" ]
172then
173 echo "WobbleMode: On " >> $datasetfile
174fi
175echo "" >> $datasetfile
176
177
178# choose callisto.rc
179if [ $sequence -gt 200000 ]
180then
181 rc="callisto_mux.rc"
182else
183 rc="callisto.rc"
184fi
185
186# write callisto.rc files
187names=( "withoutcut" "qualcut" "areacut" "thetacut" )
188for (( i=0 ; i < 4 ; i++ ))
189do
190 calrc=$outpath2"/callisto_"$n8$mc"-"${names[$i]}".rc"
191 echo "creating "$calrc
192 grep -v MMoveWrite $rc > $calrc
193 echo "MMovieWrite.FileName: "$outpath"/movie"$n8$mc"-"${names[$i]}".mpg" >> $calrc
194 echo "MMovieWrite.TargetLength: "$TargetLength >> $calrc
195 echo "MMovieWrite.NumEvents: "$NumEvents >> $calrc
196 echo "MMovieWrite.Threshold: "$Threshold >> $calrc
197 if [ $i -eq 1 ]
198 then
199 echo "MFEvtNumber.FileName: "$ganymedsumfile >> $calrc
200 fi
201 if [ $i -gt 1 ]
202 then
203 echo "MFEvtNumber.FileName: "$ganymedfile >> $calrc
204 fi
205 if [ $i -gt 2 ]
206 then
207 echo "MFEvtNumber.Selector: ThetaSquared.fVal<0.04 && DataType.fVal>0.5" >> $calrc
208 fi
209done
210
211# define options for callisto
212opts=" -f -v5 -b --movie "
213if [ "$mc" == "mc" ]
214then
215 opts=$opts" -mc "
216fi
217opts=$opts" -y --iny=$calpath $sequence "
218
219# produce movie without cuts
220command="./callisto $opts --config=$outpath2/callisto_$n8$mc-${names[0]}.rc "
221echo "submitting: "$command
222condor_run $command &
223
224# run ganymed and produce summary file
225gopts="-v5 -f -b "
226if [ "$wobble" == "yes" ]
227then
228 gopts=$gopts" --config=ganymed_wobble.rc "
229fi
230command="./ganymed $gopts --sum --out=$outpath2 $datasetfile"
231echo "executing: "$command
232if ! $command
233then
234 echo "execution failed."
235 exit
236fi
237
238# produce movies with cuts
239for (( i=1 ; i < 4 ; i++ ))
240do
241 command="./callisto $opts --config=$outpath2/callisto_$n8$mc-${names[$i]}.rc "
242 echo "submitting: "$command
243 condor_run $command &
244done
245
Note: See TracBrowser for help on using the repository browser.