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

Last change on this file since 3570 was 3560, checked in by gaug, 21 years ago
*** empty log message ***
File size: 25.7 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#include <TText.h>
68#include <TPaveText.h>
69
70#include "MLog.h"
71#include "MLogManip.h"
72
73#include "MParList.h"
74
75#include "MHCalibrationChargeHiGainPix.h"
76#include "MHCalibrationChargeLoGainPix.h"
77#include "MHCalibrationChargePix.h"
78
79#include "MCalibrationChargeCam.h"
80#include "MCalibrationChargePix.h"
81
82#include "MGeomCam.h"
83#include "MGeomPix.h"
84
85#include "MBadPixelsCam.h"
86#include "MBadPixelsPix.h"
87
88#include "MRawEvtData.h"
89#include "MRawEvtPixelIter.h"
90
91#include "MExtractedSignalCam.h"
92#include "MExtractedSignalPix.h"
93
94ClassImp(MHCalibrationChargeCam);
95
96using namespace std;
97
98const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.005;
99const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
100//
101//
102//
103MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
104 : fRawEvt(NULL), fGeom(NULL), fBadPixels(NULL)
105{
106 fName = name ? name : "MHCalibrationChargeCam";
107 fTitle = title ? title : "Class to fill the calibration histograms ";
108
109 fHiGainArray = new TObjArray;
110 fHiGainArray->SetOwner();
111
112 fLoGainArray = new TObjArray;
113 fLoGainArray->SetOwner();
114
115 fAverageHiGainInnerPix = new MHCalibrationChargeHiGainPix("AverageHiGainInnerPix","Average HiGain FADC sums of inner pixels");
116 fAverageLoGainInnerPix = new MHCalibrationChargeLoGainPix("AverageLoGainInnerPix","Average LoGain FADC sums of inner pixels");
117 fAverageHiGainOuterPix = new MHCalibrationChargeHiGainPix("AverageHiGainOuterPix","Average HiGain FADC sums of outer pixels");
118 fAverageLoGainOuterPix = new MHCalibrationChargeLoGainPix("AverageLoGainOuterPix","Average LoGain FADC sums of outer pixels");
119
120/*
121 fAverageHiGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerHiGainPix");
122 fAverageHiGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterHiGainPix");
123 fAverageLoGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerLoGainPix");
124 fAverageLoGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterLoGainPix");
125*/
126 fAverageHiGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels HiGain");
127 fAverageLoGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels LoGain");
128 fAverageHiGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels HiGain");
129 fAverageLoGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels LoGain");
130
131 fAverageHiGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels HiGain");
132 fAverageLoGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels LoGain");
133 fAverageHiGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels HiGain");
134 fAverageLoGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels LoGain");
135
136 fAverageHiGainInnerPix->SetChargeFirst(-1000.);
137 fAverageHiGainOuterPix->SetChargeFirst(-1000.);
138
139 fAverageHiGainInnerPix->SetChargeLast(4000.);
140 fAverageLoGainInnerPix->SetChargeLast(4000.);
141 fAverageHiGainOuterPix->SetChargeLast(4000.);
142 fAverageLoGainOuterPix->SetChargeLast(4000.);
143
144 fAverageHiGainInnerPix->SetChargeNbins(4000);
145 fAverageLoGainInnerPix->SetChargeNbins(4000);
146 fAverageHiGainOuterPix->SetChargeNbins(4000);
147 fAverageLoGainOuterPix->SetChargeNbins(4000);
148
149 SetNumHiGainSaturationLimit();
150 SetNumLoGainSaturationLimit();
151
152 fNumInnerPixels = 0;
153 fNumOuterPixels = 0;
154 fNumExcluded = 0;
155
156 fAverageInnerSat = 0;
157 fAverageOuterSat = 0;
158 fAverageInnerPixSigma = 0.;
159 fAverageOuterPixSigma = 0.;
160 fAverageInnerPixSigmaErr = 0.;
161 fAverageOuterPixSigmaErr = 0.;
162 fAverageInnerPixRelSigma = 0.;
163 fAverageOuterPixRelSigma = 0.;
164 fAverageInnerPixRelSigmaErr = 0.;
165 fAverageOuterPixRelSigmaErr = 0.;
166
167}
168
169// --------------------------------------------------------------------------
170//
171// Delete the TClonesArray of MHCalibrationChargePix containers
172// Delete the MHCalibrationPINDiode and the MHCalibrationBlindPix
173//
174// Delete the histograms if they exist
175//
176MHCalibrationChargeCam::~MHCalibrationChargeCam()
177{
178 delete fHiGainArray;
179 delete fLoGainArray;
180
181 delete fAverageHiGainInnerPix;
182 delete fAverageLoGainInnerPix;
183 delete fAverageHiGainOuterPix;
184 delete fAverageLoGainOuterPix;
185
186}
187
188// --------------------------------------------------------------------------
189//
190// Get i-th pixel (pixel number)
191//
192MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i)
193{
194 return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
195}
196
197// --------------------------------------------------------------------------
198//
199// Get i-th pixel (pixel number)
200//
201const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i) const
202{
203 return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
204}
205
206// --------------------------------------------------------------------------
207//
208// Get i-th pixel (pixel number)
209//
210MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i)
211{
212 return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
213}
214
215// --------------------------------------------------------------------------
216//
217// Get i-th pixel (pixel number)
218//
219const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i) const
220{
221 return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
222}
223
224
225#if 0
226// --------------------------------------------------------------------------
227//
228// Our own clone function is necessary since root 3.01/06 or Mars 0.4
229// I don't know the reason
230//
231TObject *MHCalibrationChargeCam::Clone(const char *) const
232{
233
234 const Int_t nhi = fHiGainArray->GetSize();
235 const Int_t nlo = fLoGainArray->GetSize();
236 //
237 // FIXME, this might be done faster and more elegant, by direct copy.
238 //
239 MHCalibrationChargeCam *cam = (MHCalibrationChargeCam*)(this)->Clone("");
240// MHCalibrationChargeCam cam;
241// Copy(*cam);
242
243/*
244 cam->fHiGainArray->Delete();
245 cam->fLoGainArray->Delete();
246
247 cam->fHiGainArray->Expand(nhi);
248 cam->fLoGainArray->Expand(nlo);
249
250 for (int i=0; i<nhi; i++)
251 {
252 delete (*cam->fHiGainArray)[i];
253 (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
254 }
255 for (int i=0; i<nlo; i++)
256 {
257 delete (*cam->fLoGainArray)[i];
258 (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
259 }
260*/
261
262/*
263 delete cam->fAverageHiGainInnerPix;
264 delete cam->fAverageLoGainInnerPix;
265 delete cam->fAverageHiGainOuterPix;
266 delete cam->fAverageLoGainOuterPix;
267
268 cam->GetAverageHiGainInnerPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainInnerPix->Clone();
269 cam->GetAverageLoGainInnerPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainInnerPix->Clone();
270
271 cam->GetAverageHiGainOuterPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainOuterPix->Clone();
272 cam->GetAverageLoGainOuterPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainOuterPix->Clone();
273
274 fAverageHiGainInnerPix->Copy(cam->GetAverageHiGainInnerPix());
275 fAverageLoGainInnerPix->Copy(cam->GetAverageLoGainInnerPix());
276 fAverageHiGainOuterPix->Copy(cam->GetAverageHiGainOuterPix());
277 fAverageLoGainOuterPix->Copy(cam->GetAverageLoGainOuterPix());
278*/
279
280 return cam;
281}
282#endif
283// --------------------------------------------------------------------------
284//
285// To setup the object we get the number of pixels from a MGeomCam object
286// in the Parameter list.
287//
288Bool_t MHCalibrationChargeCam::SetupFill(const MParList *pList)
289{
290
291 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
292 if (!fRawEvt)
293 {
294 *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
295 return kFALSE;
296 }
297
298 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
299 if (!fGeom)
300 {
301 *fLog << err << "MGeomCam not found... aborting." << endl;
302 return kFALSE;
303 }
304
305 fHiGainArray->Delete();
306 fLoGainArray->Delete();
307
308 fAverageHiGainInnerPix->Init();
309 fAverageLoGainInnerPix->Init();
310 fAverageHiGainOuterPix->Init();
311 fAverageLoGainOuterPix->Init();
312
313 return kTRUE;
314}
315
316Bool_t MHCalibrationChargeCam::ReInit(MParList *pList)
317{
318
319 fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
320 if (!fBadPixels)
321 return kFALSE;
322
323
324 fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
325 if (!fCam)
326 return kFALSE;
327
328 MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
329 if (!signal)
330 {
331 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
332 return kFALSE;
333 }
334
335 const Int_t n = signal->GetSize();
336
337 if (fHiGainArray->GetEntries()==0)
338 {
339 fHiGainArray->Expand(n);
340
341 for (Int_t i=0; i<n; i++)
342 {
343 //
344 // Oscillating pixels
345 //
346 (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
347
348 if ((*fBadPixels)[i].IsBad())
349 {
350 fNumExcluded++;
351 (*this)[i].SetExcluded();
352 }
353 (*this)[i].Init();
354 (*this)[i].ChangeHistId(i);
355 }
356 }
357
358
359 if (fLoGainArray->GetEntries()==0)
360 {
361 fLoGainArray->Expand(n);
362
363 for (Int_t i=0; i<n; i++)
364 {
365 (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
366 //
367 // Pixels with non-valid behavior
368 //
369 if ((*fBadPixels)[i].IsBad())
370 (*this)(i).SetExcluded();
371
372 (*this)(i).Init();
373 (*this)(i).ChangeHistId(i);
374 }
375 }
376
377
378 *fLog << inf << GetDescriptor() << ": " << fNumExcluded << " excluded Pixels " << endl;
379
380 return kTRUE;
381}
382
383
384// --------------------------------------------------------------------------
385Bool_t MHCalibrationChargeCam::Fill(const MParContainer *par, const Stat_t w)
386{
387
388 MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
389 if (!signal)
390 {
391 *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
392 return kFALSE;
393 }
394
395 Int_t n = signal->GetSize();
396 Int_t lofirst = signal->GetFirstUsedSliceLoGain();
397
398 if (fHiGainArray->GetEntries() != n)
399 {
400 *fLog << err << "ERROR - Size mismatch... abort." << endl;
401 return kFALSE;
402 }
403
404 if (fLoGainArray->GetEntries() != n)
405 {
406 *fLog << err << "ERROR - Size mismatch... abort." << endl;
407 return kFALSE;
408 }
409
410 //
411 // First the extracted signal
412 //
413 Float_t sumhiinnertot = 0.;
414 Float_t sumloinnertot = 0.;
415 Float_t sumhioutertot = 0.;
416 Float_t sumlooutertot = 0.;
417 Int_t sumhiinnersat = 0;
418 Int_t sumloinnersat = 0;
419 Int_t sumhioutersat = 0;
420 Int_t sumlooutersat = 0;
421
422 fNumInnerPixels = fNumOuterPixels = 0;
423
424 for (int i=0; i<n; i++)
425 {
426
427 if ((*this)[i].IsExcluded())
428 continue;
429
430 const MExtractedSignalPix &pix = (*signal)[i];
431
432 const Float_t sumhi = pix.GetExtractedSignalHiGain();
433 const Float_t sumlo = pix.GetExtractedSignalLoGain();
434
435 (*this)[i].FillHistAndArray(sumhi);
436 (*this)(i).FillHistAndArray(sumlo);
437
438 const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
439 const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
440
441 (*this)[i].SetSaturated(sathi);
442 (*this)(i).SetSaturated(satlo);
443
444 if (fGeom->GetPixRatio(i) == 1.)
445 {
446 sumhiinnertot += sumhi;
447 sumloinnertot += sumlo;
448 sumhiinnersat += sathi;
449 sumloinnersat += satlo;
450 fNumInnerPixels++;
451 }
452 else
453 {
454 sumhioutertot += sumhi;
455 sumlooutertot += sumlo;
456 sumhioutersat += sathi;
457 sumlooutersat += satlo;
458 fNumOuterPixels++;
459 }
460
461 }
462
463 fAverageHiGainInnerPix->FillHistAndArray(sumhiinnertot/fNumInnerPixels);
464 fAverageLoGainInnerPix->FillHistAndArray(sumloinnertot/fNumInnerPixels);
465 fAverageHiGainOuterPix->FillHistAndArray(sumhioutertot/fNumOuterPixels);
466 fAverageLoGainOuterPix->FillHistAndArray(sumlooutertot/fNumOuterPixels);
467
468 fAverageHiGainInnerPix->SetSaturated((Float_t)sumhiinnersat/fNumInnerPixels);
469 fAverageLoGainInnerPix->SetSaturated((Float_t)sumloinnersat/fNumInnerPixels);
470 fAverageHiGainOuterPix->SetSaturated((Float_t)sumhioutersat/fNumOuterPixels);
471 fAverageLoGainOuterPix->SetSaturated((Float_t)sumlooutersat/fNumOuterPixels);
472
473 //
474 // Now the times
475 //
476 sumhiinnertot = sumloinnertot = sumhioutertot = sumlooutertot = 0.;
477 fNumInnerPixels = fNumOuterPixels = 0;
478
479 MRawEvtPixelIter pixel(fRawEvt);
480 while (pixel.Next())
481 {
482
483 const UInt_t pixid = pixel.GetPixelId();
484
485 if ((*this)[pixid].IsExcluded())
486 continue;
487
488 const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
489 const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
490
491 (*this)[pixid].FillAbsTime(timehi);
492 (*this)(pixid).FillAbsTime(timelo);
493
494 if (fGeom->GetPixRatio(pixel.GetPixelId()) == 1.)
495 {
496 sumhiinnertot += timehi;
497 sumloinnertot += timelo;
498 fNumInnerPixels++;
499 }
500 else
501 {
502 sumhioutertot += timehi;
503 sumlooutertot += timelo;
504 fNumOuterPixels++;
505 }
506 }
507
508 fAverageHiGainInnerPix-> FillAbsTime(sumhiinnertot/fNumInnerPixels);
509 fAverageLoGainInnerPix-> FillAbsTime(sumloinnertot/fNumInnerPixels);
510 fAverageHiGainOuterPix-> FillAbsTime(sumhioutertot/fNumOuterPixels);
511 fAverageLoGainOuterPix-> FillAbsTime(sumlooutertot/fNumOuterPixels);
512
513 return kTRUE;
514}
515
516// --------------------------------------------------------------------------
517//
518// 1) Return if the charge distribution is already succesfully fitted
519// or if the histogram is empty
520// 2) Fit the histograms with a Gaussian
521// 3) In case of failure set the bit kFitted to false and take histogram means and RMS
522// 4) Check for pickup noise
523// 5) Check the fourier spectrum
524// 5) Retrieve the results and store them in this class
525//
526Bool_t MHCalibrationChargeCam::Finalize()
527{
528
529 for (int i=0; i<fHiGainArray->GetSize(); i++)
530 {
531
532 MCalibrationChargePix &pix = (*fCam)[i];
533 MHCalibrationChargeHiGainPix &histhi = (*this)[i];
534 MBadPixelsPix &bad = (*fBadPixels)[i];
535
536 FinalizeHiGainHists(histhi,pix,bad);
537
538 }
539
540 for (int i=0; i<fLoGainArray->GetSize(); i++)
541 {
542
543 if ((*this)(i).IsExcluded())
544 continue;
545
546 MHCalibrationChargeLoGainPix &histlo = (*this)(i);
547 MCalibrationChargePix &pix = (*fCam)[i];
548 MBadPixelsPix &bad = (*fBadPixels)[i];
549
550 FinalizeLoGainHists(histlo,pix,bad);
551
552 }
553
554 FinalizeHiGainHists(*fAverageHiGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
555 FinalizeLoGainHists(*fAverageLoGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
556 FinalizeHiGainHists(*fAverageHiGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
557 FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
558
559 FinalizeAveragePix(*fCam->GetAverageInnerPix(),fNumInnerPixels,
560 fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
561 fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr,
562 fAverageInnerSat);
563 FinalizeAveragePix(*fCam->GetAverageOuterPix(),fNumOuterPixels,
564 fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
565 fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr,
566 fAverageOuterSat);
567
568 return kTRUE;
569}
570
571void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist,
572 MCalibrationChargePix &pix,
573 MBadPixelsPix &bad)
574{
575
576 if (hist.IsEmpty())
577 {
578 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
579 return;
580 }
581
582 if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries())
583 {
584 pix.SetHiGainSaturation();
585 bad.SetHiGainSaturation();
586 return;
587 }
588
589 //
590 // 2) Fit the Hi Gain histograms with a Gaussian
591 //
592 if (!hist.FitGaus())
593 //
594 // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
595 //
596 if (!hist.RepeatFit())
597 {
598 hist.BypassFit();
599 bad.SetHiGainNotFitted();
600 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
601 }
602
603 //
604 // 4) Check for pickup
605 //
606 hist.CountPickup();
607
608 //
609 // 5) Check for oscillations
610 //
611 hist.CreateFourierSpectrum();
612
613 //
614 // 6) Retrieve the results and store them in this class
615 //
616 pix.SetHiGainMeanCharge( hist.GetMean() );
617 pix.SetHiGainMeanChargeErr( hist.GetMeanErr() );
618 pix.SetHiGainSigmaCharge( hist.GetSigma() );
619 pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
620 pix.SetHiGainChargeProb ( hist.GetProb() );
621
622 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
623 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
624
625 pix.SetHiGainNumPickup ( hist.GetPickup() );
626
627 if (!hist.IsFourierSpectrumOK())
628 {
629 bad.SetHiGainOscillating();
630 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
631 }
632}
633
634
635void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist,
636 MCalibrationChargePix &pix,
637 MBadPixelsPix &bad)
638{
639
640 if (hist.IsEmpty())
641 {
642 if (pix.IsHiGainSaturation())
643 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
644 return;
645 }
646
647 if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
648 {
649 pix.SetLoGainSaturation();
650 bad.SetLoGainSaturation();
651 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
652 return;
653 }
654
655 //
656 // 2) Fit the Lo Gain histograms with a Gaussian
657 //
658 if (!hist.FitGaus())
659 //
660 // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
661 //
662 if (!hist.RepeatFit())
663 {
664 hist.BypassFit();
665 bad.SetLoGainNotFitted();
666 if (pix.IsHiGainSaturation())
667 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
668 }
669
670 //
671 // 4) Check for pickup
672 //
673 hist.CountPickup();
674
675 //
676 // 5) Check for oscillations
677 //
678 hist.CreateFourierSpectrum();
679
680 //
681 // 6) Retrieve the results and store them in this class
682 //
683 pix.SetLoGainMeanCharge( hist.GetMean() );
684 pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );
685 pix.SetLoGainSigmaCharge( hist.GetSigma() );
686 pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );
687 pix.SetLoGainChargeProb ( hist.GetProb() );
688
689 if (pix.IsHiGainSaturation())
690 {
691 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
692 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
693 }
694
695 pix.SetLoGainNumPickup ( hist.GetPickup() );
696
697 if (!hist.IsFourierSpectrumOK())
698 {
699 bad.SetLoGainOscillating();
700 if (pix.IsHiGainSaturation())
701 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
702 }
703}
704
705void MHCalibrationChargeCam::FinalizeAveragePix(MCalibrationChargePix &pix, Int_t npix,
706 Float_t &sigma, Float_t &sigmaerr,
707 Float_t &relsigma, Float_t &relsigmaerr,
708 Bool_t &b)
709{
710
711 if (pix.IsHiGainSaturation())
712 b = kTRUE;
713
714 sigma = pix.GetSigmaCharge () * TMath::Sqrt((Float_t)npix);
715 sigmaerr = pix.GetSigmaChargeErr () * TMath::Sqrt((Float_t)npix);
716
717 relsigma = sigma / pix.GetMeanCharge();
718
719 relsigmaerr = sigmaerr*sigmaerr / sigma / sigma;
720 relsigmaerr += pix.GetMeanChargeErr()*pix.GetMeanChargeErr() / pix.GetMeanCharge() / pix.GetMeanCharge();
721
722 relsigmaerr *= relsigma;
723 relsigmaerr = TMath::Sqrt(relsigmaerr);
724
725 pix.SetSigmaCharge (sigma);
726 pix.SetSigmaChargeErr(sigmaerr);
727
728}
729
730
731Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
732{
733 return kTRUE;
734}
735
736// --------------------------------------------------------------------------
737//
738// What MHCamera needs in order to draw an individual pixel in the camera
739//
740void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
741{
742
743 if (idx == -1)
744 fAverageHiGainInnerPix->DrawClone();
745 if (idx == -2)
746 fAverageHiGainOuterPix->DrawClone();
747 if (idx == -3)
748 fAverageLoGainInnerPix->DrawClone();
749 if (idx == -4)
750 fAverageLoGainOuterPix->DrawClone();
751 (*this)[idx].DrawClone();
752
753}
754
755
756void MHCalibrationChargeCam::Draw(const Option_t *opt)
757{
758
759 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
760 pad->SetBorderMode(0);
761
762 pad->Divide(2,2);
763
764 pad->cd(1);
765
766 fAverageHiGainInnerPix->Draw(opt);
767
768 if (!fAverageInnerSat)
769 DrawAverageSigma(fAverageInnerSat, 1,
770 fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
771 fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr);
772
773 pad->cd(2);
774
775 fAverageLoGainInnerPix->Draw(opt);
776
777 if (fAverageInnerSat)
778 DrawAverageSigma(fAverageInnerSat, 1,
779 fAverageInnerPixSigma, fAverageInnerPixSigmaErr,
780 fAverageInnerPixRelSigma, fAverageInnerPixRelSigmaErr);
781
782 pad->cd(3);
783
784 fAverageHiGainOuterPix->Draw(opt);
785
786 if (!fAverageOuterSat)
787 DrawAverageSigma(fAverageOuterSat, 0,
788 fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
789 fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr);
790
791 pad->cd(4);
792
793 fAverageLoGainOuterPix->Draw(opt);
794
795 if (fAverageOuterSat)
796 DrawAverageSigma(fAverageOuterSat, 0,
797 fAverageOuterPixSigma, fAverageOuterPixSigmaErr,
798 fAverageOuterPixRelSigma, fAverageOuterPixRelSigmaErr);
799}
800
801void MHCalibrationChargeCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
802 Float_t sigma, Float_t sigmaerr,
803 Float_t relsigma, Float_t relsigmaerr) const
804{
805
806 if (sigma != 0)
807 {
808
809 TPad *newpad = new TPad("newpad","transparent",0,0,1,1);
810 newpad->SetFillStyle(4000);
811 newpad->Draw();
812 newpad->cd();
813
814 TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
815 text->SetTextSize(0.07);
816 const TString line1 = Form("%s%s%s",inner ? "Inner" : "Outer",
817 " Pixels ", sat ? "Low Gain" : "High Gain");
818 TText *txt1 = text->AddText(line1.Data());
819 const TString line2 = Form("Sigma per Pixel: %2.2f #pm %2.2f",sigma,sigmaerr);
820 TText *txt2 = text->AddText(line2.Data());
821 const TString line3 = Form("Rel. Sigma per Pixel: %2.2f #pm %2.2f",relsigma,relsigmaerr);
822 TText *txt3 = text->AddText(line3.Data());
823 text->Draw("");
824
825 text->SetBit(kCanDelete);
826 txt1->SetBit(kCanDelete);
827 txt2->SetBit(kCanDelete);
828 txt3->SetBit(kCanDelete);
829 newpad->SetBit(kCanDelete);
830 }
831}
832
Note: See TracBrowser for help on using the repository browser.