| 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 02/2004 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | \* ======================================================================== */
|
|---|
| 23 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 24 | //
|
|---|
| 25 | // MCalibrationChargePix
|
|---|
| 26 | //
|
|---|
| 27 | // Storage container of the calibrated Charge of one pixel.
|
|---|
| 28 | //
|
|---|
| 29 | // The following values are initialized to meaningful values:
|
|---|
| 30 | //
|
|---|
| 31 | // - The Electronic Rms to 1.5 per FADC slice
|
|---|
| 32 | // - The uncertainty about the Electronic RMS to 0.3 per slice
|
|---|
| 33 | // - The F-Factor is assumed to have been measured in Munich to 1.13 - 1.17.
|
|---|
| 34 | // with the Munich definition of the F-Factor, thus:
|
|---|
| 35 | // F = Sigma(Out)/Mean(Out) * Mean(In)/Sigma(In)
|
|---|
| 36 | // Mean F-Factor (gkFFactor) = 1.15
|
|---|
| 37 | // Error F-Factor (gkFFactorErr) = 0.02
|
|---|
| 38 | //
|
|---|
| 39 | // The following variables are calculated inside this class:
|
|---|
| 40 | // - fLoGainPedRmsSquare and fLoGainPedRmsSquareVar (see CalcLoGainPedestal())
|
|---|
| 41 | // - fRSigmaSquare and fRSigmaSquareVar (see CalcReducedSigma() )
|
|---|
| 42 | // - fPheFFactorMethod and fPheFFactorMethodVar (see CalcFFactorMethod() )
|
|---|
| 43 | //
|
|---|
| 44 | // The following variables are set by MHCalibrationChargeCam:
|
|---|
| 45 | // - fAbsTimeMean and fAbsTimeRms
|
|---|
| 46 | // - all variables in MCalibrationPix
|
|---|
| 47 | //
|
|---|
| 48 | // The following variables are set by MCalibrationChargeCalc:
|
|---|
| 49 | // - fPed, fPedVar and fPedRms
|
|---|
| 50 | // - fMeanConversionFFactorMethod, fMeanConversionBlindPixelMethod,
|
|---|
| 51 | // fMeanConversionPINDiodeMethod and fMeanConversionCombinedMethod
|
|---|
| 52 | // - fConversionFFactorMethodVar, fConversionBlindPixelMethodVar
|
|---|
| 53 | // fConversionPINDiodeMethodVar and fConversionCombinedMethodVar
|
|---|
| 54 | // - fSigmaConversionFFactorMethod, fSigmaConversionBlindPixelMethod
|
|---|
| 55 | // fSigmaConversionPINDiodeMethod and fSigmaConversionCombinedMethod
|
|---|
| 56 | // - fTotalFFactorFFactorMethod, fTotalFFactorBlindPixelMethod
|
|---|
| 57 | // fTotalFFactorPINDiodeMethod and fTotalFFactorCombinedMethod
|
|---|
| 58 | // - fTotalFFactorFFactorMethodVar, fTotalFFactorBlindPixelMethodVar,
|
|---|
| 59 | // fTotalFFactorPINDiodeMethodVar and fTotalFFactorCombinedMethodVar
|
|---|
| 60 | //
|
|---|
| 61 | // The following variables are not yet implemented:
|
|---|
| 62 | // - fConversionHiLo and fConversionHiLoVar (now set fixed to 10. +- 2.5)
|
|---|
| 63 | //
|
|---|
| 64 | // Error of all variables are calculated by error-propagation. Note that internally,
|
|---|
| 65 | // all error variables contain Variances in order to save the CPU-intensive square rooting
|
|---|
| 66 | //
|
|---|
| 67 | // Low-Gain variables are stored internally unconverted, i.e. directly from the summed
|
|---|
| 68 | // FADC slices extraction results, but can be retrieved converted to High-Gain amplifications
|
|---|
| 69 | // by calls to: GetConvertedLoGainMean() or GetConvertedLoGainSigma()
|
|---|
| 70 | //
|
|---|
| 71 | // See also: MCalibrationChargeCam, MCalibrationChargeCalc,
|
|---|
| 72 | // MHCalibrationChargeCam, MHCalibrationChargePix
|
|---|
| 73 | //
|
|---|
| 74 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 75 | #include "MCalibrationChargePix.h"
|
|---|
| 76 |
|
|---|
| 77 | #include "MLog.h"
|
|---|
| 78 | #include "MLogManip.h"
|
|---|
| 79 |
|
|---|
| 80 | #include "MBadPixelsPix.h"
|
|---|
| 81 |
|
|---|
| 82 | ClassImp(MCalibrationChargePix);
|
|---|
| 83 |
|
|---|
| 84 | using namespace std;
|
|---|
| 85 |
|
|---|
| 86 | const Float_t MCalibrationChargePix::gkElectronicPedRms = 1.5;
|
|---|
| 87 | const Float_t MCalibrationChargePix::gkElectronicPedRmsErr = 0.3;
|
|---|
| 88 | const Float_t MCalibrationChargePix::gkFFactor = 1.15;
|
|---|
| 89 | const Float_t MCalibrationChargePix::gkFFactorErr = 0.02;
|
|---|
| 90 |
|
|---|
| 91 | const Float_t MCalibrationChargePix::fgConversionHiLo = 10.;
|
|---|
| 92 | const Float_t MCalibrationChargePix::fgConversionHiLoErr = 2.5;
|
|---|
| 93 | const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit = 5.;
|
|---|
| 94 | // --------------------------------------------------------------------------
|
|---|
| 95 | //
|
|---|
| 96 | // Default Constructor:
|
|---|
| 97 | //
|
|---|
| 98 | // Sets:
|
|---|
| 99 | // - fCalibFlags to 0
|
|---|
| 100 | // - fConversionHiLo to fgConversionHiLo
|
|---|
| 101 | // - fConversionHiLoVar to square of fgConversionHiLoErr
|
|---|
| 102 | // - fPheFFactorMethodLimit to fgPheFFactorMethodLimit
|
|---|
| 103 | //
|
|---|
| 104 | // Calls:
|
|---|
| 105 | // - Clear()
|
|---|
| 106 | //
|
|---|
| 107 | MCalibrationChargePix::MCalibrationChargePix(const char *name, const char *title)
|
|---|
| 108 | : fCalibFlags(0)
|
|---|
| 109 | {
|
|---|
| 110 |
|
|---|
| 111 | fName = name ? name : "MCalibrationChargePix";
|
|---|
| 112 | fTitle = title ? title : "Container of the fit results of MHCalibrationChargePixs ";
|
|---|
| 113 |
|
|---|
| 114 | //
|
|---|
| 115 | // At the moment, we don't have a database, yet,
|
|---|
| 116 | // so we get it from the configuration file
|
|---|
| 117 | //
|
|---|
| 118 | SetConversionHiLo();
|
|---|
| 119 | SetConversionHiLoErr();
|
|---|
| 120 |
|
|---|
| 121 | SetPheFFactorMethodLimit();
|
|---|
| 122 |
|
|---|
| 123 | Clear();
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | // ------------------------------------------------------------------------
|
|---|
| 127 | //
|
|---|
| 128 | // Sets:
|
|---|
| 129 | // - all flags to kFALSE
|
|---|
| 130 | // - all variables to -1.
|
|---|
| 131 | //
|
|---|
| 132 | // Calls:
|
|---|
| 133 | // - MCalibrationPix::Clear()
|
|---|
| 134 | //
|
|---|
| 135 | void MCalibrationChargePix::Clear(Option_t *o)
|
|---|
| 136 | {
|
|---|
| 137 |
|
|---|
| 138 | SetBlindPixelMethodValid ( kFALSE );
|
|---|
| 139 | SetFFactorMethodValid ( kFALSE );
|
|---|
| 140 | SetPINDiodeMethodValid ( kFALSE );
|
|---|
| 141 | SetCombinedMethodValid ( kFALSE );
|
|---|
| 142 |
|
|---|
| 143 | fRSigmaSquare = -1.;
|
|---|
| 144 | fRSigmaSquareVar = -1.;
|
|---|
| 145 |
|
|---|
| 146 | fPed = -1.;
|
|---|
| 147 | fPedRms = -1.;
|
|---|
| 148 | fPedVar = -1.;
|
|---|
| 149 |
|
|---|
| 150 | fLoGainPedRmsSquare = -1.;
|
|---|
| 151 | fLoGainPedRmsSquareVar = -1.;
|
|---|
| 152 |
|
|---|
| 153 | fAbsTimeMean = -1.;
|
|---|
| 154 | fAbsTimeRms = -1.;
|
|---|
| 155 |
|
|---|
| 156 | fPheFFactorMethod = -1.;
|
|---|
| 157 | fPheFFactorMethodVar = -1.;
|
|---|
| 158 |
|
|---|
| 159 | fMeanConversionFFactorMethod = -1.;
|
|---|
| 160 | fMeanConversionBlindPixelMethod = -1.;
|
|---|
| 161 | fMeanConversionPINDiodeMethod = -1.;
|
|---|
| 162 | fMeanConversionCombinedMethod = -1.;
|
|---|
| 163 |
|
|---|
| 164 | fConversionFFactorMethodVar = -1.;
|
|---|
| 165 | fConversionBlindPixelMethodVar = -1.;
|
|---|
| 166 | fConversionPINDiodeMethodVar = -1.;
|
|---|
| 167 | fConversionCombinedMethodVar = -1.;
|
|---|
| 168 |
|
|---|
| 169 | fSigmaConversionFFactorMethod = -1.;
|
|---|
| 170 | fSigmaConversionBlindPixelMethod = -1.;
|
|---|
| 171 | fSigmaConversionPINDiodeMethod = -1.;
|
|---|
| 172 | fSigmaConversionCombinedMethod = -1.;
|
|---|
| 173 |
|
|---|
| 174 | fTotalFFactorFFactorMethod = -1.;
|
|---|
| 175 | fTotalFFactorBlindPixelMethod = -1.;
|
|---|
| 176 | fTotalFFactorPINDiodeMethod = -1.;
|
|---|
| 177 | fTotalFFactorCombinedMethod = -1.;
|
|---|
| 178 |
|
|---|
| 179 | MCalibrationPix::Clear();
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 | // --------------------------------------------------------------------------
|
|---|
| 184 | //
|
|---|
| 185 | // Set conversion factors Blind Pixel Method from outside (only for MC)
|
|---|
| 186 | //
|
|---|
| 187 | void MCalibrationChargePix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
|
|---|
| 188 | {
|
|---|
| 189 | fMeanConversionBlindPixelMethod = c;
|
|---|
| 190 | fConversionBlindPixelMethodVar = err*err;
|
|---|
| 191 | fSigmaConversionBlindPixelMethod = sig;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | // --------------------------------------------------------------------------
|
|---|
| 196 | //
|
|---|
| 197 | // Set conversion factors Combined Method from outside (only for MC)
|
|---|
| 198 | //
|
|---|
| 199 | void MCalibrationChargePix::SetConversionCombinedMethod(Float_t c, Float_t err, Float_t sig)
|
|---|
| 200 | {
|
|---|
| 201 | fMeanConversionCombinedMethod = c;
|
|---|
| 202 | fConversionCombinedMethodVar = err*err;
|
|---|
| 203 | fSigmaConversionCombinedMethod = sig;
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 |
|
|---|
| 207 | // --------------------------------------------------------------------------
|
|---|
| 208 | //
|
|---|
| 209 | // Set conversion factors F-Factor Method from outside (only for MC)
|
|---|
| 210 | //
|
|---|
| 211 | void MCalibrationChargePix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
|
|---|
| 212 | {
|
|---|
| 213 | fMeanConversionFFactorMethod = c;
|
|---|
| 214 | fConversionFFactorMethodVar = err*err;
|
|---|
| 215 | fSigmaConversionFFactorMethod = sig;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | // --------------------------------------------------------------------------
|
|---|
| 219 | //
|
|---|
| 220 | // Set conversion factors PIN Diode Method from outside (only for MC)
|
|---|
| 221 | //
|
|---|
| 222 | void MCalibrationChargePix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
|
|---|
| 223 | {
|
|---|
| 224 | fMeanConversionPINDiodeMethod = c ;
|
|---|
| 225 | fConversionPINDiodeMethodVar = err*err;
|
|---|
| 226 | fSigmaConversionPINDiodeMethod = sig;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | // --------------------------------------------------------------------------
|
|---|
| 230 | //
|
|---|
| 231 | // Set Blind Pixel Method Validity Bit from outside
|
|---|
| 232 | //
|
|---|
| 233 | void MCalibrationChargePix::SetBlindPixelMethodValid(const Bool_t b )
|
|---|
| 234 | {
|
|---|
| 235 | b ? SETBIT(fCalibFlags, kBlindPixelMethodValid) : CLRBIT(fCalibFlags, kBlindPixelMethodValid);
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | // --------------------------------------------------------------------------
|
|---|
| 239 | //
|
|---|
| 240 | // Set Combined Method Validity Bit from outside
|
|---|
| 241 | //
|
|---|
| 242 | void MCalibrationChargePix::SetCombinedMethodValid(const Bool_t b )
|
|---|
| 243 | {
|
|---|
| 244 | b ? SETBIT(fCalibFlags, kCombinedMethodValid) : CLRBIT(fCalibFlags, kCombinedMethodValid);
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | // --------------------------------------------------------------------------
|
|---|
| 248 | //
|
|---|
| 249 | // Set F-Factor Method Validity Bit from outside
|
|---|
| 250 | //
|
|---|
| 251 | void MCalibrationChargePix::SetFFactorMethodValid(const Bool_t b )
|
|---|
| 252 | {
|
|---|
| 253 | b ? SETBIT(fCalibFlags, kFFactorMethodValid) : CLRBIT(fCalibFlags, kFFactorMethodValid);
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | // --------------------------------------------------------------------------
|
|---|
| 257 | //
|
|---|
| 258 | // Set PIN Diode Method Validity Bit from outside
|
|---|
| 259 | //
|
|---|
| 260 | void MCalibrationChargePix::SetPINDiodeMethodValid(const Bool_t b )
|
|---|
| 261 | {
|
|---|
| 262 | b ? SETBIT(fCalibFlags, kPINDiodeMethodValid) : CLRBIT(fCalibFlags, kPINDiodeMethodValid);
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | // --------------------------------------------------------------------------
|
|---|
| 266 | //
|
|---|
| 267 | // Set pedestals from outside (done by MCalibrationChargeCalc)
|
|---|
| 268 | //
|
|---|
| 269 | void MCalibrationChargePix::SetPedestal(const Float_t ped, const Float_t pedrms, const Float_t pederr)
|
|---|
| 270 | {
|
|---|
| 271 |
|
|---|
| 272 | fPed = ped;
|
|---|
| 273 | fPedRms = pedrms;
|
|---|
| 274 | fPedVar = pederr*pederr;
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | // -------------------------------------------------------------------------------
|
|---|
| 278 | //
|
|---|
| 279 | // Get the conversion Error Hi-Gain to Low-Gain:
|
|---|
| 280 | // - If fConversionHiLoVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 281 | //
|
|---|
| 282 | Float_t MCalibrationChargePix::GetConversionHiLoErr() const
|
|---|
| 283 | {
|
|---|
| 284 | if (fConversionHiLoVar < 0.)
|
|---|
| 285 | return -1.;
|
|---|
| 286 |
|
|---|
| 287 | return TMath::Sqrt(fConversionHiLoVar);
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | // --------------------------------------------------------------------------
|
|---|
| 291 | //
|
|---|
| 292 | // Get the relative variance of the conversion factor between higain and logain:
|
|---|
| 293 | // - If fConversionHiLo is 0, return -1.
|
|---|
| 294 | // - If fConversionHiLoVar is smaller than 0, return -1.
|
|---|
| 295 | // - Else returns: fConversionHiLoVar / fConversionHiLo^2
|
|---|
| 296 | //
|
|---|
| 297 | const Float_t MCalibrationChargePix::GetConversionHiLoRelVar() const
|
|---|
| 298 | {
|
|---|
| 299 |
|
|---|
| 300 | if (fConversionHiLoVar < 0.)
|
|---|
| 301 | return -1.;
|
|---|
| 302 |
|
|---|
| 303 | if (fConversionHiLo == 0.)
|
|---|
| 304 | return -1.;
|
|---|
| 305 |
|
|---|
| 306 | return fConversionHiLoVar / (fConversionHiLo * fConversionHiLo);
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 | // --------------------------------------------------------------------------
|
|---|
| 311 | //
|
|---|
| 312 | // Get the relative variance of the conversion factor between higain and logain:
|
|---|
| 313 | // - If gkFFactor is 0, return -1.
|
|---|
| 314 | // - If gkFFactorErr is smaller than 0, return -1.
|
|---|
| 315 | // - Else returns: gkFFactorErr^2 / gkFFactor*^2
|
|---|
| 316 | //
|
|---|
| 317 | const Float_t MCalibrationChargePix::GetFFactorRelVar() const
|
|---|
| 318 | {
|
|---|
| 319 |
|
|---|
| 320 | if (gkFFactorErr < 0.)
|
|---|
| 321 | return -1.;
|
|---|
| 322 |
|
|---|
| 323 | if (gkFFactor == 0.)
|
|---|
| 324 | return -1.;
|
|---|
| 325 |
|
|---|
| 326 | return gkFFactorErr * gkFFactorErr / (gkFFactor * gkFFactor);
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 | //
|
|---|
| 331 | // Get the Error of the Mean pedestals:
|
|---|
| 332 | // Returns square root of fPedVar
|
|---|
| 333 | //
|
|---|
| 334 | Float_t MCalibrationChargePix::GetPedErr() const
|
|---|
| 335 | {
|
|---|
| 336 | return TMath::Sqrt(fPedVar);
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | // --------------------------------------------------------------------------
|
|---|
| 340 | //
|
|---|
| 341 | // Get the pedestals RMS:
|
|---|
| 342 | // - Test bit kHiGainSaturation:
|
|---|
| 343 | // If yes, return square root of fLoGainPedRmsSquare (if greater than 0, otherwise -1.),
|
|---|
| 344 | // If no, return fPedRms
|
|---|
| 345 | //
|
|---|
| 346 | Float_t MCalibrationChargePix::GetPedRms() const
|
|---|
| 347 | {
|
|---|
| 348 |
|
|---|
| 349 | if (IsHiGainSaturation())
|
|---|
| 350 | if (fLoGainPedRmsSquare < 0.)
|
|---|
| 351 | return -1.;
|
|---|
| 352 | else
|
|---|
| 353 | return TMath::Sqrt(fLoGainPedRmsSquare);
|
|---|
| 354 |
|
|---|
| 355 | return fPedRms;
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | // --------------------------------------------------------------------------
|
|---|
| 359 | //
|
|---|
| 360 | // Get the Error of the pedestals RMS:
|
|---|
| 361 | // - Test bit kHiGainSaturation:
|
|---|
| 362 | // If yes, return square root of (0.25*fLoGainPedRmsSquareVar/ fLoGainPedRmsSquare) (if greater than 0, otherwise -1.)
|
|---|
| 363 | // If no , return square root of (fPedVar) (if greater than 0, otherwise -1.), divided by 2.
|
|---|
| 364 | //
|
|---|
| 365 | Float_t MCalibrationChargePix::GetPedRmsErr() const
|
|---|
| 366 | {
|
|---|
| 367 | if (IsHiGainSaturation())
|
|---|
| 368 | if (fLoGainPedRmsSquareVar < 0.)
|
|---|
| 369 | return -1.;
|
|---|
| 370 | else
|
|---|
| 371 | return TMath::Sqrt(0.25*fLoGainPedRmsSquareVar/fLoGainPedRmsSquare);
|
|---|
| 372 | else
|
|---|
| 373 | if (fPedVar < 0.)
|
|---|
| 374 | return -1.;
|
|---|
| 375 | else
|
|---|
| 376 | return TMath::Sqrt(fPedVar)/2.;
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 | // --------------------------------------------------------------------------
|
|---|
| 381 | //
|
|---|
| 382 | // Get the Low Gain Mean converted to High Gain amplification:
|
|---|
| 383 | // Returns fLoGainMean multiplied with fConversionHiLo
|
|---|
| 384 | //
|
|---|
| 385 | Float_t MCalibrationChargePix::GetConvertedLoGainMean() const
|
|---|
| 386 | {
|
|---|
| 387 | return fLoGainMean * fConversionHiLo;
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | // --------------------------------------------------------------------------
|
|---|
| 391 | //
|
|---|
| 392 | // Get the Error of the converted Low Gain Mean:
|
|---|
| 393 | //
|
|---|
| 394 | // Returns -1 if the variable fLoGainMean or fLoGainMeanVar are smaller than 0.
|
|---|
| 395 | //
|
|---|
| 396 | // Returns the square root of the quadratic sum of the relative variances of
|
|---|
| 397 | // the fLoGainMean and fConversionHiLo, mulitplied with GetConvertedLoGainMean()
|
|---|
| 398 | //
|
|---|
| 399 | Float_t MCalibrationChargePix::GetConvertedLoGainMeanErr() const
|
|---|
| 400 | {
|
|---|
| 401 |
|
|---|
| 402 | const Float_t logainrelvar = GetLoGainMeanRelVar();
|
|---|
| 403 |
|
|---|
| 404 | if (logainrelvar < 0.)
|
|---|
| 405 | return -1.;
|
|---|
| 406 |
|
|---|
| 407 | return TMath::Sqrt(logainrelvar + GetConversionHiLoRelVar()) * GetConvertedLoGainMean();
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | // --------------------------------------------------------------------------
|
|---|
| 411 | //
|
|---|
| 412 | // Get the Low Gain Sigma converted to High Gain amplification:
|
|---|
| 413 | // Returns fLoGainSigma multiplied with fConversionHiLo
|
|---|
| 414 | //
|
|---|
| 415 | Float_t MCalibrationChargePix::GetConvertedLoGainSigma() const
|
|---|
| 416 | {
|
|---|
| 417 | return fLoGainSigma * fConversionHiLo;
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | // --------------------------------------------------------------------------
|
|---|
| 421 | //
|
|---|
| 422 | // Get the Error of the converted Low Gain Sigma:
|
|---|
| 423 | //
|
|---|
| 424 | // Returns -1 if the variable fLoGainSigma or fLoGainSigmaVar are smaller than 0.
|
|---|
| 425 | //
|
|---|
| 426 | // Returns the square root of the quadratic sum of the relative variances of
|
|---|
| 427 | // the fLoGainSigma and fConversionHiLo, mulitplied with GetConvertedLoGainSigma()
|
|---|
| 428 | //
|
|---|
| 429 | Float_t MCalibrationChargePix::GetConvertedLoGainSigmaErr() const
|
|---|
| 430 | {
|
|---|
| 431 |
|
|---|
| 432 | if (fLoGainSigmaVar < 0.)
|
|---|
| 433 | return -1.;
|
|---|
| 434 |
|
|---|
| 435 | if (fLoGainSigma < 0.)
|
|---|
| 436 | return -1.;
|
|---|
| 437 |
|
|---|
| 438 | const Float_t sigmaRelVar = fLoGainSigmaVar
|
|---|
| 439 | /( fLoGainSigma * fLoGainSigma );
|
|---|
| 440 |
|
|---|
| 441 | return TMath::Sqrt(sigmaRelVar+GetConversionHiLoRelVar()) * GetConvertedLoGainSigma();
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 | // --------------------------------------------------------------------------
|
|---|
| 445 | //
|
|---|
| 446 | // Get the reduced Sigma:
|
|---|
| 447 | // - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 448 | // - Test bit kHiGainSaturation:
|
|---|
| 449 | // If yes, return square root of fRSigmaSquare, multiplied with fConversionHiLo,
|
|---|
| 450 | // If no , return square root of fRSigmaSquare
|
|---|
| 451 | //
|
|---|
| 452 | Float_t MCalibrationChargePix::GetRSigma() const
|
|---|
| 453 | {
|
|---|
| 454 | if (fRSigmaSquare < 0)
|
|---|
| 455 | return -1;
|
|---|
| 456 |
|
|---|
| 457 | const Float_t rsigma = TMath::Sqrt(fRSigmaSquare);
|
|---|
| 458 |
|
|---|
| 459 | return IsHiGainSaturation() ? rsigma*fConversionHiLo : rsigma ;
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | // --------------------------------------------------------------------------
|
|---|
| 463 | //
|
|---|
| 464 | // Get the error of the reduced Sigma:
|
|---|
| 465 | // - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 466 | // - Calculate the absolute variance of the reduced sigma with the formula:
|
|---|
| 467 | // reduced sigma variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare
|
|---|
| 468 | // - Test bit kHiGainSaturation:
|
|---|
| 469 | // If yes, returns the square root of the quadratic sum of the relative variances of the
|
|---|
| 470 | // reduced sigma and fConversionHiLo, mulitplied with GetRSigma()
|
|---|
| 471 | // Else returns the square root of rel. (0.25*fRSigmaSquareVar / fRSigmaSquare)
|
|---|
| 472 | //
|
|---|
| 473 | Float_t MCalibrationChargePix::GetRSigmaErr() const
|
|---|
| 474 | {
|
|---|
| 475 |
|
|---|
| 476 | if (fRSigmaSquareVar < 0)
|
|---|
| 477 | return -1;
|
|---|
| 478 |
|
|---|
| 479 | //
|
|---|
| 480 | // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
|
|---|
| 481 | // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
|
|---|
| 482 | //
|
|---|
| 483 | const Float_t rsigmaVar = 0.25 * fRSigmaSquareVar / fRSigmaSquare;
|
|---|
| 484 |
|
|---|
| 485 | if (IsHiGainSaturation())
|
|---|
| 486 | return TMath::Sqrt(rsigmaVar/fRSigmaSquare + GetConversionHiLoRelVar()) * GetRSigma();
|
|---|
| 487 | else
|
|---|
| 488 | return TMath::Sqrt(rsigmaVar);
|
|---|
| 489 |
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | // --------------------------------------------------------------------------
|
|---|
| 493 | //
|
|---|
| 494 | // Get the relative variance of the reduced Sigma:
|
|---|
| 495 | // - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 496 | // - Calculate the relative variance of the reduced sigma squares with the formula:
|
|---|
| 497 | // reduced sigma rel. variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare
|
|---|
| 498 | // - Test bit kHiGainSaturation:
|
|---|
| 499 | // If yes, returns the sum of the relative variances of the reduced sigma and fConversionHiLo
|
|---|
| 500 | // Else returns the relative variance of the reduced sigma
|
|---|
| 501 | //
|
|---|
| 502 | Float_t MCalibrationChargePix::GetRSigmaRelVar() const
|
|---|
| 503 | {
|
|---|
| 504 |
|
|---|
| 505 | if (fRSigmaSquareVar < 0)
|
|---|
| 506 | return -1;
|
|---|
| 507 |
|
|---|
| 508 | //
|
|---|
| 509 | // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
|
|---|
| 510 | // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
|
|---|
| 511 | //
|
|---|
| 512 | const Float_t rsigmaRelVar = 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare );
|
|---|
| 513 |
|
|---|
| 514 | if (IsHiGainSaturation())
|
|---|
| 515 | return rsigmaRelVar + GetConversionHiLoRelVar();
|
|---|
| 516 | else
|
|---|
| 517 | return rsigmaRelVar;
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | // --------------------------------------------------------------------------
|
|---|
| 521 | //
|
|---|
| 522 | // Get the error on the number of photo-electrons (F-Factor Method):
|
|---|
| 523 | // - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 524 | // - Else returns the square root of fPheFFactorMethodVar
|
|---|
| 525 | //
|
|---|
| 526 | Float_t MCalibrationChargePix::GetPheFFactorMethodErr() const
|
|---|
| 527 | {
|
|---|
| 528 | if (fPheFFactorMethodVar < 0.)
|
|---|
| 529 | return -1.;
|
|---|
| 530 | return TMath::Sqrt(fPheFFactorMethodVar);
|
|---|
| 531 | }
|
|---|
| 532 |
|
|---|
| 533 | // --------------------------------------------------------------------------
|
|---|
| 534 | //
|
|---|
| 535 | // Get the error on the mean conversion factor (Combined Method):
|
|---|
| 536 | // - If fConversionCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 537 | // - Else returns the square root of fConversionCombinedMethodVar
|
|---|
| 538 | //
|
|---|
| 539 | Float_t MCalibrationChargePix::GetConversionCombinedMethodErr() const
|
|---|
| 540 | {
|
|---|
| 541 | if (fConversionCombinedMethodVar < 0.)
|
|---|
| 542 | return -1.;
|
|---|
| 543 | return TMath::Sqrt(fConversionCombinedMethodVar);
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | // --------------------------------------------------------------------------
|
|---|
| 547 | //
|
|---|
| 548 | // Get the error on the mean conversion factor (PINDiode Method):
|
|---|
| 549 | // - If fConversionPINDiodeMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 550 | // - Else returns the square root of fConversionPINDiodeMethodVar
|
|---|
| 551 | //
|
|---|
| 552 | Float_t MCalibrationChargePix::GetConversionPINDiodeMethodErr() const
|
|---|
| 553 | {
|
|---|
| 554 | if (fConversionPINDiodeMethodVar < 0.)
|
|---|
| 555 | return -1.;
|
|---|
| 556 | return TMath::Sqrt(fConversionPINDiodeMethodVar);
|
|---|
| 557 | }
|
|---|
| 558 |
|
|---|
| 559 | // --------------------------------------------------------------------------
|
|---|
| 560 | //
|
|---|
| 561 | // Get the error on the mean conversion factor (BlindPixel Method):
|
|---|
| 562 | // - If fConversionBlindPixelMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 563 | // - Else returns the square root of fConversionBlindPixelMethodVar
|
|---|
| 564 | //
|
|---|
| 565 | Float_t MCalibrationChargePix::GetConversionBlindPixelMethodErr() const
|
|---|
| 566 | {
|
|---|
| 567 | if (fConversionBlindPixelMethodVar < 0.)
|
|---|
| 568 | return -1.;
|
|---|
| 569 | return TMath::Sqrt(fConversionBlindPixelMethodVar);
|
|---|
| 570 | }
|
|---|
| 571 |
|
|---|
| 572 | // --------------------------------------------------------------------------
|
|---|
| 573 | //
|
|---|
| 574 | // Get the error on the mean conversion factor (FFactor Method):
|
|---|
| 575 | // - If fConversionFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 576 | // - Else returns the square root of fConversionFFactorMethodVar
|
|---|
| 577 | //
|
|---|
| 578 | Float_t MCalibrationChargePix::GetConversionFFactorMethodErr() const
|
|---|
| 579 | {
|
|---|
| 580 | if (fConversionFFactorMethodVar < 0.)
|
|---|
| 581 | return -1.;
|
|---|
| 582 | return TMath::Sqrt(fConversionFFactorMethodVar);
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 | // --------------------------------------------------------------------------
|
|---|
| 586 | //
|
|---|
| 587 | // Get the error on the total F-Factor (Combined Method):
|
|---|
| 588 | // - If fTotalFFactorCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 589 | // - Else returns the square root of fTotalFFactorCombinedMethodVar
|
|---|
| 590 | //
|
|---|
| 591 | Float_t MCalibrationChargePix::GetTotalFFactorCombinedMethodErr() const
|
|---|
| 592 | {
|
|---|
| 593 | if (fTotalFFactorCombinedMethodVar < 0.)
|
|---|
| 594 | return -1.;
|
|---|
| 595 | return TMath::Sqrt(fTotalFFactorCombinedMethodVar);
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | // --------------------------------------------------------------------------
|
|---|
| 599 | //
|
|---|
| 600 | // Get the error on the total F-Factor (PIN Diode Method):
|
|---|
| 601 | // - If fTotalPINDiodeCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 602 | // - Else returns the square root of fTotalPINDiodeCombinedMethodVar
|
|---|
| 603 | //
|
|---|
| 604 | Float_t MCalibrationChargePix::GetTotalFFactorPINDiodeMethodErr() const
|
|---|
| 605 | {
|
|---|
| 606 | if (fTotalFFactorPINDiodeMethodVar < 0.)
|
|---|
| 607 | return -1.;
|
|---|
| 608 | return TMath::Sqrt(fTotalFFactorPINDiodeMethodVar);
|
|---|
| 609 | }
|
|---|
| 610 |
|
|---|
| 611 | // --------------------------------------------------------------------------
|
|---|
| 612 | //
|
|---|
| 613 | // Get the error on the total F-Factor (Blind Pixel Method):
|
|---|
| 614 | // - If fTotalBlindPixelCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 615 | // - Else returns the square root of fTotalBlindPixelCombinedMethodVar
|
|---|
| 616 | //
|
|---|
| 617 | Float_t MCalibrationChargePix::GetTotalFFactorBlindPixelMethodErr() const
|
|---|
| 618 | {
|
|---|
| 619 | if (fTotalFFactorBlindPixelMethodVar < 0.)
|
|---|
| 620 | return -1.;
|
|---|
| 621 | return TMath::Sqrt(fTotalFFactorBlindPixelMethodVar);
|
|---|
| 622 | }
|
|---|
| 623 |
|
|---|
| 624 | // --------------------------------------------------------------------------
|
|---|
| 625 | //
|
|---|
| 626 | // Get the error on the total F-Factor (F-Factor Method):
|
|---|
| 627 | // - If fTotalFFactorCombinedMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
|---|
| 628 | // - Else returns the square root of fTotalFFactorCombinedMethodVar
|
|---|
| 629 | //
|
|---|
| 630 | Float_t MCalibrationChargePix::GetTotalFFactorFFactorMethodErr() const
|
|---|
| 631 | {
|
|---|
| 632 | if (fTotalFFactorFFactorMethodVar < 0.)
|
|---|
| 633 | return -1.;
|
|---|
| 634 | return TMath::Sqrt(fTotalFFactorFFactorMethodVar);
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | // --------------------------------------------------------------------------
|
|---|
| 638 | //
|
|---|
| 639 | // Test bit kBlindPixelMethodValid
|
|---|
| 640 | //
|
|---|
| 641 | Bool_t MCalibrationChargePix::IsBlindPixelMethodValid() const
|
|---|
| 642 | {
|
|---|
| 643 | return TESTBIT(fCalibFlags, kBlindPixelMethodValid);
|
|---|
| 644 | }
|
|---|
| 645 |
|
|---|
| 646 | // --------------------------------------------------------------------------
|
|---|
| 647 | //
|
|---|
| 648 | // Test bit kFFactorMethodValid
|
|---|
| 649 | //
|
|---|
| 650 | Bool_t MCalibrationChargePix::IsFFactorMethodValid() const
|
|---|
| 651 | {
|
|---|
| 652 | return TESTBIT(fCalibFlags, kFFactorMethodValid);
|
|---|
| 653 | }
|
|---|
| 654 |
|
|---|
| 655 | // --------------------------------------------------------------------------
|
|---|
| 656 | //
|
|---|
| 657 | // Test bit kPINDiodeMethodValid
|
|---|
| 658 | //
|
|---|
| 659 | Bool_t MCalibrationChargePix::IsPINDiodeMethodValid() const
|
|---|
| 660 | {
|
|---|
| 661 | return TESTBIT(fCalibFlags, kPINDiodeMethodValid);
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| 664 | // --------------------------------------------------------------------------
|
|---|
| 665 | //
|
|---|
| 666 | // Test bit kCombinedMethodValid
|
|---|
| 667 | //
|
|---|
| 668 | Bool_t MCalibrationChargePix::IsCombinedMethodValid() const
|
|---|
| 669 | {
|
|---|
| 670 | return TESTBIT(fCalibFlags, kCombinedMethodValid);
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | // ----------------------------------------------------------------------------
|
|---|
| 674 | //
|
|---|
| 675 | // - If fSigma is smaller than 0 (i.e. has not yet been set), return kFALSE
|
|---|
| 676 | // - If fPedRms is smaller than 0 (i.e. has not yet been set), return kFALSE
|
|---|
| 677 | //
|
|---|
| 678 | // Calculate the reduced sigma of the low-Gain FADC slices:
|
|---|
| 679 | // - Test bit IsHiGainSaturation() for the Sigma:
|
|---|
| 680 | // If yes, take fLoGainSigma and fLoGainSigmaVar
|
|---|
| 681 | // If no , take fHiGainSigma and fHiGainSigmaVar
|
|---|
| 682 | //
|
|---|
| 683 | // - Test bit IsHiGainSaturation() for the pedRMS:
|
|---|
| 684 | // If yes, take fLoGainPedRmsSquare and fLoGainPedRmsSquareVar
|
|---|
| 685 | // If no , take fPedRms and fPedVar
|
|---|
| 686 | //
|
|---|
| 687 | // - Calculate the reduced sigma with the formula:
|
|---|
| 688 | // fRSigmaSquare = Sigma*Sigma - pedRMS*pedRMS
|
|---|
| 689 | //
|
|---|
| 690 | // - If fRSigmaSquare is smaller than 0, give a warning and return kFALSE
|
|---|
| 691 | //
|
|---|
| 692 | // - Calculate the variance of the reduced sigma with the formula:
|
|---|
| 693 | // fRSigmaSquareVar = 4.* (sigmaVar*Sigma*Sigma + pedRmsVar*pedRMS*pedRMS)
|
|---|
| 694 | //
|
|---|
| 695 | // A back-transformation to the corr. amplification factor of the High-Gain is done
|
|---|
| 696 | // in GetRSigma() and GetRSigmaErr()
|
|---|
| 697 | //
|
|---|
| 698 | Bool_t MCalibrationChargePix::CalcReducedSigma()
|
|---|
| 699 | {
|
|---|
| 700 |
|
|---|
| 701 | if (GetSigma() < 0.)
|
|---|
| 702 | return kFALSE;
|
|---|
| 703 |
|
|---|
| 704 | if (GetPedRms() < 0.)
|
|---|
| 705 | return kFALSE;
|
|---|
| 706 |
|
|---|
| 707 | const Float_t sigma = IsHiGainSaturation() ? fLoGainSigma : fHiGainSigma ;
|
|---|
| 708 | const Float_t sigmavar = IsHiGainSaturation() ? fLoGainSigmaVar : fHiGainSigmaVar;
|
|---|
| 709 | const Float_t pedRmsSquare = IsHiGainSaturation() ? fLoGainPedRmsSquare : fPedRms*fPedRms;
|
|---|
| 710 | const Float_t pedRmsSquareVar = IsHiGainSaturation() ? fLoGainPedRmsSquareVar : 0.25*fPedVar*pedRmsSquare;
|
|---|
| 711 |
|
|---|
| 712 | const Float_t sigmaSquare = sigma * sigma;
|
|---|
| 713 | const Float_t sigmaSquareVar = sigmavar * sigmaSquare;
|
|---|
| 714 |
|
|---|
| 715 | //
|
|---|
| 716 | // Calculate the reduced sigmas
|
|---|
| 717 | //
|
|---|
| 718 | fRSigmaSquare = sigmaSquare - pedRmsSquare;
|
|---|
| 719 | if (fRSigmaSquare <= 0.)
|
|---|
| 720 | {
|
|---|
| 721 | *fLog << warn
|
|---|
| 722 | << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel "
|
|---|
| 723 | << fPixId << endl;
|
|---|
| 724 | return kFALSE;
|
|---|
| 725 | }
|
|---|
| 726 |
|
|---|
| 727 | fRSigmaSquareVar = 4. * (sigmaSquareVar + pedRmsSquareVar);
|
|---|
| 728 |
|
|---|
| 729 | return kTRUE;
|
|---|
| 730 | }
|
|---|
| 731 |
|
|---|
| 732 | // ------------------------------------------------------------------
|
|---|
| 733 | //
|
|---|
| 734 | // If fRSigmaSquare is smaller than 0 (i.e. has not yet been set),
|
|---|
| 735 | // set kFFactorMethodValid to kFALSE and return kFALSE
|
|---|
| 736 | //
|
|---|
| 737 | // Calculate the number of photo-electrons with the F-Factor method:
|
|---|
| 738 | // - Test bit IsHiGainSaturation() for the Mean Sum of FADC slices:
|
|---|
| 739 | // If yes, take fLoGainMean and fLoGainMeanVar
|
|---|
| 740 | // If no , take fHiGainMean and fHiGainMeanVar
|
|---|
| 741 | //
|
|---|
| 742 | // - Test bit IsHiGainSaturation() for the pedRMS:
|
|---|
| 743 | // If yes, take fLoGainPedRmsSquare and fLoGainPedRmsSquareVar
|
|---|
| 744 | // If no , take fPedRms and fPedVar
|
|---|
| 745 | //
|
|---|
| 746 | // - Calculate the number of photo-electrons with the formula:
|
|---|
| 747 | // fPheFFactorMethod = gkFFactor*gkFFactor * Mean * Mean / fRSigmaSquare
|
|---|
| 748 | //
|
|---|
| 749 | // - Calculate the Variance on the photo-electrons with the formula:
|
|---|
| 750 | // fPheFFactorMethodVar = ( 4. * gkFFactorErr * gkFFactorErr / ( gkFFactor * gkFFactor )
|
|---|
| 751 | // + 4. * Mean Var. / ( Mean * Mean )
|
|---|
| 752 | // + fRSigmaSquareVar / fRSigmaSquare
|
|---|
| 753 | // ) * fPheFFactorMethod * fPheFFactorMethod
|
|---|
| 754 | //
|
|---|
| 755 | // - If fPheFFactorMethod is less than fPheFFactorMethodLimit,
|
|---|
| 756 | // set kFFactorMethodValid to kFALSE and return kFALSE
|
|---|
| 757 | // else: Set kFFactorMethodValid to kTRUE and return kTRUE
|
|---|
| 758 | //
|
|---|
| 759 | Bool_t MCalibrationChargePix::CalcFFactorMethod()
|
|---|
| 760 | {
|
|---|
| 761 |
|
|---|
| 762 | if (fRSigmaSquare < 0.)
|
|---|
| 763 | {
|
|---|
| 764 | SetFFactorMethodValid(kFALSE);
|
|---|
| 765 | return kFALSE;
|
|---|
| 766 | }
|
|---|
| 767 |
|
|---|
| 768 | //
|
|---|
| 769 | // Square all variables in order to avoid applications of square root
|
|---|
| 770 | //
|
|---|
| 771 | const Float_t meanSquare = GetMean() * GetMean();
|
|---|
| 772 | const Float_t meanSquareRelVar = 4.* GetMeanRelVar();
|
|---|
| 773 |
|
|---|
| 774 | const Float_t ffactorsquare = gkFFactor * gkFFactor;
|
|---|
| 775 | const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
|
|---|
| 776 |
|
|---|
| 777 | const Float_t rsigmaSquareRelVar = fRSigmaSquareVar / fRSigmaSquare;
|
|---|
| 778 |
|
|---|
| 779 | //
|
|---|
| 780 | // Calculate the number of phe's from the F-Factor method
|
|---|
| 781 | // (independent on Hi Gain or Lo Gain)
|
|---|
| 782 | //
|
|---|
| 783 | fPheFFactorMethod = ffactorsquare * meanSquare / fRSigmaSquare;
|
|---|
| 784 |
|
|---|
| 785 | if (fPheFFactorMethod < fPheFFactorMethodLimit)
|
|---|
| 786 | {
|
|---|
| 787 | SetFFactorMethodValid(kFALSE);
|
|---|
| 788 | return kFALSE;
|
|---|
| 789 | }
|
|---|
| 790 |
|
|---|
| 791 | //
|
|---|
| 792 | // Calculate the Error of Nphe
|
|---|
| 793 | //
|
|---|
| 794 | fPheFFactorMethodVar = (ffactorsquareRelVar + meanSquareRelVar + rsigmaSquareRelVar)
|
|---|
| 795 | * fPheFFactorMethod * fPheFFactorMethod;
|
|---|
| 796 |
|
|---|
| 797 | SetFFactorMethodValid(kTRUE);
|
|---|
| 798 | return kTRUE;
|
|---|
| 799 | }
|
|---|
| 800 |
|
|---|
| 801 |
|
|---|
| 802 | // ----------------------------------------------------------------------------
|
|---|
| 803 | //
|
|---|
| 804 | // - If fPed is smaller than 0 (i.e. has not yet been set), return.
|
|---|
| 805 | // - If fPedVar is smaller than 0 (i.e. has not yet been set), return.
|
|---|
| 806 | //
|
|---|
| 807 | // Calculate the electronic pedestal RMS with the formula:
|
|---|
| 808 | // - elec. pedestal = gkElectronicPedRms * sqrt(logainsamples)
|
|---|
| 809 | //
|
|---|
| 810 | // Calculate the night sky background ped. RMS contribution ("NSB") in the high-gain
|
|---|
| 811 | // from the high gain Pedestal RMS with the formula:
|
|---|
| 812 | // - HiGain NSB square = fPedRms * fPedRms - elec.ped.* elec.ped.
|
|---|
| 813 | // - Var(HiGain NSB square) = fPedVar * fPedRms * fPedRms + 4.*elecPedRmsVar * elec.ped.* elec.ped.
|
|---|
| 814 | //
|
|---|
| 815 | // If HiGain NSB square is smaller than 0., set it to zero. (but not the error!)
|
|---|
| 816 | //
|
|---|
| 817 | // Convert the NSB ped. RMS contribution to the low-gain with the formula:
|
|---|
| 818 | // - LoGain NSB square = - HiGain NSB square / (fConversionHiLo*fConversionHiLo)
|
|---|
| 819 | // - Var(LoGain NSB square) = ( Var(HiGain NSB square) / (HiGain NSB square * HiGain NSB square)
|
|---|
| 820 | // + GetConversionHiLoRelVar()
|
|---|
| 821 | // ) * LoGain NSB square * LoGain NSB square
|
|---|
| 822 | //
|
|---|
| 823 | // - Low Gain Ped RMS Square = LoGain NSB square + elec.ped. square
|
|---|
| 824 | // Var (Low Gain Ped RMS Square) = Var(LoGain NSB square) + Var(elec.ped. square)
|
|---|
| 825 | //
|
|---|
| 826 | void MCalibrationChargePix::CalcLoGainPedestal(Float_t logainsamples)
|
|---|
| 827 | {
|
|---|
| 828 |
|
|---|
| 829 | if (fPedRms < 0.)
|
|---|
| 830 | return;
|
|---|
| 831 |
|
|---|
| 832 | if (fPedVar < 0.)
|
|---|
| 833 | return;
|
|---|
| 834 |
|
|---|
| 835 | const Float_t elecPedRms = gkElectronicPedRms * TMath::Sqrt(logainsamples);
|
|---|
| 836 | const Float_t elecPedRmsVar = gkElectronicPedRmsErr * gkElectronicPedRmsErr * logainsamples;
|
|---|
| 837 |
|
|---|
| 838 | Float_t pedRmsSquare = fPedRms * fPedRms;
|
|---|
| 839 | Float_t pedRmsSquareVar = fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2.
|
|---|
| 840 |
|
|---|
| 841 | //
|
|---|
| 842 | // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
|
|---|
| 843 | // from the HI GAIN (all calculation per slice up to now):
|
|---|
| 844 | //
|
|---|
| 845 | // We extract the pure NSB contribution:
|
|---|
| 846 | //
|
|---|
| 847 | const Float_t elecRmsSquare = elecPedRms * elecPedRms;
|
|---|
| 848 | const Float_t elecRmsSquareVar = 4.*elecPedRmsVar * elecRmsSquare;
|
|---|
| 849 |
|
|---|
| 850 | Float_t higainNsbSquare = pedRmsSquare - elecRmsSquare;
|
|---|
| 851 | Float_t higainNsbSquareRelVar = (pedRmsSquareVar + elecRmsSquareVar)
|
|---|
| 852 | / (higainNsbSquare * higainNsbSquare) ;
|
|---|
| 853 |
|
|---|
| 854 | if (higainNsbSquare < 0.)
|
|---|
| 855 | higainNsbSquare = 0.;
|
|---|
| 856 |
|
|---|
| 857 | //
|
|---|
| 858 | // Now, we divide the NSB by the conversion factor and
|
|---|
| 859 | // add it quadratically to the electronic noise
|
|---|
| 860 | //
|
|---|
| 861 | const Float_t conversionSquare = fConversionHiLo * fConversionHiLo;
|
|---|
| 862 | const Float_t conversionSquareRelVar = 4.* GetConversionHiLoRelVar();
|
|---|
| 863 |
|
|---|
| 864 | const Float_t logainNsbSquare = higainNsbSquare / conversionSquare;
|
|---|
| 865 | const Float_t logainNsbSquareVar = ( higainNsbSquareRelVar + conversionSquareRelVar )
|
|---|
| 866 | * logainNsbSquare * logainNsbSquare;
|
|---|
| 867 |
|
|---|
| 868 | fLoGainPedRmsSquare = logainNsbSquare + elecRmsSquare;
|
|---|
| 869 | fLoGainPedRmsSquareVar = logainNsbSquareVar + elecRmsSquareVar;
|
|---|
| 870 | }
|
|---|
| 871 |
|
|---|