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

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