| 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 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 | #include "MCalibrationPix.h"
|
|---|
| 34 | #include "MCalibrationConfig.h"
|
|---|
| 35 |
|
|---|
| 36 | #include "MLog.h"
|
|---|
| 37 | #include "MLogManip.h"
|
|---|
| 38 |
|
|---|
| 39 | ClassImp(MCalibrationPix);
|
|---|
| 40 |
|
|---|
| 41 | using namespace std;
|
|---|
| 42 |
|
|---|
| 43 | // --------------------------------------------------------------------------
|
|---|
| 44 | //
|
|---|
| 45 | // Default Constructor:
|
|---|
| 46 | //
|
|---|
| 47 | // The following values are initialized to meaningful values:
|
|---|
| 48 | //
|
|---|
| 49 | // - The Electronic Rms to 1.5 per FADC slice
|
|---|
| 50 | // - The uncertainty about the Electronic RMS to 0.3 per slice
|
|---|
| 51 | // - The F-Factor is assumed to have been measured in Munich to 1.13 - 1.17.
|
|---|
| 52 | // We use here the Square of the Munich definition, thus:
|
|---|
| 53 | // Mean F-Factor = 1.15*1.15 = 1.32
|
|---|
| 54 | // Error F-Factor = 2.*0.02 = 0.04
|
|---|
| 55 | //
|
|---|
| 56 | MCalibrationPix::MCalibrationPix(const char *name, const char *title)
|
|---|
| 57 | : fPixId(-1),
|
|---|
| 58 | fCharge(-1.),
|
|---|
| 59 | fErrCharge(-1.),
|
|---|
| 60 | fSigmaCharge(-1.),
|
|---|
| 61 | fErrSigmaCharge(-1.),
|
|---|
| 62 | fRSigmaSquare(-1.),
|
|---|
| 63 | fChargeProb(-1.),
|
|---|
| 64 | fPed(-1.),
|
|---|
| 65 | fPedRms(-1.),
|
|---|
| 66 | fErrPedRms(0.),
|
|---|
| 67 | fElectronicPedRms(1.5),
|
|---|
| 68 | fErrElectronicPedRms(0.3),
|
|---|
| 69 | fTime(-1.),
|
|---|
| 70 | fSigmaTime(-1.),
|
|---|
| 71 | fTimeChiSquare(-1.),
|
|---|
| 72 | fFactor(1.32),
|
|---|
| 73 | fFactorError(0.04),
|
|---|
| 74 | fPheFFactorMethod(-1.),
|
|---|
| 75 | fPheFFactorMethodError(-1.),
|
|---|
| 76 | fConversionFFactorMethod(-1.),
|
|---|
| 77 | fConversionBlindPixelMethod(-1.),
|
|---|
| 78 | fConversionPINDiodeMethod(-1.),
|
|---|
| 79 | fConversionErrorFFactorMethod(-1.),
|
|---|
| 80 | fConversionErrorBlindPixelMethod(-1.),
|
|---|
| 81 | fConversionErrorPINDiodeMethod(-1.),
|
|---|
| 82 | fConversionSigmaFFactorMethod(-1.),
|
|---|
| 83 | fConversionSigmaBlindPixelMethod(-1.),
|
|---|
| 84 | fConversionSigmaPINDiodeMethod(-1.),
|
|---|
| 85 | fHiGainSaturation(kFALSE),
|
|---|
| 86 | fExcluded(kFALSE),
|
|---|
| 87 | fFitValid(kFALSE),
|
|---|
| 88 | fFitted(kFALSE),
|
|---|
| 89 | fBlindPixelMethodValid(kFALSE),
|
|---|
| 90 | fFFactorMethodValid(kFALSE),
|
|---|
| 91 | fPINDiodeMethodValid(kFALSE),
|
|---|
| 92 | fChargeLimit(5.),
|
|---|
| 93 | fChargeErrLimit(0.)
|
|---|
| 94 | {
|
|---|
| 95 |
|
|---|
| 96 | fName = name ? name : "MCalibrationPixel";
|
|---|
| 97 | fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
|
|---|
| 98 |
|
|---|
| 99 | //
|
|---|
| 100 | // At the moment, we don't have a database, yet,
|
|---|
| 101 | // so we get it from the configuration file
|
|---|
| 102 | //
|
|---|
| 103 | fConversionHiLo = gkConversionHiLo;
|
|---|
| 104 | fConversionHiLoError = gkConversionHiLoError;
|
|---|
| 105 |
|
|---|
| 106 | fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
|
|---|
| 107 |
|
|---|
| 108 | if (!fHist)
|
|---|
| 109 | *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl;
|
|---|
| 110 |
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | MCalibrationPix::~MCalibrationPix()
|
|---|
| 114 | {
|
|---|
| 115 | delete fHist;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | void MCalibrationPix::DefinePixId(Int_t i)
|
|---|
| 120 | {
|
|---|
| 121 |
|
|---|
| 122 | fPixId = i;
|
|---|
| 123 | fHist->ChangeHistId(i);
|
|---|
| 124 |
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | // ------------------------------------------------------------------------
|
|---|
| 129 | //
|
|---|
| 130 | // Invalidate values
|
|---|
| 131 | //
|
|---|
| 132 | void MCalibrationPix::Clear(Option_t *o)
|
|---|
| 133 | {
|
|---|
| 134 | fHist->Reset();
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | // --------------------------------------------------------------------------
|
|---|
| 139 | //
|
|---|
| 140 | // 1) Return if the charge distribution is already succesfully fitted
|
|---|
| 141 | // or if the histogram is empty
|
|---|
| 142 | // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
|
|---|
| 143 | // possible remaining cosmics to spoil the fit.
|
|---|
| 144 | // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
|
|---|
| 145 | // 4) Fit the histograms with a Gaussian
|
|---|
| 146 | // 5) In case of failure print out the fit results
|
|---|
| 147 | // 6) Retrieve the results and store them in this class
|
|---|
| 148 | // 7) Calculate the number of photo-electrons after the F-Factor method
|
|---|
| 149 | // 8) Calculate the errors of the F-Factor method
|
|---|
| 150 | //
|
|---|
| 151 | // The fits are declared valid (fFitValid = kTRUE), if:
|
|---|
| 152 | //
|
|---|
| 153 | // 1) Pixel has a fitted charge greater than 5*PedRMS
|
|---|
| 154 | // 2) Pixel has a fit error greater than 0.
|
|---|
| 155 | // 3) Pixel has a fit Probability greater than 0.0001
|
|---|
| 156 | // 4) Pixel has a charge sigma bigger than its Pedestal RMS
|
|---|
| 157 | // 5) If FitTimes is used,
|
|---|
| 158 | // the mean arrival time is at least 1.0 slices from the used edge slices
|
|---|
| 159 | // (this stage is only performed in the times fit)
|
|---|
| 160 | //
|
|---|
| 161 | // If the histogram is empty, all values are set to -1.
|
|---|
| 162 | //
|
|---|
| 163 | // The conversion factor after the F-Factor method is declared valid, if:
|
|---|
| 164 | //
|
|---|
| 165 | // 1) fFitValid is kTRUE
|
|---|
| 166 | // 2) Conversion Factor is bigger than 0.
|
|---|
| 167 | // 3) The error of the conversion factor is smaller than 10%
|
|---|
| 168 | //
|
|---|
| 169 | Bool_t MCalibrationPix::FitCharge()
|
|---|
| 170 | {
|
|---|
| 171 |
|
|---|
| 172 | //
|
|---|
| 173 | // 1) Return if the charge distribution is already succesfully fitted
|
|---|
| 174 | // or if the histogram is empty
|
|---|
| 175 | //
|
|---|
| 176 | if (fHist->IsFitOK() || fHist->IsEmpty())
|
|---|
| 177 | return kTRUE;
|
|---|
| 178 |
|
|---|
| 179 | //
|
|---|
| 180 | // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
|
|---|
| 181 | // possible remaining cosmics to spoil the fit.
|
|---|
| 182 | //
|
|---|
| 183 | if (fPed && fPedRms)
|
|---|
| 184 | fHist->SetLowerFitRange(1.5*fPedRms);
|
|---|
| 185 | else
|
|---|
| 186 | *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl;
|
|---|
| 187 |
|
|---|
| 188 | //
|
|---|
| 189 | // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
|
|---|
| 190 | //
|
|---|
| 191 | if (fHist->UseLoGain())
|
|---|
| 192 | {
|
|---|
| 193 |
|
|---|
| 194 | SetHiGainSaturation();
|
|---|
| 195 |
|
|---|
| 196 | //
|
|---|
| 197 | // 4) Fit the Lo Gain histograms with a Gaussian
|
|---|
| 198 | //
|
|---|
| 199 | if(!fHist->FitChargeLoGain())
|
|---|
| 200 | {
|
|---|
| 201 | *fLog << warn << "WARNING: Could not fit Lo Gain charges of pixel " << fPixId << endl;
|
|---|
| 202 | //
|
|---|
| 203 | // 5) In case of failure print out the fit results
|
|---|
| 204 | //
|
|---|
| 205 | fHist->PrintChargeFitResult();
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 | else
|
|---|
| 209 | {
|
|---|
| 210 | //
|
|---|
| 211 | // 4) Fit the Hi Gain histograms with a Gaussian
|
|---|
| 212 | //
|
|---|
| 213 | if(!fHist->FitChargeHiGain())
|
|---|
| 214 | {
|
|---|
| 215 | *fLog << warn << "WARNING: Could not fit Hi Gain charges of pixel " << fPixId << endl;
|
|---|
| 216 | //
|
|---|
| 217 | // 5) In case of failure print out the fit results
|
|---|
| 218 | //
|
|---|
| 219 | fHist->PrintChargeFitResult();
|
|---|
| 220 | }
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 | //
|
|---|
| 225 | // 6) Retrieve the results and store them in this class
|
|---|
| 226 | //
|
|---|
| 227 | fCharge = fHist->GetChargeMean();
|
|---|
| 228 | fErrCharge = fHist->GetChargeMeanErr();
|
|---|
| 229 | fSigmaCharge = fHist->GetChargeSigma();
|
|---|
| 230 | fErrSigmaCharge = fHist->GetChargeSigmaErr();
|
|---|
| 231 | fChargeProb = fHist->GetChargeProb();
|
|---|
| 232 |
|
|---|
| 233 | if (fCharge <= 0.)
|
|---|
| 234 | {
|
|---|
| 235 | *fLog << warn << "WARNING: Cannot apply calibration: Mean Fitted Charges are smaller than 0 in pixel "
|
|---|
| 236 | << fPixId << endl;
|
|---|
| 237 | return kFALSE;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | if (fErrCharge > 0.)
|
|---|
| 241 | fFitted = kTRUE;
|
|---|
| 242 |
|
|---|
| 243 | if (CheckChargeFitValidity())
|
|---|
| 244 | fFitValid = kTRUE;
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 | //
|
|---|
| 248 | // 7) Calculate the number of photo-electrons after the F-Factor method
|
|---|
| 249 | // 8) Calculate the errors of the F-Factor method
|
|---|
| 250 | //
|
|---|
| 251 | if ((fPed > 0.) && (fPedRms > 0.))
|
|---|
| 252 | {
|
|---|
| 253 |
|
|---|
| 254 | //
|
|---|
| 255 | // Square all variables in order to avoid applications of square root
|
|---|
| 256 | //
|
|---|
| 257 | // First the relative error squares
|
|---|
| 258 | //
|
|---|
| 259 | const Float_t chargeSquare = fCharge* fCharge;
|
|---|
| 260 | const Float_t chargeSquareRelErrSquare = 4.*fErrCharge*fErrCharge / chargeSquare;
|
|---|
| 261 |
|
|---|
| 262 | const Float_t fFactorRelErrSquare = fFactorError * fFactorError / (fFactor * fFactor);
|
|---|
| 263 | //
|
|---|
| 264 | // Now the absolute error squares
|
|---|
| 265 | //
|
|---|
| 266 | const Float_t sigmaSquare = fSigmaCharge* fSigmaCharge;
|
|---|
| 267 | const Float_t sigmaSquareErrSquare = 4.*fErrSigmaCharge*fErrSigmaCharge * sigmaSquare;
|
|---|
| 268 |
|
|---|
| 269 | const Float_t elecRmsSquare = fElectronicPedRms* fElectronicPedRms;
|
|---|
| 270 | const Float_t elecRmsSquareErrSquare = 4.*fErrElectronicPedRms*fErrElectronicPedRms * elecRmsSquare;
|
|---|
| 271 |
|
|---|
| 272 | Float_t pedRmsSquare = fPedRms* fPedRms;
|
|---|
| 273 | Float_t pedRmsSquareErrSquare = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
|
|---|
| 274 |
|
|---|
| 275 | if (fHiGainSaturation)
|
|---|
| 276 | {
|
|---|
| 277 |
|
|---|
| 278 | //
|
|---|
| 279 | // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
|
|---|
| 280 | // from the Hi Gain:
|
|---|
| 281 | //
|
|---|
| 282 | // We extract the pure NSB contribution:
|
|---|
| 283 | //
|
|---|
| 284 | Float_t nsbSquare = pedRmsSquare - elecRmsSquare;
|
|---|
| 285 | Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
|
|---|
| 286 | / (nsbSquare * nsbSquare) ;
|
|---|
| 287 |
|
|---|
| 288 | if (nsbSquare < 0.)
|
|---|
| 289 | nsbSquare = 0.;
|
|---|
| 290 |
|
|---|
| 291 | //
|
|---|
| 292 | // Now, we divide the NSB by the conversion factor and
|
|---|
| 293 | // add it quadratically to the electronic noise
|
|---|
| 294 | //
|
|---|
| 295 | const Float_t conversionSquare = fConversionHiLo *fConversionHiLo;
|
|---|
| 296 | const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoError*fConversionHiLoError/conversionSquare;
|
|---|
| 297 |
|
|---|
| 298 | //
|
|---|
| 299 | // Calculate the new "Pedestal RMS"
|
|---|
| 300 | //
|
|---|
| 301 | const Float_t convertedNsbSquare = nsbSquare / conversionSquare;
|
|---|
| 302 | const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
|
|---|
| 303 | * convertedNsbSquare * convertedNsbSquare;
|
|---|
| 304 |
|
|---|
| 305 | pedRmsSquare = convertedNsbSquare + elecRmsSquare;
|
|---|
| 306 | pedRmsSquareErrSquare = convertedNsbSquareErrSquare + elecRmsSquareErrSquare;
|
|---|
| 307 |
|
|---|
| 308 | } /* if (fHiGainSaturation) */
|
|---|
| 309 |
|
|---|
| 310 | //
|
|---|
| 311 | // Calculate the reduced sigmas
|
|---|
| 312 | //
|
|---|
| 313 | fRSigmaSquare = sigmaSquare - pedRmsSquare;
|
|---|
| 314 | if (fRSigmaSquare <= 0.)
|
|---|
| 315 | {
|
|---|
| 316 | *fLog << warn
|
|---|
| 317 | << "WARNING: Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel "
|
|---|
| 318 | << fPixId << endl;
|
|---|
| 319 | if (fHiGainSaturation)
|
|---|
| 320 | ApplyLoGainConversion();
|
|---|
| 321 | return kFALSE;
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | const Float_t rSigmaSquareRelErrSquare = (sigmaSquareErrSquare + pedRmsSquareErrSquare)
|
|---|
| 325 | / (fRSigmaSquare * fRSigmaSquare) ;
|
|---|
| 326 |
|
|---|
| 327 | //
|
|---|
| 328 | // Calculate the number of phe's from the F-Factor method
|
|---|
| 329 | // (independent on Hi Gain or Lo Gain)
|
|---|
| 330 | //
|
|---|
| 331 | fPheFFactorMethod = fFactor * chargeSquare / fRSigmaSquare;
|
|---|
| 332 |
|
|---|
| 333 | const Float_t pheFFactorRelErrSquare = fFactorRelErrSquare
|
|---|
| 334 | + chargeSquareRelErrSquare
|
|---|
| 335 | + rSigmaSquareRelErrSquare ;
|
|---|
| 336 |
|
|---|
| 337 | fPheFFactorMethodError = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
|
|---|
| 338 |
|
|---|
| 339 | //
|
|---|
| 340 | // Calculate the conversion factors
|
|---|
| 341 | //
|
|---|
| 342 | if (fHiGainSaturation)
|
|---|
| 343 | ApplyLoGainConversion();
|
|---|
| 344 |
|
|---|
| 345 | const Float_t chargeRelErrSquare = fErrCharge*fErrCharge / (fCharge * fCharge);
|
|---|
| 346 |
|
|---|
| 347 | fConversionFFactorMethod = fPheFFactorMethod / fCharge ;
|
|---|
| 348 | fConversionErrorFFactorMethod = ( pheFFactorRelErrSquare + chargeRelErrSquare )
|
|---|
| 349 | * fConversionFFactorMethod * fConversionFFactorMethod;
|
|---|
| 350 |
|
|---|
| 351 | if ( IsFitValid() &&
|
|---|
| 352 | (fConversionFFactorMethod > 0.) &&
|
|---|
| 353 | (fConversionErrorFFactorMethod/fConversionFFactorMethod < 0.1) )
|
|---|
| 354 | fFFactorMethodValid = kTRUE;
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 | } /* if ((fPed > 0.) && (fPedRms > 0.)) */
|
|---|
| 358 |
|
|---|
| 359 | return kTRUE;
|
|---|
| 360 |
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | //
|
|---|
| 364 | // The check return kTRUE if:
|
|---|
| 365 | //
|
|---|
| 366 | // 1) Pixel has a fitted charge greater than 5*PedRMS
|
|---|
| 367 | // 2) Pixel has a fit error greater than 0.
|
|---|
| 368 | // 3) Pixel has a fit Probability greater than 0.0001
|
|---|
| 369 | // 4) Pixel has a charge sigma bigger than its Pedestal RMS
|
|---|
| 370 | //
|
|---|
| 371 | Bool_t MCalibrationPix::CheckChargeFitValidity()
|
|---|
| 372 | {
|
|---|
| 373 |
|
|---|
| 374 | Float_t equivpedestal = GetPedRms();
|
|---|
| 375 |
|
|---|
| 376 | if (fHiGainSaturation)
|
|---|
| 377 | equivpedestal /= fConversionHiLo;
|
|---|
| 378 |
|
|---|
| 379 | if (fCharge < fChargeLimit*equivpedestal)
|
|---|
| 380 | {
|
|---|
| 381 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
|---|
| 382 | << fChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
|
|---|
| 383 | return kFALSE;
|
|---|
| 384 | }
|
|---|
| 385 |
|
|---|
| 386 | if (fErrCharge < fChargeErrLimit)
|
|---|
| 387 | {
|
|---|
| 388 | *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
|
|---|
| 389 | << fChargeErrLimit << " in Pixel " << fPixId << endl;
|
|---|
| 390 | return kFALSE;
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | if (!fHist->IsFitOK())
|
|---|
| 394 | {
|
|---|
| 395 | *fLog << warn << "WARNING: Probability of Fitted Charge too low in Pixel " << fPixId << endl;
|
|---|
| 396 | return kFALSE;
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | if (fSigmaCharge < equivpedestal)
|
|---|
| 400 | {
|
|---|
| 401 | *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel " << fPixId << endl;
|
|---|
| 402 | return kFALSE;
|
|---|
| 403 | }
|
|---|
| 404 | return kTRUE;
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | //
|
|---|
| 408 | // The check returns kTRUE if:
|
|---|
| 409 | //
|
|---|
| 410 | // The mean arrival time is at least 1.0 slices from the used edge slices
|
|---|
| 411 | //
|
|---|
| 412 | Bool_t MCalibrationPix::CheckTimeFitValidity()
|
|---|
| 413 | {
|
|---|
| 414 |
|
|---|
| 415 | Float_t lowerrange;
|
|---|
| 416 | Float_t upperrange;
|
|---|
| 417 |
|
|---|
| 418 | if (fHiGainSaturation)
|
|---|
| 419 | {
|
|---|
| 420 | lowerrange = (Float_t)fHist->GetTimeLowerFitRangeLoGain()+1.;
|
|---|
| 421 | upperrange = (Float_t)fHist->GetTimeUpperFitRangeLoGain()+1.;
|
|---|
| 422 | }
|
|---|
| 423 | else
|
|---|
| 424 | {
|
|---|
| 425 | lowerrange = (Float_t)fHist->GetTimeLowerFitRangeHiGain()+1.;
|
|---|
| 426 | upperrange = (Float_t)fHist->GetTimeUpperFitRangeHiGain()+1.;
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 | if (fTime < lowerrange)
|
|---|
| 431 | {
|
|---|
| 432 | *fLog << warn
|
|---|
| 433 | << "WARNING: Mean Fitted Time inside or smaller than first used FADC slice in Pixel "
|
|---|
| 434 | << fPixId << " time: " << fTime << " Range: " << lowerrange << endl;
|
|---|
| 435 | return kFALSE;
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | if (fTime > upperrange)
|
|---|
| 439 | {
|
|---|
| 440 | *fLog << warn
|
|---|
| 441 | << "WARNING: Mean Fitted Time inside or greater than last used FADC slice in Pixel "
|
|---|
| 442 | << fPixId << " time: " << fTime << " Range: " << upperrange << endl;
|
|---|
| 443 | return kFALSE;
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | return kTRUE;
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 |
|
|---|
| 450 | //
|
|---|
| 451 | // The check returns kTRUE if:
|
|---|
| 452 | //
|
|---|
| 453 | //
|
|---|
| 454 | //
|
|---|
| 455 | Bool_t MCalibrationPix::CheckOscillations()
|
|---|
| 456 | {
|
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 | return kTRUE;
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 | void MCalibrationPix::ApplyLoGainConversion()
|
|---|
| 465 | {
|
|---|
| 466 |
|
|---|
| 467 | const Float_t chargeRelErrSquare = fErrCharge*fErrCharge
|
|---|
| 468 | /( fCharge * fCharge);
|
|---|
| 469 | const Float_t sigmaRelErrSquare = fErrSigmaCharge*fErrSigmaCharge
|
|---|
| 470 | /( fSigmaCharge * fSigmaCharge);
|
|---|
| 471 | const Float_t conversionRelErrSquare = fConversionHiLoError*fConversionHiLoError
|
|---|
| 472 | /(fConversionHiLo * fConversionHiLo);
|
|---|
| 473 |
|
|---|
| 474 | fCharge *= fConversionHiLo;
|
|---|
| 475 | fErrCharge = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fCharge;
|
|---|
| 476 |
|
|---|
| 477 | fSigmaCharge *= fConversionHiLo;
|
|---|
| 478 | fErrSigmaCharge = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fSigmaCharge;
|
|---|
| 479 |
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 | // --------------------------------------------------------------------------
|
|---|
| 484 | //
|
|---|
| 485 | // Set the pedestals from outside
|
|---|
| 486 | //
|
|---|
| 487 | void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
|
|---|
| 488 | {
|
|---|
| 489 |
|
|---|
| 490 | fPed = ped;
|
|---|
| 491 | fPedRms = pedrms;
|
|---|
| 492 |
|
|---|
| 493 | }
|
|---|
| 494 |
|
|---|
| 495 | // --------------------------------------------------------------------------
|
|---|
| 496 | //
|
|---|
| 497 | // 1) Fit the arrival times
|
|---|
| 498 | // 2) Retrieve the results
|
|---|
| 499 | // 3) Note that because of the low number of bins, the NDf is sometimes 0, so
|
|---|
| 500 | // Root does not give a reasonable Probability, the Chisquare is more significant
|
|---|
| 501 | //
|
|---|
| 502 | // This fit has to be done AFTER the Charges fit,
|
|---|
| 503 | // otherwise only the Hi Gain will be fitted, even if there are no entries
|
|---|
| 504 | //
|
|---|
| 505 | //
|
|---|
| 506 | Bool_t MCalibrationPix::FitTime()
|
|---|
| 507 | {
|
|---|
| 508 |
|
|---|
| 509 | //
|
|---|
| 510 | // Fit the Low Gain
|
|---|
| 511 | //
|
|---|
| 512 | if (fHiGainSaturation)
|
|---|
| 513 | {
|
|---|
| 514 | if(!fHist->FitTimeLoGain())
|
|---|
| 515 | {
|
|---|
| 516 | *fLog << warn << "WARNING: Could not fit Lo Gain times of pixel " << fPixId << endl;
|
|---|
| 517 | // fHist->PrintTimeFitResult();
|
|---|
| 518 | return kFALSE;
|
|---|
| 519 | }
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 | //
|
|---|
| 523 | // Fit the High Gain
|
|---|
| 524 | //
|
|---|
| 525 | else
|
|---|
| 526 | {
|
|---|
| 527 | if(!fHist->FitTimeHiGain())
|
|---|
| 528 | {
|
|---|
| 529 | *fLog << warn << "WARNING: Could not fit Hi Gain times of pixel " << fPixId << endl;
|
|---|
| 530 | // fHist->PrintTimeFitResult();
|
|---|
| 531 | return kFALSE;
|
|---|
| 532 | }
|
|---|
| 533 | }
|
|---|
| 534 |
|
|---|
| 535 | fTime = fHist->GetTimeMean();
|
|---|
| 536 | fSigmaTime = fHist->GetTimeSigma();
|
|---|
| 537 | fTimeChiSquare = fHist->GetTimeChiSquare();
|
|---|
| 538 | fTimeProb = fHist->GetTimeProb();
|
|---|
| 539 |
|
|---|
| 540 | if (!CheckTimeFitValidity())
|
|---|
| 541 | fFitValid = kFALSE;
|
|---|
| 542 |
|
|---|
| 543 | return kTRUE;
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|