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