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

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