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

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