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

Last change on this file since 3697 was 3697, checked in by gaug, 21 years ago
*** empty log message ***
File size: 28.2 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;
146const Float_t MHCalibrationChargeCam::fgTimeLowerLimit = 1.;
147const Float_t MHCalibrationChargeCam::fgTimeUpperLimit = 2.;
148// --------------------------------------------------------------------------
149//
150// Default Constructor.
151//
152// Sets:
153// - all pointers to NULL
154//
155// Initializes:
156// - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
157// - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
158// - fTimeLowerLimit to fgTimeLowerLimit
159// - fTimeUpperLimit to fgTimeUpperLimit
160//
161MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
162 : fRawEvt(NULL), fSig(NULL)
163{
164 fName = name ? name : "MHCalibrationChargeCam";
165 fTitle = title ? title : "Class to fill the calibration histograms ";
166
167 SetNumHiGainSaturationLimit();
168 SetNumLoGainSaturationLimit();
169 SetTimeLowerLimit();
170 SetTimeUpperLimit();
171}
172
173// --------------------------------------------------------------------------
174//
175// Gets the pointers to:
176// - MRawEvtData
177// - MExtractedSignalCam
178//
179Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
180{
181
182 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
183 if (!fRawEvt)
184 {
185 *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
186 return kFALSE;
187 }
188
189 MExtractedSignalCam *fSig = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
190 if (!fSig)
191 {
192 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
193 return kFALSE;
194 }
195
196 return kTRUE;
197}
198
199// --------------------------------------------------------------------------
200//
201// Gets or creates the pointers to:
202// - MCalibrationChargeCam
203// - MBadPixelsCam
204//
205// Initializes the number of used FADC slices from MExtractedSignalCam
206// into MCalibrationChargeCam and test for changes in that variable
207//
208// Initializes, if empty to MGeomCam::GetNumPixels():
209// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
210//
211// Initializes, if empty to MGeomCam::GetNumAreas() for:
212// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
213//
214// Initializes, if empty to MGeomCam::GetNumSectors() for:
215// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
216//
217// Calls MHCalibrationCam::InitHists() for every entry in:
218// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
219// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
220// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
221//
222// Sets Titles and Names for the Charge Histograms:
223// - MHCalibrationCam::fAverageHiGainAreas
224// - MHCalibrationCam::fAverageHiGainSectors
225//
226// Sets number of bins to MHCalibrationCam::fAverageNbins for:
227// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
228// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
229//
230Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
231{
232
233 fCam = (MCalibrationCam*)pList->FindObject("MCalibrationChargeCam");
234 if (!fCam)
235 {
236 fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
237 if (!fCam)
238 {
239 gLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
240 return kFALSE;
241 }
242 else
243 fCam->Init(*fGeom);
244 }
245
246 const Float_t numhigain = fSig->GetNumUsedHiGainFADCSlices();
247 const Float_t numlogain = fSig->GetNumUsedLoGainFADCSlices();
248
249 if (fCam->GetNumHiGainFADCSlices() == 0.)
250 fCam->SetNumHiGainFADCSlices ( numhigain );
251 else if (fCam->GetNumHiGainFADCSlices() != numhigain)
252 {
253 *fLog << err << GetDescriptor()
254 << ": Number of High Gain FADC extraction slices has changes, abort..." << endl;
255 return kFALSE;
256 }
257
258 if (fCam->GetNumLoGainFADCSlices() == 0.)
259 fCam->SetNumLoGainFADCSlices ( numlogain );
260 else if (fCam->GetNumLoGainFADCSlices() != numlogain)
261 {
262 *fLog << err << GetDescriptor()
263 << ": Number of Low Gain FADC extraction slices has changes, abort..." << endl;
264 return kFALSE;
265 }
266
267 const Int_t npixels = fGeom->GetNumPixels();
268 const Int_t nsectors = fGeom->GetNumSectors();
269 const Int_t nareas = fGeom->GetNumAreas();
270
271 if (fHiGainArray->GetEntries()==0)
272 {
273 fHiGainArray->Expand(npixels);
274 for (Int_t i=0; i<npixels; i++)
275 {
276 (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
277 InitHists((*this)[i],(*fBadPixels)[i],i);
278 }
279 }
280
281 if (fLoGainArray->GetEntries()==0)
282 {
283 fLoGainArray->Expand(npixels);
284
285 for (Int_t i=0; i<npixels; i++)
286 {
287 (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
288 InitHists((*this)(i),(*fBadPixels)[i],i);
289 }
290
291 }
292
293 if (fAverageHiGainAreas->GetEntries()==0)
294 {
295 fAverageHiGainAreas->Expand(nareas);
296
297 for (Int_t j=0; j<nareas; j++)
298 {
299 (*fAverageHiGainAreas)[j] =
300 new MHCalibrationChargeHiGainPix("AverageHiGainArea",
301 "Average HiGain FADC sums area idx ");
302
303 InitHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j);
304
305 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
306
307 hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Area Idx ");
308 hist.SetNbins(fAverageNbins);
309 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
310 }
311 }
312
313 if (fAverageLoGainAreas->GetEntries()==0)
314 {
315 fAverageLoGainAreas->Expand(nareas);
316
317 for (Int_t j=0; j<nareas; j++)
318 {
319 (*fAverageLoGainAreas)[j] =
320 new MHCalibrationChargeLoGainPix("AverageLoGainArea",
321 "Average LoGain FADC sums of pixel area idx ");
322
323 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
324
325 InitHists(hist,fCam->GetAverageBadArea(j),j);
326
327 hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Area Idx ");
328 hist.SetNbins(fAverageNbins);
329 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
330
331 }
332 }
333
334 if (fAverageHiGainSectors->GetEntries()==0)
335 {
336 fAverageHiGainSectors->Expand(nsectors);
337
338 for (Int_t j=0; j<nsectors; j++)
339 {
340 (*fAverageHiGainSectors)[j] =
341 new MHCalibrationChargeHiGainPix("AverageHiGainSector",
342 "Average HiGain FADC sums of pixel sector ");
343
344 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
345
346 InitHists(hist,fCam->GetAverageBadSector(j),j);
347
348 hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
349 hist.SetNbins(fAverageNbins);
350 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
351
352 }
353 }
354
355 if (fAverageLoGainSectors->GetEntries()==0)
356 {
357 fAverageLoGainSectors->Expand(nsectors);
358
359 for (Int_t j=0; j<nsectors; j++)
360 {
361 (*fAverageLoGainSectors)[j] =
362 new MHCalibrationChargeLoGainPix("AverageLoGainSector",
363 "Average LoGain FADC sums of pixel sector ");
364
365 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
366
367 InitHists(hist,fCam->GetAverageBadSector(j),j);
368
369 hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
370 hist.SetNbins(fAverageNbins);
371 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
372
373 }
374 }
375
376 return kTRUE;
377}
378
379
380// --------------------------------------------------------------------------
381//
382// Retrieves from MExtractedSignalCam:
383// - first used LoGain FADC slice
384//
385// Retrieves from MGeomCam:
386// - number of pixels
387// - number of pixel areas
388// - number of sectors
389//
390// For all TObjArray's (including the averaged ones), the following steps are performed:
391//
392// 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
393// - MExtractedSignalPix::GetExtractedSignalHiGain();
394// - MExtractedSignalPix::GetExtractedSignalLoGain();
395//
396// 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
397// - MExtractedSignalPix::GetNumHiGainSaturated();
398// - MExtractedSignalPix::GetNumLoGainSaturated();
399//
400// 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
401// - MRawEvtPixelIter::GetIdxMaxHiGainSample();
402// - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
403//
404Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
405{
406
407 MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
408 if (!signal)
409 {
410 *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
411 return kFALSE;
412 }
413
414 const UInt_t npixels = fGeom->GetNumPixels();
415 const UInt_t nareas = fGeom->GetNumAreas();
416 const UInt_t nsectors = fGeom->GetNumSectors();
417 const UInt_t lofirst = signal->GetFirstUsedSliceLoGain();
418
419 Float_t sumhiarea [nareas], sumloarea [nareas], timehiarea [nareas], timeloarea [nareas];
420 Float_t sumhisector[nsectors], sumlosector[nsectors], timehisector[nsectors], timelosector[nsectors];
421 Int_t sathiarea [nareas], satloarea [nareas];
422 Int_t sathisector[nsectors], satlosector[nsectors];
423
424 memset(sumhiarea, 0, nareas * sizeof(Float_t));
425 memset(sumloarea, 0, nareas * sizeof(Float_t));
426 memset(timehiarea, 0, nareas * sizeof(Float_t));
427 memset(timeloarea, 0, nareas * sizeof(Float_t));
428 memset(sathiarea, 0, nareas * sizeof(Int_t ));
429 memset(satloarea, 0, nareas * sizeof(Int_t ));
430 memset(sumhisector, 0, nsectors*sizeof(Float_t));
431 memset(sumlosector, 0, nsectors*sizeof(Float_t));
432 memset(timehisector,0, nsectors*sizeof(Float_t));
433 memset(timelosector,0, nsectors*sizeof(Float_t));
434 memset(sathisector, 0, nsectors*sizeof(Int_t ));
435 memset(satlosector, 0, nsectors*sizeof(Int_t ));
436
437 for (UInt_t i=0; i<npixels; i++)
438 {
439
440 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
441 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
442
443 if (histhi.IsExcluded())
444 continue;
445
446 const MExtractedSignalPix &pix = (*signal)[i];
447
448 const Float_t sumhi = pix.GetExtractedSignalHiGain();
449 const Float_t sumlo = pix.GetExtractedSignalLoGain();
450
451 histhi.FillHistAndArray(sumhi);
452 histlo.FillHistAndArray(sumlo);
453
454 const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
455 const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
456
457 histhi.SetSaturated(sathi);
458 histlo.SetSaturated(satlo);
459
460 const Int_t aidx = (*fGeom)[i].GetAidx();
461 const Int_t sector = (*fGeom)[i].GetSector();
462
463 sumhiarea[aidx] += sumhi;
464 sumloarea[aidx] += sumlo;
465 sathiarea[aidx] += sathi;
466 satloarea[aidx] += satlo;
467
468 sumhisector[sector] += sumhi;
469 sumlosector[sector] += sumlo;
470 sathisector[sector] += sathi;
471 satlosector[sector] += satlo;
472 }
473
474 MRawEvtPixelIter pixel(fRawEvt);
475 while (pixel.Next())
476 {
477
478 const UInt_t pixid = pixel.GetPixelId();
479
480 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
481 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
482
483 if (histhi.IsExcluded())
484 continue;
485
486 const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
487 const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
488
489 histhi.FillAbsTime(timehi);
490 histlo.FillAbsTime(timelo);
491
492 const Int_t aidx = (*fGeom)[pixid].GetAidx();
493 const Int_t sector = (*fGeom)[pixid].GetSector();
494
495 timehiarea[aidx] += timehi;
496 timeloarea[aidx] += timelo;
497
498 timehisector[sector] += timehi;
499 timelosector[sector] += timelo;
500 }
501
502 for (UInt_t j=0; j<nareas; j++)
503 {
504
505 const Int_t npix = fAverageAreaNum[j];
506
507 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
508 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
509
510 hipix.FillHistAndArray(sumhiarea[j]/npix);
511 lopix.FillHistAndArray(sumloarea[j]/npix);
512
513 hipix.SetSaturated((Float_t)sathiarea[j]/npix);
514 lopix.SetSaturated((Float_t)satloarea[j]/npix);
515
516 hipix.FillAbsTime(timehiarea[j]/npix);
517 lopix.FillAbsTime(timeloarea[j]/npix);
518
519 }
520
521 for (UInt_t j=0; j<nsectors; j++)
522 {
523
524 const Int_t npix = fAverageSectorNum[j];
525
526 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
527 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
528
529 hipix.FillHistAndArray(sumhisector[j]/npix);
530 lopix.FillHistAndArray(sumlosector[j]/npix);
531
532 hipix.SetSaturated((Float_t)sathisector[j]/npix);
533 lopix.SetSaturated((Float_t)satlosector[j]/npix);
534
535 hipix.FillAbsTime(timehisector[j]/npix);
536 lopix.FillAbsTime(timelosector[j]/npix);
537
538 }
539
540 return kTRUE;
541}
542
543// --------------------------------------------------------------------------
544//
545// For all TObjArray's (including the averaged ones), the following steps are performed:
546//
547// 1) Returns if the pixel is excluded.
548// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
549// or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
550// 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
551// MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
552// otherwise the Hi-Gain ones.
553// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
554// with the flags:
555// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
556// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
557// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
558// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
559//
560Bool_t MHCalibrationChargeCam::FinalizeHists()
561{
562
563 const Byte_t firsthi = fSig->GetFirstUsedSliceHiGain();
564 const Byte_t lasthi = fSig->GetLastUsedSliceHiGain();
565 const Byte_t firstlo = fSig->GetFirstUsedSliceLoGain();
566 const Byte_t lastlo = fSig->GetLastUsedSliceLoGain();
567
568
569 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
570 {
571
572 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
573 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
574 MBadPixelsPix &bad = (*fBadPixels)[i];
575
576 if (histhi.IsExcluded())
577 continue;
578
579 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
580 {
581 pix.SetHiGainSaturation();
582 histhi.CreateFourierSpectrum();
583 continue;
584 }
585
586 FinalizeAbsTimes(histhi, pix, bad, firsthi, lasthi);
587 }
588
589 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
590 {
591
592 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
593 MBadPixelsPix &bad = (*fBadPixels)[i];
594
595 if (histlo.IsExcluded())
596 continue;
597
598 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
599 {
600 *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
601 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
602 histlo.CreateFourierSpectrum();
603 continue;
604 }
605
606 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
607
608 if (pix.IsHiGainSaturation())
609 FinalizeAbsTimes(histlo, pix, bad, firstlo, lastlo);
610 }
611
612 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
613 {
614
615 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
616 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
617 MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
618
619 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
620 {
621 pix.SetHiGainSaturation();
622 histhi.CreateFourierSpectrum();
623 continue;
624 }
625
626 FinalizeAbsTimes(histhi, pix, bad, firsthi, lasthi);
627 }
628
629 for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
630 {
631
632 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
633 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
634 MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
635
636 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
637 {
638 *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
639 histlo.CreateFourierSpectrum();
640 continue;
641 }
642
643 if (pix.IsHiGainSaturation())
644 FinalizeAbsTimes(histlo, pix, bad, firstlo, lastlo);
645 }
646
647 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
648 {
649
650 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
651 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
652 MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
653
654 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
655 {
656 pix.SetHiGainSaturation();
657 histhi.CreateFourierSpectrum();
658 continue;
659 }
660
661 FinalizeAbsTimes(histhi, pix, bad, firsthi, lasthi);
662 }
663
664 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
665 {
666
667 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
668 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
669 MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
670
671 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
672 {
673 *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
674 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
675 histlo.CreateFourierSpectrum();
676 continue;
677 }
678
679 if (pix.IsHiGainSaturation())
680 FinalizeAbsTimes(histlo, pix, bad, firstlo, lastlo);
681 }
682
683 //
684 // Perform the fitting for the High Gain (done in MHCalibrationCam)
685 //
686 FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
687 MBadPixelsPix::kHiGainNotFitted,
688 MBadPixelsPix::kHiGainOscillating);
689 //
690 // Perform the fitting for the Low Gain (done in MHCalibrationCam)
691 //
692 FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
693 MBadPixelsPix::kLoGainNotFitted,
694 MBadPixelsPix::kLoGainOscillating);
695
696 return kTRUE;
697}
698
699// --------------------------------------------------------------------------------
700//
701// Fill the absolute time results into MCalibrationChargePix
702//
703// Check absolute time validity:
704// - Mean arrival time is at least fTimeLowerLimit slices from the lower edge
705// - Mean arrival time is at least fUpperLimit slices from the upper edge
706//
707void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
708 Byte_t first, Byte_t last)
709{
710
711 const Float_t mean = hist.GetAbsTimeMean();
712 const Float_t rms = hist.GetAbsTimeRms();
713
714 pix.SetAbsTimeMean ( mean );
715 pix.SetAbsTimeRms ( rms );
716
717 const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
718 const Float_t upperlimit = (Float_t)last + fTimeUpperLimit;
719
720 if ( mean < lowerlimit)
721 {
722 *fLog << warn << GetDescriptor()
723 << Form("%s%3.1f%s%2i%s%4i",": Mean ArrivalTime: ",mean," smaller than ",fTimeLowerLimit,
724 " FADC slices from lower edge in pixel ",hist.GetPixId()) << endl;
725 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
726 }
727
728 if ( mean > upperlimit )
729 {
730 *fLog << warn << GetDescriptor()
731 << Form("%s%3.1f%s%2i%s%4i",": Mean ArrivalTime: ",mean," greater than ",fTimeUpperLimit,
732 " FADC slices from upper edge in pixel ",hist.GetPixId()) << endl;
733 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
734 }
735}
736
737// --------------------------------------------------------------------------
738//
739// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
740// - MBadPixelsPix::kLoGainSaturation
741//
742// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
743// - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
744// - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
745// - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
746// - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
747//
748void MHCalibrationChargeCam::FinalizeBadPixels()
749{
750
751 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
752 {
753
754 MBadPixelsPix &bad = (*fBadPixels)[i];
755 MCalibrationPix &pix = (*fCam)[i];
756
757 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
758 if (!pix.IsHiGainSaturation())
759 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
760
761 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
762 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
763
764 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
765 if (pix.IsHiGainSaturation())
766 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
767
768 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
769 if (pix.IsHiGainSaturation())
770 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
771
772 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
773 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
774 }
775}
776
777// --------------------------------------------------------------------------
778//
779// Dummy, needed by MCamEvent
780//
781Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
782{
783 return kTRUE;
784}
785
786// --------------------------------------------------------------------------
787//
788// Calls MHGausEvents::DrawClone() for pixel idx
789//
790void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
791{
792 (*this)[idx].DrawClone();
793}
794
Note: See TracBrowser for help on using the repository browser.