source: trunk/MagicSoft/Mars/mreport/MReport.cc@ 7970

Last change on this file since 7970 was 7726, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.2 KB
Line 
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
51ClassImp(MReport);
52
53using 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//
65Bool_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 fState=state;
82 if (!fTime->Set(yea, mon, day, hor, min, sec, ms))
83 {
84 *fLog << err << "ERROR - Event has invalid time: ";
85 *fLog << Form("%d.%d.%d %02d:%02d:%02d.%03d", day, mon, yea, hor, min, sec, ms);
86 *fLog << "... abort." << endl;
87 return kFALSE;
88 }
89
90 str.Remove(0, len);
91
92 return kTRUE;
93}
94
95// --------------------------------------------------------------------------
96//
97// Report Body must be overwritten. It will get the line idetified to belong
98// to fIdentifier without the leading status and time infomration as an
99// argument.
100//
101Int_t MReport::InterpreteBody(TString &str, Int_t ver)
102{
103 *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
104 return kTRUE;
105}
106
107// --------------------------------------------------------------------------
108//
109// Interprets Header and Body of a report file line. Calls SetReadyToSave()
110// in case the interpretation was successfull. And fTime->SetReadyToSave()
111// when a corresponding time container exists.
112//
113// SetupReading must be called successfully before.
114//
115// Due to wrong assignment by arehucas the veriosn number for some
116// cases is replaced.
117//
118// Old Version | MjdMin | MjdMax | New Version
119// -------------+---------+---------+-------------
120// 200504130 | 53548.0 | 53567.0 | 200506300
121// 200503170 | 53446.5 | 53447.5 | 200502240
122// 200508290 | 53643.5 | | 200509300
123// 200510250 | 53801.5 | 53813.5 | 200603080
124// 200510250 | 53813.5 | | 200603190
125// 200604010 | 53863.5 | | 200605080
126//
127Int_t MReport::Interprete(TString &str, const MTime &start, const MTime &stop, Int_t ver)
128{
129 // Interprete header (time, status, etc) of report
130 if (!InterpreteHeader(str))
131 return kFALSE;
132
133 // return -1: This is the special case: out of time limit
134 if (start && *fTime<start)
135 return -1;
136 if (stop && *fTime>stop)
137 return -1;
138
139 // Due to wrong assignment by arehucas the veriosn number for some
140 // cases is replaced.
141 if (ver==200504130 && GetMjd()>53548 && GetMjd()<53567)
142 ver=200506300;
143
144 if (ver==200503170 && GetMjd()>53446.5 && GetMjd()<53447.5)
145 ver=200502240;
146
147 if (ver==200508290 && GetMjd()>53643.5)
148 ver=200509300;
149
150 if (ver==200510250 && GetMjd()>53801.5 && GetMjd()<53813.5)
151 ver=200603080;
152
153 if (ver==200510250 && GetMjd()>53813.5)
154 ver=200603190;
155
156 if (ver==200604010 && GetMjd()>53864.5)
157 ver=200605080;
158
159 // Interprete body (contents) of report
160 const Int_t rc = InterpreteBody(str, ver);
161 if (rc != kTRUE)
162 return rc;
163
164 SetReadyToSave();
165 fTime->SetReadyToSave();
166
167 return kTRUE;
168}
169
170// --------------------------------------------------------------------------
171//
172// Check for the existance of a corresponding MTime in the given parameter
173// list. If it is not found a new one will be created. The name of the
174// MTime object is created by taking the ClassName() of the derived MReport
175// class and stripping the leading MReport
176//
177Bool_t MReport::SetupReading(MParList &plist)
178{
179 fTime = NULL;
180
181 TString id(ClassName());
182 if (!id.BeginsWith("MReport"))
183 {
184 *fLog << warn << " WARNING - Class name '" << id << "' ";
185 *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
186 return kFALSE;
187 }
188
189 id.Remove(0, 7);
190 if (id.IsNull())
191 {
192 *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
193 return kFALSE;
194 }
195
196 id.Prepend("MTime");
197
198 fTime = (MTime*)plist.FindCreateObj("MTime", id);
199 if (!fTime)
200 return kFALSE;
201
202 return kTRUE;
203}
Note: See TracBrowser for help on using the repository browser.