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

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