source: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc@ 3602

Last change on this file since 3602 was 3602, checked in by gaug, 21 years ago
*** empty log message ***
File size: 27.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//
27// MCalibrationChargeCalc
28//
29// Task to calculate the calibration conversion factors from the FADC
30// time slices. The integrated time slices have to be delivered by an
31// MExtractedSignalCam. The pedestals by an MPedestalCam.
32//
33// The output container MCalibrationCam holds one entry of type MCalibrationChargePix
34// for every pixel. It is filled in the following way:
35//
36// ProProcess: Initialize MCalibrationCam
37// Initialize pulser light wavelength
38//
39// ReInit: MCalibrationCam::InitSize(NumPixels) is called from MGeomApply (which allocates
40// memory in a TClonesArray of type MCalibrationChargePix)
41// Initializes pointer to MBadPixelsCam
42//
43// Process: Nothing done by this class, histograms are filled by
44// MHCalibrationChargeCam
45//
46// PostProcess: Fit results from MHCalibrationChargeCam are retrieved
47// and used for the calculation of the reduced sigma,
48// the F-Factor method, the blind pixel method (photon flux
49// inside plexiglass) and
50// the PINDiode method (photon flux
51// outside plexiglass)
52//
53// Hi-Gain vs. Lo-Gain Calibration (very memory-intensive)
54// can be skipped with the command:
55// MalibrationCam::SkipHiLoGainCalibration()
56//
57// Input Containers:
58// MRawEvtData
59// MPedestalCam
60// MBadPixelsCam
61//
62// Output Containers:
63// MCalibrationCam
64// MCalibrationQECam
65// MBadPixelsCam
66//
67//
68// Preliminary description of the calibration in photons (email from 12/02/04)
69//
70// Why calibrating in photons:
71// ===========================
72//
73// At the Barcelona meeting in 2002, we decided to calibrate the camera in
74// photons. This for the following reasons:
75//
76// * The physical quantity arriving at the camera are photons. This is
77// the direct physical information from the air shower. The photons
78// have a flux and a spectrum.
79//
80// * The photon fluxes depend mostly on the shower energy (with
81// corrections deriving from the observation conditions), while the photon
82// spectra depend mostly on the observation conditions: zenith angle,
83// quality of the air, also the impact parameter of the shower.
84//
85// * The photomultiplier, in turn, has different response properties
86// (quantum efficiencies) for photons of different colour. (Moreover,
87// different pixels have slightly different quantum efficiencies).
88// The resulting number of photo-electrons is then amplified (linearly)
89// with respect to the photo-electron flux.
90//
91// * In the ideal case, one would like to disentagle the effects
92// of the observation conditions from the primary particle energy (which
93// one likes to measure). To do so, one needs:
94//
95// 1) A reliable calibration relating the FADC counts to the photo-electron
96// flux -> This is accomplished with the F-Factor method.
97//
98// 2) A reliable calibration of the wavelength-dependent quantum efficiency
99// -> This is accomplished with the combination of the three methods,
100// together with QE-measurements performed by David in order to do
101// the interpolation.
102//
103// 3) A reliable calibration of the observation conditions. This means:
104// - Tracing the atmospheric conditions -> LIDAR
105// - Tracing the observation zenith angle -> Drive System
106// 4) Some knowlegde about the impact parameter:
107// - This is the only part which cannot be accomplished well with a
108// single telescope. We would thus need to convolute the spectrum
109// over the distribution of impact parameters.
110//
111//
112// How an ideal calibration would look like:
113// =========================================
114//
115// We know from the combined PIN-Diode and Blind-Pixel Method the response of
116// each pixel to well-measured light fluxes in three representative
117// wavelengths (green, blue, UV). We also know the response to these light
118// fluxes in photo-electrons. Thus, we can derive:
119//
120// - conversion factors to photo-electrons
121// - conversion factors to photons in three wavelengths.
122//
123// Together with David's measurements and some MC-simulation, we should be
124// able to derive tables for typical Cherenkov-photon spectra - convoluted
125// with the impact parameters and depending on the athmospheric conditions
126// and the zenith angle (the "outer parameters").
127//
128// From these tables we can create "calibration tables" containing some
129// effective quantum efficiency depending on these outer parameters and which
130// are different for each pixel.
131//
132// In an ideal MCalibrate, one would thus have to convert first the FADC
133// slices to Photo-electrons and then, depending on the outer parameters,
134// look up the effective quantum efficiency and get the mean number of
135// photons which is then used for the further analysis.
136//
137// How the (first) MAGIC calibration should look like:
138// ===================================================
139//
140// For the moment, we have only one reliable calibration method, although
141// with very large systematic errors. This is the F-Factor method. Knowing
142// that the light is uniform over the whole camera (which I would not at all
143// guarantee in the case of the CT1 pulser), one could in principle already
144// perform a relative calibration of the quantum efficiencies in the UV.
145// However, the spread in QE at UV is about 10-15% (according to the plot
146// that Abelardo sent around last time. The spread in photo-electrons is 15%
147// for the inner pixels, but much larger (40%) for the outer ones.
148//
149// I'm not sure if we can already say that we have measured the relative
150// difference in quantum efficiency for the inner pixels and produce a first
151// QE-table for each pixel. To so, I would rather check in other wavelengths
152// (which we can do in about one-two weeks when the optical transmission of
153// the calibration trigger is installed).
154//
155// Thus, for the moment being, I would join Thomas proposal to calibrate in
156// photo-electrons and apply one stupid average quantum efficiency for all
157// pixels. This keeping in mind that we will have much preciser information
158// in about one to two weeks.
159//
160//
161// What MCalibrate should calculate and what should be stored:
162// ===========================================================
163//
164// It is clear that in the end, MCerPhotEvt will store photons.
165// MCalibrationCam stores the conversionfactors to photo-electrons and also
166// some tables of how to apply the conversion to photons, given the outer
167// parameters. This is not yet implemented and not even discussed.
168//
169// To start, I would suggest that we define the "average quantum efficiency"
170// (maybe something like 25+-3%) and apply them equally to all
171// photo-electrons. Later, this average factor can be easily replaced by a
172// pixel-dependent factor and later by a (pixel-dependent) table.
173//
174//
175//
176//////////////////////////////////////////////////////////////////////////////
177#include "MCalibrationChargeCalc.h"
178
179#include <TSystem.h>
180#include <TH1.h>
181
182#include "MLog.h"
183#include "MLogManip.h"
184
185#include "MParList.h"
186
187#include "MGeomCam.h"
188#include "MRawRunHeader.h"
189#include "MRawEvtPixelIter.h"
190
191#include "MPedestalCam.h"
192#include "MPedestalPix.h"
193
194#include "MCalibrationChargeCam.h"
195#include "MCalibrationChargePix.h"
196#include "MCalibrationChargePINDiode.h"
197#include "MCalibrationChargeBlindPix.h"
198
199#include "MExtractedSignalCam.h"
200#include "MExtractedSignalPix.h"
201
202#include "MBadPixelsCam.h"
203#include "MBadPixelsPix.h"
204
205#include "MCalibrationQECam.h"
206#include "MCalibrationQEPix.h"
207
208
209ClassImp(MCalibrationChargeCalc);
210
211using namespace std;
212
213const Float_t MCalibrationChargeCalc::fgChargeLimit = 3.;
214const Float_t MCalibrationChargeCalc::fgChargeErrLimit = 0.;
215const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit = 1.;
216const Float_t MCalibrationChargeCalc::fgTimeLowerLimit = 1.;
217const Float_t MCalibrationChargeCalc::fgTimeUpperLimit = 2.;
218// --------------------------------------------------------------------------
219//
220// Default constructor.
221//
222MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
223 : fPedestals(NULL), fCam(NULL), fQECam(NULL),
224 fRawEvt(NULL), fRunHeader(NULL), fGeom(NULL),
225 fBadPixels(NULL), fEvtTime(NULL),
226 fSignals(NULL), fPINDiode(NULL), fBlindPixel(NULL)
227{
228
229 fName = name ? name : "MCalibrationChargeCalc";
230 fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
231
232 AddToBranchList("MRawEvtData.fHiGainPixId");
233 AddToBranchList("MRawEvtData.fLoGainPixId");
234 AddToBranchList("MRawEvtData.fHiGainFadcSamples");
235 AddToBranchList("MRawEvtData.fLoGainFadcSamples");
236
237 Clear();
238
239 SetChargeLimit();
240 SetChargeErrLimit();
241
242 SetChargeRelErrLimit();
243 SetTimeLowerLimit();
244 SetTimeUpperLimit();
245}
246
247void MCalibrationChargeCalc::Clear(const Option_t *o)
248{
249
250 SETBIT(fFlags, kUseQualityChecks);
251 SETBIT(fFlags, kHiLoGainCalibration);
252
253 fNumHiGainSamples = 0.;
254 fNumLoGainSamples = 0.;
255 fSqrtHiGainSamples = 0.;
256 fSqrtLoGainSamples = 0.;
257 fConversionHiLo = 0;
258 SkipQualityChecks ( kFALSE );
259 SkipHiLoGainCalibration( kFALSE );
260
261}
262
263
264// --------------------------------------------------------------------------
265//
266// The PreProcess searches for the following input containers:
267// - MRawEvtData
268// - MPedestalCam
269//
270// The following output containers are also searched and created if
271// they were not found:
272//
273// - MCalibrationCam
274// - MCalibrationQECam
275//
276// The following output containers are only searched, but not created
277//
278// - MTime
279//
280Int_t MCalibrationChargeCalc::PreProcess(MParList *pList)
281{
282
283 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
284 if (!fRawEvt)
285 {
286 *fLog << err << "MRawEvtData not found... aborting." << endl;
287 return kFALSE;
288 }
289
290 fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
291 if (!fCam)
292 return kFALSE;
293
294 fQECam = (MCalibrationQECam*)pList->FindCreateObj("MCalibrationQECam");
295 if (!fQECam)
296 return kFALSE;
297
298 fPINDiode = (MCalibrationChargePINDiode*)pList->FindCreateObj("MCalibrationChargePINDiode");
299 if (!fPINDiode)
300 return kFALSE;
301
302 fBlindPixel = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
303 if (!fBlindPixel)
304 return kFALSE;
305
306 fEvtTime = (MTime*)pList->FindObject("MTime");
307
308 fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
309 if (!fPedestals)
310 {
311 *fLog << err << "MPedestalCam not found... aborting" << endl;
312 return kFALSE;
313 }
314
315 fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
316 if (!fSignals)
317 {
318 *fLog << err << "MExtractedSignalCam not found... aborting" << endl;
319 return kFALSE;
320 }
321
322 return kTRUE;
323}
324
325
326// --------------------------------------------------------------------------
327//
328// The ReInit searches for the following input containers:
329// - MRawRunHeader
330// - MGeomCam
331// - MBadPixelsCam
332//
333// It retrieves the following variables from MExtractedSignalCam:
334//
335// fNumHiGainSamples
336// fNumLoGainSamples
337//
338// fFirstUsedSliceHiGain
339// fLastUsedSliceHiGain
340// fFirstUsedSliceLoGain
341// fLastUsedSliceLoGain
342//
343// It defines the PixId of every pixel in MCalibrationChargeCam and MCalibrationQECam
344// It sets all pixels excluded which have the flag fBadBixelsPix::IsBad() set.
345//
346Bool_t MCalibrationChargeCalc::ReInit(MParList *pList )
347{
348
349 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
350 if (!fRunHeader)
351 {
352 *fLog << err << "MRawRunHeader not found... aborting." << endl;
353 return kFALSE;
354 }
355
356 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
357 if (!fGeom)
358 {
359 *fLog << err << "No MGeomCam found... aborting." << endl;
360 return kFALSE;
361 }
362
363 fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
364 if (!fBadPixels)
365 {
366 *fLog << err << "Could not find or create MBadPixelsCam ... aborting." << endl;
367 return kFALSE;
368 }
369
370 fNumHiGainSamples = fSignals->GetNumUsedHiGainFADCSlices();
371 fNumLoGainSamples = fSignals->GetNumUsedLoGainFADCSlices();
372 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
373 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
374
375 UInt_t npixels = fGeom->GetNumPixels();
376
377 for (UInt_t i=0; i<npixels; i++)
378 {
379
380 MCalibrationChargePix &pix = (*fCam) [i];
381 MCalibrationQEPix &pqe = (*fQECam) [i];
382 MBadPixelsPix &bad = (*fBadPixels)[i];
383
384 pix.SetPixId(i);
385 pqe.SetPixId(i);
386
387 if (bad.IsBad())
388 {
389 pix.SetExcluded();
390 pqe.SetExcluded();
391 continue;
392 }
393
394 }
395
396 return kTRUE;
397}
398
399
400Int_t MCalibrationChargeCalc::Process()
401{
402 return kTRUE;
403}
404
405// --------------------------------------------------------------------------
406//
407// Finalize pedestals:
408//
409// * Retrieve pedestal and pedestal RMS from MPedestalPix
410// * Retrieve total entries from MPedestalCam
411// * sum up pedestal and pedestalRMS for the average pixel
412// * set pedestal*number of used samples in MCalibrationChargePix
413// * set pedestal RMS * sqrt of number of used samples in MCalibrationChargePix
414//
415//
416void MCalibrationChargeCalc::FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal,
417 Float_t &avped, Float_t &avrms)
418{
419
420 //
421 // get the pedestals
422 //
423 const Float_t pedes = ped.GetPedestal();
424 const Float_t prms = ped.GetPedestalRms();
425 const Float_t num = TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
426
427 //
428 // Calculate the average pedestal
429 //
430 avped += pedes;
431 avrms += prms;
432
433 //
434 // set them in the calibration camera
435 //
436 if (cal.IsHiGainSaturation())
437 {
438 cal.SetPedestal(pedes* fNumLoGainSamples,
439 prms * fSqrtLoGainSamples,
440 prms * fNumLoGainSamples / num);
441 cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
442 }
443 else
444 {
445 cal.SetPedestal(pedes* fNumHiGainSamples,
446 prms * fSqrtHiGainSamples,
447 prms * fNumHiGainSamples / num);
448 }
449
450}
451
452void MCalibrationChargeCalc::FinalizeAvPedestals(MCalibrationChargePix &cal,
453 Float_t avped, Float_t avrms, Int_t avnum)
454{
455
456 //
457 // set the pedestans in the calibration camera
458 //
459 if (cal.IsHiGainSaturation())
460 {
461 cal.SetPedestal(avped/avnum * fNumLoGainSamples,
462 avrms/avnum * fSqrtLoGainSamples,
463 avrms/avnum * fSqrtLoGainSamples/avnum);
464 cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
465 }
466 else
467 {
468 cal.SetPedestal(avped/avnum * fNumHiGainSamples,
469 avrms/avnum * fSqrtHiGainSamples,
470 avrms/avnum * fSqrtHiGainSamples/avnum);
471 }
472}
473
474//
475// Finalize charges per pixel:
476// * Check chage validity
477// * check absolute time validity
478// * calculate the reduced sigma
479// * caluclate the number of photo-electrons
480//
481//
482Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
483{
484
485 //
486 // The check return kTRUE if:
487 //
488 // 1) Pixel has a fitted charge greater than fChargeLimit*PedRMS
489 // 2) Pixel has a fit error greater than fChargeVarLimit
490 // 3) Pixel has a fitted charge greater its fChargeRelVarLimit times its charge error
491 // 4) Pixel has a charge sigma bigger than its Pedestal RMS
492 //
493 if (cal.GetMeanCharge() < fChargeLimit*cal.GetPedRms())
494 {
495 *fLog << warn << "WARNING: Fitted Charge: " << cal.GetMeanCharge() << " is smaller than "
496 << fChargeLimit << " Pedestal RMS: " << cal.GetPedRms() << " in Pixel " << cal.GetPixId() << endl;
497 bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal);
498 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
499 }
500
501 if (cal.GetMeanChargeErr() < fChargeErrLimit)
502 {
503 *fLog << warn << "WARNING: Sigma of Fitted Charge: " << cal.GetMeanChargeErr() << " is smaller than "
504 << fChargeErrLimit << " in Pixel " << cal.GetPixId() << endl;
505 bad.SetUncalibrated( MBadPixelsPix::kChargeErrNotValid );
506 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
507 }
508
509 if (cal.GetMeanCharge() < fChargeRelErrLimit*cal.GetMeanChargeErr())
510 {
511 *fLog << warn << "WARNING: Fitted Charge: " << cal.GetMeanCharge() << " is smaller than "
512 << fChargeRelErrLimit << "* its error: " << cal.GetMeanChargeErr() << " in Pixel " << cal.GetPixId() << endl;
513 bad.SetUncalibrated( MBadPixelsPix::kChargeRelErrNotValid );
514 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
515 }
516
517 if (cal.GetSigmaCharge() < cal.GetPedRms())
518 {
519 *fLog << warn << "WARNING: Sigma of Fitted Charge: " << cal.GetSigmaCharge()
520 << " smaller than Pedestal RMS: " << cal.GetPedRms() << " in Pixel " << cal.GetPixId() << endl;
521 bad.SetUncalibrated( MBadPixelsPix::kChargeSigmaNotValid );
522 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
523 }
524
525 //
526 // The check returns kTRUE if:
527 //
528 // The mean arrival time is at least 1.0 slices from the lower edge slices and 2 slices from the upper edge
529 //
530 const Byte_t loweredge = cal.IsHiGainSaturation() ? fSignals->GetFirstUsedSliceLoGain()
531 : fSignals->GetFirstUsedSliceHiGain();
532 const Byte_t upperedge = cal.IsHiGainSaturation() ? fSignals->GetLastUsedSliceLoGain()
533 : fSignals->GetLastUsedSliceHiGain();
534
535 const Float_t lowerlimit = (Float_t)loweredge + fTimeLowerLimit;
536 const Float_t upperlimit = (Float_t)upperedge + fTimeUpperLimit;
537
538 if ( cal.GetAbsTimeMean() < lowerlimit)
539 {
540 *fLog << warn << "WARNING: Mean ArrivalTime in first " << fTimeLowerLimit
541 << " extraction bin of the Pixel " << cal.GetPixId() << endl;
542 *fLog << cal.GetAbsTimeMean() << " " << lowerlimit << endl;
543 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
544 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
545 }
546
547 if ( cal.GetAbsTimeMean() > upperlimit )
548 {
549 *fLog << warn << "WARNING: Mean ArrivalTime in last " << fTimeUpperLimit
550 << " two extraction bins of the Pixel " << cal.GetPixId() << endl;
551 *fLog << cal.GetAbsTimeMean() << " " << upperlimit << endl;
552 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
553 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
554 }
555
556 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
557 return kFALSE;
558
559 if (!cal.CalcReducedSigma())
560 {
561 *fLog << warn << GetDescriptor()
562 << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
563 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
564 return kFALSE;
565 }
566
567 if (!cal.CalcFFactorMethod())
568 {
569 *fLog << warn << GetDescriptor()
570 << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
571 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
572 return kFALSE;
573 }
574 return kTRUE;
575}
576
577//
578// * Finalize the pedestals
579// * Do the quality checks
580// * Calculate the reduced sigma
581// * Calculate the F-Factor Method
582//
583Int_t MCalibrationChargeCalc::PostProcess()
584{
585
586 if (GetNumExecutions()==0)
587 return kFALSE;
588
589 //
590 // loop over the pedestal events and check if we have calibration
591 //
592 Int_t nvalid = 0;
593 Float_t avinnerped = 0.;
594 Float_t avinnerprms = 0.;
595 Int_t avinnernum = 0;
596 Float_t avouterped = 0.;
597 Float_t avouterprms = 0.;
598 Int_t avouternum = 0;
599
600 for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
601 {
602
603 MCalibrationChargePix &pix = (*fCam)[pixid];
604 //
605 // Check if the pixel has been excluded from the fits
606 //
607 if (pix.IsExcluded())
608 continue;
609
610 MPedestalPix &ped = (*fPedestals)[pixid];
611 MBadPixelsPix &bad = (*fBadPixels)[pixid];
612
613 if (fGeom->GetPixRatio(pixid) == 1.)
614 {
615 FinalizePedestals(ped,pix,avinnerped,avinnerprms);
616 avinnernum++;
617 }
618 else
619 {
620 FinalizePedestals(ped,pix,avouterped,avouterprms);
621 avouternum++;
622 }
623
624 if (FinalizeCharges(pix,bad))
625 nvalid++;
626 }
627
628 //
629 // The Michele check ...
630 //
631 if (nvalid == 0)
632 {
633 *fLog << err << GetDescriptor() << ": All pixels have non-valid calibration. "
634 << "Did you forget to fill the histograms "
635 << "(filling MHCalibrationChargeCam from MExtractedSignalCam using MFillH) ? " << endl;
636 *fLog << err << GetDescriptor() << ": Or, maybe, you have used a pedestal run "
637 << "instead of a calibration run " << endl;
638 return kFALSE;
639 }
640
641 FinalizeAvPedestals(*fCam->GetAverageInnerPix(), avinnerped, avinnerprms,avinnernum);
642 FinalizeAvPedestals(*fCam->GetAverageOuterPix(), avouterped, avouterprms,avouternum);
643
644 FinalizeCharges(*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
645 FinalizeCharges(*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
646
647 //
648 // F-Factor calibration
649 //
650 if (fCam->CalcMeanFluxPhotonsFFactorMethod(*fGeom, *fBadPixels))
651 {
652 fCam->ApplyFFactorCalibration(*fGeom,*fBadPixels);
653 fCam->SetFFactorMethodValid(kTRUE);
654 }
655 else
656 {
657 *fLog << warn << "Could not calculate the flux of photo-electrons from the F-Factor method, " << endl;
658 fCam->SetFFactorMethodValid(kFALSE);
659 }
660
661 //
662 // Blind Pixel calibration
663 //
664 if (!fBlindPixel->CheckChargeFitValidity())
665 {
666 *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
667 << "charge fit not valid " << endl;
668 fCam->SetBlindPixelMethodValid(kFALSE);
669 }
670 else
671 {
672 if (!fBlindPixel->CalcFluxInsidePlexiglass())
673 {
674 *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
675 << "will skip PIN Diode Calibration " << endl;
676 fCam->SetBlindPixelMethodValid(kFALSE);
677 }
678 else
679 {
680 fCam->SetBlindPixelMethodValid(kTRUE);
681 fCam->ApplyBlindPixelCalibration(*fGeom,*fBadPixels, *fBlindPixel);
682 }
683 }
684
685 //
686 // PIN Diode calibration
687 //
688 if (!fPINDiode->CheckChargeFitValidity() || !fPINDiode->CheckTimeFitValidity())
689 {
690 *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
691 << "charge fit not valid " << endl;
692 fCam->SetPINDiodeMethodValid(kFALSE);
693 }
694 else
695 {
696 if (!fPINDiode->CalcFluxOutsidePlexiglass())
697 {
698 *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
699 << "will skip PIN Diode Calibration " << endl;
700 fCam->SetPINDiodeMethodValid(kFALSE);
701 }
702 else
703 {
704 fCam->SetPINDiodeMethodValid(kTRUE);
705 fCam->ApplyPINDiodeCalibration(*fGeom,*fBadPixels, *fPINDiode);
706 }
707 }
708
709 fCam->SetReadyToSave();
710
711 *fLog << inf << endl;
712 *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
713 *fLog << dec << setfill(' ');
714
715 UInt_t countinner = 0;
716 UInt_t countouter = 0;
717 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
718 {
719 MBadPixelsPix &bad = (*fBadPixels)[i];
720 if (bad.IsOK())
721 {
722 if (fGeom->GetPixRatio(i) == 1.)
723 countinner++;
724 else
725 countouter++;
726 }
727 }
728
729 *fLog << " " << setw(7) << "Successfully calibrated Pixels: "
730 << "Inner: " << countinner << " Outer: " << countouter << endl;
731
732 PrintUnsuitable(MBadPixelsPix::kUnsuitableRun, "Bad Pixels: ");
733 PrintUnsuitable(MBadPixelsPix::kUnreliableRun, "Unreliable Pixels: ");
734
735 *fLog << inf << endl;
736 *fLog << GetDescriptor() << ": Errors statistics:" << endl;
737
738 PrintUncalibrated(MBadPixelsPix::kChargeIsPedestal,
739 Form("%s%2.1f%s","Signal less than ",fChargeLimit," Pedestal RMS: "));
740 PrintUncalibrated(MBadPixelsPix::kChargeErrNotValid,
741 Form("%s%2.1f%s","Signal Error smaller than ",fChargeErrLimit,": "));
742 PrintUncalibrated(MBadPixelsPix::kChargeRelErrNotValid,
743 Form("%s%2.1f%s","Signal Error bigger than ",fChargeRelErrLimit," times Mean Signal: "));
744 PrintUncalibrated(MBadPixelsPix::kChargeSigmaNotValid,
745 "Signal Sigma smaller than Pedestal RMS: ");
746 PrintUncalibrated(MBadPixelsPix::kLoGainSaturation,
747 "Pixels with Low Gain Saturation: ");
748 PrintUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin,
749 Form("%s%2.1f%s","Mean Abs. Arr. Time in First ",fTimeLowerLimit," Bin(s): "));
750 PrintUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins,
751 Form("%s%2.1f%s","Mean Abs. Arr. Time in Last ",fTimeUpperLimit," Bin(s): "));
752 PrintUncalibrated(MBadPixelsPix::kHiGainOscillating,
753 "Pixels with changing Hi Gain signal over time: ");
754 PrintUncalibrated(MBadPixelsPix::kLoGainOscillating,
755 "Pixels with changing Lo Gain signal over time: ");
756 PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,
757 "Pixels with deviating number of phes: ");
758 PrintUncalibrated(MBadPixelsPix::kHiGainNotFitted,
759 "Pixels with unsuccesful Gauss fit to the Hi Gain: ");
760 PrintUncalibrated(MBadPixelsPix::kLoGainNotFitted,
761 "Pixels with unsuccesful Gauss fit to the Lo Gain: ");
762
763 return kTRUE;
764}
765
766void MCalibrationChargeCalc::PrintUnsuitable(MBadPixelsPix::UnsuitableType_t typ, const char *text) const
767{
768
769 UInt_t countinner = 0;
770 UInt_t countouter = 0;
771 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
772 {
773 MBadPixelsPix &bad = (*fBadPixels)[i];
774 if (bad.IsUnsuitable(typ))
775 {
776 if (fGeom->GetPixRatio(i) == 1.)
777 countinner++;
778 else
779 countouter++;
780 }
781 }
782
783 *fLog << " " << setw(7) << text
784 << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
785}
786
787void MCalibrationChargeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const
788{
789
790 UInt_t countinner = 0;
791 UInt_t countouter = 0;
792 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
793 {
794 MBadPixelsPix &bad = (*fBadPixels)[i];
795 if (bad.IsUncalibrated(typ))
796 {
797 if (fGeom->GetPixRatio(i) == 1.)
798 countinner++;
799 else
800 countouter++;
801 }
802 }
803
804 *fLog << " " << setw(7) << text
805 << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
806}
807
Note: See TracBrowser for help on using the repository browser.