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 UnsuitableType
|
---|
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::kPreviouslyExcluded,"Previously excluded");
|
---|
451 | PrintBadPixels(MBadPixelsPix::kChargeIsPedestal,"Signal smaller 3 Pedestal RMS");
|
---|
452 | PrintBadPixels(MBadPixelsPix::kChargeSigmaNotValid,"Signal smaller 3 Pedestal RMS");
|
---|
453 | PrintBadPixels(MBadPixelsPix::kChargeRelErrNotValid,"Signal Rel. error too large");
|
---|
454 | PrintBadPixels(MBadPixelsPix::kLoGainSaturation,"Low Gain Saturation");
|
---|
455 | PrintBadPixels(MBadPixelsPix::kMeanTimeInFirstBin,"Mean Arr. Time In First Extraction Bin");
|
---|
456 | PrintBadPixels(MBadPixelsPix::kMeanTimeInLast2Bins,"Mean Arr. Time In Last 2 Extraction Bins");
|
---|
457 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhes,"Deviating Number of Photo-electrons");
|
---|
458 | PrintBadPixels(MBadPixelsPix::kDeviatingNumPhots,"Deviating Number of Photons");
|
---|
459 | PrintBadPixels(MBadPixelsPix::kHiGainOverFlow,"High-Gain Histogram Overflow");
|
---|
460 | PrintBadPixels(MBadPixelsPix::kLoGainOverFlow,"Low-Gain Histogram Overflow");
|
---|
461 | PrintBadPixels(MBadPixelsPix::kDeadPedestalRms,"Presumably dead from Ped. Rms");
|
---|
462 | PrintBadPixels(MBadPixelsPix::kFluctuatingArrivalTimes,"Fluctuating Pulse Arrival Times");
|
---|
463 |
|
---|
464 | *fLog << endl;
|
---|
465 | *fLog << all << "Unreliable pixels statistics:" << endl;
|
---|
466 | *fLog << endl;
|
---|
467 |
|
---|
468 | PrintBadPixels(MBadPixelsPix::kChargeSigmaNotValid,"Signal Sigma smaller Pedestal RMS");
|
---|
469 | PrintBadPixels(MBadPixelsPix::kHiGainNotFitted ,"High Gain Signals could not be fitted");
|
---|
470 | PrintBadPixels(MBadPixelsPix::kLoGainNotFitted ,"Low Gain Signals could not be fitted");
|
---|
471 | PrintBadPixels(MBadPixelsPix::kRelTimeNotFitted ,"Relative Arr. Times could not be fitted");
|
---|
472 | PrintBadPixels(MBadPixelsPix::kHiGainOscillating ,"High Gain Signals Oscillation");
|
---|
473 | PrintBadPixels(MBadPixelsPix::kLoGainOscillating ,"Low Gain Signals Oscillation");
|
---|
474 | PrintBadPixels(MBadPixelsPix::kRelTimeOscillating ,"Relative Arr. Times Oscillation");
|
---|
475 | PrintBadPixels(MBadPixelsPix::kDeviatingFFactor ,"Deviating global F-Factor");
|
---|
476 | }
|
---|
477 |
|
---|
478 | void MBadPixelsCam::PrintBadPixels( MBadPixelsPix::UncalibratedType_t typ, const char *text) const
|
---|
479 | {
|
---|
480 |
|
---|
481 |
|
---|
482 | *fLog << "Pixels with " << text << ": " << endl;
|
---|
483 | UInt_t count = 0;
|
---|
484 | UInt_t full = 0;
|
---|
485 |
|
---|
486 | for (Int_t i=0; i<GetSize(); i++)
|
---|
487 | {
|
---|
488 | if ((*this)[i].IsUncalibrated(typ))
|
---|
489 | {
|
---|
490 | *fLog << i << " ";
|
---|
491 | full++;
|
---|
492 | count++;
|
---|
493 | }
|
---|
494 |
|
---|
495 | if (count == 0)
|
---|
496 | continue;
|
---|
497 |
|
---|
498 | if (!(full % 25))
|
---|
499 | {
|
---|
500 | full = 0;
|
---|
501 | *fLog << endl;
|
---|
502 | }
|
---|
503 | }
|
---|
504 |
|
---|
505 | *fLog << endl;
|
---|
506 | *fLog << Form("%3i",count) << " pixels in total " << endl;
|
---|
507 | }
|
---|
508 |
|
---|
509 | // --------------------------------------------------------------------------
|
---|
510 | //
|
---|
511 | // Read from an ascii file of the format:
|
---|
512 | // pixel1 pixel2 pixel3 pixel4
|
---|
513 | // while pixel1,2,3,4 are the pixel indices used in the software.
|
---|
514 | //
|
---|
515 | // To read the pixels corresponding to a given run you can give run!=0
|
---|
516 | // and a file of the format:
|
---|
517 | // 1234: 17 193 292
|
---|
518 | // 1235: 17 193 292 293
|
---|
519 | //
|
---|
520 | void MBadPixelsCam::AsciiRead(istream &fin, UInt_t run=0)
|
---|
521 | {
|
---|
522 |
|
---|
523 | Int_t len;
|
---|
524 | TString str;
|
---|
525 |
|
---|
526 | while (1)
|
---|
527 | {
|
---|
528 | str.ReadLine(fin);
|
---|
529 |
|
---|
530 | if (str.IsNull())
|
---|
531 | {
|
---|
532 | *fLog << warn << GetDescriptor()
|
---|
533 | << ": Cannot apply AsciiRead from istream pointer. "
|
---|
534 | << "Either file does not exist or file is empty! " << endl;
|
---|
535 | return;
|
---|
536 | }
|
---|
537 |
|
---|
538 | Int_t r;
|
---|
539 |
|
---|
540 | const Int_t n = sscanf(str.Data(), " %d : %n", &r, &len);
|
---|
541 | if (n!=1)
|
---|
542 | return;
|
---|
543 |
|
---|
544 | if (run==0 || run && (UInt_t)r==run)
|
---|
545 | break;
|
---|
546 | }
|
---|
547 |
|
---|
548 | str.Remove(0, len);
|
---|
549 |
|
---|
550 | while (1)
|
---|
551 | {
|
---|
552 | Int_t idx;
|
---|
553 | const Int_t n = sscanf(str.Data(), " %d %n", &idx, &len);
|
---|
554 |
|
---|
555 | if (n!=1)
|
---|
556 | break;
|
---|
557 |
|
---|
558 | str.Remove(0, len);
|
---|
559 |
|
---|
560 | if (idx>=GetSize())
|
---|
561 | InitSize(idx+1);
|
---|
562 |
|
---|
563 | (*this)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
564 | (*this)[idx].SetUncalibrated(MBadPixelsPix::kPreviouslyExcluded);
|
---|
565 | }
|
---|
566 | }
|
---|
567 |
|
---|
568 | // --------------------------------------------------------------------------
|
---|
569 | //
|
---|
570 | // Write the information into an ascii file. If a run-number is given the
|
---|
571 | // run-number will lead the line.
|
---|
572 | //
|
---|
573 | Bool_t MBadPixelsCam::AsciiWrite(ostream &fout, UInt_t run=0) const
|
---|
574 | {
|
---|
575 | if (run)
|
---|
576 | fout << run << ":";
|
---|
577 |
|
---|
578 | for (int i=0; i<GetSize(); i++)
|
---|
579 | if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
580 | fout << " " << i;
|
---|
581 |
|
---|
582 | if (run && GetSize())
|
---|
583 | fout << endl;
|
---|
584 |
|
---|
585 | return kTRUE;
|
---|
586 | }
|
---|
587 |
|
---|
588 | // --------------------------------------------------------------------------
|
---|
589 | //
|
---|
590 | // The types are the following:
|
---|
591 | // 0: MBadPixelsPix::GetInfo()[0]
|
---|
592 | // 1: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
|
---|
593 | // 2: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableEvt)
|
---|
594 | // 3: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
|
---|
595 | // 4: MBadPixelsPix::IsHiGainBad()
|
---|
596 | // 5: MBadPixelsPix::IsLoGainBad()
|
---|
597 | // 6: MBadPixelsPix::GetUnsuitableCalLevel()
|
---|
598 | // 7: MBadPixelsPix::GetUnreliableCalLevel()
|
---|
599 | // 8: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainNotFitted)
|
---|
600 | // 9: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainNotFitted)
|
---|
601 | // 10: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
|
---|
602 | // 11: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
|
---|
603 | // 12: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainSaturation )
|
---|
604 | // 13: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeIsPedestal )
|
---|
605 | // 14: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeErrNotValid)
|
---|
606 | // 15: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid)
|
---|
607 | // 16: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid )
|
---|
608 | // 17: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin )
|
---|
609 | // 18: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins )
|
---|
610 | // 19: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes )
|
---|
611 | // 20: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted )
|
---|
612 | // 21: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeOscillating )
|
---|
613 | // 22: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots )
|
---|
614 | // 23: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOverFlow )
|
---|
615 | // 24: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOverFlow )
|
---|
616 | //
|
---|
617 | Bool_t MBadPixelsCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
618 | {
|
---|
619 |
|
---|
620 | if (idx >= GetSize())
|
---|
621 | return kFALSE;
|
---|
622 |
|
---|
623 | switch (type)
|
---|
624 | {
|
---|
625 | case 0:
|
---|
626 | return (*this)[idx].GetInfo()[0];
|
---|
627 | case 1:
|
---|
628 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
629 | return kFALSE;
|
---|
630 | val = 1;
|
---|
631 | break;
|
---|
632 | case 2:
|
---|
633 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt))
|
---|
634 | return kFALSE;
|
---|
635 | val = 1;
|
---|
636 | break;
|
---|
637 | case 3:
|
---|
638 | if (!(*this)[idx].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
|
---|
639 | return kFALSE;
|
---|
640 | val = 1;
|
---|
641 | break;
|
---|
642 | case 4:
|
---|
643 | if (!(*this)[idx].IsHiGainBad())
|
---|
644 | return kFALSE;
|
---|
645 | val = 1;
|
---|
646 | break;
|
---|
647 | case 5:
|
---|
648 | if (!(*this)[idx].IsLoGainBad())
|
---|
649 | return kFALSE;
|
---|
650 | val = 1;
|
---|
651 | break;
|
---|
652 | case 6:
|
---|
653 | if ((*this)[idx].GetUnsuitableCalLevel())
|
---|
654 | val = (*this)[idx].GetUnsuitableCalLevel();
|
---|
655 | else
|
---|
656 | return kFALSE;
|
---|
657 | break;
|
---|
658 | case 7:
|
---|
659 | if ((*this)[idx].GetUnreliableCalLevel())
|
---|
660 | val = (*this)[idx].GetUnreliableCalLevel();
|
---|
661 | else
|
---|
662 | return kFALSE;
|
---|
663 | break;
|
---|
664 | case 8:
|
---|
665 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
|
---|
666 | return kFALSE;
|
---|
667 | val = 1;
|
---|
668 | break;
|
---|
669 | case 9:
|
---|
670 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
|
---|
671 | return kFALSE;
|
---|
672 | val = 1;
|
---|
673 | break;
|
---|
674 | case 10:
|
---|
675 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
|
---|
676 | return kFALSE;
|
---|
677 | val = 1;
|
---|
678 | break;
|
---|
679 | case 11:
|
---|
680 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
|
---|
681 | return kFALSE;
|
---|
682 | val = 1;
|
---|
683 | break;
|
---|
684 | case 12:
|
---|
685 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainSaturation ))
|
---|
686 | return kFALSE;
|
---|
687 | val = 1;
|
---|
688 | break;
|
---|
689 | case 13:
|
---|
690 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal ))
|
---|
691 | return kFALSE;
|
---|
692 | val = 1;
|
---|
693 | break;
|
---|
694 | case 14:
|
---|
695 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeErrNotValid))
|
---|
696 | return kFALSE;
|
---|
697 | val = 1;
|
---|
698 | break;
|
---|
699 | case 15:
|
---|
700 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid))
|
---|
701 | return kFALSE;
|
---|
702 | val = 1;
|
---|
703 | break;
|
---|
704 | case 16:
|
---|
705 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid ))
|
---|
706 | return kFALSE;
|
---|
707 | val = 1;
|
---|
708 | break;
|
---|
709 | case 17:
|
---|
710 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin ))
|
---|
711 | return kFALSE;
|
---|
712 | val = 1;
|
---|
713 | break;
|
---|
714 | case 18:
|
---|
715 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins ))
|
---|
716 | return kFALSE;
|
---|
717 | val = 1;
|
---|
718 | break;
|
---|
719 | case 19:
|
---|
720 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes ))
|
---|
721 | return kFALSE;
|
---|
722 | val = 1;
|
---|
723 | break;
|
---|
724 | case 20:
|
---|
725 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted ))
|
---|
726 | return kFALSE;
|
---|
727 | val = 1;
|
---|
728 | break;
|
---|
729 | case 21:
|
---|
730 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
|
---|
731 | return kFALSE;
|
---|
732 | val = 1;
|
---|
733 | break;
|
---|
734 | case 22:
|
---|
735 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhots))
|
---|
736 | return kFALSE;
|
---|
737 | val = 1;
|
---|
738 | break;
|
---|
739 | case 23:
|
---|
740 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOverFlow ))
|
---|
741 | return kFALSE;
|
---|
742 | val = 1;
|
---|
743 | break;
|
---|
744 | case 24:
|
---|
745 | if (!(*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOverFlow ))
|
---|
746 | return kFALSE;
|
---|
747 | val = 1;
|
---|
748 | break;
|
---|
749 | default:
|
---|
750 | return kFALSE;
|
---|
751 | }
|
---|
752 |
|
---|
753 | return kTRUE;
|
---|
754 | }
|
---|
755 |
|
---|
756 | void MBadPixelsCam::DrawPixelContent(Int_t num) const
|
---|
757 | {
|
---|
758 | *fLog << warn << "MBadPixelsCam::DrawPixelContent - not available." << endl;
|
---|
759 | }
|
---|