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 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | ! Markus Gaug 3/2004 <mailto:markus@ifae.es>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MBadPixelsCam
|
---|
29 | //
|
---|
30 | //
|
---|
31 | // Storage container to store bad pixel of the camera...
|
---|
32 | //
|
---|
33 | /////////////////////////////////////////////////////////////////////////////
|
---|
34 | #include "MBadPixelsCam.h"
|
---|
35 |
|
---|
36 | #include <iostream>
|
---|
37 |
|
---|
38 | #include <TClonesArray.h>
|
---|
39 |
|
---|
40 | #include "MLog.h"
|
---|
41 | #include "MLogManip.h"
|
---|
42 |
|
---|
43 | #include "MBadPixelsPix.h"
|
---|
44 |
|
---|
45 | #include "MGeomCam.h"
|
---|
46 | #include "MGeomPix.h"
|
---|
47 |
|
---|
48 | ClassImp(MBadPixelsCam);
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | // --------------------------------------------------------------------------
|
---|
53 | //
|
---|
54 | // Default constructor.
|
---|
55 | //
|
---|
56 | MBadPixelsCam::MBadPixelsCam(const char *name, const char *title)
|
---|
57 | {
|
---|
58 | fName = name ? name : "MBadPixelsCam";
|
---|
59 | fTitle = title ? title : "Storage container to store bad pixel information";
|
---|
60 |
|
---|
61 | fArray = new TClonesArray("MBadPixelsPix", 1);
|
---|
62 | }
|
---|
63 |
|
---|
64 | MBadPixelsCam::MBadPixelsCam(const MBadPixelsCam &cam)
|
---|
65 | {
|
---|
66 | fName = "MBadPixelsCam";
|
---|
67 | fTitle = "Storage container to store bad pixel information";
|
---|
68 |
|
---|
69 | fArray = new TClonesArray("MBadPixelsPix", 1);
|
---|
70 | cam.Copy(*this);
|
---|
71 | }
|
---|
72 |
|
---|
73 | // --------------------------------------------------------------------------
|
---|
74 | //
|
---|
75 | // Delete the array conatining the bad pixel information
|
---|
76 | //
|
---|
77 | MBadPixelsCam::~MBadPixelsCam()
|
---|
78 | {
|
---|
79 | delete fArray;
|
---|
80 | }
|
---|
81 |
|
---|
82 | // --------------------------------------------------------------------------
|
---|
83 | //
|
---|
84 | // Set the size of the camera
|
---|
85 | //
|
---|
86 | void MBadPixelsCam::InitSize(const UInt_t i)
|
---|
87 | {
|
---|
88 | fArray->ExpandCreate(i);
|
---|
89 | }
|
---|
90 |
|
---|
91 | // --------------------------------------------------------------------------
|
---|
92 | //
|
---|
93 | // Get the size of the MBadPixelsCam
|
---|
94 | //
|
---|
95 | Int_t MBadPixelsCam::GetSize() const
|
---|
96 | {
|
---|
97 | return fArray->GetEntriesFast();
|
---|
98 | }
|
---|
99 |
|
---|
100 | // --------------------------------------------------------------------------
|
---|
101 | //
|
---|
102 | // Copy 'constructor'
|
---|
103 | //
|
---|
104 | void MBadPixelsCam::Copy(TObject &object) const
|
---|
105 | {
|
---|
106 | MBadPixelsCam &cam = (MBadPixelsCam&)object;
|
---|
107 |
|
---|
108 | const Int_t n = GetSize();
|
---|
109 |
|
---|
110 | if (n==0)
|
---|
111 | return;
|
---|
112 |
|
---|
113 | cam.InitSize(n);
|
---|
114 | for (int i=0; i<n; i++)
|
---|
115 | (*this)[i].Copy(cam[i]);
|
---|
116 | }
|
---|
117 |
|
---|
118 | // --------------------------------------------------------------------------
|
---|
119 | //
|
---|
120 | // Get i-th pixel (pixel number)
|
---|
121 | //
|
---|
122 | MBadPixelsPix &MBadPixelsCam::operator[](Int_t i)
|
---|
123 | {
|
---|
124 | return *static_cast<MBadPixelsPix*>(fArray->UncheckedAt(i));
|
---|
125 | }
|
---|
126 |
|
---|
127 | // --------------------------------------------------------------------------
|
---|
128 | //
|
---|
129 | // Get i-th pixel (pixel number)
|
---|
130 | //
|
---|
131 | const MBadPixelsPix &MBadPixelsCam::operator[](Int_t i) const
|
---|
132 | {
|
---|
133 | return *static_cast<MBadPixelsPix*>(fArray->UncheckedAt(i));
|
---|
134 | }
|
---|
135 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // Merge two MBadPixelsCam together, see also MBadPixelsPix::Merge
|
---|
139 | //
|
---|
140 | void MBadPixelsCam::Merge(const MBadPixelsCam &cam)
|
---|
141 | {
|
---|
142 | const Int_t n = cam.GetSize();
|
---|
143 | if (n==0)
|
---|
144 | {
|
---|
145 | *fLog << warn << "MBadPixelsCam::Merge: Container empty." << endl;
|
---|
146 | return;
|
---|
147 | }
|
---|
148 |
|
---|
149 | if (GetSize()==0)
|
---|
150 | InitSize(n);
|
---|
151 |
|
---|
152 | if (n!=GetSize())
|
---|
153 | {
|
---|
154 | *fLog << warn << "MBadPixelsCam::Merge: Size mismatch... ignored." << endl;
|
---|
155 | return;
|
---|
156 | }
|
---|
157 |
|
---|
158 | for (int i=0; i<n; i++)
|
---|
159 | (*this)[i].Merge(cam[i]);
|
---|
160 | }
|
---|
161 |
|
---|
162 | // --------------------------------------------------------------------------
|
---|
163 | //
|
---|
164 | // Clear the contents of all bad pixels (set=0 means Ok)
|
---|
165 | //
|
---|
166 | void MBadPixelsCam::Clear(Option_t *o)
|
---|
167 | {
|
---|
168 | fArray->ForEach(TObject, Clear)();
|
---|
169 | }
|
---|
170 |
|
---|
171 | // --------------------------------------------------------------------------
|
---|
172 | //
|
---|
173 | // Reset event depending bits
|
---|
174 | //
|
---|
175 | void MBadPixelsCam::Reset()
|
---|
176 | {
|
---|
177 | fArray->ForEach(MParContainer, Reset)();
|
---|
178 | }
|
---|
179 |
|
---|
180 | // --------------------------------------------------------------------------
|
---|
181 | //
|
---|
182 | // Calculate the number of pixels with the given type-flags.
|
---|
183 | //
|
---|
184 | // The second argument aidx is the area index (see MGeomCam, MGeomPix)
|
---|
185 | // The default (or any value less than 0) means: all
|
---|
186 | //
|
---|
187 | // Returns -1 if the geometry doesn't match.
|
---|
188 | //
|
---|
189 | Short_t MBadPixelsCam::GetNumUnsuitable(MBadPixelsPix::UnsuitableType_t type, const MGeomCam *geom, Int_t aidx) const
|
---|
190 | {
|
---|
191 | const UInt_t n = GetSize();
|
---|
192 |
|
---|
193 | if (aidx>=0 && geom->GetNumPixels()!=n)
|
---|
194 | {
|
---|
195 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom->ClassName() << ") size mismatch!" << endl;
|
---|
196 | return -1;
|
---|
197 | }
|
---|
198 |
|
---|
199 | Short_t rc = 0;
|
---|
200 | for (UInt_t i=0; i<n; i++)
|
---|
201 | {
|
---|
202 | if (aidx>=0 && (*geom)[i].GetAidx()!=aidx)
|
---|
203 | continue;
|
---|
204 |
|
---|
205 | if ((*this)[i].IsUnsuitable(type))
|
---|
206 | rc++;
|
---|
207 | }
|
---|
208 | return rc;
|
---|
209 | }
|
---|
210 |
|
---|
211 | // --------------------------------------------------------------------------
|
---|
212 | //
|
---|
213 | // Counts the number of neighbors matching NOT UnsuitableType type
|
---|
214 | //
|
---|
215 | Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeomPix &pix) const
|
---|
216 | {
|
---|
217 | const Int_t n2 = pix.GetNumNeighbors();
|
---|
218 |
|
---|
219 | Int_t cnt=0;
|
---|
220 | for (int j=0; j<n2; j++)
|
---|
221 | {
|
---|
222 | const Int_t id2 = pix.GetNeighbor(j);
|
---|
223 | if (!(*this)[id2].IsUnsuitable(type))
|
---|
224 | cnt++;
|
---|
225 | }
|
---|
226 |
|
---|
227 | return cnt;
|
---|
228 | }
|
---|
229 |
|
---|
230 | // --------------------------------------------------------------------------
|
---|
231 | //
|
---|
232 | // Calculate the number of pixels which are - under no circumstances -
|
---|
233 | // interpolatable, called isolated. This means that a pixel (its own status
|
---|
234 | // doesn't matter) has less than two reliable neighbor pixels.
|
---|
235 | //
|
---|
236 | // The second argument aidx is the area index (see MGeomCam, MGeomPix)
|
---|
237 | // The default (or any value less than 0) means: all
|
---|
238 | //
|
---|
239 | // Returns -1 if the geometry doesn't match.
|
---|
240 | //
|
---|
241 | Short_t MBadPixelsCam::GetNumIsolated(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx) const
|
---|
242 | {
|
---|
243 | const Int_t n = geom.GetNumPixels();
|
---|
244 |
|
---|
245 | if (n!=GetSize())
|
---|
246 | {
|
---|
247 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom.ClassName() << ") size mismatch!" << endl;
|
---|
248 | return -1;
|
---|
249 | }
|
---|
250 |
|
---|
251 | Short_t rc = 0;
|
---|
252 | for (int i=0; i<n; i++)
|
---|
253 | {
|
---|
254 | const MGeomPix &pix = geom[i];
|
---|
255 | if (aidx>=0 && pix.GetAidx()!=aidx)
|
---|
256 | continue;
|
---|
257 |
|
---|
258 | if (GetNumSuitableNeighbors(type, pix)<2)
|
---|
259 | rc++;
|
---|
260 | }
|
---|
261 | return rc;
|
---|
262 | }
|
---|
263 |
|
---|
264 | // --------------------------------------------------------------------------
|
---|
265 | //
|
---|
266 | // This is a helper function which calculates the size of a single cluster
|
---|
267 | // by iterative calling.
|
---|
268 | //
|
---|
269 | // If a pixel matches the criterias the counter is increased by 1 and
|
---|
270 | // the function is called for all its neighbors. If
|
---|
271 | //
|
---|
272 | // The second argument aidx is the area index (see MGeomCam, MGeomPix)
|
---|
273 | // The default (or any value less than 0) means: all
|
---|
274 | //
|
---|
275 | // Returns -1 if the geometry doesn't match.
|
---|
276 | //
|
---|
277 | Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const
|
---|
278 | {
|
---|
279 | const MGeomPix *pix = (MGeomPix*)list[idx];
|
---|
280 | if (!pix)
|
---|
281 | return 0;
|
---|
282 |
|
---|
283 | if (GetNumSuitableNeighbors(type, *pix)>1)
|
---|
284 | return 0;
|
---|
285 |
|
---|
286 | if (aidx>=0 && pix->GetAidx()!=aidx)
|
---|
287 | return 1;
|
---|
288 |
|
---|
289 | list.RemoveAt(idx);
|
---|
290 |
|
---|
291 | Short_t cnt = 1;
|
---|
292 | const Int_t n = pix->GetNumNeighbors();
|
---|
293 | for (int i=0; i<n; i++)
|
---|
294 | cnt += GetNumMaxCluster(type, list, pix->GetNeighbor(i), aidx);
|
---|
295 |
|
---|
296 | return cnt;
|
---|
297 | }
|
---|
298 |
|
---|
299 | // --------------------------------------------------------------------------
|
---|
300 | //
|
---|
301 | // Returns the size of the biggest cluster with the given USuitableType
|
---|
302 | // type and the given area index.
|
---|
303 | //
|
---|
304 | // The second argument aidx is the area index (see MGeomCam, MGeomPix)
|
---|
305 | // The default (or any value less than 0) means: all
|
---|
306 | //
|
---|
307 | // Returns -1 if the geometry doesn't match.
|
---|
308 | //
|
---|
309 | Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, const MGeomCam &geom, Int_t aidx) const
|
---|
310 | {
|
---|
311 | const Int_t n = geom.GetNumPixels();
|
---|
312 |
|
---|
313 | if (n!=GetSize())
|
---|
314 | {
|
---|
315 | *fLog << err << GetDescriptor() << "ERROR - Geometry (" << geom.ClassName() << ") size mismatch!" << endl;
|
---|
316 | return -1;
|
---|
317 | }
|
---|
318 |
|
---|
319 | TObjArray list(n);
|
---|
320 | for (int i=0; i<n; i++)
|
---|
321 | list.AddAt(&geom[i], i);
|
---|
322 |
|
---|
323 | Short_t max = 0;
|
---|
324 | for (int i=0; i<n; i++)
|
---|
325 | max = TMath::Max(GetNumMaxCluster(type, list, i, aidx), max);
|
---|
326 |
|
---|
327 | return max;
|
---|
328 | }
|
---|
329 |
|
---|
330 | // --------------------------------------------------------------------------
|
---|
331 | //
|
---|
332 | // Print the contents of all bad pixels
|
---|
333 | //
|
---|
334 | void MBadPixelsCam::Print(Option_t *o) const
|
---|
335 | {
|
---|
336 |
|
---|
337 | *fLog << all << GetDescriptor() << ":" << endl;
|
---|
338 | *fLog << "Pixels without problems:" << endl;
|
---|
339 |
|
---|
340 | Int_t count = 0;
|
---|
341 | Int_t full = 0;
|
---|
342 |
|
---|
343 | for (Int_t i=0; i<GetSize(); i++)
|
---|
344 | {
|
---|
345 | if (!(*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
346 | {
|
---|
347 | *fLog << i << " ";
|
---|
348 | full++;
|
---|
349 | count ++;
|
---|
350 | }
|
---|
351 |
|
---|
352 | if (count == 0)
|
---|
353 | continue;
|
---|
354 |
|
---|
355 | if (!(full % 25))
|
---|
356 | {
|
---|
357 | full = 0;
|
---|
358 | *fLog << endl;
|
---|
359 | }
|
---|
360 | }
|
---|
361 | *fLog << endl;
|
---|
362 | *fLog << count << " normal pixels" << endl;
|
---|
363 | *fLog << endl;
|
---|
364 |
|
---|
365 | *fLog << "Pixels unsuited for the whole run:" << endl;
|
---|
366 |
|
---|
367 | full = 0;
|
---|
368 | count = 0;
|
---|
369 | for (Int_t i=0; i<GetSize(); i++)
|
---|
370 | {
|
---|
371 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
372 | {
|
---|
373 | *fLog << i << " ";
|
---|
374 | full++;
|
---|
375 | count ++;
|
---|
376 | }
|
---|
377 |
|
---|
378 | if (count == 0)
|
---|
379 | continue;
|
---|
380 |
|
---|
381 | if (!(full % 25))
|
---|
382 | {
|
---|
383 | full = 0;
|
---|
384 | *fLog << endl;
|
---|
385 | }
|
---|
386 | }
|
---|
387 |
|
---|
388 | *fLog << endl;
|
---|
389 | *fLog << count << " unsuited pixels per run :-(" << endl;
|
---|
390 | *fLog << endl;
|
---|
391 |
|
---|
392 | *fLog << "Pixels unsuited for this event:" << endl;
|
---|
393 |
|
---|
394 | full = 0;
|
---|
395 | count = 0;
|
---|
396 | for (Int_t i=0; i<GetSize(); i++)
|
---|
397 | {
|
---|
398 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt))
|
---|
399 | {
|
---|
400 | *fLog << i << " ";
|
---|
401 | full++;
|
---|
402 | count ++;
|
---|
403 | }
|
---|
404 |
|
---|
405 | if (count == 0)
|
---|
406 | continue;
|
---|
407 |
|
---|
408 | if (!(full % 25))
|
---|
409 | {
|
---|
410 | full = 0;
|
---|
411 | *fLog << endl;
|
---|
412 | }
|
---|
413 | }
|
---|
414 |
|
---|
415 | *fLog << endl;
|
---|
416 | *fLog << count << " unsuited pixels per event :-(" << endl;
|
---|
417 | *fLog << endl;
|
---|
418 |
|
---|
419 | full = 0;
|
---|
420 | count = 0;
|
---|
421 |
|
---|
422 | *fLog << all << "Pixels unreliable for the whole run:" << endl;
|
---|
423 |
|
---|
424 | for (Int_t i=0; i<GetSize(); i++)
|
---|
425 | {
|
---|
426 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
|
---|
427 | {
|
---|
428 | *fLog << i << " ";
|
---|
429 | full++;
|
---|
430 | count ++;
|
---|
431 | }
|
---|
432 |
|
---|
433 | if (count == 0)
|
---|
434 | continue;
|
---|
435 |
|
---|
436 | if (!(full % 25))
|
---|
437 | {
|
---|
438 | full = 0;
|
---|
439 | *fLog << endl;
|
---|
440 | }
|
---|
441 | }
|
---|
442 |
|
---|
443 | *fLog << endl;
|
---|
444 | *fLog << count << " unreliable pixels :-(" << endl;
|
---|
445 | *fLog << endl;
|
---|
446 | *fLog << endl;
|
---|
447 | *fLog << all << "Unsuited pixels statistics:" << endl;
|
---|
448 | *fLog << endl;
|
---|
449 |
|
---|
450 | PrintBadPixels(MBadPixelsPix::kChargeIsPedestal,"Signal smaller 3 Pedestal RMS");
|
---|
451 | PrintBadPixels(MBadPixelsPix::kChargeSigmaNotValid,"Signal smaller 3 Pedestal RMS");
|
---|
452 | PrintBadPixels(MBadPixelsPix::kChargeRelErrNotValid,"Signal Rel. error too large");
|
---|
453 | PrintBadPixels(MBadPixelsPix::kLoGainSaturation,"Low Gain Saturation");
|
---|
454 | PrintBadPixels(MBadPixelsPix::kMeanTimeInFirstBin,"Mean Arr. Time In First Extraction Bin");
|
---|
455 | PrintBadPixels(MBadPixelsPix::kMeanTimeInLast2Bins,"Mean Arr. Time In Last 2 Extraction Bins");
|
---|
456 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhes,"Deviating Number of Photo-electrons");
|
---|
457 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhots,"Deviating Number of Photons");
|
---|
458 | PrintBadPixels(MBadPixelsPix::kHiGainOverFlow,"High-Gain Histogram Overflow");
|
---|
459 | PrintBadPixels(MBadPixelsPix::kLoGainOverFlow,"Low-Gain Histogram Overflow");
|
---|
460 |
|
---|
461 | *fLog << endl;
|
---|
462 | *fLog << all << "Unreliable pixels statistics:" << endl;
|
---|
463 | *fLog << endl;
|
---|
464 |
|
---|
465 | PrintBadPixels(MBadPixelsPix::kChargeSigmaNotValid,"Signal Sigma smaller Pedestal RMS");
|
---|
466 | PrintBadPixels(MBadPixelsPix::kHiGainNotFitted ,"High Gain Signals could not be fitted");
|
---|
467 | PrintBadPixels(MBadPixelsPix::kLoGainNotFitted ,"Low Gain Signals could not be fitted");
|
---|
468 | PrintBadPixels(MBadPixelsPix::kRelTimeNotFitted ,"Relative Arr. Times could not be fitted");
|
---|
469 | PrintBadPixels(MBadPixelsPix::kHiGainOscillating ,"High Gain Signals Oscillation");
|
---|
470 | PrintBadPixels(MBadPixelsPix::kLoGainOscillating ,"Low Gain Signals Oscillation");
|
---|
471 | PrintBadPixels(MBadPixelsPix::kRelTimeOscillating ,"Relative Arr. Times Oscillation");
|
---|
472 | PrintBadPixels(MBadPixelsPix::kDeviatingFFactor ,"Deviating global F-Factor");
|
---|
473 | }
|
---|
474 |
|
---|
475 | void MBadPixelsCam::PrintBadPixels( MBadPixelsPix::UncalibratedType_t typ, const char *text) const
|
---|
476 | {
|
---|
477 |
|
---|
478 |
|
---|
479 | *fLog << "Pixels with " << text << ": " << endl;
|
---|
480 | UInt_t count = 0;
|
---|
481 | UInt_t full = 0;
|
---|
482 |
|
---|
483 | for (Int_t i=0; i<GetSize(); i++)
|
---|
484 | {
|
---|
485 | if ((*this)[i].IsUncalibrated(typ))
|
---|
486 | {
|
---|
487 | *fLog << i << " ";
|
---|
488 | full++;
|
---|
489 | count++;
|
---|
490 | }
|
---|
491 |
|
---|
492 | if (count == 0)
|
---|
493 | continue;
|
---|
494 |
|
---|
495 | if (!(full % 25))
|
---|
496 | {
|
---|
497 | full = 0;
|
---|
498 | *fLog << endl;
|
---|
499 | }
|
---|
500 | }
|
---|
501 |
|
---|
502 | *fLog << endl;
|
---|
503 | *fLog << Form("%3i",count) << " pixels in total " << endl;
|
---|
504 | }
|
---|
505 |
|
---|
506 | // --------------------------------------------------------------------------
|
---|
507 | //
|
---|
508 | // Read from an ascii file of the format:
|
---|
509 | // pixel1 pixel2 pixel3 pixel4
|
---|
510 | // while pixel1,2,3,4 are the pixel indices used in the software.
|
---|
511 | //
|
---|
512 | // To read the pixels corresponding to a given run you can give run!=0
|
---|
513 | // and a file of the format:
|
---|
514 | // 1234: 17 193 292
|
---|
515 | // 1235: 17 193 292 293
|
---|
516 | //
|
---|
517 | void MBadPixelsCam::AsciiRead(istream &fin, UInt_t run=0)
|
---|
518 | {
|
---|
519 |
|
---|
520 | Int_t len;
|
---|
521 | TString str;
|
---|
522 |
|
---|
523 | while (1)
|
---|
524 | {
|
---|
525 | str.ReadLine(fin);
|
---|
526 |
|
---|
527 | if (str.IsNull())
|
---|
528 | {
|
---|
529 | *fLog << warn << GetDescriptor()
|
---|
530 | << ": Cannot apply AsciiRead from istream pointer. "
|
---|
531 | << "Either file does not exist or file is empty! " << endl;
|
---|
532 | return;
|
---|
533 | }
|
---|
534 |
|
---|
535 | Int_t r;
|
---|
536 |
|
---|
537 | const Int_t n = sscanf(str.Data(), " %d : %n", &r, &len);
|
---|
538 | if (n!=1)
|
---|
539 | return;
|
---|
540 |
|
---|
541 | if (run==0 || run && (UInt_t)r==run)
|
---|
542 | break;
|
---|
543 | }
|
---|
544 |
|
---|
545 | str.Remove(0, len);
|
---|
546 |
|
---|
547 | while (1)
|
---|
548 | {
|
---|
549 | Int_t idx;
|
---|
550 | const Int_t n = sscanf(str.Data(), " %d %n", &idx, &len);
|
---|
551 |
|
---|
552 | if (n!=1)
|
---|
553 | break;
|
---|
554 |
|
---|
555 | str.Remove(0, len);
|
---|
556 |
|
---|
557 | if (idx>=GetSize())
|
---|
558 | InitSize(idx+1);
|
---|
559 |
|
---|
560 | (*this)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
561 | }
|
---|
562 | }
|
---|
563 |
|
---|
564 | // --------------------------------------------------------------------------
|
---|
565 | //
|
---|
566 | // Write the information into an ascii file. If a run-number is given the
|
---|
567 | // run-number will lead the line.
|
---|
568 | //
|
---|
569 | Bool_t MBadPixelsCam::AsciiWrite(ostream &fout, UInt_t run=0) const
|
---|
570 | {
|
---|
571 | if (run)
|
---|
572 | fout << run << ":";
|
---|
573 |
|
---|
574 | for (int i=0; i<GetSize(); i++)
|
---|
575 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
576 | fout << " " << i;
|
---|
577 |
|
---|
578 | if (run && GetSize())
|
---|
579 | fout << endl;
|
---|
580 |
|
---|
581 | return kTRUE;
|
---|
582 | }
|
---|
583 |
|
---|
584 | // --------------------------------------------------------------------------
|
---|
585 | //
|
---|
586 | // The types are the following:
|
---|
587 | // 0: MBadPixelsPix::GetInfo()[0]
|
---|
588 | // 1: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
|
---|
589 | // 2: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableEvt)
|
---|
590 | // 3: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
|
---|
591 | // 4: MBadPixelsPix::IsHiGainBad()
|
---|
592 | // 5: MBadPixelsPix::IsLoGainBad()
|
---|
593 | // 6: MBadPixelsPix::GetUnsuitableCalLevel()
|
---|
594 | // 7: MBadPixelsPix::GetUnreliableCalLevel()
|
---|
595 | // 8: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainNotFitted)
|
---|
596 | // 9: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainNotFitted)
|
---|
597 | // 10: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
|
---|
598 | // 11: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
|
---|
599 | // 12: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainSaturation )
|
---|
600 | // 13: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeIsPedestal )
|
---|
601 | // 14: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeErrNotValid)
|
---|
602 | // 15: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid)
|
---|
603 | // 16: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid )
|
---|
604 | // 17: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin )
|
---|
605 | // 18: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins )
|
---|
606 | // 19: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes )
|
---|
607 | // 20: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted )
|
---|
608 | // 21: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeOscillating )
|
---|
609 | // 22: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots )
|
---|
610 | // 23: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOverFlow )
|
---|
611 | // 24: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOverFlow )
|
---|
612 | //
|
---|
613 | Bool_t MBadPixelsCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
614 | {
|
---|
615 |
|
---|
616 | if (idx >= GetSize())
|
---|
617 | return kFALSE;
|
---|
618 |
|
---|
619 | switch (type)
|
---|
620 | {
|
---|
621 | case 0:
|
---|
622 | return (*this)[idx].GetInfo()[0];
|
---|
623 | case 1:
|
---|
624 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
625 | return kFALSE;
|
---|
626 | val = 1;
|
---|
627 | break;
|
---|
628 | case 2:
|
---|
629 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt))
|
---|
630 | return kFALSE;
|
---|
631 | val = 1;
|
---|
632 | break;
|
---|
633 | case 3:
|
---|
634 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
|
---|
635 | return kFALSE;
|
---|
636 | val = 1;
|
---|
637 | break;
|
---|
638 | case 4:
|
---|
639 | if (!(*this)[idx].IsHiGainBad())
|
---|
640 | return kFALSE;
|
---|
641 | val = 1;
|
---|
642 | break;
|
---|
643 | case 5:
|
---|
644 | if (!(*this)[idx].IsLoGainBad())
|
---|
645 | return kFALSE;
|
---|
646 | val = 1;
|
---|
647 | break;
|
---|
648 | case 6:
|
---|
649 | if ((*this)[idx].GetUnsuitableCalLevel())
|
---|
650 | val = (*this)[idx].GetUnsuitableCalLevel();
|
---|
651 | else
|
---|
652 | return kFALSE;
|
---|
653 | break;
|
---|
654 | case 7:
|
---|
655 | if ((*this)[idx].GetUnreliableCalLevel())
|
---|
656 | val = (*this)[idx].GetUnreliableCalLevel();
|
---|
657 | else
|
---|
658 | return kFALSE;
|
---|
659 | break;
|
---|
660 | case 8:
|
---|
661 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
|
---|
662 | return kFALSE;
|
---|
663 | val = 1;
|
---|
664 | break;
|
---|
665 | case 9:
|
---|
666 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
|
---|
667 | return kFALSE;
|
---|
668 | val = 1;
|
---|
669 | break;
|
---|
670 | case 10:
|
---|
671 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
|
---|
672 | return kFALSE;
|
---|
673 | val = 1;
|
---|
674 | break;
|
---|
675 | case 11:
|
---|
676 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
|
---|
677 | return kFALSE;
|
---|
678 | val = 1;
|
---|
679 | break;
|
---|
680 | case 12:
|
---|
681 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainSaturation ))
|
---|
682 | return kFALSE;
|
---|
683 | val = 1;
|
---|
684 | break;
|
---|
685 | case 13:
|
---|
686 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal ))
|
---|
687 | return kFALSE;
|
---|
688 | val = 1;
|
---|
689 | break;
|
---|
690 | case 14:
|
---|
691 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeErrNotValid))
|
---|
692 | return kFALSE;
|
---|
693 | val = 1;
|
---|
694 | break;
|
---|
695 | case 15:
|
---|
696 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid))
|
---|
697 | return kFALSE;
|
---|
698 | val = 1;
|
---|
699 | break;
|
---|
700 | case 16:
|
---|
701 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid ))
|
---|
702 | return kFALSE;
|
---|
703 | val = 1;
|
---|
704 | break;
|
---|
705 | case 17:
|
---|
706 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin ))
|
---|
707 | return kFALSE;
|
---|
708 | val = 1;
|
---|
709 | break;
|
---|
710 | case 18:
|
---|
711 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins ))
|
---|
712 | return kFALSE;
|
---|
713 | val = 1;
|
---|
714 | break;
|
---|
715 | case 19:
|
---|
716 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes ))
|
---|
717 | return kFALSE;
|
---|
718 | val = 1;
|
---|
719 | break;
|
---|
720 | case 20:
|
---|
721 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted ))
|
---|
722 | return kFALSE;
|
---|
723 | val = 1;
|
---|
724 | break;
|
---|
725 | case 21:
|
---|
726 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
|
---|
727 | return kFALSE;
|
---|
728 | val = 1;
|
---|
729 | break;
|
---|
730 | case 22:
|
---|
731 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots))
|
---|
732 | return kFALSE;
|
---|
733 | val = 1;
|
---|
734 | break;
|
---|
735 | case 23:
|
---|
736 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOverFlow ))
|
---|
737 | return kFALSE;
|
---|
738 | val = 1;
|
---|
739 | break;
|
---|
740 | case 24:
|
---|
741 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOverFlow ))
|
---|
742 | return kFALSE;
|
---|
743 | val = 1;
|
---|
744 | break;
|
---|
745 | default:
|
---|
746 | return kFALSE;
|
---|
747 | }
|
---|
748 |
|
---|
749 | return kTRUE;
|
---|
750 | }
|
---|
751 |
|
---|
752 | void MBadPixelsCam::DrawPixelContent(Int_t num) const
|
---|
753 | {
|
---|
754 | *fLog << warn << "MBadPixelsCam::DrawPixelContent - not available." << endl;
|
---|
755 | }
|
---|