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-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | // //
|
---|
27 | // MCalibrationPix //
|
---|
28 | // //
|
---|
29 | // This is the storage container to hold informations about the pedestal //
|
---|
30 | // (offset) value of one Pixel (PMT). //
|
---|
31 | // //
|
---|
32 | // The following values are initialized to meaningful values:
|
---|
33 | //
|
---|
34 | // - The Electronic Rms to 1.5 per FADC slice
|
---|
35 | // - The uncertainty about the Electronic RMS to 0.3 per slice
|
---|
36 | // - The F-Factor is assumed to have been measured in Munich to 1.13 - 1.17.
|
---|
37 | // We use here the Square of the Munich definition, thus:
|
---|
38 | // Mean F-Factor = 1.15*1.15 = 1.32
|
---|
39 | // Error F-Factor = 2.*0.02 = 0.04
|
---|
40 | //
|
---|
41 | /////////////////////////////////////////////////////////////////////////////
|
---|
42 | #include "MCalibrationPix.h"
|
---|
43 | #include "MCalibrationConfig.h"
|
---|
44 |
|
---|
45 | #include "MLog.h"
|
---|
46 | #include "MLogManip.h"
|
---|
47 |
|
---|
48 | ClassImp(MCalibrationPix);
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | const Float_t MCalibrationPix::gkElectronicPedRms = 1.5;
|
---|
53 | const Float_t MCalibrationPix::gkErrElectronicPedRms = 0.3;
|
---|
54 | const Float_t MCalibrationPix::gkFFactor = 1.32;
|
---|
55 | const Float_t MCalibrationPix::gkFFactorError = 0.04;
|
---|
56 | const Float_t MCalibrationPix::gkChargeLimit = 3.;
|
---|
57 | const Float_t MCalibrationPix::gkChargeErrLimit = 0.;
|
---|
58 | const Float_t MCalibrationPix::gkChargeRelErrLimit = 1.;
|
---|
59 | const Float_t MCalibrationPix::gkTimeLimit = 1.5;
|
---|
60 | const Float_t MCalibrationPix::gkTimeErrLimit = 3.;
|
---|
61 |
|
---|
62 | // --------------------------------------------------------------------------
|
---|
63 | //
|
---|
64 | // Default Constructor:
|
---|
65 | //
|
---|
66 | MCalibrationPix::MCalibrationPix(const char *name, const char *title)
|
---|
67 | : fPixId(-1),
|
---|
68 | fFlags(0)
|
---|
69 | {
|
---|
70 |
|
---|
71 | fName = name ? name : "MCalibrationPixel";
|
---|
72 | fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
|
---|
73 |
|
---|
74 | //
|
---|
75 | // At the moment, we don't have a database, yet,
|
---|
76 | // so we get it from the configuration file
|
---|
77 | //
|
---|
78 | fConversionHiLo = gkConversionHiLo;
|
---|
79 | fConversionHiLoError = gkConversionHiLoError;
|
---|
80 |
|
---|
81 | fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
|
---|
82 |
|
---|
83 | if (!fHist)
|
---|
84 | *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl;
|
---|
85 |
|
---|
86 | Clear();
|
---|
87 | }
|
---|
88 |
|
---|
89 | MCalibrationPix::~MCalibrationPix()
|
---|
90 | {
|
---|
91 | delete fHist;
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 | // ------------------------------------------------------------------------
|
---|
96 | //
|
---|
97 | // Invalidate values
|
---|
98 | //
|
---|
99 | void MCalibrationPix::Clear(Option_t *o)
|
---|
100 | {
|
---|
101 |
|
---|
102 | fHist->Reset();
|
---|
103 |
|
---|
104 | CLRBIT(fFlags, kHiGainSaturation);
|
---|
105 | CLRBIT(fFlags, kExcluded);
|
---|
106 | CLRBIT(fFlags, kChargeFitValid);
|
---|
107 | CLRBIT(fFlags, kTimeFitValid);
|
---|
108 | CLRBIT(fFlags, kFitted);
|
---|
109 | CLRBIT(fFlags, kBlindPixelMethodValid);
|
---|
110 | CLRBIT(fFlags, kFFactorMethodValid);
|
---|
111 | CLRBIT(fFlags, kPINDiodeMethodValid);
|
---|
112 |
|
---|
113 | fCharge = -1.;
|
---|
114 | fErrCharge = -1.;
|
---|
115 | fSigmaCharge = -1.;
|
---|
116 | fErrSigmaCharge = -1.;
|
---|
117 | fRSigmaSquare = -1.;
|
---|
118 | fChargeProb = -1.;
|
---|
119 | fPed = -1.;
|
---|
120 | fPedRms = -1.;
|
---|
121 | fErrPedRms = 0.;
|
---|
122 | fTime = -1.;
|
---|
123 | fErrTime = -1.;
|
---|
124 | fSigmaTime = -1.;
|
---|
125 | fTimeProb = -1.;
|
---|
126 | fTimeFirstHiGain = 0 ;
|
---|
127 | fTimeLastHiGain = 0 ;
|
---|
128 | fTimeFirstLoGain = 0 ;
|
---|
129 | fTimeLastLoGain = 0 ;
|
---|
130 |
|
---|
131 | fPheFFactorMethod = -1.;
|
---|
132 | fPheFFactorMethodError = -1.;
|
---|
133 | fConversionFFactorMethod = -1.;
|
---|
134 | fConversionBlindPixelMethod = -1.;
|
---|
135 | fConversionPINDiodeMethod = -1.;
|
---|
136 | fConversionErrorFFactorMethod = -1.;
|
---|
137 | fConversionErrorBlindPixelMethod = -1.;
|
---|
138 | fConversionErrorPINDiodeMethod = -1.;
|
---|
139 | fConversionSigmaFFactorMethod = -1.;
|
---|
140 | fConversionSigmaBlindPixelMethod = -1.;
|
---|
141 | fConversionSigmaPINDiodeMethod = -1.;
|
---|
142 |
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | void MCalibrationPix::DefinePixId(Int_t i)
|
---|
147 | {
|
---|
148 |
|
---|
149 | fPixId = i;
|
---|
150 | fHist->ChangeHistId(i);
|
---|
151 |
|
---|
152 | }
|
---|
153 |
|
---|
154 |
|
---|
155 | // --------------------------------------------------------------------------
|
---|
156 | //
|
---|
157 | // Set the pedestals from outside
|
---|
158 | //
|
---|
159 | void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
|
---|
160 | {
|
---|
161 |
|
---|
162 | fPed = ped;
|
---|
163 | fPedRms = pedrms;
|
---|
164 |
|
---|
165 | }
|
---|
166 |
|
---|
167 | // --------------------------------------------------------------------------
|
---|
168 | //
|
---|
169 | // Set the conversion factors from outside (only for MC)
|
---|
170 | //
|
---|
171 | void MCalibrationPix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
|
---|
172 | {
|
---|
173 | fConversionFFactorMethod = c;
|
---|
174 | fConversionErrorFFactorMethod = err;
|
---|
175 | fConversionSigmaFFactorMethod = sig;
|
---|
176 | }
|
---|
177 |
|
---|
178 |
|
---|
179 | // --------------------------------------------------------------------------
|
---|
180 | //
|
---|
181 | // Set the conversion factors from outside (only for MC)
|
---|
182 | //
|
---|
183 | void MCalibrationPix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
|
---|
184 | {
|
---|
185 | fConversionBlindPixelMethod = c;
|
---|
186 | fConversionErrorBlindPixelMethod = err;
|
---|
187 | fConversionSigmaBlindPixelMethod = sig;
|
---|
188 | }
|
---|
189 |
|
---|
190 | // --------------------------------------------------------------------------
|
---|
191 | //
|
---|
192 | // Set the conversion factors from outside (only for MC)
|
---|
193 | //
|
---|
194 | void MCalibrationPix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
|
---|
195 | {
|
---|
196 | fConversionPINDiodeMethod = c ;
|
---|
197 | fConversionErrorPINDiodeMethod = err;
|
---|
198 | fConversionSigmaPINDiodeMethod = sig;
|
---|
199 | }
|
---|
200 |
|
---|
201 | // --------------------------------------------------------------------------
|
---|
202 | //
|
---|
203 | // Set the Hi Gain Saturation Bit from outside (only for MC)
|
---|
204 | //
|
---|
205 | void MCalibrationPix::SetHiGainSaturation(Bool_t b)
|
---|
206 | {
|
---|
207 |
|
---|
208 | if (b)
|
---|
209 | {
|
---|
210 | SETBIT(fFlags, kHiGainSaturation);
|
---|
211 | fHist->SetUseLoGain(1);
|
---|
212 | }
|
---|
213 | else
|
---|
214 | {
|
---|
215 | CLRBIT(fFlags, kHiGainSaturation);
|
---|
216 | fHist->SetUseLoGain(0);
|
---|
217 | }
|
---|
218 | }
|
---|
219 |
|
---|
220 | // --------------------------------------------------------------------------
|
---|
221 | //
|
---|
222 | // Set the Excluded Bit from outside
|
---|
223 | //
|
---|
224 | void MCalibrationPix::SetExcluded(Bool_t b )
|
---|
225 | {
|
---|
226 | b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
|
---|
227 | }
|
---|
228 |
|
---|
229 |
|
---|
230 | // --------------------------------------------------------------------------
|
---|
231 | //
|
---|
232 | // Set the Excluded Bit from outside
|
---|
233 | //
|
---|
234 | void MCalibrationPix::SetExcludeQualityCheck(Bool_t b )
|
---|
235 | {
|
---|
236 | b ? SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck);
|
---|
237 | }
|
---|
238 |
|
---|
239 | // --------------------------------------------------------------------------
|
---|
240 | //
|
---|
241 | // Set the Excluded Bit from outside
|
---|
242 | //
|
---|
243 | void MCalibrationPix::SetChargeFitValid(Bool_t b )
|
---|
244 | {
|
---|
245 | b ? SETBIT(fFlags, kChargeFitValid) : CLRBIT(fFlags, kChargeFitValid);
|
---|
246 | }
|
---|
247 |
|
---|
248 | // --------------------------------------------------------------------------
|
---|
249 | //
|
---|
250 | // Set the Excluded Bit from outside
|
---|
251 | //
|
---|
252 | void MCalibrationPix::SetTimeFitValid(Bool_t b )
|
---|
253 | {
|
---|
254 | b ? SETBIT(fFlags, kTimeFitValid) : CLRBIT(fFlags, kTimeFitValid);
|
---|
255 | }
|
---|
256 |
|
---|
257 | // --------------------------------------------------------------------------
|
---|
258 | //
|
---|
259 | // Set the Excluded Bit from outside
|
---|
260 | //
|
---|
261 | void MCalibrationPix::SetFitted(Bool_t b )
|
---|
262 | {
|
---|
263 | b ? SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted);
|
---|
264 | }
|
---|
265 |
|
---|
266 | // --------------------------------------------------------------------------
|
---|
267 | //
|
---|
268 | // Set the Excluded Bit from outside
|
---|
269 | //
|
---|
270 | void MCalibrationPix::SetBlindPixelMethodValid(Bool_t b )
|
---|
271 | {
|
---|
272 | b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
|
---|
273 | }
|
---|
274 |
|
---|
275 | // --------------------------------------------------------------------------
|
---|
276 | //
|
---|
277 | // Set the Excluded Bit from outside
|
---|
278 | //
|
---|
279 | void MCalibrationPix::SetFFactorMethodValid(Bool_t b )
|
---|
280 | {
|
---|
281 | b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
|
---|
282 | }
|
---|
283 |
|
---|
284 | // --------------------------------------------------------------------------
|
---|
285 | //
|
---|
286 | // Set the Excluded Bit from outside
|
---|
287 | //
|
---|
288 | void MCalibrationPix::SetPINDiodeMethodValid(Bool_t b )
|
---|
289 | {
|
---|
290 | b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
|
---|
291 | }
|
---|
292 |
|
---|
293 | void MCalibrationPix::SetAbsTimeBordersHiGain(Byte_t f, Byte_t l)
|
---|
294 | {
|
---|
295 |
|
---|
296 | fTimeFirstHiGain = f;
|
---|
297 | fTimeLastHiGain = l;
|
---|
298 |
|
---|
299 | }
|
---|
300 |
|
---|
301 | void MCalibrationPix::SetAbsTimeBordersLoGain(Byte_t f, Byte_t l)
|
---|
302 | {
|
---|
303 |
|
---|
304 | fTimeFirstLoGain = f;
|
---|
305 | fTimeLastLoGain = l;
|
---|
306 |
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 |
|
---|
311 | Bool_t MCalibrationPix::IsExcluded() const
|
---|
312 | {
|
---|
313 | return TESTBIT(fFlags,kExcluded);
|
---|
314 | }
|
---|
315 |
|
---|
316 | Bool_t MCalibrationPix::IsChargeFitValid() const
|
---|
317 | {
|
---|
318 | return TESTBIT(fFlags, kChargeFitValid);
|
---|
319 | }
|
---|
320 |
|
---|
321 | Bool_t MCalibrationPix::IsTimeFitValid() const
|
---|
322 | {
|
---|
323 | return TESTBIT(fFlags, kTimeFitValid);
|
---|
324 | }
|
---|
325 |
|
---|
326 | Bool_t MCalibrationPix::IsFitted() const
|
---|
327 | {
|
---|
328 | return TESTBIT(fFlags, kFitted);
|
---|
329 | }
|
---|
330 |
|
---|
331 | Bool_t MCalibrationPix::IsBlindPixelMethodValid() const
|
---|
332 | {
|
---|
333 | return TESTBIT(fFlags, kBlindPixelMethodValid);
|
---|
334 | }
|
---|
335 |
|
---|
336 | Bool_t MCalibrationPix::IsFFactorMethodValid() const
|
---|
337 | {
|
---|
338 | return TESTBIT(fFlags, kFFactorMethodValid);
|
---|
339 | }
|
---|
340 |
|
---|
341 | Bool_t MCalibrationPix::IsPINDiodeMethodValid() const
|
---|
342 | {
|
---|
343 | return TESTBIT(fFlags, kPINDiodeMethodValid);
|
---|
344 | }
|
---|
345 |
|
---|
346 |
|
---|
347 | // --------------------------------------------------------------------------
|
---|
348 | //
|
---|
349 | // 1) Return if the charge distribution is already succesfully fitted
|
---|
350 | // or if the histogram is empty
|
---|
351 | // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
|
---|
352 | // possible remaining cosmics to spoil the fit.
|
---|
353 | // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
|
---|
354 | // 4) Fit the histograms with a Gaussian
|
---|
355 | // 5) In case of failure set the bit kFitted to false
|
---|
356 | // 6) Retrieve the results and store them in this class
|
---|
357 | // 7) Calculate the number of photo-electrons after the F-Factor method
|
---|
358 | // 8) Calculate the errors of the F-Factor method
|
---|
359 | //
|
---|
360 | // The fits are declared valid (fFitValid = kTRUE), if:
|
---|
361 | //
|
---|
362 | // 1) Pixel has a fitted charge greater than 3*PedRMS
|
---|
363 | // 2) Pixel has a fit error greater than 0.
|
---|
364 | // 3) Pixel has a fit Probability greater than 0.0001
|
---|
365 | // 4) Pixel has a charge sigma bigger than its Pedestal RMS
|
---|
366 | // 5) If FitTimes is used,
|
---|
367 | // the mean arrival time is at least 1.0 slices from the used edge slices
|
---|
368 | // (this stage is only performed in the times fit)
|
---|
369 | //
|
---|
370 | // If the histogram is empty, all values are set to -1.
|
---|
371 | //
|
---|
372 | // The conversion factor after the F-Factor method is declared valid, if:
|
---|
373 | //
|
---|
374 | // 1) fFitValid is kTRUE
|
---|
375 | // 2) Conversion Factor is bigger than 0.
|
---|
376 | // 3) The error of the conversion factor is smaller than 10%
|
---|
377 | //
|
---|
378 | Bool_t MCalibrationPix::FitCharge()
|
---|
379 | {
|
---|
380 |
|
---|
381 | //
|
---|
382 | // 1) Return if the charge distribution is already succesfully fitted
|
---|
383 | // or if the histogram is empty
|
---|
384 | //
|
---|
385 | if (fHist->IsChargeFitOK() || fHist->IsEmpty())
|
---|
386 | return kTRUE;
|
---|
387 |
|
---|
388 | //
|
---|
389 | // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
|
---|
390 | // possible remaining cosmics to spoil the fit.
|
---|
391 | //
|
---|
392 | // if (fPed && fPedRms)
|
---|
393 | // fHist->SetLowerFitRange(1.5*fPedRms);
|
---|
394 | // else
|
---|
395 | // *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl;
|
---|
396 |
|
---|
397 | //
|
---|
398 | // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
|
---|
399 | //
|
---|
400 | if (fHist->UseLoGain())
|
---|
401 | SetHiGainSaturation();
|
---|
402 |
|
---|
403 | //
|
---|
404 | // 4) Fit the Lo Gain histograms with a Gaussian
|
---|
405 | //
|
---|
406 | if(fHist->FitCharge())
|
---|
407 | {
|
---|
408 | SETBIT(fFlags,kFitted);
|
---|
409 | }
|
---|
410 | else
|
---|
411 | {
|
---|
412 | *fLog << warn << "WARNING: Could not fit charges of pixel " << fPixId << endl;
|
---|
413 | //
|
---|
414 | // 5) In case of failure set the bit kFitted to false
|
---|
415 | //
|
---|
416 | CLRBIT(fFlags,kFitted);
|
---|
417 | }
|
---|
418 |
|
---|
419 | //
|
---|
420 | // 6) Retrieve the results and store them in this class
|
---|
421 | //
|
---|
422 | fCharge = fHist->GetChargeMean();
|
---|
423 | fErrCharge = fHist->GetChargeMeanErr();
|
---|
424 | fSigmaCharge = fHist->GetChargeSigma();
|
---|
425 | fErrSigmaCharge = fHist->GetChargeSigmaErr();
|
---|
426 | fChargeProb = fHist->GetChargeProb();
|
---|
427 |
|
---|
428 | if (CheckChargeFitValidity())
|
---|
429 | SETBIT(fFlags,kChargeFitValid);
|
---|
430 | else
|
---|
431 | {
|
---|
432 | CLRBIT(fFlags,kChargeFitValid);
|
---|
433 | return kFALSE;
|
---|
434 | }
|
---|
435 |
|
---|
436 | //
|
---|
437 | // 7) Calculate the number of photo-electrons after the F-Factor method
|
---|
438 | // 8) Calculate the errors of the F-Factor method
|
---|
439 | //
|
---|
440 | if ((fPed > 0.) && (fPedRms > 0.))
|
---|
441 | {
|
---|
442 |
|
---|
443 | //
|
---|
444 | // Square all variables in order to avoid applications of square root
|
---|
445 | //
|
---|
446 | // First the relative error squares
|
---|
447 | //
|
---|
448 | const Float_t chargeSquare = fCharge* fCharge;
|
---|
449 | const Float_t chargeSquareRelErrSquare = 4.*fErrCharge*fErrCharge / chargeSquare;
|
---|
450 |
|
---|
451 | const Float_t fFactorRelErrSquare = gkFFactorError * gkFFactorError / (gkFFactor * gkFFactor);
|
---|
452 | //
|
---|
453 | // Now the absolute error squares
|
---|
454 | //
|
---|
455 | const Float_t sigmaSquare = fSigmaCharge* fSigmaCharge;
|
---|
456 | const Float_t sigmaSquareErrSquare = 4.*fErrSigmaCharge*fErrSigmaCharge * sigmaSquare;
|
---|
457 |
|
---|
458 | const Float_t elecRmsSquare = gkElectronicPedRms* gkElectronicPedRms;
|
---|
459 | const Float_t elecRmsSquareErrSquare = 4.*gkErrElectronicPedRms*gkErrElectronicPedRms * elecRmsSquare;
|
---|
460 |
|
---|
461 | Float_t pedRmsSquare = fPedRms* fPedRms;
|
---|
462 | Float_t pedRmsSquareErrSquare = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
|
---|
463 |
|
---|
464 | if (TESTBIT(fFlags,kHiGainSaturation))
|
---|
465 | {
|
---|
466 |
|
---|
467 | //
|
---|
468 | // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
|
---|
469 | // from the Hi Gain:
|
---|
470 | //
|
---|
471 | // We extract the pure NSB contribution:
|
---|
472 | //
|
---|
473 | Float_t nsbSquare = pedRmsSquare - elecRmsSquare;
|
---|
474 | Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
|
---|
475 | / (nsbSquare * nsbSquare) ;
|
---|
476 |
|
---|
477 | if (nsbSquare < 0.)
|
---|
478 | nsbSquare = 0.;
|
---|
479 |
|
---|
480 | //
|
---|
481 | // Now, we divide the NSB by the conversion factor and
|
---|
482 | // add it quadratically to the electronic noise
|
---|
483 | //
|
---|
484 | const Float_t conversionSquare = fConversionHiLo *fConversionHiLo;
|
---|
485 | const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoError*fConversionHiLoError/conversionSquare;
|
---|
486 |
|
---|
487 | //
|
---|
488 | // Calculate the new "Pedestal RMS"
|
---|
489 | //
|
---|
490 | const Float_t convertedNsbSquare = nsbSquare / conversionSquare;
|
---|
491 | const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
|
---|
492 | * convertedNsbSquare * convertedNsbSquare;
|
---|
493 |
|
---|
494 | pedRmsSquare = convertedNsbSquare + elecRmsSquare;
|
---|
495 | pedRmsSquareErrSquare = convertedNsbSquareErrSquare + elecRmsSquareErrSquare;
|
---|
496 |
|
---|
497 | } /* if (kHiGainSaturation) */
|
---|
498 |
|
---|
499 | //
|
---|
500 | // Calculate the reduced sigmas
|
---|
501 | //
|
---|
502 | fRSigmaSquare = sigmaSquare - pedRmsSquare;
|
---|
503 | if (fRSigmaSquare <= 0.)
|
---|
504 | {
|
---|
505 | *fLog << warn
|
---|
506 | << "WARNING: Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel "
|
---|
507 | << fPixId << endl;
|
---|
508 | if (TESTBIT(fFlags,kHiGainSaturation))
|
---|
509 | ApplyLoGainConversion();
|
---|
510 | return kFALSE;
|
---|
511 | }
|
---|
512 |
|
---|
513 | const Float_t rSigmaSquareRelErrSquare = (sigmaSquareErrSquare + pedRmsSquareErrSquare)
|
---|
514 | / (fRSigmaSquare * fRSigmaSquare) ;
|
---|
515 |
|
---|
516 | //
|
---|
517 | // Calculate the number of phe's from the F-Factor method
|
---|
518 | // (independent on Hi Gain or Lo Gain)
|
---|
519 | //
|
---|
520 | fPheFFactorMethod = gkFFactor * chargeSquare / fRSigmaSquare;
|
---|
521 |
|
---|
522 | const Float_t pheFFactorRelErrSquare = fFactorRelErrSquare
|
---|
523 | + chargeSquareRelErrSquare
|
---|
524 | + rSigmaSquareRelErrSquare ;
|
---|
525 |
|
---|
526 | fPheFFactorMethodError = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
|
---|
527 |
|
---|
528 | //
|
---|
529 | // Calculate the conversion factors
|
---|
530 | //
|
---|
531 | if (TESTBIT(fFlags,kHiGainSaturation))
|
---|
532 | ApplyLoGainConversion();
|
---|
533 |
|
---|
534 | const Float_t chargeRelErrSquare = fErrCharge*fErrCharge / (fCharge * fCharge);
|
---|
535 |
|
---|
536 | fConversionFFactorMethod = fPheFFactorMethod / fCharge ;
|
---|
537 | fConversionErrorFFactorMethod = ( pheFFactorRelErrSquare + chargeRelErrSquare )
|
---|
538 | * fConversionFFactorMethod * fConversionFFactorMethod;
|
---|
539 |
|
---|
540 | if ( IsChargeFitValid() &&
|
---|
541 | (fConversionFFactorMethod > 0.) &&
|
---|
542 | (fConversionErrorFFactorMethod/fConversionFFactorMethod < 0.1) )
|
---|
543 | SETBIT(fFlags,kFFactorMethodValid);
|
---|
544 | else
|
---|
545 | CLRBIT(fFlags,kFFactorMethodValid);
|
---|
546 |
|
---|
547 | } /* if ((fPed > 0.) && (fPedRms > 0.)) */
|
---|
548 |
|
---|
549 | return kTRUE;
|
---|
550 |
|
---|
551 | }
|
---|
552 |
|
---|
553 | //
|
---|
554 | // The check return kTRUE if:
|
---|
555 | //
|
---|
556 | // 0) No value is nan
|
---|
557 | // 1) Pixel has a fitted charge greater than 3*PedRMS
|
---|
558 | // 2) Pixel has a fit error greater than 0.
|
---|
559 | // 3) Pixel has a fitted charge greater its charge error
|
---|
560 | // 4) Pixel has a fit Probability greater than 0.0001
|
---|
561 | // 5) Pixel has a charge sigma bigger than its Pedestal RMS
|
---|
562 | //
|
---|
563 | Bool_t MCalibrationPix::CheckChargeFitValidity()
|
---|
564 | {
|
---|
565 |
|
---|
566 | if (TMath::IsNaN(fCharge)
|
---|
567 | || TMath::IsNaN(fErrCharge)
|
---|
568 | || TMath::IsNaN(fSigmaCharge)
|
---|
569 | || TMath::IsNaN(fErrSigmaCharge)
|
---|
570 | || TMath::IsNaN(fChargeProb))
|
---|
571 | {
|
---|
572 | *fLog << warn << "WARNING: Some of the fit values are NAN in Pixel " << fPixId << endl;
|
---|
573 | return kFALSE;
|
---|
574 | }
|
---|
575 |
|
---|
576 |
|
---|
577 | if (TESTBIT(fFlags,kExcludeQualityCheck))
|
---|
578 | return kTRUE;
|
---|
579 |
|
---|
580 | Float_t equivpedestal = GetPedRms();
|
---|
581 |
|
---|
582 | if (TESTBIT(fFlags,kHiGainSaturation))
|
---|
583 | equivpedestal /= fConversionHiLo;
|
---|
584 |
|
---|
585 | if (fCharge < gkChargeLimit*equivpedestal)
|
---|
586 | {
|
---|
587 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
588 | << gkChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
|
---|
589 | return kFALSE;
|
---|
590 | }
|
---|
591 |
|
---|
592 | if (fErrCharge < gkChargeErrLimit)
|
---|
593 | {
|
---|
594 | *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
|
---|
595 | << gkChargeErrLimit << " in Pixel " << fPixId << endl;
|
---|
596 | return kFALSE;
|
---|
597 | }
|
---|
598 |
|
---|
599 | if (fCharge < gkChargeRelErrLimit*fErrCharge)
|
---|
600 | {
|
---|
601 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
602 | << gkChargeRelErrLimit << "* its error in Pixel " << fPixId << endl;
|
---|
603 | return kFALSE;
|
---|
604 | }
|
---|
605 |
|
---|
606 | if (!fHist->IsChargeFitOK())
|
---|
607 | {
|
---|
608 | *fLog << warn << "WARNING: Probability of Fitted Charge too low in Pixel "
|
---|
609 | << fPixId << endl;
|
---|
610 | return kFALSE;
|
---|
611 | }
|
---|
612 |
|
---|
613 | if (fSigmaCharge < equivpedestal)
|
---|
614 | {
|
---|
615 | *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel "
|
---|
616 | << fPixId << endl;
|
---|
617 | return kFALSE;
|
---|
618 | }
|
---|
619 | return kTRUE;
|
---|
620 | }
|
---|
621 |
|
---|
622 | //
|
---|
623 | // The check return kTRUE if:
|
---|
624 | //
|
---|
625 | // 0) No value is nan
|
---|
626 | // 1) Pixel has a fitted rel. time smaller than 3*FADC slices
|
---|
627 | // 2) Pixel has a fit error greater than 0.
|
---|
628 | // 4) Pixel has a fit Probability greater than 0.001
|
---|
629 | // 5) The absolute arrival time is at least 1.0 slices from the used edge slices
|
---|
630 | //
|
---|
631 | Bool_t MCalibrationPix::CheckTimeFitValidity()
|
---|
632 | {
|
---|
633 |
|
---|
634 | if (TMath::IsNaN(fTime)
|
---|
635 | || TMath::IsNaN(fErrTime)
|
---|
636 | || TMath::IsNaN(fSigmaTime)
|
---|
637 | || TMath::IsNaN(fTimeProb))
|
---|
638 | {
|
---|
639 | *fLog << warn << "WARNING: Some of the time fit values are NAN in Pixel "
|
---|
640 | << fPixId << endl;
|
---|
641 | return kFALSE;
|
---|
642 | }
|
---|
643 |
|
---|
644 | if (TESTBIT(fFlags,kExcludeQualityCheck))
|
---|
645 | return kTRUE;
|
---|
646 |
|
---|
647 | if (TMath::Abs(fTime) > gkTimeLimit)
|
---|
648 | {
|
---|
649 | *fLog << warn << "WARNING: Abs(Fitted Rel. Time) is greater than "
|
---|
650 | << gkTimeLimit << " in Pixel " << fPixId << endl;
|
---|
651 | return kFALSE;
|
---|
652 | }
|
---|
653 |
|
---|
654 | if (fErrTime > gkTimeErrLimit)
|
---|
655 | {
|
---|
656 | *fLog << warn << "WARNING: Error of Fitted Time is smaller than "
|
---|
657 | << gkTimeErrLimit << " in Pixel " << fPixId << endl;
|
---|
658 | return kFALSE;
|
---|
659 | }
|
---|
660 |
|
---|
661 | if (!fHist->IsTimeFitOK())
|
---|
662 | {
|
---|
663 | *fLog << warn << "WARNING: Probability of Fitted Time too low in Pixel "
|
---|
664 | << fPixId << endl;
|
---|
665 | return kFALSE;
|
---|
666 | }
|
---|
667 |
|
---|
668 | Float_t first;
|
---|
669 | Float_t last;
|
---|
670 |
|
---|
671 | if (TESTBIT(fFlags,kHiGainSaturation))
|
---|
672 | {
|
---|
673 | first = (Float_t)fHist->GetAbsTimeFirstLoGain();
|
---|
674 | last = (Float_t)fHist->GetAbsTimeLastLoGain();
|
---|
675 |
|
---|
676 | if (first < (Float_t)fTimeFirstLoGain+1)
|
---|
677 | {
|
---|
678 | *fLog << warn
|
---|
679 | << "WARNING: Some absolute times smaller than limit in Pixel "
|
---|
680 | << fPixId << " time: " << first << " Limit: " << fTimeFirstLoGain+1 << endl;
|
---|
681 | return kFALSE;
|
---|
682 | }
|
---|
683 |
|
---|
684 | if ((Float_t)fTimeLastLoGain-1 > last)
|
---|
685 | {
|
---|
686 | *fLog << warn
|
---|
687 | << "WARNING: Some absolute times bigger than limit in Pixel "
|
---|
688 | << fPixId << " time: " << last << " Limit: " << fTimeLastLoGain-1 << endl;
|
---|
689 | return kFALSE;
|
---|
690 | }
|
---|
691 |
|
---|
692 | }
|
---|
693 | else
|
---|
694 | {
|
---|
695 | first = (Float_t)fHist->GetAbsTimeFirstHiGain();
|
---|
696 | last = (Float_t)fHist->GetAbsTimeLastHiGain();
|
---|
697 |
|
---|
698 | if (first > ((Float_t)fTimeFirstHiGain+1.))
|
---|
699 | {
|
---|
700 | *fLog << warn
|
---|
701 | << "WARNING: Some absolute times smaller than limit in Pixel "
|
---|
702 | << fPixId << " time: " << first << " Limit: " << (Float_t)fTimeFirstHiGain+1. << endl;
|
---|
703 | // return kFALSE;
|
---|
704 | }
|
---|
705 |
|
---|
706 | if (((Float_t)fTimeLastHiGain-1.) > last)
|
---|
707 | {
|
---|
708 | *fLog << warn
|
---|
709 | << "WARNING: Some absolute times bigger than limit in Pixel "
|
---|
710 | << fPixId << " time: " << last << " Limit: " << (Float_t)fTimeLastHiGain-1. << endl;
|
---|
711 | // return kFALSE;
|
---|
712 | }
|
---|
713 |
|
---|
714 | }
|
---|
715 |
|
---|
716 |
|
---|
717 |
|
---|
718 | return kTRUE;
|
---|
719 | }
|
---|
720 |
|
---|
721 |
|
---|
722 | //
|
---|
723 | // The check returns kTRUE if:
|
---|
724 | //
|
---|
725 | //
|
---|
726 | //
|
---|
727 | Bool_t MCalibrationPix::CheckOscillations()
|
---|
728 | {
|
---|
729 |
|
---|
730 |
|
---|
731 | return kTRUE;
|
---|
732 | }
|
---|
733 |
|
---|
734 |
|
---|
735 |
|
---|
736 | void MCalibrationPix::ApplyLoGainConversion()
|
---|
737 | {
|
---|
738 |
|
---|
739 | const Float_t chargeRelErrSquare = fErrCharge*fErrCharge
|
---|
740 | /( fCharge * fCharge);
|
---|
741 | const Float_t sigmaRelErrSquare = fErrSigmaCharge*fErrSigmaCharge
|
---|
742 | /( fSigmaCharge * fSigmaCharge);
|
---|
743 | const Float_t conversionRelErrSquare = fConversionHiLoError*fConversionHiLoError
|
---|
744 | /(fConversionHiLo * fConversionHiLo);
|
---|
745 |
|
---|
746 | fCharge *= fConversionHiLo;
|
---|
747 | fErrCharge = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fCharge;
|
---|
748 |
|
---|
749 | fSigmaCharge *= fConversionHiLo;
|
---|
750 | fErrSigmaCharge = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fSigmaCharge;
|
---|
751 |
|
---|
752 | }
|
---|
753 |
|
---|
754 |
|
---|
755 |
|
---|
756 | // --------------------------------------------------------------------------
|
---|
757 | //
|
---|
758 | // 1) Fit the arrival times
|
---|
759 | // 2) Retrieve the results
|
---|
760 | //
|
---|
761 | // This fit has to be done AFTER the Charges fit,
|
---|
762 | // otherwise only the Hi Gain will be fitted, even if there are no entries
|
---|
763 | //
|
---|
764 | //
|
---|
765 | Bool_t MCalibrationPix::FitTime()
|
---|
766 | {
|
---|
767 |
|
---|
768 | if(!fHist->FitTime())
|
---|
769 | {
|
---|
770 | *fLog << warn << "WARNING: Could not fit relative times of pixel " << fPixId << endl;
|
---|
771 | return kFALSE;
|
---|
772 | }
|
---|
773 |
|
---|
774 | fTime = fHist->GetRelTimeMean();
|
---|
775 | fErrTime = fHist->GetRelTimeMeanErr();
|
---|
776 | fSigmaTime = fHist->GetRelTimeSigma();
|
---|
777 | fTimeProb = fHist->GetRelTimeProb();
|
---|
778 |
|
---|
779 | if (CheckTimeFitValidity())
|
---|
780 | SETBIT(fFlags,kTimeFitValid);
|
---|
781 | else
|
---|
782 | CLRBIT(fFlags,kTimeFitValid);
|
---|
783 |
|
---|
784 | return kTRUE;
|
---|
785 | }
|
---|
786 |
|
---|