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

Last change on this file since 3433 was 3433, checked in by gaug, 21 years ago
*** empty log message ***
File size: 22.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!
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 return kTRUE;
557}
558
559void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist,
560 MCalibrationChargePix &pix,
561 MBadPixelsPix &bad)
562{
563
564 if (hist.IsEmpty())
565 return;
566
567 if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries())
568 {
569 pix.SetHiGainSaturation();
570 bad.SetHiGainSaturation();
571 return;
572 }
573
574 //
575 // 2) Fit the Hi Gain histograms with a Gaussian
576 //
577 if (hist.FitGaus())
578 bad.SetHiGainFitted();
579 //
580 // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
581 //
582 else if (hist.RepeatFit())
583 bad.SetHiGainFitted();
584 else
585 {
586 hist.BypassFit();
587 bad.SetNoHiGainFitted();
588 }
589
590 //
591 // 4) Check for pickup
592 //
593 hist.CountPickup();
594
595 //
596 // 5) Check for oscillations
597 //
598 hist.CreateFourierSpectrum();
599
600 //
601 // 6) Retrieve the results and store them in this class
602 //
603 pix.SetHiGainMeanCharge( hist.GetMean() );
604 pix.SetHiGainMeanChargeErr( hist.GetMeanErr() );
605 pix.SetHiGainSigmaCharge( hist.GetSigma() );
606 pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
607 pix.SetHiGainChargeProb ( hist.GetProb() );
608
609 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
610 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
611
612 pix.SetHiGainNumPickup ( hist.GetPickup() );
613
614 if (!hist.IsFourierSpectrumOK())
615 bad.SetHiGainOscillating();
616}
617
618
619void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist,
620 MCalibrationChargePix &pix,
621 MBadPixelsPix &bad)
622{
623
624
625 if (hist.IsEmpty())
626 return;
627
628 if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
629 {
630 pix.SetLoGainSaturation();
631 bad.SetLoGainSaturation();
632 return;
633 }
634 //
635 // 2) Fit the Lo Gain histograms with a Gaussian
636 //
637 if (hist.FitGaus())
638 bad.SetLoGainFitted();
639 //
640 // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
641 //
642 else if (hist.RepeatFit())
643 bad.SetLoGainFitted();
644 else
645 {
646 hist.BypassFit();
647 bad.SetNoLoGainFitted();
648 }
649
650 //
651 // 4) Check for pickup
652 //
653 hist.CountPickup();
654
655 //
656 // 5) Check for oscillations
657 //
658 hist.CreateFourierSpectrum();
659
660 //
661 // 6) Retrieve the results and store them in this class
662 //
663 pix.SetLoGainMeanCharge( hist.GetMean() );
664 pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );
665 pix.SetLoGainSigmaCharge( hist.GetSigma() );
666 pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );
667 pix.SetLoGainChargeProb ( hist.GetProb() );
668
669 if (pix.IsHiGainSaturation())
670 {
671 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
672 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
673 }
674
675 pix.SetLoGainNumPickup ( hist.GetPickup() );
676
677 if (!hist.IsFourierSpectrumOK())
678 bad.SetLoGainOscillating();
679}
680
681Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
682{
683 return kTRUE;
684}
685
686// --------------------------------------------------------------------------
687//
688// What MHCamera needs in order to draw an individual pixel in the camera
689//
690void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
691{
692
693 if (idx == -1)
694 fAverageHiGainInnerPix->DrawClone();
695 if (idx == -2)
696 fAverageHiGainOuterPix->DrawClone();
697 if (idx == -3)
698 fAverageLoGainInnerPix->DrawClone();
699 if (idx == -4)
700 fAverageLoGainOuterPix->DrawClone();
701 (*this)[idx].DrawClone();
702
703}
704
705
706void MHCalibrationChargeCam::Draw(const Option_t *opt)
707{
708
709 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
710 pad->SetBorderMode(0);
711
712 pad->Divide(2,2);
713
714 pad->cd(1);
715
716 if (!fAverageHiGainInnerPix->IsEmpty())
717 gPad->SetLogy();
718 fAverageHiGainInnerPix->Draw(opt);
719
720 pad->cd(2);
721
722 if (!fAverageLoGainInnerPix->IsEmpty())
723 gPad->SetLogy();
724 fAverageLoGainInnerPix->Draw(opt);
725
726 pad->cd(3);
727
728 if (!fAverageHiGainOuterPix->IsEmpty())
729 gPad->SetLogy();
730 fAverageHiGainOuterPix->Draw(opt);
731
732 pad->cd(4);
733
734 if (!fAverageLoGainOuterPix->IsEmpty())
735 gPad->SetLogy();
736 fAverageLoGainOuterPix->Draw(opt);
737
738}
Note: See TracBrowser for help on using the repository browser.