source: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc@ 8425

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