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 | ! Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | //////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MReportTrigger
|
---|
29 | //
|
---|
30 | // This is the class interpreting and storing the TRIGGER-REPORT information.
|
---|
31 | // Updated to add IPR; data format follows TDAS 00-07
|
---|
32 | //
|
---|
33 | //////////////////////////////////////////////////////////////////////////////
|
---|
34 | #include "MReportTrigger.h"
|
---|
35 |
|
---|
36 | #include "MParList.h"
|
---|
37 |
|
---|
38 | #include "MLogManip.h"
|
---|
39 | #include "MTriggerIPR.h"
|
---|
40 | #include "MTriggerCell.h"
|
---|
41 | #include "MTriggerBit.h"
|
---|
42 | #include "MTriggerPrescFact.h"
|
---|
43 | #include "MTriggerLiveTime.h"
|
---|
44 |
|
---|
45 | ClassImp(MReportTrigger);
|
---|
46 |
|
---|
47 | using namespace std;
|
---|
48 |
|
---|
49 | // --------------------------------------------------------------------------
|
---|
50 | //
|
---|
51 | // Default construtor. Initialize identifier to "TRIGGER-REPORT"
|
---|
52 | //
|
---|
53 | MReportTrigger::MReportTrigger() : MReport("TRIGGER-REPORT")
|
---|
54 | {
|
---|
55 | fName = "MReportTrigger";
|
---|
56 | fTitle = "Class for TRIGGER-REPORT information";
|
---|
57 | }
|
---|
58 |
|
---|
59 | // --------------------------------------------------------------------------
|
---|
60 | //
|
---|
61 | // FindCreate the following objects:
|
---|
62 | // - MTriggerIPR
|
---|
63 | // - MTriggerCell
|
---|
64 | // - MTriggerBit
|
---|
65 | // - MTriggerPrescFact
|
---|
66 | //
|
---|
67 | Bool_t MReportTrigger::SetupReading(MParList &plist)
|
---|
68 | {
|
---|
69 | fPixel = (MTriggerIPR*)plist.FindCreateObj("MTriggerIPR");
|
---|
70 | if (!fPixel)
|
---|
71 | return kFALSE;
|
---|
72 |
|
---|
73 | fCell = (MTriggerCell*)plist.FindCreateObj("MTriggerCell");
|
---|
74 | if (!fCell)
|
---|
75 | return kFALSE;
|
---|
76 |
|
---|
77 | fBit = (MTriggerBit*)plist.FindCreateObj("MTriggerBit");
|
---|
78 | if (!fBit)
|
---|
79 | return kFALSE;
|
---|
80 |
|
---|
81 | fPrescFactor = (MTriggerPrescFact*)plist.FindCreateObj("MTriggerPrescFact");
|
---|
82 | if (!fPrescFactor)
|
---|
83 | return kFALSE;
|
---|
84 |
|
---|
85 | fLiveTime = (MTriggerLiveTime*)plist.FindCreateObj("MTriggerLiveTime");
|
---|
86 | if (!fLiveTime)
|
---|
87 | return kFALSE;
|
---|
88 |
|
---|
89 | return MReport::SetupReading(plist);
|
---|
90 | }
|
---|
91 |
|
---|
92 | // --------------------------------------------------------------------------
|
---|
93 | //
|
---|
94 | // Interprete the Cell rates part of the report
|
---|
95 | // Read 32 floats separated with a blank
|
---|
96 | //
|
---|
97 | Bool_t MReportTrigger::InterpreteCell(TString &str)
|
---|
98 | {
|
---|
99 | Int_t len=0, n, i=0;
|
---|
100 | Int_t gsNCells=32;
|
---|
101 |
|
---|
102 | for (i=0;i<gsNCells;i++)
|
---|
103 | {
|
---|
104 | n = sscanf(str.Data(), " %f %n", &fCell->fCellRate[i], &len);
|
---|
105 | if (n!=1)
|
---|
106 | {
|
---|
107 | *fLog << warn << "WARNING - Cell Scaler Value #" << i << " missing." << endl;
|
---|
108 | return kCONTINUE;
|
---|
109 | }
|
---|
110 | str.Remove(0, len); // Remove cell rates from report string
|
---|
111 | }
|
---|
112 |
|
---|
113 | str=str.Strip(TString::kLeading);
|
---|
114 |
|
---|
115 | *fLog << warn << "Cell ok!" <<endl;
|
---|
116 | return kTRUE;
|
---|
117 | }
|
---|
118 |
|
---|
119 | // --------------------------------------------------------------------------
|
---|
120 | //
|
---|
121 | // Interprete the Prescaling factors part of the report
|
---|
122 | //
|
---|
123 | Bool_t MReportTrigger::InterpretePrescFact(TString &str)
|
---|
124 | {
|
---|
125 | Int_t len=0, n, i=0;
|
---|
126 | Int_t gsNPrescFacts=8;
|
---|
127 |
|
---|
128 | str.Remove(0, 1);
|
---|
129 | *fLog << warn << str<<endl;
|
---|
130 |
|
---|
131 | for (i=0;i<gsNPrescFacts;i++)
|
---|
132 | {
|
---|
133 | const Int_t ws = str.First(' ');
|
---|
134 | if (ws<=0)
|
---|
135 | {
|
---|
136 | *fLog << warn << "WARNING - Cannot determine Prescaling factor #" << i << " descriptor" << endl;
|
---|
137 | return kCONTINUE;
|
---|
138 | }
|
---|
139 | TString descriptor = str(0, ws);
|
---|
140 | *fLog << descriptor <<endl;
|
---|
141 | str.Remove(0, ws);
|
---|
142 |
|
---|
143 | n = sscanf(str.Data(), " %li %n", &fPrescFactor->fPrescFact[i], &len);
|
---|
144 | if (n!=1)
|
---|
145 | {
|
---|
146 | *fLog << warn << "WARNING - prescaler factor " << i << " missing." << endl;
|
---|
147 | return kCONTINUE;
|
---|
148 | }
|
---|
149 | str.Remove(0, len); // Remove Prescal. factors from report string
|
---|
150 | *fLog << warn << fPrescFactor->fPrescFact[i]<<endl;
|
---|
151 | }
|
---|
152 | str=str.Strip(TString::kLeading);
|
---|
153 |
|
---|
154 | return kTRUE;
|
---|
155 | }
|
---|
156 |
|
---|
157 | // --------------------------------------------------------------------------
|
---|
158 | //
|
---|
159 | // Interprete the Scaler with Live-Deadtime part of the report
|
---|
160 | // Read 4x5 integers separated with a blank
|
---|
161 | //
|
---|
162 | Bool_t MReportTrigger::InterpreteLiveTime(TString &str)
|
---|
163 | {
|
---|
164 | Int_t len, n, i=0;
|
---|
165 | Int_t gsNScalers=5;
|
---|
166 | Int_t dLSB, dMSB,lLSB, lMSB;
|
---|
167 |
|
---|
168 | for (i=0;i<gsNScalers;i++)
|
---|
169 | {
|
---|
170 | n = sscanf(str.Data(), " %d %d %d %d %n", &lLSB, &lMSB,&dLSB, &dMSB, &len);
|
---|
171 | if (n!=4)
|
---|
172 | {
|
---|
173 | *fLog << warn << "WARNING - Live-Deadtime Scaler Value #" << i << " missing." << endl;
|
---|
174 | return kCONTINUE;
|
---|
175 | }
|
---|
176 |
|
---|
177 | str.Remove(0, len); // Remove Live-Deadtimes from string
|
---|
178 |
|
---|
179 | //convert to seconds and fill container
|
---|
180 | // (FIXME! only the MSB (seconds is now considered)
|
---|
181 | (fLiveTime->fLiveTime)[i] = lMSB;
|
---|
182 | (fLiveTime->fDeadTime)[i] = dMSB;
|
---|
183 | }
|
---|
184 |
|
---|
185 | str=str.Strip(TString::kLeading);
|
---|
186 |
|
---|
187 | return kTRUE;
|
---|
188 | }
|
---|
189 |
|
---|
190 | // --------------------------------------------------------------------------
|
---|
191 | //
|
---|
192 | // Interprete the Bit rates part of the report
|
---|
193 | // 20 integers. First and last two are not used
|
---|
194 | //
|
---|
195 | Bool_t MReportTrigger::InterpreteBit(TString &str)
|
---|
196 | {
|
---|
197 | Int_t len, n, i=0;
|
---|
198 | Int_t gsNBits=20;
|
---|
199 |
|
---|
200 | for (i=0;i<gsNBits;i++)
|
---|
201 | {
|
---|
202 | n = sscanf(str.Data(), " %f %n", &fBit->fBit[i], &len);
|
---|
203 | if (n!=1)
|
---|
204 | {
|
---|
205 | *fLog << warn << "WARNING - Bit rate #" << i << " missing." << endl;
|
---|
206 | return kCONTINUE;
|
---|
207 | }
|
---|
208 | str.Remove(0, len); // Remove output bit rates from string
|
---|
209 | }
|
---|
210 |
|
---|
211 | str=str.Strip(TString::kLeading);
|
---|
212 |
|
---|
213 | return kTRUE;
|
---|
214 | }
|
---|
215 |
|
---|
216 | // --------------------------------------------------------------------------
|
---|
217 | //
|
---|
218 | // Interprete the L1 and L2 table names
|
---|
219 | // 1String + 1Int +1 String
|
---|
220 | //
|
---|
221 | Bool_t MReportTrigger::InterpreteL1L2Table(TString &str)
|
---|
222 | {
|
---|
223 | const Int_t wsL1 = str.First(' ');
|
---|
224 |
|
---|
225 | if (wsL1<=0)
|
---|
226 | {
|
---|
227 | *fLog << warn << "WARNING - Cannot determine name of L1 trigger table." << endl;
|
---|
228 | return kCONTINUE;
|
---|
229 | }
|
---|
230 |
|
---|
231 | TString L1tablename = str(0, wsL1);
|
---|
232 | str.Remove(0, wsL1);
|
---|
233 |
|
---|
234 | // remove an integer between names
|
---|
235 | Int_t len;
|
---|
236 | Int_t mi;
|
---|
237 | Int_t n=sscanf(str.Data(), "%d %n", &mi, &len);
|
---|
238 | if (n!=1)
|
---|
239 | {
|
---|
240 | *fLog << warn << "WARNING - Not enough arguments." << endl;
|
---|
241 | return kCONTINUE;
|
---|
242 | }
|
---|
243 | str.Remove(0, len);
|
---|
244 |
|
---|
245 | // L2 tablename
|
---|
246 | const Int_t wsL2 = str.First(' ');
|
---|
247 |
|
---|
248 | if (wsL2<=0)
|
---|
249 | {
|
---|
250 | *fLog << warn << "WARNING - Cannot determine name of L2 trigger table." << endl;
|
---|
251 | return kCONTINUE;
|
---|
252 | }
|
---|
253 | TString L2tablename = str(0, wsL2);
|
---|
254 | str.Remove(0,wsL2);
|
---|
255 | str.Strip(TString::kBoth);
|
---|
256 |
|
---|
257 | return kTRUE;
|
---|
258 | }
|
---|
259 |
|
---|
260 | // --------------------------------------------------------------------------
|
---|
261 | //
|
---|
262 | // Interprete a part of the report without meaning by this time
|
---|
263 | // 18 integers
|
---|
264 | //
|
---|
265 | Bool_t MReportTrigger::InterpreteDummy(TString &str)
|
---|
266 | {
|
---|
267 | Int_t len, n, i=0;
|
---|
268 | Int_t gsNDummies=18;
|
---|
269 | Int_t dummy;
|
---|
270 |
|
---|
271 | for (i=0;i<gsNDummies;i++)
|
---|
272 | {
|
---|
273 | n = sscanf(str.Data(), " %d %n", &dummy, &len);
|
---|
274 | if (n!=1)
|
---|
275 | {
|
---|
276 | *fLog << warn << "WARNING - Dummy #" << i << " missing." << endl;
|
---|
277 | return kCONTINUE;
|
---|
278 | }
|
---|
279 | str.Remove(0, len); // Remove dummies from report string
|
---|
280 | }
|
---|
281 |
|
---|
282 | str=str.Strip(TString::kLeading);
|
---|
283 |
|
---|
284 | return kTRUE;
|
---|
285 | }
|
---|
286 |
|
---|
287 | // --------------------------------------------------------------------------
|
---|
288 | //
|
---|
289 | // Interprete the IPR part of the report
|
---|
290 | //
|
---|
291 | Bool_t MReportTrigger::InterpreteIPR(TString &str)
|
---|
292 | {
|
---|
293 |
|
---|
294 |
|
---|
295 | *fLog << warn << "IPR ok!" <<endl;
|
---|
296 | return kTRUE;
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | // --------------------------------------------------------------------------
|
---|
301 | //
|
---|
302 | // Interprete the body of the TRIGGER-REPORT string
|
---|
303 | // Read comments for details
|
---|
304 | //
|
---|
305 | Int_t MReportTrigger::InterpreteBody(TString &str)
|
---|
306 | {
|
---|
307 | str = str.Strip(TString::kLeading);
|
---|
308 |
|
---|
309 | // Extract trigger table name
|
---|
310 | const Int_t ws = str.First(' ');
|
---|
311 |
|
---|
312 | if (ws<=0)
|
---|
313 | {
|
---|
314 | *fLog << warn << "WARNING - Cannot determine name of trigger table." << endl;
|
---|
315 | return kCONTINUE;
|
---|
316 | }
|
---|
317 |
|
---|
318 | TString tablename = str(0, ws);
|
---|
319 | str.Remove(0, ws);
|
---|
320 |
|
---|
321 | // Read the cell rates (32 fields)
|
---|
322 | if (!InterpreteCell(str))
|
---|
323 | return kCONTINUE;
|
---|
324 |
|
---|
325 | // Read L1 and L2 table name (2 fields)
|
---|
326 | if (!InterpreteL1L2Table(str))
|
---|
327 | return kCONTINUE;
|
---|
328 |
|
---|
329 | // Read prescaling factors (2x8 fields)
|
---|
330 | if (!InterpretePrescFact(str))
|
---|
331 | return kCONTINUE;
|
---|
332 |
|
---|
333 | // Read livetime and deadtime (5x4 fields)
|
---|
334 | if (!InterpreteLiveTime(str))
|
---|
335 | return kCONTINUE;
|
---|
336 |
|
---|
337 | // Read L2 outout bit rates
|
---|
338 | if (!InterpreteBit(str))
|
---|
339 | return kCONTINUE;
|
---|
340 |
|
---|
341 | // Read global rates (before and after prescaling)
|
---|
342 | Int_t len, n;
|
---|
343 | n = sscanf(str.Data(), " %f %f %n", &fL2BeforePrescaler, &fL2AfterPrescaler, &len);
|
---|
344 | if (n!=2)
|
---|
345 | {
|
---|
346 | *fLog << warn << "WARNING - Couldn't read Trigger rates." << endl;
|
---|
347 | return kFALSE;
|
---|
348 | }
|
---|
349 | str.Remove(0,len);
|
---|
350 | str.Strip(TString::kBoth);
|
---|
351 |
|
---|
352 | // Read 18 dummy fields
|
---|
353 | if (!InterpreteDummy(str))
|
---|
354 | return kCONTINUE;
|
---|
355 |
|
---|
356 | // Read IPR
|
---|
357 | if (!InterpreteIPR(str))
|
---|
358 | return kCONTINUE;
|
---|
359 |
|
---|
360 | /*
|
---|
361 |
|
---|
362 | // Read Individual pixel rates
|
---|
363 | pos = str.Data();
|
---|
364 | end = str.Data() + 344;
|
---|
365 |
|
---|
366 | Int_t i=0;
|
---|
367 | while (pos < end)
|
---|
368 | {
|
---|
369 | const Char_t hex[4] = { pos[0], pos[1], pos[2], 0 };
|
---|
370 | n = sscanf(hex, "%hx", &fRates->fRates[i++]);
|
---|
371 | pos++;
|
---|
372 | if (n!=1)
|
---|
373 | {
|
---|
374 | *fLog << warn << "WARNING - Rate #" << i << " missing." << endl;
|
---|
375 | return kFALSE;
|
---|
376 | }
|
---|
377 | }
|
---|
378 |
|
---|
379 | */
|
---|
380 |
|
---|
381 | str.Remove(0,len);
|
---|
382 | str.Strip(TString::kBoth);
|
---|
383 |
|
---|
384 | return str==(TString)"OVER" ? kTRUE : kCONTINUE;
|
---|
385 | }
|
---|