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

Last change on this file since 3544 was 3496, checked in by gaug, 21 years ago
*** empty log message ***
File size: 23.1 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.005;
97const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
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 if (!fRawEvt)
278 {
279 *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
280 return kFALSE;
281 }
282
283 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
284 if (!fGeom)
285 {
286 *fLog << err << "MGeomCam not found... aborting." << endl;
287 return kFALSE;
288 }
289
290 fHiGainArray->Delete();
291 fLoGainArray->Delete();
292
293 fAverageHiGainInnerPix->Init();
294 fAverageLoGainInnerPix->Init();
295 fAverageHiGainOuterPix->Init();
296 fAverageLoGainOuterPix->Init();
297
298 return kTRUE;
299}
300
301Bool_t MHCalibrationChargeCam::ReInit(MParList *pList)
302{
303
304 fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
305 if (!fBadPixels)
306 return kFALSE;
307
308
309 fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
310 if (!fCam)
311 return kFALSE;
312
313 MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
314 if (!signal)
315 {
316 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
317 return kFALSE;
318 }
319
320 const Int_t n = signal->GetSize();
321
322 if (fHiGainArray->GetEntries()==0)
323 {
324 fHiGainArray->Expand(n);
325
326 for (Int_t i=0; i<n; i++)
327 {
328 //
329 // Oscillating pixels
330 //
331 (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
332
333 if ((*fBadPixels)[i].IsBad())
334 {
335 fNumExcluded++;
336 (*this)[i].SetExcluded();
337 }
338 (*this)[i].Init();
339 (*this)[i].ChangeHistId(i);
340 }
341 }
342
343
344 if (fLoGainArray->GetEntries()==0)
345 {
346 fLoGainArray->Expand(n);
347
348 for (Int_t i=0; i<n; i++)
349 {
350 (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
351 //
352 // Pixels with non-valid behavior
353 //
354 if ((*fBadPixels)[i].IsBad())
355 (*this)(i).SetExcluded();
356
357 (*this)(i).Init();
358 (*this)(i).ChangeHistId(i);
359 }
360 }
361
362
363 *fLog << inf << GetDescriptor() << ": " << fNumExcluded << " excluded Pixels " << endl;
364
365 return kTRUE;
366}
367
368
369// --------------------------------------------------------------------------
370Bool_t MHCalibrationChargeCam::Fill(const MParContainer *par, const Stat_t w)
371{
372
373 MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
374 if (!signal)
375 {
376 *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
377 return kFALSE;
378 }
379
380 Int_t n = signal->GetSize();
381 Int_t lofirst = signal->GetFirstUsedSliceLoGain();
382
383 if (fHiGainArray->GetEntries() != n)
384 {
385 *fLog << err << "ERROR - Size mismatch... abort." << endl;
386 return kFALSE;
387 }
388
389 if (fLoGainArray->GetEntries() != n)
390 {
391 *fLog << err << "ERROR - Size mismatch... abort." << endl;
392 return kFALSE;
393 }
394
395 //
396 // First the extracted signal
397 //
398 Float_t sumhiinnertot = 0.;
399 Float_t sumloinnertot = 0.;
400 Float_t sumhioutertot = 0.;
401 Float_t sumlooutertot = 0.;
402 Int_t sumhiinnersat = 0;
403 Int_t sumloinnersat = 0;
404 Int_t sumhioutersat = 0;
405 Int_t sumlooutersat = 0;
406
407 fNumInnerPixels = fNumOuterPixels = 0;
408
409 for (int i=0; i<n; i++)
410 {
411
412 if ((*this)[i].IsExcluded())
413 continue;
414
415 const MExtractedSignalPix &pix = (*signal)[i];
416
417 const Float_t sumhi = pix.GetExtractedSignalHiGain();
418 const Float_t sumlo = pix.GetExtractedSignalLoGain();
419
420 (*this)[i].FillHistAndArray(sumhi);
421 (*this)(i).FillHistAndArray(sumlo);
422
423 const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
424 const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
425
426 (*this)[i].SetSaturated(sathi);
427 (*this)(i).SetSaturated(satlo);
428
429 if (fGeom->GetPixRatio(i) == 1.)
430 {
431 sumhiinnertot += sumhi;
432 sumloinnertot += sumlo;
433 sumhiinnersat += sathi;
434 sumloinnersat += satlo;
435 fNumInnerPixels++;
436 }
437 else
438 {
439 sumhioutertot += sumhi;
440 sumlooutertot += sumlo;
441 sumhioutersat += sathi;
442 sumlooutersat += satlo;
443 fNumOuterPixels++;
444 }
445
446 }
447
448 fAverageHiGainInnerPix->FillHistAndArray(sumhiinnertot/fNumInnerPixels);
449 fAverageLoGainInnerPix->FillHistAndArray(sumloinnertot/fNumInnerPixels);
450 fAverageHiGainOuterPix->FillHistAndArray(sumhioutertot/fNumOuterPixels);
451 fAverageLoGainOuterPix->FillHistAndArray(sumlooutertot/fNumOuterPixels);
452
453 fAverageHiGainInnerPix->SetSaturated((Float_t)sumhiinnersat/fNumInnerPixels);
454 fAverageLoGainInnerPix->SetSaturated((Float_t)sumloinnersat/fNumInnerPixels);
455 fAverageHiGainOuterPix->SetSaturated((Float_t)sumhioutersat/fNumOuterPixels);
456 fAverageLoGainOuterPix->SetSaturated((Float_t)sumlooutersat/fNumOuterPixels);
457
458 //
459 // Now the times
460 //
461 sumhiinnertot = sumloinnertot = sumhioutertot = sumlooutertot = 0.;
462 fNumInnerPixels = fNumOuterPixels = 0;
463
464 MRawEvtPixelIter pixel(fRawEvt);
465 while (pixel.Next())
466 {
467
468 const UInt_t pixid = pixel.GetPixelId();
469
470 if ((*this)[pixid].IsExcluded())
471 continue;
472
473 const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
474 const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
475
476 (*this)[pixid].FillAbsTime(timehi);
477 (*this)(pixid).FillAbsTime(timelo);
478
479 if (fGeom->GetPixRatio(pixel.GetPixelId()) == 1.)
480 {
481 sumhiinnertot += timehi;
482 sumloinnertot += timelo;
483 fNumInnerPixels++;
484 }
485 else
486 {
487 sumhioutertot += timehi;
488 sumlooutertot += timelo;
489 fNumOuterPixels++;
490 }
491 }
492
493 fAverageHiGainInnerPix-> FillAbsTime(sumhiinnertot/fNumInnerPixels);
494 fAverageLoGainInnerPix-> FillAbsTime(sumloinnertot/fNumInnerPixels);
495 fAverageHiGainOuterPix-> FillAbsTime(sumhioutertot/fNumOuterPixels);
496 fAverageLoGainOuterPix-> FillAbsTime(sumlooutertot/fNumOuterPixels);
497
498 return kTRUE;
499}
500
501// --------------------------------------------------------------------------
502//
503// 1) Return if the charge distribution is already succesfully fitted
504// or if the histogram is empty
505// 2) Fit the histograms with a Gaussian
506// 3) In case of failure set the bit kFitted to false and take histogram means and RMS
507// 4) Check for pickup noise
508// 5) Check the fourier spectrum
509// 5) Retrieve the results and store them in this class
510//
511Bool_t MHCalibrationChargeCam::Finalize()
512{
513
514 for (int i=0; i<fHiGainArray->GetSize(); i++)
515 {
516
517 MCalibrationChargePix &pix = (*fCam)[i];
518 MHCalibrationChargeHiGainPix &histhi = (*this)[i];
519 MBadPixelsPix &bad = (*fBadPixels)[i];
520
521 FinalizeHiGainHists(histhi,pix,bad);
522
523 }
524
525 for (int i=0; i<fLoGainArray->GetSize(); i++)
526 {
527
528 if ((*this)(i).IsExcluded())
529 continue;
530
531 MHCalibrationChargeLoGainPix &histlo = (*this)(i);
532 MCalibrationChargePix &pix = (*fCam)[i];
533 MBadPixelsPix &bad = (*fBadPixels)[i];
534
535 FinalizeLoGainHists(histlo,pix,bad);
536
537 }
538
539 FinalizeHiGainHists(*fAverageHiGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
540 FinalizeLoGainHists(*fAverageLoGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
541 FinalizeHiGainHists(*fAverageHiGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
542 FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
543
544 fCam->GetAverageInnerPix()->SetSigmaCharge (fCam->GetAverageInnerPix()->GetSigmaCharge()
545 *TMath::Sqrt((Float_t)fNumInnerPixels));
546 fCam->GetAverageOuterPix()->SetSigmaCharge (fCam->GetAverageOuterPix()->GetSigmaCharge()
547 *TMath::Sqrt((Float_t)fNumOuterPixels));
548 fCam->GetAverageInnerPix()->SetSigmaChargeErr(fCam->GetAverageInnerPix()->GetSigmaChargeErr()
549 *TMath::Sqrt((Float_t)fNumInnerPixels));
550 fCam->GetAverageOuterPix()->SetSigmaChargeErr(fCam->GetAverageOuterPix()->GetSigmaChargeErr()
551 *TMath::Sqrt((Float_t)fNumOuterPixels));
552
553 return kTRUE;
554}
555
556void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist,
557 MCalibrationChargePix &pix,
558 MBadPixelsPix &bad)
559{
560
561 if (hist.IsEmpty())
562 {
563 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
564 return;
565 }
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 pix.SetHiGainFitted();
578 if (!hist.FitGaus())
579 //
580 // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
581 //
582 if (!hist.RepeatFit())
583 {
584 hist.BypassFit();
585 pix.SetHiGainFitted(kFALSE);
586 bad.SetHiGainNotFitted();
587 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
588 }
589 else
590 pix.SetHiGainFitted();
591
592 //
593 // 4) Check for pickup
594 //
595 hist.CountPickup();
596
597 //
598 // 5) Check for oscillations
599 //
600 hist.CreateFourierSpectrum();
601
602 //
603 // 6) Retrieve the results and store them in this class
604 //
605 pix.SetHiGainMeanCharge( hist.GetMean() );
606 pix.SetHiGainMeanChargeErr( hist.GetMeanErr() );
607 pix.SetHiGainSigmaCharge( hist.GetSigma() );
608 pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
609 pix.SetHiGainChargeProb ( hist.GetProb() );
610
611 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
612 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
613
614 pix.SetHiGainNumPickup ( hist.GetPickup() );
615
616 if (!hist.IsFourierSpectrumOK())
617 {
618 bad.SetHiGainOscillating();
619 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
620 }
621}
622
623
624void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist,
625 MCalibrationChargePix &pix,
626 MBadPixelsPix &bad)
627{
628
629 if (hist.IsEmpty())
630 {
631 if (pix.IsHiGainSaturation())
632 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
633 return;
634 }
635
636 if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
637 {
638 pix.SetLoGainSaturation();
639 bad.SetLoGainSaturation();
640 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
641 return;
642 }
643
644 //
645 // 2) Fit the Lo Gain histograms with a Gaussian
646 //
647 pix.SetLoGainFitted();
648 if (!hist.FitGaus())
649 //
650 // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
651 //
652 if (!hist.RepeatFit())
653 {
654 hist.BypassFit();
655 pix.SetLoGainFitted(kFALSE);
656 bad.SetLoGainNotFitted();
657 if (pix.IsHiGainSaturation())
658 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
659 }
660
661 //
662 // 4) Check for pickup
663 //
664 hist.CountPickup();
665
666 //
667 // 5) Check for oscillations
668 //
669 hist.CreateFourierSpectrum();
670
671 //
672 // 6) Retrieve the results and store them in this class
673 //
674 pix.SetLoGainMeanCharge( hist.GetMean() );
675 pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );
676 pix.SetLoGainSigmaCharge( hist.GetSigma() );
677 pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );
678 pix.SetLoGainChargeProb ( hist.GetProb() );
679
680 if (pix.IsHiGainSaturation())
681 {
682 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
683 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
684 }
685
686 pix.SetLoGainNumPickup ( hist.GetPickup() );
687
688 if (!hist.IsFourierSpectrumOK())
689 {
690 bad.SetLoGainOscillating();
691 if (pix.IsHiGainSaturation())
692 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
693 }
694}
695
696Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
697{
698 return kTRUE;
699}
700
701// --------------------------------------------------------------------------
702//
703// What MHCamera needs in order to draw an individual pixel in the camera
704//
705void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
706{
707
708 if (idx == -1)
709 fAverageHiGainInnerPix->DrawClone();
710 if (idx == -2)
711 fAverageHiGainOuterPix->DrawClone();
712 if (idx == -3)
713 fAverageLoGainInnerPix->DrawClone();
714 if (idx == -4)
715 fAverageLoGainOuterPix->DrawClone();
716 (*this)[idx].DrawClone();
717
718}
719
720
721void MHCalibrationChargeCam::Draw(const Option_t *opt)
722{
723
724 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
725 pad->SetBorderMode(0);
726
727 pad->Divide(2,2);
728
729 pad->cd(1);
730
731 if (!fAverageHiGainInnerPix->IsEmpty())
732 gPad->SetLogy();
733 fAverageHiGainInnerPix->Draw(opt);
734
735 pad->cd(2);
736
737 if (!fAverageLoGainInnerPix->IsEmpty())
738 gPad->SetLogy();
739 fAverageLoGainInnerPix->Draw(opt);
740
741 pad->cd(3);
742
743 if (!fAverageHiGainOuterPix->IsEmpty())
744 gPad->SetLogy();
745 fAverageHiGainOuterPix->Draw(opt);
746
747 pad->cd(4);
748
749 if (!fAverageLoGainOuterPix->IsEmpty())
750 gPad->SetLogy();
751 fAverageLoGainOuterPix->Draw(opt);
752
753}
Note: See TracBrowser for help on using the repository browser.