| 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 | !
|
|---|
| 19 | ! Author(s): Markus Gaug 11/2003 <mailto:markus@ifae.es>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MCalibrationCam
|
|---|
| 29 | //
|
|---|
| 30 | // Hold the whole Calibration results of the camera:
|
|---|
| 31 | //
|
|---|
| 32 | // 1) MCalibrationCam initializes a TClonesArray whose elements are
|
|---|
| 33 | // pointers to MCalibrationPix Containers
|
|---|
| 34 | // 2) It initializes a pointer to an MCalibrationBlindPix container
|
|---|
| 35 | // 3) It initializes a pointer to an MCalibrationPINDiode container
|
|---|
| 36 | //
|
|---|
| 37 | // 4)
|
|---|
| 38 | //
|
|---|
| 39 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 40 | #include "MCalibrationCam.h"
|
|---|
| 41 |
|
|---|
| 42 | #include <TH2.h>
|
|---|
| 43 | #include <TCanvas.h>
|
|---|
| 44 | #include <TClonesArray.h>
|
|---|
| 45 |
|
|---|
| 46 | #include "MLog.h"
|
|---|
| 47 | #include "MLogManip.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MGeomCam.h"
|
|---|
| 50 |
|
|---|
| 51 | #include "MCalibrationPix.h"
|
|---|
| 52 | #include "MCalibrationConfig.h"
|
|---|
| 53 | #include "MCalibrationBlindPix.h"
|
|---|
| 54 | #include "MCalibrationPINDiode.h"
|
|---|
| 55 |
|
|---|
| 56 | #include "MHCalibrationPixel.h"
|
|---|
| 57 |
|
|---|
| 58 | ClassImp(MCalibrationCam);
|
|---|
| 59 |
|
|---|
| 60 | using namespace std;
|
|---|
| 61 |
|
|---|
| 62 | const Int_t MCalibrationCam::gkBlindPixelId = 559;
|
|---|
| 63 | const Int_t MCalibrationCam::gkPINDiodeId = 9999;
|
|---|
| 64 | const Float_t MCalibrationCam::gkTimeSliceWidth = 3.3;
|
|---|
| 65 |
|
|---|
| 66 | // --------------------------------------------------------------------------
|
|---|
| 67 | //
|
|---|
| 68 | // Default constructor.
|
|---|
| 69 | //
|
|---|
| 70 | // Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry
|
|---|
| 71 | // Later, a call to MCalibrationCam::InitSize(Int_t size) has to be performed
|
|---|
| 72 | //
|
|---|
| 73 | // Creates an MCalibrationBlindPix container
|
|---|
| 74 | // Creates an MCalibrationPINDiode container
|
|---|
| 75 | //
|
|---|
| 76 | MCalibrationCam::MCalibrationCam(const char *name, const char *title)
|
|---|
| 77 | : fOffsets(NULL),
|
|---|
| 78 | fSlopes(NULL),
|
|---|
| 79 | fOffvsSlope(NULL)
|
|---|
| 80 | {
|
|---|
| 81 | fName = name ? name : "MCalibrationCam";
|
|---|
| 82 | fTitle = title ? title : "Storage container for the Calibration Information in the camera";
|
|---|
| 83 |
|
|---|
| 84 | fPixels = new TClonesArray("MCalibrationPix",1);
|
|---|
| 85 | fBlindPixel = new MCalibrationBlindPix();
|
|---|
| 86 | fPINDiode = new MCalibrationPINDiode();
|
|---|
| 87 |
|
|---|
| 88 | Clear();
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | // --------------------------------------------------------------------------
|
|---|
| 92 | //
|
|---|
| 93 | // Delete the TClonesArray of MCalibrationPix containers
|
|---|
| 94 | // Delete the MCalibrationPINDiode and the MCalibrationBlindPix
|
|---|
| 95 | //
|
|---|
| 96 | // Delete the histograms if they exist
|
|---|
| 97 | //
|
|---|
| 98 | MCalibrationCam::~MCalibrationCam()
|
|---|
| 99 | {
|
|---|
| 100 |
|
|---|
| 101 | //
|
|---|
| 102 | // delete fPixels should delete all Objects stored inside
|
|---|
| 103 | //
|
|---|
| 104 | delete fPixels;
|
|---|
| 105 | delete fBlindPixel;
|
|---|
| 106 | delete fPINDiode;
|
|---|
| 107 |
|
|---|
| 108 | if (fOffsets)
|
|---|
| 109 | delete fOffsets;
|
|---|
| 110 | if (fSlopes)
|
|---|
| 111 | delete fSlopes;
|
|---|
| 112 | if (fOffvsSlope)
|
|---|
| 113 | delete fOffvsSlope;
|
|---|
| 114 |
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // -------------------------------------------------------------------
|
|---|
| 118 | //
|
|---|
| 119 | // This function simply allocates memory via the ROOT command:
|
|---|
| 120 | // (TObject**) TStorage::ReAlloc(fCont, newSize * sizeof(TObject*),
|
|---|
| 121 | // fSize * sizeof(TObject*));
|
|---|
| 122 | // newSize corresponds to size in our case
|
|---|
| 123 | // fSize is the old size (in most cases: 1)
|
|---|
| 124 | //
|
|---|
| 125 | void MCalibrationCam::InitSize(const UInt_t i)
|
|---|
| 126 | {
|
|---|
| 127 |
|
|---|
| 128 | //
|
|---|
| 129 | // check if we have already initialized to size
|
|---|
| 130 | //
|
|---|
| 131 | if (CheckBounds(i))
|
|---|
| 132 | return;
|
|---|
| 133 |
|
|---|
| 134 | fPixels->ExpandCreate(i);
|
|---|
| 135 |
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | // --------------------------------------------------------------------------
|
|---|
| 139 | //
|
|---|
| 140 | // This function returns the current size of the TClonesArray
|
|---|
| 141 | // independently if the MCalibrationPix is filled with values or not.
|
|---|
| 142 | //
|
|---|
| 143 | // It is the size of the array fPixels.
|
|---|
| 144 | //
|
|---|
| 145 | Int_t MCalibrationCam::GetSize() const
|
|---|
| 146 | {
|
|---|
| 147 | return fPixels->GetEntriesFast();
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | // --------------------------------------------------------------------------
|
|---|
| 151 | //
|
|---|
| 152 | // Check if position i is inside the current bounds of the TClonesArray
|
|---|
| 153 | //
|
|---|
| 154 | Bool_t MCalibrationCam::CheckBounds(Int_t i) const
|
|---|
| 155 | {
|
|---|
| 156 | return i < GetSize();
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | // --------------------------------------------------------------------------
|
|---|
| 161 | //
|
|---|
| 162 | // Get i-th pixel (pixel number)
|
|---|
| 163 | //
|
|---|
| 164 | MCalibrationPix &MCalibrationCam::operator[](Int_t i)
|
|---|
| 165 | {
|
|---|
| 166 | return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | // --------------------------------------------------------------------------
|
|---|
| 170 | //
|
|---|
| 171 | // Get i-th pixel (pixel number)
|
|---|
| 172 | //
|
|---|
| 173 | MCalibrationPix &MCalibrationCam::operator[](Int_t i) const
|
|---|
| 174 | {
|
|---|
| 175 | return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 | // --------------------------------------
|
|---|
| 180 | //
|
|---|
| 181 | void MCalibrationCam::Clear(Option_t *o)
|
|---|
| 182 | {
|
|---|
| 183 |
|
|---|
| 184 | fPixels->ForEach(TObject, Clear)();
|
|---|
| 185 | fBlindPixel->Clear();
|
|---|
| 186 | fPINDiode->Clear();
|
|---|
| 187 |
|
|---|
| 188 | fMeanPhotInsidePlexiglass = -1.;
|
|---|
| 189 | fMeanPhotErrInsidePlexiglass = -1.;
|
|---|
| 190 | fMeanPhotOutsidePlexiglass = -1.;
|
|---|
| 191 | fMeanPhotErrOutsidePlexiglass = -1.;
|
|---|
| 192 |
|
|---|
| 193 | fNumExcludedPixels = 0;
|
|---|
| 194 |
|
|---|
| 195 | CLRBIT(fFlags,kBlindPixelMethodValid);
|
|---|
| 196 | CLRBIT(fFlags,kPINDiodeMethodValid);
|
|---|
| 197 | CLRBIT(fFlags,kNumPhotInsidePlexiglassAvailable);
|
|---|
| 198 | CLRBIT(fFlags,kNumPhotOutsidePlexiglassAvailable);
|
|---|
| 199 |
|
|---|
| 200 | return;
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | void MCalibrationCam::SetBlindPixelMethodValid(const Bool_t b)
|
|---|
| 204 | {
|
|---|
| 205 |
|
|---|
| 206 | if (b)
|
|---|
| 207 | SETBIT(fFlags, kBlindPixelMethodValid);
|
|---|
| 208 | else
|
|---|
| 209 | CLRBIT(fFlags, kBlindPixelMethodValid);
|
|---|
| 210 |
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | void MCalibrationCam::SetPINDiodeMethodValid(const Bool_t b)
|
|---|
| 214 | {
|
|---|
| 215 |
|
|---|
| 216 | if (b)
|
|---|
| 217 | SETBIT(fFlags, kPINDiodeMethodValid);
|
|---|
| 218 | else
|
|---|
| 219 | CLRBIT(fFlags, kPINDiodeMethodValid);
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | Bool_t MCalibrationCam::IsBlindPixelMethodValid() const
|
|---|
| 225 | {
|
|---|
| 226 | return TESTBIT(fFlags,kBlindPixelMethodValid);
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | Bool_t MCalibrationCam::IsPINDiodeMethodValid() const
|
|---|
| 230 | {
|
|---|
| 231 | return TESTBIT(fFlags,kPINDiodeMethodValid);
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 | Bool_t MCalibrationCam::IsNumPhotInsidePlexiglassAvailable() const
|
|---|
| 236 | {
|
|---|
| 237 | return TESTBIT(fFlags,kNumPhotInsidePlexiglassAvailable);
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | Bool_t MCalibrationCam::IsNumPhotOutsidePlexiglassAvailable() const
|
|---|
| 241 | {
|
|---|
| 242 | return TESTBIT(fFlags,kNumPhotOutsidePlexiglassAvailable);
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 | // --------------------------------------------------------------------------
|
|---|
| 248 | //
|
|---|
| 249 | // Print first the well fitted pixels
|
|---|
| 250 | // and then the ones which are not FitValid
|
|---|
| 251 | //
|
|---|
| 252 | void MCalibrationCam::Print(Option_t *o) const
|
|---|
| 253 | {
|
|---|
| 254 |
|
|---|
| 255 | *fLog << all << GetDescriptor() << ":" << endl;
|
|---|
| 256 | int id = 0;
|
|---|
| 257 |
|
|---|
| 258 | *fLog << all << "Succesfully calibrated pixels:" << endl;
|
|---|
| 259 | *fLog << all << endl;
|
|---|
| 260 |
|
|---|
| 261 | TIter Next(fPixels);
|
|---|
| 262 | MCalibrationPix *pix;
|
|---|
| 263 | while ((pix=(MCalibrationPix*)Next()))
|
|---|
| 264 | {
|
|---|
| 265 |
|
|---|
| 266 | if (pix->IsChargeFitValid() && !pix->IsExcluded())
|
|---|
| 267 | {
|
|---|
| 268 |
|
|---|
| 269 | *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
|
|---|
| 270 | << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
|
|---|
| 271 | << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge()
|
|---|
| 272 | << " Nr Phe's: " << pix->GetPheFFactorMethod() << endl;
|
|---|
| 273 | id++;
|
|---|
| 274 | }
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | *fLog << all << id << " succesful pixels :-))" << endl;
|
|---|
| 278 | id = 0;
|
|---|
| 279 |
|
|---|
| 280 | *fLog << all << endl;
|
|---|
| 281 | *fLog << all << "Pixels with errors:" << endl;
|
|---|
| 282 | *fLog << all << endl;
|
|---|
| 283 |
|
|---|
| 284 | TIter Next2(fPixels);
|
|---|
| 285 | while ((pix=(MCalibrationPix*)Next2()))
|
|---|
| 286 | {
|
|---|
| 287 |
|
|---|
| 288 | if (!pix->IsChargeFitValid() && !pix->IsExcluded())
|
|---|
| 289 | {
|
|---|
| 290 |
|
|---|
| 291 | *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
|
|---|
| 292 | << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
|
|---|
| 293 | << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge() << endl;
|
|---|
| 294 | id++;
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 | *fLog << all << id << " pixels with errors :-((" << endl;
|
|---|
| 298 |
|
|---|
| 299 | *fLog << all << endl;
|
|---|
| 300 | *fLog << all << "Excluded pixels:" << endl;
|
|---|
| 301 | *fLog << all << endl;
|
|---|
| 302 |
|
|---|
| 303 | TIter Next3(fPixels);
|
|---|
| 304 | while ((pix=(MCalibrationPix*)Next3()))
|
|---|
| 305 | if (pix->IsExcluded())
|
|---|
| 306 | *fLog << all << pix->GetPixId() << endl;
|
|---|
| 307 |
|
|---|
| 308 | *fLog << all << fNumExcludedPixels << " excluded pixels " << endl;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | // --------------------------------------------------------------------------
|
|---|
| 312 | //
|
|---|
| 313 | // Return true if pixel is inside bounds of the TClonesArray fPixels
|
|---|
| 314 | //
|
|---|
| 315 | Bool_t MCalibrationCam::IsPixelUsed(Int_t idx) const
|
|---|
| 316 | {
|
|---|
| 317 | if (!CheckBounds(idx))
|
|---|
| 318 | return kFALSE;
|
|---|
| 319 |
|
|---|
| 320 | return kTRUE;
|
|---|
| 321 | }
|
|---|
| 322 |
|
|---|
| 323 | // --------------------------------------------------------------------------
|
|---|
| 324 | //
|
|---|
| 325 | // Return true if pixel has already been fitted once (independent of the result)
|
|---|
| 326 | //
|
|---|
| 327 | Bool_t MCalibrationCam::IsPixelFitted(Int_t idx) const
|
|---|
| 328 | {
|
|---|
| 329 |
|
|---|
| 330 | if (!CheckBounds(idx))
|
|---|
| 331 | return kFALSE;
|
|---|
| 332 |
|
|---|
| 333 | return (*this)[idx].IsFitted();
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | // --------------------------------------------------------------------------
|
|---|
| 337 | //
|
|---|
| 338 | // Sets the user ranges of all histograms such that
|
|---|
| 339 | // empty bins at the edges are not used. Additionally, it rebins the
|
|---|
| 340 | // histograms such that in total, 50 bins are used.
|
|---|
| 341 | //
|
|---|
| 342 | void MCalibrationCam::CutEdges()
|
|---|
| 343 | {
|
|---|
| 344 |
|
|---|
| 345 | fBlindPixel->GetHist()->CutAllEdges();
|
|---|
| 346 | fPINDiode->GetHist()->CutAllEdges();
|
|---|
| 347 |
|
|---|
| 348 | TIter Next(fPixels);
|
|---|
| 349 | MCalibrationPix *pix;
|
|---|
| 350 | while ((pix=(MCalibrationPix*)Next()))
|
|---|
| 351 | {
|
|---|
| 352 | pix->GetHist()->CutAllEdges();
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | return;
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 | // The types are as follows:
|
|---|
| 360 | //
|
|---|
| 361 | // 0: Fitted Charge
|
|---|
| 362 | // 1: Error of fitted Charge
|
|---|
| 363 | // 2: Sigma of fitted Charge
|
|---|
| 364 | // 3: Error of Sigma of fitted Charge
|
|---|
| 365 | // 4: Returned probability of Gauss fit to Charge distribution
|
|---|
| 366 | // 5: Mean arrival time
|
|---|
| 367 | // 6: Sigma of the arrival time
|
|---|
| 368 | // 7: Chi-square of the Gauss fit to the arrival times
|
|---|
| 369 | // 8: Pedestal
|
|---|
| 370 | // 9: Pedestal RMS
|
|---|
| 371 | // 10: Reduced Sigma Square
|
|---|
| 372 | // 11: Number of Photo-electrons after the F-Factor method
|
|---|
| 373 | // 12: Error on the Number of Photo-electrons after the F-Factor method
|
|---|
| 374 | // 13: Mean conversion factor after the F-Factor method
|
|---|
| 375 | // 14: Error on the conversion factor after the F-Factor method
|
|---|
| 376 | // 15: Number of Photons after the Blind Pixel method
|
|---|
| 377 | // 16: Mean conversion factor after the Blind Pixel method
|
|---|
| 378 | //
|
|---|
| 379 | Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 380 | {
|
|---|
| 381 |
|
|---|
| 382 | if (idx > GetSize())
|
|---|
| 383 | return kFALSE;
|
|---|
| 384 |
|
|---|
| 385 | if ( (!(*this)[idx].IsChargeFitValid()) || (*this)[idx].IsExcluded())
|
|---|
| 386 | return kFALSE;
|
|---|
| 387 |
|
|---|
| 388 | if (idx == gkBlindPixelId)
|
|---|
| 389 | return kFALSE;
|
|---|
| 390 |
|
|---|
| 391 | if (idx == gkPINDiodeId)
|
|---|
| 392 | return kFALSE;
|
|---|
| 393 |
|
|---|
| 394 | switch (type)
|
|---|
| 395 | {
|
|---|
| 396 | case 0:
|
|---|
| 397 | val = (*this)[idx].GetCharge();
|
|---|
| 398 | break;
|
|---|
| 399 | case 1:
|
|---|
| 400 | val = (*this)[idx].GetErrCharge();
|
|---|
| 401 | break;
|
|---|
| 402 | case 2:
|
|---|
| 403 | val = (*this)[idx].GetSigmaCharge();
|
|---|
| 404 | break;
|
|---|
| 405 | case 3:
|
|---|
| 406 | val = (*this)[idx].GetErrSigmaCharge();
|
|---|
| 407 | break;
|
|---|
| 408 | case 4:
|
|---|
| 409 | val = (*this)[idx].GetChargeProb();
|
|---|
| 410 | break;
|
|---|
| 411 | case 5:
|
|---|
| 412 | if (!(*this)[idx].IsTimeFitValid())
|
|---|
| 413 | return kFALSE;
|
|---|
| 414 | val = (*this)[idx].GetMeanTimeOffset() * gkTimeSliceWidth;
|
|---|
| 415 | break;
|
|---|
| 416 | case 6:
|
|---|
| 417 | if (!(*this)[idx].IsTimeFitValid())
|
|---|
| 418 | return kFALSE;
|
|---|
| 419 | val = (*this)[idx].GetTimingPrecision() * gkTimeSliceWidth;
|
|---|
| 420 | break;
|
|---|
| 421 | case 7:
|
|---|
| 422 | if (!(*this)[idx].IsTimeFitValid())
|
|---|
| 423 | return kFALSE;
|
|---|
| 424 | val = (*this)[idx].GetTimeProb();
|
|---|
| 425 | break;
|
|---|
| 426 | case 8:
|
|---|
| 427 | val = (*this)[idx].GetPed();
|
|---|
| 428 | break;
|
|---|
| 429 | case 9:
|
|---|
| 430 | val = (*this)[idx].GetPedRms();
|
|---|
| 431 | break;
|
|---|
| 432 | case 10:
|
|---|
| 433 | val = (*this)[idx].GetRSigmaCharge();
|
|---|
| 434 | break;
|
|---|
| 435 | case 11:
|
|---|
| 436 | val = (*this)[idx].GetPheFFactorMethod();
|
|---|
| 437 | break;
|
|---|
| 438 | case 12:
|
|---|
| 439 | val = (*this)[idx].GetPheFFactorMethodError();
|
|---|
| 440 | break;
|
|---|
| 441 | case 13:
|
|---|
| 442 | val = (*this)[idx].GetMeanConversionFFactorMethod();
|
|---|
| 443 | break;
|
|---|
| 444 | case 14:
|
|---|
| 445 | val = (*this)[idx].GetErrorConversionFFactorMethod();
|
|---|
| 446 | break;
|
|---|
| 447 | case 15:
|
|---|
| 448 | if (idx < 397)
|
|---|
| 449 | val = (double)fMeanPhotInsidePlexiglass;
|
|---|
| 450 | else
|
|---|
| 451 | val = (double)fMeanPhotInsidePlexiglass*gkCalibrationOutervsInnerPixelArea;
|
|---|
| 452 | break;
|
|---|
| 453 | case 16:
|
|---|
| 454 | if (idx < 397)
|
|---|
| 455 | val = (*this)[idx].GetMeanConversionBlindPixelMethod();
|
|---|
| 456 | else
|
|---|
| 457 | val = (*this)[idx].GetMeanConversionBlindPixelMethod()*gkCalibrationOutervsInnerPixelArea;
|
|---|
| 458 | break;
|
|---|
| 459 | case 17:
|
|---|
| 460 | val = (*this)[idx].GetRSigmaCharge() / (*this)[idx].GetCharge();
|
|---|
| 461 | break;
|
|---|
| 462 | case 18:
|
|---|
| 463 | if (!(*this)[idx].IsTimeFitValid())
|
|---|
| 464 | return kFALSE;
|
|---|
| 465 | val = (*this)[idx].GetAbsTimeMean();
|
|---|
| 466 | break;
|
|---|
| 467 | case 19:
|
|---|
| 468 | if (!(*this)[idx].IsTimeFitValid())
|
|---|
| 469 | return kFALSE;
|
|---|
| 470 | val = (*this)[idx].GetAbsTimeMeanErr();
|
|---|
| 471 | break;
|
|---|
| 472 | case 20:
|
|---|
| 473 | if (!(*this)[idx].IsTimeFitValid())
|
|---|
| 474 | return kFALSE;
|
|---|
| 475 | val = (*this)[idx].GetAbsTimeRms();
|
|---|
| 476 | break;
|
|---|
| 477 | case 21:
|
|---|
| 478 | if (!(*this)[idx].IsTimeFitValid())
|
|---|
| 479 | return kFALSE;
|
|---|
| 480 | val = (*this)[idx].GetAbsTimeMeanErr()/TMath::Sqrt(2.);
|
|---|
| 481 | break;
|
|---|
| 482 | default:
|
|---|
| 483 | return kFALSE;
|
|---|
| 484 | }
|
|---|
| 485 | return val!=-1.;
|
|---|
| 486 | }
|
|---|
| 487 |
|
|---|
| 488 | // --------------------------------------------------------------------------
|
|---|
| 489 | //
|
|---|
| 490 | // What MHCamera needs in order to draw an individual pixel in the camera
|
|---|
| 491 | //
|
|---|
| 492 | void MCalibrationCam::DrawPixelContent(Int_t idx) const
|
|---|
| 493 | {
|
|---|
| 494 | (*this)[idx].Draw();
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 | // --------------------------------------------------------------------------
|
|---|
| 499 | //
|
|---|
| 500 | //
|
|---|
| 501 | //
|
|---|
| 502 | Bool_t MCalibrationCam::CalcNumPhotInsidePlexiglass()
|
|---|
| 503 | {
|
|---|
| 504 |
|
|---|
| 505 | if (!fBlindPixel->IsFitOK())
|
|---|
| 506 | return kFALSE;
|
|---|
| 507 |
|
|---|
| 508 | const Float_t mean = fBlindPixel->GetLambda();
|
|---|
| 509 | const Float_t merr = fBlindPixel->GetErrLambda();
|
|---|
| 510 |
|
|---|
| 511 | switch (fColor)
|
|---|
| 512 | {
|
|---|
| 513 | case kECGreen:
|
|---|
| 514 | fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQEGreen) // real photons
|
|---|
| 515 | *TMath::Power(10,gkCalibrationBlindPixelAttGreen) // correct for absorption
|
|---|
| 516 | * gkCalibrationInnerPixelArea; // correct for area
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 | break;
|
|---|
| 520 | case kECBlue:
|
|---|
| 521 | fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQEBlue )
|
|---|
| 522 | *TMath::Power(10,gkCalibrationBlindPixelAttBlue)
|
|---|
| 523 | * gkCalibrationInnerPixelArea;
|
|---|
| 524 | break;
|
|---|
| 525 | case kECUV:
|
|---|
| 526 | fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQEUV )
|
|---|
| 527 | *TMath::Power(10,gkCalibrationBlindPixelAttUV)
|
|---|
| 528 | * gkCalibrationInnerPixelArea;
|
|---|
| 529 | break;
|
|---|
| 530 | case kECCT1:
|
|---|
| 531 | default:
|
|---|
| 532 | fMeanPhotInsidePlexiglass = (mean / gkCalibrationBlindPixelQECT1 )
|
|---|
| 533 | *TMath::Power(10,gkCalibrationBlindPixelAttCT1)
|
|---|
| 534 | * gkCalibrationInnerPixelArea;
|
|---|
| 535 | break;
|
|---|
| 536 | }
|
|---|
| 537 |
|
|---|
| 538 | SETBIT(fFlags,kNumPhotInsidePlexiglassAvailable);
|
|---|
| 539 |
|
|---|
| 540 | *fLog << inf << endl;
|
|---|
| 541 | *fLog << inf << "Mean number of Photons for an Inner Pixel (inside Plexiglass): "
|
|---|
| 542 | << fMeanPhotInsidePlexiglass << endl;
|
|---|
| 543 |
|
|---|
| 544 | TIter Next(fPixels);
|
|---|
| 545 | MCalibrationPix *pix;
|
|---|
| 546 | while ((pix=(MCalibrationPix*)Next()))
|
|---|
| 547 | {
|
|---|
| 548 | if((pix->GetCharge() > 0.) && (fMeanPhotInsidePlexiglass > 0.))
|
|---|
| 549 | {
|
|---|
| 550 |
|
|---|
| 551 | Float_t conversion = fMeanPhotInsidePlexiglass/pix->GetCharge();
|
|---|
| 552 | Float_t conversionerr = 0.;
|
|---|
| 553 | Float_t conversionsigma = 0.;
|
|---|
| 554 | pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
|
|---|
| 555 |
|
|---|
| 556 | if (conversionerr/conversion < 0.1)
|
|---|
| 557 | pix->SetBlindPixelMethodValid();
|
|---|
| 558 | }
|
|---|
| 559 | }
|
|---|
| 560 | return kTRUE;
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 |
|
|---|
| 564 | Bool_t MCalibrationCam::CalcNumPhotOutsidePlexiglass()
|
|---|
| 565 | {
|
|---|
| 566 |
|
|---|
| 567 | if (!fPINDiode->IsChargeFitValid())
|
|---|
| 568 | return kFALSE;
|
|---|
| 569 |
|
|---|
| 570 | const Float_t mean = fPINDiode->GetCharge();
|
|---|
| 571 | const Float_t merr = fPINDiode->GetErrCharge();
|
|---|
| 572 |
|
|---|
| 573 | switch (fColor)
|
|---|
| 574 | {
|
|---|
| 575 | case kECGreen:
|
|---|
| 576 | fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQEGreen) // real photons
|
|---|
| 577 | * gkCalibrationInnerPixelvsPINDiodeArea; // correct for area
|
|---|
| 578 | break;
|
|---|
| 579 | case kECBlue:
|
|---|
| 580 | fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQEBlue )
|
|---|
| 581 | * gkCalibrationInnerPixelvsPINDiodeArea;
|
|---|
| 582 | break;
|
|---|
| 583 | case kECUV:
|
|---|
| 584 | fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQEUV )
|
|---|
| 585 | * gkCalibrationInnerPixelvsPINDiodeArea;
|
|---|
| 586 | break;
|
|---|
| 587 | case kECCT1:
|
|---|
| 588 | default:
|
|---|
| 589 | fMeanPhotOutsidePlexiglass = (mean / gkCalibrationPINDiodeQECT1 )
|
|---|
| 590 | * gkCalibrationInnerPixelvsPINDiodeArea;
|
|---|
| 591 | break;
|
|---|
| 592 | }
|
|---|
| 593 |
|
|---|
| 594 | SETBIT(fFlags,kNumPhotOutsidePlexiglassAvailable);
|
|---|
| 595 |
|
|---|
| 596 | *fLog << inf << endl;
|
|---|
| 597 | *fLog << inf << mean << " Mean number of Photons for an Inner Pixel (outside Plexiglass): "
|
|---|
| 598 | << fMeanPhotOutsidePlexiglass << endl;
|
|---|
| 599 | *fLog << inf << endl;
|
|---|
| 600 |
|
|---|
| 601 | TIter Next(fPixels);
|
|---|
| 602 | MCalibrationPix *pix;
|
|---|
| 603 | while ((pix=(MCalibrationPix*)Next()))
|
|---|
| 604 | {
|
|---|
| 605 |
|
|---|
| 606 | if((pix->GetCharge() > 0.) && (fMeanPhotInsidePlexiglass > 0.))
|
|---|
| 607 | pix->SetConversionPINDiodeMethod(fMeanPhotOutsidePlexiglass/pix->GetCharge(), 0., 0.);
|
|---|
| 608 | }
|
|---|
| 609 | return kTRUE;
|
|---|
| 610 | }
|
|---|
| 611 |
|
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 | Bool_t MCalibrationCam::GetConversionFactorBlindPixel(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
|
|---|
| 615 | {
|
|---|
| 616 |
|
|---|
| 617 | if (ipx < 0 || !IsPixelFitted(ipx))
|
|---|
| 618 | return kFALSE;
|
|---|
| 619 |
|
|---|
| 620 | if (!IsNumPhotInsidePlexiglassAvailable())
|
|---|
| 621 | if (!CalcNumPhotInsidePlexiglass())
|
|---|
| 622 | return kFALSE;
|
|---|
| 623 |
|
|---|
| 624 | mean = (*this)[ipx].GetMeanConversionBlindPixelMethod();
|
|---|
| 625 | err = (*this)[ipx].GetErrorConversionBlindPixelMethod();
|
|---|
| 626 | sigma = (*this)[ipx].GetSigmaConversionBlindPixelMethod();
|
|---|
| 627 |
|
|---|
| 628 | return kTRUE;
|
|---|
| 629 | }
|
|---|
| 630 |
|
|---|
| 631 |
|
|---|
| 632 | Bool_t MCalibrationCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
|
|---|
| 633 | {
|
|---|
| 634 |
|
|---|
| 635 | if (ipx < 0 || !IsPixelFitted(ipx))
|
|---|
| 636 | return kFALSE;
|
|---|
| 637 |
|
|---|
| 638 | Float_t conv = (*this)[ipx].GetMeanConversionFFactorMethod();
|
|---|
| 639 |
|
|---|
| 640 | if (conv < 0.)
|
|---|
| 641 | return kFALSE;
|
|---|
| 642 |
|
|---|
| 643 | mean = conv;
|
|---|
| 644 | err = (*this)[ipx].GetErrorConversionFFactorMethod();
|
|---|
| 645 | sigma = (*this)[ipx].GetSigmaConversionFFactorMethod();
|
|---|
| 646 |
|
|---|
| 647 | return kTRUE;
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 |
|
|---|
| 651 | //-----------------------------------------------------------------------------------
|
|---|
| 652 | //
|
|---|
| 653 | // Calculates the conversion factor between the integral of FADCs slices
|
|---|
| 654 | // (as defined in the signal extractor MExtractSignal.cc)
|
|---|
| 655 | // and the number of photons reaching the plexiglass for one Inner Pixel
|
|---|
| 656 | //
|
|---|
| 657 | // FIXME: The PINDiode is still not working and so is the code
|
|---|
| 658 | //
|
|---|
| 659 | Bool_t MCalibrationCam::GetConversionFactorPINDiode(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
|
|---|
| 660 | {
|
|---|
| 661 |
|
|---|
| 662 | if (ipx < 0 || !IsPixelFitted(ipx))
|
|---|
| 663 | return kFALSE;
|
|---|
| 664 |
|
|---|
| 665 | if (!IsNumPhotOutsidePlexiglassAvailable())
|
|---|
| 666 | if (!CalcNumPhotOutsidePlexiglass())
|
|---|
| 667 | return kFALSE;
|
|---|
| 668 |
|
|---|
| 669 | mean = (*this)[ipx].GetMeanConversionPINDiodeMethod();
|
|---|
| 670 | err = (*this)[ipx].GetErrorConversionPINDiodeMethod();
|
|---|
| 671 | sigma = (*this)[ipx].GetSigmaConversionPINDiodeMethod();
|
|---|
| 672 |
|
|---|
| 673 | return kFALSE;
|
|---|
| 674 |
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | //-----------------------------------------------------------------------------------
|
|---|
| 678 | //
|
|---|
| 679 | // Calculates the best combination of the three used methods possible
|
|---|
| 680 | // between the integral of FADCs slices
|
|---|
| 681 | // (as defined in the signal extractor MExtractSignal.cc)
|
|---|
| 682 | // and the number of photons reaching one Inner Pixel.
|
|---|
| 683 | // The procedure is not yet defined.
|
|---|
| 684 | //
|
|---|
| 685 | // FIXME: The PINDiode is still not working and so is the code
|
|---|
| 686 | //
|
|---|
| 687 | Bool_t MCalibrationCam::GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
|
|---|
| 688 | {
|
|---|
| 689 |
|
|---|
| 690 | if (ipx < 0 || !IsPixelFitted(ipx))
|
|---|
| 691 | return kFALSE;
|
|---|
| 692 |
|
|---|
| 693 | return kFALSE;
|
|---|
| 694 |
|
|---|
| 695 | }
|
|---|
| 696 |
|
|---|
| 697 |
|
|---|
| 698 | void MCalibrationCam::DrawHiLoFits()
|
|---|
| 699 | {
|
|---|
| 700 |
|
|---|
| 701 | if (!fOffsets)
|
|---|
| 702 | fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
|
|---|
| 703 | if (!fSlopes)
|
|---|
| 704 | fSlopes = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
|
|---|
| 705 | if (!fOffvsSlope)
|
|---|
| 706 | fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
|
|---|
| 707 |
|
|---|
| 708 | TIter Next(fPixels);
|
|---|
| 709 | MCalibrationPix *pix;
|
|---|
| 710 | MHCalibrationPixel *hist;
|
|---|
| 711 | while ((pix=(MCalibrationPix*)Next()))
|
|---|
| 712 | {
|
|---|
| 713 | hist = pix->GetHist();
|
|---|
| 714 | hist->FitHiGainvsLoGain();
|
|---|
| 715 | fOffsets->Fill(hist->GetOffset(),1.);
|
|---|
| 716 | fSlopes->Fill(hist->GetSlope(),1.);
|
|---|
| 717 | fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
|
|---|
| 718 | }
|
|---|
| 719 |
|
|---|
| 720 | TCanvas *c1 = new TCanvas();
|
|---|
| 721 |
|
|---|
| 722 | c1->Divide(1,3);
|
|---|
| 723 | c1->cd(1);
|
|---|
| 724 | fOffsets->Draw();
|
|---|
| 725 | gPad->Modified();
|
|---|
| 726 | gPad->Update();
|
|---|
| 727 |
|
|---|
| 728 | c1->cd(2);
|
|---|
| 729 | fSlopes->Draw();
|
|---|
| 730 | gPad->Modified();
|
|---|
| 731 | gPad->Update();
|
|---|
| 732 |
|
|---|
| 733 | c1->cd(3);
|
|---|
| 734 | fOffvsSlope->Draw("col1");
|
|---|
| 735 | gPad->Modified();
|
|---|
| 736 | gPad->Update();
|
|---|
| 737 | }
|
|---|
| 738 |
|
|---|