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

Last change on this file since 4692 was 4658, checked in by gaug, 20 years ago
*** empty log message ***
File size: 18.4 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// Sets the kFFactorMethodValid bit from outside
163//
164void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b)
165{
166 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
167}
168
169
170// --------------------------------------------------------------------------
171//
172// Test bit kFFactorMethodValid
173//
174Bool_t MCalibrationChargeCam::IsFFactorMethodValid() const
175{
176 return TESTBIT(fFlags,kFFactorMethodValid);
177}
178
179// --------------------------------------------------------------------------
180//
181// Print first the well fitted pixels
182// and then the ones which are not FitValid
183//
184void MCalibrationChargeCam::Print(Option_t *o) const
185{
186
187 *fLog << all << GetDescriptor() << ":" << endl;
188 int id = 0;
189
190 *fLog << all << "Calibrated pixels:" << endl;
191 *fLog << all << endl;
192
193 TIter Next(fPixels);
194 MCalibrationChargePix *pix;
195 while ((pix=(MCalibrationChargePix*)Next()))
196 {
197
198 if (!pix->IsExcluded())
199 {
200
201 *fLog << all
202 << Form("%s%3i","Pixel: ",pix->GetPixId())
203 << Form("%s%4.2f%s%4.2f"," Ped.Rms: ",pix->GetPedRms(),"+-",pix->GetPedRmsErr())
204 << Form("%s%4.2f%s%4.2f"," Charge: " ,pix->GetConvertedMean(),"+-",pix->GetConvertedSigma())
205 << Form("%s%4.2f%s%4.2f"," Red.Sigma: ",pix->GetConvertedRSigma(),"+-",pix->GetConvertedRSigmaErr())
206 << Form("%s%4.2f%s%4.2f"," Num.Phes: ",pix->GetPheFFactorMethod(),"+-",pix->GetPheFFactorMethodErr())
207 << Form("%s%4.2f%s%4.2f"," Conv.FADC2Phe: ",pix->GetMeanConvFADC2Phe(),"+-",pix->GetMeanConvFADC2PheErr())
208 << " Saturated? :" << pix->IsHiGainSaturation()
209 << endl;
210 id++;
211 }
212 }
213
214 *fLog << all << id << " pixels" << endl;
215 id = 0;
216
217
218 *fLog << all << endl;
219 *fLog << all << "Excluded pixels:" << endl;
220 *fLog << all << endl;
221
222 id = 0;
223
224 TIter Next4(fPixels);
225 while ((pix=(MCalibrationChargePix*)Next4()))
226 {
227 if (pix->IsExcluded())
228 {
229 *fLog << all << pix->GetPixId() << " ";
230 id++;
231
232 if (!(id % 25))
233 *fLog << endl;
234 }
235 }
236
237 *fLog << endl;
238 *fLog << all << id << " Excluded pixels " << endl;
239 *fLog << endl;
240
241 *fLog << all << endl;
242 *fLog << all << "Averaged Areas:" << endl;
243 *fLog << all << endl;
244
245 TIter Next5(fAverageAreas);
246 while ((pix=(MCalibrationChargePix*)Next5()))
247 {
248 *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
249 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
250 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
251 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
252 << " Reduced Sigma: " << pix->GetRSigma()
253 << " Nr Phe's: " << pix->GetPheFFactorMethod()
254 << endl;
255 }
256
257 *fLog << all << endl;
258 *fLog << all << "Averaged Sectors:" << endl;
259 *fLog << all << endl;
260
261 TIter Next6(fAverageSectors);
262 while ((pix=(MCalibrationChargePix*)Next6()))
263 {
264 *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
265 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
266 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
267 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
268 << " Reduced Sigma: " << pix->GetRSigma()
269 << " Nr Phe's: " << pix->GetPheFFactorMethod()
270 << endl;
271 }
272 *fLog << all << endl;
273}
274
275
276// --------------------------------------------------------------------------
277//
278// The types are as follows:
279//
280// Fitted values:
281// ==============
282//
283// 0: Fitted Charge (see MCalibrationPix::GetMean())
284// 1: Error of fitted Charge (see MCalibrationPix::GetMeanErr())
285// 2: Sigma of fitted Charge (see MCalibrationPix::GetSigma())
286// 3: Error of Sigma of fitted Charge (see MCalibrationPix::GetSigmaErr())
287//
288// Useful variables derived from the fit results:
289// =============================================
290//
291// 4: Probability Gauss fit Charge distribution (see MCalibrationPix::GetProb())
292// 5: Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigma())
293// 6: Error Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigmaErr())
294// 7: Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerCharge())
295// 8: Error of Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerChargeErr())
296//
297// Results of the F-Factor calibration Method:
298// ===========================================
299//
300// 9: Nr. Photo-electrons from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethod())
301// 10: Error Nr. Photo-el. from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethodErr())
302// 11: Conversion factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2Phe()
303// 12: Error conv. factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2PheErr()
304// 13: Overall F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2Phot()
305// 14: Error F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()
306// 15: Pixels valid calibration F-Factor-Method (see MCalibrationChargePix::IsFFactorMethodValid())
307//
308// Results of the Low-Gain vs. High-Gain Conversion:
309// =================================================
310//
311// 16: Mean Signal Hi-Gain / Mean Signal Lo-Gain (see MCalibrationPix::GetHiLoMeansDivided())
312// 17: Error Signal High-Gain / Signal Low Gain (see MCalibrationPix::GetHiLoMeansDividedErr())
313// 18: Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDivided())
314// 19: Error Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDividedErr())
315//
316// Localized defects:
317// ==================
318//
319// 20: Excluded Pixels
320// 21: Number of pickup events in the Hi Gain (see MCalibrationPix::GetHiGainNumPickup())
321// 22: Number of pickup events in the Lo Gain (see MCalibrationPix::GetLoGainNumPickup())
322// 23: Number of blackout events in the Hi Gain (see MCalibrationPix::GetHiGainNumBlackout())
323// 24: Number of blackout events in the Lo Gain (see MCalibrationPix::GetLoGainNumBlackout())
324//
325// Other classifications of pixels:
326// ================================
327//
328// 25: Pixels with saturated High-Gain (see MCalibrationPix::IsHiGainSaturation())
329//
330// Calculated absolute arrival times (very low precision!):
331// ========================================================
332//
333// 26: Absolute Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeMean())
334// 27: RMS Ab. Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeRms())
335//
336// Used Pedestals:
337// ===============
338//
339// 28: Pedestal for entire signal extr. range (see MCalibrationChargePix::Ped())
340// 29: Error Pedestal entire signal extr. range (see MCalibrationChargePix::PedErr())
341// 30: Ped. RMS entire signal extraction range (see MCalibrationChargePix::PedRms())
342// 31: Error Ped. RMS entire signal extr. range (see MCalibrationChargePix::PedRmsErr())
343//
344Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
345{
346
347 if (idx > GetSize())
348 return kFALSE;
349
350 Float_t area = cam[idx].GetA();
351
352 if (area == 0)
353 return kFALSE;
354
355 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
356
357 switch (type)
358 {
359 case 0:
360 if (pix.IsExcluded())
361 return kFALSE;
362 val = pix.GetMean();
363 break;
364 case 1:
365 if (pix.IsExcluded())
366 return kFALSE;
367 val = pix.GetMeanErr();
368 break;
369 case 2:
370 if (pix.IsExcluded())
371 return kFALSE;
372 val = pix.GetSigma();
373 break;
374 case 3:
375 if (pix.IsExcluded())
376 return kFALSE;
377 val = pix.GetSigmaErr();
378 break;
379 case 4:
380 if (pix.IsExcluded())
381 return kFALSE;
382 val = pix.GetProb();
383 break;
384 case 5:
385 if (pix.IsExcluded())
386 return kFALSE;
387 if (pix.GetRSigma() == -1.)
388 return kFALSE;
389 val = pix.GetRSigma();
390 break;
391 case 6:
392 if (pix.IsExcluded())
393 return kFALSE;
394 if (pix.GetRSigma() == -1.)
395 return kFALSE;
396 val = pix.GetRSigmaErr();
397 break;
398 case 7:
399 if (pix.IsExcluded())
400 return kFALSE;
401 val = pix.GetRSigmaPerCharge();
402 break;
403 case 8:
404 if (pix.IsExcluded())
405 return kFALSE;
406 val = pix.GetRSigmaPerChargeErr();
407 break;
408 case 9:
409 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
410 return kFALSE;
411 val = pix.GetPheFFactorMethod();
412 break;
413 case 10:
414 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
415 return kFALSE;
416 val = pix.GetPheFFactorMethodErr();
417 break;
418 case 11:
419 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
420 return kFALSE;
421 val = pix.GetMeanConvFADC2Phe();
422 break;
423 case 12:
424 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
425 return kFALSE;
426 val = pix.GetMeanConvFADC2PheErr();
427 break;
428 case 13:
429 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
430 return kFALSE;
431 val = pix.GetMeanFFactorFADC2Phot();
432 break;
433 case 14:
434 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
435 return kFALSE;
436 val = pix.GetMeanFFactorFADC2PhotErr();
437 break;
438 case 15:
439 if (pix.IsExcluded())
440 return kFALSE;
441 if (pix.IsFFactorMethodValid())
442 val = 1;
443 else
444 return kFALSE;
445 break;
446 case 16:
447 if (pix.IsExcluded())
448 return kFALSE;
449 val = pix.GetHiLoMeansDivided();
450 break;
451 case 17:
452 if (pix.IsExcluded())
453 return kFALSE;
454 val = pix.GetHiLoMeansDividedErr();
455 break;
456 case 18:
457 if (pix.IsExcluded())
458 return kFALSE;
459 val = pix.GetHiLoSigmasDivided();
460 break;
461 case 19:
462 if (pix.IsExcluded())
463 return kFALSE;
464 val = pix.GetHiLoSigmasDividedErr();
465 break;
466 case 20:
467 if (pix.IsExcluded())
468 val = 1.;
469 else
470 return kFALSE;
471 break;
472 case 21:
473 if (pix.IsExcluded())
474 return kFALSE;
475 val = pix.GetHiGainNumPickup();
476 break;
477 case 22:
478 if (pix.IsExcluded())
479 return kFALSE;
480 val = pix.GetLoGainNumPickup();
481 break;
482 case 23:
483 if (pix.IsExcluded())
484 return kFALSE;
485 val = pix.GetHiGainNumBlackout();
486 break;
487 case 24:
488 if (pix.IsExcluded())
489 return kFALSE;
490 val = pix.GetLoGainNumBlackout();
491 break;
492 case 25:
493 if (pix.IsExcluded())
494 return kFALSE;
495 val = pix.IsHiGainSaturation();
496 break;
497 case 26:
498 if (pix.IsExcluded())
499 return kFALSE;
500 val = pix.GetAbsTimeMean();
501 break;
502 case 27:
503 if (pix.IsExcluded())
504 return kFALSE;
505 val = pix.GetAbsTimeRms();
506 break;
507 case 28:
508 if (pix.IsExcluded())
509 return kFALSE;
510 val = pix.GetPed();
511 break;
512 case 29:
513 if (pix.IsExcluded())
514 return kFALSE;
515 val = pix.GetPedErr();
516 break;
517 case 30:
518 if (pix.IsExcluded())
519 return kFALSE;
520 val = pix.GetPedRms();
521 break;
522 case 31:
523 if (pix.IsExcluded())
524 return kFALSE;
525 val = pix.GetPedErr()/2.;
526 break;
527 default:
528 return kFALSE;
529 }
530
531 return val!=-1.;
532}
533
534// --------------------------------------------------------------------------
535//
536// Calls MCalibrationChargePix::DrawClone()
537//
538void MCalibrationChargeCam::DrawPixelContent(Int_t idx) const
539{
540 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
541 pix.DrawClone();
542}
543
544
545
546Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor)
547{
548
549 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
550
551 Float_t conv = pix.GetMeanConvFADC2Phe();
552
553 if (conv < 0.)
554 return kFALSE;
555
556 mean = conv;
557 err = pix.GetMeanConvFADC2PheErr();
558 ffactor = pix.GetMeanFFactorFADC2Phot();
559
560 return kTRUE;
561}
562
563
Note: See TracBrowser for help on using the repository browser.