| 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 | // MHCalibrationChargeCam
|
|---|
| 27 | //
|
|---|
| 28 | // Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes
|
|---|
| 29 | // MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
|
|---|
| 30 | //
|
|---|
| 31 | // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and
|
|---|
| 32 | // MHCalibrationCam::fLoGainArray
|
|---|
| 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::fAverageLoGainAreas
|
|---|
| 37 | //
|
|---|
| 38 | // - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
|
|---|
| 39 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and
|
|---|
| 40 | // MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 41 | //
|
|---|
| 42 | // Every signal is taken from MExtractedSignalCam and filled into a histogram and
|
|---|
| 43 | // an array, in order to perform a Fourier analysis (see MHGausEvents).
|
|---|
| 44 | // The signals are moreover averaged on an event-by-event basis and written into
|
|---|
| 45 | // the corresponding average pixels.
|
|---|
| 46 | //
|
|---|
| 47 | // Additionally, the (FADC slice) position of the maximum is stored in an Absolute
|
|---|
| 48 | // Arrival Time histogram. This histogram serves for a rough cross-check if the
|
|---|
| 49 | // signal does not lie at or outside the edges of the extraction window.
|
|---|
| 50 | //
|
|---|
| 51 | // The Charge histograms are fitted to a Gaussian, mean and sigma with its errors
|
|---|
| 52 | // and the fit probability are extracted. If none of these values are NaN's and
|
|---|
| 53 | // if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
|
|---|
| 54 | // the fit is declared valid.
|
|---|
| 55 | // Otherwise, the fit is repeated within ranges of the previous mean
|
|---|
| 56 | // +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
|
|---|
| 57 | // In case this does not make the fit valid, the histogram means and RMS's are
|
|---|
| 58 | // taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
|
|---|
| 59 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or
|
|---|
| 60 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
|
|---|
| 61 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 62 | //
|
|---|
| 63 | // Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas
|
|---|
| 64 | // from the mean are counted as Pickup events (stored in MHGausEvents::fPickup)
|
|---|
| 65 | //
|
|---|
| 66 | // Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
|
|---|
| 67 | // slices show saturation, the following flag is set:
|
|---|
| 68 | // - MCalibrationChargePix::SetHiGainSaturation();
|
|---|
| 69 | // In that case, the calibration constants are derived from the low-gain results.
|
|---|
| 70 | //
|
|---|
| 71 | // If more than fNumLoGainSaturationLimit (default: 1%) of the overall
|
|---|
| 72 | // low-gain FADC slices saturate, the following flags are set:
|
|---|
| 73 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
|
|---|
| 74 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun )
|
|---|
| 75 | //
|
|---|
| 76 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
|---|
| 77 | // spectrum and investigates if the projected fourier components follow an exponential
|
|---|
| 78 | // distribution. In case that the probability of the exponential fit is less than
|
|---|
| 79 | // MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
|
|---|
| 80 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
|
|---|
| 81 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
|
|---|
| 82 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
|---|
| 83 | //
|
|---|
| 84 | // This same procedure is performed for the average pixels.
|
|---|
| 85 | //
|
|---|
| 86 | // The following results are written into MCalibrationChargeCam:
|
|---|
| 87 | //
|
|---|
| 88 | // - MCalibrationPix::SetHiGainSaturation()
|
|---|
| 89 | // - MCalibrationPix::SetHiGainMean()
|
|---|
| 90 | // - MCalibrationPix::SetHiGainMeanErr()
|
|---|
| 91 | // - MCalibrationPix::SetHiGainSigma()
|
|---|
| 92 | // - MCalibrationPix::SetHiGainSigmaErr()
|
|---|
| 93 | // - MCalibrationPix::SetHiGainProb()
|
|---|
| 94 | // - MCalibrationPix::SetHiGainNumPickup()
|
|---|
| 95 | //
|
|---|
| 96 | // - MCalibrationPix::SetLoGainMean()
|
|---|
| 97 | // - MCalibrationPix::SetLoGainMeanErr()
|
|---|
| 98 | // - MCalibrationPix::SetLoGainSigma()
|
|---|
| 99 | // - MCalibrationPix::SetLoGainSigmaErr()
|
|---|
| 100 | // - MCalibrationPix::SetLoGainProb()
|
|---|
| 101 | // - MCalibrationPix::SetLoGainNumPickup()
|
|---|
| 102 | //
|
|---|
| 103 | // - MCalibrationChargePix::SetAbsTimeMean()
|
|---|
| 104 | // - MCalibrationChargePix::SetAbsTimeRms()
|
|---|
| 105 | //
|
|---|
| 106 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
|---|
| 107 | // the number involved pixels in order to be able to compare it to the average of
|
|---|
| 108 | // sigmas in the camera.
|
|---|
| 109 | //
|
|---|
| 110 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 111 | #include "MHCalibrationChargeCam.h"
|
|---|
| 112 | #include "MHCalibrationCam.h"
|
|---|
| 113 |
|
|---|
| 114 | #include "MLog.h"
|
|---|
| 115 | #include "MLogManip.h"
|
|---|
| 116 |
|
|---|
| 117 | #include "MParList.h"
|
|---|
| 118 |
|
|---|
| 119 | #include "MHCalibrationChargeHiGainPix.h"
|
|---|
| 120 | #include "MHCalibrationChargeLoGainPix.h"
|
|---|
| 121 | #include "MHCalibrationChargePix.h"
|
|---|
| 122 |
|
|---|
| 123 | #include "MCalibrationChargeCam.h"
|
|---|
| 124 | #include "MCalibrationChargePix.h"
|
|---|
| 125 |
|
|---|
| 126 | #include "MGeomCam.h"
|
|---|
| 127 | #include "MGeomPix.h"
|
|---|
| 128 |
|
|---|
| 129 | #include "MHGausEvents.h"
|
|---|
| 130 |
|
|---|
| 131 | #include "MBadPixelsCam.h"
|
|---|
| 132 | #include "MBadPixelsPix.h"
|
|---|
| 133 |
|
|---|
| 134 | #include "MRawEvtData.h"
|
|---|
| 135 | #include "MRawEvtPixelIter.h"
|
|---|
| 136 |
|
|---|
| 137 | #include "MExtractedSignalCam.h"
|
|---|
| 138 | #include "MExtractedSignalPix.h"
|
|---|
| 139 |
|
|---|
| 140 | ClassImp(MHCalibrationChargeCam);
|
|---|
| 141 |
|
|---|
| 142 | using namespace std;
|
|---|
| 143 |
|
|---|
| 144 | const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
|
|---|
| 145 | const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
|
|---|
| 146 | // --------------------------------------------------------------------------
|
|---|
| 147 | //
|
|---|
| 148 | // Default Constructor.
|
|---|
| 149 | //
|
|---|
| 150 | // Sets:
|
|---|
| 151 | // - all pointers to NULL
|
|---|
| 152 | //
|
|---|
| 153 | // Initializes:
|
|---|
| 154 | // - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
|
|---|
| 155 | // - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
|
|---|
| 156 | //
|
|---|
| 157 | MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
|
|---|
| 158 | : fRawEvt(NULL)
|
|---|
| 159 | {
|
|---|
| 160 | fName = name ? name : "MHCalibrationChargeCam";
|
|---|
| 161 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
|---|
| 162 |
|
|---|
| 163 | SetNumHiGainSaturationLimit();
|
|---|
| 164 | SetNumLoGainSaturationLimit();
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | // --------------------------------------------------------------------------
|
|---|
| 168 | //
|
|---|
| 169 | // Gets the pointers to:
|
|---|
| 170 | // - MRawEvtData
|
|---|
| 171 | //
|
|---|
| 172 | Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
|
|---|
| 173 | {
|
|---|
| 174 |
|
|---|
| 175 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
|---|
| 176 | if (!fRawEvt)
|
|---|
| 177 | {
|
|---|
| 178 | *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
|---|
| 179 | return kFALSE;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | return kTRUE;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | // --------------------------------------------------------------------------
|
|---|
| 186 | //
|
|---|
| 187 | // Gets or creates the pointers to:
|
|---|
| 188 | // - MCalibrationChargeCam
|
|---|
| 189 | //
|
|---|
| 190 | // Searches pointer to:
|
|---|
| 191 | // - MExtractedSignalCam
|
|---|
| 192 | //
|
|---|
| 193 | // Initializes, if empty to MGeomCam::GetNumPixels():
|
|---|
| 194 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
|---|
| 195 | //
|
|---|
| 196 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
|---|
| 197 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 198 | //
|
|---|
| 199 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
|---|
| 200 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 201 | //
|
|---|
| 202 | // Calls MHCalibrationCam::InitHists() for every entry in:
|
|---|
| 203 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
|---|
| 204 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 205 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 206 | //
|
|---|
| 207 | // Sets Titles and Names for the Charge Histograms:
|
|---|
| 208 | // - MHCalibrationCam::fAverageHiGainAreas
|
|---|
| 209 | // - MHCalibrationCam::fAverageHiGainSectors
|
|---|
| 210 | //
|
|---|
| 211 | // Sets number of bins to MHCalibrationCam::fAverageNbins for:
|
|---|
| 212 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
|---|
| 213 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
|---|
| 214 | //
|
|---|
| 215 | Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
|
|---|
| 216 | {
|
|---|
| 217 |
|
|---|
| 218 | fCam = (MCalibrationCam*)pList->FindCreateObj("MCalibrationChargeCam");
|
|---|
| 219 | if (!fCam)
|
|---|
| 220 | return kFALSE;
|
|---|
| 221 |
|
|---|
| 222 | MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
|---|
| 223 | if (!signal)
|
|---|
| 224 | {
|
|---|
| 225 | *fLog << err << "MExtractedSignalCam not found... abort." << endl;
|
|---|
| 226 | return kFALSE;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | const Int_t npixels = fGeom->GetNumPixels();
|
|---|
| 230 | const Int_t nsectors = fGeom->GetNumSectors();
|
|---|
| 231 | const Int_t nareas = fGeom->GetNumAreas();
|
|---|
| 232 |
|
|---|
| 233 | if (fHiGainArray->GetEntries()==0)
|
|---|
| 234 | {
|
|---|
| 235 | fHiGainArray->Expand(npixels);
|
|---|
| 236 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 237 | {
|
|---|
| 238 | (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
|
|---|
| 239 | InitHists((*this)[i],(*fBadPixels)[i],i);
|
|---|
| 240 | }
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | if (fLoGainArray->GetEntries()==0)
|
|---|
| 244 | {
|
|---|
| 245 | fLoGainArray->Expand(npixels);
|
|---|
| 246 |
|
|---|
| 247 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 248 | {
|
|---|
| 249 | (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
|
|---|
| 250 | InitHists((*this)(i),(*fBadPixels)[i],i);
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | if (fAverageHiGainAreas->GetEntries()==0)
|
|---|
| 256 | {
|
|---|
| 257 | fAverageHiGainAreas->Expand(nareas);
|
|---|
| 258 |
|
|---|
| 259 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 260 | {
|
|---|
| 261 | (*fAverageHiGainAreas)[j] =
|
|---|
| 262 | new MHCalibrationChargeHiGainPix("AverageHiGainArea",
|
|---|
| 263 | "Average HiGain FADC sums area idx ");
|
|---|
| 264 |
|
|---|
| 265 | InitHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j);
|
|---|
| 266 |
|
|---|
| 267 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
|---|
| 268 |
|
|---|
| 269 | hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Area Idx ");
|
|---|
| 270 | hist.SetNbins(fAverageNbins);
|
|---|
| 271 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
|
|---|
| 272 | }
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 | if (fAverageLoGainAreas->GetEntries()==0)
|
|---|
| 276 | {
|
|---|
| 277 | fAverageLoGainAreas->Expand(nareas);
|
|---|
| 278 |
|
|---|
| 279 | for (Int_t j=0; j<nareas; j++)
|
|---|
| 280 | {
|
|---|
| 281 | (*fAverageLoGainAreas)[j] =
|
|---|
| 282 | new MHCalibrationChargeLoGainPix("AverageLoGainArea",
|
|---|
| 283 | "Average LoGain FADC sums of pixel area idx ");
|
|---|
| 284 |
|
|---|
| 285 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
|---|
| 286 |
|
|---|
| 287 | InitHists(hist,fCam->GetAverageBadArea(j),j);
|
|---|
| 288 |
|
|---|
| 289 | hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Area Idx ");
|
|---|
| 290 | hist.SetNbins(fAverageNbins);
|
|---|
| 291 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
|
|---|
| 292 |
|
|---|
| 293 | }
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | if (fAverageHiGainSectors->GetEntries()==0)
|
|---|
| 297 | {
|
|---|
| 298 | fAverageHiGainSectors->Expand(nsectors);
|
|---|
| 299 |
|
|---|
| 300 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 301 | {
|
|---|
| 302 | (*fAverageHiGainSectors)[j] =
|
|---|
| 303 | new MHCalibrationChargeHiGainPix("AverageHiGainSector",
|
|---|
| 304 | "Average HiGain FADC sums of pixel sector ");
|
|---|
| 305 |
|
|---|
| 306 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
|---|
| 307 |
|
|---|
| 308 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
|---|
| 309 |
|
|---|
| 310 | hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
|
|---|
| 311 | hist.SetNbins(fAverageNbins);
|
|---|
| 312 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
|
|---|
| 313 |
|
|---|
| 314 | }
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | if (fAverageLoGainSectors->GetEntries()==0)
|
|---|
| 318 | {
|
|---|
| 319 | fAverageLoGainSectors->Expand(nsectors);
|
|---|
| 320 |
|
|---|
| 321 | for (Int_t j=0; j<nsectors; j++)
|
|---|
| 322 | {
|
|---|
| 323 | (*fAverageLoGainSectors)[j] =
|
|---|
| 324 | new MHCalibrationChargeLoGainPix("AverageLoGainSector",
|
|---|
| 325 | "Average LoGain FADC sums of pixel sector ");
|
|---|
| 326 |
|
|---|
| 327 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
|---|
| 328 |
|
|---|
| 329 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
|---|
| 330 |
|
|---|
| 331 | hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
|
|---|
| 332 | hist.SetNbins(fAverageNbins);
|
|---|
| 333 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
|
|---|
| 334 |
|
|---|
| 335 | }
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | return kTRUE;
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 | // --------------------------------------------------------------------------
|
|---|
| 343 | //
|
|---|
| 344 | // Retrieves from MExtractedSignalCam:
|
|---|
| 345 | // - first used LoGain FADC slice
|
|---|
| 346 | //
|
|---|
| 347 | // Retrieves from MGeomCam:
|
|---|
| 348 | // - number of pixels
|
|---|
| 349 | // - number of pixel areas
|
|---|
| 350 | // - number of sectors
|
|---|
| 351 | //
|
|---|
| 352 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
|---|
| 353 | //
|
|---|
| 354 | // 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
|
|---|
| 355 | // - MExtractedSignalPix::GetExtractedSignalHiGain();
|
|---|
| 356 | // - MExtractedSignalPix::GetExtractedSignalLoGain();
|
|---|
| 357 | //
|
|---|
| 358 | // 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
|
|---|
| 359 | // - MExtractedSignalPix::GetNumHiGainSaturated();
|
|---|
| 360 | // - MExtractedSignalPix::GetNumLoGainSaturated();
|
|---|
| 361 | //
|
|---|
| 362 | // 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
|
|---|
| 363 | // - MRawEvtPixelIter::GetIdxMaxHiGainSample();
|
|---|
| 364 | // - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
|
|---|
| 365 | //
|
|---|
| 366 | Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
|
|---|
| 367 | {
|
|---|
| 368 |
|
|---|
| 369 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
|---|
| 370 | if (!signal)
|
|---|
| 371 | {
|
|---|
| 372 | *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
|
|---|
| 373 | return kFALSE;
|
|---|
| 374 | }
|
|---|
| 375 |
|
|---|
| 376 | const Int_t npixels = fGeom->GetNumPixels();
|
|---|
| 377 | const Int_t nareas = fGeom->GetNumAreas();
|
|---|
| 378 | const Int_t nsectors = fGeom->GetNumSectors();
|
|---|
| 379 | const Int_t lofirst = signal->GetFirstUsedSliceLoGain();
|
|---|
| 380 |
|
|---|
| 381 | Float_t sumhiarea [nareas], sumloarea [nareas], timehiarea [nareas], timeloarea [nareas];
|
|---|
| 382 | Float_t sumhisector[nsectors], sumlosector[nsectors], timehisector[nsectors], timelosector[nsectors];
|
|---|
| 383 | Int_t sathiarea [nareas], satloarea [nareas];
|
|---|
| 384 | Int_t sathisector[nsectors], satlosector[nsectors];
|
|---|
| 385 |
|
|---|
| 386 | for (UInt_t j=0; j<nareas; j++)
|
|---|
| 387 | {
|
|---|
| 388 | sumhiarea [j] = sumloarea [j] = timehiarea [j] = timeloarea [j] = 0.;
|
|---|
| 389 | sathiarea [j] = satloarea [j] = 0;
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | for (UInt_t j=0; j<nsectors; j++)
|
|---|
| 393 | {
|
|---|
| 394 | sumhisector[j] = sumlosector[j] = timehisector[j] = timelosector[j] = 0.;
|
|---|
| 395 | sathisector[j] = satlosector[j] = 0;
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 | for (Int_t i=0; i<npixels; i++)
|
|---|
| 400 | {
|
|---|
| 401 |
|
|---|
| 402 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
|---|
| 403 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
|---|
| 404 |
|
|---|
| 405 | if (histhi.IsExcluded())
|
|---|
| 406 | continue;
|
|---|
| 407 |
|
|---|
| 408 | const MExtractedSignalPix &pix = (*signal)[i];
|
|---|
| 409 |
|
|---|
| 410 | const Float_t sumhi = pix.GetExtractedSignalHiGain();
|
|---|
| 411 | const Float_t sumlo = pix.GetExtractedSignalLoGain();
|
|---|
| 412 |
|
|---|
| 413 | histhi.FillHistAndArray(sumhi);
|
|---|
| 414 | histlo.FillHistAndArray(sumlo);
|
|---|
| 415 |
|
|---|
| 416 | const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
|
|---|
| 417 | const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
|
|---|
| 418 |
|
|---|
| 419 | histhi.SetSaturated(sathi);
|
|---|
| 420 | histlo.SetSaturated(satlo);
|
|---|
| 421 |
|
|---|
| 422 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
|---|
| 423 | const Int_t sector = (*fGeom)[i].GetSector();
|
|---|
| 424 |
|
|---|
| 425 | sumhiarea[aidx] += sumhi;
|
|---|
| 426 | sumloarea[aidx] += sumlo;
|
|---|
| 427 | sathiarea[aidx] += sathi;
|
|---|
| 428 | satloarea[aidx] += satlo;
|
|---|
| 429 |
|
|---|
| 430 | sumhisector[sector] += sumhi;
|
|---|
| 431 | sumlosector[sector] += sumlo;
|
|---|
| 432 | sathisector[sector] += sathi;
|
|---|
| 433 | satlosector[sector] += satlo;
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | MRawEvtPixelIter pixel(fRawEvt);
|
|---|
| 437 | while (pixel.Next())
|
|---|
| 438 | {
|
|---|
| 439 |
|
|---|
| 440 | const UInt_t pixid = pixel.GetPixelId();
|
|---|
| 441 |
|
|---|
| 442 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
|
|---|
| 443 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
|
|---|
| 444 |
|
|---|
| 445 | if (histhi.IsExcluded())
|
|---|
| 446 | continue;
|
|---|
| 447 |
|
|---|
| 448 | const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
|
|---|
| 449 | const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
|
|---|
| 450 |
|
|---|
| 451 | histhi.FillAbsTime(timehi);
|
|---|
| 452 | histlo.FillAbsTime(timelo);
|
|---|
| 453 |
|
|---|
| 454 | const Int_t aidx = (*fGeom)[pixid].GetAidx();
|
|---|
| 455 | const Int_t sector = (*fGeom)[pixid].GetSector();
|
|---|
| 456 |
|
|---|
| 457 | timehiarea[aidx] += timehi;
|
|---|
| 458 | timeloarea[aidx] += timelo;
|
|---|
| 459 |
|
|---|
| 460 | timehisector[sector] += timehi;
|
|---|
| 461 | timelosector[sector] += timelo;
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | for (UInt_t j=0; j<nareas; j++)
|
|---|
| 465 | {
|
|---|
| 466 |
|
|---|
| 467 | const Int_t npix = fAverageAreaNum[j];
|
|---|
| 468 |
|
|---|
| 469 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
|---|
| 470 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
|---|
| 471 |
|
|---|
| 472 | hipix.FillHistAndArray(sumhiarea[j]/npix);
|
|---|
| 473 | lopix.FillHistAndArray(sumloarea[j]/npix);
|
|---|
| 474 |
|
|---|
| 475 | hipix.SetSaturated((Float_t)sathiarea[j]/npix);
|
|---|
| 476 | lopix.SetSaturated((Float_t)satloarea[j]/npix);
|
|---|
| 477 |
|
|---|
| 478 | hipix.FillAbsTime(timehiarea[j]/npix);
|
|---|
| 479 | lopix.FillAbsTime(timeloarea[j]/npix);
|
|---|
| 480 |
|
|---|
| 481 | }
|
|---|
| 482 |
|
|---|
| 483 | for (UInt_t j=0; j<nsectors; j++)
|
|---|
| 484 | {
|
|---|
| 485 |
|
|---|
| 486 | const Int_t npix = fAverageSectorNum[j];
|
|---|
| 487 |
|
|---|
| 488 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
|---|
| 489 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
|---|
| 490 |
|
|---|
| 491 | hipix.FillHistAndArray(sumhisector[j]/npix);
|
|---|
| 492 | lopix.FillHistAndArray(sumlosector[j]/npix);
|
|---|
| 493 |
|
|---|
| 494 | hipix.SetSaturated((Float_t)sathisector[j]/npix);
|
|---|
| 495 | lopix.SetSaturated((Float_t)satlosector[j]/npix);
|
|---|
| 496 |
|
|---|
| 497 | hipix.FillAbsTime(timehisector[j]/npix);
|
|---|
| 498 | lopix.FillAbsTime(timelosector[j]/npix);
|
|---|
| 499 |
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | return kTRUE;
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | // --------------------------------------------------------------------------
|
|---|
| 506 | //
|
|---|
| 507 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
|---|
| 508 | //
|
|---|
| 509 | // 1) Returns if the pixel is excluded.
|
|---|
| 510 | // 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
|
|---|
| 511 | // or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
|
|---|
| 512 | // 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
|
|---|
| 513 | // MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
|
|---|
| 514 | // otherwise the Hi-Gain ones.
|
|---|
| 515 | // 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
|
|---|
| 516 | // with the flags:
|
|---|
| 517 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
|
|---|
| 518 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
|
|---|
| 519 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
|
|---|
| 520 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
|
|---|
| 521 | //
|
|---|
| 522 | Bool_t MHCalibrationChargeCam::FinalizeHists()
|
|---|
| 523 | {
|
|---|
| 524 |
|
|---|
| 525 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
|---|
| 526 | {
|
|---|
| 527 |
|
|---|
| 528 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
|---|
| 529 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
|---|
| 530 |
|
|---|
| 531 | if (histhi.IsExcluded())
|
|---|
| 532 | continue;
|
|---|
| 533 |
|
|---|
| 534 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 535 | {
|
|---|
| 536 | pix.SetHiGainSaturation();
|
|---|
| 537 | histhi.CreateFourierSpectrum();
|
|---|
| 538 | continue;
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
|
|---|
| 542 | pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
|
|---|
| 543 | }
|
|---|
| 544 |
|
|---|
| 545 | for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
|
|---|
| 546 | {
|
|---|
| 547 |
|
|---|
| 548 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
|---|
| 549 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 550 |
|
|---|
| 551 | if (histlo.IsExcluded())
|
|---|
| 552 | continue;
|
|---|
| 553 |
|
|---|
| 554 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
|---|
| 555 | {
|
|---|
| 556 | *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
|
|---|
| 557 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
|---|
| 558 | histlo.CreateFourierSpectrum();
|
|---|
| 559 | continue;
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
|---|
| 563 |
|
|---|
| 564 | if (pix.IsHiGainSaturation())
|
|---|
| 565 | {
|
|---|
| 566 | pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
|
|---|
| 567 | pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
|
|---|
| 568 | }
|
|---|
| 569 | }
|
|---|
| 570 |
|
|---|
| 571 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
|---|
| 572 | {
|
|---|
| 573 |
|
|---|
| 574 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
|---|
| 575 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
|---|
| 576 |
|
|---|
| 577 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 578 | {
|
|---|
| 579 | pix.SetHiGainSaturation();
|
|---|
| 580 | histhi.CreateFourierSpectrum();
|
|---|
| 581 | continue;
|
|---|
| 582 | }
|
|---|
| 583 |
|
|---|
| 584 | pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
|
|---|
| 585 | pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
|
|---|
| 586 | }
|
|---|
| 587 |
|
|---|
| 588 | for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
|
|---|
| 589 | {
|
|---|
| 590 |
|
|---|
| 591 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
|---|
| 592 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
|---|
| 593 |
|
|---|
| 594 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
|---|
| 595 | {
|
|---|
| 596 | *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
|
|---|
| 597 | histlo.CreateFourierSpectrum();
|
|---|
| 598 | continue;
|
|---|
| 599 | }
|
|---|
| 600 |
|
|---|
| 601 | if (pix.IsHiGainSaturation())
|
|---|
| 602 | {
|
|---|
| 603 | pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
|
|---|
| 604 | pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
|
|---|
| 605 | }
|
|---|
| 606 | }
|
|---|
| 607 |
|
|---|
| 608 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
|---|
| 609 | {
|
|---|
| 610 |
|
|---|
| 611 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
|---|
| 612 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
|---|
| 613 |
|
|---|
| 614 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
|---|
| 615 | {
|
|---|
| 616 | pix.SetHiGainSaturation();
|
|---|
| 617 | histhi.CreateFourierSpectrum();
|
|---|
| 618 | continue;
|
|---|
| 619 | }
|
|---|
| 620 |
|
|---|
| 621 | pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
|
|---|
| 622 | pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 625 | for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
|
|---|
| 626 | {
|
|---|
| 627 |
|
|---|
| 628 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
|---|
| 629 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
|---|
| 630 | MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
|
|---|
| 631 |
|
|---|
| 632 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
|---|
| 633 | {
|
|---|
| 634 | *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
|
|---|
| 635 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
|---|
| 636 | histlo.CreateFourierSpectrum();
|
|---|
| 637 | continue;
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 | if (pix.IsHiGainSaturation())
|
|---|
| 641 | {
|
|---|
| 642 | pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
|
|---|
| 643 | pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
|
|---|
| 644 | }
|
|---|
| 645 | }
|
|---|
| 646 |
|
|---|
| 647 | //
|
|---|
| 648 | // Perform the fitting for the High Gain (done in MHCalibrationCam)
|
|---|
| 649 | //
|
|---|
| 650 | FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
|---|
| 651 | MBadPixelsPix::kHiGainNotFitted,
|
|---|
| 652 | MBadPixelsPix::kHiGainOscillating);
|
|---|
| 653 | //
|
|---|
| 654 | // Perform the fitting for the Low Gain (done in MHCalibrationCam)
|
|---|
| 655 | //
|
|---|
| 656 | FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
|---|
| 657 | MBadPixelsPix::kLoGainNotFitted,
|
|---|
| 658 | MBadPixelsPix::kLoGainOscillating);
|
|---|
| 659 |
|
|---|
| 660 | return kTRUE;
|
|---|
| 661 | }
|
|---|
| 662 |
|
|---|
| 663 | // --------------------------------------------------------------------------
|
|---|
| 664 | //
|
|---|
| 665 | // Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
|
|---|
| 666 | // - MBadPixelsPix::kLoGainSaturation
|
|---|
| 667 | //
|
|---|
| 668 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
|---|
| 669 | // - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
|
|---|
| 670 | // - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
|
|---|
| 671 | // - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
|
|---|
| 672 | // - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
|
|---|
| 673 | //
|
|---|
| 674 | void MHCalibrationChargeCam::FinalizeBadPixels()
|
|---|
| 675 | {
|
|---|
| 676 |
|
|---|
| 677 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
|---|
| 678 | {
|
|---|
| 679 |
|
|---|
| 680 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 681 | MCalibrationPix &pix = (*fCam)[i];
|
|---|
| 682 |
|
|---|
| 683 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
|
|---|
| 684 | if (!pix.IsHiGainSaturation())
|
|---|
| 685 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 686 |
|
|---|
| 687 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
|
|---|
| 688 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 689 |
|
|---|
| 690 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
|
|---|
| 691 | if (pix.IsHiGainSaturation())
|
|---|
| 692 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 693 |
|
|---|
| 694 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
|
|---|
| 695 | if (pix.IsHiGainSaturation())
|
|---|
| 696 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
|---|
| 697 |
|
|---|
| 698 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
|
|---|
| 699 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
|---|
| 700 | }
|
|---|
| 701 | }
|
|---|
| 702 |
|
|---|
| 703 | // --------------------------------------------------------------------------
|
|---|
| 704 | //
|
|---|
| 705 | // Dummy, needed by MCamEvent
|
|---|
| 706 | //
|
|---|
| 707 | Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 708 | {
|
|---|
| 709 | return kTRUE;
|
|---|
| 710 | }
|
|---|
| 711 |
|
|---|
| 712 | // --------------------------------------------------------------------------
|
|---|
| 713 | //
|
|---|
| 714 | // Calls MHGausEvents::DrawClone() for pixel idx
|
|---|
| 715 | //
|
|---|
| 716 | void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
|
|---|
| 717 | {
|
|---|
| 718 | (*this)[idx].DrawClone();
|
|---|
| 719 | }
|
|---|
| 720 |
|
|---|