1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MReport
|
---|
28 | //
|
---|
29 | // This is a base class for all reports comming from subsystems stored in
|
---|
30 | // a report file.
|
---|
31 | //
|
---|
32 | //
|
---|
33 | // Due to wrong assignment by arehucas the veriosn number for some
|
---|
34 | // cases is replaced.
|
---|
35 | //
|
---|
36 | // Old Version | MjdMin | MjdMax | New Version
|
---|
37 | // -------------+---------+---------+-------------
|
---|
38 | // see MReport::Interprete()
|
---|
39 | //
|
---|
40 | // Be carefull: The class name of all classes derived from this class
|
---|
41 | // should start with 'MReport', see SetupReading
|
---|
42 | //
|
---|
43 | //////////////////////////////////////////////////////////////////////////////
|
---|
44 | #include "MReport.h"
|
---|
45 |
|
---|
46 | #include "MLogManip.h"
|
---|
47 |
|
---|
48 | #include "MTime.h"
|
---|
49 | #include "MParList.h"
|
---|
50 |
|
---|
51 | ClassImp(MReport);
|
---|
52 |
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Interpretes the beginning of a line which starts like:
|
---|
58 | // status hour minute second millisec skip skip skip skip skip
|
---|
59 | // The identifier is assumed to be removed.
|
---|
60 | //
|
---|
61 | // While skip are numbers which won't enter the analysis
|
---|
62 | //
|
---|
63 | // SetupReading must be called successfully before.
|
---|
64 | //
|
---|
65 | Bool_t MReport::InterpreteHeader(TString &str)
|
---|
66 | {
|
---|
67 | int len, state;
|
---|
68 | int yea, mon, day, hor, min, sec, ms;
|
---|
69 |
|
---|
70 | int n = sscanf(str.Data(),
|
---|
71 | fHasReportTime ?
|
---|
72 | " %d %d %d %d %d %d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %n" :
|
---|
73 | " %d %d %d %d %d %d %d %d %n",
|
---|
74 | &state, &yea, &mon, &day, &hor, &min, &sec, &ms, &len);
|
---|
75 | if (n!=8)
|
---|
76 | {
|
---|
77 | *fLog << err << "ERROR - Cannot interprete Body of " << fIdentifier << " (n=" << n << ")" << endl;
|
---|
78 | return kFALSE;
|
---|
79 | }
|
---|
80 |
|
---|
81 | if (ms==1000)
|
---|
82 | {
|
---|
83 | *fLog << warn << "WARNING - Milliseconds in timestamp of " << fIdentifier;
|
---|
84 | *fLog << Form(" %d.%d.%d %02d:%02d:%02d.%03d", day, mon, yea, hor, min, sec, ms);
|
---|
85 | *fLog << " reset to 999." << endl;
|
---|
86 | ms = 999;
|
---|
87 | }
|
---|
88 |
|
---|
89 | fState=state;
|
---|
90 | if (!fTime->Set(yea, mon, day, hor, min, sec, ms))
|
---|
91 | {
|
---|
92 | *fLog << err << "ERROR - Event " << fIdentifier << " has invalid time ";
|
---|
93 | *fLog << Form("%d.%d.%d %02d:%02d:%02d.%03d", day, mon, yea, hor, min, sec, ms);
|
---|
94 | *fLog << "... abort." << endl;
|
---|
95 | return kFALSE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | str.Remove(0, len);
|
---|
99 |
|
---|
100 | return kTRUE;
|
---|
101 | }
|
---|
102 |
|
---|
103 | // --------------------------------------------------------------------------
|
---|
104 | //
|
---|
105 | // Report Body must be overwritten. It will get the line idetified to belong
|
---|
106 | // to fIdentifier without the leading status and time infomration as an
|
---|
107 | // argument.
|
---|
108 | //
|
---|
109 | Int_t MReport::InterpreteBody(TString &str, Int_t ver)
|
---|
110 | {
|
---|
111 | *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
|
---|
112 | return kTRUE;
|
---|
113 | }
|
---|
114 |
|
---|
115 | // --------------------------------------------------------------------------
|
---|
116 | //
|
---|
117 | // Interprets Header and Body of a report file line. Calls SetReadyToSave()
|
---|
118 | // in case the interpretation was successfull. And fTime->SetReadyToSave()
|
---|
119 | // when a corresponding time container exists.
|
---|
120 | //
|
---|
121 | // SetupReading must be called successfully before.
|
---|
122 | //
|
---|
123 | // Due to wrong assignment by arehucas the veriosn number for some
|
---|
124 | // cases is replaced.
|
---|
125 | //
|
---|
126 | // Old Version | MjdMin | MjdMax | New Version
|
---|
127 | // -------------+---------+---------+-------------
|
---|
128 | // 200504130 | 53548.0 | 53567.0 | 200506300
|
---|
129 | // 200503170 | 53446.5 | 53447.5 | 200502240
|
---|
130 | // 200508290 | 53643.5 | | 200509300
|
---|
131 | // 200510250 | 53801.5 | 53813.5 | 200603080
|
---|
132 | // 200510250 | 53813.5 | | 200603190
|
---|
133 | // 200604010 | 53863.5 | | 200605080
|
---|
134 | //
|
---|
135 | Int_t MReport::Interprete(TString &str, const MTime &start, const MTime &stop, Int_t ver)
|
---|
136 | {
|
---|
137 | // Interprete header (time, status, etc) of report
|
---|
138 | if (!InterpreteHeader(str))
|
---|
139 | return kFALSE;
|
---|
140 |
|
---|
141 | // return -1: This is the special case: out of time limit
|
---|
142 | if (start && *fTime<start)
|
---|
143 | return -1;
|
---|
144 | if (stop && *fTime>stop)
|
---|
145 | return -1;
|
---|
146 |
|
---|
147 | // Due to wrong assignment by arehucas the veriosn number for some
|
---|
148 | // cases is replaced.
|
---|
149 | if (ver==200504130 && GetMjd()>53548 && GetMjd()<53567)
|
---|
150 | ver=200506300;
|
---|
151 |
|
---|
152 | if (ver==200503170 && GetMjd()>53446.5 && GetMjd()<53447.5)
|
---|
153 | ver=200502240;
|
---|
154 |
|
---|
155 | if (ver==200508290 && GetMjd()>53643.5)
|
---|
156 | ver=200509300;
|
---|
157 |
|
---|
158 | if (ver==200510250 && GetMjd()>53801.5 && GetMjd()<53813.5)
|
---|
159 | ver=200603080;
|
---|
160 |
|
---|
161 | if (ver==200510250 && GetMjd()>53813.5)
|
---|
162 | ver=200603190;
|
---|
163 |
|
---|
164 | if (ver==200604010 && GetMjd()>53864.5)
|
---|
165 | ver=200605080;
|
---|
166 |
|
---|
167 | // Interprete body (contents) of report
|
---|
168 | const Int_t rc = InterpreteBody(str, ver);
|
---|
169 | if (rc != kTRUE)
|
---|
170 | return rc;
|
---|
171 |
|
---|
172 | SetReadyToSave();
|
---|
173 | fTime->SetReadyToSave();
|
---|
174 |
|
---|
175 | return kTRUE;
|
---|
176 | }
|
---|
177 |
|
---|
178 | // --------------------------------------------------------------------------
|
---|
179 | //
|
---|
180 | // Check for the existance of a corresponding MTime in the given parameter
|
---|
181 | // list. If it is not found a new one will be created. The name of the
|
---|
182 | // MTime object is created by taking the ClassName() of the derived MReport
|
---|
183 | // class and stripping the leading MReport
|
---|
184 | //
|
---|
185 | Bool_t MReport::SetupReading(MParList &plist)
|
---|
186 | {
|
---|
187 | fTime = NULL;
|
---|
188 |
|
---|
189 | TString id(ClassName());
|
---|
190 | if (!id.BeginsWith("MReport"))
|
---|
191 | {
|
---|
192 | *fLog << warn << " WARNING - Class name '" << id << "' ";
|
---|
193 | *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
|
---|
194 | return kFALSE;
|
---|
195 | }
|
---|
196 |
|
---|
197 | id.Remove(0, 7);
|
---|
198 | if (id.IsNull())
|
---|
199 | {
|
---|
200 | *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
|
---|
201 | return kFALSE;
|
---|
202 | }
|
---|
203 |
|
---|
204 | id.Prepend("MTime");
|
---|
205 |
|
---|
206 | fTime = (MTime*)plist.FindCreateObj("MTime", id);
|
---|
207 | if (!fTime)
|
---|
208 | return kFALSE;
|
---|
209 |
|
---|
210 | return kTRUE;
|
---|
211 | }
|
---|