source: tags/Mars-V0.9.4.2/mbadpixels/MBadPixelsIntensityCam.cc

Last change on this file was 7189, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 14.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Markus Gaug 11/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24/////////////////////////////////////////////////////////////////////////////
25//
26// MBadPixelsIntensityCam
27//
28// Base class for intensity calibration results
29//
30// Contains TClonesArrays for the following objects:
31// - fCams: Array of classes derived from MBadPixelsCam, one entry
32// per calibration camera result. Has to be created
33//
34// See also: MCalibrationIntensityChargeCam, MCalibrationIntensityQECam,
35// MCalibrationIntensityRelTimeCam,
36// MCalibrationCam, MCalibrationPix,
37// MCalibrationQECam, MCalibrationQEPix,
38// MHCalibrationChargePix, MHCalibrationChargeCam
39// MCalibrationChargeBlindPix, MCalibrationChargePINDiode
40//
41//
42/////////////////////////////////////////////////////////////////////////////
43#include "MBadPixelsIntensityCam.h"
44
45#include <TOrdCollection.h>
46#include <TGraph.h>
47
48#include "MGeomPix.h"
49#include "MHCamera.h"
50#include "MLogManip.h"
51
52ClassImp(MBadPixelsIntensityCam);
53
54using namespace std;
55// --------------------------------------------------------------------------
56//
57// Default constructor.
58//
59// Initializes and sets owner of:
60// - fCams
61// - Initializes fCams to entry
62//
63MBadPixelsIntensityCam::MBadPixelsIntensityCam(const char *name, const char *title)
64{
65
66 fName = name ? name : "MBadPixelsIntensityCam";
67 fTitle = title ? title : "Base container for the Intensity Calibration";
68
69 fCams = new TOrdCollection;
70 fCams->SetOwner();
71
72 InitSize(1);
73}
74
75// --------------------------------------------------------------------------
76//
77// Deletes the cameras if they exist
78//
79MBadPixelsIntensityCam::~MBadPixelsIntensityCam()
80{
81 if (fCams)
82 delete fCams;
83}
84
85// --------------------------------------------------------------------------
86//
87// Add a new MBadPixelsCam to fCams, give it the name "name" and initialize
88// it with geom.
89//
90void MBadPixelsIntensityCam::AddToList( const char* name, const MGeomCam &geom)
91{
92 InitSize(GetSize()+1);
93 GetCam()->SetName(name);
94 GetCam()->Init(geom);
95}
96
97
98
99// --------------------------------------------------------------------------
100//
101// Copy 'constructor'
102//
103void MBadPixelsIntensityCam::Copy(TObject& object) const
104{
105
106 MBadPixelsIntensityCam &calib = (MBadPixelsIntensityCam&)object;
107
108 MParContainer::Copy(calib);
109
110 const UInt_t n = GetSize();
111 if (n != 0)
112 {
113 calib.InitSize(n);
114 for (UInt_t i=0; i<n; i++)
115 GetCam(i)->Copy(*(calib.GetCam(i)));
116 }
117
118}
119
120// -----------------------------------------------------
121//
122// Calls Clear() for all entries fCams
123//
124void MBadPixelsIntensityCam::Clear(Option_t *o)
125{
126
127 fCams->ForEach(MBadPixelsCam, Clear)();
128
129 return;
130}
131
132// -----------------------------------------------------
133//
134// Calls Print(o) for all entries fCams
135//
136void MBadPixelsIntensityCam::Print(Option_t *o) const
137{
138 fCams->ForEach(MBadPixelsCam, Print)(o);
139}
140
141
142// -------------------------------------------------------------------
143//
144// Initialize the objects inside the TOrdCollection using the
145// function Add().
146//
147// InitSize can only increase the size, but not shrink.
148//
149// It can be called more than one time. New Containers are
150// added only from the current size to the argument i.
151//
152void MBadPixelsIntensityCam::InitSize(const UInt_t i)
153{
154
155 const UInt_t save = GetSize();
156
157 if (i==save)
158 return;
159
160 if (i>save)
161 Add(save,i);
162}
163
164// -------------------------------------------------------------------
165//
166// Add MBadPixelsCams in the ranges from - to. In order to initialize
167// from MBadPixelsCam derived containers, overwrite this function
168//
169void MBadPixelsIntensityCam::Add(const UInt_t from, const UInt_t to)
170{
171 for (UInt_t i=from; i<to; i++)
172 fCams->AddAt(new MBadPixelsCam,i);
173}
174
175
176// -------------------------------------------------------------------
177//
178// If size is still 0, Intialize a first Cam.
179// Calls Init(geom) for all fCams
180//
181void MBadPixelsIntensityCam::Init(const MGeomCam &geom)
182{
183 if (GetSize() == 0)
184 InitSize(1);
185
186 fCams->ForEach(MBadPixelsCam,Init)(geom);
187}
188
189
190// --------------------------------------------------------------------------
191//
192// Returns the current size of the TOrdCollection fCams
193// independently if the MBadPixelsCam is filled with values or not.
194//
195Int_t MBadPixelsIntensityCam::GetSize() const
196{
197 return fCams->GetSize();
198}
199
200// --------------------------------------------------------------------------
201//
202// Get i-th pixel from current camera
203//
204MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i)
205{
206 return (*GetCam())[i];
207}
208
209// --------------------------------------------------------------------------
210//
211// Get i-th pixel from current camera
212//
213const MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i) const
214{
215 return (*GetCam())[i];
216}
217
218
219// --------------------------------------------------------------------------
220//
221// Get i-th camera
222//
223MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i)
224{
225 return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
226}
227
228// --------------------------------------------------------------------------
229//
230// Get i-th camera
231//
232const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i) const
233{
234 return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
235}
236
237// --------------------------------------------------------------------------
238//
239// Get camera with name 'name'
240//
241MBadPixelsCam *MBadPixelsIntensityCam::GetCam(const char *name )
242{
243 return static_cast<MBadPixelsCam*>(fCams->FindObject(name));
244}
245
246// --------------------------------------------------------------------------
247//
248// Get camera with name 'name'
249//
250const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(const char *name ) const
251{
252 return static_cast<MBadPixelsCam*>(fCams->FindObject(name));
253}
254
255// --------------------------------------------------------------------------
256//
257// Calls GetPixelContent for the current entry in fCams
258//
259Bool_t MBadPixelsIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
260{
261 return GetCam()->GetPixelContent(val,idx,cam,type);
262}
263
264// --------------------------------------------------------------------------
265//
266// Calls DrawPixelContent for the current entry in fCams
267//
268void MBadPixelsIntensityCam::DrawPixelContent( Int_t num ) const
269{
270 return GetCam()->DrawPixelContent(num);
271}
272
273
274// -------------------------------------------------------------------
275//
276// Returns a TGraph with the number of uncalibrated type pixels per area index
277// vs. the calibration camera.
278//
279TGraph *MBadPixelsIntensityCam::GetUncalibratedPerAreaVsTime(const MBadPixelsPix::UncalibratedType_t typ,
280 const Int_t aidx, const MGeomCam &geom)
281{
282
283 const Int_t size = GetSize();
284
285 if (size == 0)
286 return NULL;
287
288 TArrayF uncal(size);
289 TArrayF time(size);
290
291 for (Int_t i=0;i<GetSize();i++)
292 {
293 //
294 // Get the calibration cam from the intensity cam
295 //
296 MBadPixelsCam *cam = GetCam(i);
297
298 //
299 // Get the calibration pix from the calibration cam
300 //
301 for (Int_t j=0; j<cam->GetSize(); j++)
302 {
303
304 if (geom[j].GetAidx() != aidx && aidx > -1)
305 continue;
306
307 const MBadPixelsPix &pix = (*cam)[j];
308 //
309 // Don't use bad pixels
310 //
311 if (pix.IsUncalibrated(typ))
312 uncal[i]++;
313 }
314 time[i] = i;
315 }
316
317 TGraph *gr = new TGraph(size,time.GetArray(),uncal.GetArray());
318
319 gr->SetTitle(Form("Uncalibrated Pixels Area %d",aidx));
320 gr->GetXaxis()->SetTitle("Camera Nr.");
321 gr->GetYaxis()->SetTitle("<N_{uncal}> [1]");
322 return gr;
323}
324
325TGraph *MBadPixelsIntensityCam::GetUnsuitablePerAreaVsTime(const MBadPixelsPix::UnsuitableType_t typ, const Int_t aidx, const MGeomCam &geom)
326{
327 const Int_t size = GetSize();
328
329 if (size == 0)
330 return NULL;
331
332 TArrayF unsuit(size);
333 TArrayF time(size);
334
335 for (Int_t i=0;i<GetSize();i++)
336 {
337 //
338 // Get the calibration cam from the intensity cam
339 //
340 MBadPixelsCam *cam = GetCam(i);
341
342 //
343 // Get the calibration pix from the calibration cam
344 //
345 for (Int_t j=0; j<cam->GetSize(); j++)
346 {
347 if (geom[j].GetAidx() != aidx && aidx > -1)
348 continue;
349
350 const MBadPixelsPix &pix = (*cam)[j];
351 //
352 // Don't use bad pixels
353 //
354 if (pix.IsUnsuitable(typ))
355 unsuit[i]++;
356 }
357 time[i] = i;
358 }
359
360 TGraph *gr = new TGraph(size,time.GetArray(),unsuit.GetArray());
361
362 gr->SetTitle(Form("Unsuitable Pixels Area %d",aidx));
363 gr->GetXaxis()->SetTitle("Camera Nr.");
364 gr->GetYaxis()->SetTitle("<N_{unsuit}> [1]");
365 return gr;
366}
367
368MHCamera *MBadPixelsIntensityCam::GetUnsuitableSpectrum(const MBadPixelsPix::UnsuitableType_t typ, const MGeomCam &geom)
369{
370 const Int_t size = GetSize();
371
372 if (size == 0)
373 return NULL;
374
375 TString title;
376 TString axist;
377
378 switch (typ)
379 {
380 case MBadPixelsPix::kUnsuitableRun:
381 title = "Unsuitable Pixels";
382 break;
383 case MBadPixelsPix::kUnreliableRun:
384 title = "Unreliable Pixels";
385 break;
386 default:
387 *fLog << warn << "Could not determine unsuitable type ... abort " << endl;
388 return NULL;
389 }
390
391 MHCamera *camunsuit = new MHCamera(geom,"Unsuitables",title.Data());
392
393 for (Int_t i=0;i<GetSize();i++)
394 {
395 //
396 // Get the calibration cam from the intensity cam
397 //
398 MBadPixelsCam *cam = GetCam(i);
399
400 //
401 // Get the calibration pix from the calibration cam
402 //
403 for (Int_t j=0; j<cam->GetSize(); j++)
404 {
405 const MBadPixelsPix &pix = (*cam)[j];
406 //
407 // Don't use bad pixels
408 //
409 if (pix.IsUnsuitable(typ))
410 {
411 camunsuit->Fill(j,1);
412 camunsuit->SetUsed(j);
413 }
414 }
415 }
416
417 return camunsuit;
418}
419
420MHCamera *MBadPixelsIntensityCam::GetUncalibratedSpectrum(const MBadPixelsPix::UncalibratedType_t typ, const MGeomCam &geom)
421{
422
423 const Int_t size = GetSize();
424
425 if (size == 0)
426 return NULL;
427
428 TString title;
429 TString axist;
430
431 switch (typ)
432 {
433 case MBadPixelsPix::kPreviouslyExcluded:
434 title = "PreviouslyExcluded";
435 break;
436 case MBadPixelsPix::kHiGainNotFitted:
437 title = "HiGainNotFitted";
438 break;
439 case MBadPixelsPix::kLoGainNotFitted:
440 title = "LoGainNotFitted";
441 break;
442 case MBadPixelsPix::kRelTimeNotFitted:
443 title = "RelTimeNotFitted";
444 break;
445 case MBadPixelsPix::kHiGainOscillating:
446 title = "HiGainOscillating";
447 break;
448 case MBadPixelsPix::kLoGainOscillating:
449 title = "LoGainOscillating";
450 break;
451 case MBadPixelsPix::kRelTimeOscillating:
452 title = "RelTimeOscillating";
453 break;
454 case MBadPixelsPix::kLoGainSaturation:
455 title = "LoGainSaturation";
456 break;
457 case MBadPixelsPix::kChargeIsPedestal:
458 title = "ChargeIsPedestal";
459 break;
460 case MBadPixelsPix::kChargeErrNotValid:
461 title = "ChargeErrNotValid";
462 break;
463 case MBadPixelsPix::kChargeRelErrNotValid:
464 title = "ChargeRelErrNotValid";
465 break;
466 case MBadPixelsPix::kChargeSigmaNotValid:
467 title = "ChargeSigmaNotValid";
468 break;
469 case MBadPixelsPix::kMeanTimeInFirstBin:
470 title = "MeanTimeInFirstBin";
471 break;
472 case MBadPixelsPix::kMeanTimeInLast2Bins:
473 title = "MeanTimeInLast2Bins";
474 break;
475 case MBadPixelsPix::kDeviatingNumPhes:
476 title = "DeviatingNumPhes";
477 break;
478 case MBadPixelsPix::kDeviatingNumPhots:
479 title = "DeviatingNumPhots";
480 break;
481 case MBadPixelsPix::kDeviatingFFactor:
482 title = "DeviatingFFactor";
483 break;
484 case MBadPixelsPix::kDeviatingTimeResolution:
485 title = "DeviatingTimeResolution";
486 break;
487 case MBadPixelsPix::kConversionHiLoNotValid:
488 title = "ConversionHiLoNotValid";
489 break;
490 case MBadPixelsPix::kHiGainOverFlow:
491 title = "HiGainOverFlow";
492 break;
493 case MBadPixelsPix::kLoGainOverFlow:
494 title = "LoGainOverFlow";
495 break;
496 case MBadPixelsPix::kHiLoNotFitted:
497 title = "HiLoNotFitted";
498 break;
499 case MBadPixelsPix::kHiLoOscillating:
500 title = "HiLoOscillating";
501 break;
502 case MBadPixelsPix::kDeadPedestalRms:
503 title = "DeadPedestalRms";
504 break;
505 case MBadPixelsPix::kFluctuatingArrivalTimes:
506 title = "FluctuatingArrivalTimes";
507 break;
508 default:
509 *fLog << warn << "Could not determine uncalibrated type ... abort " << endl;
510 return NULL;
511 }
512
513 MHCamera *camuncal = new MHCamera(geom,"Uncalibrated",title.Data());
514
515 for (Int_t i=0;i<GetSize();i++)
516 {
517 //
518 // Get the calibration cam from the intensity cam
519 //
520 MBadPixelsCam *cam = GetCam(i);
521
522 //
523 // Get the calibration pix from the calibration cam
524 //
525 for (Int_t j=0; j<cam->GetSize(); j++)
526 {
527 const MBadPixelsPix &pix = (*cam)[j];
528 //
529 // Don't use bad pixels
530 //
531 if (pix.IsUncalibrated(typ))
532 {
533 camuncal->Fill(j,1);
534 camuncal->SetUsed(j);
535 }
536 }
537 }
538
539 return camuncal;
540}
541
542
543
544void MBadPixelsIntensityCam::DrawUnsuitablePerAreaVsTime(const MBadPixelsPix::UnsuitableType_t typ, const Int_t aidx, const MGeomCam &geom)
545{
546 TGraph *gr = GetUnsuitablePerAreaVsTime(typ,aidx,geom);
547 gr->SetBit(kCanDelete);
548 gr->Draw("A*");
549}
550
551void MBadPixelsIntensityCam::DrawUncalibratedPerAreaVsTime(const MBadPixelsPix::UncalibratedType_t typ, const Int_t aidx, const MGeomCam &geom)
552{
553 TGraph *gr = GetUncalibratedPerAreaVsTime(typ,aidx,geom);
554 gr->SetBit(kCanDelete);
555 gr->Draw("A*");
556}
Note: See TracBrowser for help on using the repository browser.