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

Last change on this file since 4983 was 4967, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 27.8 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):
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
84#include <TClonesArray.h>
85
86#include "MLog.h"
87#include "MLogManip.h"
88
89#include "MGeomCam.h"
90#include "MGeomPix.h"
91
92#include "MBadPixelsCam.h"
93#include "MBadPixelsPix.h"
94
95#include "MCalibrationQECam.h"
96#include "MCalibrationQEPix.h"
97
98#include "MCalibrationChargePix.h"
99#include "MCalibrationChargeBlindPix.h"
100#include "MCalibrationChargePINDiode.h"
101
102ClassImp(MCalibrationChargeCam);
103
104using namespace std;
105// --------------------------------------------------------------------------
106//
107// Default constructor.
108//
109// Sets all pointers to 0
110//
111// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
112// to hold one container per pixel. Later, a call to MCalibrationChargeCam::InitSize()
113// has to be performed (in MGeomApply).
114//
115// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
116// to hold one container per pixel AREA. Later, a call to MCalibrationChargeCam::InitAreas()
117// has to be performed (in MGeomApply).
118//
119// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
120// to hold one container per camera SECTOR. Later, a call to MCalibrationChargeCam::InitSectors()
121// has to be performed (in MGeomApply).
122//
123// Calls:
124// - Clear()
125//
126MCalibrationChargeCam::MCalibrationChargeCam(const char *name, const char *title)
127{
128 fName = name ? name : "MCalibrationChargeCam";
129 fTitle = title ? title : "Storage container for the Calibration Information in the camera";
130
131 fPixels = new TClonesArray("MCalibrationChargePix",1);
132 fAverageAreas = new TClonesArray("MCalibrationChargePix",1);
133 fAverageSectors = new TClonesArray("MCalibrationChargePix",1);
134
135 Clear();
136}
137
138// --------------------------------------
139//
140// Sets all variable to 0.
141// Sets all flags to kFALSE
142// Calls MCalibrationCam::Clear()
143//
144void MCalibrationChargeCam::Clear(Option_t *o)
145{
146
147 SetFFactorMethodValid ( kFALSE );
148
149 fNumPhotonsBlindPixelMethod = 0.;
150 fNumPhotonsFFactorMethod = 0.;
151 fNumPhotonsPINDiodeMethod = 0.;
152 fNumPhotonsBlindPixelMethodErr = 0.;
153 fNumPhotonsFFactorMethodErr = 0.;
154 fNumPhotonsPINDiodeMethodErr = 0.;
155
156 MCalibrationCam::Clear();
157
158 return;
159}
160
161// -----------------------------------------------
162//
163// Sets the kFFactorMethodValid bit from outside
164//
165void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b)
166{
167 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
168}
169
170
171// --------------------------------------------------------------------------
172//
173// Test bit kFFactorMethodValid
174//
175Bool_t MCalibrationChargeCam::IsFFactorMethodValid() const
176{
177 return TESTBIT(fFlags,kFFactorMethodValid);
178}
179
180// --------------------------------------------------------------------------
181//
182// Print first the well fitted pixels
183// and then the ones which are not FitValid
184//
185void MCalibrationChargeCam::Print(Option_t *o) const
186{
187
188 *fLog << all << GetDescriptor() << ":" << endl;
189 int id = 0;
190
191 *fLog << all << "Calibrated pixels:" << endl;
192 *fLog << all << endl;
193
194 TIter Next(fPixels);
195 MCalibrationChargePix *pix;
196 while ((pix=(MCalibrationChargePix*)Next()))
197 {
198
199 if (!pix->IsExcluded())
200 {
201
202 *fLog << all
203 << Form("%s%3i","Pixel: ",pix->GetPixId())
204 << Form("%s%4.2f%s%4.2f"," Ped.Rms: ",pix->GetPedRms(),"+-",pix->GetPedRmsErr())
205 << Form("%s%4.2f%s%4.2f"," Charge: " ,pix->GetConvertedMean(),"+-",pix->GetConvertedSigma())
206 << Form("%s%4.2f%s%4.2f"," Red.Sigma: ",pix->GetConvertedRSigma(),"+-",pix->GetConvertedRSigmaErr())
207 << Form("%s%4.2f%s%4.2f"," Num.Phes: ",pix->GetPheFFactorMethod(),"+-",pix->GetPheFFactorMethodErr())
208 << Form("%s%4.2f%s%4.2f"," Conv.FADC2Phe: ",pix->GetMeanConvFADC2Phe(),"+-",pix->GetMeanConvFADC2PheErr())
209 << " Saturated? :" << pix->IsHiGainSaturation()
210 << endl;
211 id++;
212 }
213 }
214
215 *fLog << all << id << " pixels" << endl;
216 id = 0;
217
218
219 *fLog << all << endl;
220 *fLog << all << "Excluded pixels:" << endl;
221 *fLog << all << endl;
222
223 id = 0;
224
225 TIter Next4(fPixels);
226 while ((pix=(MCalibrationChargePix*)Next4()))
227 {
228 if (pix->IsExcluded())
229 {
230 *fLog << all << pix->GetPixId() << " ";
231 id++;
232
233 if (!(id % 25))
234 *fLog << endl;
235 }
236 }
237
238 *fLog << endl;
239 *fLog << all << id << " Excluded pixels " << endl;
240 *fLog << endl;
241
242 *fLog << all << endl;
243 *fLog << all << "Averaged Areas:" << endl;
244 *fLog << all << endl;
245
246 TIter Next5(fAverageAreas);
247 while ((pix=(MCalibrationChargePix*)Next5()))
248 {
249 *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
250 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
251 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
252 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
253 << " Reduced Sigma: " << pix->GetRSigma()
254 << " Nr Phe's: " << pix->GetPheFFactorMethod()
255 << endl;
256 }
257
258 *fLog << all << endl;
259 *fLog << all << "Averaged Sectors:" << endl;
260 *fLog << all << endl;
261
262 TIter Next6(fAverageSectors);
263 while ((pix=(MCalibrationChargePix*)Next6()))
264 {
265 *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
266 << " Ped. Rms: " << pix->GetPedRms() << " +- " << pix->GetPedRmsErr()
267 << " Mean signal: " << pix->GetMean() << " +- " << pix->GetMeanErr()
268 << " Sigma signal: " << pix->GetSigma() << " +- "<< pix->GetSigmaErr()
269 << " Reduced Sigma: " << pix->GetRSigma()
270 << " Nr Phe's: " << pix->GetPheFFactorMethod()
271 << endl;
272 }
273 *fLog << all << endl;
274}
275
276
277// --------------------------------------------------------------------------
278//
279// The types are as follows:
280//
281// Fitted values:
282// ==============
283//
284// 0: Fitted Charge (see MCalibrationPix::GetMean())
285// 1: Error of fitted Charge (see MCalibrationPix::GetMeanErr())
286// 2: Sigma of fitted Charge (see MCalibrationPix::GetSigma())
287// 3: Error of Sigma of fitted Charge (see MCalibrationPix::GetSigmaErr())
288//
289// Useful variables derived from the fit results:
290// =============================================
291//
292// 4: Probability Gauss fit Charge distribution (see MCalibrationPix::GetProb())
293// 5: Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigma())
294// 6: Error Reduced Sigma of fitted Charge (see MCalibrationChargePix::GetRSigmaErr())
295// 7: Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerCharge())
296// 8: Error of Reduced Sigma per Charge (see MCalibrationChargePix::GetRSigmaPerChargeErr())
297//
298// Results of the F-Factor calibration Method:
299// ===========================================
300//
301// 9: Nr. Photo-electrons from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethod())
302// 10: Error Nr. Photo-el. from F-Factor Method (see MCalibrationChargePix::GetPheFFactorMethodErr())
303// 11: Conversion factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2Phe()
304// 12: Error conv. factor from F-Factor Method (see MCalibrationChargePix::GetMeanConvFADC2PheErr()
305// 13: Overall F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2Phot()
306// 14: Error F-Factor from F-Factor Method (see MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()
307// 15: Pixels valid calibration F-Factor-Method (see MCalibrationChargePix::IsFFactorMethodValid())
308//
309// Results of the Low-Gain vs. High-Gain Conversion:
310// =================================================
311//
312// 16: Mean Signal Hi-Gain / Mean Signal Lo-Gain (see MCalibrationPix::GetHiLoMeansDivided())
313// 17: Error Signal High-Gain / Signal Low Gain (see MCalibrationPix::GetHiLoMeansDividedErr())
314// 18: Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDivided())
315// 19: Error Sigma High-Gain / Sigma Low Gain (see MCalibrationPix::GetHiLoSigmasDividedErr())
316//
317// Localized defects:
318// ==================
319//
320// 20: Excluded Pixels
321// 21: Number of pickup events in the Hi Gain (see MCalibrationPix::GetHiGainNumPickup())
322// 22: Number of pickup events in the Lo Gain (see MCalibrationPix::GetLoGainNumPickup())
323// 23: Number of blackout events in the Hi Gain (see MCalibrationPix::GetHiGainNumBlackout())
324// 24: Number of blackout events in the Lo Gain (see MCalibrationPix::GetLoGainNumBlackout())
325//
326// Other classifications of pixels:
327// ================================
328//
329// 25: Pixels with saturated High-Gain (see MCalibrationPix::IsHiGainSaturation())
330//
331// Calculated absolute arrival times (very low precision!):
332// ========================================================
333//
334// 26: Absolute Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeMean())
335// 27: RMS Ab. Arrival time of the signal (see MCalibrationChargePix::GetAbsTimeRms())
336//
337// Used Pedestals:
338// ===============
339//
340// 28: Pedestal for entire signal extr. range (see MCalibrationChargePix::Ped())
341// 29: Error Pedestal entire signal extr. range (see MCalibrationChargePix::PedErr())
342// 30: Ped. RMS entire signal extraction range (see MCalibrationChargePix::PedRms())
343// 31: Error Ped. RMS entire signal extr. range (see MCalibrationChargePix::PedRmsErr())
344//
345Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
346{
347
348 if (idx > GetSize())
349 return kFALSE;
350
351 Float_t area = cam[idx].GetA();
352
353 if (area == 0)
354 return kFALSE;
355
356 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
357
358 switch (type)
359 {
360 case 0:
361 if (pix.IsExcluded())
362 return kFALSE;
363 val = pix.GetMean();
364 break;
365 case 1:
366 if (pix.IsExcluded())
367 return kFALSE;
368 val = pix.GetMeanErr();
369 break;
370 case 2:
371 if (pix.IsExcluded())
372 return kFALSE;
373 val = pix.GetSigma();
374 break;
375 case 3:
376 if (pix.IsExcluded())
377 return kFALSE;
378 val = pix.GetSigmaErr();
379 break;
380 case 4:
381 if (pix.IsExcluded())
382 return kFALSE;
383 val = pix.GetProb();
384 break;
385 case 5:
386 if (pix.IsExcluded())
387 return kFALSE;
388 if (pix.GetRSigma() == -1.)
389 return kFALSE;
390 val = pix.GetRSigma();
391 break;
392 case 6:
393 if (pix.IsExcluded())
394 return kFALSE;
395 if (pix.GetRSigma() == -1.)
396 return kFALSE;
397 val = pix.GetRSigmaErr();
398 break;
399 case 7:
400 if (pix.IsExcluded())
401 return kFALSE;
402 val = pix.GetRSigmaPerCharge();
403 break;
404 case 8:
405 if (pix.IsExcluded())
406 return kFALSE;
407 val = pix.GetRSigmaPerChargeErr();
408 break;
409 case 9:
410 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
411 return kFALSE;
412 val = pix.GetPheFFactorMethod();
413 break;
414 case 10:
415 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
416 return kFALSE;
417 val = pix.GetPheFFactorMethodErr();
418 break;
419 case 11:
420 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
421 return kFALSE;
422 val = pix.GetMeanConvFADC2Phe();
423 break;
424 case 12:
425 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
426 return kFALSE;
427 val = pix.GetMeanConvFADC2PheErr();
428 break;
429 case 13:
430 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
431 return kFALSE;
432 val = pix.GetMeanFFactorFADC2Phot();
433 break;
434 case 14:
435 if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
436 return kFALSE;
437 val = pix.GetMeanFFactorFADC2PhotErr();
438 break;
439 case 15:
440 if (pix.IsExcluded())
441 return kFALSE;
442 if (pix.IsFFactorMethodValid())
443 val = 1;
444 else
445 return kFALSE;
446 break;
447 case 16:
448 if (pix.IsExcluded())
449 return kFALSE;
450 val = pix.GetHiLoMeansDivided();
451 break;
452 case 17:
453 if (pix.IsExcluded())
454 return kFALSE;
455 val = pix.GetHiLoMeansDividedErr();
456 break;
457 case 18:
458 if (pix.IsExcluded())
459 return kFALSE;
460 val = pix.GetHiLoSigmasDivided();
461 break;
462 case 19:
463 if (pix.IsExcluded())
464 return kFALSE;
465 val = pix.GetHiLoSigmasDividedErr();
466 break;
467 case 20:
468 if (pix.IsExcluded())
469 val = 1.;
470 else
471 return kFALSE;
472 break;
473 case 21:
474 if (pix.IsExcluded())
475 return kFALSE;
476 val = pix.GetHiGainNumPickup();
477 break;
478 case 22:
479 if (pix.IsExcluded())
480 return kFALSE;
481 val = pix.GetLoGainNumPickup();
482 break;
483 case 23:
484 if (pix.IsExcluded())
485 return kFALSE;
486 val = pix.GetHiGainNumBlackout();
487 break;
488 case 24:
489 if (pix.IsExcluded())
490 return kFALSE;
491 val = pix.GetLoGainNumBlackout();
492 break;
493 case 25:
494 if (pix.IsExcluded())
495 return kFALSE;
496 val = pix.IsHiGainSaturation();
497 break;
498 case 26:
499 if (pix.IsExcluded())
500 return kFALSE;
501 val = pix.GetAbsTimeMean();
502 break;
503 case 27:
504 if (pix.IsExcluded())
505 return kFALSE;
506 val = pix.GetAbsTimeRms();
507 break;
508 case 28:
509 if (pix.IsExcluded())
510 return kFALSE;
511 val = pix.GetPed();
512 break;
513 case 29:
514 if (pix.IsExcluded())
515 return kFALSE;
516 val = pix.GetPedErr();
517 break;
518 case 30:
519 if (pix.IsExcluded())
520 return kFALSE;
521 val = pix.GetPedRms();
522 break;
523 case 31:
524 if (pix.IsExcluded())
525 return kFALSE;
526 val = pix.GetPedErr()/2.;
527 break;
528 default:
529 return kFALSE;
530 }
531
532 return val!=-1.;
533}
534
535// --------------------------------------------------------------------------
536//
537// Calls MCalibrationChargePix::DrawClone()
538//
539void MCalibrationChargeCam::DrawPixelContent(Int_t idx) const
540{
541 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
542 pix.DrawClone();
543}
544
545
546
547Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor)
548{
549
550 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
551
552 Float_t conv = pix.GetMeanConvFADC2Phe();
553
554 if (conv < 0.)
555 return kFALSE;
556
557 mean = conv;
558 err = pix.GetMeanConvFADC2PheErr();
559 ffactor = pix.GetMeanFFactorFADC2Phot();
560
561 return kTRUE;
562}
563
564
565// --------------------------------------------------------------------------
566//
567// Calculates the average conversion factor FADC counts to photons for pixel sizes.
568// The geometry container is used to get the necessary
569// geometry information (area index). The MCalibrationQECam container is necessary for
570// the quantum efficiency information.
571// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
572// in the calculation of the size average.
573//
574// Returns a TArrayF of dimension 2:
575// arr[0]: averaged conversion factors (default: -1.)
576// arr[1]: Error (rms) of averaged conversion factors (default: 0.)
577//
578// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
579//
580TArrayF *MCalibrationChargeCam::GetAveragedConvFADC2PhotPerArea ( const MGeomCam &geom, const MCalibrationQECam &qecam,
581 const UInt_t ai, MBadPixelsCam *bad)
582{
583
584 const Int_t np = GetSize();
585
586 Double_t mean = 0.;
587 Double_t mean2 = 0.;
588 Int_t nr = 0;
589
590 for (int i=0; i<np; i++)
591 {
592 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
593 continue;
594
595 const UInt_t aidx = geom[i].GetAidx();
596
597 if (ai != aidx)
598 continue;
599
600 const MCalibrationQEPix &qepix = (MCalibrationQEPix&)qecam[i];
601 if (!qepix.IsAverageQECombinedAvailable())
602 continue;
603
604 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
605 const Float_t conv = pix.GetMeanConvFADC2Phe();
606 const Float_t qe = qepix.GetQECascadesCombined();
607
608 mean += conv/qe;
609 mean2 += conv*conv/qe/qe;
610 nr ++;
611
612 }
613
614 TArrayF *arr = new TArrayF(2);
615 arr->AddAt(nr ? mean/nr : -1.,0);
616 arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
617
618 return arr;
619}
620
621// --------------------------------------------------------------------------
622//
623// Calculates the average conversion factor FADC counts to photons for camera sectors.
624// The geometry container is used to get the necessary
625// geometry information (area index). The MCalibrationQECam container is necessary for
626// the quantum efficiency information.
627// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
628// in the calculation of the size average.
629//
630// Returns a TArrayF of dimension 2:
631// arr[0]: averaged conversion factors (default: -1.)
632// arr[1]: Error (rms) of averaged conversion factors (default: 0.)
633//
634// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
635//
636TArrayF *MCalibrationChargeCam::GetAveragedConvFADC2PhotPerSector( const MGeomCam &geom, const MCalibrationQECam &qecam,
637 const UInt_t sec, MBadPixelsCam *bad)
638{
639 const Int_t np = GetSize();
640
641 Double_t mean = 0.;
642 Double_t mean2 = 0.;
643 Int_t nr = 0;
644
645 for (int i=0; i<np; i++)
646 {
647 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
648 continue;
649
650 const UInt_t sector = geom[i].GetSector();
651
652 if (sector != sec)
653 continue;
654
655 const MCalibrationQEPix &qepix = (MCalibrationQEPix&)qecam[i];
656 if (!qepix.IsAverageQECombinedAvailable())
657 continue;
658
659 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
660 const Float_t conv = pix.GetMeanConvFADC2Phe();
661 const Float_t qe = qepix.GetQECascadesCombined();
662
663 mean += conv/qe;
664 mean2 += conv*conv/qe/qe;
665 nr ++;
666
667 }
668
669 TArrayF *arr = new TArrayF(2);
670 arr->AddAt(nr ? mean/nr : -1.,0);
671 arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
672
673 return arr;
674}
675
676// --------------------------------------------------------------------------
677//
678// Calculates the average mean arrival times for pixel sizes.
679// The geometry container is used to get the necessary
680// geometry information (area index).
681// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
682// in the calculation of the size average.
683//
684// Returns a TArrayF of dimension 2:
685// arr[0]: averaged mean arrival times (default: -1.)
686// arr[1]: Error (rms) of averaged mean arrival times (default: 0.)
687//
688// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
689//
690TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeMeanPerArea ( const MGeomCam &geom,
691 const UInt_t ai, MBadPixelsCam *bad)
692{
693
694 const Int_t np = GetSize();
695
696 Double_t mean = 0.;
697 Double_t mean2 = 0.;
698 Int_t nr = 0;
699
700 for (int i=0; i<np; i++)
701 {
702 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
703 continue;
704
705 const UInt_t aidx = geom[i].GetAidx();
706
707 if (ai != aidx)
708 continue;
709
710 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
711 const Float_t time = pix.GetAbsTimeMean();
712
713 mean += time ;
714 mean2 += time*time;
715 nr ++;
716
717 }
718
719 TArrayF *arr = new TArrayF(2);
720 arr->AddAt(nr ? mean/nr : -1.,0);
721 arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
722
723 return arr;
724}
725
726// --------------------------------------------------------------------------
727//
728// Calculates the average mean arrival times for camera sectors.
729// The geometry container is used to get the necessary
730// geometry information (area index).
731// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
732// in the calculation of the size average.
733//
734// Returns a TArrayF of dimension 2:
735// arr[0]: averaged mean arrival times (default: -1.)
736// arr[1]: Error (rms) of averaged mean arrival times (default: 0.)
737//
738// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
739//
740TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeMeanPerSector( const MGeomCam &geom,
741 const UInt_t sec, MBadPixelsCam *bad)
742{
743 const Int_t np = GetSize();
744
745 Double_t mean = 0.;
746 Double_t mean2 = 0.;
747 Int_t nr = 0;
748
749 for (int i=0; i<np; i++)
750 {
751 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
752 continue;
753
754 const UInt_t sector = geom[i].GetSector();
755
756 if (sector != sec)
757 continue;
758
759 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
760 const Float_t time = pix.GetAbsTimeMean();
761
762 mean += time;
763 mean2 += time*time;
764 nr ++;
765
766 }
767
768 TArrayF *arr = new TArrayF(2);
769 arr->AddAt(nr ? mean/nr : -1.,0);
770 arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
771
772 return arr;
773}
774
775// --------------------------------------------------------------------------
776//
777// Calculates the average arrival time RMSs for pixel sizes.
778// The geometry container is used to get the necessary
779// geometry information (area index).
780// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
781// in the calculation of the size average.
782//
783// Returns a TArrayF of dimension 2:
784// arr[0]: averaged arrival time RMSs (default: -1.)
785// arr[1]: Error (rms) of averaged arrival time RMSs (default: 0.)
786//
787// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
788//
789TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeRmsPerArea ( const MGeomCam &geom,
790 const UInt_t ai, MBadPixelsCam *bad)
791{
792
793 const Int_t np = GetSize();
794
795 Double_t mean = 0.;
796 Double_t mean2 = 0.;
797 Int_t nr = 0;
798
799 for (int i=0; i<np; i++)
800 {
801 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
802 continue;
803
804 const UInt_t aidx = geom[i].GetAidx();
805
806 if (ai != aidx)
807 continue;
808
809 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
810 const Float_t rms = pix.GetAbsTimeRms();
811
812 mean += rms;
813 mean2 += rms*rms;
814 nr ++;
815
816 }
817
818 TArrayF *arr = new TArrayF(2);
819 arr->AddAt(nr ? mean/nr : -1.,0);
820 arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
821
822 return arr;
823}
824
825// --------------------------------------------------------------------------
826//
827// Calculates the average arrival time RMSs for camera sectors.
828// The geometry container is used to get the necessary
829// geometry information (area index).
830// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
831// in the calculation of the size average.
832//
833// Returns a TArrayF of dimension 2:
834// arr[0]: averaged arrival time RMSs (default: -1.)
835// arr[1]: Error (rms) of averaged arrival time RMSs (default: 0.)
836//
837// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
838//
839TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeRmsPerSector( const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
840{
841 const Int_t np = GetSize();
842
843 Double_t mean = 0.;
844 Double_t mean2 = 0.;
845 Int_t nr = 0;
846
847 for (int i=0; i<np; i++)
848 {
849 if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
850 continue;
851
852 const UInt_t sector = geom[i].GetSector();
853
854 if (sector != sec)
855 continue;
856
857 const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
858 const Float_t rms = pix.GetAbsTimeRms();
859
860 mean += rms;
861 mean2 += rms*rms;
862 nr ++;
863 }
864
865 TArrayF *arr = new TArrayF(2);
866 arr->AddAt(nr ? mean/nr : -1.,0);
867 arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
868
869 return arr;
870}
Note: See TracBrowser for help on using the repository browser.