| 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 | // MHCalibrationTestCam
|
|---|
| 27 | //
|
|---|
| 28 | // Fills the calibrated signal from an MCerPhotEvt into
|
|---|
| 29 | // MHCalibrationTestPix for every:
|
|---|
| 30 | //
|
|---|
| 31 | // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray
|
|---|
| 32 | // or MHCalibrationCam::fHiGainArray, respectively.
|
|---|
| 33 | //
|
|---|
| 34 | // - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
|
|---|
| 35 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
|
|---|
| 36 | // MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 37 | //
|
|---|
| 38 | // - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
|
|---|
| 39 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 40 | // and MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 41 | //
|
|---|
| 42 | // The signals are filled into a histogram and an array, in order to perform
|
|---|
| 43 | // a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an
|
|---|
| 44 | // event-by-event basis and written into the corresponding average pixels.
|
|---|
| 45 | //
|
|---|
| 46 | // The histograms are fitted to a Gaussian, mean and sigma with its errors
|
|---|
| 47 | // and the fit probability are extracted. If none of these values are NaN's and
|
|---|
| 48 | // if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
|
|---|
| 49 | // the fit is declared valid.
|
|---|
| 50 | // Otherwise, the fit is repeated within ranges of the previous mean
|
|---|
| 51 | // +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
|
|---|
| 52 | // In case this does not make the fit valid, the histogram means and RMS's are
|
|---|
| 53 | // taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
|
|---|
| 54 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) and
|
|---|
| 55 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 56 | //
|
|---|
| 57 | // Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas
|
|---|
| 58 | // from the mean are counted as Pickup events (stored in MHGausEvents::fPickup)
|
|---|
| 59 | //
|
|---|
| 60 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
|---|
| 61 | // spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the
|
|---|
| 62 | // projected fourier components follow an exponential distribution.
|
|---|
| 63 | // In case that the probability of the exponential fit is less than
|
|---|
| 64 | // MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
|
|---|
| 65 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) and
|
|---|
| 66 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 67 | //
|
|---|
| 68 | // This same procedure is performed for the average pixels.
|
|---|
| 69 | //
|
|---|
| 70 | // The following results are written into an MCalibrationCam:
|
|---|
| 71 | //
|
|---|
| 72 | // - MCalibrationPix::SetMean()
|
|---|
| 73 | // - MCalibrationPix::SetMeanErr()
|
|---|
| 74 | // - MCalibrationPix::SetSigma()
|
|---|
| 75 | // - MCalibrationPix::SetSigmaErr()
|
|---|
| 76 | // - MCalibrationPix::SetProb()
|
|---|
| 77 | // - MCalibrationPix::SetNumPickup()
|
|---|
| 78 | //
|
|---|
| 79 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
|---|
| 80 | // the number involved pixels in order to be able to compare it to the average of
|
|---|
| 81 | // sigmas in the camera.
|
|---|
| 82 | //
|
|---|
| 83 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 84 | #include "MHCalibrationTestCam.h"
|
|---|
| 85 | #include "MHCalibrationTestPix.h"
|
|---|
| 86 |
|
|---|
| 87 | #include "MLog.h"
|
|---|
| 88 | #include "MLogManip.h"
|
|---|
| 89 |
|
|---|
| 90 | #include "MParList.h"
|
|---|
| 91 |
|
|---|
| 92 | #include "MCalibrationCam.h"
|
|---|
| 93 | #include "MCalibrationPix.h"
|
|---|
| 94 |
|
|---|
| 95 | #include "MCerPhotEvt.h"
|
|---|
| 96 | #include "MCerPhotPix.h"
|
|---|
| 97 |
|
|---|
| 98 | #include "MGeomCam.h"
|
|---|
| 99 | #include "MGeomPix.h"
|
|---|
| 100 |
|
|---|
| 101 | #include "MBadPixelsCam.h"
|
|---|
| 102 | #include "MBadPixelsPix.h"
|
|---|
| 103 |
|
|---|
| 104 | ClassImp(MHCalibrationTestCam);
|
|---|
| 105 |
|
|---|
| 106 | using namespace std;
|
|---|
| 107 | // --------------------------------------------------------------------------
|
|---|
| 108 | //
|
|---|
| 109 | // Default Constructor.
|
|---|
| 110 | //
|
|---|
| 111 | MHCalibrationTestCam::MHCalibrationTestCam(const char *name, const char *title)
|
|---|
| 112 | {
|
|---|
| 113 |
|
|---|
| 114 | fName = name ? name : "MHCalibrationTestCam";
|
|---|
| 115 | fTitle = title ? title : "Histogram class for testing the calibration";
|
|---|
| 116 |
|
|---|
| 117 | SetAverageNbins(5000);
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | // --------------------------------------------------------------------------
|
|---|
| 121 | //
|
|---|
| 122 | // Gets or creates the pointers to:
|
|---|
| 123 | // - MCalibrationTestCam
|
|---|
| 124 | //
|
|---|
| 125 | // Searches pointer to:
|
|---|
| 126 | // - MCerPhotEvt
|
|---|
| 127 | //
|
|---|
| 128 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
|---|
| 129 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 130 | //
|
|---|
| 131 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
|---|
| 132 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 133 | //
|
|---|
| 134 | // Calls MHCalibrationCam::InitHists() for every entry in:
|
|---|
| 135 | // - MHCalibrationCam::fHiGainArray
|
|---|
| 136 | // - MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 137 | // - MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 138 | //
|
|---|
| 139 | // Sets Titles and Names for the Histograms
|
|---|
| 140 | // - MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 141 | // - MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 142 | //
|
|---|
| 143 | // Sets number of bins to MHCalibrationCam::fAverageNbins for:
|
|---|
| 144 | // - MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 145 | // - MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 146 | //
|
|---|
| 147 | Bool_t MHCalibrationTestCam::ReInitHists(MParList *pList)
|
|---|
| 148 | {
|
|---|
| 149 |
|
|---|
| 150 | MCerPhotEvt *signal = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
|---|
| 151 | if (!signal)
|
|---|
| 152 | {
|
|---|
| 153 | *fLog << err << "MCerPhotEvt not found... abort." << endl;
|
|---|
| 154 | return kFALSE;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | const Int_t npixels = fGeom->GetNumPixels();
|
|---|
| 158 | const Int_t nsectors = fGeom->GetNumSectors();
|
|---|
| 159 | const Int_t nareas = fGeom->GetNumAreas();
|
|---|
| 160 |
|
|---|
| 161 | if (fHiGainArray->GetEntries()==0)
|
|---|
| 162 | {
|
|---|
| 163 | fHiGainArray->Expand(npixels);
|
|---|
| 164 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 165 | {
|
|---|
| 166 | (*fHiGainArray)[i] = new MHCalibrationTestPix("Calibrated Events",
|
|---|
| 167 | "Test Calibration Pixel");
|
|---|
| 168 | InitHists((*this)[i],(*fBadPixels)[i],i);
|
|---|
| 169 | }
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | if (fLoGainArray->GetEntries()==0)
|
|---|
| 173 | {
|
|---|
| 174 | fLoGainArray->Expand(npixels);
|
|---|
| 175 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 176 | {
|
|---|
| 177 | (*fLoGainArray)[i] = new MHCalibrationTestPix("Calibrated Events",
|
|---|
| 178 | "Test Calibration Pixel");
|
|---|
| 179 | InitHists((*this)(i),(*fBadPixels)[i],i);
|
|---|
| 180 | }
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | if (fAverageHiGainAreas->GetEntries()==0)
|
|---|
| 185 | {
|
|---|
| 186 | fAverageHiGainAreas->Expand(nareas);
|
|---|
| 187 |
|
|---|
| 188 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 189 | {
|
|---|
| 190 | (*fAverageHiGainAreas)[j] =
|
|---|
| 191 | new MHCalibrationTestPix("MHCalibrationTestAverageArea",
|
|---|
| 192 | "Average Test Calibrations Area Idx ");
|
|---|
| 193 |
|
|---|
| 194 | GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Test Calibrations Area Idx ");
|
|---|
| 195 | GetAverageHiGainArea(j).SetNbins(fAverageNbins);
|
|---|
| 196 | GetAverageHiGainArea(j).InitBins();
|
|---|
| 197 | GetAverageHiGainArea(j).ChangeHistId(j);
|
|---|
| 198 | GetAverageHiGainArea(j).SetEventFrequency(fPulserFrequency);
|
|---|
| 199 |
|
|---|
| 200 | TH1F *h = GetAverageHiGainArea(j).GetHGausHist();
|
|---|
| 201 | h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | if (fAverageLoGainAreas->GetEntries()==0)
|
|---|
| 206 | {
|
|---|
| 207 | fAverageLoGainAreas->Expand(nareas);
|
|---|
| 208 |
|
|---|
| 209 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 210 | {
|
|---|
| 211 | (*fAverageLoGainAreas)[j] =
|
|---|
| 212 | new MHCalibrationTestPix("MHCalibrationTestAverageArea",
|
|---|
| 213 | "Average Test Calibrations Area Idx ");
|
|---|
| 214 |
|
|---|
| 215 | GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Test Calibrations Area Idx ");
|
|---|
| 216 | GetAverageLoGainArea(j).SetNbins(fAverageNbins);
|
|---|
| 217 | GetAverageLoGainArea(j).InitBins();
|
|---|
| 218 | GetAverageLoGainArea(j).ChangeHistId(j);
|
|---|
| 219 | GetAverageLoGainArea(j).SetEventFrequency(fPulserFrequency);
|
|---|
| 220 |
|
|---|
| 221 | }
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 | if (fAverageHiGainSectors->GetEntries()==0)
|
|---|
| 226 | {
|
|---|
| 227 | fAverageHiGainSectors->Expand(nsectors);
|
|---|
| 228 |
|
|---|
| 229 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 230 | {
|
|---|
| 231 | (*fAverageHiGainSectors)[j] =
|
|---|
| 232 | new MHCalibrationTestPix("MHCalibrationTestAverageSector",
|
|---|
| 233 | "Average Test Calibrations Sector ");
|
|---|
| 234 |
|
|---|
| 235 | GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Test Calibrations Sector ");
|
|---|
| 236 | GetAverageHiGainSector(j).SetNbins(fAverageNbins);
|
|---|
| 237 | GetAverageHiGainSector(j).InitBins();
|
|---|
| 238 | GetAverageHiGainSector(j).ChangeHistId(j);
|
|---|
| 239 | GetAverageHiGainSector(j).SetEventFrequency(fPulserFrequency);
|
|---|
| 240 |
|
|---|
| 241 | TH1F *h = GetAverageHiGainSector(j).GetHGausHist();
|
|---|
| 242 | h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
|
|---|
| 243 |
|
|---|
| 244 | }
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 | if (fAverageLoGainSectors->GetEntries()==0)
|
|---|
| 249 | {
|
|---|
| 250 | fAverageLoGainSectors->Expand(nsectors);
|
|---|
| 251 |
|
|---|
| 252 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 253 | {
|
|---|
| 254 | (*fAverageLoGainSectors)[j] =
|
|---|
| 255 | new MHCalibrationTestPix("MHCalibrationTestAverageSector",
|
|---|
| 256 | "Average Test Calibrations Sector ");
|
|---|
| 257 |
|
|---|
| 258 | GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Test Calibrations Sector ");
|
|---|
| 259 | GetAverageLoGainSector(j).SetNbins(fAverageNbins);
|
|---|
| 260 | GetAverageLoGainSector(j).InitBins();
|
|---|
| 261 | GetAverageLoGainSector(j).ChangeHistId(j);
|
|---|
| 262 | GetAverageLoGainSector(j).SetEventFrequency(fPulserFrequency);
|
|---|
| 263 | }
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 | return kTRUE;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 | // -------------------------------------------------------------------------------
|
|---|
| 272 | //
|
|---|
| 273 | // Retrieves pointer to MCerPhotEvt:
|
|---|
| 274 | //
|
|---|
| 275 | // Retrieves from MGeomCam:
|
|---|
| 276 | // - number of pixels
|
|---|
| 277 | // - number of pixel areas
|
|---|
| 278 | // - number of sectors
|
|---|
| 279 | //
|
|---|
| 280 | // Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
|
|---|
| 281 | // depending on MCerPhotPix::IsLoGainUsed(), with:
|
|---|
| 282 | // - MCerPhotPix::GetArrivalTime(pixid) - MCerPhotPix::GetArrivalTime(1);
|
|---|
| 283 | // (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
|
|---|
| 284 | //
|
|---|
| 285 | Bool_t MHCalibrationTestCam::FillHists(const MParContainer *par, const Stat_t w)
|
|---|
| 286 | {
|
|---|
| 287 |
|
|---|
| 288 | MCerPhotEvt *calibration = (MCerPhotEvt*)par;
|
|---|
| 289 | if (!calibration)
|
|---|
| 290 | {
|
|---|
| 291 | gLog << err << "No argument in MHCalibrationRelTimeCam::Fill... abort." << endl;
|
|---|
| 292 | return kFALSE;
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | const Int_t npixels = fGeom->GetNumPixels();
|
|---|
| 296 | const Int_t nareas = fGeom->GetNumAreas();
|
|---|
| 297 | const Int_t nsectors = fGeom->GetNumSectors();
|
|---|
| 298 |
|
|---|
| 299 | Float_t sumareahi [nareas];
|
|---|
| 300 | Float_t sumsectorhi[nsectors];
|
|---|
| 301 | Int_t numareahi [nareas];
|
|---|
| 302 | Int_t numsectorhi[nsectors];
|
|---|
| 303 |
|
|---|
| 304 | memset(sumareahi, 0, nareas * sizeof(Float_t));
|
|---|
| 305 | memset(sumsectorhi, 0, nsectors*sizeof(Float_t));
|
|---|
| 306 | memset(numareahi, 0, nareas * sizeof(Int_t));
|
|---|
| 307 | memset(numsectorhi, 0, nsectors*sizeof(Int_t));
|
|---|
| 308 |
|
|---|
| 309 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 310 | {
|
|---|
| 311 |
|
|---|
| 312 | MHGausEvents &histhi = (*this)[i];
|
|---|
| 313 |
|
|---|
| 314 | if (histhi.IsExcluded())
|
|---|
| 315 | continue;
|
|---|
| 316 |
|
|---|
| 317 | const MCerPhotPix *pix = calibration->GetPixById(i);
|
|---|
| 318 | if (!pix)
|
|---|
| 319 | continue;
|
|---|
| 320 |
|
|---|
| 321 | const Float_t signal = pix->GetNumPhotons();
|
|---|
| 322 |
|
|---|
| 323 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
|---|
| 324 | const Int_t sector = (*fGeom)[i].GetSector();
|
|---|
| 325 |
|
|---|
| 326 | histhi.FillHistAndArray(signal) ;
|
|---|
| 327 | sumareahi [aidx] += signal;
|
|---|
| 328 | numareahi [aidx] ++;
|
|---|
| 329 | sumsectorhi[sector] += signal;
|
|---|
| 330 | numsectorhi[sector] ++;
|
|---|
| 331 | }
|
|---|
| 332 |
|
|---|
| 333 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 334 | {
|
|---|
| 335 | MHGausEvents &histhi = GetAverageHiGainArea(j);
|
|---|
| 336 | histhi.FillHistAndArray(numareahi[j] == 0 ? 0. : sumareahi[j]/numareahi[j]);
|
|---|
| 337 |
|
|---|
| 338 | }
|
|---|
| 339 |
|
|---|
| 340 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 341 | {
|
|---|
| 342 | MHGausEvents &histhi = GetAverageHiGainSector(j);
|
|---|
| 343 | histhi.FillHistAndArray(numsectorhi[j] == 0 ? 0. : sumsectorhi[j]/numsectorhi[j]);
|
|---|
| 344 |
|
|---|
| 345 | }
|
|---|
| 346 |
|
|---|
| 347 | return kTRUE;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | // --------------------------------------------------------------------------
|
|---|
| 351 | //
|
|---|
| 352 | // Calls:
|
|---|
| 353 | // - MHCalibrationCam::FitHiGainArrays() with flags:
|
|---|
| 354 | // MBadPixelsPix::kTestNotFitted and MBadPixelsPix::kTestOscillating
|
|---|
| 355 | // - MHCalibrationCam::FitLoGainArrays() with flags:
|
|---|
| 356 | // MBadPixelsPix::kTestNotFitted and MBadPixelsPix::kTestOscillating
|
|---|
| 357 | //
|
|---|
| 358 | Bool_t MHCalibrationTestCam::FinalizeHists()
|
|---|
| 359 | {
|
|---|
| 360 |
|
|---|
| 361 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
|---|
| 362 | {
|
|---|
| 363 |
|
|---|
| 364 | MHGausEvents &hist = (*this)[i];
|
|---|
| 365 |
|
|---|
| 366 | if (hist.IsExcluded())
|
|---|
| 367 | continue;
|
|---|
| 368 |
|
|---|
| 369 | if (hist.IsEmpty())
|
|---|
| 370 | continue;
|
|---|
| 371 |
|
|---|
| 372 | if (!hist.FitGaus())
|
|---|
| 373 | if (!hist.RepeatFit())
|
|---|
| 374 | {
|
|---|
| 375 | hist.BypassFit();
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | hist.CreateFourierSpectrum();
|
|---|
| 379 |
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
|---|
| 383 | {
|
|---|
| 384 |
|
|---|
| 385 | MHGausEvents &hist = GetAverageHiGainArea(j);
|
|---|
| 386 | if (hist.IsEmpty())
|
|---|
| 387 | continue;
|
|---|
| 388 |
|
|---|
| 389 | if (!hist.FitGaus())
|
|---|
| 390 | if (!hist.RepeatFit())
|
|---|
| 391 | {
|
|---|
| 392 | hist.BypassFit();
|
|---|
| 393 | }
|
|---|
| 394 |
|
|---|
| 395 | hist.CreateFourierSpectrum();
|
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
|---|
| 401 | {
|
|---|
| 402 |
|
|---|
| 403 | MHGausEvents &hist = GetAverageHiGainSector(j);
|
|---|
| 404 | if (hist.IsEmpty())
|
|---|
| 405 | continue;
|
|---|
| 406 |
|
|---|
| 407 | if (!hist.FitGaus())
|
|---|
| 408 | if (!hist.RepeatFit())
|
|---|
| 409 | {
|
|---|
| 410 | hist.BypassFit();
|
|---|
| 411 | }
|
|---|
| 412 | hist.CreateFourierSpectrum();
|
|---|
| 413 |
|
|---|
| 414 |
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | return kTRUE;
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | // --------------------------------------------------------------------------
|
|---|
| 421 | //
|
|---|
| 422 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
|---|
| 423 | // - MBadPixelsPix::kTestNotFitted
|
|---|
| 424 | // - MBadPixelsPix::kTestOscillating
|
|---|
| 425 | //
|
|---|
| 426 | void MHCalibrationTestCam::FinalizeBadPixels()
|
|---|
| 427 | {
|
|---|
| 428 |
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | // --------------------------------------------------------------------------
|
|---|
| 432 | //
|
|---|
| 433 | // The types are as follows:
|
|---|
| 434 | //
|
|---|
| 435 | // Fitted values:
|
|---|
| 436 | // ==============
|
|---|
| 437 | //
|
|---|
| 438 | // 0: Fitted Mean Test Calibration (MHGausEvents::GetMean())
|
|---|
| 439 | // 1: Error Mean Test Calibration (MHGausEvents::GetMeanErr())
|
|---|
| 440 | // 2: Sigma fitted Test Calibration (MHGausEvents::GetSigma())
|
|---|
| 441 | // 3: Error Sigma Test Calibration (MHGausEvents::GetSigmaErr())
|
|---|
| 442 | //
|
|---|
| 443 | // Useful variables derived from the fit results:
|
|---|
| 444 | // =============================================
|
|---|
| 445 | //
|
|---|
| 446 | // 4: Returned probability of Gauss fit (calls: MHGausEvents::GetProb())
|
|---|
| 447 | //
|
|---|
| 448 | // Localized defects:
|
|---|
| 449 | // ==================
|
|---|
| 450 | //
|
|---|
| 451 | // 5: Gaus fit not OK (calls: MHGausEvents::IsGausFitOK())
|
|---|
| 452 | // 6: Fourier spectrum not OK (calls: MHGausEvents::IsFourierSpectrumOK())
|
|---|
| 453 | //
|
|---|
| 454 | // Converted values:
|
|---|
| 455 | // =================
|
|---|
| 456 | //
|
|---|
| 457 | // 7: Fitted Mean Test Calibration (MHGausEvents::GetMean()) by MGeomPix::GetA()
|
|---|
| 458 | // 8: Fitted Mean Error Calibration (MHGausEvents::GetSigma()) by MGeomPix::GetA()
|
|---|
| 459 | // 9: Fitted Sigma Test Calibration (MHGausEvents::GetMean()) by MGeomPix::GetA()
|
|---|
| 460 | // 8: Fitted Sigma Error Calibration (MHGausEvents::GetSigma()) by MGeomPix::GetA()
|
|---|
| 461 | //
|
|---|
| 462 | Bool_t MHCalibrationTestCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 463 | {
|
|---|
| 464 |
|
|---|
| 465 | if (fHiGainArray->GetSize() <= idx)
|
|---|
| 466 | return kFALSE;
|
|---|
| 467 |
|
|---|
| 468 | const MHGausEvents &pix = (*this)[idx];
|
|---|
| 469 |
|
|---|
| 470 | if (pix.IsExcluded())
|
|---|
| 471 | return kFALSE;
|
|---|
| 472 |
|
|---|
| 473 | switch (type)
|
|---|
| 474 | {
|
|---|
| 475 | case 0:
|
|---|
| 476 | val = pix.GetMean();
|
|---|
| 477 | break;
|
|---|
| 478 | case 1:
|
|---|
| 479 | val = pix.GetMeanErr();
|
|---|
| 480 | break;
|
|---|
| 481 | case 2:
|
|---|
| 482 | val = pix.GetSigma();
|
|---|
| 483 | break;
|
|---|
| 484 | case 3:
|
|---|
| 485 | val = pix.GetSigmaErr();
|
|---|
| 486 | break;
|
|---|
| 487 | case 4:
|
|---|
| 488 | val = pix.GetProb();
|
|---|
| 489 | break;
|
|---|
| 490 | case 5:
|
|---|
| 491 | if (!pix.IsGausFitOK())
|
|---|
| 492 | val = 1.;
|
|---|
| 493 | break;
|
|---|
| 494 | case 6:
|
|---|
| 495 | if (!pix.IsFourierSpectrumOK())
|
|---|
| 496 | val = 1.;
|
|---|
| 497 | break;
|
|---|
| 498 | case 7:
|
|---|
| 499 | val = pix.GetMean()/cam[idx].GetA();
|
|---|
| 500 | break;
|
|---|
| 501 | case 8:
|
|---|
| 502 | val = pix.GetMeanErr()/cam[idx].GetA();
|
|---|
| 503 | break;
|
|---|
| 504 | case 9:
|
|---|
| 505 | val = pix.GetSigma()/cam[idx].GetA();
|
|---|
| 506 | break;
|
|---|
| 507 | case 10:
|
|---|
| 508 | val = pix.GetSigmaErr()/cam[idx].GetA();
|
|---|
| 509 | break;
|
|---|
| 510 | default:
|
|---|
| 511 | return kFALSE;
|
|---|
| 512 | }
|
|---|
| 513 | return kTRUE;
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | // --------------------------------------------------------------------------
|
|---|
| 517 | //
|
|---|
| 518 | // Calls MHGausEvents::DrawClone() for pixel idx
|
|---|
| 519 | //
|
|---|
| 520 | void MHCalibrationTestCam::DrawPixelContent(Int_t idx) const
|
|---|
| 521 | {
|
|---|
| 522 | (*this)[idx].DrawClone();
|
|---|
| 523 | }
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 | //------------------------------------------------------------
|
|---|
| 527 | //
|
|---|
| 528 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
|---|
| 529 | // the number involved pixels
|
|---|
| 530 | //
|
|---|
| 531 | void MHCalibrationTestCam::CalcAverageSigma()
|
|---|
| 532 | {
|
|---|
| 533 |
|
|---|
| 534 | for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
|
|---|
| 535 | {
|
|---|
| 536 |
|
|---|
| 537 | MHGausEvents &hist = GetAverageHiGainArea(j);
|
|---|
| 538 |
|
|---|
| 539 | const Float_t numsqr = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
|
|---|
| 540 | fAverageAreaSigma[j] = hist.GetSigma () * numsqr;
|
|---|
| 541 | fAverageAreaSigmaVar[j] = hist.GetSigmaErr () * hist.GetSigmaErr() * numsqr;
|
|---|
| 542 |
|
|---|
| 543 | fAverageAreaRelSigma [j] = fAverageAreaSigma[j] / hist.GetMean();
|
|---|
| 544 | fAverageAreaRelSigmaVar[j] = fAverageAreaSigmaVar[j] / (fAverageAreaSigma[j]*fAverageAreaSigma[j]);
|
|---|
| 545 | fAverageAreaRelSigmaVar[j] += hist.GetMeanErr()*hist.GetMeanErr()/hist.GetMean()/hist.GetMean();
|
|---|
| 546 | fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
|
|---|
| 547 | }
|
|---|
| 548 | }
|
|---|