| 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 to hold informations about the calibration values     // | 
|---|
| 28 | // values of one Pixel (PMT).                                              // | 
|---|
| 29 | //                                                                         // | 
|---|
| 30 | // The following values are initialized to meaningful values: | 
|---|
| 31 | // | 
|---|
| 32 | // - The Electronic Rms to 1.5 per FADC slice | 
|---|
| 33 | // - The uncertainty about the Electronic RMS to 0.3 per slice | 
|---|
| 34 | // - The F-Factor is assumed to have been measured in Munich to 1.13 - 1.17. | 
|---|
| 35 | //   with the Munich definition of the F-Factor, thus: | 
|---|
| 36 | //   F = Sigma(Out)/Mean(Out) * Mean(In)/Sigma(In) | 
|---|
| 37 | //   Mean F-Factor  = 1.15 | 
|---|
| 38 | //   Error F-Factor = 0.02 | 
|---|
| 39 | // | 
|---|
| 40 | // - Average QE: (email David Paneque, 14.2.04): | 
|---|
| 41 | // | 
|---|
| 42 | //  The conversion factor that comes purely from QE folded to a Cherenkov | 
|---|
| 43 | //  spectrum has to be multiplied by: | 
|---|
| 44 | //  * Plexiglass window -->> 0.96 X 0.96 | 
|---|
| 45 | //  * PMT photoelectron collection efficiency -->> 0.9 | 
|---|
| 46 | //  * Light guides efficiency -->> 0.94 | 
|---|
| 47 | // | 
|---|
| 48 | //  Concerning the light guides effiency estimation... Daniel Ferenc | 
|---|
| 49 | //  is preparing some work (simulations) to estimate it. Yet so far, he has | 
|---|
| 50 | //  been busy with other stuff, and this work is still UNfinished. | 
|---|
| 51 | // | 
|---|
| 52 | //  The estimation I did comes from: | 
|---|
| 53 | //  1) Reflectivity of light guide walls is 85 % (aluminum) | 
|---|
| 54 | //  2) At ZERO degree light incidence, 37% of the light hits such walls | 
|---|
| 55 | //    (0.15X37%= 5.6% of light lost) | 
|---|
| 56 | //  3) When increasing the light incidence angle, more and more light hits | 
|---|
| 57 | //     the walls. | 
|---|
| 58 | // | 
|---|
| 59 | //  However, the loses due to larger amount of photons hitting the walls is more | 
|---|
| 60 | //  or less counteracted by the fact that more and more photon trajectories cross | 
|---|
| 61 | //  the PMT photocathode twice, increasing the effective sensitivity of the PMT. | 
|---|
| 62 | // | 
|---|
| 63 | //  Jurgen Gebauer did some quick measurements about this issue. I attach a | 
|---|
| 64 | //  plot. You can see that the angular dependence is (more or less) in agreement | 
|---|
| 65 | //  with a CosTheta function (below 20-25 degrees), | 
|---|
| 66 | //  which is the variation of teh entrance window cross section. So, in | 
|---|
| 67 | //  first approximation, no loses when increasing light incidence angle; | 
|---|
| 68 | //  and therefore, the factor 0.94. | 
|---|
| 69 | // | 
|---|
| 70 | //  So, summarizing... I would propose the following conversion factors | 
|---|
| 71 | //  (while working with CT1 cal box) in order to get the final number of photons | 
|---|
| 72 | //  from the detected measured size in ADC counts. | 
|---|
| 73 | // | 
|---|
| 74 | //  Nph = ADC * FmethodConversionFactor / ConvPhe-PhFactor | 
|---|
| 75 | // | 
|---|
| 76 | //  FmethodConversionFactor ; measured for individual pmts | 
|---|
| 77 | // | 
|---|
| 78 | //  ConvPhe-PhFactor = 0.98 * 0.23 * 0.90 * 0.94 * 0.96 * 0.96 = 0.18 | 
|---|
| 79 | // | 
|---|
| 80 | //  I would not apply any smearing of this factor (which we have in nature), | 
|---|
| 81 | //  since we might be applying it to PMTs in the totally wrong direction. | 
|---|
| 82 | // | 
|---|
| 83 | // | 
|---|
| 84 | //  Error of all variables are calculated by error-propagation. Note that internally, | 
|---|
| 85 | //  all error variables contain Variances in order to save the CPU-intensive square rooting | 
|---|
| 86 | // | 
|---|
| 87 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 88 | #include "MCalibrationChargePix.h" | 
|---|
| 89 |  | 
|---|
| 90 | #include "MLog.h" | 
|---|
| 91 | #include "MLogManip.h" | 
|---|
| 92 |  | 
|---|
| 93 | #include "MBadPixelsPix.h" | 
|---|
| 94 |  | 
|---|
| 95 | ClassImp(MCalibrationChargePix); | 
|---|
| 96 |  | 
|---|
| 97 | using namespace std; | 
|---|
| 98 |  | 
|---|
| 99 | const Float_t MCalibrationChargePix::gkElectronicPedRms         = 1.5; | 
|---|
| 100 | const Float_t MCalibrationChargePix::gkElectronicPedRmsErr      = 0.3; | 
|---|
| 101 | const Float_t MCalibrationChargePix::gkFFactor                  = 1.15; | 
|---|
| 102 | const Float_t MCalibrationChargePix::gkFFactorErr               = 0.02; | 
|---|
| 103 |  | 
|---|
| 104 | const Float_t MCalibrationChargePix::gkConversionHiLo           = 10.; | 
|---|
| 105 | const Float_t MCalibrationChargePix::gkConversionHiLoErr        = 2.5; | 
|---|
| 106 |  | 
|---|
| 107 | const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit    = 5.; | 
|---|
| 108 | // -------------------------------------------------------------------------- | 
|---|
| 109 | // | 
|---|
| 110 | // Default Constructor: | 
|---|
| 111 | // | 
|---|
| 112 | MCalibrationChargePix::MCalibrationChargePix(const char *name, const char *title) | 
|---|
| 113 | : fPixId(-1), | 
|---|
| 114 | fFlags(0) | 
|---|
| 115 | { | 
|---|
| 116 |  | 
|---|
| 117 | fName  = name  ? name  : "MCalibrationChargePix"; | 
|---|
| 118 | fTitle = title ? title : "Container of the fit results of MHCalibrationChargePixs "; | 
|---|
| 119 |  | 
|---|
| 120 | Clear(); | 
|---|
| 121 |  | 
|---|
| 122 | // | 
|---|
| 123 | // At the moment, we don't have a database, yet, | 
|---|
| 124 | // so we get it from the configuration file | 
|---|
| 125 | // | 
|---|
| 126 | SetConversionHiLo(); | 
|---|
| 127 | SetConversionHiLoErr(); | 
|---|
| 128 |  | 
|---|
| 129 | SetPheFFactorMethodLimit(); | 
|---|
| 130 |  | 
|---|
| 131 | } | 
|---|
| 132 |  | 
|---|
| 133 | // ------------------------------------------------------------------------ | 
|---|
| 134 | // | 
|---|
| 135 | // Invalidate values | 
|---|
| 136 | // | 
|---|
| 137 | void MCalibrationChargePix::Clear(Option_t *o) | 
|---|
| 138 | { | 
|---|
| 139 |  | 
|---|
| 140 | SetHiGainSaturation       ( kFALSE ); | 
|---|
| 141 | SetLoGainSaturation       ( kFALSE ); | 
|---|
| 142 | SetExcluded               ( kFALSE ); | 
|---|
| 143 | SetBlindPixelMethodValid  ( kFALSE ); | 
|---|
| 144 | SetFFactorMethodValid     ( kFALSE ); | 
|---|
| 145 | SetPINDiodeMethodValid    ( kFALSE ); | 
|---|
| 146 | SetCombinedMethodValid    ( kFALSE ); | 
|---|
| 147 |  | 
|---|
| 148 | fHiGainMeanCharge                 =  -1.; | 
|---|
| 149 | fHiGainMeanChargeVar              =  -1.; | 
|---|
| 150 | fHiGainSigmaCharge                =  -1.; | 
|---|
| 151 | fHiGainSigmaChargeVar             =  -1.; | 
|---|
| 152 | fHiGainChargeProb                 =  -1.; | 
|---|
| 153 |  | 
|---|
| 154 | fLoGainMeanCharge                 =  -1.; | 
|---|
| 155 | fLoGainMeanChargeVar              =  -1.; | 
|---|
| 156 | fLoGainSigmaCharge                =  -1.; | 
|---|
| 157 | fLoGainSigmaChargeVar             =  -1.; | 
|---|
| 158 | fLoGainChargeProb                 =  -1.; | 
|---|
| 159 |  | 
|---|
| 160 | fRSigmaCharge                     =  -1.; | 
|---|
| 161 | fRSigmaChargeVar                  =  -1.; | 
|---|
| 162 |  | 
|---|
| 163 | fHiGainNumPickup                  =  -1; | 
|---|
| 164 | fLoGainNumPickup                  =  -1; | 
|---|
| 165 |  | 
|---|
| 166 | fPed                              =  -1.; | 
|---|
| 167 | fPedRms                           =  -1.; | 
|---|
| 168 | fPedVar                           =  -1.; | 
|---|
| 169 |  | 
|---|
| 170 | fLoGainPedRms                     =  -1.; | 
|---|
| 171 | fLoGainPedRmsVar                  =  -1.; | 
|---|
| 172 |  | 
|---|
| 173 | fAbsTimeMean                      =  -1.; | 
|---|
| 174 | fAbsTimeRms                       =  -1.; | 
|---|
| 175 |  | 
|---|
| 176 | fPheFFactorMethod                 =  -1.; | 
|---|
| 177 | fPheFFactorMethodVar              =  -1.; | 
|---|
| 178 |  | 
|---|
| 179 | fMeanConversionFFactorMethod      =  -1.; | 
|---|
| 180 | fMeanConversionBlindPixelMethod   =  -1.; | 
|---|
| 181 | fMeanConversionPINDiodeMethod     =  -1.; | 
|---|
| 182 | fMeanConversionCombinedMethod     =  -1.; | 
|---|
| 183 |  | 
|---|
| 184 | fConversionFFactorMethodVar       =  -1.; | 
|---|
| 185 | fConversionBlindPixelMethodVar    =  -1.; | 
|---|
| 186 | fConversionPINDiodeMethodVar      =  -1.; | 
|---|
| 187 | fConversionCombinedMethodVar      =  -1.; | 
|---|
| 188 |  | 
|---|
| 189 | fSigmaConversionFFactorMethod     =  -1.; | 
|---|
| 190 | fSigmaConversionBlindPixelMethod  =  -1.; | 
|---|
| 191 | fSigmaConversionPINDiodeMethod    =  -1.; | 
|---|
| 192 | fSigmaConversionCombinedMethod    =  -1.; | 
|---|
| 193 |  | 
|---|
| 194 | fTotalFFactorFFactorMethod        =  -1.; | 
|---|
| 195 | fTotalFFactorBlindPixelMethod     =  -1.; | 
|---|
| 196 | fTotalFFactorPINDiodeMethod       =  -1.; | 
|---|
| 197 | fTotalFFactorCombinedMethod       =  -1.; | 
|---|
| 198 |  | 
|---|
| 199 | } | 
|---|
| 200 |  | 
|---|
| 201 |  | 
|---|
| 202 | // -------------------------------------------------------------------------- | 
|---|
| 203 | // | 
|---|
| 204 | // Set the pedestals from outside | 
|---|
| 205 | // | 
|---|
| 206 | void MCalibrationChargePix::SetPedestal(const Float_t ped, const Float_t pedrms, const Float_t pederr) | 
|---|
| 207 | { | 
|---|
| 208 |  | 
|---|
| 209 | fPed       = ped; | 
|---|
| 210 | fPedRms    = pedrms; | 
|---|
| 211 | fPedVar    = pederr*pederr; | 
|---|
| 212 | } | 
|---|
| 213 |  | 
|---|
| 214 |  | 
|---|
| 215 | void  MCalibrationChargePix::SetMeanCharge( const Float_t f ) | 
|---|
| 216 | { | 
|---|
| 217 | if (IsHiGainSaturation()) | 
|---|
| 218 | fLoGainMeanCharge = f; | 
|---|
| 219 | else | 
|---|
| 220 | fHiGainMeanCharge = f; | 
|---|
| 221 | } | 
|---|
| 222 |  | 
|---|
| 223 | void  MCalibrationChargePix::SetMeanChargeErr( const Float_t f ) | 
|---|
| 224 | { | 
|---|
| 225 | if (IsHiGainSaturation()) | 
|---|
| 226 | fLoGainMeanChargeVar = f*f; | 
|---|
| 227 | else | 
|---|
| 228 | fHiGainMeanChargeVar = f*f; | 
|---|
| 229 |  | 
|---|
| 230 | } | 
|---|
| 231 |  | 
|---|
| 232 | void  MCalibrationChargePix::SetSigmaCharge( const Float_t f ) | 
|---|
| 233 | { | 
|---|
| 234 | if (IsHiGainSaturation()) | 
|---|
| 235 | fLoGainSigmaCharge = f; | 
|---|
| 236 | else | 
|---|
| 237 | fHiGainSigmaCharge = f; | 
|---|
| 238 | } | 
|---|
| 239 |  | 
|---|
| 240 |  | 
|---|
| 241 | void  MCalibrationChargePix::SetSigmaChargeErr( const Float_t f ) | 
|---|
| 242 | { | 
|---|
| 243 | if (IsHiGainSaturation()) | 
|---|
| 244 | fLoGainSigmaChargeVar = f*f; | 
|---|
| 245 | else | 
|---|
| 246 | fHiGainSigmaChargeVar = f*f; | 
|---|
| 247 |  | 
|---|
| 248 | } | 
|---|
| 249 |  | 
|---|
| 250 | // -------------------------------------------------------------------------- | 
|---|
| 251 | // | 
|---|
| 252 | // Set the conversion factors from outside (only for MC) | 
|---|
| 253 | // | 
|---|
| 254 | void MCalibrationChargePix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig) | 
|---|
| 255 | { | 
|---|
| 256 | fMeanConversionFFactorMethod  = c; | 
|---|
| 257 | fConversionFFactorMethodVar   = err*err; | 
|---|
| 258 | fSigmaConversionFFactorMethod = sig; | 
|---|
| 259 | } | 
|---|
| 260 |  | 
|---|
| 261 | // -------------------------------------------------------------------------- | 
|---|
| 262 | // | 
|---|
| 263 | // Set the conversion factors from outside (only for MC) | 
|---|
| 264 | // | 
|---|
| 265 | void MCalibrationChargePix::SetConversionCombinedMethod(Float_t c, Float_t err, Float_t sig) | 
|---|
| 266 | { | 
|---|
| 267 | fMeanConversionCombinedMethod  = c; | 
|---|
| 268 | fConversionCombinedMethodVar   = err*err; | 
|---|
| 269 | fSigmaConversionCombinedMethod = sig; | 
|---|
| 270 | } | 
|---|
| 271 |  | 
|---|
| 272 |  | 
|---|
| 273 | // -------------------------------------------------------------------------- | 
|---|
| 274 | // | 
|---|
| 275 | // Set the conversion factors from outside (only for MC) | 
|---|
| 276 | // | 
|---|
| 277 | void MCalibrationChargePix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig) | 
|---|
| 278 | { | 
|---|
| 279 | fMeanConversionBlindPixelMethod  = c; | 
|---|
| 280 | fConversionBlindPixelMethodVar   = err*err; | 
|---|
| 281 | fSigmaConversionBlindPixelMethod = sig; | 
|---|
| 282 | } | 
|---|
| 283 |  | 
|---|
| 284 | // -------------------------------------------------------------------------- | 
|---|
| 285 | // | 
|---|
| 286 | // Set the conversion factors from outside (only for MC) | 
|---|
| 287 | // | 
|---|
| 288 | void MCalibrationChargePix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig) | 
|---|
| 289 | { | 
|---|
| 290 | fMeanConversionPINDiodeMethod  = c ; | 
|---|
| 291 | fConversionPINDiodeMethodVar   = err*err; | 
|---|
| 292 | fSigmaConversionPINDiodeMethod = sig; | 
|---|
| 293 | } | 
|---|
| 294 |  | 
|---|
| 295 | // -------------------------------------------------------------------------- | 
|---|
| 296 | // | 
|---|
| 297 | // Set the Hi Gain Saturation Bit from outside | 
|---|
| 298 | // | 
|---|
| 299 | void MCalibrationChargePix::SetHiGainSaturation(Bool_t b) | 
|---|
| 300 | { | 
|---|
| 301 | b ?  SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation); | 
|---|
| 302 | } | 
|---|
| 303 |  | 
|---|
| 304 | // -------------------------------------------------------------------------- | 
|---|
| 305 | // | 
|---|
| 306 | // Set the Lo Gain Saturation Bit from outside | 
|---|
| 307 | // | 
|---|
| 308 | void MCalibrationChargePix::SetLoGainSaturation(Bool_t b) | 
|---|
| 309 | { | 
|---|
| 310 | b ?  SETBIT(fFlags, kLoGainSaturation) : CLRBIT(fFlags, kLoGainSaturation); | 
|---|
| 311 | } | 
|---|
| 312 |  | 
|---|
| 313 | // -------------------------------------------------------------------------- | 
|---|
| 314 | // | 
|---|
| 315 | // Set the Excluded Bit from outside | 
|---|
| 316 | // | 
|---|
| 317 | void MCalibrationChargePix::SetExcluded(Bool_t b ) | 
|---|
| 318 | { | 
|---|
| 319 | b ?  SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded); | 
|---|
| 320 | } | 
|---|
| 321 |  | 
|---|
| 322 |  | 
|---|
| 323 | // -------------------------------------------------------------------------- | 
|---|
| 324 | // | 
|---|
| 325 | // Set the Excluded Bit from outside | 
|---|
| 326 | // | 
|---|
| 327 | void MCalibrationChargePix::SetBlindPixelMethodValid(const Bool_t b ) | 
|---|
| 328 | { | 
|---|
| 329 | b ?  SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid); | 
|---|
| 330 | } | 
|---|
| 331 |  | 
|---|
| 332 | // -------------------------------------------------------------------------- | 
|---|
| 333 | // | 
|---|
| 334 | // Set the Excluded Bit from outside | 
|---|
| 335 | // | 
|---|
| 336 | void MCalibrationChargePix::SetFFactorMethodValid(const Bool_t b ) | 
|---|
| 337 | { | 
|---|
| 338 | b ?  SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid); | 
|---|
| 339 | } | 
|---|
| 340 |  | 
|---|
| 341 | // -------------------------------------------------------------------------- | 
|---|
| 342 | // | 
|---|
| 343 | // Set the Excluded Bit from outside | 
|---|
| 344 | // | 
|---|
| 345 | void MCalibrationChargePix::SetPINDiodeMethodValid(const Bool_t b ) | 
|---|
| 346 | { | 
|---|
| 347 | b ?  SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid); | 
|---|
| 348 | } | 
|---|
| 349 |  | 
|---|
| 350 | // -------------------------------------------------------------------------- | 
|---|
| 351 | // | 
|---|
| 352 | // Set the Excluded Bit from outside | 
|---|
| 353 | // | 
|---|
| 354 | void MCalibrationChargePix::SetCombinedMethodValid(const Bool_t b ) | 
|---|
| 355 | { | 
|---|
| 356 | b ?  SETBIT(fFlags, kCombinedMethodValid) : CLRBIT(fFlags, kCombinedMethodValid); | 
|---|
| 357 | } | 
|---|
| 358 |  | 
|---|
| 359 |  | 
|---|
| 360 | Float_t  MCalibrationChargePix::GetPedRms()  const | 
|---|
| 361 | { | 
|---|
| 362 | return IsHiGainSaturation() ? fLoGainPedRms : fPedRms; | 
|---|
| 363 | } | 
|---|
| 364 |  | 
|---|
| 365 | Float_t  MCalibrationChargePix::GetPedRmsErr()  const | 
|---|
| 366 | { | 
|---|
| 367 | return IsHiGainSaturation() ? TMath::Sqrt(fLoGainPedRmsVar) : TMath::Sqrt(fPedVar)/2.; | 
|---|
| 368 | } | 
|---|
| 369 |  | 
|---|
| 370 | Float_t  MCalibrationChargePix::GetPedErr()  const | 
|---|
| 371 | { | 
|---|
| 372 | return  TMath::Sqrt(fPedVar); | 
|---|
| 373 | } | 
|---|
| 374 |  | 
|---|
| 375 | Float_t  MCalibrationChargePix::GetMeanCharge()   const | 
|---|
| 376 | { | 
|---|
| 377 | return IsHiGainSaturation() ? GetLoGainMeanCharge() : GetHiGainMeanCharge() ; | 
|---|
| 378 | } | 
|---|
| 379 |  | 
|---|
| 380 | Float_t  MCalibrationChargePix::GetMeanChargeErr()   const | 
|---|
| 381 | { | 
|---|
| 382 | return IsHiGainSaturation() ? GetLoGainMeanChargeErr() : GetHiGainMeanChargeErr() ; | 
|---|
| 383 | } | 
|---|
| 384 |  | 
|---|
| 385 | Float_t  MCalibrationChargePix::GetChargeProb()   const | 
|---|
| 386 | { | 
|---|
| 387 | return IsHiGainSaturation() ? fLoGainChargeProb : fHiGainChargeProb ; | 
|---|
| 388 | } | 
|---|
| 389 |  | 
|---|
| 390 | Float_t  MCalibrationChargePix::GetSigmaCharge()   const | 
|---|
| 391 | { | 
|---|
| 392 | return IsHiGainSaturation() ? GetLoGainSigmaCharge() : GetHiGainSigmaCharge() ; | 
|---|
| 393 | } | 
|---|
| 394 |  | 
|---|
| 395 | Float_t  MCalibrationChargePix::GetSigmaChargeErr()   const | 
|---|
| 396 | { | 
|---|
| 397 | return IsHiGainSaturation() ? GetLoGainSigmaChargeErr() : GetHiGainSigmaChargeErr() ; | 
|---|
| 398 | } | 
|---|
| 399 |  | 
|---|
| 400 | Float_t MCalibrationChargePix::GetHiGainMeanChargeErr()  const | 
|---|
| 401 | { | 
|---|
| 402 | return TMath::Sqrt(fHiGainMeanChargeVar); | 
|---|
| 403 | } | 
|---|
| 404 |  | 
|---|
| 405 | Float_t MCalibrationChargePix::GetLoGainMeanCharge()  const | 
|---|
| 406 | { | 
|---|
| 407 | return fLoGainMeanCharge * fConversionHiLo; | 
|---|
| 408 | } | 
|---|
| 409 |  | 
|---|
| 410 | Float_t MCalibrationChargePix::GetLoGainMeanChargeErr()  const | 
|---|
| 411 | { | 
|---|
| 412 |  | 
|---|
| 413 | const Float_t chargeRelVar     =  fLoGainMeanChargeVar | 
|---|
| 414 | /( fLoGainMeanCharge * fLoGainMeanCharge ); | 
|---|
| 415 |  | 
|---|
| 416 | const Float_t conversionRelVar =  fConversionHiLoVar | 
|---|
| 417 | /( fConversionHiLo   * fConversionHiLo   ); | 
|---|
| 418 |  | 
|---|
| 419 | return TMath::Sqrt(chargeRelVar+conversionRelVar) * GetLoGainMeanCharge(); | 
|---|
| 420 | } | 
|---|
| 421 |  | 
|---|
| 422 | Float_t MCalibrationChargePix::GetLoGainSigmaCharge()  const | 
|---|
| 423 | { | 
|---|
| 424 | return fLoGainSigmaCharge * fConversionHiLo; | 
|---|
| 425 | } | 
|---|
| 426 |  | 
|---|
| 427 | Float_t MCalibrationChargePix::GetLoGainSigmaChargeErr()  const | 
|---|
| 428 | { | 
|---|
| 429 |  | 
|---|
| 430 | const Float_t sigmaRelVar     =  fLoGainSigmaChargeVar | 
|---|
| 431 | /( fLoGainSigmaCharge * fLoGainSigmaCharge ); | 
|---|
| 432 |  | 
|---|
| 433 | const Float_t conversionRelVar =  fConversionHiLoVar | 
|---|
| 434 | /( fConversionHiLo   * fConversionHiLo   ); | 
|---|
| 435 |  | 
|---|
| 436 | return TMath::Sqrt(sigmaRelVar+conversionRelVar) * GetLoGainSigmaCharge(); | 
|---|
| 437 | } | 
|---|
| 438 |  | 
|---|
| 439 | Float_t MCalibrationChargePix::GetHiGainSigmaChargeErr()  const | 
|---|
| 440 | { | 
|---|
| 441 | return TMath::Sqrt(fHiGainSigmaChargeVar); | 
|---|
| 442 | } | 
|---|
| 443 |  | 
|---|
| 444 | Float_t MCalibrationChargePix::GetRSigmaCharge()  const | 
|---|
| 445 | { | 
|---|
| 446 | return IsHiGainSaturation() ? fRSigmaCharge*fConversionHiLo : fRSigmaCharge ; | 
|---|
| 447 | } | 
|---|
| 448 |  | 
|---|
| 449 | Float_t MCalibrationChargePix::GetRSigmaChargeErr()  const | 
|---|
| 450 | { | 
|---|
| 451 | if (IsHiGainSaturation()) | 
|---|
| 452 | { | 
|---|
| 453 | const Float_t rsigmaRelVar     =  fRSigmaChargeVar | 
|---|
| 454 | /( fRSigmaCharge * fRSigmaCharge ); | 
|---|
| 455 | const Float_t conversionRelVar =  fConversionHiLoVar | 
|---|
| 456 | /( fConversionHiLo   * fConversionHiLo   ); | 
|---|
| 457 | return TMath::Sqrt(rsigmaRelVar+conversionRelVar) * GetRSigmaCharge(); | 
|---|
| 458 | } | 
|---|
| 459 | else | 
|---|
| 460 | return TMath::Sqrt(fRSigmaChargeVar); | 
|---|
| 461 |  | 
|---|
| 462 | } | 
|---|
| 463 |  | 
|---|
| 464 | Float_t MCalibrationChargePix::GetConversionHiLoErr()  const | 
|---|
| 465 | { | 
|---|
| 466 | if (fConversionHiLoVar < 0.) | 
|---|
| 467 | return -1.; | 
|---|
| 468 | return TMath::Sqrt(fConversionHiLoVar); | 
|---|
| 469 | } | 
|---|
| 470 |  | 
|---|
| 471 | Float_t MCalibrationChargePix::GetPheFFactorMethodErr()  const | 
|---|
| 472 | { | 
|---|
| 473 | if (fPheFFactorMethodVar < 0.) | 
|---|
| 474 | return -1.; | 
|---|
| 475 | return TMath::Sqrt(fPheFFactorMethodVar); | 
|---|
| 476 | } | 
|---|
| 477 |  | 
|---|
| 478 | Float_t MCalibrationChargePix::GetConversionCombinedMethodErr()  const | 
|---|
| 479 | { | 
|---|
| 480 | if (fConversionCombinedMethodVar < 0.) | 
|---|
| 481 | return -1.; | 
|---|
| 482 | return TMath::Sqrt(fConversionCombinedMethodVar); | 
|---|
| 483 | } | 
|---|
| 484 |  | 
|---|
| 485 | Float_t MCalibrationChargePix::GetConversionPINDiodeMethodErr()  const | 
|---|
| 486 | { | 
|---|
| 487 | if (fConversionPINDiodeMethodVar < 0.) | 
|---|
| 488 | return -1.; | 
|---|
| 489 | return TMath::Sqrt(fConversionPINDiodeMethodVar); | 
|---|
| 490 | } | 
|---|
| 491 |  | 
|---|
| 492 | Float_t MCalibrationChargePix::GetConversionBlindPixelMethodErr()  const | 
|---|
| 493 | { | 
|---|
| 494 | if (fConversionBlindPixelMethodVar < 0.) | 
|---|
| 495 | return -1.; | 
|---|
| 496 | return TMath::Sqrt(fConversionBlindPixelMethodVar); | 
|---|
| 497 | } | 
|---|
| 498 |  | 
|---|
| 499 | Float_t MCalibrationChargePix::GetConversionFFactorMethodErr()  const | 
|---|
| 500 | { | 
|---|
| 501 | if (fConversionFFactorMethodVar < 0.) | 
|---|
| 502 | return -1.; | 
|---|
| 503 | return TMath::Sqrt(fConversionFFactorMethodVar); | 
|---|
| 504 | } | 
|---|
| 505 |  | 
|---|
| 506 | Float_t MCalibrationChargePix::GetTotalFFactorCombinedMethodErr()  const | 
|---|
| 507 | { | 
|---|
| 508 | if (fTotalFFactorCombinedMethodVar < 0.) | 
|---|
| 509 | return -1.; | 
|---|
| 510 | return TMath::Sqrt(fTotalFFactorCombinedMethodVar); | 
|---|
| 511 | } | 
|---|
| 512 |  | 
|---|
| 513 | Float_t MCalibrationChargePix::GetTotalFFactorPINDiodeMethodErr()  const | 
|---|
| 514 | { | 
|---|
| 515 | if (fTotalFFactorPINDiodeMethodVar < 0.) | 
|---|
| 516 | return -1.; | 
|---|
| 517 | return TMath::Sqrt(fTotalFFactorPINDiodeMethodVar); | 
|---|
| 518 | } | 
|---|
| 519 |  | 
|---|
| 520 | Float_t MCalibrationChargePix::GetTotalFFactorBlindPixelMethodErr()  const | 
|---|
| 521 | { | 
|---|
| 522 | if (fTotalFFactorBlindPixelMethodVar < 0.) | 
|---|
| 523 | return -1.; | 
|---|
| 524 | return TMath::Sqrt(fTotalFFactorBlindPixelMethodVar); | 
|---|
| 525 | } | 
|---|
| 526 |  | 
|---|
| 527 | Float_t MCalibrationChargePix::GetTotalFFactorFFactorMethodErr()  const | 
|---|
| 528 | { | 
|---|
| 529 | if (fTotalFFactorFFactorMethodVar < 0.) | 
|---|
| 530 | return -1.; | 
|---|
| 531 | return TMath::Sqrt(fTotalFFactorFFactorMethodVar); | 
|---|
| 532 | } | 
|---|
| 533 |  | 
|---|
| 534 | Bool_t MCalibrationChargePix::IsExcluded()     const | 
|---|
| 535 | { | 
|---|
| 536 | return TESTBIT(fFlags,kExcluded); | 
|---|
| 537 | } | 
|---|
| 538 |  | 
|---|
| 539 | Bool_t MCalibrationChargePix::IsHiGainSaturation()    const | 
|---|
| 540 | { | 
|---|
| 541 | return TESTBIT(fFlags,kHiGainSaturation); | 
|---|
| 542 | } | 
|---|
| 543 |  | 
|---|
| 544 | Bool_t MCalibrationChargePix::IsLoGainSaturation()    const | 
|---|
| 545 | { | 
|---|
| 546 | return TESTBIT(fFlags,kLoGainSaturation); | 
|---|
| 547 | } | 
|---|
| 548 |  | 
|---|
| 549 | Bool_t MCalibrationChargePix::IsBlindPixelMethodValid() const | 
|---|
| 550 | { | 
|---|
| 551 | return TESTBIT(fFlags, kBlindPixelMethodValid); | 
|---|
| 552 | } | 
|---|
| 553 |  | 
|---|
| 554 | Bool_t MCalibrationChargePix::IsFFactorMethodValid()   const | 
|---|
| 555 | { | 
|---|
| 556 | return TESTBIT(fFlags, kFFactorMethodValid); | 
|---|
| 557 | } | 
|---|
| 558 |  | 
|---|
| 559 | Bool_t MCalibrationChargePix::IsPINDiodeMethodValid()  const | 
|---|
| 560 | { | 
|---|
| 561 | return TESTBIT(fFlags, kPINDiodeMethodValid); | 
|---|
| 562 | } | 
|---|
| 563 |  | 
|---|
| 564 | Bool_t MCalibrationChargePix::IsCombinedMethodValid()  const | 
|---|
| 565 | { | 
|---|
| 566 | return TESTBIT(fFlags, kCombinedMethodValid); | 
|---|
| 567 | } | 
|---|
| 568 |  | 
|---|
| 569 | // | 
|---|
| 570 | // | 
|---|
| 571 | // | 
|---|
| 572 | Bool_t MCalibrationChargePix::CalcReducedSigma() | 
|---|
| 573 | { | 
|---|
| 574 |  | 
|---|
| 575 | const Float_t sigmacharge    = IsHiGainSaturation() ? fLoGainSigmaCharge    : fHiGainSigmaCharge   ; | 
|---|
| 576 | const Float_t sigmachargevar = IsHiGainSaturation() ? fLoGainSigmaChargeVar : fHiGainSigmaChargeVar; | 
|---|
| 577 |  | 
|---|
| 578 | const Float_t sigmaSquare     =      sigmacharge     * sigmacharge; | 
|---|
| 579 | const Float_t sigmaSquareVar  = 4.*  sigmachargevar  * sigmaSquare; | 
|---|
| 580 |  | 
|---|
| 581 | Float_t pedRmsSquare ; | 
|---|
| 582 | Float_t pedRmsSquareVar; | 
|---|
| 583 |  | 
|---|
| 584 | if (IsHiGainSaturation()) | 
|---|
| 585 | { | 
|---|
| 586 | pedRmsSquare     =      fLoGainPedRms    * fLoGainPedRms; | 
|---|
| 587 | pedRmsSquareVar  =  4.* fLoGainPedRmsVar * pedRmsSquare; | 
|---|
| 588 | } | 
|---|
| 589 | else | 
|---|
| 590 | { | 
|---|
| 591 | pedRmsSquare       =  fPedRms * fPedRms; | 
|---|
| 592 | pedRmsSquareVar    =  fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2. | 
|---|
| 593 | } | 
|---|
| 594 | // | 
|---|
| 595 | // Calculate the reduced sigmas | 
|---|
| 596 | // | 
|---|
| 597 | const Float_t rsigmachargesquare = sigmaSquare - pedRmsSquare; | 
|---|
| 598 | if (rsigmachargesquare <= 0.) | 
|---|
| 599 | { | 
|---|
| 600 | *fLog << warn | 
|---|
| 601 | << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel " | 
|---|
| 602 | << fPixId << endl; | 
|---|
| 603 | return kFALSE; | 
|---|
| 604 | } | 
|---|
| 605 |  | 
|---|
| 606 |  | 
|---|
| 607 | fRSigmaCharge    = TMath::Sqrt(rsigmachargesquare); | 
|---|
| 608 | fRSigmaChargeVar = 0.25 * (sigmaSquareVar + pedRmsSquareVar) / rsigmachargesquare; | 
|---|
| 609 |  | 
|---|
| 610 | return kTRUE; | 
|---|
| 611 | } | 
|---|
| 612 |  | 
|---|
| 613 | // | 
|---|
| 614 | // Calculate the number of photo-electrons after the F-Factor method | 
|---|
| 615 | // Calculate the errors of the F-Factor method | 
|---|
| 616 | // | 
|---|
| 617 | Bool_t MCalibrationChargePix::CalcFFactorMethod() | 
|---|
| 618 | { | 
|---|
| 619 |  | 
|---|
| 620 | if (fRSigmaCharge < 0.) | 
|---|
| 621 | { | 
|---|
| 622 | SetFFactorMethodValid(kFALSE); | 
|---|
| 623 | return kFALSE; | 
|---|
| 624 | } | 
|---|
| 625 |  | 
|---|
| 626 | const Float_t charge    = IsHiGainSaturation() ? fLoGainMeanCharge    : fHiGainMeanCharge   ; | 
|---|
| 627 | const Float_t chargevar = IsHiGainSaturation() ? fLoGainMeanChargeVar : fHiGainMeanChargeVar; | 
|---|
| 628 |  | 
|---|
| 629 | // | 
|---|
| 630 | // Square all variables in order to avoid applications of square root | 
|---|
| 631 | // | 
|---|
| 632 | // First the relative error squares | 
|---|
| 633 | // | 
|---|
| 634 | const Float_t chargeSquare        =     charge * charge; | 
|---|
| 635 | const Float_t chargeSquareRelVar  = 4.* chargevar/ chargeSquare; | 
|---|
| 636 |  | 
|---|
| 637 | const Float_t ffactorsquare       =    gkFFactor    * gkFFactor; | 
|---|
| 638 | const Float_t ffactorsquareRelVar = 4.*gkFFactorErr * gkFFactorErr / ffactorsquare; | 
|---|
| 639 |  | 
|---|
| 640 | const Float_t rsigmaSquare        =     fRSigmaCharge    * fRSigmaCharge; | 
|---|
| 641 | const Float_t rsigmaSquareRelVar  = 4.* fRSigmaChargeVar / rsigmaSquare; | 
|---|
| 642 |  | 
|---|
| 643 | // | 
|---|
| 644 | // Calculate the number of phe's from the F-Factor method | 
|---|
| 645 | // (independent on Hi Gain or Lo Gain) | 
|---|
| 646 | // | 
|---|
| 647 | fPheFFactorMethod = ffactorsquare * chargeSquare / rsigmaSquare; | 
|---|
| 648 |  | 
|---|
| 649 | if (fPheFFactorMethod < fPheFFactorMethodLimit) | 
|---|
| 650 | { | 
|---|
| 651 | SetFFactorMethodValid(kFALSE); | 
|---|
| 652 | return kFALSE; | 
|---|
| 653 | } | 
|---|
| 654 |  | 
|---|
| 655 | // | 
|---|
| 656 | // Calculate the Error of Nphe | 
|---|
| 657 | // | 
|---|
| 658 | fPheFFactorMethodVar =  (ffactorsquareRelVar + chargeSquareRelVar + rsigmaSquareRelVar) | 
|---|
| 659 | * fPheFFactorMethod * fPheFFactorMethod; | 
|---|
| 660 |  | 
|---|
| 661 | SetFFactorMethodValid(kTRUE); | 
|---|
| 662 | return kTRUE; | 
|---|
| 663 | } | 
|---|
| 664 |  | 
|---|
| 665 |  | 
|---|
| 666 | void MCalibrationChargePix::CalcLoGainPedestal(Float_t logainsamples) | 
|---|
| 667 | { | 
|---|
| 668 |  | 
|---|
| 669 | fElectronicPedRms       = gkElectronicPedRms    * TMath::Sqrt(logainsamples); | 
|---|
| 670 | fElectronicPedRmsVar    = gkElectronicPedRmsErr * gkElectronicPedRmsErr * logainsamples; | 
|---|
| 671 |  | 
|---|
| 672 | Float_t pedRmsSquare      = fPedRms * fPedRms; | 
|---|
| 673 | Float_t pedRmsSquareVar   = fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2. | 
|---|
| 674 |  | 
|---|
| 675 | // | 
|---|
| 676 | // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it | 
|---|
| 677 | // from the HI GAIN (all calculation per slice up to now): | 
|---|
| 678 | // | 
|---|
| 679 | // We extract the pure NSB contribution: | 
|---|
| 680 | // | 
|---|
| 681 | const Float_t elecRmsSquare    =    fElectronicPedRms    * fElectronicPedRms; | 
|---|
| 682 | const Float_t elecRmsSquareVar = 4.*fElectronicPedRmsVar * elecRmsSquare; | 
|---|
| 683 |  | 
|---|
| 684 | Float_t nsbSquare             =  pedRmsSquare    - elecRmsSquare; | 
|---|
| 685 | Float_t nsbSquareRelVar       = (pedRmsSquareVar + elecRmsSquareVar) | 
|---|
| 686 | / (nsbSquare * nsbSquare) ; | 
|---|
| 687 |  | 
|---|
| 688 | if (nsbSquare < 0.) | 
|---|
| 689 | nsbSquare = 0.; | 
|---|
| 690 |  | 
|---|
| 691 | // | 
|---|
| 692 | // Now, we divide the NSB by the conversion factor and | 
|---|
| 693 | // add it quadratically to the electronic noise | 
|---|
| 694 | // | 
|---|
| 695 | const Float_t conversionSquare        =    fConversionHiLo    * fConversionHiLo; | 
|---|
| 696 | const Float_t convertedNsbSquare      =    nsbSquare       / conversionSquare; | 
|---|
| 697 | const Float_t convertedNsbSquareVar   =    nsbSquareRelVar | 
|---|
| 698 | * convertedNsbSquare * convertedNsbSquare; | 
|---|
| 699 |  | 
|---|
| 700 | pedRmsSquare     = convertedNsbSquare    + elecRmsSquare; | 
|---|
| 701 | pedRmsSquareVar  = convertedNsbSquareVar + elecRmsSquareVar; | 
|---|
| 702 |  | 
|---|
| 703 | fLoGainPedRms    = TMath::Sqrt(pedRmsSquare); | 
|---|
| 704 | fLoGainPedRmsVar = 0.25 * pedRmsSquareVar /  pedRmsSquare; | 
|---|
| 705 |  | 
|---|
| 706 | } | 
|---|
| 707 |  | 
|---|
| 708 |  | 
|---|
| 709 |  | 
|---|