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

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