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

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