source: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc@ 4631

Last change on this file since 4631 was 4603, checked in by gaug, 20 years ago
*** empty log message ***
File size: 18.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 11/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24/////////////////////////////////////////////////////////////////////////////
25//
26// MCalibrationChargeCam
27//
28// Storage container for charge calibration results from the signal distribution
29// fits (see MHCalibrationChargeCam and MHCalibrationChargePix), the calculation
30// of reduced sigmas and number of photo-electrons (this class) and conversion
31// factors sum FADC slices to photo-electrons (see MCalibrationChargeCalc)
32//
33// Individual pixels have to be cast when retrieved e.g.:
34// MCalibrationChargePix &avpix = (MCalibrationChargePix&)(*fChargeCam)[i]
35//
36// Averaged values over one whole area index (e.g. inner or outer pixels for
37// the MAGIC camera), can be retrieved via:
38// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageArea(i)
39//
40// Averaged values over one whole camera sector can be retrieved via:
41// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageSector(i)
42//
43// Note the averageing has been done on an event-by-event basis. Resulting
44// Sigma's of the Gauss fit have been multiplied with the square root of the number
45// of involved pixels in order to make a direct comparison possible with the mean of
46// sigmas.
47//
48// Final numbers of uncalibrated or unreliable pixels can be retrieved via the commands:
49// GetNumUncalibrated(aidx) and GetNumUnreliable(aidx) where aidx is the area index (0 for
50// inner and 1 for outer pixels in the MAGIC camera).
51//
52// The following "calibration" constants are used for the calibration of each pixel
53// (see MCalibrate):
54//
55// - MCalibrationQEPix::GetMeanConvFADC2Phe(): The mean conversion factor from the
56// summed FADC slices to the number of photo-electrons (in first order independent
57// on colour and intensity)
58// - MCalibrationQEPix::GetMeanFFactorFADC2Phot(): The mean F-Factor of the total
59// readout chain dividing the signal to noise of the incoming number of photons
60// (= sqrt(number photons)) by the signal to noise of the outgoing summed FADC slices
61// signal (= MCalibrationPix::GetMean() / MCalibrationChargePix::GetRSigma() )
62//
63// The following calibration constants can be retrieved directly from this class:
64//
65// - GetConversionFactorFFactor ( Int_t idx, Float_t &mean, Float_t &err, Float_t &sigma );
66//
67// where:
68// - idx is the pixel software ID
69// - "mean" is the mean conversion constant, to be multiplied with the retrieved signal
70// in order to get a calibrated number of PHOTONS.
71// - "err" is the pure statistical uncertainty about the MEAN
72// - "sigma", if mulitplied with the square root of signal, gives the approximate sigma of the
73// retrieved mean number of incident Cherenkov photons.
74//
75// Note, Conversion is ALWAYS (included the F-Factor method!) from summed FADC slices to PHOTONS.
76//
77// See also: MCalibrationChargePix, MCalibrationChargeCalc, MCalibrationQECam
78// MHCalibrationChargePix, MHCalibrationChargeCam
79// MCalibrationChargeBlindPix, MCalibrationChargePINDiode
80//
81/////////////////////////////////////////////////////////////////////////////
82#include "MCalibrationChargeCam.h"
83#include "MCalibrationCam.h"
84
85#include <TClonesArray.h>
86
87#include "MLog.h"
88#include "MLogManip.h"
89
90#include "MGeomCam.h"
91#include "MGeomPix.h"
92
93#include "MBadPixelsCam.h"
94#include "MBadPixelsPix.h"
95
96#include "MCalibrationChargePix.h"
97#include "MCalibrationChargeBlindPix.h"
98#include "MCalibrationChargePINDiode.h"
99
100ClassImp(MCalibrationChargeCam);
101
102using namespace std;
103// --------------------------------------------------------------------------
104//
105// Default constructor.
106//
107// Sets all pointers to 0
108//
109// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
110// to hold one container per pixel. Later, a call to MCalibrationChargeCam::InitSize()
111// has to be performed (in MGeomApply).
112//
113// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
114// to hold one container per pixel AREA. Later, a call to MCalibrationChargeCam::InitAreas()
115// has to be performed (in MGeomApply).
116//
117// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
118// to hold one container per camera SECTOR. Later, a call to MCalibrationChargeCam::InitSectors()
119// has to be performed (in MGeomApply).
120//
121// Calls:
122// - Clear()
123//
124MCalibrationChargeCam::MCalibrationChargeCam(const char *name, const char *title)
125{
126 fName = name ? name : "MCalibrationChargeCam";
127 fTitle = title ? title : "Storage container for the Calibration Information in the camera";
128
129 fPixels = new TClonesArray("MCalibrationChargePix",1);
130 fAverageAreas = new TClonesArray("MCalibrationChargePix",1);
131 fAverageSectors = new TClonesArray("MCalibrationChargePix",1);
132
133 Clear();
134}
135
136
137// --------------------------------------
138//
139// Sets all variable to 0.
140// Sets all flags to kFALSE
141// Calls MCalibrationCam::Clear()
142//
143void MCalibrationChargeCam::Clear(Option_t *o)
144{
145
146 SetFFactorMethodValid ( kFALSE );
147
148 fNumPhotonsBlindPixelMethod = 0.;
149 fNumPhotonsFFactorMethod = 0.;
150 fNumPhotonsPINDiodeMethod = 0.;
151 fNumPhotonsBlindPixelMethodErr = 0.;
152 fNumPhotonsFFactorMethodErr = 0.;
153 fNumPhotonsPINDiodeMethodErr = 0.;
154
155 MCalibrationCam::Clear();
156
157 return;
158}
159
160// -------------------------------------------------------------------
161//
162// Calls:
163// - MCalibrationCam::Init()
164//
165void MCalibrationChargeCam::Init(const MGeomCam &geom)
166{
167 MCalibrationCam::Init(geom);
168}
169
170// -----------------------------------------------
171//
172// Sets the kFFactorMethodValid bit from outside
173//
174void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b)
175{
176 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
177}
178
179
180// --------------------------------------------------------------------------
181//
182// Test bit kFFactorMethodValid
183//
184Bool_t MCalibrationChargeCam::IsFFactorMethodValid() const
185{
186 return TESTBIT(fFlags,kFFactorMethodValid);
187}
188
189// --------------------------------------------------------------------------
190//
191// Print first the well fitted pixels
192// and then the ones which are not FitValid
193//
194void MCalibrationChargeCam::Print(Option_t *o) const
195{
196
197 *fLog << all << GetDescriptor() << ":" << endl;
198 int id = 0;
199
200 *fLog << all << "Calibrated pixels:" << endl;
201 *fLog << all << endl;
202
203 TIter Next(fPixels);
204 MCalibrationChargePix *pix;
205 while ((pix=(MCalibrationChargePix*)Next()))
206 {
207
208 if (!pix->IsExcluded())
209 {
210
211 *fLog << all
212 << Form("%s%3i","Pixel: ",pix->GetPixId())
213 << Form("%s%4.2f%s%4.2f"," Ped.Rms: ",pix->GetPedRms(),"+-",pix->GetPedRmsErr())
214 << Form("%s%4.2f%s%4.2f"," Charge: " ,pix->GetConvertedMean(),"+-",pix->GetConvertedSigma())
215 << Form("%s%4.2f%s%4.2f"," Red.Sigma: ",pix->GetConvertedRSigma(),"+-",pix->GetConvertedRSigmaErr())
216 << Form("%s%4.2f%s%4.2f"," Num.Phes: ",pix->GetPheFFactorMethod(),"+-",pix->GetPheFFactorMethodErr())
217 << Form("%s%4.2f%s%4.2f"," Conv.FADC2Phe: ",pix->GetMeanConvFADC2Phe(),"+-",pix->GetMeanConvFADC2PheErr())
218 << " Saturated? :" << pix->IsHiGainSaturation()
219 << endl;
220 id++;
221 }
222 }
223
224 *fLog << all << id << " pixels" << endl;
225 id = 0;
226
227
228 *fLog << all << endl;
229 *fLog << all << "Excluded pixels:" << endl;
230 *fLog << all << endl;
231
232 id = 0;
233
234 TIter Next4(fPixels);
235 while ((pix=(MCalibrationChargePix*)Next4()))
236 {
237 if (pix->IsExcluded())
238 {
239 *fLog << all << pix->GetPixId() << " ";
240 id++;
241
242 if (!(id % 25))
243 *fLog << endl;
244 }
245 }
246
247 *fLog << endl;
248 *fLog << all << id << " Excluded pixels " << endl;
249 *fLog << endl;
250
251 *fLog << all << endl;
252 *fLog << all << "Averaged Areas:" << endl;
253 *fLog << all << endl;
254
255 TIter Next5(fAverageAreas);
256 while ((pix=(MCalibrationChargePix*)Next5()))
257 {
258 *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
259 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
260 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
261 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
262 << " Reduced Sigma: " << pix->GetRSigma()
263 << " Nr Phe's: " << pix->GetPheFFactorMethod()
264 << endl;
265 }
266
267 *fLog << all << endl;
268 *fLog << all << "Averaged Sectors:" << endl;
269 *fLog << all << endl;
270
271 TIter Next6(fAverageSectors);
272 while ((pix=(MCalibrationChargePix*)Next6()))
273 {
274 *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
275 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
276 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
277 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
278 << " Reduced Sigma: " << pix->GetRSigma()
279 << " Nr Phe's: " << pix->GetPheFFactorMethod()
280 << endl;
281 }
282 *fLog << all << endl;
283}
284
285
286// --------------------------------------------------------------------------
287//
288// The types are as follows:
289//
290// Fitted values:
291// ==============
292//
293// 0: Fitted Charge (see MCalibrationPix::GetMean())
294// 1: Error of fitted Charge (see MCalibrationPix::GetMeanErr())
295// 2: Sigma of fitted Charge (see MCalibrationPix::GetSigma())
296// 3: Error of Sigma of fitted Charge (see MCalibrationPix::GetSigmaErr())
297//
298// Useful variables derived from the fit results:
299// =============================================
300//
301// 4: Probability Gauss fit Charge distribution (see MCalibrationPix::GetProb())
302// 5: Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigma())
303// 6: Error Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigmaErr())
304// 7: Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerCharge())
305// 8: Error of Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerChargeErr())
306//
307// Results of the F-Factor calibration Method:
308// ===========================================
309//
310// 9: Nr. Photo-electrons from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethod())
311// 10: Error Nr. Photo-el. from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethodErr())
312// 11: Conversion factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2Phe()
313// 12: Error conv. factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2PheErr()
314// 13: Overall F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2Phot()
315// 14: Error F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()
316// 15: Pixels valid calibration F-Factor-Method (see MCalibrationChargePix::IsFFactorMethodValid())
317//
318// Results of the Low-Gain vs. High-Gain Conversion:
319// =================================================
320//
321// 16: Mean Signal Hi-Gain / Mean Signal Lo-Gain (see MCalibrationPix::GetHiLoMeansDivided())
322// 17: Error Signal High-Gain / Signal Low Gain (see MCalibrationPix::GetHiLoMeansDividedErr())
323// 18: Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDivided())
324// 19: Error Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDividedErr())
325//
326// Localized defects:
327// ==================
328//
329// 20: Excluded Pixels
330// 21: Number of pickup events in the Hi Gain (see MCalibrationPix::GetHiGainNumPickup())
331// 22: Number of pickup events in the Lo Gain (see MCalibrationPix::GetLoGainNumPickup())
332// 23: Number of blackout events in the Hi Gain (see MCalibrationPix::GetHiGainNumBlackout())
333// 24: Number of blackout events in the Lo Gain (see MCalibrationPix::GetLoGainNumBlackout())
334//
335// Other classifications of pixels:
336// ================================
337//
338// 25: Pixels with saturated High-Gain (see MCalibrationPix::IsHiGainSaturation())
339//
340// Calculated absolute arrival times (very low precision!):
341// ========================================================
342//
343// 26: Absolute Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeMean())
344// 27: RMS Ab. Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeRms())
345//
346// Used Pedestals:
347// ===============
348//
349// 28: Pedestal for entire signal extr. range (see MCalibrationChargePix::Ped())
350// 29: Error Pedestal entire signal extr. range (see MCalibrationChargePix::PedErr())
351// 30: Ped. RMS entire signal extraction range (see MCalibrationChargePix::PedRms())
352// 31: Error Ped. RMS entire signal extr. range (see MCalibrationChargePix::PedRmsErr())
353//
354Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
355{
356
357 if (idx > GetSize())
358 return kFALSE;
359
360 Float_t area = cam[idx].GetA();
361
362 if (area == 0)
363 return kFALSE;
364
365 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
366
367 switch (type)
368 {
369 case 0:
370 if (pix.IsExcluded())
371 return kFALSE;
372 val = pix.GetMean();
373 break;
374 case 1:
375 if (pix.IsExcluded())
376 return kFALSE;
377 val = pix.GetMeanErr();
378 break;
379 case 2:
380 if (pix.IsExcluded())
381 return kFALSE;
382 val = pix.GetSigma();
383 break;
384 case 3:
385 if (pix.IsExcluded())
386 return kFALSE;
387 val = pix.GetSigmaErr();
388 break;
389 case 4:
390 if (pix.IsExcluded())
391 return kFALSE;
392 val = pix.GetProb();
393 break;
394 case 5:
395 if (pix.IsExcluded())
396 return kFALSE;
397 if (pix.GetRSigma() == -1.)
398 return kFALSE;
399 val = pix.GetRSigma();
400 break;
401 case 6:
402 if (pix.IsExcluded())
403 return kFALSE;
404 if (pix.GetRSigma() == -1.)
405 return kFALSE;
406 val = pix.GetRSigmaErr();
407 break;
408 case 7:
409 if (pix.IsExcluded())
410 return kFALSE;
411 val = pix.GetRSigmaPerCharge();
412 break;
413 case 8:
414 if (pix.IsExcluded())
415 return kFALSE;
416 val = pix.GetRSigmaPerChargeErr();
417 break;
418 case 9:
419 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
420 return kFALSE;
421 val = pix.GetPheFFactorMethod();
422 break;
423 case 10:
424 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
425 return kFALSE;
426 val = pix.GetPheFFactorMethodErr();
427 break;
428 case 11:
429 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
430 return kFALSE;
431 val = pix.GetMeanConvFADC2Phe();
432 break;
433 case 12:
434 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
435 return kFALSE;
436 val = pix.GetMeanConvFADC2PheErr();
437 break;
438 case 13:
439 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
440 return kFALSE;
441 val = pix.GetMeanFFactorFADC2Phot();
442 break;
443 case 14:
444 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
445 return kFALSE;
446 val = pix.GetMeanFFactorFADC2PhotErr();
447 break;
448 case 15:
449 if (pix.IsExcluded())
450 return kFALSE;
451 if (pix.IsFFactorMethodValid())
452 val = 1;
453 else
454 return kFALSE;
455 break;
456 case 16:
457 if (pix.IsExcluded())
458 return kFALSE;
459 val = pix.GetHiLoMeansDivided();
460 break;
461 case 17:
462 if (pix.IsExcluded())
463 return kFALSE;
464 val = pix.GetHiLoMeansDividedErr();
465 break;
466 case 18:
467 if (pix.IsExcluded())
468 return kFALSE;
469 val = pix.GetHiLoSigmasDivided();
470 break;
471 case 19:
472 if (pix.IsExcluded())
473 return kFALSE;
474 val = pix.GetHiLoSigmasDividedErr();
475 break;
476 case 20:
477 if (pix.IsExcluded())
478 val = 1.;
479 else
480 return kFALSE;
481 break;
482 case 21:
483 if (pix.IsExcluded())
484 return kFALSE;
485 val = pix.GetHiGainNumPickup();
486 break;
487 case 22:
488 if (pix.IsExcluded())
489 return kFALSE;
490 val = pix.GetLoGainNumPickup();
491 break;
492 case 23:
493 if (pix.IsExcluded())
494 return kFALSE;
495 val = pix.GetHiGainNumBlackout();
496 break;
497 case 24:
498 if (pix.IsExcluded())
499 return kFALSE;
500 val = pix.GetLoGainNumBlackout();
501 break;
502 case 25:
503 if (pix.IsExcluded())
504 return kFALSE;
505 val = pix.IsHiGainSaturation();
506 break;
507 case 26:
508 if (pix.IsExcluded())
509 return kFALSE;
510 val = pix.GetAbsTimeMean();
511 break;
512 case 27:
513 if (pix.IsExcluded())
514 return kFALSE;
515 val = pix.GetAbsTimeRms();
516 break;
517 case 28:
518 if (pix.IsExcluded())
519 return kFALSE;
520 val = pix.GetPed();
521 break;
522 case 29:
523 if (pix.IsExcluded())
524 return kFALSE;
525 val = pix.GetPedErr();
526 break;
527 case 30:
528 if (pix.IsExcluded())
529 return kFALSE;
530 val = pix.GetPedRms();
531 break;
532 case 31:
533 if (pix.IsExcluded())
534 return kFALSE;
535 val = pix.GetPedErr()/2.;
536 break;
537 default:
538 return kFALSE;
539 }
540
541 return val!=-1.;
542}
543
544// --------------------------------------------------------------------------
545//
546// Calls MCalibrationChargePix::DrawClone()
547//
548void MCalibrationChargeCam::DrawPixelContent(Int_t idx) const
549{
550 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
551 pix.DrawClone();
552}
553
554
555
556Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor)
557{
558
559 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
560
561 Float_t conv = pix.GetMeanConvFADC2Phe();
562
563 if (conv < 0.)
564 return kFALSE;
565
566 mean = conv;
567 err = pix.GetMeanConvFADC2PheErr();
568 ffactor = pix.GetMeanFFactorFADC2Phot();
569
570 return kTRUE;
571}
572
573
Note: See TracBrowser for help on using the repository browser.