| 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 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MCalibrationChargePINDiode //
|
|---|
| 28 | // //
|
|---|
| 29 | // This is the storage container to hold informations about the pedestal //
|
|---|
| 30 | // (offset) value of one Pixel (PMT). //
|
|---|
| 31 | // //
|
|---|
| 32 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 | #include "MCalibrationChargePINDiode.h"
|
|---|
| 34 |
|
|---|
| 35 | #include "MLog.h"
|
|---|
| 36 | #include "MLogManip.h"
|
|---|
| 37 |
|
|---|
| 38 | ClassImp(MCalibrationChargePINDiode);
|
|---|
| 39 |
|
|---|
| 40 | using namespace std;
|
|---|
| 41 |
|
|---|
| 42 | const Float_t MCalibrationChargePINDiode::fgChargeLimit = 3.;
|
|---|
| 43 | const Float_t MCalibrationChargePINDiode::fgChargeErrLimit = 0.;
|
|---|
| 44 | const Float_t MCalibrationChargePINDiode::fgChargeRelErrLimit = 1.;
|
|---|
| 45 |
|
|---|
| 46 | const Float_t MCalibrationChargePINDiode::fgConversionChargePhotons = -1.;
|
|---|
| 47 | const Float_t MCalibrationChargePINDiode::fgConversionChargePhotonsErr = -1.;
|
|---|
| 48 | //
|
|---|
| 49 | // Area of Inner Pixel w.r.t. PIN Diode (which is 1 cm2)
|
|---|
| 50 | //
|
|---|
| 51 | // Distance of PIN Diode to pulser D1: 1.5 +- 0.3 m
|
|---|
| 52 | // Distance of Inner Pixel to pulser D2: 18.0 +- 0.5 m
|
|---|
| 53 | //
|
|---|
| 54 | //
|
|---|
| 55 | // D1*D1
|
|---|
| 56 | // conversion C = ------ = 0.0069
|
|---|
| 57 | // D2*D2
|
|---|
| 58 | //
|
|---|
| 59 | // Delta C / C = 2 * Sqrt( (Delta D1/D1)2 + (Delta D2/D2)2 )
|
|---|
| 60 | // Delta C / C = 0.4
|
|---|
| 61 | //
|
|---|
| 62 | // C = 0.007 +- 0.003
|
|---|
| 63 | //
|
|---|
| 64 | const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiode = 0.007;
|
|---|
| 65 | const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiodeErr = 0.003;
|
|---|
| 66 | //
|
|---|
| 67 | // Average QE of the PIN Diode
|
|---|
| 68 | //
|
|---|
| 69 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreen = -1.0;
|
|---|
| 70 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlue = -1.0;
|
|---|
| 71 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUV = -1.0;
|
|---|
| 72 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1 = -1.0;
|
|---|
| 73 | //
|
|---|
| 74 | // Average QE of the PIN Diode
|
|---|
| 75 | //
|
|---|
| 76 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreenErr = -1.0;
|
|---|
| 77 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlueErr = -1.0;
|
|---|
| 78 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUVErr = -1.0;
|
|---|
| 79 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1Err = -1.0;
|
|---|
| 80 |
|
|---|
| 81 | const Float_t MCalibrationChargePINDiode::gkPINDiodeArea = 100;
|
|---|
| 82 | // --------------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Default Constructor.
|
|---|
| 85 | //
|
|---|
| 86 | MCalibrationChargePINDiode::MCalibrationChargePINDiode(const char *name, const char *title)
|
|---|
| 87 | : fCalibFlags(0)
|
|---|
| 88 | {
|
|---|
| 89 |
|
|---|
| 90 | fName = name ? name : "MCalibrationChargePINDiode";
|
|---|
| 91 | fTitle = title ? title : "Container of the fit results of MHCalibrationChargePINDiode";
|
|---|
| 92 |
|
|---|
| 93 | Clear();
|
|---|
| 94 |
|
|---|
| 95 | SetChargeLimit();
|
|---|
| 96 | SetChargeErrLimit();
|
|---|
| 97 | SetChargeRelErrLimit();
|
|---|
| 98 |
|
|---|
| 99 | SetConversionChargePhotons();
|
|---|
| 100 | SetConversionChargePhotonsErr();
|
|---|
| 101 |
|
|---|
| 102 | SetOscillating ( kFALSE );
|
|---|
| 103 | SetExcluded ( kFALSE );
|
|---|
| 104 | SetExcludeQualityCheck ( kFALSE );
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | // ------------------------------------------------------------------------
|
|---|
| 108 | //
|
|---|
| 109 | // Invalidate values
|
|---|
| 110 | //
|
|---|
| 111 | void MCalibrationChargePINDiode::Clear(Option_t *o)
|
|---|
| 112 | {
|
|---|
| 113 |
|
|---|
| 114 | SetChargeFitValid ( kFALSE );
|
|---|
| 115 | SetTimeFitValid ( kFALSE );
|
|---|
| 116 | SetMeanTimeInFirstBin ( kFALSE );
|
|---|
| 117 | SetMeanTimeInLastBin ( kFALSE );
|
|---|
| 118 |
|
|---|
| 119 | fPed = -1.;
|
|---|
| 120 | fPedRms = -1.;
|
|---|
| 121 |
|
|---|
| 122 | fRmsChargeMean = -1.;
|
|---|
| 123 | fRmsChargeMeanErr = -1.;
|
|---|
| 124 | fRmsChargeSigma = -1.;
|
|---|
| 125 | fRmsChargeSigmaErr = -1.;
|
|---|
| 126 |
|
|---|
| 127 | fAbsTimeMean = -1.;
|
|---|
| 128 | fAbsTimeRms = -1.;
|
|---|
| 129 |
|
|---|
| 130 | fTimeLowerEdge = -1.;
|
|---|
| 131 | fTimeUpperEdge = -1.;
|
|---|
| 132 |
|
|---|
| 133 | fConvertedPhotons = -1.;
|
|---|
| 134 | fConvertedPhotonsErr = -1.;
|
|---|
| 135 |
|
|---|
| 136 | fMeanFluxOutsidePlexiglass = -1.;
|
|---|
| 137 | fMeanFluxErrOutsidePlexiglass = -1.;
|
|---|
| 138 |
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 | // --------------------------------------------------------------------------
|
|---|
| 143 | //
|
|---|
| 144 | // Set the pedestals from outside
|
|---|
| 145 | //
|
|---|
| 146 | void MCalibrationChargePINDiode::SetPedestal(Float_t ped, Float_t pedrms)
|
|---|
| 147 | {
|
|---|
| 148 |
|
|---|
| 149 | fPed = ped;
|
|---|
| 150 | fPedRms = pedrms;
|
|---|
| 151 |
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | // --------------------------------------------------------------------------
|
|---|
| 155 | //
|
|---|
| 156 | // Set the Oscillating Bit from outside
|
|---|
| 157 | //
|
|---|
| 158 | void MCalibrationChargePINDiode::SetOscillating( const Bool_t b)
|
|---|
| 159 | {
|
|---|
| 160 | b ? SETBIT(fCalibFlags,kOscillating) : CLRBIT(fCalibFlags,kOscillating);
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 | // --------------------------------------------------------------------------
|
|---|
| 165 | //
|
|---|
| 166 | // Set the Excluded Bit from outside
|
|---|
| 167 | //
|
|---|
| 168 | void MCalibrationChargePINDiode::SetExcludeQualityCheck(Bool_t b )
|
|---|
| 169 | {
|
|---|
| 170 | b ? SETBIT(fCalibFlags, kExcludeQualityCheck) : CLRBIT(fCalibFlags, kExcludeQualityCheck);
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | // --------------------------------------------------------------------------
|
|---|
| 174 | //
|
|---|
| 175 | // Set the Excluded Bit from outside
|
|---|
| 176 | //
|
|---|
| 177 | void MCalibrationChargePINDiode::SetChargeFitValid(Bool_t b )
|
|---|
| 178 | {
|
|---|
| 179 | b ? SETBIT(fCalibFlags, kChargeFitValid) : CLRBIT(fCalibFlags, kChargeFitValid);
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | // --------------------------------------------------------------------------
|
|---|
| 183 | //
|
|---|
| 184 | // Set the Excluded Bit from outside
|
|---|
| 185 | //
|
|---|
| 186 | void MCalibrationChargePINDiode::SetTimeFitValid(Bool_t b )
|
|---|
| 187 | {
|
|---|
| 188 | b ? SETBIT(fCalibFlags, kTimeFitValid) : CLRBIT(fCalibFlags, kTimeFitValid);
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | void MCalibrationChargePINDiode::SetFluxOutsidePlexiglassAvailable (const Bool_t b)
|
|---|
| 192 | {
|
|---|
| 193 | b ? SETBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable) : CLRBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable);
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | void MCalibrationChargePINDiode::SetMeanTimeInFirstBin(const Bool_t b)
|
|---|
| 197 | {
|
|---|
| 198 | b ? SETBIT(fCalibFlags,kMeanTimeInFirstBin) : CLRBIT(fCalibFlags,kMeanTimeInFirstBin);
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | void MCalibrationChargePINDiode::SetMeanTimeInLastBin(const Bool_t b)
|
|---|
| 202 | {
|
|---|
| 203 | b ? SETBIT(fCalibFlags,kMeanTimeInLastBin) : CLRBIT(fCalibFlags,kMeanTimeInLastBin);
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | Bool_t MCalibrationChargePINDiode::IsMeanTimeInFirstBin() const
|
|---|
| 207 | {
|
|---|
| 208 | return TESTBIT(fCalibFlags,kMeanTimeInFirstBin);
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | Bool_t MCalibrationChargePINDiode::IsMeanTimeInLastBin() const
|
|---|
| 212 | {
|
|---|
| 213 | return TESTBIT(fCalibFlags,kMeanTimeInLastBin);
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | Bool_t MCalibrationChargePINDiode::IsChargeFitValid() const
|
|---|
| 217 | {
|
|---|
| 218 | return TESTBIT(fCalibFlags, kChargeFitValid);
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | Bool_t MCalibrationChargePINDiode::IsTimeFitValid() const
|
|---|
| 222 | {
|
|---|
| 223 | return TESTBIT(fCalibFlags, kTimeFitValid);
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | //
|
|---|
| 227 | // The check return kTRUE if:
|
|---|
| 228 | //
|
|---|
| 229 | // 1) PINDiode has a fitted charge greater than fChargeLimit*PedRMS
|
|---|
| 230 | // 2) PINDiode has a fit error greater than fChargeErrLimit
|
|---|
| 231 | // 3) PINDiode has a fitted charge greater its fChargeRelErrLimit times its charge error
|
|---|
| 232 | // 4) PINDiode has a charge sigma bigger than its Pedestal RMS
|
|---|
| 233 | //
|
|---|
| 234 | Bool_t MCalibrationChargePINDiode::CheckChargeFitValidity()
|
|---|
| 235 | {
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 | if (GetMean() < fChargeLimit*GetPedRms())
|
|---|
| 239 | {
|
|---|
| 240 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
|---|
| 241 | << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
|
|---|
| 242 | return kFALSE;
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | if (GetMeanErr() < fChargeErrLimit)
|
|---|
| 246 | {
|
|---|
| 247 | *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
|
|---|
| 248 | << fChargeErrLimit << " in PINDiode " << endl;
|
|---|
| 249 | return kFALSE;
|
|---|
| 250 | }
|
|---|
| 251 |
|
|---|
| 252 | if (GetMean() < fChargeRelErrLimit*GetMeanErr())
|
|---|
| 253 | {
|
|---|
| 254 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
|---|
| 255 | << fChargeRelErrLimit << "* its error in PINDiode " << endl;
|
|---|
| 256 | return kFALSE;
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | if (GetSigma() < GetPedRms())
|
|---|
| 260 | {
|
|---|
| 261 | *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
|
|---|
| 262 | return kFALSE;
|
|---|
| 263 | }
|
|---|
| 264 | return kTRUE;
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | //
|
|---|
| 268 | // The check returns kTRUE if:
|
|---|
| 269 | //
|
|---|
| 270 | // The mean arrival time is at least 1.0 slices from the used edge slices
|
|---|
| 271 | //
|
|---|
| 272 | Bool_t MCalibrationChargePINDiode::CheckTimeFitValidity()
|
|---|
| 273 | {
|
|---|
| 274 |
|
|---|
| 275 | if ( fAbsTimeMean < fTimeLowerEdge+1.)
|
|---|
| 276 | {
|
|---|
| 277 | *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the PINDiode " << endl;
|
|---|
| 278 | SetMeanTimeInFirstBin();
|
|---|
| 279 | return kFALSE;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | if ( fAbsTimeMean > fTimeUpperEdge-1.)
|
|---|
| 283 | {
|
|---|
| 284 | *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the PINDiode " << endl;
|
|---|
| 285 | SetMeanTimeInLastBin();
|
|---|
| 286 | return kFALSE;
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | return kTRUE;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
|
|---|
| 293 | {
|
|---|
| 294 |
|
|---|
| 295 | if (IsChargeFitValid())
|
|---|
| 296 | return kFALSE;
|
|---|
| 297 |
|
|---|
| 298 | // Start calculation of number of photons per mm^2 on the camera
|
|---|
| 299 | fMeanFluxOutsidePlexiglass = fConvertedPhotons * gkPINDiodeArea;
|
|---|
| 300 | // Correct for the distance between camera and PIN Diode and for different areas.
|
|---|
| 301 | fMeanFluxOutsidePlexiglass *= gkFluxCameravsPINDiode;
|
|---|
| 302 |
|
|---|
| 303 | // Start calculation of number of photons relative Variance (!!)
|
|---|
| 304 | fMeanFluxErrOutsidePlexiglass = fConvertedPhotonsErr * fConvertedPhotonsErr
|
|---|
| 305 | / fConvertedPhotons / fConvertedPhotons ;
|
|---|
| 306 | fMeanFluxErrOutsidePlexiglass += gkFluxCameravsPINDiodeErr*gkFluxCameravsPINDiodeErr
|
|---|
| 307 | / gkFluxCameravsPINDiode/gkFluxCameravsPINDiode;
|
|---|
| 308 |
|
|---|
| 309 | switch (fColor)
|
|---|
| 310 | {
|
|---|
| 311 | case kGREEN:
|
|---|
| 312 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQEGreen;
|
|---|
| 313 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEGreenErr*gkPINDiodeQEGreenErr
|
|---|
| 314 | / gkPINDiodeQEGreen/gkPINDiodeQEGreen;
|
|---|
| 315 | break;
|
|---|
| 316 | case kBLUE:
|
|---|
| 317 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQEBlue;
|
|---|
| 318 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEBlueErr*gkPINDiodeQEBlueErr
|
|---|
| 319 | / gkPINDiodeQEBlue/gkPINDiodeQEBlue;
|
|---|
| 320 | break;
|
|---|
| 321 | case kUV:
|
|---|
| 322 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQEUV;
|
|---|
| 323 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEUVErr*gkPINDiodeQEUVErr
|
|---|
| 324 | / gkPINDiodeQEUV/gkPINDiodeQEUV;
|
|---|
| 325 | break;
|
|---|
| 326 | case kCT1:
|
|---|
| 327 | default:
|
|---|
| 328 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQECT1;
|
|---|
| 329 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQECT1Err*gkPINDiodeQECT1Err
|
|---|
| 330 | / gkPINDiodeQECT1/gkPINDiodeQECT1;
|
|---|
| 331 | break;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 | *fLog << inf << endl;
|
|---|
| 336 | *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: "
|
|---|
| 337 | << fMeanFluxOutsidePlexiglass << endl;
|
|---|
| 338 |
|
|---|
| 339 | if (fMeanFluxOutsidePlexiglass < 0.)
|
|---|
| 340 | return kFALSE;
|
|---|
| 341 |
|
|---|
| 342 | if (fMeanFluxErrOutsidePlexiglass < 0.)
|
|---|
| 343 | return kFALSE;
|
|---|
| 344 |
|
|---|
| 345 | SetFluxOutsidePlexiglassAvailable();
|
|---|
| 346 |
|
|---|
| 347 | // Finish calculation of errors -> convert from relative variance to absolute error
|
|---|
| 348 | fMeanFluxErrOutsidePlexiglass = TMath::Sqrt(fMeanFluxErrOutsidePlexiglass);
|
|---|
| 349 | fMeanFluxErrOutsidePlexiglass *= fMeanFluxOutsidePlexiglass;
|
|---|
| 350 |
|
|---|
| 351 | *fLog << inf << " Error on Photon flux [ph/mm^2] outside Plexiglass: "
|
|---|
| 352 | << fMeanFluxErrOutsidePlexiglass << endl;
|
|---|
| 353 | *fLog << inf << endl;
|
|---|
| 354 |
|
|---|
| 355 | return kTRUE;
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 |
|
|---|