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

Last change on this file since 8260 was 8106, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 36.6 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCam.cc,v 1.69 2006-10-17 17:18:40 tbretz Exp $
3! --------------------------------------------------------------------------
4!
5! *
6! * This file is part of MARS, the MAGIC Analysis and Reconstruction
7! * Software. It is distributed to you in the hope that it can be a useful
8! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9! * It is distributed WITHOUT ANY WARRANTY.
10! *
11! * Permission to use, copy, modify and distribute this software and its
12! * documentation for any purpose is hereby granted without fee,
13! * provided that the above copyright notice appear in all copies and
14! * that both that copyright notice and this permission notice appear
15! * in supporting documentation. It is provided "as is" without express
16! * or implied warranty.
17! *
18!
19!
20! Author(s): Markus Gaug 11/2003 <mailto:markus@ifae.es>
21!
22! Copyright: MAGIC Software Development, 2000-2004
23!
24!
25\* ======================================================================== */
26/////////////////////////////////////////////////////////////////////////////
27//
28// MCalibrationChargeCam
29//
30// Storage container for charge calibration results from the signal distribution
31// fits (see MHCalibrationChargeCam and MHCalibrationChargePix), the calculation
32// of reduced sigmas and number of photo-electrons (this class) and conversion
33// factors sum FADC slices to photo-electrons (see MCalibrationChargeCalc)
34//
35// Individual pixels have to be cast when retrieved e.g.:
36// MCalibrationChargePix &avpix = (MCalibrationChargePix&)(*fChargeCam)[i]
37//
38// Averaged values over one whole area index (e.g. inner or outer pixels for
39// the MAGIC camera), can be retrieved via:
40// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageArea(i)
41//
42// Averaged values over one whole camera sector can be retrieved via:
43// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageSector(i)
44//
45// Note the averageing has been done on an event-by-event basis. Resulting
46// Sigma's of the Gauss fit have been multiplied with the square root of the number
47// of involved pixels in order to make a direct comparison possible with the mean of
48// sigmas.
49//
50// Final numbers of uncalibrated or unreliable pixels can be retrieved via the commands:
51// GetNumUncalibrated(aidx) and GetNumUnreliable(aidx) where aidx is the area index (0 for
52// inner and 1 for outer pixels in the MAGIC camera).
53//
54// The following "calibration" constants are used for the calibration of each pixel
55// (see MCalibrate):
56//
57// - MCalibrationQEPix::GetMeanConvFADC2Phe(): The mean conversion factor from the
58// summed FADC slices to the number of photo-electrons (in first order independent
59// on colour and intensity)
60// - MCalibrationQEPix::GetMeanFFactorFADC2Phot(): The mean F-Factor of the total
61// readout chain dividing the signal to noise of the incoming number of photons
62// (= sqrt(number photons)) by the signal to noise of the outgoing summed FADC slices
63// signal (= MCalibrationPix::GetMean() / MCalibrationChargePix::GetRSigma() )
64//
65// The following calibration constants can be retrieved directly from this class:
66//
67// - GetConversionFactorFFactor ( Int_t idx, Float_t &mean, Float_t &err, Float_t &sigma );
68//
69// where:
70// - idx is the pixel software ID
71// - "mean" is the mean conversion constant, to be multiplied with the retrieved signal
72// in order to get a calibrated number of PHOTONS.
73// - "err" is the pure statistical uncertainty about the MEAN
74// - "sigma", if mulitplied with the square root of signal, gives the approximate sigma of the
75// retrieved mean number of incident Cherenkov photons.
76//
77// Note, Conversion is ALWAYS (included the F-Factor method!) from summed FADC slices to PHOTONS.
78//
79// See also: MCalibrationChargePix, MCalibrationChargeCalc, MCalibrationQECam
80// MHCalibrationChargePix, MHCalibrationChargeCam
81// MCalibrationBlindPix, MCalibrationChargePINDiode
82//
83/////////////////////////////////////////////////////////////////////////////
84#include "MCalibrationChargeCam.h"
85#include "MCalibrationChargePix.h"
86
87#include <TOrdCollection.h>
88#include <TH1D.h>
89#include <TF1.h>
90
91#include "MLog.h"
92#include "MLogManip.h"
93
94#include "MGeomCam.h"
95#include "MGeomPix.h"
96
97#include "MBadPixelsCam.h"
98#include "MBadPixelsPix.h"
99
100#include "MCalibrationQECam.h"
101#include "MCalibrationQEPix.h"
102
103#include "MHCamera.h"
104
105ClassImp(MCalibrationChargeCam);
106
107using namespace std;
108// --------------------------------------------------------------------------
109//
110// Default constructor.
111//
112// Calls:
113// - Clear()
114//
115MCalibrationChargeCam::MCalibrationChargeCam(const char *name, const char *title)
116{
117 fName = name ? name : "MCalibrationChargeCam";
118 fTitle = title ? title : "Storage container for the Calibration Information in the camera";
119
120 Clear();
121}
122
123/*
124// --------------------------------------------------------------------------
125//
126// Creates new MCalibrationCam only for the averaged areas:
127// the rest has to be retrieved directly, e.g. via:
128//
129TObject *MCalibrationChargeCam::Clone(const char *) const
130{
131
132 //
133 // FIXME, this might be done faster and more elegant, by direct copy.
134 //
135 MCalibrationChargeCam *cam = new MCalibrationChargeCam(fName,fTitle);
136
137 cam->fNumUnsuitable = fNumUnsuitable;
138 cam->fNumUnreliable = fNumUnreliable;
139 cam->fNumHiGainFADCSlices = fNumHiGainFADCSlices;
140 cam->fNumLoGainFADCSlices = fNumLoGainFADCSlices;
141 cam->fPulserColor = fPulserColor;
142
143 cam->fFlags = fFlags;
144
145 cam->fNumPhotonsBlindPixelMethod = fNumPhotonsBlindPixelMethod;
146 cam->fNumPhotonsFFactorMethod = fNumPhotonsFFactorMethod;
147 cam->fNumPhotonsPINDiodeMethod = fNumPhotonsPINDiodeMethod;
148 cam->fNumPhotonsBlindPixelMethodErr = fNumPhotonsBlindPixelMethodErr;
149 cam->fNumPhotonsFFactorMethodErr = fNumPhotonsFFactorMethodErr;
150 cam->fNumPhotonsPINDiodeMethodErr = fNumPhotonsPINDiodeMethodErr;
151
152 for (Int_t i=0; i<GetSize(); i++)
153 cam->fPixels->AddAt((*this)[i].Clone(),i);
154
155 for (Int_t i=0; i<GetAverageAreas(); i++)
156 {
157 cam->fAverageAreas->AddAt(GetAverageArea(i).Clone(),i);
158 cam->fAverageBadAreas->AddAt(GetAverageBadArea(i).Clone(),i);
159 }
160 for (Int_t i=0; i<GetAverageSectors(); i++)
161 {
162 cam->fAverageSectors->AddAt(GetAverageSector(i).Clone(),i);
163 cam->fAverageBadSectors->AddAt(GetAverageBadSector(i).Clone(),i);
164 }
165
166 return cam;
167}
168*/
169
170// -------------------------------------------------------------------
171//
172// Add MCalibrationChargePix's in the ranges from - to to fPixels
173//
174void MCalibrationChargeCam::Add(const UInt_t a, const UInt_t b)
175{
176 for (UInt_t i=a; i<b; i++)
177 {
178 fPixels->AddAt(new MCalibrationChargePix,i);
179 (*this)[i].SetPixId(i);
180 }
181}
182
183// -------------------------------------------------------------------
184//
185// Add MCalibrationChargePix's in the ranges from - to to fAverageAreas
186//
187void MCalibrationChargeCam::AddArea(const UInt_t a, const UInt_t b)
188{
189 for (UInt_t i=a; i<b; i++)
190 {
191 fAverageAreas->AddAt(new MCalibrationChargePix,i);
192 GetAverageArea(i).SetPixId(i);
193 }
194}
195
196// -------------------------------------------------------------------
197//
198// Add MCalibrationChargePix's in the ranges from - to to fAverageSectors
199//
200void MCalibrationChargeCam::AddSector(const UInt_t a, const UInt_t b)
201{
202 for (UInt_t i=a; i<b; i++)
203 {
204 fAverageSectors->AddAt(new MCalibrationChargePix,i);
205 GetAverageSector(i).SetPixId(i);
206 }
207}
208
209
210// --------------------------------------
211//
212// Sets all variable to 0.
213// Sets all flags to kFALSE
214// Calls MCalibrationCam::Clear()
215//
216void MCalibrationChargeCam::Clear(Option_t *o)
217{
218
219 SetFFactorMethodValid ( kFALSE );
220
221 fNumPhotonsBlindPixelMethod = 0.;
222 fNumPhotonsFFactorMethod = 0.;
223 fNumPhotonsPINDiodeMethod = 0.;
224 fNumPhotonsBlindPixelMethodErr = 0.;
225 fNumPhotonsFFactorMethodErr = 0.;
226 fNumPhotonsPINDiodeMethodErr = 0.;
227
228 MCalibrationCam::Clear();
229
230 return;
231}
232
233// -----------------------------------------------
234//
235// Sets the kFFactorMethodValid bit from outside
236//
237void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b)
238{
239 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
240}
241
242
243// --------------------------------------------------------------------------
244//
245// Test bit kFFactorMethodValid
246//
247Bool_t MCalibrationChargeCam::IsFFactorMethodValid() const
248{
249 return TESTBIT(fFlags,kFFactorMethodValid);
250}
251
252// --------------------------------------------------------------------------
253//
254// Copy High-gain vs. low-gain conversion factors from cam to this.
255//
256Bool_t MCalibrationChargeCam::MergeHiLoConversionFactors(const MCalibrationChargeCam &cam) const
257{
258
259 if (GetSize() != cam.GetSize())
260 {
261 *fLog << warn << "Sizes mismatch! Cannot merge high-gain vs. low-gain convertion factors" << endl;
262 return kFALSE;
263 }
264
265 for (Int_t i=0; i<GetSize(); i++)
266 {
267 ((MCalibrationChargePix&)(*this)[i]).SetConversionHiLo (((MCalibrationChargePix&)cam[i]).GetConversionHiLo());
268 ((MCalibrationChargePix&)(*this)[i]).SetConversionHiLoErr(((MCalibrationChargePix&)cam[i]).GetConversionHiLoErr());
269 }
270
271 return kTRUE;
272}
273
274// --------------------------------------------------------------------------
275//
276// Print first the well fitted pixels
277// and then the ones which are not FitValid
278//
279void MCalibrationChargeCam::Print(Option_t *o) const
280{
281
282 *fLog << all << GetDescriptor() << ":" << endl;
283 int id = 0;
284
285 *fLog << all << "Calibrated pixels:" << endl;
286 *fLog << all << endl;
287
288 TIter Next(fPixels);
289 MCalibrationChargePix *pix;
290 while ((pix=(MCalibrationChargePix*)Next()))
291 {
292
293 if (pix->IsFFactorMethodValid())
294 {
295
296 *fLog << all
297 << Form("%s%3i","Pixel: ",pix->GetPixId())
298 << Form("%s%4.2f%s%4.2f"," Ped.Rms: ",pix->GetPedRms(),"+-",pix->GetPedRmsErr())
299 << Form("%s%4.2f%s%4.2f"," Charge: " ,pix->GetConvertedMean(),"+-",pix->GetConvertedSigma())
300 << Form("%s%4.2f%s%4.2f"," Red.Sigma: ",pix->GetConvertedRSigma(),"+-",pix->GetConvertedRSigmaErr())
301 << Form("%s%4.2f%s%4.2f"," Num.Phes: ",pix->GetPheFFactorMethod(),"+-",pix->GetPheFFactorMethodErr())
302 << Form("%s%4.2f%s%4.2f"," Conv.FADC2Phe: ",pix->GetMeanConvFADC2Phe(),"+-",pix->GetMeanConvFADC2PheErr())
303 << " Saturated? :" << pix->IsHiGainSaturation()
304 << Form("%s%4.2f%s%4.2f"," Conv.HiLo: ",pix->GetConversionHiLo(),"+-",pix->GetConversionHiLoErr())
305 << endl;
306 id++;
307 }
308 }
309
310 *fLog << all << id << " pixels" << endl;
311 id = 0;
312
313
314 *fLog << all << endl;
315 *fLog << all << "Previously Excluded pixels:" << endl;
316 *fLog << all << endl;
317
318 id = 0;
319
320 TIter Next4(fPixels);
321 while ((pix=(MCalibrationChargePix*)Next4()))
322 {
323 if (pix->IsExcluded())
324 {
325 *fLog << all << pix->GetPixId() << " ";
326 id++;
327
328 if (!(id % 25))
329 *fLog << endl;
330 }
331 }
332
333 *fLog << all << endl;
334 *fLog << all << "New Excluded pixels:" << endl;
335 *fLog << all << endl;
336
337 TIter Next5(fPixels);
338 while ((pix=(MCalibrationChargePix*)Next5()))
339 {
340 if (!pix->IsFFactorMethodValid() && !pix->IsExcluded())
341 {
342 *fLog << all << pix->GetPixId() << " ";
343 id++;
344
345 if (!(id % 25))
346 *fLog << endl;
347 }
348 }
349
350 *fLog << endl;
351 *fLog << all << id << " Excluded pixels " << endl;
352 *fLog << endl;
353
354 *fLog << all << endl;
355 *fLog << all << "Averaged Areas:" << endl;
356 *fLog << all << endl;
357
358 TIter Next6(fAverageAreas);
359 while ((pix=(MCalibrationChargePix*)Next6()))
360 {
361 *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
362 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
363 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
364 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
365 << " Reduced Sigma: " << pix->GetRSigma()
366 << " Nr Phe's: " << pix->GetPheFFactorMethod()
367 << endl;
368 }
369
370 *fLog << all << endl;
371 *fLog << all << "Averaged Sectors:" << endl;
372 *fLog << all << endl;
373
374 TIter Next7(fAverageSectors);
375 while ((pix=(MCalibrationChargePix*)Next7()))
376 {
377 *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
378 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
379 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
380 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
381 << " Reduced Sigma: " << pix->GetRSigma()
382 << " Nr Phe's: " << pix->GetPheFFactorMethod()
383 << endl;
384 }
385 *fLog << all << endl;
386}
387
388
389// --------------------------------------------------------------------------
390//
391// The types are as follows:
392//
393// Fitted values:
394// ==============
395//
396// 0: Fitted Charge (see MCalibrationPix::GetMean())
397// 1: Error of fitted Charge (see MCalibrationPix::GetMeanErr())
398// 2: Sigma of fitted Charge (see MCalibrationPix::GetSigma())
399// 3: Error of Sigma of fitted Charge (see MCalibrationPix::GetSigmaErr())
400//
401// Useful variables derived from the fit results:
402// =============================================
403//
404// 4: Probability Gauss fit Charge distribution (see MCalibrationPix::GetProb())
405// 5: Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigma())
406// 6: Error Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigmaErr())
407// 7: Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerCharge())
408// 8: Error of Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerChargeErr())
409//
410// Results of the F-Factor calibration Method:
411// ===========================================
412//
413// 9: Nr. Photo-electrons from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethod())
414// 10: Error Nr. Photo-el. from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethodErr())
415// 11: Conversion factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2Phe()
416// 12: Error conv. factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2PheErr()
417// 13: Overall F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2Phot()
418// 14: Error F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()
419// 15: Pixels valid calibration F-Factor-Method (see MCalibrationChargePix::IsFFactorMethodValid())
420//
421// Results of the Low-Gain vs. High-Gain Conversion:
422// =================================================
423//
424// 16: Mean Signal Hi-Gain / Mean Signal Lo-Gain (see MCalibrationPix::GetHiLoMeansDivided())
425// 17: Error Signal High-Gain / Signal Low Gain (see MCalibrationPix::GetHiLoMeansDividedErr())
426// 18: Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDivided())
427// 19: Error Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDividedErr())
428//
429// Localized defects:
430// ==================
431//
432// 20: Excluded Pixels
433// 21: Number of pickup events in the Hi Gain (see MCalibrationPix::GetHiGainNumPickup())
434// 22: Number of pickup events in the Lo Gain (see MCalibrationPix::GetLoGainNumPickup())
435// 23: Number of blackout events in the Hi Gain (see MCalibrationPix::GetHiGainNumBlackout())
436// 24: Number of blackout events in the Lo Gain (see MCalibrationPix::GetLoGainNumBlackout())
437//
438// Other classifications of pixels:
439// ================================
440//
441// 25: Pixels with saturated High-Gain (see MCalibrationPix::IsHiGainSaturation())
442//
443// Calculated absolute arrival times (very low precision!):
444// ========================================================
445//
446// 26: Absolute Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeMean())
447// 27: RMS Ab. Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeRms())
448//
449// Used Pedestals:
450// ===============
451//
452// 28: Pedestal for entire signal extr. range (see MCalibrationChargePix::Ped())
453// 29: Error Pedestal entire signal extr. range (see MCalibrationChargePix::PedErr())
454// 30: Ped. RMS entire signal extraction range (see MCalibrationChargePix::PedRms())
455// 31: Error Ped. RMS entire signal extr. range (see MCalibrationChargePix::PedRmsErr())
456//
457// Special variables (for data check):
458// ====================================
459//
460// 32: HiGain RMS divided by Mean for every pixel (with inclusion of the excluded pixels)
461//
462Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
463{
464
465 if (idx > GetSize())
466 return kFALSE;
467
468 Float_t area = cam[idx].GetA();
469
470 if (area == 0)
471 return kFALSE;
472
473 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
474
475 switch (type)
476 {
477 case 0:
478 if (pix.IsExcluded())
479 return kFALSE;
480 val = pix.GetConvertedMean();
481 break;
482 case 1:
483 if (pix.IsExcluded())
484 return kFALSE;
485 val = pix.GetConvertedMeanErr();
486 break;
487 case 2:
488 if (pix.IsExcluded())
489 return kFALSE;
490 val = pix.GetConvertedSigma();
491 break;
492 case 3:
493 if (pix.IsExcluded())
494 return kFALSE;
495 val = pix.GetConvertedSigmaErr();
496 break;
497 case 4:
498 if (pix.IsExcluded())
499 return kFALSE;
500 val = pix.GetProb();
501 break;
502 case 5:
503 if (!pix.IsFFactorMethodValid())
504 return kFALSE;
505 if (pix.GetRSigma() == -1.)
506 return kFALSE;
507 val = pix.GetConvertedRSigma();
508 break;
509 case 6:
510 if (!pix.IsFFactorMethodValid())
511 return kFALSE;
512 if (pix.GetRSigma() == -1.)
513 return kFALSE;
514 val = pix.GetConvertedRSigmaErr();
515 break;
516 case 7:
517 if (!pix.IsFFactorMethodValid())
518 return kFALSE;
519 val = pix.GetRSigmaPerCharge();
520 break;
521 case 8:
522 if (!pix.IsFFactorMethodValid())
523 return kFALSE;
524 val = pix.GetRSigmaPerChargeErr();
525 break;
526 case 9:
527 // if (!pix.IsFFactorMethodValid())
528 // return kFALSE;
529 if (pix.IsExcluded())
530 return kFALSE;
531 val = pix.GetPheFFactorMethod();
532 break;
533 case 10:
534 // if (!pix.IsFFactorMethodValid())
535 // return kFALSE;
536 if (pix.IsExcluded())
537 return kFALSE;
538 val = pix.GetPheFFactorMethodErr();
539 if (val < 0.)
540 val = 0.00001;
541 break;
542 case 11:
543 // if (!pix.IsFFactorMethodValid())
544 // return kFALSE;
545 if (pix.IsExcluded())
546 return kFALSE;
547 val = pix.GetMeanConvFADC2Phe();
548 break;
549 case 12:
550 // if (!pix.IsFFactorMethodValid())
551 // return kFALSE;
552 if (pix.IsExcluded())
553 return kFALSE;
554 val = pix.GetMeanConvFADC2PheErr();
555 if (val < 0.)
556 val = 0.00001;
557 break;
558 case 13:
559 // if (!pix.IsFFactorMethodValid())
560 // return kFALSE;
561 if (pix.IsExcluded())
562 return kFALSE;
563 val = pix.GetMeanFFactorFADC2Phot();
564 break;
565 case 14:
566 // if (!pix.IsFFactorMethodValid())
567 // return kFALSE;
568 if (pix.IsExcluded())
569 return kFALSE;
570 val = pix.GetMeanFFactorFADC2PhotErr();
571 if (val < 0.)
572 val = 0.00001;
573 break;
574 case 15:
575 if (pix.IsExcluded())
576 return kFALSE;
577 if (pix.IsFFactorMethodValid())
578 val = 1;
579 else
580 return kFALSE;
581 break;
582 case 16:
583 if (pix.IsExcluded())
584 return kFALSE;
585 val = pix.GetHiLoMeansDivided();
586 break;
587 case 17:
588 if (pix.IsExcluded())
589 return kFALSE;
590 val = pix.GetHiLoMeansDividedErr();
591 break;
592 case 18:
593 if (pix.IsExcluded())
594 return kFALSE;
595 val = pix.GetHiLoSigmasDivided();
596 break;
597 case 19:
598 if (pix.IsExcluded())
599 return kFALSE;
600 val = pix.GetHiLoSigmasDividedErr();
601 break;
602 case 20:
603 if (pix.IsExcluded())
604 val = 1.;
605 else
606 return kFALSE;
607 break;
608 case 21:
609 if (pix.IsExcluded())
610 return kFALSE;
611 val = pix.GetHiGainNumPickup();
612 break;
613 case 22:
614 if (pix.IsExcluded())
615 return kFALSE;
616 val = pix.GetLoGainNumPickup();
617 break;
618 case 23:
619 if (pix.IsExcluded())
620 return kFALSE;
621 val = pix.GetHiGainNumBlackout();
622 break;
623 case 24:
624 if (pix.IsExcluded())
625 return kFALSE;
626 val = pix.GetLoGainNumBlackout();
627 break;
628 case 25:
629 if (pix.IsExcluded())
630 return kFALSE;
631 val = pix.IsHiGainSaturation();
632 break;
633 case 26:
634 if (pix.IsExcluded())
635 return kFALSE;
636 val = pix.GetAbsTimeMean();
637 break;
638 case 27:
639 if (pix.IsExcluded())
640 return kFALSE;
641 val = pix.GetAbsTimeRms();
642 break;
643 case 28:
644 if (pix.IsExcluded())
645 return kFALSE;
646 val = pix.GetPed();
647 break;
648 case 29:
649 if (pix.IsExcluded())
650 return kFALSE;
651 val = pix.GetPedErr();
652 break;
653 case 30:
654 if (pix.IsExcluded())
655 return kFALSE;
656 val = pix.GetPedRms();
657 break;
658 case 31:
659 if (pix.IsExcluded())
660 return kFALSE;
661 val = pix.GetPedErr()/2.;
662 break;
663 case 32:
664 if (pix.IsExcluded())
665 return kFALSE;
666 val = pix.GetMean() == 0. ? 0. : pix.GetRms()/pix.GetMean();
667 break;
668 case 33:
669 if (pix.IsExcluded())
670 return kFALSE;
671 if (pix.GetMean() == 0.)
672 val = 0.;
673 else
674 val = pix.GetSigmaErr()/pix.GetMean() + pix.GetRms()/pix.GetMean()/pix.GetMean()*pix.GetMeanErr();
675 break;
676 default:
677 return kFALSE;
678 }
679
680 return val!=-1.;
681}
682
683
684Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &ferr, Float_t &ffactor)
685{
686
687 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
688
689 Float_t conv = pix.GetMeanConvFADC2Phe();
690
691 if (conv < 0.)
692 return kFALSE;
693
694 mean = conv;
695 ferr = pix.GetMeanConvFADC2PheErr();
696 ffactor = pix.GetMeanFFactorFADC2Phot();
697
698 return kTRUE;
699}
700
701
702// --------------------------------------------------------------------------
703//
704// Calculates the average conversion factor FADC counts to photons for pixel sizes.
705// The geometry container is used to get the necessary
706// geometry information (area index). The MCalibrationQECam container is necessary for
707// the quantum efficiency information.
708// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
709// in the calculation of the size average.
710//
711// Returns a TArrayF of dimension 2:
712// arr[0]: averaged conversion factors (default: -1.)
713// arr[1]: Error (rms) of averaged conversion factors (default: 0.)
714//
715TArrayF MCalibrationChargeCam::GetAveragedConvFADC2PhotPerArea ( const MGeomCam &geom, const MCalibrationQECam &qecam,
716 const UInt_t ai, MBadPixelsCam *bad)
717{
718
719 const Int_t np = GetSize();
720
721 Double_t mean = 0.;
722 Double_t mean2 = 0.;
723 Int_t nr = 0;
724
725 MHCamera convcam(geom,"ConvFactors","Conversion Factors;Conv Factor [phot/FADC cnts];channels");
726
727 for (int i=0; i<np; i++)
728 {
729 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
730 continue;
731
732 if (bad && (*bad)[i].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes))
733 continue;
734
735 const UInt_t aidx = geom[i].GetAidx();
736
737 if (ai != aidx)
738 continue;
739
740 const MCalibrationQEPix &qepix = (MCalibrationQEPix&)qecam[i];
741 if (!qepix.IsAverageQEFFactorAvailable())
742 continue;
743
744 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
745 const Float_t conv = pix.GetMeanConvFADC2Phe()/qepix.GetQECascadesFFactor();
746
747 mean += conv;
748 mean2 += conv*conv;
749 nr ++;
750
751 convcam.Fill(i,conv);
752 convcam.SetUsed(i);
753 }
754
755 Float_t mn = nr ? mean/nr : -1.;
756 Float_t sg = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0.;
757
758 const Int_t aidx = (Int_t)ai;
759
760 TH1D *h = convcam.ProjectionS(TArrayI(),TArrayI(1,&aidx),"_py",750);
761 h->SetDirectory(NULL);
762
763 TF1 *fit = NULL;
764
765 if (geom.InheritsFrom("MGeomCamMagic"))
766 {
767
768 fit = new TF1("fit","gaus",0.4,5.);
769
770 // Fix the ranges, as found by Nadia
771 if(aidx == 0)
772 h->Fit(fit, "REQ0", "",0.4,1.5);
773 else
774 h->Fit(fit ,"REQ0", "",1.,5.);
775 }
776 else
777 {
778 h->Fit("gaus","Q0");
779 fit = h->GetFunction("gaus");
780 }
781
782 Float_t ci2 = fit->GetChisquare();
783 Float_t sigma = fit->GetParameter(2);
784
785 if (ci2 > 500. || sigma > sg)
786 {
787 if (geom.InheritsFrom("MGeomCamMagic"))
788 {
789 // Fix the ranges, as found by Nadia
790 if(aidx == 0)
791 h->Fit(fit, "REQ0", "",0.4,1.5);
792 else
793 h->Fit(fit, "REQ0", "",1.,5.);
794 }
795 else
796 {
797 h->Fit("gaus","MREQ0");
798 fit = h->GetFunction("gaus");
799 }
800
801 ci2 = fit->GetChisquare();
802 sigma = fit->GetParameter(2);
803 }
804
805 const Int_t ndf = fit->GetNDF();
806
807 if (ci2 < 500. && sigma < sg && ndf > 2)
808 {
809 mn = fit->GetParameter(1);
810 sg = sigma;
811 }
812
813 *fLog << inf << "Conversion Factors to photons area idx: " << aidx << ":" << endl;
814 *fLog << inf << "Mean: " << Form("%4.3f",mn)
815 << "+-" << Form("%4.3f",fit->GetParError(1))
816 << " Sigma: " << Form("%4.3f",sg) << "+-" << Form("%4.3f",fit->GetParError(2))
817 << " Chisquare: " << Form("%4.3f",fit->GetChisquare()) << " NDF : " << ndf << endl;
818
819 delete fit;
820 delete h;
821 gROOT->GetListOfFunctions()->Remove(fit);
822
823 TArrayF arr(2);
824 arr[0] = mn;
825 arr[1] = sg;
826
827 return arr;
828}
829
830// --------------------------------------------------------------------------
831//
832// Calculates the average conversion factor FADC counts to equiv. photo-electrons for pixel sizes.
833// The geometry container is used to get the necessary
834// geometry information (area index). The MCalibrationQECam container is necessary for
835// the quantum efficiency information.
836// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
837// in the calculation of the size average.
838//
839// Returns a TArrayF of dimension 2:
840// arr[0]: averaged conversion factors (default: -1.)
841// arr[1]: Error (rms) of averaged conversion factors (default: 0.)
842//
843TArrayF MCalibrationChargeCam::GetAveragedConvFADC2PhePerArea ( const MGeomCam &geom, const MCalibrationQECam &qecam,
844 const UInt_t ai, MBadPixelsCam *bad)
845{
846
847 const Int_t np = GetSize();
848
849 Double_t mean = 0.;
850 Double_t mean2 = 0.;
851 Int_t nr = 0;
852
853 MHCamera convcam(geom,"ConvFactors","Conversion Factors;Conv Factor [phe/FADC cnts];channels");
854
855 for (int i=0; i<np; i++)
856 {
857 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
858 continue;
859
860 if (bad && (*bad)[i].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes))
861 continue;
862
863 const UInt_t aidx = geom[i].GetAidx();
864
865 if (ai != aidx)
866 continue;
867
868 const MCalibrationQEPix &qepix = (MCalibrationQEPix&)qecam[i];
869 if (!qepix.IsAverageQEFFactorAvailable())
870 continue;
871
872 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
873 const Float_t conv = pix.GetMeanConvFADC2Phe()/qepix.GetQECascadesFFactor()*MCalibrationQEPix::gkDefaultAverageQE;
874
875 mean += conv;
876 mean2 += conv*conv;
877 nr ++;
878
879 convcam.Fill(i,conv);
880 convcam.SetUsed(i);
881 }
882
883 Float_t mn = nr ? mean/nr : -1.;
884 Float_t sg = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0.;
885
886 const Int_t aidx = (Int_t)ai;
887
888 TH1D *h = convcam.ProjectionS(TArrayI(),TArrayI(1,&aidx),"_py",750);
889 h->SetDirectory(NULL);
890
891 TF1 *fit = NULL;
892
893 if (geom.InheritsFrom("MGeomCamMagic"))
894 {
895
896 fit = new TF1("fit","gaus",0.01,1.);
897
898 // Fix the ranges, as found by Nadia
899 if(aidx == 0)
900 {h->Fit("fit","REQ0", "",0.07,0.3);}
901 else
902 {h->Fit("fit","REQ0", "",0.15,1.0);}
903 }
904 else
905 {
906 h->Fit("gaus","Q0");
907 fit = h->GetFunction("gaus");
908 }
909
910 Float_t ci2 = fit->GetChisquare();
911 Float_t sigma = fit->GetParameter(2);
912
913 if (ci2 > 500. || sigma > sg)
914 {
915 if (geom.InheritsFrom("MGeomCamMagic"))
916 {
917 // Fix the ranges, as found by Nadia
918 if(aidx == 0)
919 {h->Fit("fit","REQ0", "",0.07,0.3);}
920 else
921 {h->Fit("fit","REQ0", "",0.15,1.0);}
922 }
923 else
924 {
925 h->Fit("gaus","MREQ0");
926 fit = h->GetFunction("gaus");
927 }
928
929 ci2 = fit->GetChisquare();
930 sigma = fit->GetParameter(2);
931 }
932
933 const Int_t ndf = fit->GetNDF();
934
935 if (ci2 < 500. && sigma < sg && ndf > 2)
936 {
937 mn = fit->GetParameter(1);
938 sg = sigma;
939 }
940
941 *fLog << inf << "Conversion Factors to equiv. photo-electrons area idx: " << aidx << ":" << endl;
942 *fLog << inf << "Mean: " << Form("%4.3f",mn)
943 << "+-" << Form("%4.3f",fit->GetParError(1))
944 << " Sigma: " << Form("%4.3f",sg) << "+-" << Form("%4.3f",fit->GetParError(2))
945 << " Chisquare: " << Form("%4.3f",fit->GetChisquare()) << " NDF : " << ndf << endl;
946
947 delete fit;
948 delete h;
949 gROOT->GetListOfFunctions()->Remove(fit);
950
951 TArrayF arr(2);
952 arr[0] = mn;
953 arr[1] = sg;
954
955 return arr;
956}
957
958// --------------------------------------------------------------------------
959//
960// Calculates the average conversion factor FADC counts to photons for camera sectors.
961// The geometry container is used to get the necessary
962// geometry information (area index). The MCalibrationQECam container is necessary for
963// the quantum efficiency information.
964// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
965// in the calculation of the size average.
966//
967// Returns a TArrayF of dimension 2:
968// arr[0]: averaged conversion factors (default: -1.)
969// arr[1]: Error (rms) of averaged conversion factors (default: 0.)
970//
971TArrayF MCalibrationChargeCam::GetAveragedConvFADC2PhotPerSector( const MGeomCam &geom, const MCalibrationQECam &qecam,
972 const UInt_t sec, MBadPixelsCam *bad)
973{
974 const Int_t np = GetSize();
975
976 Double_t mean = 0.;
977 Double_t mean2 = 0.;
978 Int_t nr = 0;
979
980 for (int i=0; i<np; i++)
981 {
982 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
983 continue;
984
985 const UInt_t sector = geom[i].GetSector();
986
987 if (sector != sec)
988 continue;
989
990 const MCalibrationQEPix &qepix = (MCalibrationQEPix&)qecam[i];
991 if (!qepix.IsAverageQEFFactorAvailable())
992 continue;
993
994 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
995 const Float_t conv = pix.GetMeanConvFADC2Phe();
996 const Float_t qe = qepix.GetQECascadesFFactor();
997
998 mean += conv/qe;
999 mean2 += conv*conv/qe/qe;
1000 nr ++;
1001
1002 }
1003
1004 TArrayF arr(2);
1005 arr[0] = nr ? mean/nr : -1;
1006 arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0;
1007 return arr;
1008}
1009
1010// --------------------------------------------------------------------------
1011//
1012// Calculates the average mean arrival times for pixel sizes.
1013// The geometry container is used to get the necessary
1014// geometry information (area index).
1015// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
1016// in the calculation of the size average.
1017//
1018// Returns a TArrayF of dimension 2:
1019// arr[0]: averaged mean arrival times (default: -1.)
1020// arr[1]: Error (rms) of averaged mean arrival times (default: 0.)
1021//
1022TArrayF MCalibrationChargeCam::GetAveragedArrivalTimeMeanPerArea(const MGeomCam &geom,
1023 const UInt_t ai, MBadPixelsCam *bad)
1024{
1025
1026 const Int_t np = GetSize();
1027
1028 Double_t mean = 0.;
1029 Double_t mean2 = 0.;
1030 Int_t nr = 0;
1031
1032 for (int i=0; i<np; i++)
1033 {
1034 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
1035 continue;
1036
1037 const UInt_t aidx = geom[i].GetAidx();
1038
1039 if (ai != aidx)
1040 continue;
1041
1042 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
1043 const Float_t time = pix.GetAbsTimeMean();
1044
1045 mean += time ;
1046 mean2 += time*time;
1047 nr ++;
1048
1049 }
1050
1051 TArrayF arr(2);
1052 arr[0] = nr ? mean/nr : -1;
1053 arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0;
1054 return arr;
1055}
1056
1057// --------------------------------------------------------------------------
1058//
1059// Calculates the average mean arrival times for camera sectors.
1060// The geometry container is used to get the necessary
1061// geometry information (area index).
1062// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
1063// in the calculation of the size average.
1064//
1065// Returns a TArrayF of dimension 2:
1066// arr[0]: averaged mean arrival times (default: -1.)
1067// arr[1]: Error (rms) of averaged mean arrival times (default: 0.)
1068//
1069TArrayF MCalibrationChargeCam::GetAveragedArrivalTimeMeanPerSector(const MGeomCam &geom,
1070 const UInt_t sec, MBadPixelsCam *bad)
1071{
1072 const Int_t np = GetSize();
1073
1074 Double_t mean = 0.;
1075 Double_t mean2 = 0.;
1076 Int_t nr = 0;
1077
1078 for (int i=0; i<np; i++)
1079 {
1080 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
1081 continue;
1082
1083 const UInt_t sector = geom[i].GetSector();
1084
1085 if (sector != sec)
1086 continue;
1087
1088 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
1089 const Float_t time = pix.GetAbsTimeMean();
1090
1091 mean += time;
1092 mean2 += time*time;
1093 nr ++;
1094
1095 }
1096
1097 TArrayF arr(2);
1098 arr[0] = nr ? mean/nr : -1;
1099 arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0;
1100 return arr;
1101}
1102
1103// --------------------------------------------------------------------------
1104//
1105// Calculates the average arrival time RMSs for pixel sizes.
1106// The geometry container is used to get the necessary
1107// geometry information (area index).
1108// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
1109// in the calculation of the size average.
1110//
1111// Returns a TArrayF of dimension 2:
1112// arr[0]: averaged arrival time RMSs (default: -1.)
1113// arr[1]: Error (rms) of averaged arrival time RMSs (default: 0.)
1114//
1115TArrayF MCalibrationChargeCam::GetAveragedArrivalTimeRmsPerArea ( const MGeomCam &geom,
1116 const UInt_t ai, MBadPixelsCam *bad)
1117{
1118
1119 const Int_t np = GetSize();
1120
1121 Double_t mean = 0.;
1122 Double_t mean2 = 0.;
1123 Int_t nr = 0;
1124
1125 for (int i=0; i<np; i++)
1126 {
1127 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
1128 continue;
1129
1130 const UInt_t aidx = geom[i].GetAidx();
1131
1132 if (ai != aidx)
1133 continue;
1134
1135 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
1136 const Float_t rms = pix.GetAbsTimeRms();
1137
1138 mean += rms;
1139 mean2 += rms*rms;
1140 nr ++;
1141
1142 }
1143
1144 TArrayF arr(2);
1145 arr[0] = nr ? mean/nr : -1;
1146 arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0;
1147 return arr;
1148}
1149
1150// --------------------------------------------------------------------------
1151//
1152// Calculates the average arrival time RMSs for camera sectors.
1153// The geometry container is used to get the necessary
1154// geometry information (area index).
1155// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
1156// in the calculation of the size average.
1157//
1158// Returns a TArrayF of dimension 2:
1159// arr[0]: averaged arrival time RMSs (default: -1.)
1160// arr[1]: Error (rms) of averaged arrival time RMSs (default: 0.)
1161//
1162TArrayF MCalibrationChargeCam::GetAveragedArrivalTimeRmsPerSector( const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
1163{
1164 const Int_t np = GetSize();
1165
1166 Double_t mean = 0.;
1167 Double_t mean2 = 0.;
1168 Int_t nr = 0;
1169
1170 for (int i=0; i<np; i++)
1171 {
1172 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
1173 continue;
1174
1175 const UInt_t sector = geom[i].GetSector();
1176
1177 if (sector != sec)
1178 continue;
1179
1180 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
1181 const Float_t rms = pix.GetAbsTimeRms();
1182
1183 mean += rms;
1184 mean2 += rms*rms;
1185 nr ++;
1186 }
1187
1188 TArrayF arr(2);
1189 arr[0] = nr ? mean/nr : -1;
1190 arr[1] = nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0;
1191
1192 return arr;
1193}
Note: See TracBrowser for help on using the repository browser.