| 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 | // MHCalibrationRelTimeCam
|
|---|
| 27 | //
|
|---|
| 28 | // Fills the extracted relative arrival times of MArrivalTimeCam into
|
|---|
| 29 | // the MHCalibrationPix-classes MHCalibrationRelTimePix for every:
|
|---|
| 30 | //
|
|---|
| 31 | // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray
|
|---|
| 32 | // or MHCalibrationCam::fHiGainArray, respectively, depending if
|
|---|
| 33 | // MArrivalTimePix::IsLoGainUsed() is set.
|
|---|
| 34 | //
|
|---|
| 35 | // - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
|
|---|
| 36 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
|
|---|
| 37 | // MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 38 | //
|
|---|
| 39 | // - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
|
|---|
| 40 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 41 | // and MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 42 | //
|
|---|
| 43 | // Every relative time is calculated as the difference between the individual
|
|---|
| 44 | // pixel arrival time and the one of pixel 1 (hardware number: 2).
|
|---|
| 45 | // The relative times are filled into a histogram and an array, in order to perform
|
|---|
| 46 | // a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an
|
|---|
| 47 | // event-by-event basis and written into the corresponding average pixels.
|
|---|
| 48 | //
|
|---|
| 49 | // The histograms are fitted to a Gaussian, mean and sigma with its errors
|
|---|
| 50 | // and the fit probability are extracted. If none of these values are NaN's and
|
|---|
| 51 | // if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
|
|---|
| 52 | // the fit is declared valid.
|
|---|
| 53 | // Otherwise, the fit is repeated within ranges of the previous mean
|
|---|
| 54 | // +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
|
|---|
| 55 | // In case this does not make the fit valid, the histogram means and RMS's are
|
|---|
| 56 | // taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
|
|---|
| 57 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeNotFitted ) and
|
|---|
| 58 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 59 | //
|
|---|
| 60 | // Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas
|
|---|
| 61 | // from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup)
|
|---|
| 62 | //
|
|---|
| 63 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
|---|
| 64 | // spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the
|
|---|
| 65 | // projected fourier components follow an exponential distribution.
|
|---|
| 66 | // In case that the probability of the exponential fit is less than
|
|---|
| 67 | // MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
|
|---|
| 68 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeOscillating ) and
|
|---|
| 69 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 70 | //
|
|---|
| 71 | // This same procedure is performed for the average pixels.
|
|---|
| 72 | //
|
|---|
| 73 | // The following results are written into MCalibrationRelTimeCam:
|
|---|
| 74 | //
|
|---|
| 75 | // - MCalibrationPix::SetMean()
|
|---|
| 76 | // - MCalibrationPix::SetMeanErr()
|
|---|
| 77 | // - MCalibrationPix::SetSigma()
|
|---|
| 78 | // - MCalibrationPix::SetSigmaErr()
|
|---|
| 79 | // - MCalibrationPix::SetProb()
|
|---|
| 80 | // - MCalibrationPix::SetNumPickup()
|
|---|
| 81 | //
|
|---|
| 82 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
|---|
| 83 | // the number involved pixels in order to be able to compare it to the average of
|
|---|
| 84 | // sigmas in the camera.
|
|---|
| 85 | //
|
|---|
| 86 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 87 | #include "MHCalibrationRelTimeCam.h"
|
|---|
| 88 | #include "MHCalibrationRelTimePix.h"
|
|---|
| 89 |
|
|---|
| 90 | #include "MHCalibrationPix.h"
|
|---|
| 91 |
|
|---|
| 92 | #include "MLog.h"
|
|---|
| 93 | #include "MLogManip.h"
|
|---|
| 94 |
|
|---|
| 95 | #include "MParList.h"
|
|---|
| 96 |
|
|---|
| 97 | #include "MCalibrationIntensityRelTimeCam.h"
|
|---|
| 98 |
|
|---|
| 99 | #include "MCalibrationRelTimeCam.h"
|
|---|
| 100 | #include "MCalibrationRelTimePix.h"
|
|---|
| 101 | #include "MCalibrationPix.h"
|
|---|
| 102 |
|
|---|
| 103 | #include "MArrivalTimeCam.h"
|
|---|
| 104 | #include "MArrivalTimePix.h"
|
|---|
| 105 |
|
|---|
| 106 | #include "MGeomCam.h"
|
|---|
| 107 | #include "MGeomPix.h"
|
|---|
| 108 |
|
|---|
| 109 | #include "MBadPixelsCam.h"
|
|---|
| 110 | #include "MBadPixelsPix.h"
|
|---|
| 111 |
|
|---|
| 112 | ClassImp(MHCalibrationRelTimeCam);
|
|---|
| 113 |
|
|---|
| 114 | using namespace std;
|
|---|
| 115 |
|
|---|
| 116 | const Float_t MHCalibrationRelTimeCam::fgNumHiGainSaturationLimit = 0.25;
|
|---|
| 117 | const UInt_t MHCalibrationRelTimeCam::fgReferencePixel = 1;
|
|---|
| 118 | // --------------------------------------------------------------------------
|
|---|
| 119 | //
|
|---|
| 120 | // Default Constructor.
|
|---|
| 121 | //
|
|---|
| 122 | // Sets:
|
|---|
| 123 | // - fReferencePixel to fgReferencePixel
|
|---|
| 124 | //
|
|---|
| 125 | MHCalibrationRelTimeCam::MHCalibrationRelTimeCam(const char *name, const char *title)
|
|---|
| 126 | {
|
|---|
| 127 |
|
|---|
| 128 | fName = name ? name : "MHCalibrationRelTimeCam";
|
|---|
| 129 | fTitle = title ? title : "Histogram class for the relative time calibration of the camera";
|
|---|
| 130 |
|
|---|
| 131 | SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
|
|---|
| 132 | SetReferencePixel();
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | // --------------------------------------------------------------------------
|
|---|
| 136 | //
|
|---|
| 137 | // Gets or creates the pointers to:
|
|---|
| 138 | // - MCalibrationRelTimeCam
|
|---|
| 139 | //
|
|---|
| 140 | // Searches pointer to:
|
|---|
| 141 | // - MArrivalTimeCam
|
|---|
| 142 | //
|
|---|
| 143 | // Initializes, if empty to MGeomCam::GetNumPixels():
|
|---|
| 144 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
|---|
| 145 | //
|
|---|
| 146 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
|---|
| 147 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 148 | //
|
|---|
| 149 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
|---|
| 150 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 151 | //
|
|---|
| 152 | // Calls MHCalibrationCam::InitHists() for every entry in:
|
|---|
| 153 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
|---|
| 154 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 155 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 156 | //
|
|---|
| 157 | // Sets Titles and Names for the Histograms
|
|---|
| 158 | // - MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 159 | // - MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 160 | //
|
|---|
| 161 | // Sets number of bins to MHCalibrationCam::fAverageNbins for:
|
|---|
| 162 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 163 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 164 | //
|
|---|
| 165 | Bool_t MHCalibrationRelTimeCam::ReInitHists(MParList *pList)
|
|---|
| 166 | {
|
|---|
| 167 |
|
|---|
| 168 | fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityRelTimeCam"));
|
|---|
| 169 | if (fIntensCam)
|
|---|
| 170 | *fLog << inf << "Found MCalibrationIntensityRelTimeCam ... " << endl;
|
|---|
| 171 | else
|
|---|
| 172 | {
|
|---|
| 173 | fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
|---|
| 174 | if (!fCam)
|
|---|
| 175 | {
|
|---|
| 176 | fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationRelTimeCam"));
|
|---|
| 177 | if (!fCam)
|
|---|
| 178 | {
|
|---|
| 179 | *fLog << err << "Cannot find nor create MCalibrationRelTimeCam ... abort." << endl;
|
|---|
| 180 | return kFALSE;
|
|---|
| 181 | }
|
|---|
| 182 | fCam->Init(*fGeom);
|
|---|
| 183 | }
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | MArrivalTimeCam *signal = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
|
|---|
| 187 | if (!signal)
|
|---|
| 188 | {
|
|---|
| 189 | *fLog << err << "MArrivalTimeCam not found... abort." << endl;
|
|---|
| 190 | return kFALSE;
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | const Int_t npixels = fGeom->GetNumPixels();
|
|---|
| 194 | const Int_t nsectors = fGeom->GetNumSectors();
|
|---|
| 195 | const Int_t nareas = fGeom->GetNumAreas();
|
|---|
| 196 |
|
|---|
| 197 | if (fHiGainArray->GetEntries()==0)
|
|---|
| 198 | {
|
|---|
| 199 | fHiGainArray->Expand(npixels);
|
|---|
| 200 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 201 | {
|
|---|
| 202 | (*fHiGainArray)[i] = new MHCalibrationRelTimePix("MHCalibrationRelTimePixHiGain",
|
|---|
| 203 | "Rel. Arr. Time Hi-Gain Pixel ");
|
|---|
| 204 | InitHists((*this)[i],(*fBadPixels)[i],i);
|
|---|
| 205 | }
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | if (fLoGainArray->GetEntries()==0 && fLoGain )
|
|---|
| 209 | {
|
|---|
| 210 | fLoGainArray->Expand(npixels);
|
|---|
| 211 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 212 | {
|
|---|
| 213 | (*fLoGainArray)[i] = new MHCalibrationRelTimePix("MHCalibrationRelTimePixLoGain",
|
|---|
| 214 | "Rel. Arr. Time Lo-Gain Pixel ");
|
|---|
| 215 | InitHists((*this)(i),(*fBadPixels)[i],i);
|
|---|
| 216 | }
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 | if (fAverageHiGainAreas->GetEntries()==0)
|
|---|
| 221 | {
|
|---|
| 222 | fAverageHiGainAreas->Expand(nareas);
|
|---|
| 223 |
|
|---|
| 224 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 225 | {
|
|---|
| 226 | (*fAverageHiGainAreas)[j] =
|
|---|
| 227 | new MHCalibrationRelTimePix("RelTimeAverageHiGainArea",
|
|---|
| 228 | "Average Rel. Arr. Times Hi-Gain Area Idx ");
|
|---|
| 229 |
|
|---|
| 230 | MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageHiGainArea(j);
|
|---|
| 231 |
|
|---|
| 232 | hist.SetNbins(fAverageNbins);
|
|---|
| 233 | hist.GetHGausHist()->SetTitle("Rel. Arr. Times average HiGain Area Idx ");
|
|---|
| 234 |
|
|---|
| 235 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
|---|
| 236 | {
|
|---|
| 237 | hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
|
|---|
| 238 | j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
|
|---|
| 239 | hist.InitBins();
|
|---|
| 240 | hist.SetEventFrequency(fPulserFrequency);
|
|---|
| 241 | }
|
|---|
| 242 | else
|
|---|
| 243 | {
|
|---|
| 244 | hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
|
|---|
| 245 | InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | if (fAverageLoGainAreas->GetEntries()==0 && fLoGain )
|
|---|
| 251 | {
|
|---|
| 252 | fAverageLoGainAreas->Expand(nareas);
|
|---|
| 253 |
|
|---|
| 254 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 255 | {
|
|---|
| 256 | (*fAverageLoGainAreas)[j] =
|
|---|
| 257 | new MHCalibrationRelTimePix("RelTimeAverageAreaLoGain",
|
|---|
| 258 | "Average Rel. Arr. Times Lo-Gain Area Idx ");
|
|---|
| 259 |
|
|---|
| 260 | MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageLoGainArea(j);
|
|---|
| 261 | hist.SetNbins(fAverageNbins);
|
|---|
| 262 |
|
|---|
| 263 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
|---|
| 264 | {
|
|---|
| 265 | hist.GetHGausHist()->SetTitle(Form("%s%s%s","Rel. Arr. Times averaged on event-by-event basis ",
|
|---|
| 266 | j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
|
|---|
| 267 | hist.InitBins();
|
|---|
| 268 | hist.SetEventFrequency(fPulserFrequency);
|
|---|
| 269 | }
|
|---|
| 270 | else
|
|---|
| 271 | {
|
|---|
| 272 | hist.GetHGausHist()->SetTitle("Rel. Arr. Times averaged on event-by-event basis Low Gain Area Idx ");
|
|---|
| 273 | InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
|
|---|
| 274 | }
|
|---|
| 275 | }
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | if (fAverageHiGainSectors->GetEntries()==0)
|
|---|
| 279 | {
|
|---|
| 280 | fAverageHiGainSectors->Expand(nsectors);
|
|---|
| 281 |
|
|---|
| 282 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 283 | {
|
|---|
| 284 | (*fAverageHiGainSectors)[j] =
|
|---|
| 285 | new MHCalibrationRelTimePix("RelTimeAverageSectorHiGain",
|
|---|
| 286 | "Average HiGain Rel. Arr. Times Sector ");
|
|---|
| 287 |
|
|---|
| 288 | MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageHiGainSector(j);
|
|---|
| 289 |
|
|---|
| 290 | hist.GetHGausHist()->SetTitle("Rel. Arr. Times averaged on event-by-event basis HiGain Sector ");
|
|---|
| 291 | hist.SetNbins(fAverageNbins);
|
|---|
| 292 |
|
|---|
| 293 | InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
|
|---|
| 294 | }
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 | if (fAverageLoGainSectors->GetEntries()==0 && fLoGain )
|
|---|
| 298 | {
|
|---|
| 299 | fAverageLoGainSectors->Expand(nsectors);
|
|---|
| 300 |
|
|---|
| 301 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 302 | {
|
|---|
| 303 | (*fAverageLoGainSectors)[j] =
|
|---|
| 304 | new MHCalibrationRelTimePix("RelTimeAverageSectorLoGain",
|
|---|
| 305 | "Average LoGain Rel. Arr. Times Sector ");
|
|---|
| 306 |
|
|---|
| 307 | MHCalibrationRelTimePix &hist = (MHCalibrationRelTimePix&)GetAverageLoGainSector(j);
|
|---|
| 308 |
|
|---|
| 309 | hist.GetHGausHist()->SetTitle("Rel. Arr. Times averaged on event-by-event basis LoGain Sector ");
|
|---|
| 310 | hist.SetNbins(fAverageNbins);
|
|---|
| 311 |
|
|---|
| 312 | InitHists(hist,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
|
|---|
| 313 | }
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | fSumareahi .Set(nareas);
|
|---|
| 317 | fSumarealo .Set(nareas);
|
|---|
| 318 | fSumsectorhi.Set(nsectors);
|
|---|
| 319 | fSumsectorlo.Set(nsectors);
|
|---|
| 320 | fNumareahi .Set(nareas);
|
|---|
| 321 | fNumarealo .Set(nareas);
|
|---|
| 322 | fNumsectorhi.Set(nsectors);
|
|---|
| 323 | fNumsectorlo.Set(nsectors);
|
|---|
| 324 |
|
|---|
| 325 | return kTRUE;
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 | // -------------------------------------------------------------------------------
|
|---|
| 330 | //
|
|---|
| 331 | // Retrieves pointer to MArrivalTimeCam:
|
|---|
| 332 | //
|
|---|
| 333 | // Retrieves from MGeomCam:
|
|---|
| 334 | // - number of pixels
|
|---|
| 335 | // - number of pixel areas
|
|---|
| 336 | // - number of sectors
|
|---|
| 337 | //
|
|---|
| 338 | // Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
|
|---|
| 339 | // depending on MArrivalTimePix::IsLoGainUsed(), with:
|
|---|
| 340 | // - MArrivalTimePix::GetArrivalTime(pixid) - MArrivalTimePix::GetArrivalTime(1);
|
|---|
| 341 | // (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
|
|---|
| 342 | //
|
|---|
| 343 | Bool_t MHCalibrationRelTimeCam::FillHists(const MParContainer *par, const Stat_t w)
|
|---|
| 344 | {
|
|---|
| 345 |
|
|---|
| 346 | MArrivalTimeCam *arrtime = (MArrivalTimeCam*)par;
|
|---|
| 347 | if (!arrtime)
|
|---|
| 348 | {
|
|---|
| 349 | gLog << err << "No argument in MArrivalTime::Fill... abort." << endl;
|
|---|
| 350 | return kFALSE;
|
|---|
| 351 | }
|
|---|
| 352 |
|
|---|
| 353 | const Int_t npixels = fGeom->GetNumPixels();
|
|---|
| 354 | const Int_t nareas = fGeom->GetNumAreas();
|
|---|
| 355 | const Int_t nsectors = fGeom->GetNumSectors();
|
|---|
| 356 |
|
|---|
| 357 | fSumareahi .Reset();
|
|---|
| 358 | fSumarealo .Reset();
|
|---|
| 359 | fSumsectorhi.Reset();
|
|---|
| 360 | fSumsectorlo.Reset();
|
|---|
| 361 | fNumareahi .Reset();
|
|---|
| 362 | fNumarealo .Reset();
|
|---|
| 363 | fNumsectorhi.Reset();
|
|---|
| 364 | fNumsectorlo.Reset();
|
|---|
| 365 |
|
|---|
| 366 | const MArrivalTimePix &refpix = (*arrtime)[fReferencePixel];
|
|---|
| 367 | const Float_t reftime = refpix.IsLoGainUsed()
|
|---|
| 368 | ? refpix.GetArrivalTimeLoGain() : refpix.GetArrivalTimeHiGain();
|
|---|
| 369 |
|
|---|
| 370 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 371 | {
|
|---|
| 372 |
|
|---|
| 373 | MHCalibrationPix &histhi = (*this)[i];
|
|---|
| 374 | MHCalibrationPix &histlo = (*this)(i);
|
|---|
| 375 |
|
|---|
| 376 | if (histhi.IsExcluded())
|
|---|
| 377 | continue;
|
|---|
| 378 |
|
|---|
| 379 | const MArrivalTimePix &pix = (*arrtime)[i];
|
|---|
| 380 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
|---|
| 381 | const Int_t sector = (*fGeom)[i].GetSector();
|
|---|
| 382 |
|
|---|
| 383 | if (pix.IsLoGainUsed() && fLoGain)
|
|---|
| 384 | {
|
|---|
| 385 | const Float_t reltime = pix.GetArrivalTimeLoGain() - reftime;
|
|---|
| 386 | histhi.SetSaturated(1);
|
|---|
| 387 | histlo.FillHistAndArray(reltime);
|
|---|
| 388 | fSumarealo [aidx] += reltime;
|
|---|
| 389 | fNumarealo [aidx] ++;
|
|---|
| 390 | fSumsectorlo[sector] += reltime;
|
|---|
| 391 | fNumsectorlo[sector] ++;
|
|---|
| 392 | }
|
|---|
| 393 | else
|
|---|
| 394 | {
|
|---|
| 395 | const Float_t reltime = pix.GetArrivalTimeHiGain() - reftime;
|
|---|
| 396 |
|
|---|
| 397 | histhi.FillHistAndArray(reltime) ;
|
|---|
| 398 | fSumareahi [aidx] += reltime;
|
|---|
| 399 | fNumareahi [aidx] ++;
|
|---|
| 400 | fSumsectorhi[sector] += reltime;
|
|---|
| 401 | fNumsectorhi[sector] ++;
|
|---|
| 402 | }
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 406 | {
|
|---|
| 407 | MHCalibrationPix &histhi = GetAverageHiGainArea(j);
|
|---|
| 408 | histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
|
|---|
| 409 |
|
|---|
| 410 | if (fLoGain)
|
|---|
| 411 | {
|
|---|
| 412 | MHCalibrationPix &histlo = GetAverageLoGainArea(j);
|
|---|
| 413 | histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
|
|---|
| 414 | }
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 418 | {
|
|---|
| 419 | MHCalibrationPix &histhi = GetAverageHiGainSector(j);
|
|---|
| 420 | histhi.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
|
|---|
| 421 |
|
|---|
| 422 | if (fLoGain)
|
|---|
| 423 | {
|
|---|
| 424 | MHCalibrationPix &histlo = GetAverageLoGainSector(j);
|
|---|
| 425 | histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
|
|---|
| 426 | }
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | return kTRUE;
|
|---|
| 430 | }
|
|---|
| 431 |
|
|---|
| 432 | // --------------------------------------------------------------------------
|
|---|
| 433 | //
|
|---|
| 434 | // Calls:
|
|---|
| 435 | // - MHCalibrationCam::FitHiGainArrays() with flags:
|
|---|
| 436 | // MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
|
|---|
| 437 | // - MHCalibrationCam::FitLoGainArrays() with flags:
|
|---|
| 438 | // MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
|
|---|
| 439 | //
|
|---|
| 440 | Bool_t MHCalibrationRelTimeCam::FinalizeHists()
|
|---|
| 441 | {
|
|---|
| 442 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
|---|
| 443 | {
|
|---|
| 444 |
|
|---|
| 445 | MHCalibrationRelTimePix &histhi = (MHCalibrationRelTimePix&)(*this)[i];
|
|---|
| 446 |
|
|---|
| 447 | if (histhi.IsExcluded())
|
|---|
| 448 | continue;
|
|---|
| 449 |
|
|---|
| 450 | MCalibrationRelTimePix &pix = fIntensCam
|
|---|
| 451 | ? (MCalibrationRelTimePix&)(*fIntensCam)[i]
|
|---|
| 452 | : (MCalibrationRelTimePix&)(*fCam)[i];
|
|---|
| 453 |
|
|---|
| 454 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 455 | {
|
|---|
| 456 | pix.SetHiGainSaturation();
|
|---|
| 457 | histhi.SetExcluded();
|
|---|
| 458 | }
|
|---|
| 459 | else
|
|---|
| 460 | if (fLoGain)
|
|---|
| 461 | (*this)(i).SetExcluded();
|
|---|
| 462 |
|
|---|
| 463 | Stat_t overflow = histhi.GetHGausHist()->GetBinContent(histhi.GetHGausHist()->GetNbinsX()+1);
|
|---|
| 464 | if (overflow > 0.1)
|
|---|
| 465 | {
|
|---|
| 466 | *fLog << warn << GetDescriptor()
|
|---|
| 467 | << ": HiGain Histogram Overflow occurred " << overflow
|
|---|
| 468 | << " times in pixel: " << i << " (without saturation!) " << endl;
|
|---|
| 469 | // bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | overflow = histhi.GetHGausHist()->GetBinContent(0);
|
|---|
| 473 | if (overflow > 0.1)
|
|---|
| 474 | {
|
|---|
| 475 | *fLog << warn << GetDescriptor()
|
|---|
| 476 | << ": HiGain Histogram Underflow occurred " << overflow
|
|---|
| 477 | << " times in pixel: " << i << " (without saturation!) " << endl;
|
|---|
| 478 | // bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
|
|---|
| 479 | }
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
|---|
| 483 | {
|
|---|
| 484 |
|
|---|
| 485 | MHCalibrationRelTimePix &histhi = (MHCalibrationRelTimePix&)GetAverageHiGainArea(j);
|
|---|
| 486 |
|
|---|
| 487 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 488 | {
|
|---|
| 489 | MCalibrationRelTimePix &pix = fIntensCam
|
|---|
| 490 | ? (MCalibrationRelTimePix&)fIntensCam->GetAverageArea(j)
|
|---|
| 491 | : (MCalibrationRelTimePix&)fCam->GetAverageArea(j);
|
|---|
| 492 | pix.SetHiGainSaturation();
|
|---|
| 493 | histhi.SetExcluded();
|
|---|
| 494 | }
|
|---|
| 495 | else
|
|---|
| 496 | if (fLoGain)
|
|---|
| 497 | GetAverageLoGainArea(j).SetExcluded();
|
|---|
| 498 |
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
|---|
| 502 | {
|
|---|
| 503 |
|
|---|
| 504 | MHCalibrationRelTimePix &histhi = (MHCalibrationRelTimePix&)GetAverageHiGainSector(j);
|
|---|
| 505 | MCalibrationRelTimePix &pix = fIntensCam
|
|---|
| 506 | ? (MCalibrationRelTimePix&)fIntensCam->GetAverageSector(j)
|
|---|
| 507 | : (MCalibrationRelTimePix&)fCam->GetAverageSector(j);
|
|---|
| 508 |
|
|---|
| 509 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 510 | {
|
|---|
| 511 | pix.SetHiGainSaturation();
|
|---|
| 512 | histhi.SetExcluded();
|
|---|
| 513 | }
|
|---|
| 514 | else
|
|---|
| 515 | if (fLoGain)
|
|---|
| 516 | GetAverageLoGainSector(j).SetExcluded();
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | FitHiGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
|
|---|
| 520 | *fBadPixels,
|
|---|
| 521 | MBadPixelsPix::kRelTimeNotFitted,
|
|---|
| 522 | MBadPixelsPix::kRelTimeOscillating);
|
|---|
| 523 |
|
|---|
| 524 | if (fLoGain)
|
|---|
| 525 | FitLoGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
|
|---|
| 526 | *fBadPixels,
|
|---|
| 527 | MBadPixelsPix::kRelTimeNotFitted,
|
|---|
| 528 | MBadPixelsPix::kRelTimeOscillating);
|
|---|
| 529 |
|
|---|
| 530 | return kTRUE;
|
|---|
| 531 | }
|
|---|
| 532 |
|
|---|
| 533 | // --------------------------------------------------------------------------
|
|---|
| 534 | //
|
|---|
| 535 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
|---|
| 536 | // - MBadPixelsPix::kRelTimeNotFitted
|
|---|
| 537 | // - MBadPixelsPix::kRelTimeOscillating
|
|---|
| 538 | //
|
|---|
| 539 | void MHCalibrationRelTimeCam::FinalizeBadPixels()
|
|---|
| 540 | {
|
|---|
| 541 |
|
|---|
| 542 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
|---|
| 543 | {
|
|---|
| 544 |
|
|---|
| 545 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 546 |
|
|---|
| 547 | if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted ))
|
|---|
| 548 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 549 |
|
|---|
| 550 | if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
|
|---|
| 551 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 552 |
|
|---|
| 553 | }
|
|---|
| 554 | }
|
|---|
| 555 |
|
|---|
| 556 | // --------------------------------------------------------------------------
|
|---|
| 557 | //
|
|---|
| 558 | // The types are as follows:
|
|---|
| 559 | //
|
|---|
| 560 | // Fitted values:
|
|---|
| 561 | // ==============
|
|---|
| 562 | //
|
|---|
| 563 | // 0: Fitted Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMean()*MHCalibrationRelTimePix::GetFADCSliceWidth())
|
|---|
| 564 | // 1: Error Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMeanErr()*MHCalibrationRelTimePix::GetFADCSliceWidth())
|
|---|
| 565 | // 2: Sigma fitted Relative Arrival Time in FADC slices (MHGausEvents::GetSigma()*MHCalibrationRelTimePix::GetFADCSliceWidth())
|
|---|
| 566 | // 3: Error Sigma Relative Arrival Time in FADC slices (MHGausEvents::GetSigmaErr()*MHCalibrationRelTimePix::GetFADCSliceWidth())
|
|---|
| 567 | //
|
|---|
| 568 | // Useful variables derived from the fit results:
|
|---|
| 569 | // =============================================
|
|---|
| 570 | //
|
|---|
| 571 | // 4: Returned probability of Gauss fit (calls: MHGausEvents::GetProb())
|
|---|
| 572 | //
|
|---|
| 573 | // Localized defects:
|
|---|
| 574 | // ==================
|
|---|
| 575 | //
|
|---|
| 576 | // 5: Gaus fit not OK (calls: MHGausEvents::IsGausFitOK())
|
|---|
| 577 | // 6: Fourier spectrum not OK (calls: MHGausEvents::IsFourierSpectrumOK())
|
|---|
| 578 | //
|
|---|
| 579 | Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 580 | {
|
|---|
| 581 |
|
|---|
| 582 | if (fHiGainArray->GetSize() <= idx)
|
|---|
| 583 | return kFALSE;
|
|---|
| 584 |
|
|---|
| 585 | const MHCalibrationRelTimePix &pix = (MHCalibrationRelTimePix&)(*this)[idx];
|
|---|
| 586 |
|
|---|
| 587 | switch (type)
|
|---|
| 588 | {
|
|---|
| 589 | case 0:
|
|---|
| 590 | val = pix.GetMean();
|
|---|
| 591 | break;
|
|---|
| 592 | case 1:
|
|---|
| 593 | val = pix.GetMeanErr();
|
|---|
| 594 | break;
|
|---|
| 595 | case 2:
|
|---|
| 596 | val = pix.GetSigma();
|
|---|
| 597 | break;
|
|---|
| 598 | case 3:
|
|---|
| 599 | val = pix.GetSigmaErr();
|
|---|
| 600 | break;
|
|---|
| 601 | case 4:
|
|---|
| 602 | val = pix.GetProb();
|
|---|
| 603 | break;
|
|---|
| 604 | case 5:
|
|---|
| 605 | if (!pix.IsGausFitOK())
|
|---|
| 606 | val = 1.;
|
|---|
| 607 | break;
|
|---|
| 608 | case 6:
|
|---|
| 609 | if (!pix.IsFourierSpectrumOK())
|
|---|
| 610 | val = 1.;
|
|---|
| 611 | break;
|
|---|
| 612 | default:
|
|---|
| 613 | return kFALSE;
|
|---|
| 614 | }
|
|---|
| 615 | return kTRUE;
|
|---|
| 616 | }
|
|---|
| 617 |
|
|---|
| 618 | // --------------------------------------------------------------------------
|
|---|
| 619 | //
|
|---|
| 620 | // Calls MHCalibrationPix::DrawClone() for pixel idx
|
|---|
| 621 | //
|
|---|
| 622 | void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
|
|---|
| 623 | {
|
|---|
| 624 | (*this)[idx].DrawClone();
|
|---|
| 625 | }
|
|---|