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

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