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

Last change on this file since 3797 was 3739, checked in by gaug, 21 years ago
*** empty log message ***
File size: 49.6 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 and quantum efficiencies
30// from the fit results to the summed FADC slice distributions delivered by
31// MCalibrationChargeCam, MCalibrationChargePix, MCalibrationChargeBlindPix and
32// MCalibrationChargePINDiode, calculated and filled by MHCalibrationChargeCam,
33// MHCalibrationChargePix, MHCalibrationChargeBlindPix and MHCalibrationChargePINDiode.
34//
35// PreProcess(): Initialize pointers to MCalibrationChargeCam, MCalibrationChargeBlindPix
36// MCalibrationChargePINDiode and MCalibrationQECam
37//
38// Initialize pulser light wavelength
39//
40// ReInit(): MCalibrationCam::InitSize(NumPixels) is called from MGeomApply (which allocates
41// memory in a TClonesArray of type MCalibrationChargePix)
42// Initializes pointer to MBadPixelsCam
43//
44// Process(): Nothing to be done, histograms getting filled by MHCalibrationChargeCam
45//
46// PostProcess(): - FinalizePedestals()
47// - FinalizeCharges()
48// - FinalizeFFactorMethod()
49// - FinalizeBadPixels()
50// - FinalizeBlindPixel()
51// - FinalizePINDiode()
52// - FinalizeFFactorQECam()
53// - FinalizeBlindPixelQECam()
54// - FinalizePINDiodeQECam()
55//
56// Input Containers:
57// MCalibrationChargeCam
58// MCalibrationChargeBlindPix
59// MCalibrationChargePINDiode
60// MCalibrationQECam
61// MPedestalCam
62// MBadPixelsCam
63// MGeomCam
64// MTime
65//
66// Output Containers:
67// MCalibrationChargeCam
68// MCalibrationChargeBlindPix
69// MCalibrationChargePINDiode
70// MCalibrationQECam
71// MBadPixelsCam
72//
73//
74// Preliminary description of the calibration in photons (email from 12/02/04)
75//
76// Why calibrating in photons:
77// ===========================
78//
79// At the Barcelona meeting in 2002, we decided to calibrate the camera in
80// photons. This for the following reasons:
81//
82// * The physical quantity arriving at the camera are photons. This is
83// the direct physical information from the air shower. The photons
84// have a flux and a spectrum.
85//
86// * The photon fluxes depend mostly on the shower energy (with
87// corrections deriving from the observation conditions), while the photon
88// spectra depend mostly on the observation conditions: zenith angle,
89// quality of the air, also the impact parameter of the shower.
90//
91// * The photomultiplier, in turn, has different response properties
92// (quantum efficiencies) for photons of different colour. (Moreover,
93// different pixels have slightly different quantum efficiencies).
94// The resulting number of photo-electrons is then amplified (linearly)
95// with respect to the photo-electron flux.
96//
97// * In the ideal case, one would like to disentagle the effects
98// of the observation conditions from the primary particle energy (which
99// one likes to measure). To do so, one needs:
100//
101// 1) A reliable calibration relating the FADC counts to the photo-electron
102// flux -> This is accomplished with the F-Factor method.
103//
104// 2) A reliable calibration of the wavelength-dependent quantum efficiency
105// -> This is accomplished with the combination of the three methods,
106// together with QE-measurements performed by David in order to do
107// the interpolation.
108//
109// 3) A reliable calibration of the observation conditions. This means:
110// - Tracing the atmospheric conditions -> LIDAR
111// - Tracing the observation zenith angle -> Drive System
112//
113// 4) Some knowlegde about the impact parameter:
114// - This is the only part which cannot be accomplished well with a
115// single telescope. We would thus need to convolute the spectrum
116// over the distribution of impact parameters.
117//
118//
119// How an ideal calibration would look like:
120// =========================================
121//
122// We know from the combined PIN-Diode and Blind-Pixel Method the response of
123// each pixel to well-measured light fluxes in three representative
124// wavelengths (green, blue, UV). We also know the response to these light
125// fluxes in photo-electrons. Thus, we can derive:
126//
127// - conversion factors to photo-electrons
128// - conversion factors to photons in three wavelengths.
129//
130// Together with David's measurements and some MC-simulation, we should be
131// able to derive tables for typical Cherenkov-photon spectra - convoluted
132// with the impact parameters and depending on the athmospheric conditions
133// and the zenith angle (the "outer parameters").
134//
135// From these tables we can create "calibration tables" containing some
136// effective quantum efficiency depending on these outer parameters and which
137// are different for each pixel.
138//
139// In an ideal MCalibrate, one would thus have to convert first the FADC
140// slices to Photo-electrons and then, depending on the outer parameters,
141// look up the effective quantum efficiency and get the mean number of
142// photons which is then used for the further analysis.
143//
144// How the (first) MAGIC calibration should look like:
145// ===================================================
146//
147// For the moment, we have only one reliable calibration method, although
148// with very large systematic errors. This is the F-Factor method. Knowing
149// that the light is uniform over the whole camera (which I would not at all
150// guarantee in the case of the CT1 pulser), one could in principle already
151// perform a relative calibration of the quantum efficiencies in the UV.
152// However, the spread in QE at UV is about 10-15% (according to the plot
153// that Abelardo sent around last time. The spread in photo-electrons is 15%
154// for the inner pixels, but much larger (40%) for the outer ones.
155//
156// I'm not sure if we can already say that we have measured the relative
157// difference in quantum efficiency for the inner pixels and produce a first
158// QE-table for each pixel. To so, I would rather check in other wavelengths
159// (which we can do in about one-two weeks when the optical transmission of
160// the calibration trigger is installed).
161//
162// Thus, for the moment being, I would join Thomas proposal to calibrate in
163// photo-electrons and apply one stupid average quantum efficiency for all
164// pixels. This keeping in mind that we will have much preciser information
165// in about one to two weeks.
166//
167//
168// What MCalibrate should calculate and what should be stored:
169// ===========================================================
170//
171// It is clear that in the end, MCerPhotEvt will store photons.
172// MCalibrationCam stores the conversionfactors to photo-electrons and also
173// some tables of how to apply the conversion to photons, given the outer
174// parameters. This is not yet implemented and not even discussed.
175//
176// To start, I would suggest that we define the "average quantum efficiency"
177// (maybe something like 25+-3%) and apply them equally to all
178// photo-electrons. Later, this average factor can be easily replaced by a
179// pixel-dependent factor and later by a (pixel-dependent) table.
180//
181//
182//
183//////////////////////////////////////////////////////////////////////////////
184#include "MCalibrationChargeCalc.h"
185
186#include <TSystem.h>
187#include <TH1.h>
188
189#include "MLog.h"
190#include "MLogManip.h"
191
192#include "MParList.h"
193
194#include "MRawRunHeader.h"
195#include "MRawEvtPixelIter.h"
196
197#include "MGeomCam.h"
198#include "MGeomPix.h"
199
200#include "MPedestalCam.h"
201#include "MPedestalPix.h"
202
203#include "MCalibrationChargeCam.h"
204#include "MCalibrationChargePix.h"
205#include "MCalibrationChargePINDiode.h"
206#include "MCalibrationChargeBlindPix.h"
207
208#include "MExtractedSignalCam.h"
209#include "MExtractedSignalPix.h"
210#include "MExtractedSignalBlindPixel.h"
211#include "MExtractedSignalPINDiode.h"
212
213#include "MBadPixelsCam.h"
214#include "MBadPixelsPix.h"
215
216#include "MCalibrationQECam.h"
217#include "MCalibrationQEPix.h"
218
219#include "MCalibrationCam.h"
220
221ClassImp(MCalibrationChargeCalc);
222
223using namespace std;
224
225const Float_t MCalibrationChargeCalc::fgChargeLimit = 3.;
226const Float_t MCalibrationChargeCalc::fgChargeErrLimit = 0.;
227const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit = 1.;
228const Float_t MCalibrationChargeCalc::fgLambdaErrLimit = 0.2;
229const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit = 0.2;
230const Float_t MCalibrationChargeCalc::fgPheErrLimit = 5.;
231// --------------------------------------------------------------------------
232//
233// Default constructor.
234//
235// Sets all pointers to NULL
236//
237// Calls AddToBranchList for:
238// - MRawEvtData.fHiGainPixId
239// - MRawEvtData.fLoGainPixId
240// - MRawEvtData.fHiGainFadcSamples
241// - MRawEvtData.fLoGainFadcSamples
242//
243// Initializes:
244// - fChargeLimit to fgChargeLimit
245// - fChargeErrLimit to fgChargeErrLimit
246// - fChargeRelErrLimit to fgChargeRelErrLimit
247// - fLambdaCheckLimit to fgLambdaCheckLimit
248// - fLambdaErrLimit to fgLambdaErrLimit
249// - fPheErrLimit to fgPheErrLimit
250// - fPulserColor to MCalibrationCam::kCT1
251//
252// Calls:
253// - Clear()
254//
255MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
256 : fBadPixels(NULL), fCam(NULL), fBlindPixel(NULL), fPINDiode(NULL),
257 fQECam(NULL), fGeom(NULL), fPedestals(NULL), fEvtTime(NULL)
258 {
259
260 fName = name ? name : "MCalibrationChargeCalc";
261 fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
262
263 AddToBranchList("MRawEvtData.fHiGainPixId");
264 AddToBranchList("MRawEvtData.fLoGainPixId");
265 AddToBranchList("MRawEvtData.fHiGainFadcSamples");
266 AddToBranchList("MRawEvtData.fLoGainFadcSamples");
267
268 SetChargeLimit();
269 SetChargeErrLimit();
270 SetChargeRelErrLimit();
271 SetLambdaCheckLimit();
272 SetLambdaErrLimit();
273 SetPheErrLimit();
274 SetPulserColor(MCalibrationCam::kNONE);
275
276 Clear();
277
278}
279
280// --------------------------------------------------------------------------
281//
282// Sets:
283// - all variables to 0.,
284// - all flags to kFALSE
285//
286void MCalibrationChargeCalc::Clear(const Option_t *o)
287{
288
289 fNumHiGainSamples = 0.;
290 fNumLoGainSamples = 0.;
291 fSqrtHiGainSamples = 0.;
292 fSqrtLoGainSamples = 0.;
293 SkipHiLoGainCalibration( kFALSE );
294}
295
296
297// -----------------------------------------------------------------------------------
298//
299// The following container are searched for and execution aborted if not in MParList:
300// - MPedestalCam
301//
302// The following containers are searched and created if they were not found:
303//
304// - MCalibrationQECam
305// - MBadPixelsCam
306//
307// The following output containers are only searched, but not created. If they
308// cannot be found, the corresponding calibration part is only skipped.
309//
310// - MTime
311//
312Int_t MCalibrationChargeCalc::PreProcess(MParList *pList)
313{
314
315 //
316 // Containers that have to be there.
317 //
318 fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
319 if (!fPedestals)
320 {
321 *fLog << err << "MPedestalCam not found... aborting" << endl;
322 return kFALSE;
323 }
324
325 //
326 // Containers that are created in case that they are not there.
327 //
328 fQECam = (MCalibrationQECam*)pList->FindCreateObj("MCalibrationQECam");
329 if (!fQECam)
330 {
331 *fLog << err << "Cannot find nor create MCalibrationQECam... aborting" << endl;
332 return kFALSE;
333 }
334
335 fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
336 if (!fBadPixels)
337 {
338 *fLog << err << "Could not find or create MBadPixelsCam ... aborting." << endl;
339 return kFALSE;
340 }
341
342
343 fEvtTime = (MTime*)pList->FindObject("MTime");
344
345 //
346 // Check the pulser colour --> FIXME: this solution is only valid until the arrival of the DM's
347 //
348 if (fPulserColor == MCalibrationCam::kNONE)
349 {
350 *fLog << endl;
351 *fLog << err << GetDescriptor()
352 << ": No Pulser colour has been chosen. Since the installation of the IFAE pulser box,"
353 << " you HAVE to provide the LEDs colour, otherwise there is no calibration. " << endl;
354 *fLog << "See e.g. the macro calibration.C " << endl;
355 return kFALSE;
356 }
357
358 return kTRUE;
359}
360
361
362// --------------------------------------------------------------------------
363//
364// Search for the following input containers and abort if not existing:
365// - MGeomCam
366// - MCalibrationChargeCam
367//
368// Search for the following input containers and give a warning if not existing:
369// - MCalibrationChargeBlindPix
370// - MCalibrationChargePINDiode
371//
372// It retrieves the following variables from MCalibrationChargeCam:
373//
374// - fNumHiGainSamples
375// - fNumLoGainSamples
376//
377// It defines the PixId of every pixel in:
378//
379// - MCalibrationChargeCam
380// - MCalibrationQECam
381//
382// It sets all pixels in excluded which have the flag fBadBixelsPix::IsBad() set in:
383//
384// - MCalibrationChargePix
385// - MCalibrationQEPix
386//
387// Sets the pulser colour and tests if it has not changed w.r.t. fPulserColor in:
388//
389// - MCalibrationChargeCam
390// - MCalibrationChargeBlindPix (if existing)
391// - MCalibrationChargePINDiode (if existing)
392//
393Bool_t MCalibrationChargeCalc::ReInit(MParList *pList )
394{
395
396 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
397 if (!fGeom)
398 {
399 *fLog << err << "No MGeomCam found... aborting." << endl;
400 return kFALSE;
401 }
402
403 fCam = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
404 if (!fCam)
405 {
406 *fLog << err << "Cannot find MCalibrationChargeCam... aborting" << endl;
407 *fLog << err << "Maybe you forget to call an MFillH for the MHCalibrationChargeCam before..." << endl;
408 return kFALSE;
409 }
410
411 //
412 // Optional Containers
413 //
414 fBlindPixel = (MCalibrationChargeBlindPix*)pList->FindObject("MCalibrationChargeBlindPix");
415 if (!fBlindPixel)
416 *fLog << warn << GetDescriptor()
417 << ": MCalibrationChargeBlindPix not found... no blind pixel method! " << endl;
418
419 fPINDiode = (MCalibrationChargePINDiode*)pList->FindObject("MCalibrationChargePINDiode");
420 if (!fPINDiode)
421 *fLog << warn << GetDescriptor()
422 << "MCalibrationChargePINDiode not found... no PIN Diode method! " << endl;
423
424
425 //
426 // Initialize the pulser colours
427 //
428 if (fCam->GetPulserColor() == MCalibrationCam::kNONE)
429 {
430 fCam->SetPulserColor( fPulserColor );
431
432 if (fBlindPixel)
433 fBlindPixel->SetColor( fPulserColor );
434
435 if (fPINDiode)
436 fPINDiode->SetColor( fPulserColor );
437 }
438
439 if (fPulserColor != fCam->GetPulserColor())
440 {
441 *fLog << err << GetDescriptor()
442 << ": Pulser colour has changed w.r.t. last file in MCalibrationChargeCam" << endl;
443 *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
444 return kFALSE;
445 }
446
447 if (fBlindPixel)
448 if (fPulserColor != fBlindPixel->GetColor())
449 {
450 *fLog << err << GetDescriptor()
451 << ": Pulser colour has changed w.r.t. last file in MCalibrationChargeBlindPix." << endl;
452 *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
453 return kFALSE;
454 }
455
456 if (fPINDiode)
457 if (fPulserColor != fPINDiode->GetColor())
458 {
459 *fLog << err << GetDescriptor()
460 << ": Pulser colour has changed w.r.t. last file in MCalibrationChargePINDiode." << endl;
461 *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
462 return kFALSE;
463 }
464
465
466 fNumHiGainSamples = fCam->GetNumHiGainFADCSlices();
467 fNumLoGainSamples = fCam->GetNumLoGainFADCSlices();
468 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
469 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
470
471 UInt_t npixels = fGeom->GetNumPixels();
472
473 for (UInt_t i=0; i<npixels; i++)
474 {
475
476 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam) [i];
477 MCalibrationQEPix &pqe = (MCalibrationQEPix&) (*fQECam)[i];
478 MBadPixelsPix &bad = (*fBadPixels)[i];
479
480 pix.SetPixId(i);
481 pqe.SetPixId(i);
482
483 if (bad.IsBad())
484 {
485 pix.SetExcluded();
486 pqe.SetExcluded();
487 continue;
488 }
489
490 }
491
492 return kTRUE;
493}
494
495// ----------------------------------------------------------------------------------
496//
497// Nothing to be done in Process, but have a look at MHCalibrationChargeCam, instead
498//
499Int_t MCalibrationChargeCalc::Process()
500{
501 return kTRUE;
502}
503
504// -----------------------------------------------------------------------
505//
506// Return if number of executions is null.
507//
508// First loop over pixels, average areas and sectors, call:
509// - FinalizePedestals()
510// - FinalizeCharges()
511// for every entry. Count number of valid pixels in loop and return kFALSE
512// if there are none (the "Michele check").
513//
514// Call FinalizeBadPixels()
515//
516// Call FinalizeFFactorMethod() (second and third loop over pixels and areas)
517//
518// Call FinalizeBlindPixel()
519// Call FinalizePINDiode()
520//
521// Call FinalizeFFactorQECam() (fourth loop over pixels and areas)
522// Call FinalizeBlindPixelQECam() (fifth loop over pixels and areas)
523// Call FinalizePINDiodeQECam() (sixth loop over pixels and areas)
524//
525// Call MParContainer::SetReadyToSave() for fCam, fQECam, fBadPixels and
526// fBlindPixel and fPINDiode if they exist
527//
528// Print out some statistics
529//
530Int_t MCalibrationChargeCalc::PostProcess()
531{
532
533 if (GetNumExecutions()==0)
534 return kFALSE;
535
536 if (fPINDiode)
537 if (!fPINDiode->IsValid())
538 {
539 *fLog << warn << GetDescriptor()
540 << ": MCalibrationChargePINDiode is declared not valid... no PIN Diode method! " << endl;
541 fPINDiode = NULL;
542 }
543
544 if (fBlindPixel)
545 if (!fBlindPixel->IsValid())
546 {
547 *fLog << warn << GetDescriptor()
548 << ": MCalibrationChargeBlindPix is declared not valid... no Blind Pixel method! " << endl;
549 fBlindPixel = NULL;
550 }
551
552 //
553 // First loop over pixels, call FinalizePedestals and FinalizeCharges
554 //
555 Int_t nvalid = 0;
556
557 for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
558 {
559
560 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid];
561 //
562 // Check if the pixel has been excluded from the fits
563 //
564 if (pix.IsExcluded())
565 continue;
566
567 MPedestalPix &ped = (*fPedestals)[pixid];
568 MBadPixelsPix &bad = (*fBadPixels)[pixid];
569
570 FinalizePedestals(ped,pix);
571
572 if (FinalizeCharges(pix,bad))
573 nvalid++;
574 }
575
576 //
577 // The Michele check ...
578 //
579 if (nvalid == 0)
580 {
581 *fLog << err << GetDescriptor() << ": All pixels have non-valid calibration. "
582 << "Did you forget to fill the histograms "
583 << "(filling MHCalibrationChargeCam from MExtractedSignalCam using MFillH) ? " << endl;
584 *fLog << err << GetDescriptor() << ": Or, maybe, you have used a pedestal run "
585 << "instead of a calibration run " << endl;
586 return kFALSE;
587 }
588
589 for (UInt_t aidx=0; aidx<fGeom->GetNumAreas(); aidx++)
590 {
591
592 const MPedestalPix &ped = fPedestals->GetAverageArea(aidx);
593 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
594
595 FinalizePedestals(ped,pix);
596 FinalizeCharges(pix, fCam->GetAverageBadArea(aidx));
597 }
598
599 for (UInt_t sector=0; sector<fGeom->GetNumSectors(); sector++)
600 {
601
602 const MPedestalPix &ped = fPedestals->GetAverageSector(sector);
603 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
604
605 FinalizePedestals(ped,pix);
606 FinalizeCharges(pix, fCam->GetAverageBadSector(sector));
607 }
608
609 //
610 // Finalize Bad Pixels
611 //
612 FinalizeBadPixels();
613
614 //
615 // Finalize F-Factor method
616 //
617 if (!FinalizeFFactorMethod())
618 {
619 *fLog << warn << "Could not calculate the photons flux from the F-Factor method " << endl;
620 fCam->SetFFactorMethodValid(kFALSE);
621 return kFALSE;
622 }
623 else
624 fCam->SetFFactorMethodValid(kTRUE);
625
626 //
627 // Finalize Blind Pixel
628 //
629 if (FinalizeBlindPixel())
630 fQECam->SetBlindPixelMethodValid(kTRUE);
631 else
632 fQECam->SetBlindPixelMethodValid(kFALSE);
633
634 //
635 // Finalize PIN Diode
636 //
637 if (FinalizePINDiode())
638 fQECam->SetPINDiodeMethodValid(kTRUE);
639 else
640 fQECam->SetPINDiodeMethodValid(kFALSE);
641
642 //
643 // Finalize QE Cam
644 //
645 FinalizeFFactorQECam();
646 FinalizeBlindPixelQECam();
647 FinalizePINDiodeQECam();
648
649 fCam ->SetReadyToSave();
650 fQECam ->SetReadyToSave();
651 fBadPixels->SetReadyToSave();
652
653 if (fBlindPixel)
654 fBlindPixel->SetReadyToSave();
655 if (fPINDiode)
656 fPINDiode->SetReadyToSave();
657
658
659
660 *fLog << inf << endl;
661 *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
662 *fLog << dec << setfill(' ');
663
664 UInt_t countinner = 0;
665 UInt_t countouter = 0;
666 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
667 {
668 MBadPixelsPix &bad = (*fBadPixels)[i];
669 if (bad.IsOK())
670 {
671 if (fGeom->GetPixRatio(i) == 1.)
672 countinner++;
673 else
674 countouter++;
675 }
676 }
677
678 *fLog << " " << setw(7) << "Successfully calibrated Pixels: "
679 << "Inner: " << countinner << " Outer: " << countouter << endl;
680
681 PrintUnsuitable(MBadPixelsPix::kUnsuitableRun, "Bad Pixels: ");
682 PrintUnsuitable(MBadPixelsPix::kUnreliableRun, "Unreliable Pixels: ");
683
684 *fLog << inf << endl;
685 *fLog << GetDescriptor() << ": Errors statistics:" << endl;
686
687 PrintUncalibrated(MBadPixelsPix::kChargeIsPedestal,
688 Form("%s%2.1f%s","Signal less than ",fChargeLimit," Pedestal RMS: "));
689 PrintUncalibrated(MBadPixelsPix::kChargeErrNotValid,
690 Form("%s%2.1f%s","Signal Error smaller than ",fChargeErrLimit,": "));
691 PrintUncalibrated(MBadPixelsPix::kChargeRelErrNotValid,
692 Form("%s%2.1f%s","Signal Error bigger than ",fChargeRelErrLimit," times Mean Signal: "));
693 PrintUncalibrated(MBadPixelsPix::kChargeSigmaNotValid,
694 "Signal Sigma smaller than Pedestal RMS: ");
695 PrintUncalibrated(MBadPixelsPix::kLoGainSaturation,
696 "Pixels with Low Gain Saturation: ");
697 PrintUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin,
698 Form("%s%2.1f%s","Mean Abs. Arr. Time in First ",1.," Bin(s): "));
699 PrintUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins,
700 Form("%s%2.1f%s","Mean Abs. Arr. Time in Last ",2.," Bin(s): "));
701 PrintUncalibrated(MBadPixelsPix::kHiGainOscillating,
702 "Pixels with changing Hi Gain signal over time: ");
703 PrintUncalibrated(MBadPixelsPix::kLoGainOscillating,
704 "Pixels with changing Lo Gain signal over time: ");
705 PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,
706 "Pixels with deviating number of phes: ");
707 PrintUncalibrated(MBadPixelsPix::kHiGainNotFitted,
708 "Pixels with unsuccesful Gauss fit to the Hi Gain: ");
709 PrintUncalibrated(MBadPixelsPix::kLoGainNotFitted,
710 "Pixels with unsuccesful Gauss fit to the Lo Gain: ");
711
712 return kTRUE;
713}
714
715// ----------------------------------------------------------------------------------
716//
717// Retrieves pedestal and pedestal RMS from MPedestalPix
718// Retrieves total entries from MPedestalCam
719// Sets pedestal*fNumHiGainSamples and pedestal*fNumLoGainSamples in MCalibrationChargePix
720// Sets pedRMS *fSqrtHiGainSamples and pedRMS *fSqrtLoGainSamples in MCalibrationChargePix
721//
722// If the flag MCalibrationPix::IsHiGainSaturation() is set, call also:
723// - MCalibrationChargePix::CalcLoGainPedestal()
724//
725void MCalibrationChargeCalc::FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal)
726{
727
728 //
729 // get the pedestals
730 //
731 const Float_t pedes = ped.GetPedestal();
732 const Float_t prms = ped.GetPedestalRms();
733 const Float_t num = TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
734
735 //
736 // set them in the calibration camera
737 //
738 if (cal.IsHiGainSaturation())
739 {
740 cal.SetPedestal(pedes* fNumLoGainSamples,
741 prms * fSqrtLoGainSamples,
742 prms * fNumLoGainSamples / num);
743 cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
744 }
745 else
746 {
747 cal.SetPedestal(pedes* fNumHiGainSamples,
748 prms * fSqrtHiGainSamples,
749 prms * fNumHiGainSamples / num);
750 }
751
752}
753
754// ----------------------------------------------------------------------------------------------------
755//
756// Check fit results validity. Bad Pixels flags are set if:
757//
758// 1) Pixel has a mean smaller than fChargeLimit*PedRMS ( Flag: MBadPixelsPix::kChargeIsPedestal)
759// 2) Pixel has a mean error smaller than fChargeErrLimit ( Flag: MBadPixelsPix::kChargeErrNotValid)
760// 3) Pixel has mean smaller than fChargeRelVarLimit times its mean error
761// ( Flag: MBadPixelsPix::kChargeRelErrNotValid)
762// 4) Pixel has a sigma bigger than its Pedestal RMS ( Flag: MBadPixelsPix::kChargeSigmaNotValid )
763//
764// Further returns if flags: MBadPixelsPix::kUnsuitableRun is set
765//
766// Calls MCalibrationChargePix::CalcReducedSigma() and sets flag: MBadPixelsPix::kChargeIsPedestal
767// if not succesful.
768//
769// Calls MCalibrationChargePix::CalcFFactorMethod() and sets flag: MBadPixelsPix::kDeviatingNumPhes)
770// if not succesful.
771//
772Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
773{
774
775 if (cal.GetMean() < fChargeLimit*cal.GetPedRms())
776 {
777 *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
778 << fChargeLimit << " Pedestal RMS: " << cal.GetPedRms() << " in Pixel " << cal.GetPixId() << endl;
779 bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal);
780 }
781
782 if (cal.GetMeanErr() < fChargeErrLimit)
783 {
784 *fLog << warn << GetDescriptor() << ": Error of Fitted Charge: " << cal.GetMeanErr()
785 << " is smaller than " << fChargeErrLimit << " in Pixel " << cal.GetPixId() << endl;
786 bad.SetUncalibrated( MBadPixelsPix::kChargeErrNotValid );
787 }
788
789 if (cal.GetMean() < fChargeRelErrLimit*cal.GetMeanErr())
790 {
791 *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
792 << fChargeRelErrLimit << "* its error: " << cal.GetMeanErr()
793 << " in Pixel " << cal.GetPixId() << endl;
794 bad.SetUncalibrated( MBadPixelsPix::kChargeRelErrNotValid );
795 }
796
797 if (cal.GetSigma() < cal.GetPedRms())
798 {
799 *fLog << warn << GetDescriptor() << ": Sigma of Fitted Charge: " << cal.GetSigma()
800 << " smaller than Pedestal RMS: " << cal.GetPedRms() << " in Pixel " << cal.GetPixId() << endl;
801 bad.SetUncalibrated( MBadPixelsPix::kChargeSigmaNotValid );
802 }
803
804 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
805 return kFALSE;
806
807 if (!cal.CalcReducedSigma())
808 {
809 *fLog << warn << GetDescriptor()
810 << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
811 bad.SetUncalibrated(MBadPixelsPix::kChargeIsPedestal);
812 return kFALSE;
813 }
814
815 if (!cal.CalcFFactorMethod())
816 {
817 *fLog << warn << GetDescriptor()
818 << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
819 bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
820 return kFALSE;
821 }
822
823 return kTRUE;
824}
825
826
827
828// -----------------------------------------------------------------------------------
829//
830// Sets pixel to MBadPixelsPix::kUnsuitableRun, if one of the following flags is set:
831// - MBadPixelsPix::kChargeIsPedestal
832// - MBadPixelsPix::kChargeErrNotValid
833// - MBadPixelsPix::kChargeRelErrNotValid
834// - MBadPixelsPix::kChargeSigmaNotValid
835// - MBadPixelsPix::kMeanTimeInFirstBin
836// - MBadPixelsPix::kMeanTimeInLast2Bins
837//
838// Sets pixel to MBadPixelsPix::kUnreliableRun, if one of the following flags is set:
839// - MBadPixelsPix::kDeviatingNumPhes
840//
841void MCalibrationChargeCalc::FinalizeBadPixels()
842{
843
844 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
845 {
846
847 MBadPixelsPix &bad = (*fBadPixels)[i];
848
849 if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal))
850 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
851
852 if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))
853 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
854
855 if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))
856 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
857
858 if (bad.IsUncalibrated( MBadPixelsPix::kChargeSigmaNotValid ))
859 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
860
861 if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin ))
862 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
863
864 if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins ))
865 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
866
867 if (bad.IsUncalibrated( MBadPixelsPix::kDeviatingNumPhes ))
868 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
869 }
870}
871
872// ------------------------------------------------------------------------
873//
874//
875// First loop: Calculate a mean and mean RMS of photo-electrons per area index
876// Include only pixels which are not MBadPixelsPix::kUnsuitableRun or
877// MBadPixelsPix::kUnreliableRun (see FinalizeBadPixels()) and set
878// MCalibrationChargePix::SetFFactorMethodValid(kFALSE) in that case.
879//
880// Second loop: Get weighted mean number of photo-electrons and its RMS including
881// only pixels with flag MCalibrationChargePix::IsFFactorMethodValid()
882// and further exclude those deviating by more than fPheErrLimit mean
883// sigmas from the mean (obtained in first loop). Set
884// MBadPixelsPix::kDeviatingNumPhes if excluded.
885//
886// Set weighted mean and variance of photo-electrons per area index in:
887// average area pixels of MCalibrationChargeCam (obtained from:
888// MCalibrationChargeCam::GetAverageArea() )
889//
890// Set weighted mean and variance of photo-electrons per sector in:
891// average sector pixels of MCalibrationChargeCam (obtained from:
892// MCalibrationChargeCam::GetAverageSector() )
893//
894Bool_t MCalibrationChargeCalc::FinalizeFFactorMethod()
895{
896
897 const UInt_t npixels = fGeom->GetNumPixels();
898 const UInt_t nareas = fGeom->GetNumAreas();
899 const UInt_t nsectors = fGeom->GetNumSectors();
900
901 Float_t lowlim [nareas];
902 Float_t upplim [nareas];
903 Float_t areavars [nareas];
904 Float_t areaweights [nareas], sectorweights [nsectors];
905 Float_t areaphes [nareas], sectorphes [nsectors];
906 Int_t numareavalid[nareas], numsectorvalid[nsectors];
907
908 memset(lowlim ,0, nareas * sizeof(Float_t));
909 memset(upplim ,0, nareas * sizeof(Float_t));
910 memset(areaphes ,0, nareas * sizeof(Float_t));
911 memset(areavars ,0, nareas * sizeof(Float_t));
912 memset(areaweights ,0, nareas * sizeof(Float_t));
913 memset(numareavalid ,0, nareas * sizeof(Int_t ));
914 memset(sectorweights ,0, nsectors * sizeof(Float_t));
915 memset(sectorphes ,0, nsectors * sizeof(Float_t));
916 memset(numsectorvalid,0, nsectors * sizeof(Int_t ));
917
918 //
919 // First loop: Get mean number of photo-electrons and the RMS
920 // The loop is only to recognize later pixels with very deviating numbers
921 //
922 for (UInt_t i=0; i<npixels; i++)
923 {
924
925 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam) [i];
926 MBadPixelsPix &bad = (*fBadPixels)[i];
927
928 if (!pix.IsFFactorMethodValid())
929 continue;
930
931 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
932 {
933 pix.SetFFactorMethodValid(kFALSE);
934 continue;
935 }
936
937 if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
938 continue;
939
940 const Float_t nphe = pix.GetPheFFactorMethod();
941 const Float_t nvar = pix.GetPheFFactorMethodVar();
942 const Int_t aidx = (*fGeom)[i].GetAidx();
943
944 if (nvar > 0.)
945 {
946 areaphes [aidx] += nphe;
947 areavars [aidx] += nvar;
948 numareavalid[aidx] ++;
949 }
950 }
951
952 for (UInt_t i=0; i<nareas; i++)
953 {
954 if (numareavalid[i] == 0)
955 {
956 *fLog << warn << GetDescriptor() << ": No pixels with valid number of photo-electrons found "
957 << "in area index: " << i << endl;
958 continue;
959 }
960
961 areaphes[i] = areaphes[i] / numareavalid[i];
962 areavars[i] = areavars[i] / numareavalid[i];
963 lowlim [i] = areaphes[i] - fPheErrLimit*TMath::Sqrt(areavars[i]);
964 upplim [i] = areaphes[i] + fPheErrLimit*TMath::Sqrt(areavars[i]);
965 }
966
967 memset(numareavalid,0,nareas*sizeof(Int_t));
968 memset(areaphes ,0,nareas*sizeof(Int_t));
969 memset(areavars ,0,nareas*sizeof(Int_t));
970
971 //
972 // Second loop: Get weighted mean number of photo-electrons and its RMS excluding
973 // pixels deviating by more than fPheErrLimit sigma.
974 // Set the conversion factor FADC counts to photo-electrons
975 //
976 for (UInt_t i=0; i<npixels; i++)
977 {
978
979 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
980
981 if (!pix.IsFFactorMethodValid())
982 continue;
983
984 const Float_t nvar = pix.GetPheFFactorMethodVar();
985
986 if (nvar <= 0.)
987 {
988 pix.SetFFactorMethodValid(kFALSE);
989 continue;
990 }
991
992 MBadPixelsPix &bad = (*fBadPixels)[i];
993
994 const Int_t aidx = (*fGeom)[i].GetAidx();
995 const Int_t sector = (*fGeom)[i].GetSector();
996 const Float_t nphe = pix.GetPheFFactorMethod();
997
998 if ( nphe < lowlim[aidx] || nphe > upplim[aidx] )
999 {
1000 *fLog << warn << GetDescriptor() << ": Deviating number of photo-electrons: "
1001 << Form("%4.2f",nphe) << " out of accepted limits: ["
1002 << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
1003 bad.SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
1004 bad.SetUnsuitable ( MBadPixelsPix::kUnreliableRun );
1005 continue;
1006 }
1007
1008 const Float_t weight = 1./nvar;
1009
1010 areaweights [aidx] += weight;
1011 areaphes [aidx] += weight*nphe;
1012 numareavalid [aidx] ++;
1013 sectorweights [sector] += weight;
1014 sectorphes [sector] += weight*nphe;
1015 numsectorvalid[sector] ++;
1016 }
1017
1018 for (UInt_t aidx=0; aidx<nareas; aidx++)
1019 {
1020
1021 MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
1022
1023 if (areaweights[aidx] <= 0. || areaphes[aidx] <= 0.)
1024 {
1025 *fLog << warn << " Mean number of phe's from area index " << aidx << " cannot be calculated: "
1026 << " Sum of weights: " << areaweights[aidx]
1027 << " Sum of weighted phes: " << areaphes[aidx] << endl;
1028 apix.SetFFactorMethodValid(kFALSE);
1029 continue;
1030 }
1031
1032 *fLog << inf << "Replacing number photo-electrons of average area idx " << aidx << ": "
1033 << Form("%5.3f%s%5.3f",apix.GetPheFFactorMethod()," +- ",apix.GetPheFFactorMethodErr()) << endl;
1034 *fLog << inf << " by average number of photo-electrons from area idx " << aidx << ": "
1035 << Form("%5.3f%s%5.3f",areaphes[aidx] / areaweights[aidx]," +- ",
1036 TMath::Sqrt(1./areaweights[aidx])) << endl;
1037
1038 apix.SetPheFFactorMethod ( areaphes[aidx]/ areaweights[aidx] );
1039 apix.SetPheFFactorMethodVar( 1. / areaweights[aidx] );
1040 apix.SetFFactorMethodValid ( kTRUE );
1041
1042 }
1043
1044 for (UInt_t sector=0; sector<nsectors; sector++)
1045 {
1046
1047 MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
1048
1049 if (sectorweights[sector] <= 0. || sectorphes[sector] <= 0.)
1050 {
1051 *fLog << warn << " Mean number of phe's from sector " << sector << " cannot be calculated: "
1052 << " Sum of weights: " << sectorweights[sector]
1053 << " Sum of weighted phes: " << sectorphes[sector] << endl;
1054 spix.SetFFactorMethodValid(kFALSE);
1055 continue;
1056 }
1057
1058 *fLog << inf << "Replacing number photo-electrons of average sector " << sector << ": "
1059 << Form("%5.3f%s%5.3f",spix.GetPheFFactorMethod()," +- ",spix.GetPheFFactorMethodErr()) << endl;
1060 *fLog << inf << " by average number photo-electrons from sector " << sector << ": "
1061 << Form("%5.3f%s%5.3f",sectorphes[sector]/ sectorweights[sector]," +- ",
1062 TMath::Sqrt(1./sectorweights[sector])) << endl;
1063
1064 spix.SetPheFFactorMethod ( sectorphes[sector]/ sectorweights[sector] );
1065 spix.SetPheFFactorMethodVar( 1. / sectorweights[sector] );
1066 spix.SetFFactorMethodValid ( kTRUE );
1067
1068 }
1069
1070 return kTRUE;
1071}
1072
1073
1074// ------------------------------------------------------------------------
1075//
1076// Returns kFALSE if pointer to MCalibrationChargeBlindPix is NULL
1077//
1078// The check returns kFALSE if:
1079//
1080// 1) fLambda and fLambdaCheck are separated relatively to each other by more than fLambdaCheckLimit
1081// 2) BlindPixel has an fLambdaErr greater than fLambdaErrLimit
1082//
1083// Calls:
1084// - MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
1085//
1086Bool_t MCalibrationChargeCalc::FinalizeBlindPixel()
1087{
1088
1089 if (!fBlindPixel)
1090 return kFALSE;
1091
1092 const Float_t lambda = fBlindPixel->GetLambda();
1093 const Float_t lambdaerr = fBlindPixel->GetLambdaErr();
1094 const Float_t lambdacheck = fBlindPixel->GetLambdaCheck();
1095
1096 if (2.*(lambdacheck-lambda)/(lambdacheck+lambda) < fLambdaCheckLimit)
1097 {
1098 *fLog << warn << GetDescriptor() << ": Lambda and Lambda-Check differ by more than "
1099 << fLambdaCheckLimit << " in the Blind Pixel " << endl;
1100 return kFALSE;
1101 }
1102
1103 if (lambdaerr < fLambdaErrLimit)
1104 {
1105 *fLog << warn << GetDescriptor() << ": Error of Fitted Lambda is greater than "
1106 << fLambdaErrLimit << " in Blind Pixel " << endl;
1107 return kFALSE;
1108 }
1109
1110 if (!fBlindPixel->CalcFluxInsidePlexiglass())
1111 {
1112 *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
1113 << "will skip Blind Pixel Calibration " << endl;
1114 return kFALSE;
1115 }
1116
1117 return kTRUE;
1118}
1119
1120// ------------------------------------------------------------------------
1121//
1122// Returns kFALSE if pointer to MCalibrationChargePINDiode is NULL
1123//
1124// The check returns kFALSE if:
1125//
1126// 1) PINDiode has a fitted charge smaller than fChargeLimit*PedRMS
1127// 2) PINDiode has a fit error smaller than fChargeErrLimit
1128// 3) PINDiode has a fitted charge smaller its fChargeRelErrLimit times its charge error
1129// 4) PINDiode has a charge sigma smaller than its Pedestal RMS
1130//
1131// Calls:
1132// - MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
1133//
1134Bool_t MCalibrationChargeCalc::FinalizePINDiode()
1135{
1136
1137 if (!fPINDiode)
1138 return kFALSE;
1139
1140 if (fPINDiode->GetMean() < fChargeLimit*fPINDiode->GetPedRms())
1141 {
1142 *fLog << warn << GetDescriptor() << ": Fitted Charge is smaller than "
1143 << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
1144 return kFALSE;
1145 }
1146
1147 if (fPINDiode->GetMeanErr() < fChargeErrLimit)
1148 {
1149 *fLog << warn << GetDescriptor() << ": Error of Fitted Charge is smaller than "
1150 << fChargeErrLimit << " in PINDiode " << endl;
1151 return kFALSE;
1152 }
1153
1154 if (fPINDiode->GetMean() < fChargeRelErrLimit*fPINDiode->GetMeanErr())
1155 {
1156 *fLog << warn << GetDescriptor() << ": Fitted Charge is smaller than "
1157 << fChargeRelErrLimit << "* its error in PINDiode " << endl;
1158 return kFALSE;
1159 }
1160
1161 if (fPINDiode->GetSigma() < fPINDiode->GetPedRms())
1162 {
1163 *fLog << warn << GetDescriptor()
1164 << ": Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
1165 return kFALSE;
1166 }
1167
1168
1169 if (!fPINDiode->CalcFluxOutsidePlexiglass())
1170 {
1171 *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
1172 << "will skip PIN Diode Calibration " << endl;
1173 return kFALSE;
1174 }
1175
1176 return kTRUE;
1177}
1178
1179// ------------------------------------------------------------------------
1180//
1181// Calculate the average number of photons outside the plexiglass with the
1182// formula:
1183//
1184// av.Num.photons(area index) = av.Num.Phes(area index)
1185// / MCalibrationQEPix::GetDefaultQE(fPulserColor)
1186// / MCalibrationQECam::GetPlexiglassQE()
1187//
1188// Calculate the variance on the average number of photons.
1189//
1190// Loop over pixels:
1191//
1192// - Continue, if not MCalibrationChargePix::IsFFactorMethodValid() and set:
1193// MCalibrationQEPix::SetFFactorMethodValid(kFALSE,fPulserColor)
1194//
1195// - Call MCalibrationChargePix::CalcMeanFFactor(av.Num.photons) and set:
1196// MCalibrationQEPix::SetFFactorMethodValid(kFALSE,fPulserColor) if not succesful
1197//
1198// - Calculate the quantum efficiency with the formula:
1199//
1200// QE = ( Num.Phes / av.Num.photons ) * MGeomCam::GetPixRatio()
1201//
1202// - Set QE in MCalibrationQEPix::SetQEFFactor ( QE, fPulserColor );
1203// - Set Variance of QE in MCalibrationQEPix::SetQEFFactorVar ( Variance, fPulserColor );
1204// - Set bit MCalibrationQEPix::SetFFactorMethodValid(kTRUE,fPulserColor)
1205//
1206// - Call MCalibrationQEPix::UpdateFFactorMethod()
1207//
1208void MCalibrationChargeCalc::FinalizeFFactorQECam()
1209{
1210
1211 MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCam->GetAverageArea(0);
1212 MCalibrationQEPix &qepix = (MCalibrationQEPix&) fQECam->GetAverageArea(0);
1213
1214 const Float_t avphotons = avpix.GetPheFFactorMethod()
1215 / qepix.GetQEFFactor(fPulserColor)
1216 / fQECam->GetPlexiglassQE();
1217
1218 const Float_t avphotrelvar = avpix.GetPheFFactorMethodRelVar()
1219 + qepix.GetQEFFactorRelVar(fPulserColor)
1220 + fQECam->GetPlexiglassQERelVar();
1221
1222 const UInt_t npixels = fGeom->GetNumPixels();
1223
1224 for (UInt_t i=0; i<npixels; i++)
1225 {
1226
1227 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
1228 MCalibrationQEPix &qepix = (MCalibrationQEPix&) (*fQECam)[i];
1229
1230 if (!pix.IsFFactorMethodValid())
1231 {
1232 qepix.SetFFactorMethodValid(kFALSE,fPulserColor);
1233 continue;
1234 }
1235
1236 const Float_t photons = avphotons / fGeom->GetPixRatio(i);
1237 const Float_t qe = pix.GetPheFFactorMethod() / photons ;
1238
1239 if (!pix.CalcMeanFFactor( photons , avphotrelvar ))
1240 {
1241 pix.SetFFactorMethodValid(kFALSE);
1242 qepix.SetFFactorMethodValid(kFALSE, fPulserColor);
1243 (*fBadPixels)[i].SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
1244 }
1245
1246 const Float_t qerelvar = avphotrelvar + pix.GetPheFFactorMethodRelVar();
1247
1248 qepix.SetQEFFactor ( qe , fPulserColor );
1249 qepix.SetQEFFactorVar ( qerelvar*qe*qe, fPulserColor );
1250 qepix.SetFFactorMethodValid( kTRUE , fPulserColor );
1251
1252 if (!qepix.UpdateFFactorMethod())
1253 *fLog << warn << GetDescriptor()
1254 << ": Cannot update Quantum efficiencies with the F-Factor Method" << endl;
1255 }
1256}
1257
1258
1259// ------------------------------------------------------------------------
1260//
1261// Loop over pixels:
1262//
1263// - Continue, if not MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable() and set:
1264// MCalibrationQEPix::SetBlindPixelMethodValid(kFALSE,fPulserColor)
1265//
1266// - Calculate the quantum efficiency with the formula:
1267//
1268// QE = Num.Phes / MCalibrationChargeBlindPix::GetFluxInsidePlexiglass()
1269// / MGeomPix::GetA() * MCalibrationQECam::GetPlexiglassQE()
1270//
1271// - Set QE in MCalibrationQEPix::SetQEBlindPixel ( QE, fPulserColor );
1272// - Set Variance of QE in MCalibrationQEPix::SetQEBlindPixelVar ( Variance, fPulserColor );
1273// - Set bit MCalibrationQEPix::SetBlindPixelMethodValid(kTRUE,fPulserColor)
1274//
1275// - Call MCalibrationQEPix::UpdateBlindPixelMethod()
1276//
1277void MCalibrationChargeCalc::FinalizeBlindPixelQECam()
1278{
1279
1280 const UInt_t npixels = fGeom->GetNumPixels();
1281
1282 //
1283 // With the knowledge of the overall photon flux, calculate the
1284 // quantum efficiencies after the Blind Pixel and PIN Diode method
1285 //
1286 for (UInt_t i=0; i<npixels; i++)
1287 {
1288
1289 MCalibrationQEPix &qepix = (MCalibrationQEPix&) (*fQECam)[i];
1290
1291 if (!fBlindPixel)
1292 {
1293 qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
1294 continue;
1295 }
1296
1297 if (!fBlindPixel->IsFluxInsidePlexiglassAvailable())
1298 {
1299 qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
1300 continue;
1301 }
1302
1303 MBadPixelsPix &bad = (*fBadPixels)[i];
1304
1305 if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
1306 {
1307 qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
1308 continue;
1309 }
1310
1311 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
1312 MGeomPix &geo = (*fGeom)[i];
1313
1314 const Float_t qe = pix.GetPheFFactorMethod()
1315 / fBlindPixel->GetFluxInsidePlexiglass()
1316 / geo.GetA()
1317 * fQECam->GetPlexiglassQE();
1318
1319 const Float_t qerelvar = fBlindPixel->GetFluxInsidePlexiglassRelVar()
1320 + fQECam->GetPlexiglassQERelVar()
1321 + pix.GetPheFFactorMethodRelVar();
1322
1323 qepix.SetQEBlindPixel ( qe , fPulserColor );
1324 qepix.SetQEBlindPixelVar ( qerelvar*qe*qe, fPulserColor );
1325 qepix.UpdateBlindPixelMethod();
1326 }
1327}
1328
1329// ------------------------------------------------------------------------
1330//
1331// Loop over pixels:
1332//
1333// - Continue, if not MCalibrationChargePINDiode::IsFluxOutsidePlexiglassAvailable() and set:
1334// MCalibrationQEPix::SetPINDiodeMethodValid(kFALSE,fPulserColor)
1335//
1336// - Calculate the quantum efficiency with the formula:
1337//
1338// QE = Num.Phes / MCalibrationChargePINDiode::GetFluxOutsidePlexiglass() / MGeomPix::GetA()
1339//
1340// - Set QE in MCalibrationQEPix::SetQEPINDiode ( QE, fPulserColor );
1341// - Set Variance of QE in MCalibrationQEPix::SetQEPINDiodeVar ( Variance, fPulserColor );
1342// - Set bit MCalibrationQEPix::SetPINDiodeMethodValid(kTRUE,fPulserColor)
1343//
1344// - Call MCalibrationQEPix::UpdatePINDiodeMethod()
1345//
1346void MCalibrationChargeCalc::FinalizePINDiodeQECam()
1347{
1348
1349 const UInt_t npixels = fGeom->GetNumPixels();
1350
1351 //
1352 // With the knowledge of the overall photon flux, calculate the
1353 // quantum efficiencies after the PIN Diode method
1354 //
1355 for (UInt_t i=0; i<npixels; i++)
1356 {
1357
1358 MCalibrationQEPix &qepix = (MCalibrationQEPix&) (*fQECam)[i];
1359
1360 if (!fPINDiode)
1361 {
1362 qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
1363 continue;
1364 }
1365
1366 if (!fPINDiode->IsFluxOutsidePlexiglassAvailable())
1367 {
1368 qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
1369 continue;
1370 }
1371
1372 MBadPixelsPix &bad = (*fBadPixels)[i];
1373
1374 if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
1375 {
1376 qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
1377 continue;
1378 }
1379
1380 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
1381 MGeomPix &geo = (*fGeom)[i];
1382
1383 const Float_t qe = pix.GetPheFFactorMethod()
1384 / fPINDiode->GetFluxOutsidePlexiglass()
1385 / geo.GetA();
1386
1387 const Float_t qerelvar = fPINDiode->GetFluxOutsidePlexiglassRelVar() + pix.GetPheFFactorMethodRelVar();
1388
1389 qepix.SetQEPINDiode ( qe , fPulserColor );
1390 qepix.SetQEPINDiodeVar ( qerelvar*qe*qe, fPulserColor );
1391 qepix.UpdateBlindPixelMethod();
1392 }
1393}
1394
1395// -----------------------------------------------------------------------------------------------
1396//
1397// Print out statistics about BadPixels of type UnsuitableType_t
1398//
1399void MCalibrationChargeCalc::PrintUnsuitable(MBadPixelsPix::UnsuitableType_t typ, const char *text) const
1400{
1401
1402 UInt_t countinner = 0;
1403 UInt_t countouter = 0;
1404 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
1405 {
1406 MBadPixelsPix &bad = (*fBadPixels)[i];
1407 if (bad.IsUnsuitable(typ))
1408 {
1409 if (fGeom->GetPixRatio(i) == 1.)
1410 countinner++;
1411 else
1412 countouter++;
1413 }
1414 }
1415
1416 *fLog << " " << setw(7) << text
1417 << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
1418}
1419
1420// -----------------------------------------------------------------------------------------------
1421//
1422// Print out statistics about BadPixels of type UncalibratedType_t
1423//
1424void MCalibrationChargeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const
1425{
1426
1427 UInt_t countinner = 0;
1428 UInt_t countouter = 0;
1429 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
1430 {
1431 MBadPixelsPix &bad = (*fBadPixels)[i];
1432 if (bad.IsUncalibrated(typ))
1433 {
1434 if (fGeom->GetPixRatio(i) == 1.)
1435 countinner++;
1436 else
1437 countouter++;
1438 }
1439 }
1440
1441 *fLog << " " << setw(7) << text
1442 << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
1443}
1444
Note: See TracBrowser for help on using the repository browser.