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

Last change on this file since 3650 was 3650, checked in by gaug, 21 years ago
*** empty log message ***
File size: 25.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! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24/////////////////////////////////////////////////////////////////////////////
25//
26// MHCalibrationChargeCam
27//
28// Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes
29// MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
30//
31// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and
32// MHCalibrationCam::fLoGainArray
33//
34// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
35// stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
36// MHCalibrationCam::fAverageLoGainAreas
37//
38// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
39// stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and
40// MHCalibrationCam::fAverageLoGainSectors
41//
42// Every signal is taken from MExtractedSignalCam and filled into a histogram and
43// an array, in order to perform a Fourier analysis (see MHGausEvents).
44// The signals are moreover averaged on an event-by-event basis and written into
45// the corresponding average pixels.
46//
47// Additionally, the (FADC slice) position of the maximum is stored in an Absolute
48// Arrival Time histogram. This histogram serves for a rough cross-check if the
49// signal does not lie at or outside the edges of the extraction window.
50//
51// The Charge histograms are fitted to a Gaussian, mean and sigma with its errors
52// and the fit probability are extracted. If none of these values are NaN's and
53// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
54// the fit is declared valid.
55// Otherwise, the fit is repeated within ranges of the previous mean
56// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
57// In case this does not make the fit valid, the histogram means and RMS's are
58// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
59// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or
60// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
61// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
62//
63// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas
64// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup)
65//
66// Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
67// slices show saturation, the following flag is set:
68// - MCalibrationChargePix::SetHiGainSaturation();
69// In that case, the calibration constants are derived from the low-gain results.
70//
71// If more than fNumLoGainSaturationLimit (default: 1%) of the overall
72// low-gain FADC slices saturate, the following flags are set:
73// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
74// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun )
75//
76// The class also fills arrays with the signal vs. event number, creates a fourier
77// spectrum and investigates if the projected fourier components follow an exponential
78// distribution. In case that the probability of the exponential fit is less than
79// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
80// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
81// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
82// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
83//
84// This same procedure is performed for the average pixels.
85//
86// The following results are written into MCalibrationChargeCam:
87//
88// - MCalibrationPix::SetHiGainSaturation()
89// - MCalibrationPix::SetHiGainMean()
90// - MCalibrationPix::SetHiGainMeanErr()
91// - MCalibrationPix::SetHiGainSigma()
92// - MCalibrationPix::SetHiGainSigmaErr()
93// - MCalibrationPix::SetHiGainProb()
94// - MCalibrationPix::SetHiGainNumPickup()
95//
96// - MCalibrationPix::SetLoGainMean()
97// - MCalibrationPix::SetLoGainMeanErr()
98// - MCalibrationPix::SetLoGainSigma()
99// - MCalibrationPix::SetLoGainSigmaErr()
100// - MCalibrationPix::SetLoGainProb()
101// - MCalibrationPix::SetLoGainNumPickup()
102//
103// - MCalibrationChargePix::SetAbsTimeMean()
104// - MCalibrationChargePix::SetAbsTimeRms()
105//
106// For all averaged areas, the fitted sigma is multiplied with the square root of
107// the number involved pixels in order to be able to compare it to the average of
108// sigmas in the camera.
109//
110/////////////////////////////////////////////////////////////////////////////
111#include "MHCalibrationChargeCam.h"
112#include "MHCalibrationCam.h"
113
114#include "MLog.h"
115#include "MLogManip.h"
116
117#include "MParList.h"
118
119#include "MHCalibrationChargeHiGainPix.h"
120#include "MHCalibrationChargeLoGainPix.h"
121#include "MHCalibrationChargePix.h"
122
123#include "MCalibrationChargeCam.h"
124#include "MCalibrationChargePix.h"
125
126#include "MGeomCam.h"
127#include "MGeomPix.h"
128
129#include "MHGausEvents.h"
130
131#include "MBadPixelsCam.h"
132#include "MBadPixelsPix.h"
133
134#include "MRawEvtData.h"
135#include "MRawEvtPixelIter.h"
136
137#include "MExtractedSignalCam.h"
138#include "MExtractedSignalPix.h"
139
140ClassImp(MHCalibrationChargeCam);
141
142using namespace std;
143
144const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
145const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
146// --------------------------------------------------------------------------
147//
148// Default Constructor.
149//
150// Sets:
151// - all pointers to NULL
152//
153// Initializes:
154// - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
155// - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
156//
157MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
158 : fRawEvt(NULL)
159{
160 fName = name ? name : "MHCalibrationChargeCam";
161 fTitle = title ? title : "Class to fill the calibration histograms ";
162
163 SetNumHiGainSaturationLimit();
164 SetNumLoGainSaturationLimit();
165}
166
167// --------------------------------------------------------------------------
168//
169// Gets the pointers to:
170// - MRawEvtData
171//
172Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
173{
174
175 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
176 if (!fRawEvt)
177 {
178 *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
179 return kFALSE;
180 }
181
182 return kTRUE;
183}
184
185// --------------------------------------------------------------------------
186//
187// Gets or creates the pointers to:
188// - MCalibrationChargeCam
189//
190// Searches pointer to:
191// - MExtractedSignalCam
192//
193// Initializes, if empty to MGeomCam::GetNumPixels():
194// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
195//
196// Initializes, if empty to MGeomCam::GetNumAreas() for:
197// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
198//
199// Initializes, if empty to MGeomCam::GetNumSectors() for:
200// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
201//
202// Calls MHCalibrationCam::InitHists() for every entry in:
203// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
204// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
205// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
206//
207// Sets Titles and Names for the Charge Histograms:
208// - MHCalibrationCam::fAverageHiGainAreas
209// - MHCalibrationCam::fAverageHiGainSectors
210//
211// Sets number of bins to MHCalibrationCam::fAverageNbins for:
212// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
213// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
214//
215Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
216{
217
218 const Int_t npixels = fGeom->GetNumPixels();
219 const Int_t nsectors = fGeom->GetNumSectors();
220 const Int_t nareas = fGeom->GetNumAreas();
221
222 fCam = (MCalibrationCam*)pList->FindObject("MCalibrationChargeCam");
223 if (!fCam)
224 {
225 fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
226 if (!fCam)
227 {
228 gLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
229 return kFALSE;
230 }
231 else
232 {
233 fCam->InitSize(npixels);
234 fCam->InitAverageAreas(nareas);
235 fCam->InitAverageSectors(nsectors);
236 }
237 }
238
239 MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
240 if (!signal)
241 {
242 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
243 return kFALSE;
244 }
245
246 if (fHiGainArray->GetEntries()==0)
247 {
248 fHiGainArray->Expand(npixels);
249 for (Int_t i=0; i<npixels; i++)
250 {
251 (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
252 InitHists((*this)[i],(*fBadPixels)[i],i);
253 }
254 }
255
256 if (fLoGainArray->GetEntries()==0)
257 {
258 fLoGainArray->Expand(npixels);
259
260 for (Int_t i=0; i<npixels; i++)
261 {
262 (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
263 InitHists((*this)(i),(*fBadPixels)[i],i);
264 }
265
266 }
267
268 if (fAverageHiGainAreas->GetEntries()==0)
269 {
270 fAverageHiGainAreas->Expand(nareas);
271
272 for (Int_t j=0; j<nareas; j++)
273 {
274 (*fAverageHiGainAreas)[j] =
275 new MHCalibrationChargeHiGainPix("AverageHiGainArea",
276 "Average HiGain FADC sums area idx ");
277
278 InitHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j);
279
280 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
281
282 hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Area Idx ");
283 hist.SetNbins(fAverageNbins);
284 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
285 }
286 }
287
288 if (fAverageLoGainAreas->GetEntries()==0)
289 {
290 fAverageLoGainAreas->Expand(nareas);
291
292 for (Int_t j=0; j<nareas; j++)
293 {
294 (*fAverageLoGainAreas)[j] =
295 new MHCalibrationChargeLoGainPix("AverageLoGainArea",
296 "Average LoGain FADC sums of pixel area idx ");
297
298 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
299
300 InitHists(hist,fCam->GetAverageBadArea(j),j);
301
302 hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Area Idx ");
303 hist.SetNbins(fAverageNbins);
304 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
305
306 }
307 }
308
309 if (fAverageHiGainSectors->GetEntries()==0)
310 {
311 fAverageHiGainSectors->Expand(nsectors);
312
313 for (Int_t j=0; j<nsectors; j++)
314 {
315 (*fAverageHiGainSectors)[j] =
316 new MHCalibrationChargeHiGainPix("AverageHiGainSector",
317 "Average HiGain FADC sums of pixel sector ");
318
319 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
320
321 InitHists(hist,fCam->GetAverageBadSector(j),j);
322
323 hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
324 hist.SetNbins(fAverageNbins);
325 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
326
327 }
328 }
329
330 if (fAverageLoGainSectors->GetEntries()==0)
331 {
332 fAverageLoGainSectors->Expand(nsectors);
333
334 for (Int_t j=0; j<nsectors; j++)
335 {
336 (*fAverageLoGainSectors)[j] =
337 new MHCalibrationChargeLoGainPix("AverageLoGainSector",
338 "Average LoGain FADC sums of pixel sector ");
339
340 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
341
342 InitHists(hist,fCam->GetAverageBadSector(j),j);
343
344 hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
345 hist.SetNbins(fAverageNbins);
346 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
347
348 }
349 }
350
351 return kTRUE;
352}
353
354
355// --------------------------------------------------------------------------
356//
357// Retrieves from MExtractedSignalCam:
358// - first used LoGain FADC slice
359//
360// Retrieves from MGeomCam:
361// - number of pixels
362// - number of pixel areas
363// - number of sectors
364//
365// For all TObjArray's (including the averaged ones), the following steps are performed:
366//
367// 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
368// - MExtractedSignalPix::GetExtractedSignalHiGain();
369// - MExtractedSignalPix::GetExtractedSignalLoGain();
370//
371// 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
372// - MExtractedSignalPix::GetNumHiGainSaturated();
373// - MExtractedSignalPix::GetNumLoGainSaturated();
374//
375// 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
376// - MRawEvtPixelIter::GetIdxMaxHiGainSample();
377// - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
378//
379Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
380{
381
382 MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
383 if (!signal)
384 {
385 *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
386 return kFALSE;
387 }
388
389 const Int_t npixels = fGeom->GetNumPixels();
390 const Int_t nareas = fGeom->GetNumAreas();
391 const Int_t nsectors = fGeom->GetNumSectors();
392 const Int_t lofirst = signal->GetFirstUsedSliceLoGain();
393
394 Float_t sumhiarea [nareas], sumloarea [nareas], timehiarea [nareas], timeloarea [nareas];
395 Float_t sumhisector[nsectors], sumlosector[nsectors], timehisector[nsectors], timelosector[nsectors];
396 Int_t sathiarea [nareas], satloarea [nareas];
397 Int_t sathisector[nsectors], satlosector[nsectors];
398
399 for (UInt_t j=0; j<nareas; j++)
400 {
401 sumhiarea [j] = sumloarea [j] = timehiarea [j] = timeloarea [j] = 0.;
402 sathiarea [j] = satloarea [j] = 0;
403 }
404
405 for (UInt_t j=0; j<nsectors; j++)
406 {
407 sumhisector[j] = sumlosector[j] = timehisector[j] = timelosector[j] = 0.;
408 sathisector[j] = satlosector[j] = 0;
409 }
410
411
412 for (Int_t i=0; i<npixels; i++)
413 {
414
415 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
416 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
417
418 if (histhi.IsExcluded())
419 continue;
420
421 const MExtractedSignalPix &pix = (*signal)[i];
422
423 const Float_t sumhi = pix.GetExtractedSignalHiGain();
424 const Float_t sumlo = pix.GetExtractedSignalLoGain();
425
426 histhi.FillHistAndArray(sumhi);
427 histlo.FillHistAndArray(sumlo);
428
429 const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
430 const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
431
432 histhi.SetSaturated(sathi);
433 histlo.SetSaturated(satlo);
434
435 const Int_t aidx = (*fGeom)[i].GetAidx();
436 const Int_t sector = (*fGeom)[i].GetSector();
437
438 sumhiarea[aidx] += sumhi;
439 sumloarea[aidx] += sumlo;
440 sathiarea[aidx] += sathi;
441 satloarea[aidx] += satlo;
442
443 sumhisector[sector] += sumhi;
444 sumlosector[sector] += sumlo;
445 sathisector[sector] += sathi;
446 satlosector[sector] += satlo;
447 }
448
449 MRawEvtPixelIter pixel(fRawEvt);
450 while (pixel.Next())
451 {
452
453 const UInt_t pixid = pixel.GetPixelId();
454
455 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
456 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
457
458 if (histhi.IsExcluded())
459 continue;
460
461 const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
462 const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
463
464 histhi.FillAbsTime(timehi);
465 histlo.FillAbsTime(timelo);
466
467 const Int_t aidx = (*fGeom)[pixid].GetAidx();
468 const Int_t sector = (*fGeom)[pixid].GetSector();
469
470 timehiarea[aidx] += timehi;
471 timeloarea[aidx] += timelo;
472
473 timehisector[sector] += timehi;
474 timelosector[sector] += timelo;
475 }
476
477 for (UInt_t j=0; j<nareas; j++)
478 {
479
480 const Int_t npix = fAverageAreaNum[j];
481
482 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
483 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
484
485 hipix.FillHistAndArray(sumhiarea[j]/npix);
486 lopix.FillHistAndArray(sumloarea[j]/npix);
487
488 hipix.SetSaturated((Float_t)sathiarea[j]/npix);
489 lopix.SetSaturated((Float_t)satloarea[j]/npix);
490
491 hipix.FillAbsTime(timehiarea[j]/npix);
492 lopix.FillAbsTime(timeloarea[j]/npix);
493
494 }
495
496 for (UInt_t j=0; j<nsectors; j++)
497 {
498
499 const Int_t npix = fAverageSectorNum[j];
500
501 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
502 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
503
504 hipix.FillHistAndArray(sumhisector[j]/npix);
505 lopix.FillHistAndArray(sumlosector[j]/npix);
506
507 hipix.SetSaturated((Float_t)sathisector[j]/npix);
508 lopix.SetSaturated((Float_t)satlosector[j]/npix);
509
510 hipix.FillAbsTime(timehisector[j]/npix);
511 lopix.FillAbsTime(timelosector[j]/npix);
512
513 }
514
515 return kTRUE;
516}
517
518// --------------------------------------------------------------------------
519//
520// For all TObjArray's (including the averaged ones), the following steps are performed:
521//
522// 1) Returns if the pixel is excluded.
523// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
524// or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
525// 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
526// MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
527// otherwise the Hi-Gain ones.
528// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
529// with the flags:
530// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
531// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
532// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
533// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
534//
535Bool_t MHCalibrationChargeCam::FinalizeHists()
536{
537
538 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
539 {
540
541 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
542 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
543
544 if (histhi.IsExcluded())
545 continue;
546
547 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
548 {
549 pix.SetHiGainSaturation();
550 histhi.CreateFourierSpectrum();
551 continue;
552 }
553
554 pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
555 pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
556 }
557
558 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
559 {
560
561 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
562 MBadPixelsPix &bad = (*fBadPixels)[i];
563
564 if (histlo.IsExcluded())
565 continue;
566
567 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
568 {
569 *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
570 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
571 histlo.CreateFourierSpectrum();
572 continue;
573 }
574
575 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
576
577 if (pix.IsHiGainSaturation())
578 {
579 pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
580 pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
581 }
582 }
583
584 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
585 {
586
587 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
588 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
589
590 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
591 {
592 pix.SetHiGainSaturation();
593 histhi.CreateFourierSpectrum();
594 continue;
595 }
596
597 pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
598 pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
599 }
600
601 for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
602 {
603
604 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
605 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
606
607 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
608 {
609 *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
610 histlo.CreateFourierSpectrum();
611 continue;
612 }
613
614 if (pix.IsHiGainSaturation())
615 {
616 pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
617 pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
618 }
619 }
620
621 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
622 {
623
624 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
625 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
626
627 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
628 {
629 pix.SetHiGainSaturation();
630 histhi.CreateFourierSpectrum();
631 continue;
632 }
633
634 pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
635 pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
636 }
637
638 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
639 {
640
641 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
642 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
643 MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
644
645 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
646 {
647 *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
648 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
649 histlo.CreateFourierSpectrum();
650 continue;
651 }
652
653 if (pix.IsHiGainSaturation())
654 {
655 pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
656 pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
657 }
658 }
659
660 //
661 // Perform the fitting for the High Gain (done in MHCalibrationCam)
662 //
663 FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
664 MBadPixelsPix::kHiGainNotFitted,
665 MBadPixelsPix::kHiGainOscillating);
666 //
667 // Perform the fitting for the Low Gain (done in MHCalibrationCam)
668 //
669 FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
670 MBadPixelsPix::kLoGainNotFitted,
671 MBadPixelsPix::kLoGainOscillating);
672
673 return kTRUE;
674}
675
676// --------------------------------------------------------------------------
677//
678// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
679// - MBadPixelsPix::kLoGainSaturation
680//
681// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
682// - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
683// - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
684// - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
685// - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
686//
687void MHCalibrationChargeCam::FinalizeBadPixels()
688{
689
690 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
691 {
692
693 MBadPixelsPix &bad = (*fBadPixels)[i];
694 MCalibrationPix &pix = (*fCam)[i];
695
696 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
697 if (!pix.IsHiGainSaturation())
698 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
699
700 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
701 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
702
703 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
704 if (pix.IsHiGainSaturation())
705 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
706
707 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
708 if (pix.IsHiGainSaturation())
709 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
710
711 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
712 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
713 }
714}
715
716// --------------------------------------------------------------------------
717//
718// Dummy, needed by MCamEvent
719//
720Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
721{
722 return kTRUE;
723}
724
725// --------------------------------------------------------------------------
726//
727// Calls MHGausEvents::DrawClone() for pixel idx
728//
729void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
730{
731 (*this)[idx].DrawClone();
732}
733
Note: See TracBrowser for help on using the repository browser.