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 06/2010 <mailto:daniela.dorner@unige.ch>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2010
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script launches the writing of the sequence files for all mc sequences
|
---|
28 | # for which this step is needed.
|
---|
29 | #
|
---|
30 | # After checking if the script is already running the todolist is written.
|
---|
31 | # Then the sequence file is written for each sequence in the todolist using
|
---|
32 | # the macro writesequencefile.C
|
---|
33 | # If this was successful, the status is inserted into the database using
|
---|
34 | # the function setstatus.
|
---|
35 | #
|
---|
36 |
|
---|
37 | source `dirname $0`/sourcefile
|
---|
38 | printprocesslog "INFO starting $0"
|
---|
39 | program=writemcsequencefile
|
---|
40 | step=SequenceFile
|
---|
41 |
|
---|
42 | set -C
|
---|
43 |
|
---|
44 | # check if script is already running
|
---|
45 | lockfile=$lockpath/lock-$program.txt
|
---|
46 | checklock
|
---|
47 |
|
---|
48 | # get todo list
|
---|
49 | gettodo
|
---|
50 |
|
---|
51 | cd $mars
|
---|
52 |
|
---|
53 | printprocesslog "INFO writing sequence files for $num mc sequences"
|
---|
54 | # write sequence file for all sequences which don't have one yet
|
---|
55 | for (( s=0 ; s < $num ; s++ ))
|
---|
56 | do
|
---|
57 | sequence=${primaries[$s]}
|
---|
58 | printprocesslog "INFO write sequence files for sequence $sequence"
|
---|
59 | setstatus "start"
|
---|
60 |
|
---|
61 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
62 | no2=`printf %08d $sequence`
|
---|
63 | sequencepath=$mcsequpath/$no
|
---|
64 | makedir $sequencepath
|
---|
65 | sequencefile=$sequencepath/sequence$no2.txt
|
---|
66 |
|
---|
67 | # data runs
|
---|
68 | query="SELECT CONCAT(fRunNumber, '.', RIGHT(fFileNumber, 3)) FROM CeresInfo WHERE fRunTypeKEY=2 AND fSequenceNumber="$sequence" GROUP BY fRunNumber, fFileNumber "
|
---|
69 | datruns=`sendquery`
|
---|
70 | if [ "$datruns" = "" ]
|
---|
71 | then
|
---|
72 | printprocesslog "ERROR data runs for sequence "$sequence" are missing in the database "
|
---|
73 | check=2
|
---|
74 | fi
|
---|
75 | # pedestal runs
|
---|
76 | query="SELECT CONCAT(fRunNumber, '.', RIGHT(fFileNumber, 3)) FROM CeresInfo WHERE fRunTypeKEY=3 AND fSequenceNumber="$sequence" GROUP BY fRunNumber, fFileNumber "
|
---|
77 | pedruns=`sendquery`
|
---|
78 | if [ "$pedruns" = "" ]
|
---|
79 | then
|
---|
80 | printprocesslog "ERROR pedestal runs for sequence "$sequence" are missing in the database "
|
---|
81 | check=2
|
---|
82 | fi
|
---|
83 | # calibration runs
|
---|
84 | query="SELECT CONCAT(fRunNumber, '.', RIGHT(fFileNumber, 3)) FROM CeresInfo WHERE fRunTypeKEY=4 AND fSequenceNumber="$sequence" GROUP BY fRunNumber, fFileNumber "
|
---|
85 | calruns=`sendquery`
|
---|
86 | if [ "$calruns" = "" ]
|
---|
87 | then
|
---|
88 | printprocesslog "ERROR calibration runs for sequence "$sequence" are missing in the database "
|
---|
89 | check=2
|
---|
90 | fi
|
---|
91 |
|
---|
92 | printprocesslog "INFO writing sequencefile $sequencefile"
|
---|
93 | echo "Sequence: "$sequence >| $sequencefile
|
---|
94 | echo "" >> $sequencefile
|
---|
95 | echo "CalRuns: "$calruns >> $sequencefile
|
---|
96 | echo "PedRuns: "$pedruns >> $sequencefile
|
---|
97 | echo "DatRuns: "$datruns >> $sequencefile
|
---|
98 | echo "" >> $sequencefile
|
---|
99 | echo "MonteCarlo: Yes" >> $sequencefile
|
---|
100 | echo "" >> $sequencefile
|
---|
101 |
|
---|
102 | setstatus "stop"
|
---|
103 | done
|
---|
104 |
|
---|
105 | finish
|
---|
106 |
|
---|