| 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 02/2004 <mailto:markus@ifae.es>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MHCalibrationChargeCam
|
|---|
| 29 | //
|
|---|
| 30 | // Fills the extracted signals of MExtractedSignalCam into the MH-classes:
|
|---|
| 31 | //
|
|---|
| 32 | // MHCalibrationChargeHiGainPix, MHCalibrationChargeLoGainPix for each pixel
|
|---|
| 33 | // and additionally for an average of the inner and the outer pixels, respectively.
|
|---|
| 34 | //
|
|---|
| 35 | // By default, subsequently the hi-gain classes are treated unless
|
|---|
| 36 | // more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
|
|---|
| 37 | // slices show saturation. In that case, the low-gain classes are treated.
|
|---|
| 38 | // If more than fNumLoGainSaturationLimit (default: 1%) of the overall
|
|---|
| 39 | // low-gain FADC slices saturate, the pixel is declared not valid and no further
|
|---|
| 40 | // treatment is pursued.
|
|---|
| 41 | //
|
|---|
| 42 | // The filled histograms are fitted to a Gaussian and the mean and sigma with
|
|---|
| 43 | // its errors and the fit probability are extracted. If none of these values are
|
|---|
| 44 | // NaN's and if the probability is bigger than fProbLimit (default: 0.5%), the fit
|
|---|
| 45 | // is declared valid. Otherwise, the fit is repeated within ranges of the previous mean
|
|---|
| 46 | // +- 5 sigma. In case that this does not help, the histogram means and RMS's are taken directly,
|
|---|
| 47 | // but the flag kFitValid is set to FALSE. Outliers of more than fPickUpLimit (default: 5) sigmas
|
|---|
| 48 | // from the mean are counted as PickUp events.
|
|---|
| 49 | //
|
|---|
| 50 | // Additionally, the slice number with the highest value is stored and a corresponding
|
|---|
| 51 | // histogram is filled. This histogram serves only for a rough cross-check if the
|
|---|
| 52 | // signal does not lie at the edges of chose extraction window.
|
|---|
| 53 | //
|
|---|
| 54 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
|---|
| 55 | // spectrum out of it and investigates if the projected frequencies follow an exponential
|
|---|
| 56 | // distribution. In case that the probability of the exponential fit is less than
|
|---|
| 57 | // fProbLimit, the pixel is declared HiGainOscillating or LoGainOscillating, respectively.
|
|---|
| 58 | //
|
|---|
| 59 | // The results are written into MCalibrationChargeCam.
|
|---|
| 60 | //
|
|---|
| 61 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 62 | #include "MHCalibrationChargeCam.h"
|
|---|
| 63 |
|
|---|
| 64 | #include <TVirtualPad.h>
|
|---|
| 65 | #include <TCanvas.h>
|
|---|
| 66 | #include <TPad.h>
|
|---|
| 67 |
|
|---|
| 68 | #include "MLog.h"
|
|---|
| 69 | #include "MLogManip.h"
|
|---|
| 70 |
|
|---|
| 71 | #include "MParList.h"
|
|---|
| 72 |
|
|---|
| 73 | #include "MHCalibrationChargeHiGainPix.h"
|
|---|
| 74 | #include "MHCalibrationChargeLoGainPix.h"
|
|---|
| 75 | #include "MHCalibrationChargePix.h"
|
|---|
| 76 |
|
|---|
| 77 | #include "MCalibrationChargeCam.h"
|
|---|
| 78 | #include "MCalibrationChargePix.h"
|
|---|
| 79 |
|
|---|
| 80 | #include "MGeomCam.h"
|
|---|
| 81 | #include "MGeomPix.h"
|
|---|
| 82 |
|
|---|
| 83 | #include "MBadPixelsCam.h"
|
|---|
| 84 | #include "MBadPixelsPix.h"
|
|---|
| 85 |
|
|---|
| 86 | #include "MRawEvtData.h"
|
|---|
| 87 | #include "MRawEvtPixelIter.h"
|
|---|
| 88 |
|
|---|
| 89 | #include "MExtractedSignalCam.h"
|
|---|
| 90 | #include "MExtractedSignalPix.h"
|
|---|
| 91 |
|
|---|
| 92 | ClassImp(MHCalibrationChargeCam);
|
|---|
| 93 |
|
|---|
| 94 | using namespace std;
|
|---|
| 95 |
|
|---|
| 96 | const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
|
|---|
| 97 | const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.01;
|
|---|
| 98 | //
|
|---|
| 99 | //
|
|---|
| 100 | //
|
|---|
| 101 | MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
|
|---|
| 102 | : fRawEvt(NULL), fGeom(NULL), fBadPixels(NULL)
|
|---|
| 103 | {
|
|---|
| 104 | fName = name ? name : "MHCalibrationChargeCam";
|
|---|
| 105 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
|---|
| 106 |
|
|---|
| 107 | fHiGainArray = new TObjArray;
|
|---|
| 108 | fHiGainArray->SetOwner();
|
|---|
| 109 |
|
|---|
| 110 | fLoGainArray = new TObjArray;
|
|---|
| 111 | fLoGainArray->SetOwner();
|
|---|
| 112 |
|
|---|
| 113 | fAverageHiGainInnerPix = new MHCalibrationChargeHiGainPix("AverageHiGainInnerPix","Average HiGain FADC sums of inner pixels");
|
|---|
| 114 | fAverageLoGainInnerPix = new MHCalibrationChargeLoGainPix("AverageLoGainInnerPix","Average LoGain FADC sums of inner pixels");
|
|---|
| 115 | fAverageHiGainOuterPix = new MHCalibrationChargeHiGainPix("AverageHiGainOuterPix","Average HiGain FADC sums of outer pixels");
|
|---|
| 116 | fAverageLoGainOuterPix = new MHCalibrationChargeLoGainPix("AverageLoGainOuterPix","Average LoGain FADC sums of outer pixels");
|
|---|
| 117 |
|
|---|
| 118 | /*
|
|---|
| 119 | fAverageHiGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerHiGainPix");
|
|---|
| 120 | fAverageHiGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterHiGainPix");
|
|---|
| 121 | fAverageLoGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerLoGainPix");
|
|---|
| 122 | fAverageLoGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterLoGainPix");
|
|---|
| 123 | */
|
|---|
| 124 | fAverageHiGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels HiGain");
|
|---|
| 125 | fAverageLoGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels LoGain");
|
|---|
| 126 | fAverageHiGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels HiGain");
|
|---|
| 127 | fAverageLoGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels LoGain");
|
|---|
| 128 |
|
|---|
| 129 | fAverageHiGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels HiGain");
|
|---|
| 130 | fAverageLoGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels LoGain");
|
|---|
| 131 | fAverageHiGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels HiGain");
|
|---|
| 132 | fAverageLoGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels LoGain");
|
|---|
| 133 |
|
|---|
| 134 | fAverageHiGainInnerPix->SetChargeFirst(-1000.);
|
|---|
| 135 | fAverageHiGainOuterPix->SetChargeFirst(-1000.);
|
|---|
| 136 |
|
|---|
| 137 | fAverageHiGainInnerPix->SetChargeLast(4000.);
|
|---|
| 138 | fAverageLoGainInnerPix->SetChargeLast(4000.);
|
|---|
| 139 | fAverageHiGainOuterPix->SetChargeLast(4000.);
|
|---|
| 140 | fAverageLoGainOuterPix->SetChargeLast(4000.);
|
|---|
| 141 |
|
|---|
| 142 | fAverageHiGainInnerPix->SetChargeNbins(4000);
|
|---|
| 143 | fAverageLoGainInnerPix->SetChargeNbins(4000);
|
|---|
| 144 | fAverageHiGainOuterPix->SetChargeNbins(4000);
|
|---|
| 145 | fAverageLoGainOuterPix->SetChargeNbins(4000);
|
|---|
| 146 |
|
|---|
| 147 | SetNumHiGainSaturationLimit();
|
|---|
| 148 | SetNumLoGainSaturationLimit();
|
|---|
| 149 |
|
|---|
| 150 | fNumInnerPixels = 0;
|
|---|
| 151 | fNumOuterPixels = 0;
|
|---|
| 152 | fNumExcluded = 0;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | // --------------------------------------------------------------------------
|
|---|
| 156 | //
|
|---|
| 157 | // Delete the TClonesArray of MHCalibrationChargePix containers
|
|---|
| 158 | // Delete the MHCalibrationPINDiode and the MHCalibrationBlindPix
|
|---|
| 159 | //
|
|---|
| 160 | // Delete the histograms if they exist
|
|---|
| 161 | //
|
|---|
| 162 | MHCalibrationChargeCam::~MHCalibrationChargeCam()
|
|---|
| 163 | {
|
|---|
| 164 | delete fHiGainArray;
|
|---|
| 165 | delete fLoGainArray;
|
|---|
| 166 |
|
|---|
| 167 | delete fAverageHiGainInnerPix;
|
|---|
| 168 | delete fAverageLoGainInnerPix;
|
|---|
| 169 | delete fAverageHiGainOuterPix;
|
|---|
| 170 | delete fAverageLoGainOuterPix;
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | // --------------------------------------------------------------------------
|
|---|
| 174 | //
|
|---|
| 175 | // Get i-th pixel (pixel number)
|
|---|
| 176 | //
|
|---|
| 177 | MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i)
|
|---|
| 178 | {
|
|---|
| 179 | return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | // --------------------------------------------------------------------------
|
|---|
| 183 | //
|
|---|
| 184 | // Get i-th pixel (pixel number)
|
|---|
| 185 | //
|
|---|
| 186 | const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i) const
|
|---|
| 187 | {
|
|---|
| 188 | return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | // --------------------------------------------------------------------------
|
|---|
| 192 | //
|
|---|
| 193 | // Get i-th pixel (pixel number)
|
|---|
| 194 | //
|
|---|
| 195 | MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i)
|
|---|
| 196 | {
|
|---|
| 197 | return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | // --------------------------------------------------------------------------
|
|---|
| 201 | //
|
|---|
| 202 | // Get i-th pixel (pixel number)
|
|---|
| 203 | //
|
|---|
| 204 | const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i) const
|
|---|
| 205 | {
|
|---|
| 206 | return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 | #if 0
|
|---|
| 211 | // --------------------------------------------------------------------------
|
|---|
| 212 | //
|
|---|
| 213 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
|---|
| 214 | // I don't know the reason
|
|---|
| 215 | //
|
|---|
| 216 | TObject *MHCalibrationChargeCam::Clone(const char *) const
|
|---|
| 217 | {
|
|---|
| 218 |
|
|---|
| 219 | const Int_t nhi = fHiGainArray->GetSize();
|
|---|
| 220 | const Int_t nlo = fLoGainArray->GetSize();
|
|---|
| 221 | //
|
|---|
| 222 | // FIXME, this might be done faster and more elegant, by direct copy.
|
|---|
| 223 | //
|
|---|
| 224 | MHCalibrationChargeCam *cam = (MHCalibrationChargeCam*)(this)->Clone("");
|
|---|
| 225 | // MHCalibrationChargeCam cam;
|
|---|
| 226 | // Copy(*cam);
|
|---|
| 227 |
|
|---|
| 228 | /*
|
|---|
| 229 | cam->fHiGainArray->Delete();
|
|---|
| 230 | cam->fLoGainArray->Delete();
|
|---|
| 231 |
|
|---|
| 232 | cam->fHiGainArray->Expand(nhi);
|
|---|
| 233 | cam->fLoGainArray->Expand(nlo);
|
|---|
| 234 |
|
|---|
| 235 | for (int i=0; i<nhi; i++)
|
|---|
| 236 | {
|
|---|
| 237 | delete (*cam->fHiGainArray)[i];
|
|---|
| 238 | (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
|
|---|
| 239 | }
|
|---|
| 240 | for (int i=0; i<nlo; i++)
|
|---|
| 241 | {
|
|---|
| 242 | delete (*cam->fLoGainArray)[i];
|
|---|
| 243 | (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
|
|---|
| 244 | }
|
|---|
| 245 | */
|
|---|
| 246 |
|
|---|
| 247 | /*
|
|---|
| 248 | delete cam->fAverageHiGainInnerPix;
|
|---|
| 249 | delete cam->fAverageLoGainInnerPix;
|
|---|
| 250 | delete cam->fAverageHiGainOuterPix;
|
|---|
| 251 | delete cam->fAverageLoGainOuterPix;
|
|---|
| 252 |
|
|---|
| 253 | cam->GetAverageHiGainInnerPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainInnerPix->Clone();
|
|---|
| 254 | cam->GetAverageLoGainInnerPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainInnerPix->Clone();
|
|---|
| 255 |
|
|---|
| 256 | cam->GetAverageHiGainOuterPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainOuterPix->Clone();
|
|---|
| 257 | cam->GetAverageLoGainOuterPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainOuterPix->Clone();
|
|---|
| 258 |
|
|---|
| 259 | fAverageHiGainInnerPix->Copy(cam->GetAverageHiGainInnerPix());
|
|---|
| 260 | fAverageLoGainInnerPix->Copy(cam->GetAverageLoGainInnerPix());
|
|---|
| 261 | fAverageHiGainOuterPix->Copy(cam->GetAverageHiGainOuterPix());
|
|---|
| 262 | fAverageLoGainOuterPix->Copy(cam->GetAverageLoGainOuterPix());
|
|---|
| 263 | */
|
|---|
| 264 |
|
|---|
| 265 | return cam;
|
|---|
| 266 | }
|
|---|
| 267 | #endif
|
|---|
| 268 | // --------------------------------------------------------------------------
|
|---|
| 269 | //
|
|---|
| 270 | // To setup the object we get the number of pixels from a MGeomCam object
|
|---|
| 271 | // in the Parameter list.
|
|---|
| 272 | //
|
|---|
| 273 | Bool_t MHCalibrationChargeCam::SetupFill(const MParList *pList)
|
|---|
| 274 | {
|
|---|
| 275 |
|
|---|
| 276 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
|---|
| 277 |
|
|---|
| 278 | if (!fRawEvt)
|
|---|
| 279 | {
|
|---|
| 280 | gLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
|---|
| 281 | return kFALSE;
|
|---|
| 282 | }
|
|---|
| 283 |
|
|---|
| 284 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
|---|
| 285 |
|
|---|
| 286 | if (!fGeom)
|
|---|
| 287 | {
|
|---|
| 288 | gLog << err << dbginf << "MGeomCam not found... aborting." << endl;
|
|---|
| 289 | return kFALSE;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | fHiGainArray->Delete();
|
|---|
| 293 | fLoGainArray->Delete();
|
|---|
| 294 |
|
|---|
| 295 | fAverageHiGainInnerPix->Init();
|
|---|
| 296 | fAverageLoGainInnerPix->Init();
|
|---|
| 297 | fAverageHiGainOuterPix->Init();
|
|---|
| 298 | fAverageLoGainOuterPix->Init();
|
|---|
| 299 |
|
|---|
| 300 | return kTRUE;
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | Bool_t MHCalibrationChargeCam::ReInit(MParList *pList)
|
|---|
| 304 | {
|
|---|
| 305 |
|
|---|
| 306 | fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
|
|---|
| 307 | if (!fBadPixels)
|
|---|
| 308 | {
|
|---|
| 309 | gLog << err << GetDescriptor() << ": ERROR: Could not find MBadPixelsCam ... aborting " << endl;
|
|---|
| 310 | return kFALSE;
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 | fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
|
|---|
| 315 | if (!fCam)
|
|---|
| 316 | {
|
|---|
| 317 | gLog << err << GetDescriptor() << ": ERROR: Could not find MCalibrationChargeCam ... aborting " << endl;
|
|---|
| 318 | return kFALSE;
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
|---|
| 322 | if (!signal)
|
|---|
| 323 | {
|
|---|
| 324 | gLog << err << "No argument in MExtractedSignalCam::ReInit... abort." << endl;
|
|---|
| 325 | return kFALSE;
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | const Int_t n = signal->GetSize();
|
|---|
| 329 |
|
|---|
| 330 | if (fHiGainArray->GetEntries()==0)
|
|---|
| 331 | {
|
|---|
| 332 | fHiGainArray->Expand(n);
|
|---|
| 333 |
|
|---|
| 334 | for (Int_t i=0; i<n; i++)
|
|---|
| 335 | {
|
|---|
| 336 | //
|
|---|
| 337 | // Oscillating pixels
|
|---|
| 338 | //
|
|---|
| 339 | (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
|
|---|
| 340 |
|
|---|
| 341 | if ((*fBadPixels)[i].IsBad())
|
|---|
| 342 | {
|
|---|
| 343 | fNumExcluded++;
|
|---|
| 344 | (*this)[i].SetExcluded();
|
|---|
| 345 | }
|
|---|
| 346 | (*this)[i].Init();
|
|---|
| 347 | (*this)[i].ChangeHistId(i);
|
|---|
| 348 | }
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 | if (fLoGainArray->GetEntries()==0)
|
|---|
| 353 | {
|
|---|
| 354 | fLoGainArray->Expand(n);
|
|---|
| 355 |
|
|---|
| 356 | for (Int_t i=0; i<n; i++)
|
|---|
| 357 | {
|
|---|
| 358 | (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
|
|---|
| 359 | //
|
|---|
| 360 | // Pixels with non-valid behavior
|
|---|
| 361 | //
|
|---|
| 362 | if ((*fBadPixels)[i].IsBad())
|
|---|
| 363 | (*this)(i).SetExcluded();
|
|---|
| 364 |
|
|---|
| 365 | (*this)(i).Init();
|
|---|
| 366 | (*this)(i).ChangeHistId(i);
|
|---|
| 367 | }
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 | *fLog << inf << GetDescriptor() << ": " << fNumExcluded << " excluded Pixels " << endl;
|
|---|
| 372 |
|
|---|
| 373 | return kTRUE;
|
|---|
| 374 | }
|
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 | // --------------------------------------------------------------------------
|
|---|
| 378 | Bool_t MHCalibrationChargeCam::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 379 | {
|
|---|
| 380 |
|
|---|
| 381 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
|---|
| 382 | if (!signal)
|
|---|
| 383 | {
|
|---|
| 384 | gLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
|
|---|
| 385 | return kFALSE;
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | Int_t n = signal->GetSize();
|
|---|
| 389 |
|
|---|
| 390 | if (fHiGainArray->GetEntries() != n)
|
|---|
| 391 | {
|
|---|
| 392 | gLog << err << "ERROR - Size mismatch... abort." << endl;
|
|---|
| 393 | return kFALSE;
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | if (fLoGainArray->GetEntries() != n)
|
|---|
| 397 | {
|
|---|
| 398 | gLog << err << "ERROR - Size mismatch... abort." << endl;
|
|---|
| 399 | return kFALSE;
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 | //
|
|---|
| 403 | // First the extracted signal
|
|---|
| 404 | //
|
|---|
| 405 | Float_t sumhiinnertot = 0.;
|
|---|
| 406 | Float_t sumloinnertot = 0.;
|
|---|
| 407 | Float_t sumhioutertot = 0.;
|
|---|
| 408 | Float_t sumlooutertot = 0.;
|
|---|
| 409 | Int_t sumhiinnersat = 0;
|
|---|
| 410 | Int_t sumloinnersat = 0;
|
|---|
| 411 | Int_t sumhioutersat = 0;
|
|---|
| 412 | Int_t sumlooutersat = 0;
|
|---|
| 413 |
|
|---|
| 414 | fNumInnerPixels = fNumOuterPixels = 0;
|
|---|
| 415 |
|
|---|
| 416 | for (int i=0; i<n; i++)
|
|---|
| 417 | {
|
|---|
| 418 |
|
|---|
| 419 | if ((*this)[i].IsExcluded())
|
|---|
| 420 | continue;
|
|---|
| 421 |
|
|---|
| 422 | const MExtractedSignalPix &pix = (*signal)[i];
|
|---|
| 423 |
|
|---|
| 424 | const Float_t sumhi = pix.GetExtractedSignalHiGain();
|
|---|
| 425 | const Float_t sumlo = pix.GetExtractedSignalLoGain();
|
|---|
| 426 |
|
|---|
| 427 | (*this)[i].FillHistAndArray(sumhi);
|
|---|
| 428 | (*this)(i).FillHistAndArray(sumlo);
|
|---|
| 429 |
|
|---|
| 430 | const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
|
|---|
| 431 | const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
|
|---|
| 432 |
|
|---|
| 433 | (*this)[i].SetSaturated(sathi);
|
|---|
| 434 | (*this)(i).SetSaturated(satlo);
|
|---|
| 435 |
|
|---|
| 436 | if (fGeom->GetPixRatio(i) == 1.)
|
|---|
| 437 | {
|
|---|
| 438 | sumhiinnertot += sumhi;
|
|---|
| 439 | sumloinnertot += sumlo;
|
|---|
| 440 | sumhiinnersat += sathi;
|
|---|
| 441 | sumloinnersat += satlo;
|
|---|
| 442 | fNumInnerPixels++;
|
|---|
| 443 | }
|
|---|
| 444 | else
|
|---|
| 445 | {
|
|---|
| 446 | sumhioutertot += sumhi;
|
|---|
| 447 | sumlooutertot += sumlo;
|
|---|
| 448 | sumhioutersat += sathi;
|
|---|
| 449 | sumlooutersat += satlo;
|
|---|
| 450 | fNumOuterPixels++;
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | }
|
|---|
| 454 |
|
|---|
| 455 | fAverageHiGainInnerPix->FillHistAndArray(sumhiinnertot/fNumInnerPixels);
|
|---|
| 456 | fAverageLoGainInnerPix->FillHistAndArray(sumloinnertot/fNumInnerPixels);
|
|---|
| 457 | fAverageHiGainOuterPix->FillHistAndArray(sumhioutertot/fNumOuterPixels);
|
|---|
| 458 | fAverageLoGainOuterPix->FillHistAndArray(sumlooutertot/fNumOuterPixels);
|
|---|
| 459 |
|
|---|
| 460 | fAverageHiGainInnerPix->SetSaturated((Float_t)sumhiinnersat/fNumInnerPixels);
|
|---|
| 461 | fAverageLoGainInnerPix->SetSaturated((Float_t)sumloinnersat/fNumInnerPixels);
|
|---|
| 462 | fAverageHiGainOuterPix->SetSaturated((Float_t)sumhioutersat/fNumOuterPixels);
|
|---|
| 463 | fAverageLoGainOuterPix->SetSaturated((Float_t)sumlooutersat/fNumOuterPixels);
|
|---|
| 464 |
|
|---|
| 465 | //
|
|---|
| 466 | // Now the times
|
|---|
| 467 | //
|
|---|
| 468 | sumhiinnertot = sumloinnertot = sumhioutertot = sumlooutertot = 0.;
|
|---|
| 469 | fNumInnerPixels = fNumOuterPixels = 0;
|
|---|
| 470 |
|
|---|
| 471 | MRawEvtPixelIter pixel(fRawEvt);
|
|---|
| 472 | while (pixel.Next())
|
|---|
| 473 | {
|
|---|
| 474 |
|
|---|
| 475 | const UInt_t pixid = pixel.GetPixelId();
|
|---|
| 476 |
|
|---|
| 477 | if ((*this)[pixid].IsExcluded())
|
|---|
| 478 | continue;
|
|---|
| 479 |
|
|---|
| 480 | const Int_t timehi = (Int_t)pixel.GetIdxMaxHiGainSample();
|
|---|
| 481 | const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample() + 15.;
|
|---|
| 482 |
|
|---|
| 483 | (*this)[pixid].FillAbsTime(timehi);
|
|---|
| 484 | (*this)(pixid).FillAbsTime(timelo);
|
|---|
| 485 |
|
|---|
| 486 | if (fGeom->GetPixRatio(pixel.GetPixelId()) == 1.)
|
|---|
| 487 | {
|
|---|
| 488 | sumhiinnertot += timehi;
|
|---|
| 489 | sumloinnertot += timelo;
|
|---|
| 490 | fNumInnerPixels++;
|
|---|
| 491 | }
|
|---|
| 492 | else
|
|---|
| 493 | {
|
|---|
| 494 | sumhioutertot += timehi;
|
|---|
| 495 | sumlooutertot += timelo;
|
|---|
| 496 | fNumOuterPixels++;
|
|---|
| 497 | }
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | fAverageHiGainInnerPix-> FillAbsTime(sumhiinnertot/fNumInnerPixels);
|
|---|
| 501 | fAverageLoGainInnerPix-> FillAbsTime(sumloinnertot/fNumInnerPixels);
|
|---|
| 502 | fAverageHiGainOuterPix-> FillAbsTime(sumhioutertot/fNumOuterPixels);
|
|---|
| 503 | fAverageLoGainOuterPix-> FillAbsTime(sumlooutertot/fNumOuterPixels);
|
|---|
| 504 |
|
|---|
| 505 | return kTRUE;
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | // --------------------------------------------------------------------------
|
|---|
| 509 | //
|
|---|
| 510 | // 1) Return if the charge distribution is already succesfully fitted
|
|---|
| 511 | // or if the histogram is empty
|
|---|
| 512 | // 2) Fit the histograms with a Gaussian
|
|---|
| 513 | // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
|
|---|
| 514 | // 4) Check for pickup noise
|
|---|
| 515 | // 5) Check the fourier spectrum
|
|---|
| 516 | // 5) Retrieve the results and store them in this class
|
|---|
| 517 | //
|
|---|
| 518 | Bool_t MHCalibrationChargeCam::Finalize()
|
|---|
| 519 | {
|
|---|
| 520 |
|
|---|
| 521 | for (int i=0; i<fHiGainArray->GetSize(); i++)
|
|---|
| 522 | {
|
|---|
| 523 |
|
|---|
| 524 | MCalibrationChargePix &pix = (*fCam)[i];
|
|---|
| 525 | MHCalibrationChargeHiGainPix &histhi = (*this)[i];
|
|---|
| 526 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 527 |
|
|---|
| 528 | FinalizeHiGainHists(histhi,pix,bad);
|
|---|
| 529 |
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | for (int i=0; i<fLoGainArray->GetSize(); i++)
|
|---|
| 533 | {
|
|---|
| 534 |
|
|---|
| 535 | if ((*this)(i).IsExcluded())
|
|---|
| 536 | continue;
|
|---|
| 537 |
|
|---|
| 538 | MHCalibrationChargeLoGainPix &histlo = (*this)(i);
|
|---|
| 539 | MCalibrationChargePix &pix = (*fCam)[i];
|
|---|
| 540 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
|---|
| 541 |
|
|---|
| 542 | FinalizeLoGainHists(histlo,pix,bad);
|
|---|
| 543 |
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | FinalizeHiGainHists(*fAverageHiGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
|
|---|
| 547 | FinalizeLoGainHists(*fAverageLoGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
|
|---|
| 548 | FinalizeHiGainHists(*fAverageHiGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
|
|---|
| 549 | FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
|
|---|
| 550 |
|
|---|
| 551 | fCam->GetAverageInnerPix()->SetSigmaCharge (fCam->GetAverageInnerPix()->GetSigmaCharge()
|
|---|
| 552 | *TMath::Sqrt((Float_t)fNumInnerPixels));
|
|---|
| 553 | fCam->GetAverageOuterPix()->SetSigmaCharge (fCam->GetAverageOuterPix()->GetSigmaCharge()
|
|---|
| 554 | *TMath::Sqrt((Float_t)fNumOuterPixels));
|
|---|
| 555 | fCam->GetAverageInnerPix()->SetSigmaChargeErr(fCam->GetAverageInnerPix()->GetSigmaChargeErr()
|
|---|
| 556 | *TMath::Sqrt((Float_t)fNumInnerPixels));
|
|---|
| 557 | fCam->GetAverageOuterPix()->SetSigmaChargeErr(fCam->GetAverageOuterPix()->GetSigmaChargeErr()
|
|---|
| 558 | *TMath::Sqrt((Float_t)fNumOuterPixels));
|
|---|
| 559 |
|
|---|
| 560 | return kTRUE;
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist,
|
|---|
| 564 | MCalibrationChargePix &pix,
|
|---|
| 565 | MBadPixelsPix &bad)
|
|---|
| 566 | {
|
|---|
| 567 |
|
|---|
| 568 | if (hist.IsEmpty())
|
|---|
| 569 | return;
|
|---|
| 570 |
|
|---|
| 571 | if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries())
|
|---|
| 572 | {
|
|---|
| 573 | pix.SetHiGainSaturation();
|
|---|
| 574 | bad.SetHiGainSaturation();
|
|---|
| 575 | return;
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | //
|
|---|
| 579 | // 2) Fit the Hi Gain histograms with a Gaussian
|
|---|
| 580 | //
|
|---|
| 581 | if (!hist.FitGaus())
|
|---|
| 582 | //
|
|---|
| 583 | // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
|
|---|
| 584 | //
|
|---|
| 585 | if (!hist.RepeatFit())
|
|---|
| 586 | {
|
|---|
| 587 | hist.BypassFit();
|
|---|
| 588 | bad.SetHiGainNotFitted();
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | //
|
|---|
| 592 | // 4) Check for pickup
|
|---|
| 593 | //
|
|---|
| 594 | hist.CountPickup();
|
|---|
| 595 |
|
|---|
| 596 | //
|
|---|
| 597 | // 5) Check for oscillations
|
|---|
| 598 | //
|
|---|
| 599 | hist.CreateFourierSpectrum();
|
|---|
| 600 |
|
|---|
| 601 | //
|
|---|
| 602 | // 6) Retrieve the results and store them in this class
|
|---|
| 603 | //
|
|---|
| 604 | pix.SetHiGainMeanCharge( hist.GetMean() );
|
|---|
| 605 | pix.SetHiGainMeanChargeErr( hist.GetMeanErr() );
|
|---|
| 606 | pix.SetHiGainSigmaCharge( hist.GetSigma() );
|
|---|
| 607 | pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
|
|---|
| 608 | pix.SetHiGainChargeProb ( hist.GetProb() );
|
|---|
| 609 |
|
|---|
| 610 | pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
|
|---|
| 611 | pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
|
|---|
| 612 |
|
|---|
| 613 | pix.SetHiGainNumPickup ( hist.GetPickup() );
|
|---|
| 614 |
|
|---|
| 615 | if (!hist.IsFourierSpectrumOK())
|
|---|
| 616 | bad.SetHiGainOscillating();
|
|---|
| 617 | }
|
|---|
| 618 |
|
|---|
| 619 |
|
|---|
| 620 | void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist,
|
|---|
| 621 | MCalibrationChargePix &pix,
|
|---|
| 622 | MBadPixelsPix &bad)
|
|---|
| 623 | {
|
|---|
| 624 |
|
|---|
| 625 |
|
|---|
| 626 | if (hist.IsEmpty())
|
|---|
| 627 | return;
|
|---|
| 628 |
|
|---|
| 629 | if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
|
|---|
| 630 | {
|
|---|
| 631 | pix.SetLoGainSaturation();
|
|---|
| 632 | bad.SetLoGainSaturation();
|
|---|
| 633 | return;
|
|---|
| 634 | }
|
|---|
| 635 | //
|
|---|
| 636 | // 2) Fit the Lo Gain histograms with a Gaussian
|
|---|
| 637 | //
|
|---|
| 638 | if (!hist.FitGaus())
|
|---|
| 639 | //
|
|---|
| 640 | // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
|
|---|
| 641 | //
|
|---|
| 642 | if (!hist.RepeatFit())
|
|---|
| 643 | {
|
|---|
| 644 | hist.BypassFit();
|
|---|
| 645 | bad.SetLoGainNotFitted();
|
|---|
| 646 | }
|
|---|
| 647 |
|
|---|
| 648 | //
|
|---|
| 649 | // 4) Check for pickup
|
|---|
| 650 | //
|
|---|
| 651 | hist.CountPickup();
|
|---|
| 652 |
|
|---|
| 653 | //
|
|---|
| 654 | // 5) Check for oscillations
|
|---|
| 655 | //
|
|---|
| 656 | hist.CreateFourierSpectrum();
|
|---|
| 657 |
|
|---|
| 658 | //
|
|---|
| 659 | // 6) Retrieve the results and store them in this class
|
|---|
| 660 | //
|
|---|
| 661 | pix.SetLoGainMeanCharge( hist.GetMean() );
|
|---|
| 662 | pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );
|
|---|
| 663 | pix.SetLoGainSigmaCharge( hist.GetSigma() );
|
|---|
| 664 | pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );
|
|---|
| 665 | pix.SetLoGainChargeProb ( hist.GetProb() );
|
|---|
| 666 |
|
|---|
| 667 | if (pix.IsHiGainSaturation())
|
|---|
| 668 | {
|
|---|
| 669 | pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
|
|---|
| 670 | pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | pix.SetLoGainNumPickup ( hist.GetPickup() );
|
|---|
| 674 |
|
|---|
| 675 | if (!hist.IsFourierSpectrumOK())
|
|---|
| 676 | bad.SetLoGainOscillating();
|
|---|
| 677 | }
|
|---|
| 678 |
|
|---|
| 679 | Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
|---|
| 680 | {
|
|---|
| 681 | return kTRUE;
|
|---|
| 682 | }
|
|---|
| 683 |
|
|---|
| 684 | // --------------------------------------------------------------------------
|
|---|
| 685 | //
|
|---|
| 686 | // What MHCamera needs in order to draw an individual pixel in the camera
|
|---|
| 687 | //
|
|---|
| 688 | void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
|
|---|
| 689 | {
|
|---|
| 690 |
|
|---|
| 691 | if (idx == -1)
|
|---|
| 692 | fAverageHiGainInnerPix->DrawClone();
|
|---|
| 693 | if (idx == -2)
|
|---|
| 694 | fAverageHiGainOuterPix->DrawClone();
|
|---|
| 695 | if (idx == -3)
|
|---|
| 696 | fAverageLoGainInnerPix->DrawClone();
|
|---|
| 697 | if (idx == -4)
|
|---|
| 698 | fAverageLoGainOuterPix->DrawClone();
|
|---|
| 699 | (*this)[idx].DrawClone();
|
|---|
| 700 |
|
|---|
| 701 | }
|
|---|
| 702 |
|
|---|
| 703 |
|
|---|
| 704 | void MHCalibrationChargeCam::Draw(const Option_t *opt)
|
|---|
| 705 | {
|
|---|
| 706 |
|
|---|
| 707 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
|---|
| 708 | pad->SetBorderMode(0);
|
|---|
| 709 |
|
|---|
| 710 | pad->Divide(2,2);
|
|---|
| 711 |
|
|---|
| 712 | pad->cd(1);
|
|---|
| 713 |
|
|---|
| 714 | if (!fAverageHiGainInnerPix->IsEmpty())
|
|---|
| 715 | gPad->SetLogy();
|
|---|
| 716 | fAverageHiGainInnerPix->Draw(opt);
|
|---|
| 717 |
|
|---|
| 718 | pad->cd(2);
|
|---|
| 719 |
|
|---|
| 720 | if (!fAverageLoGainInnerPix->IsEmpty())
|
|---|
| 721 | gPad->SetLogy();
|
|---|
| 722 | fAverageLoGainInnerPix->Draw(opt);
|
|---|
| 723 |
|
|---|
| 724 | pad->cd(3);
|
|---|
| 725 |
|
|---|
| 726 | if (!fAverageHiGainOuterPix->IsEmpty())
|
|---|
| 727 | gPad->SetLogy();
|
|---|
| 728 | fAverageHiGainOuterPix->Draw(opt);
|
|---|
| 729 |
|
|---|
| 730 | pad->cd(4);
|
|---|
| 731 |
|
|---|
| 732 | if (!fAverageLoGainOuterPix->IsEmpty())
|
|---|
| 733 | gPad->SetLogy();
|
|---|
| 734 | fAverageLoGainOuterPix->Draw(opt);
|
|---|
| 735 |
|
|---|
| 736 | }
|
|---|