source: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc@ 3432

Last change on this file since 3432 was 3432, checked in by gaug, 21 years ago
*** empty log message ***
File size: 22.6 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!
19! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHCalibrationChargeCam
29//
30// Fills the extracted signals of MExtractedSignalCam into the MH-classes:
31//
32// MHCalibrationChargeHiGainPix, MHCalibrationChargeLoGainPix for each pixel
33// and additionally for an average of the inner and the outer pixels, respectively.
34//
35// By default, subsequently the hi-gain classes are treated unless
36// more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
37// slices show saturation. In that case, the low-gain classes are treated.
38// If more than fNumLoGainSaturationLimit (default: 1%) of the overall
39// low-gain FADC slices saturate, the pixel is declared not valid and no further
40// treatment is pursued.
41//
42// The filled histograms are fitted to a Gaussian and the mean and sigma with
43// its errors and the fit probability are extracted. If none of these values are
44// NaN's and if the probability is bigger than fProbLimit (default: 0.5%), the fit
45// is declared valid. Otherwise, the fit is repeated within ranges of the previous mean
46// +- 5 sigma. In case that this does not help, the histogram means and RMS's are taken directly,
47// but the flag kFitValid is set to FALSE. Outliers of more than fPickUpLimit (default: 5) sigmas
48// from the mean are counted as PickUp events.
49//
50// Additionally, the slice number with the highest value is stored and a corresponding
51// histogram is filled. This histogram serves only for a rough cross-check if the
52// signal does not lie at the edges of chose extraction window.
53//
54// The class also fills arrays with the signal vs. event number, creates a fourier
55// spectrum out of it and investigates if the projected frequencies follow an exponential
56// distribution. In case that the probability of the exponential fit is less than
57// fProbLimit, the pixel is declared HiGainOscillating or LoGainOscillating, respectively.
58//
59// The results are written into MCalibrationChargeCam.
60//
61/////////////////////////////////////////////////////////////////////////////
62#include "MHCalibrationChargeCam.h"
63
64#include <TVirtualPad.h>
65#include <TCanvas.h>
66#include <TPad.h>
67
68#include "MLog.h"
69#include "MLogManip.h"
70
71#include "MParList.h"
72
73#include "MHCalibrationChargeHiGainPix.h"
74#include "MHCalibrationChargeLoGainPix.h"
75#include "MHCalibrationChargePix.h"
76
77#include "MCalibrationChargeCam.h"
78#include "MCalibrationChargePix.h"
79
80#include "MGeomCam.h"
81#include "MGeomPix.h"
82
83#include "MBadPixelsCam.h"
84#include "MBadPixelsPix.h"
85
86#include "MRawEvtData.h"
87#include "MRawEvtPixelIter.h"
88
89#include "MExtractedSignalCam.h"
90#include "MExtractedSignalPix.h"
91
92ClassImp(MHCalibrationChargeCam);
93
94using namespace std;
95
96const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
97const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.01;
98//
99//
100//
101MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
102 : fRawEvt(NULL), fGeom(NULL), fBadPixels(NULL)
103{
104 fName = name ? name : "MHCalibrationChargeCam";
105 fTitle = title ? title : "Class to fill the calibration histograms ";
106
107 fHiGainArray = new TObjArray;
108 fHiGainArray->SetOwner();
109
110 fLoGainArray = new TObjArray;
111 fLoGainArray->SetOwner();
112
113 fAverageHiGainInnerPix = new MHCalibrationChargeHiGainPix("AverageHiGainInnerPix","Average HiGain FADC sums of inner pixels");
114 fAverageLoGainInnerPix = new MHCalibrationChargeLoGainPix("AverageLoGainInnerPix","Average LoGain FADC sums of inner pixels");
115 fAverageHiGainOuterPix = new MHCalibrationChargeHiGainPix("AverageHiGainOuterPix","Average HiGain FADC sums of outer pixels");
116 fAverageLoGainOuterPix = new MHCalibrationChargeLoGainPix("AverageLoGainOuterPix","Average LoGain FADC sums of outer pixels");
117
118/*
119 fAverageHiGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerHiGainPix");
120 fAverageHiGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterHiGainPix");
121 fAverageLoGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerLoGainPix");
122 fAverageLoGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterLoGainPix");
123*/
124 fAverageHiGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels HiGain");
125 fAverageLoGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels LoGain");
126 fAverageHiGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels HiGain");
127 fAverageLoGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels LoGain");
128
129 fAverageHiGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels HiGain");
130 fAverageLoGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels LoGain");
131 fAverageHiGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels HiGain");
132 fAverageLoGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels LoGain");
133
134 fAverageHiGainInnerPix->SetChargeFirst(-1000.);
135 fAverageHiGainOuterPix->SetChargeFirst(-1000.);
136
137 fAverageHiGainInnerPix->SetChargeLast(4000.);
138 fAverageLoGainInnerPix->SetChargeLast(4000.);
139 fAverageHiGainOuterPix->SetChargeLast(4000.);
140 fAverageLoGainOuterPix->SetChargeLast(4000.);
141
142 fAverageHiGainInnerPix->SetChargeNbins(4000);
143 fAverageLoGainInnerPix->SetChargeNbins(4000);
144 fAverageHiGainOuterPix->SetChargeNbins(4000);
145 fAverageLoGainOuterPix->SetChargeNbins(4000);
146
147 SetNumHiGainSaturationLimit();
148 SetNumLoGainSaturationLimit();
149
150 fNumInnerPixels = 0;
151 fNumOuterPixels = 0;
152 fNumExcluded = 0;
153}
154
155// --------------------------------------------------------------------------
156//
157// Delete the TClonesArray of MHCalibrationChargePix containers
158// Delete the MHCalibrationPINDiode and the MHCalibrationBlindPix
159//
160// Delete the histograms if they exist
161//
162MHCalibrationChargeCam::~MHCalibrationChargeCam()
163{
164 delete fHiGainArray;
165 delete fLoGainArray;
166
167 delete fAverageHiGainInnerPix;
168 delete fAverageLoGainInnerPix;
169 delete fAverageHiGainOuterPix;
170 delete fAverageLoGainOuterPix;
171}
172
173// --------------------------------------------------------------------------
174//
175// Get i-th pixel (pixel number)
176//
177MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i)
178{
179 return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
180}
181
182// --------------------------------------------------------------------------
183//
184// Get i-th pixel (pixel number)
185//
186const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i) const
187{
188 return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
189}
190
191// --------------------------------------------------------------------------
192//
193// Get i-th pixel (pixel number)
194//
195MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i)
196{
197 return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
198}
199
200// --------------------------------------------------------------------------
201//
202// Get i-th pixel (pixel number)
203//
204const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i) const
205{
206 return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
207}
208
209
210#if 0
211// --------------------------------------------------------------------------
212//
213// Our own clone function is necessary since root 3.01/06 or Mars 0.4
214// I don't know the reason
215//
216TObject *MHCalibrationChargeCam::Clone(const char *) const
217{
218
219 const Int_t nhi = fHiGainArray->GetSize();
220 const Int_t nlo = fLoGainArray->GetSize();
221 //
222 // FIXME, this might be done faster and more elegant, by direct copy.
223 //
224 MHCalibrationChargeCam *cam = (MHCalibrationChargeCam*)(this)->Clone("");
225// MHCalibrationChargeCam cam;
226// Copy(*cam);
227
228/*
229 cam->fHiGainArray->Delete();
230 cam->fLoGainArray->Delete();
231
232 cam->fHiGainArray->Expand(nhi);
233 cam->fLoGainArray->Expand(nlo);
234
235 for (int i=0; i<nhi; i++)
236 {
237 delete (*cam->fHiGainArray)[i];
238 (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
239 }
240 for (int i=0; i<nlo; i++)
241 {
242 delete (*cam->fLoGainArray)[i];
243 (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
244 }
245*/
246
247/*
248 delete cam->fAverageHiGainInnerPix;
249 delete cam->fAverageLoGainInnerPix;
250 delete cam->fAverageHiGainOuterPix;
251 delete cam->fAverageLoGainOuterPix;
252
253 cam->GetAverageHiGainInnerPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainInnerPix->Clone();
254 cam->GetAverageLoGainInnerPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainInnerPix->Clone();
255
256 cam->GetAverageHiGainOuterPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainOuterPix->Clone();
257 cam->GetAverageLoGainOuterPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainOuterPix->Clone();
258
259 fAverageHiGainInnerPix->Copy(cam->GetAverageHiGainInnerPix());
260 fAverageLoGainInnerPix->Copy(cam->GetAverageLoGainInnerPix());
261 fAverageHiGainOuterPix->Copy(cam->GetAverageHiGainOuterPix());
262 fAverageLoGainOuterPix->Copy(cam->GetAverageLoGainOuterPix());
263*/
264
265 return cam;
266}
267#endif
268// --------------------------------------------------------------------------
269//
270// To setup the object we get the number of pixels from a MGeomCam object
271// in the Parameter list.
272//
273Bool_t MHCalibrationChargeCam::SetupFill(const MParList *pList)
274{
275
276 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
277
278 if (!fRawEvt)
279 {
280 gLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
281 return kFALSE;
282 }
283
284 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
285
286 if (!fGeom)
287 {
288 gLog << err << dbginf << "MGeomCam not found... aborting." << endl;
289 return kFALSE;
290 }
291
292 fHiGainArray->Delete();
293 fLoGainArray->Delete();
294
295 fAverageHiGainInnerPix->Init();
296 fAverageLoGainInnerPix->Init();
297 fAverageHiGainOuterPix->Init();
298 fAverageLoGainOuterPix->Init();
299
300 return kTRUE;
301}
302
303Bool_t MHCalibrationChargeCam::ReInit(MParList *pList)
304{
305
306 fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
307 if (!fBadPixels)
308 {
309 gLog << err << GetDescriptor() << ": ERROR: Could not find MBadPixelsCam ... aborting " << endl;
310 return kFALSE;
311 }
312
313
314 fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
315 if (!fCam)
316 {
317 gLog << err << GetDescriptor() << ": ERROR: Could not find MCalibrationChargeCam ... aborting " << endl;
318 return kFALSE;
319 }
320
321 MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
322 if (!signal)
323 {
324 gLog << err << "No argument in MExtractedSignalCam::ReInit... abort." << endl;
325 return kFALSE;
326 }
327
328 const Int_t n = signal->GetSize();
329
330 if (fHiGainArray->GetEntries()==0)
331 {
332 fHiGainArray->Expand(n);
333
334 for (Int_t i=0; i<n; i++)
335 {
336 //
337 // Oscillating pixels
338 //
339 (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
340
341 if ((*fBadPixels)[i].IsBad())
342 {
343 fNumExcluded++;
344 (*this)[i].SetExcluded();
345 }
346 (*this)[i].Init();
347 (*this)[i].ChangeHistId(i);
348 }
349 }
350
351
352 if (fLoGainArray->GetEntries()==0)
353 {
354 fLoGainArray->Expand(n);
355
356 for (Int_t i=0; i<n; i++)
357 {
358 (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
359 //
360 // Pixels with non-valid behavior
361 //
362 if ((*fBadPixels)[i].IsBad())
363 (*this)(i).SetExcluded();
364
365 (*this)(i).Init();
366 (*this)(i).ChangeHistId(i);
367 }
368 }
369
370
371 *fLog << inf << GetDescriptor() << ": " << fNumExcluded << " excluded Pixels " << endl;
372
373 return kTRUE;
374}
375
376
377// --------------------------------------------------------------------------
378Bool_t MHCalibrationChargeCam::Fill(const MParContainer *par, const Stat_t w)
379{
380
381 MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
382 if (!signal)
383 {
384 gLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
385 return kFALSE;
386 }
387
388 Int_t n = signal->GetSize();
389
390 if (fHiGainArray->GetEntries() != n)
391 {
392 gLog << err << "ERROR - Size mismatch... abort." << endl;
393 return kFALSE;
394 }
395
396 if (fLoGainArray->GetEntries() != n)
397 {
398 gLog << err << "ERROR - Size mismatch... abort." << endl;
399 return kFALSE;
400 }
401
402 //
403 // First the extracted signal
404 //
405 Float_t sumhiinnertot = 0.;
406 Float_t sumloinnertot = 0.;
407 Float_t sumhioutertot = 0.;
408 Float_t sumlooutertot = 0.;
409 Int_t sumhiinnersat = 0;
410 Int_t sumloinnersat = 0;
411 Int_t sumhioutersat = 0;
412 Int_t sumlooutersat = 0;
413
414 fNumInnerPixels = fNumOuterPixels = 0;
415
416 for (int i=0; i<n; i++)
417 {
418
419 if ((*this)[i].IsExcluded())
420 continue;
421
422 const MExtractedSignalPix &pix = (*signal)[i];
423
424 const Float_t sumhi = pix.GetExtractedSignalHiGain();
425 const Float_t sumlo = pix.GetExtractedSignalLoGain();
426
427 (*this)[i].FillHistAndArray(sumhi);
428 (*this)(i).FillHistAndArray(sumlo);
429
430 const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
431 const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
432
433 (*this)[i].SetSaturated(sathi);
434 (*this)(i).SetSaturated(satlo);
435
436 if (fGeom->GetPixRatio(i) == 1.)
437 {
438 sumhiinnertot += sumhi;
439 sumloinnertot += sumlo;
440 sumhiinnersat += sathi;
441 sumloinnersat += satlo;
442 fNumInnerPixels++;
443 }
444 else
445 {
446 sumhioutertot += sumhi;
447 sumlooutertot += sumlo;
448 sumhioutersat += sathi;
449 sumlooutersat += satlo;
450 fNumOuterPixels++;
451 }
452
453 }
454
455 fAverageHiGainInnerPix->FillHistAndArray(sumhiinnertot/fNumInnerPixels);
456 fAverageLoGainInnerPix->FillHistAndArray(sumloinnertot/fNumInnerPixels);
457 fAverageHiGainOuterPix->FillHistAndArray(sumhioutertot/fNumOuterPixels);
458 fAverageLoGainOuterPix->FillHistAndArray(sumlooutertot/fNumOuterPixels);
459
460 fAverageHiGainInnerPix->SetSaturated((Float_t)sumhiinnersat/fNumInnerPixels);
461 fAverageLoGainInnerPix->SetSaturated((Float_t)sumloinnersat/fNumInnerPixels);
462 fAverageHiGainOuterPix->SetSaturated((Float_t)sumhioutersat/fNumOuterPixels);
463 fAverageLoGainOuterPix->SetSaturated((Float_t)sumlooutersat/fNumOuterPixels);
464
465 //
466 // Now the times
467 //
468 sumhiinnertot = sumloinnertot = sumhioutertot = sumlooutertot = 0.;
469 fNumInnerPixels = fNumOuterPixels = 0;
470
471 MRawEvtPixelIter pixel(fRawEvt);
472 while (pixel.Next())
473 {
474
475 const UInt_t pixid = pixel.GetPixelId();
476
477 if ((*this)[pixid].IsExcluded())
478 continue;
479
480 const Int_t timehi = (Int_t)pixel.GetIdxMaxHiGainSample();
481 const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample() + 15.;
482
483 (*this)[pixid].FillAbsTime(timehi);
484 (*this)(pixid).FillAbsTime(timelo);
485
486 if (fGeom->GetPixRatio(pixel.GetPixelId()) == 1.)
487 {
488 sumhiinnertot += timehi;
489 sumloinnertot += timelo;
490 fNumInnerPixels++;
491 }
492 else
493 {
494 sumhioutertot += timehi;
495 sumlooutertot += timelo;
496 fNumOuterPixels++;
497 }
498 }
499
500 fAverageHiGainInnerPix-> FillAbsTime(sumhiinnertot/fNumInnerPixels);
501 fAverageLoGainInnerPix-> FillAbsTime(sumloinnertot/fNumInnerPixels);
502 fAverageHiGainOuterPix-> FillAbsTime(sumhioutertot/fNumOuterPixels);
503 fAverageLoGainOuterPix-> FillAbsTime(sumlooutertot/fNumOuterPixels);
504
505 return kTRUE;
506}
507
508// --------------------------------------------------------------------------
509//
510// 1) Return if the charge distribution is already succesfully fitted
511// or if the histogram is empty
512// 2) Fit the histograms with a Gaussian
513// 3) In case of failure set the bit kFitted to false and take histogram means and RMS
514// 4) Check for pickup noise
515// 5) Check the fourier spectrum
516// 5) Retrieve the results and store them in this class
517//
518Bool_t MHCalibrationChargeCam::Finalize()
519{
520
521 for (int i=0; i<fHiGainArray->GetSize(); i++)
522 {
523
524 MCalibrationChargePix &pix = (*fCam)[i];
525 MHCalibrationChargeHiGainPix &histhi = (*this)[i];
526 MBadPixelsPix &bad = (*fBadPixels)[i];
527
528 FinalizeHiGainHists(histhi,pix,bad);
529
530 }
531
532 for (int i=0; i<fLoGainArray->GetSize(); i++)
533 {
534
535 if ((*this)(i).IsExcluded())
536 continue;
537
538 MHCalibrationChargeLoGainPix &histlo = (*this)(i);
539 MCalibrationChargePix &pix = (*fCam)[i];
540 MBadPixelsPix &bad = (*fBadPixels)[i];
541
542 FinalizeLoGainHists(histlo,pix,bad);
543
544 }
545
546 FinalizeHiGainHists(*fAverageHiGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
547 FinalizeLoGainHists(*fAverageLoGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
548 FinalizeHiGainHists(*fAverageHiGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
549 FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
550
551 fCam->GetAverageInnerPix()->SetSigmaCharge (fCam->GetAverageInnerPix()->GetSigmaCharge() *TMath::Sqrt((Float_t)fNumInnerPixels));
552 fCam->GetAverageOuterPix()->SetSigmaCharge (fCam->GetAverageOuterPix()->GetSigmaCharge() *TMath::Sqrt((Float_t)fNumOuterPixels));
553 fCam->GetAverageInnerPix()->SetSigmaChargeErr(fCam->GetAverageInnerPix()->GetSigmaChargeErr()*TMath::Sqrt((Float_t)fNumInnerPixels));
554 fCam->GetAverageOuterPix()->SetSigmaChargeErr(fCam->GetAverageOuterPix()->GetSigmaChargeErr()*TMath::Sqrt((Float_t)fNumOuterPixels));
555
556 *fLog << err << TMath::Sqrt((Float_t)fNumInnerPixels) << endl;
557 *fLog << err << TMath::Sqrt((Float_t)fNumOuterPixels) << endl;
558
559 return kTRUE;
560}
561
562void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist,
563 MCalibrationChargePix &pix,
564 MBadPixelsPix &bad)
565{
566
567 if (hist.IsEmpty())
568 return;
569
570 if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries())
571 {
572 pix.SetHiGainSaturation();
573 bad.SetHiGainSaturation();
574 return;
575 }
576
577 //
578 // 2) Fit the Hi Gain histograms with a Gaussian
579 //
580 if (hist.FitGaus())
581 bad.SetHiGainFitted();
582 //
583 // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
584 //
585 else if (hist.RepeatFit())
586 bad.SetHiGainFitted();
587 else
588 {
589 hist.BypassFit();
590 bad.SetNoHiGainFitted();
591 }
592
593 //
594 // 4) Check for pickup
595 //
596 hist.CountPickup();
597
598 //
599 // 5) Check for oscillations
600 //
601 hist.CreateFourierSpectrum();
602
603 //
604 // 6) Retrieve the results and store them in this class
605 //
606 pix.SetHiGainMeanCharge( hist.GetMean() );
607 pix.SetHiGainMeanChargeErr( hist.GetMeanErr() );
608 pix.SetHiGainSigmaCharge( hist.GetSigma() );
609 pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
610 pix.SetHiGainChargeProb ( hist.GetProb() );
611
612 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
613 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
614
615 pix.SetHiGainNumPickup ( hist.GetPickup() );
616
617 if (!hist.IsFourierSpectrumOK())
618 bad.SetHiGainOscillating();
619}
620
621
622void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist,
623 MCalibrationChargePix &pix,
624 MBadPixelsPix &bad)
625{
626
627
628 if (hist.IsEmpty())
629 return;
630
631 if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
632 {
633 pix.SetLoGainSaturation();
634 bad.SetLoGainSaturation();
635 return;
636 }
637 //
638 // 2) Fit the Lo Gain histograms with a Gaussian
639 //
640 if (hist.FitGaus())
641 bad.SetLoGainFitted();
642 //
643 // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
644 //
645 else if (hist.RepeatFit())
646 bad.SetLoGainFitted();
647 else
648 {
649 hist.BypassFit();
650 bad.SetNoLoGainFitted();
651 }
652
653 //
654 // 4) Check for pickup
655 //
656 hist.CountPickup();
657
658 //
659 // 5) Check for oscillations
660 //
661 hist.CreateFourierSpectrum();
662
663 //
664 // 6) Retrieve the results and store them in this class
665 //
666 pix.SetLoGainMeanCharge( hist.GetMean() );
667 pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );
668 pix.SetLoGainSigmaCharge( hist.GetSigma() );
669 pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );
670 pix.SetLoGainChargeProb ( hist.GetProb() );
671
672 if (pix.IsHiGainSaturation())
673 {
674 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
675 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
676 }
677
678 pix.SetLoGainNumPickup ( hist.GetPickup() );
679
680 if (!hist.IsFourierSpectrumOK())
681 bad.SetLoGainOscillating();
682}
683
684Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
685{
686 return kTRUE;
687}
688
689// --------------------------------------------------------------------------
690//
691// What MHCamera needs in order to draw an individual pixel in the camera
692//
693void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
694{
695
696 if (idx == -1)
697 fAverageHiGainInnerPix->DrawClone();
698 if (idx == -2)
699 fAverageHiGainOuterPix->DrawClone();
700 if (idx == -3)
701 fAverageLoGainInnerPix->DrawClone();
702 if (idx == -4)
703 fAverageLoGainOuterPix->DrawClone();
704 (*this)[idx].DrawClone();
705
706}
707
708
709void MHCalibrationChargeCam::Draw(const Option_t *opt)
710{
711
712 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
713 pad->SetBorderMode(0);
714
715 pad->Divide(2,2);
716
717 pad->cd(1);
718
719 if (!fAverageHiGainInnerPix->IsEmpty())
720 gPad->SetLogy();
721 fAverageHiGainInnerPix->Draw(opt);
722
723 pad->cd(2);
724
725 if (!fAverageLoGainInnerPix->IsEmpty())
726 gPad->SetLogy();
727 fAverageLoGainInnerPix->Draw(opt);
728
729 pad->cd(3);
730
731 if (!fAverageHiGainOuterPix->IsEmpty())
732 gPad->SetLogy();
733 fAverageHiGainOuterPix->Draw(opt);
734
735 pad->cd(4);
736
737 if (!fAverageLoGainOuterPix->IsEmpty())
738 gPad->SetLogy();
739 fAverageLoGainOuterPix->Draw(opt);
740
741}
Note: See TracBrowser for help on using the repository browser.