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