| 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)
|
|---|
| 36 | sequence=
|
|---|
| 37 | sequfile=""
|
|---|
| 38 |
|
|---|
| 39 | #path of your output directory
|
|---|
| 40 | outpath=movies
|
|---|
| 41 | #define values for callisto.rc files
|
|---|
| 42 | TargetLength=5
|
|---|
| 43 | NumEvents=500
|
|---|
| 44 | Threshold=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 |
|
|---|
| 51 | function 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 |
|
|---|
| 79 | alias mymysql='mysql -u MAGIC --password=d99swMT! --host=vela MyMagic -s -e'
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | while [ "$1" ]
|
|---|
| 83 | do
|
|---|
| 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
|
|---|
| 109 | done
|
|---|
| 110 |
|
|---|
| 111 | if [ "$sequence" = "" ]
|
|---|
| 112 | then
|
|---|
| 113 | echo "WARNING sequ has not been set"
|
|---|
| 114 | echo ""
|
|---|
| 115 | usage
|
|---|
| 116 | fi
|
|---|
| 117 |
|
|---|
| 118 | # get variables
|
|---|
| 119 | if ! n8=`printf %08d $sequence`
|
|---|
| 120 | then
|
|---|
| 121 | echo "your sequence number is not valid"
|
|---|
| 122 | usage
|
|---|
| 123 | fi
|
|---|
| 124 | no=`echo $n8 | cut -c 1-4`
|
|---|
| 125 | if [ "$mc" == "mc" ]
|
|---|
| 126 | then
|
|---|
| 127 | sequfile="/magic/montecarlo/sequences/"$no"/sequence$n8.txt"
|
|---|
| 128 | calpath="/magic/montecarlo/callisto/"$no"/"$n8
|
|---|
| 129 | else
|
|---|
| 130 | sequfile="/magic/sequences/"$no"/sequence$n8.txt"
|
|---|
| 131 | calpath="/magic/data/callisto/"$no"/"$n8
|
|---|
| 132 | fi
|
|---|
| 133 | outpath2=$outpath"/temp"
|
|---|
| 134 | datasetfile=$outpath2"/dataset"$n8".txt"
|
|---|
| 135 | ganymedfile=$outpath2"/ganymed"$n8".root"
|
|---|
| 136 | ganymedsumfile=$outpath2"/ganymed"$n8"-summary.root"
|
|---|
| 137 | mkdir -pv $outpath2
|
|---|
| 138 |
|
|---|
| 139 | if ! ls $sequfile >/dev/null
|
|---|
| 140 | then
|
|---|
| 141 | echo $sequfile" doesn't exist."
|
|---|
| 142 | usage
|
|---|
| 143 | fi
|
|---|
| 144 |
|
|---|
| 145 | echo ""
|
|---|
| 146 | echo "Variables and paths from your input: "
|
|---|
| 147 | echo " outpath: "$outpath
|
|---|
| 148 | echo " sequence: "$sequence
|
|---|
| 149 | echo " sequfile: "$sequfile
|
|---|
| 150 | echo " datasetfile: "$datasetfile
|
|---|
| 151 | echo " ganymedfiles: "$ganymedfile", "$ganymedsumfile
|
|---|
| 152 | echo " inputpaths: "$calpath
|
|---|
| 153 | echo ""
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 | # write datasetfile
|
|---|
| 157 | echo "AnalysisNumber: "$sequence > $datasetfile
|
|---|
| 158 | echo "" >> $datasetfile
|
|---|
| 159 | echo "SequencesOn: "$sequence >> $datasetfile
|
|---|
| 160 | echo "" >> $datasetfile
|
|---|
| 161 | if [ "$mc" == "mc" ]
|
|---|
| 162 | then
|
|---|
| 163 | echo "MonteCarlo: Yes " >> $datasetfile
|
|---|
| 164 | else
|
|---|
| 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
|
|---|
| 170 | fi
|
|---|
| 171 | if [ "$wobble" == "yes" ]
|
|---|
| 172 | then
|
|---|
| 173 | echo "WobbleMode: On " >> $datasetfile
|
|---|
| 174 | fi
|
|---|
| 175 | echo "" >> $datasetfile
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 | # choose callisto.rc
|
|---|
| 179 | if [ $sequence -gt 200000 ]
|
|---|
| 180 | then
|
|---|
| 181 | rc="callisto_mux.rc"
|
|---|
| 182 | else
|
|---|
| 183 | rc="callisto.rc"
|
|---|
| 184 | fi
|
|---|
| 185 |
|
|---|
| 186 | # write callisto.rc files
|
|---|
| 187 | names=( "withoutcut" "qualcut" "areacut" "thetacut" )
|
|---|
| 188 | for (( i=0 ; i < 4 ; i++ ))
|
|---|
| 189 | do
|
|---|
| 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
|
|---|
| 209 | done
|
|---|
| 210 |
|
|---|
| 211 | # define options for callisto
|
|---|
| 212 | opts=" -f -v5 -b --movie "
|
|---|
| 213 | if [ "$mc" == "mc" ]
|
|---|
| 214 | then
|
|---|
| 215 | opts=$opts" -mc "
|
|---|
| 216 | fi
|
|---|
| 217 | opts=$opts" -y --iny=$calpath $sequence "
|
|---|
| 218 |
|
|---|
| 219 | # produce movie without cuts
|
|---|
| 220 | command="./callisto $opts --config=$outpath2/callisto_$n8$mc-${names[0]}.rc "
|
|---|
| 221 | echo "submitting: "$command
|
|---|
| 222 | condor_run $command &
|
|---|
| 223 |
|
|---|
| 224 | # run ganymed and produce summary file
|
|---|
| 225 | gopts="-v5 -f -b "
|
|---|
| 226 | if [ "$wobble" == "yes" ]
|
|---|
| 227 | then
|
|---|
| 228 | gopts=$gopts" --config=ganymed_wobble.rc "
|
|---|
| 229 | fi
|
|---|
| 230 | command="./ganymed $gopts --sum --out=$outpath2 $datasetfile"
|
|---|
| 231 | echo "executing: "$command
|
|---|
| 232 | if ! $command
|
|---|
| 233 | then
|
|---|
| 234 | echo "execution failed."
|
|---|
| 235 | exit
|
|---|
| 236 | fi
|
|---|
| 237 |
|
|---|
| 238 | # produce movies with cuts
|
|---|
| 239 | for (( i=1 ; i < 4 ; i++ ))
|
|---|
| 240 | do
|
|---|
| 241 | command="./callisto $opts --config=$outpath2/callisto_$n8$mc-${names[$i]}.rc "
|
|---|
| 242 | echo "submitting: "$command
|
|---|
| 243 | condor_run $command &
|
|---|
| 244 | done
|
|---|
| 245 |
|
|---|