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 | // MHCalibrationHiLoCam
|
---|
27 | //
|
---|
28 | // Fills the extracted high-gain low-gain charge ratios of MArrivalTimeCam into
|
---|
29 | // the MHCalibrationPix-classes MHCalibrationPix for every:
|
---|
30 | //
|
---|
31 | // - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray
|
---|
32 | // or MHCalibrationCam::fHiGainArray, respectively, depending if
|
---|
33 | // MArrivalTimePix::IsLoGainUsed() is set.
|
---|
34 | //
|
---|
35 | // - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
|
---|
36 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
|
---|
37 | // MHCalibrationCam::fAverageHiGainAreas
|
---|
38 | //
|
---|
39 | // - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
|
---|
40 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors
|
---|
41 | // and MHCalibrationCam::fAverageHiGainSectors
|
---|
42 | //
|
---|
43 | // The histograms are fitted to a Gaussian, mean and sigma with its errors
|
---|
44 | // and the fit probability are extracted. If none of these values are NaN's and
|
---|
45 | // if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
|
---|
46 | // the fit is declared valid.
|
---|
47 | // Otherwise, the fit is repeated within ranges of the previous mean
|
---|
48 | // +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
|
---|
49 | // In case this does not make the fit valid, the histogram means and RMS's are
|
---|
50 | // taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
|
---|
51 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiLoNotFitted ) and
|
---|
52 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
53 | //
|
---|
54 | // Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas
|
---|
55 | // from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup)
|
---|
56 | //
|
---|
57 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
---|
58 | // spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the
|
---|
59 | // projected fourier components follow an exponential distribution.
|
---|
60 | // In case that the probability of the exponential fit is less than
|
---|
61 | // MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
|
---|
62 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiLoOscillating ) and
|
---|
63 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
64 | //
|
---|
65 | // This same procedure is performed for the average pixels.
|
---|
66 | //
|
---|
67 | // The following results are written into MCalibrationHiLoCam:
|
---|
68 | //
|
---|
69 | // - MCalibrationPix::SetMean()
|
---|
70 | // - MCalibrationPix::SetMeanErr()
|
---|
71 | // - MCalibrationPix::SetSigma()
|
---|
72 | // - MCalibrationPix::SetSigmaErr()
|
---|
73 | // - MCalibrationPix::SetProb()
|
---|
74 | // - MCalibrationPix::SetNumPickup()
|
---|
75 | //
|
---|
76 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
---|
77 | // the number involved pixels in order to be able to compare it to the average of
|
---|
78 | // sigmas in the camera.
|
---|
79 | //
|
---|
80 | /////////////////////////////////////////////////////////////////////////////
|
---|
81 | #include "MHCalibrationHiLoCam.h"
|
---|
82 | #include "MHCalibrationPix.h"
|
---|
83 |
|
---|
84 | #include "MLog.h"
|
---|
85 | #include "MLogManip.h"
|
---|
86 |
|
---|
87 | #include "MParList.h"
|
---|
88 |
|
---|
89 | #include "MCalibrationHiLoCam.h"
|
---|
90 | #include "MCalibrationCam.h"
|
---|
91 | #include "MCalibrationPix.h"
|
---|
92 |
|
---|
93 | #include "MExtractedSignalCam.h"
|
---|
94 | #include "MExtractedSignalPix.h"
|
---|
95 | #include "MArrivalTimeCam.h"
|
---|
96 | #include "MArrivalTimePix.h"
|
---|
97 |
|
---|
98 | #include "MGeomCam.h"
|
---|
99 | #include "MGeomPix.h"
|
---|
100 |
|
---|
101 | #include "MBadPixelsIntensityCam.h"
|
---|
102 | #include "MBadPixelsCam.h"
|
---|
103 | #include "MBadPixelsPix.h"
|
---|
104 |
|
---|
105 | #include <TOrdCollection.h>
|
---|
106 | #include <TPad.h>
|
---|
107 | #include <TVirtualPad.h>
|
---|
108 | #include <TCanvas.h>
|
---|
109 | #include <TStyle.h>
|
---|
110 | #include <TF1.h>
|
---|
111 | #include <TLine.h>
|
---|
112 | #include <TLatex.h>
|
---|
113 | #include <TLegend.h>
|
---|
114 | #include <TGraph.h>
|
---|
115 |
|
---|
116 | ClassImp(MHCalibrationHiLoCam);
|
---|
117 |
|
---|
118 | using namespace std;
|
---|
119 |
|
---|
120 | const Int_t MHCalibrationHiLoCam::fgNbins = 200;
|
---|
121 | const Axis_t MHCalibrationHiLoCam::fgFirst = 0.;
|
---|
122 | const Axis_t MHCalibrationHiLoCam::fgLast = 20.;
|
---|
123 | const Float_t MHCalibrationHiLoCam::fgProbLimit = 0.;
|
---|
124 | const TString MHCalibrationHiLoCam::gsHistName = "HiLo";
|
---|
125 | const TString MHCalibrationHiLoCam::gsHistTitle = "HiGain vs. LoGain";
|
---|
126 | const TString MHCalibrationHiLoCam::gsHistXTitle = "Amplification Ratio [1]";
|
---|
127 | const TString MHCalibrationHiLoCam::gsHistYTitle = "Nr. events";
|
---|
128 | // --------------------------------------------------------------------------
|
---|
129 | //
|
---|
130 | // Default Constructor.
|
---|
131 | //
|
---|
132 | // Sets:
|
---|
133 | // - fNbins to fgNbins
|
---|
134 | // - fFirst to fgFirst
|
---|
135 | // - fLast to fgLast
|
---|
136 | //
|
---|
137 | // - fHistName to gsHistName
|
---|
138 | // - fHistTitle to gsHistTitle
|
---|
139 | // - fHistXTitle to gsHistXTitle
|
---|
140 | // - fHistYTitle to gsHistYTitle
|
---|
141 | //
|
---|
142 | // - fLowerLimt to fgLowerLim
|
---|
143 | // - fUpperLimt to fgUpperLim
|
---|
144 | //
|
---|
145 | MHCalibrationHiLoCam::MHCalibrationHiLoCam(const char *name, const char *title)
|
---|
146 | {
|
---|
147 |
|
---|
148 | fName = name ? name : "MHCalibrationHiLoCam";
|
---|
149 | fTitle = title ? title : "Histogram class for the high-gain vs. low-gain amplification ratio calibration";
|
---|
150 |
|
---|
151 | SetNbins(fgNbins);
|
---|
152 | SetFirst(fgFirst);
|
---|
153 | SetLast (fgLast );
|
---|
154 |
|
---|
155 | SetProbLimit(fgProbLimit);
|
---|
156 |
|
---|
157 | SetHistName (gsHistName .Data());
|
---|
158 | SetHistTitle (gsHistTitle .Data());
|
---|
159 | SetHistXTitle(gsHistXTitle.Data());
|
---|
160 | SetHistYTitle(gsHistYTitle.Data());
|
---|
161 |
|
---|
162 | }
|
---|
163 |
|
---|
164 | // --------------------------------------------------------------------------
|
---|
165 | //
|
---|
166 | // Creates new MHCalibrationHiLoCam only with the averaged areas:
|
---|
167 | // the rest has to be retrieved directly, e.g. via:
|
---|
168 | // MHCalibrationHiLoCam *cam = MParList::FindObject("MHCalibrationHiLoCam");
|
---|
169 | // - cam->GetAverageSector(5).DrawClone();
|
---|
170 | // - (*cam)[100].DrawClone()
|
---|
171 | //
|
---|
172 | TObject *MHCalibrationHiLoCam::Clone(const char *) const
|
---|
173 | {
|
---|
174 |
|
---|
175 | MHCalibrationHiLoCam *cam = new MHCalibrationHiLoCam();
|
---|
176 |
|
---|
177 | //
|
---|
178 | // Copy the data members
|
---|
179 | //
|
---|
180 | cam->fColor = fColor;
|
---|
181 | cam->fRunNumbers = fRunNumbers;
|
---|
182 | cam->fPulserFrequency = fPulserFrequency;
|
---|
183 | cam->fFlags = fFlags;
|
---|
184 | cam->fNbins = fNbins;
|
---|
185 | cam->fFirst = fFirst;
|
---|
186 | cam->fLast = fLast;
|
---|
187 |
|
---|
188 | //
|
---|
189 | // Copy the MArrays
|
---|
190 | //
|
---|
191 | cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
|
---|
192 | cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
|
---|
193 | cam->fAverageAreaSat = fAverageAreaSat;
|
---|
194 | cam->fAverageAreaSigma = fAverageAreaSigma;
|
---|
195 | cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
|
---|
196 | cam->fAverageAreaNum = fAverageAreaNum;
|
---|
197 | cam->fAverageSectorNum = fAverageSectorNum;
|
---|
198 |
|
---|
199 | if (!IsAverageing())
|
---|
200 | return cam;
|
---|
201 |
|
---|
202 | const Int_t navhi = fAverageHiGainAreas->GetSize();
|
---|
203 | const Int_t navlo = fAverageLoGainAreas->GetSize();
|
---|
204 |
|
---|
205 | for (int i=0; i<navhi; i++)
|
---|
206 | cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
|
---|
207 |
|
---|
208 | for (int i=0; i<navlo; i++)
|
---|
209 | cam->fAverageLoGainAreas->AddAt(GetAverageLoGainArea(i).Clone(),i);
|
---|
210 |
|
---|
211 | return cam;
|
---|
212 | }
|
---|
213 |
|
---|
214 | // --------------------------------------------------------------------------
|
---|
215 | //
|
---|
216 | // Gets or creates the pointers to:
|
---|
217 | // - MCalibrationHiLoCam
|
---|
218 | //
|
---|
219 | // Searches pointer to:
|
---|
220 | // - MExtractedSignalCam
|
---|
221 | // - MArrivalTimeCam
|
---|
222 | //
|
---|
223 | // Calls:
|
---|
224 | // - MHCalibrationCam::InitHiGainArrays()
|
---|
225 | // - MHCalibrationCam::InitLoGainArrays()
|
---|
226 | //
|
---|
227 | // Sets:
|
---|
228 | // - fSumarea to nareas
|
---|
229 | // - fSumsector to nareas
|
---|
230 | // - fNumarea to nareas
|
---|
231 | // - fNumsector to nareas
|
---|
232 | //
|
---|
233 | Bool_t MHCalibrationHiLoCam::ReInitHists(MParList *pList)
|
---|
234 | {
|
---|
235 |
|
---|
236 | if (!InitCams(pList,"HiLo"))
|
---|
237 | return kFALSE;
|
---|
238 |
|
---|
239 | MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
---|
240 | if (!signal)
|
---|
241 | {
|
---|
242 | *fLog << err << "MExtractedSignalCam not found... abort." << endl;
|
---|
243 | return kFALSE;
|
---|
244 | }
|
---|
245 |
|
---|
246 | MArrivalTimeCam *times = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
|
---|
247 | if (!times)
|
---|
248 | {
|
---|
249 | *fLog << warn << "MArrivalTimeCam not found... cannot calibrated arrival times between "
|
---|
250 | <<"high and low-gain" << endl;
|
---|
251 | SetLoGain(kFALSE);
|
---|
252 | }
|
---|
253 |
|
---|
254 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
255 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
256 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
257 |
|
---|
258 | InitHiGainArrays(npixels,nareas,nsectors);
|
---|
259 | InitLoGainArrays(npixels,nareas,nsectors);
|
---|
260 |
|
---|
261 | fSumareahi .Set(nareas);
|
---|
262 | fSumsectorhi.Set(nsectors);
|
---|
263 | fNumareahi .Set(nareas);
|
---|
264 | fNumsectorhi.Set(nsectors);
|
---|
265 | if (IsLoGain())
|
---|
266 | {
|
---|
267 | fSumarealo .Set(nareas);
|
---|
268 | fSumsectorlo.Set(nsectors);
|
---|
269 | fNumarealo .Set(nareas);
|
---|
270 | fNumsectorlo.Set(nsectors);
|
---|
271 | }
|
---|
272 | return kTRUE;
|
---|
273 | }
|
---|
274 |
|
---|
275 | // -------------------------------------------------------------------------------
|
---|
276 | //
|
---|
277 | // Retrieves pointer to MExtractedSignalCam:
|
---|
278 | //
|
---|
279 | // Retrieves from MGeomCam:
|
---|
280 | // - number of pixels
|
---|
281 | // - number of pixel areas
|
---|
282 | // - number of sectors
|
---|
283 | //
|
---|
284 | // Fills histograms (MHGausEvents::FillHistAndArray()) with:
|
---|
285 | // - MExtractedSignalPix::GetExtractedSignalHiGain(pixid) / MExtractedSignalPix::GetExtractedSignalLoGain;
|
---|
286 | // if the high-gain signal does not show high-gain saturation, but the low-gain
|
---|
287 | // has been extracted.
|
---|
288 | // - MArrivalTimePix::GetArrivalTimeHiGain(pixid) / MArrivalTimePix::GetArrivalTimeLoGain;
|
---|
289 | // if the high-gain signal does not show high-gain saturation, but the low-gain
|
---|
290 | // has been extracted.
|
---|
291 | //
|
---|
292 | Bool_t MHCalibrationHiLoCam::FillHists(const MParContainer *par, const Stat_t w)
|
---|
293 | {
|
---|
294 |
|
---|
295 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
---|
296 | if (!signal)
|
---|
297 | {
|
---|
298 | gLog << err << "No argument in MExtractedSignal::Fill... abort." << endl;
|
---|
299 | return kFALSE;
|
---|
300 | }
|
---|
301 |
|
---|
302 | MArrivalTimeCam *times = (MArrivalTimeCam*)par;
|
---|
303 |
|
---|
304 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
305 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
306 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
307 |
|
---|
308 | fSumareahi .Reset();
|
---|
309 | fSumsectorhi.Reset();
|
---|
310 | fNumareahi .Reset();
|
---|
311 | fNumsectorhi.Reset();
|
---|
312 | fSumarealo .Reset();
|
---|
313 | fSumsectorlo.Reset();
|
---|
314 | fNumarealo .Reset();
|
---|
315 | fNumsectorlo.Reset();
|
---|
316 |
|
---|
317 | for (Int_t i=0; i<npixels; i++)
|
---|
318 | {
|
---|
319 | const MExtractedSignalPix &pix = (*signal)[i];
|
---|
320 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
---|
321 | const Int_t sector = (*fGeom)[i].GetSector();
|
---|
322 |
|
---|
323 | const Float_t siglo = pix.GetExtractedSignalLoGain();
|
---|
324 |
|
---|
325 | //
|
---|
326 | // Skip all pixels with:
|
---|
327 | // - Saturated high-gain
|
---|
328 | // - Not extracted low-gain
|
---|
329 | // (see MExtractTimeAndCharge::fLoGainSwitch for setting the criteria)
|
---|
330 | //
|
---|
331 | if (siglo < 0.5 || pix.GetNumHiGainSaturated() > 0)
|
---|
332 | continue;
|
---|
333 |
|
---|
334 | const Float_t sighi = pix.GetExtractedSignalHiGain();
|
---|
335 | const Float_t ratio = sighi / siglo;
|
---|
336 |
|
---|
337 | MHCalibrationPix &histhi = (*this)[i];
|
---|
338 |
|
---|
339 | histhi.FillHistAndArray(ratio);
|
---|
340 | fSumareahi [aidx] += ratio;
|
---|
341 | fNumareahi [aidx] ++;
|
---|
342 | fSumsectorhi[sector] += ratio;
|
---|
343 | fNumsectorhi[sector] ++;
|
---|
344 |
|
---|
345 | if (IsLoGain())
|
---|
346 | {
|
---|
347 | const MArrivalTimePix &tix = (*times)[i];
|
---|
348 | MHCalibrationPix &histlo = (*this)(i);
|
---|
349 |
|
---|
350 | const Float_t diff = tix.GetArrivalTimeLoGain() - tix.GetArrivalTimeHiGain();
|
---|
351 |
|
---|
352 | histlo.FillHistAndArray(diff);
|
---|
353 | fSumarealo [aidx] += diff;
|
---|
354 | fNumarealo [aidx] ++;
|
---|
355 | fSumsectorlo[sector] += diff;
|
---|
356 | fNumsectorlo[sector] ++;
|
---|
357 | }
|
---|
358 | }
|
---|
359 |
|
---|
360 | for (Int_t j=0; j<nareas; j++)
|
---|
361 | {
|
---|
362 | MHCalibrationPix &histhi = GetAverageHiGainArea(j);
|
---|
363 | histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
|
---|
364 |
|
---|
365 | if (IsLoGain())
|
---|
366 | {
|
---|
367 | MHCalibrationPix &histlo = GetAverageLoGainArea(j);
|
---|
368 | histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
|
---|
369 | }
|
---|
370 | }
|
---|
371 |
|
---|
372 | for (Int_t j=0; j<nsectors; j++)
|
---|
373 | {
|
---|
374 | MHCalibrationPix &hist = GetAverageHiGainSector(j);
|
---|
375 | hist.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
|
---|
376 |
|
---|
377 | if (IsLoGain())
|
---|
378 | {
|
---|
379 | MHCalibrationPix &histlo = GetAverageLoGainSector(j);
|
---|
380 | histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | return kTRUE;
|
---|
385 | }
|
---|
386 |
|
---|
387 | // --------------------------------------------------------------------------
|
---|
388 | //
|
---|
389 | // Calls:
|
---|
390 | // - MHCalibrationCam::FitHiGainArrays() with flags:
|
---|
391 | // MBadPixelsPix::kHiLoNotFitted and MBadPixelsPix::kHiLoOscillating
|
---|
392 | // - MHCalibrationCam::FitLoGainArrays() with flags:
|
---|
393 | // MBadPixelsPix::kHiLoNotFitted and MBadPixelsPix::kHiLoOscillating
|
---|
394 | //
|
---|
395 | Bool_t MHCalibrationHiLoCam::FinalizeHists()
|
---|
396 | {
|
---|
397 |
|
---|
398 | *fLog << endl;
|
---|
399 |
|
---|
400 | MCalibrationCam *hilocam = fIntensCam ? fIntensCam->GetCam() : fCam;
|
---|
401 | MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
|
---|
402 |
|
---|
403 | const Int_t nareas = fAverageHiGainAreas->GetSize();
|
---|
404 | const Int_t nsectors = fAverageHiGainSectors->GetSize();
|
---|
405 |
|
---|
406 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
---|
407 | {
|
---|
408 |
|
---|
409 | MHCalibrationPix &hist = (*this)[i];
|
---|
410 |
|
---|
411 | if (hist.IsExcluded())
|
---|
412 | continue;
|
---|
413 |
|
---|
414 | CheckOverflow(hist);
|
---|
415 | }
|
---|
416 |
|
---|
417 | for (Int_t j=0; j<nareas; j++)
|
---|
418 | {
|
---|
419 |
|
---|
420 | MHCalibrationPix &hist = GetAverageHiGainArea(j);
|
---|
421 | //
|
---|
422 | // Check histogram overflow
|
---|
423 | //
|
---|
424 | CheckOverflow(hist);
|
---|
425 | }
|
---|
426 |
|
---|
427 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
---|
428 | {
|
---|
429 |
|
---|
430 | MHCalibrationPix &hist = GetAverageHiGainSector(j);
|
---|
431 | //
|
---|
432 | // Check histogram overflow
|
---|
433 | //
|
---|
434 | CheckOverflow(hist);
|
---|
435 | }
|
---|
436 |
|
---|
437 | FitHiGainArrays(*hilocam,*badcam,
|
---|
438 | MBadPixelsPix::kHiLoNotFitted,
|
---|
439 | MBadPixelsPix::kHiLoOscillating);
|
---|
440 |
|
---|
441 | if (!IsLoGain())
|
---|
442 | return kTRUE;
|
---|
443 |
|
---|
444 | for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
|
---|
445 | {
|
---|
446 |
|
---|
447 | MHCalibrationPix &hist = (*this)(i);
|
---|
448 |
|
---|
449 | if (hist.IsExcluded())
|
---|
450 | continue;
|
---|
451 |
|
---|
452 | CheckOverflow(hist);
|
---|
453 | }
|
---|
454 |
|
---|
455 | for (Int_t j=0; j<nareas; j++)
|
---|
456 | {
|
---|
457 |
|
---|
458 | MHCalibrationPix &hist = GetAverageLoGainArea(j);
|
---|
459 | CheckOverflow(hist);
|
---|
460 | }
|
---|
461 |
|
---|
462 | for (Int_t j=0; j<nsectors; j++)
|
---|
463 | {
|
---|
464 |
|
---|
465 | MHCalibrationPix &hist = GetAverageLoGainSector(j);
|
---|
466 | CheckOverflow(hist);
|
---|
467 | }
|
---|
468 |
|
---|
469 | FitLoGainArrays(*hilocam,*badcam,
|
---|
470 | MBadPixelsPix::kHiLoNotFitted,
|
---|
471 | MBadPixelsPix::kHiLoOscillating);
|
---|
472 |
|
---|
473 | return kTRUE;
|
---|
474 | }
|
---|
475 |
|
---|
476 | // --------------------------------------------------------------------------
|
---|
477 | //
|
---|
478 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
---|
479 | // - MBadPixelsPix::kHiLoNotFitted
|
---|
480 | // - MBadPixelsPix::kHiLoOscillating
|
---|
481 | //
|
---|
482 | void MHCalibrationHiLoCam::FinalizeBadPixels()
|
---|
483 | {
|
---|
484 |
|
---|
485 | MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
|
---|
486 |
|
---|
487 | for (Int_t i=0; i<badcam->GetSize(); i++)
|
---|
488 | {
|
---|
489 | MBadPixelsPix &bad = (*badcam)[i];
|
---|
490 |
|
---|
491 | if (bad.IsUncalibrated( MBadPixelsPix::kHiLoNotFitted ))
|
---|
492 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
493 |
|
---|
494 | if (bad.IsUncalibrated( MBadPixelsPix::kHiLoOscillating))
|
---|
495 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
496 |
|
---|
497 | }
|
---|
498 | }
|
---|
499 |
|
---|
500 | // --------------------------------------------------------------------------
|
---|
501 | //
|
---|
502 | // The types are as follows:
|
---|
503 | //
|
---|
504 | // Fitted values:
|
---|
505 | // ==============
|
---|
506 | //
|
---|
507 | // 0: Fitted Mean High-Gain Low-Gain Charge Ratio in FADC slices (MHGausEvents::GetMean()
|
---|
508 | // 1: Error Mean High-Gain Low-Gain Charge Ratio in FADC slices (MHGausEvents::GetMeanErr()
|
---|
509 | // 2: Sigma fitted High-Gain Low-Gain Charge Ratio in FADC slices (MHGausEvents::GetSigma()
|
---|
510 | // 3: Error Sigma High-Gain Low-Gain Charge Ratio in FADC slices (MHGausEvents::GetSigmaErr()
|
---|
511 | //
|
---|
512 | // Useful variables derived from the fit results:
|
---|
513 | // =============================================
|
---|
514 | //
|
---|
515 | // 4: Returned probability of Gauss fit (calls: MHGausEvents::GetProb())
|
---|
516 | //
|
---|
517 | // Localized defects:
|
---|
518 | // ==================
|
---|
519 | //
|
---|
520 | // 5: Gaus fit not OK (calls: MHGausEvents::IsGausFitOK())
|
---|
521 | // 6: Fourier spectrum not OK (calls: MHGausEvents::IsFourierSpectrumOK())
|
---|
522 | //
|
---|
523 | Bool_t MHCalibrationHiLoCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
524 | {
|
---|
525 |
|
---|
526 | if (fHiGainArray->GetSize() <= idx)
|
---|
527 | return kFALSE;
|
---|
528 |
|
---|
529 | const MHCalibrationPix &pixhi = (*this)[idx];
|
---|
530 | const MHCalibrationPix &pixlo = (*this)(idx);
|
---|
531 |
|
---|
532 | switch (type)
|
---|
533 | {
|
---|
534 | case 0:
|
---|
535 | val = pixhi.GetMean();
|
---|
536 | break;
|
---|
537 | case 1:
|
---|
538 | val = pixhi.GetMeanErr();
|
---|
539 | break;
|
---|
540 | case 2:
|
---|
541 | val = pixhi.GetSigma();
|
---|
542 | break;
|
---|
543 | case 3:
|
---|
544 | val = pixhi.GetSigmaErr();
|
---|
545 | break;
|
---|
546 | case 4:
|
---|
547 | val = pixhi.GetProb();
|
---|
548 | break;
|
---|
549 | case 5:
|
---|
550 | if (!pixhi.IsGausFitOK())
|
---|
551 | val = 1.;
|
---|
552 | break;
|
---|
553 | case 6:
|
---|
554 | if (!pixhi.IsFourierSpectrumOK())
|
---|
555 | val = 1.;
|
---|
556 | break;
|
---|
557 | case 7:
|
---|
558 | if (!IsLoGain())
|
---|
559 | break;
|
---|
560 | val = pixlo.GetMean();
|
---|
561 | break;
|
---|
562 | case 8:
|
---|
563 | if (!IsLoGain())
|
---|
564 | break;
|
---|
565 | val = pixlo.GetMeanErr();
|
---|
566 | break;
|
---|
567 | case 9:
|
---|
568 | if (!IsLoGain())
|
---|
569 | break;
|
---|
570 | val = pixlo.GetSigma();
|
---|
571 | break;
|
---|
572 | case 10:
|
---|
573 | if (!IsLoGain())
|
---|
574 | break;
|
---|
575 | val = pixlo.GetSigmaErr();
|
---|
576 | break;
|
---|
577 | case 11:
|
---|
578 | if (!IsLoGain())
|
---|
579 | break;
|
---|
580 | val = pixlo.GetProb();
|
---|
581 | break;
|
---|
582 | case 12:
|
---|
583 | if (!IsLoGain())
|
---|
584 | break;
|
---|
585 | if (!pixlo.IsGausFitOK())
|
---|
586 | val = 1.;
|
---|
587 | break;
|
---|
588 | case 13:
|
---|
589 | if (!IsLoGain())
|
---|
590 | break;
|
---|
591 | if (!pixlo.IsFourierSpectrumOK())
|
---|
592 | val = 1.;
|
---|
593 | break;
|
---|
594 | default:
|
---|
595 | return kFALSE;
|
---|
596 | }
|
---|
597 | return kTRUE;
|
---|
598 | }
|
---|
599 |
|
---|
600 | // --------------------------------------------------------------------------
|
---|
601 | //
|
---|
602 | // Calls MHCalibrationPix::DrawClone() for pixel idx
|
---|
603 | //
|
---|
604 | void MHCalibrationHiLoCam::DrawPixelContent(Int_t idx) const
|
---|
605 | {
|
---|
606 | (*this)[idx].DrawClone();
|
---|
607 | }
|
---|
608 |
|
---|
609 | void MHCalibrationHiLoCam::CheckOverflow( MHCalibrationPix &pix )
|
---|
610 | {
|
---|
611 |
|
---|
612 | if (pix.IsExcluded())
|
---|
613 | return;
|
---|
614 |
|
---|
615 | TH1F *hist = pix.GetHGausHist();
|
---|
616 |
|
---|
617 | Stat_t overflow = hist->GetBinContent(hist->GetNbinsX()+1);
|
---|
618 | if (overflow > fOverflowLimit*hist->GetEntries())
|
---|
619 | {
|
---|
620 | *fLog << warn << "Hist-overflow " << overflow
|
---|
621 | << " times in " << pix.GetName() << endl;
|
---|
622 | }
|
---|
623 |
|
---|
624 | overflow = hist->GetBinContent(0);
|
---|
625 | if (overflow > fOverflowLimit*hist->GetEntries())
|
---|
626 | {
|
---|
627 | *fLog << warn << "Hist-underflow " << overflow
|
---|
628 | << " times in " << pix.GetName() << endl;
|
---|
629 | }
|
---|
630 | }
|
---|
631 |
|
---|