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

Last change on this file since 7639 was 7639, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 6.1 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// 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
53ClassImp(MReport);
54
55using 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//
67Bool_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//
103Int_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// 200508290 | 53643.5 | | 200509300
125// 200510250 | 53801.5 | 53813.5 | 200603080
126// 200510250 | 53813.5 | | 200603190
127//
128Int_t MReport::Interprete(TString &str, const MTime &start, const MTime &stop, Int_t ver)
129{
130 // Interprete header (time, status, etc) of report
131 if (!InterpreteHeader(str))
132 return kFALSE;
133
134 // return -1: This is the special case: out of time limit
135 if (start && *fTime<start)
136 return -1;
137 if (stop && *fTime>stop)
138 return -1;
139
140 // Due to wrong assignment by arehucas the veriosn number for some
141 // cases is replaced.
142 if (ver==200504130 && GetMjd()>53548 && GetMjd()<53567)
143 ver=200506300;
144
145 if (ver==200503170 && GetMjd()>53446.5 && GetMjd()<53447.5)
146 ver=200502240;
147
148 if (ver==200508290 && GetMjd()>53643.5)
149 ver=200509300;
150
151 if (ver==200510250 && GetMjd()>53801.5 && GetMjd()<53813.5)
152 ver=200603080;
153
154 if (ver==200510250 && GetMjd()>53813.5)
155 ver=200603190;
156
157 // Interprete body (contents) of report
158 const Int_t rc = InterpreteBody(str, ver);
159 if (rc != kTRUE)
160 return rc;
161
162 SetReadyToSave();
163 fTime->SetReadyToSave();
164
165 return kTRUE;
166}
167
168// --------------------------------------------------------------------------
169//
170// Check for the existance of a corresponding MTime in the given parameter
171// list. If it is not found a new one will be created. The name of the
172// MTime object is created by taking the ClassName() of the derived MReport
173// class and stripping the leading MReport
174//
175Bool_t MReport::SetupReading(MParList &plist)
176{
177 fTime = NULL;
178
179 TString id(ClassName());
180 if (!id.BeginsWith("MReport"))
181 {
182 *fLog << warn << " WARNING - Class name '" << id << "' ";
183 *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
184 return kFALSE;
185 }
186
187 id.Remove(0, 7);
188 if (id.IsNull())
189 {
190 *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
191 return kFALSE;
192 }
193
194 id.Prepend("MTime");
195
196 fTime = (MTime*)plist.FindCreateObj("MTime", id);
197 if (!fTime)
198 return kFALSE;
199
200 return kTRUE;
201}
Note: See TracBrowser for help on using the repository browser.