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 | // with the Munich definition of the F-Factor, thus:
|
---|
38 | // F = Sigma(Out)/Mean(Out) * Mean(In)/Sigma(In)
|
---|
39 | // Mean F-Factor = 1.15
|
---|
40 | // Error F-Factor = 0.02
|
---|
41 | //
|
---|
42 | /////////////////////////////////////////////////////////////////////////////
|
---|
43 | #include "MCalibrationPix.h"
|
---|
44 | #include "MCalibrationConfig.h"
|
---|
45 |
|
---|
46 | #include "MLog.h"
|
---|
47 | #include "MLogManip.h"
|
---|
48 |
|
---|
49 | ClassImp(MCalibrationPix);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | const Float_t MCalibrationPix::gkElectronicPedRms = 1.5;
|
---|
54 | const Float_t MCalibrationPix::gkErrElectronicPedRms = 0.3;
|
---|
55 | const Float_t MCalibrationPix::gkFFactor = 1.15;
|
---|
56 | const Float_t MCalibrationPix::gkFFactorError = 0.02;
|
---|
57 | const Float_t MCalibrationPix::gkChargeLimit = 3.;
|
---|
58 | const Float_t MCalibrationPix::gkChargeErrLimit = 0.;
|
---|
59 | const Float_t MCalibrationPix::gkChargeRelErrLimit = 1.;
|
---|
60 | const Float_t MCalibrationPix::gkTimeLimit = 1.5;
|
---|
61 | const Float_t MCalibrationPix::gkTimeErrLimit = 3.;
|
---|
62 | const Float_t MCalibrationPix::gkConvFFactorRelErrorLimit = 0.1;
|
---|
63 |
|
---|
64 | // --------------------------------------------------------------------------
|
---|
65 | //
|
---|
66 | // Default Constructor:
|
---|
67 | //
|
---|
68 | MCalibrationPix::MCalibrationPix(const char *name, const char *title)
|
---|
69 | : fPixId(-1),
|
---|
70 | fFlags(0)
|
---|
71 | {
|
---|
72 |
|
---|
73 | fName = name ? name : "MCalibrationPixel";
|
---|
74 | fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
|
---|
75 |
|
---|
76 | //
|
---|
77 | // At the moment, we don't have a database, yet,
|
---|
78 | // so we get it from the configuration file
|
---|
79 | //
|
---|
80 | fConversionHiLo = gkConversionHiLo;
|
---|
81 | fConversionHiLoError = gkConversionHiLoError;
|
---|
82 |
|
---|
83 | fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
|
---|
84 |
|
---|
85 | if (!fHist)
|
---|
86 | *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl;
|
---|
87 |
|
---|
88 | Clear();
|
---|
89 | }
|
---|
90 |
|
---|
91 | MCalibrationPix::~MCalibrationPix()
|
---|
92 | {
|
---|
93 | delete fHist;
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | // ------------------------------------------------------------------------
|
---|
98 | //
|
---|
99 | // Invalidate values
|
---|
100 | //
|
---|
101 | void MCalibrationPix::Clear(Option_t *o)
|
---|
102 | {
|
---|
103 |
|
---|
104 | fHist->Reset();
|
---|
105 |
|
---|
106 | CLRBIT(fFlags, kHiGainSaturation);
|
---|
107 | CLRBIT(fFlags, kExcluded);
|
---|
108 | CLRBIT(fFlags, kExcludeQualityCheck);
|
---|
109 | CLRBIT(fFlags, kChargeValid);
|
---|
110 | CLRBIT(fFlags, kFitted);
|
---|
111 | CLRBIT(fFlags, kOscillating);
|
---|
112 | CLRBIT(fFlags, kBlindPixelMethodValid);
|
---|
113 | CLRBIT(fFlags, kFFactorMethodValid);
|
---|
114 | CLRBIT(fFlags, kPINDiodeMethodValid);
|
---|
115 | CLRBIT(fFlags, kCombinedMethodValid);
|
---|
116 |
|
---|
117 | fCharge = -1.;
|
---|
118 | fErrCharge = -1.;
|
---|
119 | fSigmaCharge = -1.;
|
---|
120 | fErrSigmaCharge = -1.;
|
---|
121 | fRSigmaCharge = -1.;
|
---|
122 | fErrRSigmaCharge = -1.;
|
---|
123 |
|
---|
124 | fChargeProb = -1.;
|
---|
125 | fPed = -1.;
|
---|
126 | fPedRms = -1.;
|
---|
127 | fErrPedRms = 0.;
|
---|
128 |
|
---|
129 | fNumHiGainSamples = -1.;
|
---|
130 | fNumLoGainSamples = -1.;
|
---|
131 |
|
---|
132 | fTimeFirstHiGain = 0 ;
|
---|
133 | fTimeLastHiGain = 0 ;
|
---|
134 | fTimeFirstLoGain = 0 ;
|
---|
135 | fTimeLastLoGain = 0 ;
|
---|
136 |
|
---|
137 | fAbsTimeMean = -1.;
|
---|
138 | fAbsTimeRms = -1.;
|
---|
139 |
|
---|
140 | fPheFFactorMethod = -1.;
|
---|
141 | fPheFFactorMethodError = -1.;
|
---|
142 |
|
---|
143 | fMeanConversionFFactorMethod = -1.;
|
---|
144 | fMeanConversionBlindPixelMethod = -1.;
|
---|
145 | fMeanConversionPINDiodeMethod = -1.;
|
---|
146 | fMeanConversionCombinedMethod = -1.;
|
---|
147 |
|
---|
148 | fErrorConversionFFactorMethod = -1.;
|
---|
149 | fErrorConversionBlindPixelMethod = -1.;
|
---|
150 | fErrorConversionPINDiodeMethod = -1.;
|
---|
151 | fErrorConversionCombinedMethod = -1.;
|
---|
152 |
|
---|
153 | fSigmaConversionFFactorMethod = -1.;
|
---|
154 | fSigmaConversionBlindPixelMethod = -1.;
|
---|
155 | fSigmaConversionPINDiodeMethod = -1.;
|
---|
156 | fSigmaConversionCombinedMethod = -1.;
|
---|
157 |
|
---|
158 | fFactorCalculated = kFALSE;
|
---|
159 |
|
---|
160 | }
|
---|
161 |
|
---|
162 |
|
---|
163 | void MCalibrationPix::DefinePixId(Int_t i)
|
---|
164 | {
|
---|
165 |
|
---|
166 | fPixId = i;
|
---|
167 | fHist->ChangeHistId(i);
|
---|
168 |
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | // --------------------------------------------------------------------------
|
---|
173 | //
|
---|
174 | // Set the pedestals from outside
|
---|
175 | //
|
---|
176 | void MCalibrationPix::SetPedestal(const Float_t ped, const Float_t pedrms,
|
---|
177 | const Float_t higainsamp, const Float_t logainsamp )
|
---|
178 | {
|
---|
179 |
|
---|
180 | fPed = ped;
|
---|
181 | fPedRms = pedrms;
|
---|
182 |
|
---|
183 | fNumHiGainSamples = higainsamp;
|
---|
184 | fNumLoGainSamples = logainsamp;
|
---|
185 |
|
---|
186 | }
|
---|
187 |
|
---|
188 | // --------------------------------------------------------------------------
|
---|
189 | //
|
---|
190 | // Set the conversion factors from outside (only for MC)
|
---|
191 | //
|
---|
192 | void MCalibrationPix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
|
---|
193 | {
|
---|
194 | fMeanConversionFFactorMethod = c;
|
---|
195 | fErrorConversionFFactorMethod = err;
|
---|
196 | fSigmaConversionFFactorMethod = sig;
|
---|
197 | }
|
---|
198 |
|
---|
199 | // --------------------------------------------------------------------------
|
---|
200 | //
|
---|
201 | // Set the conversion factors from outside (only for MC)
|
---|
202 | //
|
---|
203 | void MCalibrationPix::SetConversionCombinedMethod(Float_t c, Float_t err, Float_t sig)
|
---|
204 | {
|
---|
205 | fMeanConversionCombinedMethod = c;
|
---|
206 | fErrorConversionCombinedMethod = err;
|
---|
207 | fSigmaConversionCombinedMethod = sig;
|
---|
208 | }
|
---|
209 |
|
---|
210 |
|
---|
211 | // --------------------------------------------------------------------------
|
---|
212 | //
|
---|
213 | // Set the conversion factors from outside (only for MC)
|
---|
214 | //
|
---|
215 | void MCalibrationPix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
|
---|
216 | {
|
---|
217 | fMeanConversionBlindPixelMethod = c;
|
---|
218 | fErrorConversionBlindPixelMethod = err;
|
---|
219 | fSigmaConversionBlindPixelMethod = sig;
|
---|
220 | }
|
---|
221 |
|
---|
222 | // --------------------------------------------------------------------------
|
---|
223 | //
|
---|
224 | // Set the conversion factors from outside (only for MC)
|
---|
225 | //
|
---|
226 | void MCalibrationPix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
|
---|
227 | {
|
---|
228 | fMeanConversionPINDiodeMethod = c ;
|
---|
229 | fErrorConversionPINDiodeMethod = err;
|
---|
230 | fSigmaConversionPINDiodeMethod = sig;
|
---|
231 | }
|
---|
232 |
|
---|
233 | // --------------------------------------------------------------------------
|
---|
234 | //
|
---|
235 | // Set the Hi Gain Saturation Bit from outside (only for MC)
|
---|
236 | //
|
---|
237 | void MCalibrationPix::SetHiGainSaturation(Bool_t b)
|
---|
238 | {
|
---|
239 |
|
---|
240 | if (b)
|
---|
241 | {
|
---|
242 | SETBIT(fFlags, kHiGainSaturation);
|
---|
243 | fHist->SetUseLoGain(1);
|
---|
244 | }
|
---|
245 | else
|
---|
246 | {
|
---|
247 | CLRBIT(fFlags, kHiGainSaturation);
|
---|
248 | fHist->SetUseLoGain(0);
|
---|
249 | }
|
---|
250 | }
|
---|
251 |
|
---|
252 | // --------------------------------------------------------------------------
|
---|
253 | //
|
---|
254 | // Set the Excluded Bit from outside
|
---|
255 | //
|
---|
256 | void MCalibrationPix::SetExcluded(Bool_t b )
|
---|
257 | {
|
---|
258 | b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
|
---|
259 | }
|
---|
260 |
|
---|
261 |
|
---|
262 | // --------------------------------------------------------------------------
|
---|
263 | //
|
---|
264 | // Set the Excluded Bit from outside
|
---|
265 | //
|
---|
266 | void MCalibrationPix::SetExcludeQualityCheck(Bool_t b )
|
---|
267 | {
|
---|
268 | b ? SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck);
|
---|
269 | }
|
---|
270 |
|
---|
271 | // --------------------------------------------------------------------------
|
---|
272 | //
|
---|
273 | // Set the Excluded Bit from outside
|
---|
274 | //
|
---|
275 | void MCalibrationPix::SetChargeValid(Bool_t b )
|
---|
276 | {
|
---|
277 | b ? SETBIT(fFlags, kChargeValid) : CLRBIT(fFlags, kChargeValid);
|
---|
278 | }
|
---|
279 |
|
---|
280 | // --------------------------------------------------------------------------
|
---|
281 | //
|
---|
282 | // Set the Excluded Bit from outside
|
---|
283 | //
|
---|
284 | void MCalibrationPix::SetFitted(Bool_t b )
|
---|
285 | {
|
---|
286 | b ? SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted);
|
---|
287 | }
|
---|
288 |
|
---|
289 | // --------------------------------------------------------------------------
|
---|
290 | //
|
---|
291 | // Set the Excluded Bit from outside
|
---|
292 | //
|
---|
293 | void MCalibrationPix::SetOscillating(Bool_t b )
|
---|
294 | {
|
---|
295 | b ? SETBIT(fFlags, kOscillating) : CLRBIT(fFlags, kOscillating);
|
---|
296 | }
|
---|
297 |
|
---|
298 | // --------------------------------------------------------------------------
|
---|
299 | //
|
---|
300 | // Set the Excluded Bit from outside
|
---|
301 | //
|
---|
302 | void MCalibrationPix::SetBlindPixelMethodValid(Bool_t b )
|
---|
303 | {
|
---|
304 | b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
|
---|
305 | }
|
---|
306 |
|
---|
307 | // --------------------------------------------------------------------------
|
---|
308 | //
|
---|
309 | // Set the Excluded Bit from outside
|
---|
310 | //
|
---|
311 | void MCalibrationPix::SetFFactorMethodValid(Bool_t b )
|
---|
312 | {
|
---|
313 | b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
|
---|
314 | }
|
---|
315 |
|
---|
316 | // --------------------------------------------------------------------------
|
---|
317 | //
|
---|
318 | // Set the Excluded Bit from outside
|
---|
319 | //
|
---|
320 | void MCalibrationPix::SetPINDiodeMethodValid(Bool_t b )
|
---|
321 | {
|
---|
322 | b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
|
---|
323 | }
|
---|
324 |
|
---|
325 | void MCalibrationPix::SetAbsTimeBordersHiGain(Byte_t f, Byte_t l)
|
---|
326 | {
|
---|
327 |
|
---|
328 | fTimeFirstHiGain = f;
|
---|
329 | fTimeLastHiGain = l;
|
---|
330 |
|
---|
331 | }
|
---|
332 |
|
---|
333 | void MCalibrationPix::SetAbsTimeBordersLoGain(Byte_t f, Byte_t l)
|
---|
334 | {
|
---|
335 |
|
---|
336 | fTimeFirstLoGain = f;
|
---|
337 | fTimeLastLoGain = l;
|
---|
338 |
|
---|
339 | }
|
---|
340 |
|
---|
341 | Float_t MCalibrationPix::GetPheFFactorMethod()
|
---|
342 | {
|
---|
343 |
|
---|
344 | if (!fFactorCalculated)
|
---|
345 | CalcFFactorMethod();
|
---|
346 |
|
---|
347 | return fPheFFactorMethod;
|
---|
348 |
|
---|
349 | }
|
---|
350 |
|
---|
351 | Float_t MCalibrationPix::GetPheFFactorMethodError()
|
---|
352 | {
|
---|
353 |
|
---|
354 | if (!fFactorCalculated)
|
---|
355 | CalcFFactorMethod();
|
---|
356 |
|
---|
357 | return fPheFFactorMethodError;
|
---|
358 |
|
---|
359 | }
|
---|
360 |
|
---|
361 |
|
---|
362 | Float_t MCalibrationPix::GetTotalFFactorFFactorMethod()
|
---|
363 | {
|
---|
364 | if (!fFactorCalculated)
|
---|
365 | CalcFFactorMethod();
|
---|
366 |
|
---|
367 | if (fPheFFactorMethod > 0)
|
---|
368 | return (fRSigmaCharge/fCharge)*TMath::Sqrt(fPheFFactorMethod);
|
---|
369 | else
|
---|
370 | return -1.;
|
---|
371 | }
|
---|
372 |
|
---|
373 | Float_t MCalibrationPix::GetTotalFFactorErrorFFactorMethod()
|
---|
374 | {
|
---|
375 |
|
---|
376 | if (!fFactorCalculated)
|
---|
377 | CalcFFactorMethod();
|
---|
378 |
|
---|
379 | const Float_t rsigmaChargeRelErrSquare = fErrRSigmaCharge * fErrRSigmaCharge
|
---|
380 | / (fRSigmaCharge * fRSigmaCharge) ;
|
---|
381 | const Float_t rChargeRelErrSquare = fErrCharge * fErrCharge
|
---|
382 | / (fCharge * fCharge) ;
|
---|
383 | const Float_t rPheRelErrSquare = fPheFFactorMethodError * fPheFFactorMethodError
|
---|
384 | / (fPheFFactorMethod * fPheFFactorMethod) ;
|
---|
385 |
|
---|
386 | return TMath::Sqrt(rsigmaChargeRelErrSquare+rChargeRelErrSquare+rPheRelErrSquare);
|
---|
387 | }
|
---|
388 |
|
---|
389 |
|
---|
390 | Float_t MCalibrationPix::GetTotalFFactorBlindPixelMethod()
|
---|
391 | {
|
---|
392 | return 1.;
|
---|
393 | }
|
---|
394 |
|
---|
395 | Float_t MCalibrationPix::GetTotalFFactorErrorBlindPixelMethod()
|
---|
396 | {
|
---|
397 |
|
---|
398 | return 1.;
|
---|
399 | }
|
---|
400 |
|
---|
401 | Float_t MCalibrationPix::GetTotalFFactorPINDiodeMethod()
|
---|
402 | {
|
---|
403 | return 1.;
|
---|
404 | }
|
---|
405 |
|
---|
406 | Float_t MCalibrationPix::GetTotalFFactorErrorPINDiodeMethod()
|
---|
407 | {
|
---|
408 |
|
---|
409 | return 1.;
|
---|
410 | }
|
---|
411 |
|
---|
412 | Float_t MCalibrationPix::GetTotalFFactorCombinedMethod()
|
---|
413 | {
|
---|
414 | return 1.;
|
---|
415 | }
|
---|
416 |
|
---|
417 | Float_t MCalibrationPix::GetTotalFFactorErrorCombinedMethod()
|
---|
418 | {
|
---|
419 |
|
---|
420 | return 1.;
|
---|
421 | }
|
---|
422 |
|
---|
423 | Float_t MCalibrationPix::GetMeanConversionFFactorMethod()
|
---|
424 | {
|
---|
425 |
|
---|
426 | if (!fFactorCalculated)
|
---|
427 | CalcFFactorMethod();
|
---|
428 |
|
---|
429 | return fMeanConversionFFactorMethod;
|
---|
430 |
|
---|
431 | }
|
---|
432 |
|
---|
433 | Float_t MCalibrationPix::GetErrorConversionFFactorMethod()
|
---|
434 | {
|
---|
435 |
|
---|
436 | if (!fFactorCalculated)
|
---|
437 | CalcFFactorMethod();
|
---|
438 |
|
---|
439 | return fErrorConversionFFactorMethod;
|
---|
440 |
|
---|
441 | }
|
---|
442 |
|
---|
443 | Float_t MCalibrationPix::GetSigmaConversionFFactorMethod()
|
---|
444 | {
|
---|
445 |
|
---|
446 | if (!fFactorCalculated)
|
---|
447 | CalcFFactorMethod();
|
---|
448 |
|
---|
449 | return fSigmaConversionFFactorMethod;
|
---|
450 |
|
---|
451 | }
|
---|
452 |
|
---|
453 |
|
---|
454 | Bool_t MCalibrationPix::IsExcluded() const
|
---|
455 | {
|
---|
456 | return TESTBIT(fFlags,kExcluded);
|
---|
457 | }
|
---|
458 |
|
---|
459 | Bool_t MCalibrationPix::IsExcludeQualityCheck() const
|
---|
460 | {
|
---|
461 | return TESTBIT(fFlags,kExcludeQualityCheck);
|
---|
462 | }
|
---|
463 |
|
---|
464 | Bool_t MCalibrationPix::IsHiGainSaturation() const
|
---|
465 | {
|
---|
466 | return TESTBIT(fFlags,kHiGainSaturation);
|
---|
467 | }
|
---|
468 |
|
---|
469 | Bool_t MCalibrationPix::IsChargeValid() const
|
---|
470 | {
|
---|
471 | return TESTBIT(fFlags, kChargeValid);
|
---|
472 | }
|
---|
473 |
|
---|
474 | Bool_t MCalibrationPix::IsFitted() const
|
---|
475 | {
|
---|
476 | return TESTBIT(fFlags, kFitted);
|
---|
477 | }
|
---|
478 |
|
---|
479 | Bool_t MCalibrationPix::IsOscillating()
|
---|
480 | {
|
---|
481 |
|
---|
482 | if (TESTBIT(fFlags, kOscillating))
|
---|
483 | return kTRUE;
|
---|
484 |
|
---|
485 | if (fHist->CheckOscillations())
|
---|
486 | {
|
---|
487 | SETBIT(fFlags,kOscillating);
|
---|
488 | return kTRUE;
|
---|
489 | }
|
---|
490 |
|
---|
491 | return kFALSE;
|
---|
492 | }
|
---|
493 |
|
---|
494 | Bool_t MCalibrationPix::IsBlindPixelMethodValid() const
|
---|
495 | {
|
---|
496 | return TESTBIT(fFlags, kBlindPixelMethodValid);
|
---|
497 | }
|
---|
498 |
|
---|
499 | Bool_t MCalibrationPix::IsFFactorMethodValid()
|
---|
500 | {
|
---|
501 |
|
---|
502 | if (!fFactorCalculated)
|
---|
503 | CalcFFactorMethod();
|
---|
504 |
|
---|
505 | return TESTBIT(fFlags, kFFactorMethodValid);
|
---|
506 | }
|
---|
507 |
|
---|
508 | Bool_t MCalibrationPix::IsPINDiodeMethodValid() const
|
---|
509 | {
|
---|
510 | return TESTBIT(fFlags, kPINDiodeMethodValid);
|
---|
511 | }
|
---|
512 |
|
---|
513 | Bool_t MCalibrationPix::IsCombinedMethodValid()
|
---|
514 | {
|
---|
515 | return TESTBIT(fFlags, kCombinedMethodValid);
|
---|
516 | }
|
---|
517 |
|
---|
518 |
|
---|
519 | // --------------------------------------------------------------------------
|
---|
520 | //
|
---|
521 | // 1) Return if the charge distribution is already succesfully fitted
|
---|
522 | // or if the histogram is empty
|
---|
523 | // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
|
---|
524 | // possible remaining cosmics to spoil the fit.
|
---|
525 | // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
|
---|
526 | // 4) Fit the histograms with a Gaussian
|
---|
527 | // 5) In case of failure set the bit kFitted to false
|
---|
528 | // 6) Retrieve the results and store them in this class
|
---|
529 | // 7) Calculate the number of photo-electrons after the F-Factor method
|
---|
530 | // 8) Calculate the errors of the F-Factor method
|
---|
531 | //
|
---|
532 | // The fits are declared valid (fFitValid = kTRUE), if:
|
---|
533 | //
|
---|
534 | // 1) Pixel has a fitted charge greater than 3*PedRMS
|
---|
535 | // 2) Pixel has a fit error greater than 0.
|
---|
536 | // 3) Pixel has a fit Probability greater than 0.0001
|
---|
537 | // 4) Pixel has a charge sigma bigger than its Pedestal RMS
|
---|
538 | // 5) If FitTimes is used,
|
---|
539 | // the mean arrival time is at least 1.0 slices from the used edge slices
|
---|
540 | // (this stage is only performed in the times fit)
|
---|
541 | //
|
---|
542 | // If the histogram is empty, all values are set to -1.
|
---|
543 | //
|
---|
544 | // The conversion factor after the F-Factor method is declared valid, if:
|
---|
545 | //
|
---|
546 | // 1) fFitValid is kTRUE
|
---|
547 | // 2) Conversion Factor is bigger than 0.
|
---|
548 | // 3) The error of the conversion factor is smaller than 10%
|
---|
549 | //
|
---|
550 | Bool_t MCalibrationPix::FitCharge()
|
---|
551 | {
|
---|
552 |
|
---|
553 | //
|
---|
554 | // 1) Return if the charge distribution is already succesfully fitted
|
---|
555 | // or if the histogram is empty
|
---|
556 | //
|
---|
557 | if (fHist->IsChargeFitOK() || fHist->IsEmpty())
|
---|
558 | return kTRUE;
|
---|
559 |
|
---|
560 | //
|
---|
561 | // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
|
---|
562 | // possible remaining cosmics to spoil the fit.
|
---|
563 | //
|
---|
564 | // if (fPed && fPedRms)
|
---|
565 | // fHist->SetLowerFitRange(1.5*fPedRms);
|
---|
566 | // else
|
---|
567 | // *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl;
|
---|
568 |
|
---|
569 | //
|
---|
570 | // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
|
---|
571 | //
|
---|
572 | if (fHist->UseLoGain())
|
---|
573 | SetHiGainSaturation();
|
---|
574 |
|
---|
575 | //
|
---|
576 | // 4) Fit the Lo Gain histograms with a Gaussian
|
---|
577 | //
|
---|
578 | if (fHist->FitCharge())
|
---|
579 | SETBIT(fFlags,kFitted);
|
---|
580 | else
|
---|
581 | {
|
---|
582 | *fLog << warn << "WARNING: Could not fit charges of pixel " << fPixId << endl;
|
---|
583 | //
|
---|
584 | // 5) In case of failure set the bit kFitted to false
|
---|
585 | //
|
---|
586 | CLRBIT(fFlags,kFitted);
|
---|
587 | }
|
---|
588 |
|
---|
589 | //
|
---|
590 | // 6) Retrieve the results and store them in this class
|
---|
591 | // If fFitted is false, we get the means and RMS of the histogram!!
|
---|
592 | //
|
---|
593 | fCharge = fHist->GetChargeMean();
|
---|
594 | fErrCharge = fHist->GetChargeMeanErr();
|
---|
595 | fSigmaCharge = fHist->GetChargeSigma();
|
---|
596 | fErrSigmaCharge = fHist->GetChargeSigmaErr();
|
---|
597 | fChargeProb = fHist->GetChargeProb();
|
---|
598 |
|
---|
599 |
|
---|
600 | fAbsTimeMean = fHist->GetAbsTimeMean();
|
---|
601 | fAbsTimeMeanErr = fHist->GetAbsTimeMeanErr();
|
---|
602 | fAbsTimeRms = fHist->GetAbsTimeRms();
|
---|
603 |
|
---|
604 | if (CheckTimeFitValidity())
|
---|
605 | SETBIT(fFlags,kTimeFitValid);
|
---|
606 | else
|
---|
607 | CLRBIT(fFlags,kTimeFitValid);
|
---|
608 |
|
---|
609 | //
|
---|
610 | // Calculate the conversion factors
|
---|
611 | //
|
---|
612 | if (IsHiGainSaturation())
|
---|
613 | ApplyLoGainConversion();
|
---|
614 |
|
---|
615 | if (CheckChargeValidity())
|
---|
616 | SETBIT(fFlags,kChargeValid);
|
---|
617 | else
|
---|
618 | {
|
---|
619 | CLRBIT(fFlags,kChargeValid);
|
---|
620 | return kFALSE;
|
---|
621 | }
|
---|
622 |
|
---|
623 | return kTRUE;
|
---|
624 |
|
---|
625 | }
|
---|
626 |
|
---|
627 | //
|
---|
628 | // Calculate the number of photo-electrons after the F-Factor method
|
---|
629 | // Calculate the errors of the F-Factor method
|
---|
630 | //
|
---|
631 | Bool_t MCalibrationPix::CalcFFactorMethod()
|
---|
632 | {
|
---|
633 |
|
---|
634 | if ( (fCharge == -1.)
|
---|
635 | || (fErrCharge < 0.)
|
---|
636 | || (fSigmaCharge < 0.)
|
---|
637 | || (fPedRms < 0.) )
|
---|
638 | {
|
---|
639 | *fLog << warn << GetDescriptor() << "Cannot calculate the FFactor Method! "
|
---|
640 | << "Some of the needed parameters are not available ";
|
---|
641 | CLRBIT(fFlags,kFFactorMethodValid);
|
---|
642 | return kFALSE;
|
---|
643 | }
|
---|
644 |
|
---|
645 | //
|
---|
646 | // Square all variables in order to avoid applications of square root
|
---|
647 | //
|
---|
648 | // First the relative error squares
|
---|
649 | //
|
---|
650 | const Float_t chargeSquare = fCharge* fCharge;
|
---|
651 | const Float_t chargeSquareRelErrSquare = 4.*fErrCharge*fErrCharge / chargeSquare;
|
---|
652 |
|
---|
653 | const Float_t ffactorsquare = gkFFactor * gkFFactor;
|
---|
654 | const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorError * gkFFactorError / ffactorsquare;
|
---|
655 | //
|
---|
656 | // Now the absolute error squares
|
---|
657 | //
|
---|
658 | const Float_t sigmaSquare = fSigmaCharge*fSigmaCharge;
|
---|
659 | const Float_t sigmaSquareErrSquare = 4.*fErrSigmaCharge*fErrSigmaCharge * sigmaSquare;
|
---|
660 |
|
---|
661 | Float_t pedRmsSquare = fPedRms* fPedRms;
|
---|
662 | Float_t pedRmsSquareErrSquare = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
|
---|
663 |
|
---|
664 | if (!IsHiGainSaturation())
|
---|
665 | { /* HiGain */
|
---|
666 |
|
---|
667 | pedRmsSquare *= fNumHiGainSamples;
|
---|
668 | pedRmsSquareErrSquare *= fNumHiGainSamples*fNumHiGainSamples;
|
---|
669 | }
|
---|
670 | else
|
---|
671 | { /* LoGain */
|
---|
672 |
|
---|
673 | //
|
---|
674 | // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
|
---|
675 | // from the HI GAIN (all calculation per slice up to now):
|
---|
676 | //
|
---|
677 | // We extract the pure NSB contribution:
|
---|
678 | //
|
---|
679 | const Float_t elecRmsSquare = gkElectronicPedRms *gkElectronicPedRms;
|
---|
680 | const Float_t elecRmsSquareErrSquare = 4.*gkErrElectronicPedRms*gkErrElectronicPedRms * elecRmsSquare;
|
---|
681 |
|
---|
682 | Float_t nsbSquare = pedRmsSquare - elecRmsSquare;
|
---|
683 | Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
|
---|
684 | / (nsbSquare * nsbSquare) ;
|
---|
685 |
|
---|
686 | if (nsbSquare < 0.)
|
---|
687 | nsbSquare = 0.;
|
---|
688 |
|
---|
689 | //
|
---|
690 | // Now, we divide the NSB by the conversion factor and
|
---|
691 | // add it quadratically to the electronic noise
|
---|
692 | //
|
---|
693 | const Float_t conversionSquare = fConversionHiLo *fConversionHiLo;
|
---|
694 | const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoError*fConversionHiLoError/conversionSquare;
|
---|
695 |
|
---|
696 | const Float_t convertedNsbSquare = nsbSquare / conversionSquare;
|
---|
697 | const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
|
---|
698 | * convertedNsbSquare * convertedNsbSquare;
|
---|
699 |
|
---|
700 | pedRmsSquare = convertedNsbSquare + elecRmsSquare;
|
---|
701 | pedRmsSquareErrSquare = convertedNsbSquareErrSquare + elecRmsSquareErrSquare;
|
---|
702 |
|
---|
703 | //
|
---|
704 | // Now, correct for the number of used FADC slices in the LoGain:
|
---|
705 | //
|
---|
706 | pedRmsSquare *= fNumLoGainSamples;
|
---|
707 | pedRmsSquareErrSquare *= fNumLoGainSamples*fNumLoGainSamples;
|
---|
708 | //
|
---|
709 | // Correct also for the conversion to Hi-Gain:
|
---|
710 | //
|
---|
711 | pedRmsSquare *= fConversionHiLo*fConversionHiLo;
|
---|
712 | pedRmsSquareErrSquare *= fConversionHiLo*fConversionHiLo*fConversionHiLo*fConversionHiLo;
|
---|
713 |
|
---|
714 | } /* if (HiGainSaturation) */
|
---|
715 |
|
---|
716 | //
|
---|
717 | // Calculate the reduced sigmas
|
---|
718 | //
|
---|
719 | const Float_t rsigmachargesquare = sigmaSquare - pedRmsSquare;
|
---|
720 | if (rsigmachargesquare <= 0.)
|
---|
721 | {
|
---|
722 | *fLog << warn
|
---|
723 | << "WARNING: Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel "
|
---|
724 | << fPixId << endl;
|
---|
725 | CLRBIT(fFlags,kFFactorMethodValid);
|
---|
726 | fFactorCalculated = kTRUE;
|
---|
727 | return kFALSE;
|
---|
728 | }
|
---|
729 |
|
---|
730 | const Float_t rSigmaSquareRelErrSquare = (sigmaSquareErrSquare + pedRmsSquareErrSquare)
|
---|
731 | / (rsigmachargesquare * rsigmachargesquare) ;
|
---|
732 |
|
---|
733 | fRSigmaCharge = TMath::Sqrt(rsigmachargesquare);
|
---|
734 | fErrRSigmaCharge = TMath::Sqrt(sigmaSquareErrSquare + pedRmsSquareErrSquare);
|
---|
735 |
|
---|
736 |
|
---|
737 | //
|
---|
738 | // Calculate the number of phe's from the F-Factor method
|
---|
739 | // (independent on Hi Gain or Lo Gain)
|
---|
740 | //
|
---|
741 | fPheFFactorMethod = ffactorsquare * chargeSquare / rsigmachargesquare;
|
---|
742 |
|
---|
743 | const Float_t pheFFactorRelErrSquare = ffactorsquareRelErrSquare
|
---|
744 | + chargeSquareRelErrSquare
|
---|
745 | + rSigmaSquareRelErrSquare ;
|
---|
746 |
|
---|
747 | fPheFFactorMethodError = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
|
---|
748 |
|
---|
749 | const Float_t chargeRelErrSquare = fErrCharge*fErrCharge / (fCharge * fCharge);
|
---|
750 |
|
---|
751 | fMeanConversionFFactorMethod = fPheFFactorMethod / fCharge ;
|
---|
752 | fErrorConversionFFactorMethod = ( pheFFactorRelErrSquare + chargeRelErrSquare )
|
---|
753 | * fMeanConversionFFactorMethod * fMeanConversionFFactorMethod;
|
---|
754 |
|
---|
755 | const Float_t convrelerror = fErrorConversionFFactorMethod/fMeanConversionFFactorMethod;
|
---|
756 |
|
---|
757 | if ( (fMeanConversionFFactorMethod > 0.) && (convrelerror < gkConvFFactorRelErrorLimit))
|
---|
758 | SETBIT(fFlags,kFFactorMethodValid);
|
---|
759 |
|
---|
760 | fFactorCalculated = kTRUE;
|
---|
761 |
|
---|
762 | fSigmaConversionFFactorMethod = GetTotalFFactorFFactorMethod()*TMath::Sqrt(fMeanConversionFFactorMethod);
|
---|
763 |
|
---|
764 | return kTRUE;
|
---|
765 | }
|
---|
766 |
|
---|
767 |
|
---|
768 | //
|
---|
769 | // The check returns kTRUE if:
|
---|
770 | //
|
---|
771 | // 0) Pixel has BIT fitted set:
|
---|
772 | // This means:
|
---|
773 | // a) No result is a nan
|
---|
774 | // b) The NDF is not smaller than fNDFLimit (5)
|
---|
775 | // c) The Probability is greater than gkProbLimit (default 0.001 == 99.9%)
|
---|
776 | // 1) Pixel has a fitted charge greater than 3*PedRMS
|
---|
777 | // 2) Pixel has a fit error greater than 0.
|
---|
778 | // 3) Pixel has a fitted charge greater its charge error
|
---|
779 | // 4) Pixel has a fit Probability greater than 0.0001
|
---|
780 | // 5) Pixel has a charge sigma bigger than its Pedestal RMS
|
---|
781 | //
|
---|
782 | Bool_t MCalibrationPix::CheckChargeValidity()
|
---|
783 | {
|
---|
784 |
|
---|
785 | if (!IsFitted())
|
---|
786 | return kFALSE;
|
---|
787 |
|
---|
788 | if (IsExcludeQualityCheck())
|
---|
789 | return kTRUE;
|
---|
790 |
|
---|
791 | Float_t pedestal;
|
---|
792 |
|
---|
793 | if (!IsHiGainSaturation()) /* higain */
|
---|
794 | pedestal = GetPedRms()*TMath::Sqrt(fNumHiGainSamples);
|
---|
795 | else /* logain */
|
---|
796 | pedestal = GetPedRms()*TMath::Sqrt(fNumLoGainSamples);
|
---|
797 |
|
---|
798 |
|
---|
799 | if (fCharge < gkChargeLimit*pedestal)
|
---|
800 | {
|
---|
801 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
802 | << gkChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
|
---|
803 | return kFALSE;
|
---|
804 | }
|
---|
805 |
|
---|
806 | if (fErrCharge < gkChargeErrLimit)
|
---|
807 | {
|
---|
808 | *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
|
---|
809 | << gkChargeErrLimit << " in Pixel " << fPixId << endl;
|
---|
810 | return kFALSE;
|
---|
811 | }
|
---|
812 |
|
---|
813 | if (fCharge < gkChargeRelErrLimit*fErrCharge)
|
---|
814 | {
|
---|
815 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
816 | << gkChargeRelErrLimit << "* its error in Pixel " << fPixId << endl;
|
---|
817 | return kFALSE;
|
---|
818 | }
|
---|
819 |
|
---|
820 | if (!fHist->IsChargeFitOK())
|
---|
821 | {
|
---|
822 | *fLog << warn << "WARNING: Probability of Fitted Charge too low in Pixel "
|
---|
823 | << fPixId << endl;
|
---|
824 | return kFALSE;
|
---|
825 | }
|
---|
826 |
|
---|
827 | if (fSigmaCharge < pedestal)
|
---|
828 | {
|
---|
829 | *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel "
|
---|
830 | << fPixId << endl;
|
---|
831 | return kFALSE;
|
---|
832 | }
|
---|
833 | return kTRUE;
|
---|
834 | }
|
---|
835 |
|
---|
836 | //
|
---|
837 | // The check return kTRUE if:
|
---|
838 | //
|
---|
839 | // 0) No value is nan
|
---|
840 | // 1) Pixel has a fitted rel. time smaller than 3*FADC slices
|
---|
841 | // 2) Pixel has a fit error greater than 0.
|
---|
842 | // 4) Pixel has a fit Probability greater than 0.001
|
---|
843 | // 5) The absolute arrival time is at least 1.0 slices from the used edge slices
|
---|
844 | //
|
---|
845 | Bool_t MCalibrationPix::CheckTimeFitValidity()
|
---|
846 | {
|
---|
847 |
|
---|
848 |
|
---|
849 | if (IsExcludeQualityCheck())
|
---|
850 | return kTRUE;
|
---|
851 |
|
---|
852 | if (IsHiGainSaturation())
|
---|
853 | {
|
---|
854 |
|
---|
855 | if (fAbsTimeMean < (Float_t)fTimeFirstLoGain+1)
|
---|
856 | {
|
---|
857 | *fLog << warn
|
---|
858 | << "WARNING: Some absolute times smaller than limit in Pixel "
|
---|
859 | << fPixId << " time: " << fAbsTimeMean
|
---|
860 | << " Limit: " << (Float_t)fTimeFirstLoGain+1. << endl;
|
---|
861 | return kFALSE;
|
---|
862 | }
|
---|
863 |
|
---|
864 | if (fAbsTimeMean > (Float_t)fTimeLastLoGain-1)
|
---|
865 | {
|
---|
866 | *fLog << warn
|
---|
867 | << "WARNING: Some absolute times bigger than limit in Pixel "
|
---|
868 | << fPixId << " time: " << fAbsTimeMean
|
---|
869 | << " Limit: " << (Float_t)fTimeLastLoGain-1. << endl;
|
---|
870 | return kFALSE;
|
---|
871 | }
|
---|
872 |
|
---|
873 | }
|
---|
874 | else
|
---|
875 | {
|
---|
876 |
|
---|
877 | if (fAbsTimeMean < (Float_t)fTimeFirstHiGain+1.)
|
---|
878 | {
|
---|
879 | *fLog << warn
|
---|
880 | << "WARNING: Some absolute times smaller than limit in Pixel "
|
---|
881 | << fPixId << " time: " << fAbsTimeMean
|
---|
882 | << " Limit: " << (Float_t)fTimeFirstHiGain+1. << endl;
|
---|
883 | // return kFALSE;
|
---|
884 | }
|
---|
885 |
|
---|
886 | if (fAbsTimeMean > (Float_t)fTimeLastHiGain-1.)
|
---|
887 | {
|
---|
888 | *fLog << warn
|
---|
889 | << "WARNING: Some absolute times bigger than limit in Pixel "
|
---|
890 | << fPixId << " time: " << fAbsTimeMean
|
---|
891 | << " Limit: " << (Float_t)fTimeLastHiGain-1. << endl;
|
---|
892 | // return kFALSE;
|
---|
893 | }
|
---|
894 |
|
---|
895 | }
|
---|
896 |
|
---|
897 |
|
---|
898 |
|
---|
899 | return kTRUE;
|
---|
900 | }
|
---|
901 |
|
---|
902 |
|
---|
903 | void MCalibrationPix::CheckOscillations()
|
---|
904 | {
|
---|
905 | fHist->CheckOscillations();
|
---|
906 | }
|
---|
907 |
|
---|
908 | void MCalibrationPix::ApplyLoGainConversion()
|
---|
909 | {
|
---|
910 |
|
---|
911 | const Float_t chargeRelErrSquare = fErrCharge*fErrCharge
|
---|
912 | /( fCharge * fCharge);
|
---|
913 | const Float_t sigmaRelErrSquare = fErrSigmaCharge*fErrSigmaCharge
|
---|
914 | /( fSigmaCharge * fSigmaCharge);
|
---|
915 | const Float_t conversionRelErrSquare = fConversionHiLoError*fConversionHiLoError
|
---|
916 | /(fConversionHiLo * fConversionHiLo);
|
---|
917 |
|
---|
918 | fCharge *= fConversionHiLo;
|
---|
919 | fErrCharge = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fCharge;
|
---|
920 |
|
---|
921 | fSigmaCharge *= fConversionHiLo;
|
---|
922 | fErrSigmaCharge = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fSigmaCharge;
|
---|
923 |
|
---|
924 | }
|
---|