source: trunk/Mars/mbadpixels/MBadPixelsIntensityCam.cc@ 13408

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