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