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 | // 200504130 | 53548.0 | 53567.0 | 200506300
|
---|
39 | // 200503170 | 53446.5 | 53447.5 | 200502240
|
---|
40 | //
|
---|
41 | //
|
---|
42 | // Be carefull: The class name of all classes derived from this class
|
---|
43 | // should start with 'MReport', see SetupReading
|
---|
44 | //
|
---|
45 | //////////////////////////////////////////////////////////////////////////////
|
---|
46 | #include "MReport.h"
|
---|
47 |
|
---|
48 | #include "MLogManip.h"
|
---|
49 |
|
---|
50 | #include "MTime.h"
|
---|
51 | #include "MParList.h"
|
---|
52 |
|
---|
53 | ClassImp(MReport);
|
---|
54 |
|
---|
55 | using namespace std;
|
---|
56 |
|
---|
57 | // --------------------------------------------------------------------------
|
---|
58 | //
|
---|
59 | // Interpretes the beginning of a line which starts like:
|
---|
60 | // status hour minute second millisec skip skip skip skip skip
|
---|
61 | // The identifier is assumed to be removed.
|
---|
62 | //
|
---|
63 | // While skip are numbers which won't enter the analysis
|
---|
64 | //
|
---|
65 | // SetupReading must be called successfully before.
|
---|
66 | //
|
---|
67 | Bool_t MReport::InterpreteHeader(TString &str)
|
---|
68 | {
|
---|
69 | int len, state;
|
---|
70 | int yea, mon, day, hor, min, sec, ms;
|
---|
71 |
|
---|
72 | int n = sscanf(str.Data(),
|
---|
73 | fHasReportTime ?
|
---|
74 | " %d %d %d %d %d %d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %n" :
|
---|
75 | " %d %d %d %d %d %d %d %d %n",
|
---|
76 | &state, &yea, &mon, &day, &hor, &min, &sec, &ms, &len);
|
---|
77 | if (n!=8)
|
---|
78 | {
|
---|
79 | *fLog << err << "ERROR - Cannot interprete Body of " << fIdentifier << " (n=" << n << ")" << endl;
|
---|
80 | return kFALSE;
|
---|
81 | }
|
---|
82 |
|
---|
83 | fState=state;
|
---|
84 | if (!fTime->Set(yea, mon, day, hor, min, sec, ms))
|
---|
85 | {
|
---|
86 | *fLog << err << "ERROR - Event has invalid time: ";
|
---|
87 | *fLog << Form("%d.%d.%d %02d:%02d:%02d.%03d", day, mon, yea, hor, min, sec, ms);
|
---|
88 | *fLog << "... abort." << endl;
|
---|
89 | return kFALSE;
|
---|
90 | }
|
---|
91 |
|
---|
92 | str.Remove(0, len);
|
---|
93 |
|
---|
94 | return kTRUE;
|
---|
95 | }
|
---|
96 |
|
---|
97 | // --------------------------------------------------------------------------
|
---|
98 | //
|
---|
99 | // Report Body must be overwritten. It will get the line idetified to belong
|
---|
100 | // to fIdentifier without the leading status and time infomration as an
|
---|
101 | // argument.
|
---|
102 | //
|
---|
103 | Int_t MReport::InterpreteBody(TString &str, Int_t ver)
|
---|
104 | {
|
---|
105 | *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
|
---|
106 | return kTRUE;
|
---|
107 | }
|
---|
108 |
|
---|
109 | // --------------------------------------------------------------------------
|
---|
110 | //
|
---|
111 | // Interprets Header and Body of a report file line. Calls SetReadyToSave()
|
---|
112 | // in case the interpretation was successfull. And fTime->SetReadyToSave()
|
---|
113 | // when a corresponding time container exists.
|
---|
114 | //
|
---|
115 | // SetupReading must be called successfully before.
|
---|
116 | //
|
---|
117 | // Due to wrong assignment by arehucas the veriosn number for some
|
---|
118 | // cases is replaced.
|
---|
119 | //
|
---|
120 | // Old Version | MjdMin | MjdMax | New Version
|
---|
121 | // -------------+---------+---------+-------------
|
---|
122 | // 200504130 | 53548.0 | 53567.0 | 200506300
|
---|
123 | // 200503170 | 53446.5 | 53447.5 | 200502240
|
---|
124 | //
|
---|
125 | Int_t MReport::Interprete(TString &str, const MTime &start, const MTime &stop, Int_t ver)
|
---|
126 | {
|
---|
127 | // Interprete header (time, status, etc) of report
|
---|
128 | if (!InterpreteHeader(str))
|
---|
129 | return kFALSE;
|
---|
130 |
|
---|
131 | // return -1: This is the special case: out of time limit
|
---|
132 | if (start && *fTime<start)
|
---|
133 | return -1;
|
---|
134 | if (stop && *fTime>stop)
|
---|
135 | return -1;
|
---|
136 |
|
---|
137 | // Due to wrong assignment by arehucas the veriosn number for some
|
---|
138 | // cases is replaced.
|
---|
139 | if (ver==200504130 && GetMjd()>53548 && GetMjd()<53567)
|
---|
140 | ver=200506300;
|
---|
141 |
|
---|
142 | if (ver==200503170 && GetMjd()>53446.5 && GetMjd()<53447.5)
|
---|
143 | ver=200502240;
|
---|
144 |
|
---|
145 | // Interprete body (contents) of report
|
---|
146 | const Int_t rc = InterpreteBody(str, ver);
|
---|
147 | if (rc != kTRUE)
|
---|
148 | return rc;
|
---|
149 |
|
---|
150 | SetReadyToSave();
|
---|
151 | fTime->SetReadyToSave();
|
---|
152 |
|
---|
153 | return kTRUE;
|
---|
154 | }
|
---|
155 |
|
---|
156 | // --------------------------------------------------------------------------
|
---|
157 | //
|
---|
158 | // Check for the existance of a corresponding MTime in the given parameter
|
---|
159 | // list. If it is not found a new one will be created. The name of the
|
---|
160 | // MTime object is created by taking the ClassName() of the derived MReport
|
---|
161 | // class and stripping the leading MReport
|
---|
162 | //
|
---|
163 | Bool_t MReport::SetupReading(MParList &plist)
|
---|
164 | {
|
---|
165 | fTime = NULL;
|
---|
166 |
|
---|
167 | TString id(ClassName());
|
---|
168 | if (!id.BeginsWith("MReport"))
|
---|
169 | {
|
---|
170 | *fLog << warn << " WARNING - Class name '" << id << "' ";
|
---|
171 | *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
|
---|
172 | return kFALSE;
|
---|
173 | }
|
---|
174 |
|
---|
175 | id.Remove(0, 7);
|
---|
176 | if (id.IsNull())
|
---|
177 | {
|
---|
178 | *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
|
---|
179 | return kFALSE;
|
---|
180 | }
|
---|
181 |
|
---|
182 | id.Prepend("MTime");
|
---|
183 |
|
---|
184 | fTime = (MTime*)plist.FindCreateObj("MTime", id);
|
---|
185 | if (!fTime)
|
---|
186 | return kFALSE;
|
---|
187 |
|
---|
188 | return kTRUE;
|
---|
189 | }
|
---|