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

Last change on this file since 3622 was 3622, checked in by gaug, 20 years ago
*** empty log message ***
File size: 27.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//
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 for (UInt_t aidx=0; aidx<fGeom->GetNumAreas(); aidx++)
642 {
643
644 FinalizeAvPedestals(fCam->GetAveragePix(aidx), avinnerped, avinnerprms,avinnernum);
645 FinalizeCharges(fCam->GetAveragePix(aidx),fCam->GetAverageBadPix(aidx));
646 }
647
648 //
649 // F-Factor calibration
650 //
651 if (fCam->CalcMeanFluxPhotonsFFactorMethod(*fGeom, *fBadPixels))
652 {
653 fCam->ApplyFFactorCalibration(*fGeom,*fBadPixels);
654 fCam->SetFFactorMethodValid(kTRUE);
655 }
656 else
657 {
658 *fLog << warn << "Could not calculate the flux of photo-electrons from the F-Factor method, " << endl;
659 fCam->SetFFactorMethodValid(kFALSE);
660 }
661
662 //
663 // Blind Pixel calibration
664 //
665 if (!fBlindPixel->CheckChargeFitValidity())
666 {
667 *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
668 << "charge fit not valid " << endl;
669 fCam->SetBlindPixelMethodValid(kFALSE);
670 }
671 else
672 {
673 if (!fBlindPixel->CalcFluxInsidePlexiglass())
674 {
675 *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
676 << "will skip PIN Diode Calibration " << endl;
677 fCam->SetBlindPixelMethodValid(kFALSE);
678 }
679 else
680 {
681 fCam->SetBlindPixelMethodValid(kTRUE);
682 fCam->ApplyBlindPixelCalibration(*fGeom,*fBadPixels, *fBlindPixel);
683 }
684 }
685
686 //
687 // PIN Diode calibration
688 //
689 if (!fPINDiode->CheckChargeFitValidity() || !fPINDiode->CheckTimeFitValidity())
690 {
691 *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
692 << "charge fit not valid " << endl;
693 fCam->SetPINDiodeMethodValid(kFALSE);
694 }
695 else
696 {
697 if (!fPINDiode->CalcFluxOutsidePlexiglass())
698 {
699 *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
700 << "will skip PIN Diode Calibration " << endl;
701 fCam->SetPINDiodeMethodValid(kFALSE);
702 }
703 else
704 {
705 fCam->SetPINDiodeMethodValid(kTRUE);
706 fCam->ApplyPINDiodeCalibration(*fGeom,*fBadPixels, *fPINDiode);
707 }
708 }
709
710 fCam->SetReadyToSave();
711
712 *fLog << inf << endl;
713 *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
714 *fLog << dec << setfill(' ');
715
716 UInt_t countinner = 0;
717 UInt_t countouter = 0;
718 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
719 {
720 MBadPixelsPix &bad = (*fBadPixels)[i];
721 if (bad.IsOK())
722 {
723 if (fGeom->GetPixRatio(i) == 1.)
724 countinner++;
725 else
726 countouter++;
727 }
728 }
729
730 *fLog << " " << setw(7) << "Successfully calibrated Pixels: "
731 << "Inner: " << countinner << " Outer: " << countouter << endl;
732
733 PrintUnsuitable(MBadPixelsPix::kUnsuitableRun, "Bad Pixels: ");
734 PrintUnsuitable(MBadPixelsPix::kUnreliableRun, "Unreliable Pixels: ");
735
736 *fLog << inf << endl;
737 *fLog << GetDescriptor() << ": Errors statistics:" << endl;
738
739 PrintUncalibrated(MBadPixelsPix::kChargeIsPedestal,
740 Form("%s%2.1f%s","Signal less than ",fChargeLimit," Pedestal RMS: "));
741 PrintUncalibrated(MBadPixelsPix::kChargeErrNotValid,
742 Form("%s%2.1f%s","Signal Error smaller than ",fChargeErrLimit,": "));
743 PrintUncalibrated(MBadPixelsPix::kChargeRelErrNotValid,
744 Form("%s%2.1f%s","Signal Error bigger than ",fChargeRelErrLimit," times Mean Signal: "));
745 PrintUncalibrated(MBadPixelsPix::kChargeSigmaNotValid,
746 "Signal Sigma smaller than Pedestal RMS: ");
747 PrintUncalibrated(MBadPixelsPix::kLoGainSaturation,
748 "Pixels with Low Gain Saturation: ");
749 PrintUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin,
750 Form("%s%2.1f%s","Mean Abs. Arr. Time in First ",fTimeLowerLimit," Bin(s): "));
751 PrintUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins,
752 Form("%s%2.1f%s","Mean Abs. Arr. Time in Last ",fTimeUpperLimit," Bin(s): "));
753 PrintUncalibrated(MBadPixelsPix::kHiGainOscillating,
754 "Pixels with changing Hi Gain signal over time: ");
755 PrintUncalibrated(MBadPixelsPix::kLoGainOscillating,
756 "Pixels with changing Lo Gain signal over time: ");
757 PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,
758 "Pixels with deviating number of phes: ");
759 PrintUncalibrated(MBadPixelsPix::kHiGainNotFitted,
760 "Pixels with unsuccesful Gauss fit to the Hi Gain: ");
761 PrintUncalibrated(MBadPixelsPix::kLoGainNotFitted,
762 "Pixels with unsuccesful Gauss fit to the Lo Gain: ");
763
764 return kTRUE;
765}
766
767void MCalibrationChargeCalc::PrintUnsuitable(MBadPixelsPix::UnsuitableType_t typ, const char *text) const
768{
769
770 UInt_t countinner = 0;
771 UInt_t countouter = 0;
772 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
773 {
774 MBadPixelsPix &bad = (*fBadPixels)[i];
775 if (bad.IsUnsuitable(typ))
776 {
777 if (fGeom->GetPixRatio(i) == 1.)
778 countinner++;
779 else
780 countouter++;
781 }
782 }
783
784 *fLog << " " << setw(7) << text
785 << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
786}
787
788void MCalibrationChargeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const
789{
790
791 UInt_t countinner = 0;
792 UInt_t countouter = 0;
793 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
794 {
795 MBadPixelsPix &bad = (*fBadPixels)[i];
796 if (bad.IsUncalibrated(typ))
797 {
798 if (fGeom->GetPixRatio(i) == 1.)
799 countinner++;
800 else
801 countouter++;
802 }
803 }
804
805 *fLog << " " << setw(7) << text
806 << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
807}
808
Note: See TracBrowser for help on using the repository browser.