source: branches/Mars_MC/scripts/makemovie@ 17292

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