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 | // MHCalibrationRelTimeCam
|
---|
27 | //
|
---|
28 | // Fills the extracted relative arrival times 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 | // Every relative time is calculated as the difference between the individual
|
---|
44 | // pixel arrival time and the one of pixel 1 (hardware number: 2).
|
---|
45 | // The relative times are filled into a histogram and an array, in order to perform
|
---|
46 | // a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an
|
---|
47 | // event-by-event basis and written into the corresponding average pixels.
|
---|
48 | //
|
---|
49 | // The histograms are fitted to a Gaussian, mean and sigma with its errors
|
---|
50 | // and the fit probability are extracted. If none of these values are NaN's and
|
---|
51 | // if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
|
---|
52 | // the fit is declared valid.
|
---|
53 | // Otherwise, the fit is repeated within ranges of the previous mean
|
---|
54 | // +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
|
---|
55 | // In case this does not make the fit valid, the histogram means and RMS's are
|
---|
56 | // taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
|
---|
57 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeNotFitted ) and
|
---|
58 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
59 | //
|
---|
60 | // Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas
|
---|
61 | // from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup)
|
---|
62 | //
|
---|
63 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
---|
64 | // spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the
|
---|
65 | // projected fourier components follow an exponential distribution.
|
---|
66 | // In case that the probability of the exponential fit is less than
|
---|
67 | // MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
|
---|
68 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeOscillating ) and
|
---|
69 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
70 | //
|
---|
71 | // This same procedure is performed for the average pixels.
|
---|
72 | //
|
---|
73 | // The following results are written into MCalibrationRelTimeCam:
|
---|
74 | //
|
---|
75 | // - MCalibrationPix::SetMean()
|
---|
76 | // - MCalibrationPix::SetMeanErr()
|
---|
77 | // - MCalibrationPix::SetSigma()
|
---|
78 | // - MCalibrationPix::SetSigmaErr()
|
---|
79 | // - MCalibrationPix::SetProb()
|
---|
80 | // - MCalibrationPix::SetNumPickup()
|
---|
81 | //
|
---|
82 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
---|
83 | // the number involved pixels in order to be able to compare it to the average of
|
---|
84 | // sigmas in the camera.
|
---|
85 | //
|
---|
86 | /////////////////////////////////////////////////////////////////////////////
|
---|
87 | #include "MHCalibrationRelTimeCam.h"
|
---|
88 | #include "MHCalibrationPix.h"
|
---|
89 |
|
---|
90 | #include "MLog.h"
|
---|
91 | #include "MLogManip.h"
|
---|
92 |
|
---|
93 | #include "MParList.h"
|
---|
94 |
|
---|
95 | #include "MCalibrationIntensityRelTimeCam.h"
|
---|
96 |
|
---|
97 | #include "MCalibrationRelTimeCam.h"
|
---|
98 | #include "MCalibrationRelTimePix.h"
|
---|
99 | #include "MCalibrationPix.h"
|
---|
100 |
|
---|
101 | #include "MArrivalTimeCam.h"
|
---|
102 | #include "MArrivalTimePix.h"
|
---|
103 |
|
---|
104 | #include "MGeomCam.h"
|
---|
105 | #include "MGeomPix.h"
|
---|
106 |
|
---|
107 | #include "MBadPixelsIntensityCam.h"
|
---|
108 | #include "MBadPixelsCam.h"
|
---|
109 | #include "MBadPixelsPix.h"
|
---|
110 |
|
---|
111 | #include <TOrdCollection.h>
|
---|
112 | #include <TPad.h>
|
---|
113 | #include <TVirtualPad.h>
|
---|
114 | #include <TCanvas.h>
|
---|
115 | #include <TStyle.h>
|
---|
116 | #include <TF1.h>
|
---|
117 | #include <TLine.h>
|
---|
118 | #include <TLatex.h>
|
---|
119 | #include <TLegend.h>
|
---|
120 | #include <TGraph.h>
|
---|
121 |
|
---|
122 | ClassImp(MHCalibrationRelTimeCam);
|
---|
123 |
|
---|
124 | using namespace std;
|
---|
125 |
|
---|
126 | const Float_t MHCalibrationRelTimeCam::fgNumHiGainSaturationLimit = 0.25;
|
---|
127 | const UInt_t MHCalibrationRelTimeCam::fgReferencePixel = 1;
|
---|
128 | const Int_t MHCalibrationRelTimeCam::fgNbins = 900;
|
---|
129 | const Axis_t MHCalibrationRelTimeCam::fgFirst = -5.;
|
---|
130 | const Axis_t MHCalibrationRelTimeCam::fgLast = 5.;
|
---|
131 | const TString MHCalibrationRelTimeCam::gsHistName = "RelTime";
|
---|
132 | const TString MHCalibrationRelTimeCam::gsHistTitle = "Rel. Arr. Times";
|
---|
133 | const TString MHCalibrationRelTimeCam::gsHistXTitle = "Rel. Arr. Time [FADC slices]";
|
---|
134 | const TString MHCalibrationRelTimeCam::gsHistYTitle = "Nr. events";
|
---|
135 | // --------------------------------------------------------------------------
|
---|
136 | //
|
---|
137 | // Default Constructor.
|
---|
138 | //
|
---|
139 | // Sets:
|
---|
140 | // - fReferencePixel to fgReferencePixel
|
---|
141 | // - fNbins to fgNbins
|
---|
142 | // - fFirst to fgFirst
|
---|
143 | // - fLast to fgLast
|
---|
144 | //
|
---|
145 | // - fHistName to gsHistName
|
---|
146 | // - fHistTitle to gsHistTitle
|
---|
147 | // - fHistXTitle to gsHistXTitle
|
---|
148 | // - fHistYTitle to gsHistYTitle
|
---|
149 | //
|
---|
150 | MHCalibrationRelTimeCam::MHCalibrationRelTimeCam(const char *name, const char *title)
|
---|
151 | {
|
---|
152 |
|
---|
153 | fName = name ? name : "MHCalibrationRelTimeCam";
|
---|
154 | fTitle = title ? title : "Histogram class for the relative time calibration of the camera";
|
---|
155 |
|
---|
156 | SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
|
---|
157 |
|
---|
158 | SetReferencePixel();
|
---|
159 |
|
---|
160 | SetNbins(fgNbins);
|
---|
161 | SetFirst(fgFirst);
|
---|
162 | SetLast (fgLast );
|
---|
163 |
|
---|
164 | SetHistName (gsHistName .Data());
|
---|
165 | SetHistTitle (gsHistTitle .Data());
|
---|
166 | SetHistXTitle(gsHistXTitle.Data());
|
---|
167 | SetHistYTitle(gsHistYTitle.Data());
|
---|
168 |
|
---|
169 | }
|
---|
170 |
|
---|
171 | // --------------------------------------------------------------------------
|
---|
172 | //
|
---|
173 | // Creates new MHCalibrationRelTimeCam only with the averaged areas:
|
---|
174 | // the rest has to be retrieved directly, e.g. via:
|
---|
175 | // MHCalibrationRelTimeCam *cam = MParList::FindObject("MHCalibrationRelTimeCam");
|
---|
176 | // - cam->GetAverageSector(5).DrawClone();
|
---|
177 | // - (*cam)[100].DrawClone()
|
---|
178 | //
|
---|
179 | #if 0
|
---|
180 | TObject *MHCalibrationRelTimeCam::Clone(const char *) const
|
---|
181 | {
|
---|
182 |
|
---|
183 | MHCalibrationRelTimeCam *cam = new MHCalibrationRelTimeCam();
|
---|
184 |
|
---|
185 | //
|
---|
186 | // Copy the data members
|
---|
187 | //
|
---|
188 | cam->fRunNumbers = fRunNumbers;
|
---|
189 | cam->fPulserFrequency = fPulserFrequency;
|
---|
190 | cam->fFlags = fFlags;
|
---|
191 | cam->fNbins = fNbins;
|
---|
192 | cam->fFirst = fFirst;
|
---|
193 | cam->fLast = fLast;
|
---|
194 |
|
---|
195 | //
|
---|
196 | // Copy the MArrays
|
---|
197 | //
|
---|
198 | cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
|
---|
199 | cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
|
---|
200 | cam->fAverageAreaSat = fAverageAreaSat;
|
---|
201 | cam->fAverageAreaSigma = fAverageAreaSigma;
|
---|
202 | cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
|
---|
203 | cam->fAverageAreaNum = fAverageAreaNum;
|
---|
204 | cam->fAverageSectorNum = fAverageSectorNum;
|
---|
205 |
|
---|
206 | if (!IsAverageing())
|
---|
207 | return cam;
|
---|
208 |
|
---|
209 | const Int_t navhi = fAverageHiGainAreas->GetSize();
|
---|
210 |
|
---|
211 | for (int i=0; i<navhi; i++)
|
---|
212 | cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
|
---|
213 |
|
---|
214 | if (IsLoGain())
|
---|
215 | {
|
---|
216 |
|
---|
217 | const Int_t navlo = fAverageLoGainAreas->GetSize();
|
---|
218 | for (int i=0; i<navlo; i++)
|
---|
219 | cam->fAverageLoGainAreas->AddAt(GetAverageLoGainArea(i).Clone(),i);
|
---|
220 |
|
---|
221 | }
|
---|
222 |
|
---|
223 | return cam;
|
---|
224 | }
|
---|
225 | #endif
|
---|
226 |
|
---|
227 | // --------------------------------------------------------------------------
|
---|
228 | //
|
---|
229 | // Gets or creates the pointers to:
|
---|
230 | // - MCalibrationRelTimeCam
|
---|
231 | //
|
---|
232 | // Searches pointer to:
|
---|
233 | // - MArrivalTimeCam
|
---|
234 | //
|
---|
235 | // Calls:
|
---|
236 | // - MHCalibrationCam::InitHiGainArrays()
|
---|
237 | // - MHCalibrationCam::InitLoGainArrays()
|
---|
238 | //
|
---|
239 | // Sets:
|
---|
240 | // - fSumareahi to nareas
|
---|
241 | // - fSumarealo to nareas
|
---|
242 | // - fSumsectorhi to nareas
|
---|
243 | // - fSumsectorlo to nareas
|
---|
244 | // - fNumareahi to nareas
|
---|
245 | // - fNumarealo to nareas
|
---|
246 | // - fNumsectorhi to nareas
|
---|
247 | // - fNumsectorlo to nareas
|
---|
248 | //
|
---|
249 | Bool_t MHCalibrationRelTimeCam::ReInitHists(MParList *pList)
|
---|
250 | {
|
---|
251 |
|
---|
252 | fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityRelTimeCam"));
|
---|
253 | if (fIntensCam)
|
---|
254 | *fLog << inf << "Found MCalibrationIntensityRelTimeCam ... " << endl;
|
---|
255 | else
|
---|
256 | {
|
---|
257 | fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
258 | if (!fCam)
|
---|
259 | {
|
---|
260 | fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
261 | if (!fCam)
|
---|
262 | {
|
---|
263 | *fLog << err << "Cannot find nor create MCalibrationRelTimeCam ... abort." << endl;
|
---|
264 | return kFALSE;
|
---|
265 | }
|
---|
266 | fCam->Init(*fGeom);
|
---|
267 | }
|
---|
268 | }
|
---|
269 |
|
---|
270 | MArrivalTimeCam *signal = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
|
---|
271 | if (!signal)
|
---|
272 | {
|
---|
273 | *fLog << err << "MArrivalTimeCam not found... abort." << endl;
|
---|
274 | return kFALSE;
|
---|
275 | }
|
---|
276 |
|
---|
277 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
278 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
279 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
280 |
|
---|
281 | InitHiGainArrays(npixels,nareas,nsectors);
|
---|
282 | InitLoGainArrays(npixels,nareas,nsectors);
|
---|
283 |
|
---|
284 | fSumareahi .Set(nareas);
|
---|
285 | fSumarealo .Set(nareas);
|
---|
286 | fSumsectorhi.Set(nsectors);
|
---|
287 | fSumsectorlo.Set(nsectors);
|
---|
288 | fNumareahi .Set(nareas);
|
---|
289 | fNumarealo .Set(nareas);
|
---|
290 | fNumsectorhi.Set(nsectors);
|
---|
291 | fNumsectorlo.Set(nsectors);
|
---|
292 |
|
---|
293 | return kTRUE;
|
---|
294 | }
|
---|
295 |
|
---|
296 |
|
---|
297 | // -------------------------------------------------------------------------------
|
---|
298 | //
|
---|
299 | // Retrieves pointer to MArrivalTimeCam:
|
---|
300 | //
|
---|
301 | // Retrieves from MGeomCam:
|
---|
302 | // - number of pixels
|
---|
303 | // - number of pixel areas
|
---|
304 | // - number of sectors
|
---|
305 | //
|
---|
306 | // Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
|
---|
307 | // depending on MArrivalTimePix::IsLoGainUsed(), with:
|
---|
308 | // - MArrivalTimePix::GetArrivalTime(pixid) - MArrivalTimePix::GetArrivalTime(1);
|
---|
309 | // (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
|
---|
310 | //
|
---|
311 | Bool_t MHCalibrationRelTimeCam::FillHists(const MParContainer *par, const Stat_t w)
|
---|
312 | {
|
---|
313 |
|
---|
314 | MArrivalTimeCam *arrtime = (MArrivalTimeCam*)par;
|
---|
315 | if (!arrtime)
|
---|
316 | {
|
---|
317 | gLog << err << "No argument in MArrivalTime::Fill... abort." << endl;
|
---|
318 | return kFALSE;
|
---|
319 | }
|
---|
320 |
|
---|
321 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
322 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
323 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
324 |
|
---|
325 | fSumareahi .Reset();
|
---|
326 | fSumarealo .Reset();
|
---|
327 | fSumsectorhi.Reset();
|
---|
328 | fSumsectorlo.Reset();
|
---|
329 | fNumareahi .Reset();
|
---|
330 | fNumarealo .Reset();
|
---|
331 | fNumsectorhi.Reset();
|
---|
332 | fNumsectorlo.Reset();
|
---|
333 |
|
---|
334 | const MArrivalTimePix &refpix = (*arrtime)[fReferencePixel];
|
---|
335 | const Float_t reftime = refpix.IsLoGainUsed()
|
---|
336 | ? refpix.GetArrivalTimeLoGain() : refpix.GetArrivalTimeHiGain();
|
---|
337 |
|
---|
338 | for (Int_t i=0; i<npixels; i++)
|
---|
339 | {
|
---|
340 |
|
---|
341 | MHCalibrationPix &histhi = (*this)[i];
|
---|
342 | MHCalibrationPix &histlo = (*this)(i);
|
---|
343 |
|
---|
344 | if (histhi.IsExcluded())
|
---|
345 | continue;
|
---|
346 |
|
---|
347 | const MArrivalTimePix &pix = (*arrtime)[i];
|
---|
348 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
---|
349 | const Int_t sector = (*fGeom)[i].GetSector();
|
---|
350 |
|
---|
351 | if (pix.IsLoGainUsed() && IsLoGain())
|
---|
352 | {
|
---|
353 | const Float_t reltime = pix.GetArrivalTimeLoGain() - reftime;
|
---|
354 | histhi.AddSaturated(1);
|
---|
355 | histlo.FillHistAndArray(reltime);
|
---|
356 | fSumarealo [aidx] += reltime;
|
---|
357 | fNumarealo [aidx] ++;
|
---|
358 | fSumsectorlo[sector] += reltime;
|
---|
359 | fNumsectorlo[sector] ++;
|
---|
360 | }
|
---|
361 | else
|
---|
362 | {
|
---|
363 | const Float_t reltime = pix.GetArrivalTimeHiGain() - reftime;
|
---|
364 |
|
---|
365 | histhi.FillHistAndArray(reltime) ;
|
---|
366 | fSumareahi [aidx] += reltime;
|
---|
367 | fNumareahi [aidx] ++;
|
---|
368 | fSumsectorhi[sector] += reltime;
|
---|
369 | fNumsectorhi[sector] ++;
|
---|
370 | }
|
---|
371 | }
|
---|
372 |
|
---|
373 | for (Int_t j=0; j<nareas; j++)
|
---|
374 | {
|
---|
375 | MHCalibrationPix &histhi = GetAverageHiGainArea(j);
|
---|
376 | histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
|
---|
377 |
|
---|
378 | if (IsLoGain())
|
---|
379 | {
|
---|
380 | MHCalibrationPix &histlo = GetAverageLoGainArea(j);
|
---|
381 | histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
|
---|
382 | }
|
---|
383 | }
|
---|
384 |
|
---|
385 | for (Int_t j=0; j<nsectors; j++)
|
---|
386 | {
|
---|
387 | MHCalibrationPix &histhi = GetAverageHiGainSector(j);
|
---|
388 | histhi.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
|
---|
389 |
|
---|
390 | if (IsLoGain())
|
---|
391 | {
|
---|
392 | MHCalibrationPix &histlo = GetAverageLoGainSector(j);
|
---|
393 | histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
|
---|
394 | }
|
---|
395 | }
|
---|
396 |
|
---|
397 | return kTRUE;
|
---|
398 | }
|
---|
399 |
|
---|
400 | // --------------------------------------------------------------------------
|
---|
401 | //
|
---|
402 | // Calls:
|
---|
403 | // - MHCalibrationCam::FitHiGainArrays() with flags:
|
---|
404 | // MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
|
---|
405 | // - MHCalibrationCam::FitLoGainArrays() with flags:
|
---|
406 | // MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
|
---|
407 | //
|
---|
408 | Bool_t MHCalibrationRelTimeCam::FinalizeHists()
|
---|
409 | {
|
---|
410 |
|
---|
411 | *fLog << endl;
|
---|
412 |
|
---|
413 | MCalibrationCam *relcam = fIntensCam ? fIntensCam->GetCam() : fCam;
|
---|
414 | MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
|
---|
415 |
|
---|
416 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
---|
417 | {
|
---|
418 |
|
---|
419 | MHCalibrationPix &histhi = (*this)[i];
|
---|
420 |
|
---|
421 | if (histhi.IsExcluded())
|
---|
422 | continue;
|
---|
423 |
|
---|
424 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*relcam)[i] ;
|
---|
425 |
|
---|
426 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
427 | {
|
---|
428 | pix.SetHiGainSaturation();
|
---|
429 | histhi.SetExcluded();
|
---|
430 | }
|
---|
431 | else
|
---|
432 | if (IsLoGain())
|
---|
433 | (*this)(i).SetExcluded();
|
---|
434 |
|
---|
435 | Stat_t overflow = histhi.GetHGausHist()->GetBinContent(histhi.GetHGausHist()->GetNbinsX()+1);
|
---|
436 | if (overflow > 0.1)
|
---|
437 | {
|
---|
438 | *fLog << warn << "HiGain Hist-overflow occurred " << overflow
|
---|
439 | << " times in pix: " << i << " (w/o saturation!) " << endl;
|
---|
440 | // bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
|
---|
441 | }
|
---|
442 |
|
---|
443 | overflow = histhi.GetHGausHist()->GetBinContent(0);
|
---|
444 | if (overflow > 0.1)
|
---|
445 | {
|
---|
446 | *fLog << warn << "HiGain Hist-underflow occurred " << overflow
|
---|
447 | << " times in pix: " << i << " (w/o saturation!) " << endl;
|
---|
448 | // bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
|
---|
449 | }
|
---|
450 | }
|
---|
451 |
|
---|
452 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
---|
453 | {
|
---|
454 |
|
---|
455 | MHCalibrationPix &histhi = GetAverageHiGainArea(j);
|
---|
456 |
|
---|
457 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
458 | {
|
---|
459 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)relcam->GetAverageArea(j);
|
---|
460 | pix.SetHiGainSaturation();
|
---|
461 | histhi.SetExcluded();
|
---|
462 | }
|
---|
463 | else
|
---|
464 | if (IsLoGain())
|
---|
465 | GetAverageLoGainArea(j).SetExcluded();
|
---|
466 |
|
---|
467 | }
|
---|
468 |
|
---|
469 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
---|
470 | {
|
---|
471 |
|
---|
472 | MHCalibrationPix &histhi = GetAverageHiGainSector(j);
|
---|
473 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)relcam->GetAverageSector(j) ;
|
---|
474 |
|
---|
475 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
476 | {
|
---|
477 | pix.SetHiGainSaturation();
|
---|
478 | histhi.SetExcluded();
|
---|
479 | }
|
---|
480 | else
|
---|
481 | if (IsLoGain())
|
---|
482 | GetAverageLoGainSector(j).SetExcluded();
|
---|
483 | }
|
---|
484 |
|
---|
485 | FitHiGainArrays(*relcam,*badcam,
|
---|
486 | MBadPixelsPix::kRelTimeNotFitted,
|
---|
487 | MBadPixelsPix::kRelTimeOscillating);
|
---|
488 |
|
---|
489 | if (IsLoGain())
|
---|
490 | FitLoGainArrays(*relcam,*badcam,
|
---|
491 | MBadPixelsPix::kRelTimeNotFitted,
|
---|
492 | MBadPixelsPix::kRelTimeOscillating);
|
---|
493 |
|
---|
494 | return kTRUE;
|
---|
495 | }
|
---|
496 |
|
---|
497 | // --------------------------------------------------------------------------
|
---|
498 | //
|
---|
499 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
---|
500 | // - MBadPixelsPix::kRelTimeNotFitted
|
---|
501 | // - MBadPixelsPix::kRelTimeOscillating
|
---|
502 | //
|
---|
503 | void MHCalibrationRelTimeCam::FinalizeBadPixels()
|
---|
504 | {
|
---|
505 |
|
---|
506 | MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
|
---|
507 |
|
---|
508 | for (Int_t i=0; i<badcam->GetSize(); i++)
|
---|
509 | {
|
---|
510 | MBadPixelsPix &bad = (*badcam)[i];
|
---|
511 |
|
---|
512 | if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted ))
|
---|
513 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
514 |
|
---|
515 | if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
|
---|
516 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
517 |
|
---|
518 | }
|
---|
519 | }
|
---|
520 |
|
---|
521 | // --------------------------------------------------------------------------
|
---|
522 | //
|
---|
523 | // The types are as follows:
|
---|
524 | //
|
---|
525 | // Fitted values:
|
---|
526 | // ==============
|
---|
527 | //
|
---|
528 | // 0: Fitted Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMean()
|
---|
529 | // 1: Error Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMeanErr()
|
---|
530 | // 2: Sigma fitted Relative Arrival Time in FADC slices (MHGausEvents::GetSigma()
|
---|
531 | // 3: Error Sigma Relative Arrival Time in FADC slices (MHGausEvents::GetSigmaErr()
|
---|
532 | //
|
---|
533 | // Useful variables derived from the fit results:
|
---|
534 | // =============================================
|
---|
535 | //
|
---|
536 | // 4: Returned probability of Gauss fit (calls: MHGausEvents::GetProb())
|
---|
537 | //
|
---|
538 | // Localized defects:
|
---|
539 | // ==================
|
---|
540 | //
|
---|
541 | // 5: Gaus fit not OK (calls: MHGausEvents::IsGausFitOK())
|
---|
542 | // 6: Fourier spectrum not OK (calls: MHGausEvents::IsFourierSpectrumOK())
|
---|
543 | //
|
---|
544 | Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
545 | {
|
---|
546 |
|
---|
547 | if (fHiGainArray->GetSize() <= idx)
|
---|
548 | return kFALSE;
|
---|
549 |
|
---|
550 | const MHCalibrationPix &pix = (*this)[idx];
|
---|
551 |
|
---|
552 | switch (type)
|
---|
553 | {
|
---|
554 | case 0:
|
---|
555 | val = pix.GetMean();
|
---|
556 | break;
|
---|
557 | case 1:
|
---|
558 | val = pix.GetMeanErr();
|
---|
559 | break;
|
---|
560 | case 2:
|
---|
561 | val = pix.GetSigma();
|
---|
562 | break;
|
---|
563 | case 3:
|
---|
564 | val = pix.GetSigmaErr();
|
---|
565 | break;
|
---|
566 | case 4:
|
---|
567 | val = pix.GetProb();
|
---|
568 | break;
|
---|
569 | case 5:
|
---|
570 | if (!pix.IsGausFitOK())
|
---|
571 | val = 1.;
|
---|
572 | break;
|
---|
573 | case 6:
|
---|
574 | if (!pix.IsFourierSpectrumOK())
|
---|
575 | val = 1.;
|
---|
576 | break;
|
---|
577 | default:
|
---|
578 | return kFALSE;
|
---|
579 | }
|
---|
580 | return kTRUE;
|
---|
581 | }
|
---|
582 |
|
---|
583 | // --------------------------------------------------------------------------
|
---|
584 | //
|
---|
585 | // Calls MHCalibrationPix::DrawClone() for pixel idx
|
---|
586 | //
|
---|
587 | void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
|
---|
588 | {
|
---|
589 | (*this)[idx].DrawClone();
|
---|
590 | }
|
---|
591 |
|
---|
592 | // -----------------------------------------------------------------------------
|
---|
593 | //
|
---|
594 | // Default draw:
|
---|
595 | //
|
---|
596 | // Displays the averaged areas, both High Gain and Low Gain
|
---|
597 | //
|
---|
598 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
---|
599 | //
|
---|
600 | void MHCalibrationRelTimeCam::Draw(const Option_t *opt)
|
---|
601 | {
|
---|
602 |
|
---|
603 | const Int_t nareas = fAverageHiGainAreas->GetSize();
|
---|
604 | if (nareas == 0)
|
---|
605 | return;
|
---|
606 |
|
---|
607 | TString option(opt);
|
---|
608 | option.ToLower();
|
---|
609 |
|
---|
610 | if (!option.Contains("datacheck"))
|
---|
611 | {
|
---|
612 | MHCalibrationCam::Draw(opt);
|
---|
613 | return;
|
---|
614 | }
|
---|
615 |
|
---|
616 | //
|
---|
617 | // From here on , the datacheck - Draw
|
---|
618 | //
|
---|
619 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
620 | pad->SetBorderMode(0);
|
---|
621 | pad->Divide(1,nareas);
|
---|
622 |
|
---|
623 | //
|
---|
624 | // Loop over inner and outer pixels
|
---|
625 | //
|
---|
626 | for (Int_t i=0; i<nareas;i++)
|
---|
627 | {
|
---|
628 |
|
---|
629 | pad->cd(i+1);
|
---|
630 |
|
---|
631 | MHCalibrationPix &hipix = GetAverageHiGainArea(i);
|
---|
632 | //
|
---|
633 | // Ask for Hi-Gain saturation
|
---|
634 | //
|
---|
635 | if (hipix.GetSaturated() > fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries() && IsLoGain())
|
---|
636 | {
|
---|
637 | MHCalibrationPix &lopix = GetAverageLoGainArea(i);
|
---|
638 | DrawDataCheckPixel(lopix,0.);
|
---|
639 | }
|
---|
640 | else
|
---|
641 | DrawDataCheckPixel(hipix,0.);
|
---|
642 | }
|
---|
643 | }
|
---|
644 |
|
---|
645 | // -----------------------------------------------------------------------------
|
---|
646 | //
|
---|
647 | // Draw the average pixel for the datacheck:
|
---|
648 | //
|
---|
649 | // Displays the averaged areas, both High Gain and Low Gain
|
---|
650 | //
|
---|
651 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
---|
652 | //
|
---|
653 | void MHCalibrationRelTimeCam::DrawDataCheckPixel(MHCalibrationPix &pix, const Float_t refline)
|
---|
654 | {
|
---|
655 |
|
---|
656 | TVirtualPad *newpad = gPad;
|
---|
657 | newpad->Divide(1,2);
|
---|
658 | newpad->cd(1);
|
---|
659 |
|
---|
660 | gPad->SetTicks();
|
---|
661 | if (!pix.IsEmpty() && !pix.IsOnlyOverflow() && !pix.IsOnlyUnderflow())
|
---|
662 | gPad->SetLogy();
|
---|
663 |
|
---|
664 | TH1F *hist = pix.GetHGausHist();
|
---|
665 |
|
---|
666 | TH1F *null = new TH1F("Null",hist->GetTitle(),100,pix.GetFirst() < -3.0 ? -3.0 : pix.GetFirst(),
|
---|
667 | pix.GetLast() > 3.0 ? 3.0 : pix.GetLast());
|
---|
668 |
|
---|
669 | null->SetMaximum(1.1*hist->GetMaximum());
|
---|
670 | null->SetDirectory(NULL);
|
---|
671 | null->SetBit(kCanDelete);
|
---|
672 | null->SetStats(kFALSE);
|
---|
673 | //
|
---|
674 | // set the labels bigger
|
---|
675 | //
|
---|
676 | TAxis *xaxe = null->GetXaxis();
|
---|
677 | TAxis *yaxe = null->GetYaxis();
|
---|
678 | xaxe->CenterTitle();
|
---|
679 | yaxe->CenterTitle();
|
---|
680 | xaxe->SetTitleSize(0.07);
|
---|
681 | yaxe->SetTitleSize(0.07);
|
---|
682 | xaxe->SetTitleOffset(0.7);
|
---|
683 | yaxe->SetTitleOffset(0.55);
|
---|
684 | xaxe->SetLabelSize(0.06);
|
---|
685 | yaxe->SetLabelSize(0.06);
|
---|
686 |
|
---|
687 | xaxe->SetTitle(hist->GetXaxis()->GetTitle());
|
---|
688 | yaxe->SetTitle(hist->GetYaxis()->GetTitle());
|
---|
689 |
|
---|
690 | null->Draw();
|
---|
691 | hist->Draw("same");
|
---|
692 |
|
---|
693 | gStyle->SetOptFit();
|
---|
694 |
|
---|
695 | TF1 *fit = pix.GetFGausFit();
|
---|
696 |
|
---|
697 | if (fit)
|
---|
698 | {
|
---|
699 | switch ( fColor )
|
---|
700 | {
|
---|
701 | case MCalibrationCam::kGREEN:
|
---|
702 | fit->SetLineColor(kGreen);
|
---|
703 | break;
|
---|
704 | case MCalibrationCam::kBLUE:
|
---|
705 | fit->SetLineColor(kBlue);
|
---|
706 | break;
|
---|
707 | case MCalibrationCam::kUV:
|
---|
708 | fit->SetLineColor(106);
|
---|
709 | break;
|
---|
710 | case MCalibrationCam::kCT1:
|
---|
711 | fit->SetLineColor(006);
|
---|
712 | break;
|
---|
713 | default:
|
---|
714 | fit->SetLineColor(kRed);
|
---|
715 | }
|
---|
716 | fit->Draw("same");
|
---|
717 | }
|
---|
718 |
|
---|
719 | // DisplayRefLines(null,refline);
|
---|
720 |
|
---|
721 | gPad->Modified();
|
---|
722 | gPad->Update();
|
---|
723 |
|
---|
724 | newpad->cd(2);
|
---|
725 | gPad->SetTicks();
|
---|
726 |
|
---|
727 | TH1F *null2 = new TH1F("Null2",hist->GetTitle(),100,0.,pix.GetEvents()->GetSize()/pix.GetEventFrequency());
|
---|
728 |
|
---|
729 | null2->SetMinimum(pix.GetMean()-10.*pix.GetSigma());
|
---|
730 | null2->SetMaximum(pix.GetMean()+10.*pix.GetSigma());
|
---|
731 | null2->SetDirectory(NULL);
|
---|
732 | null2->SetBit(kCanDelete);
|
---|
733 | null2->SetStats(kFALSE);
|
---|
734 | //
|
---|
735 | // set the labels bigger
|
---|
736 | //
|
---|
737 | TAxis *xaxe2 = null2->GetXaxis();
|
---|
738 | TAxis *yaxe2 = null2->GetYaxis();
|
---|
739 | xaxe2->CenterTitle();
|
---|
740 | yaxe2->CenterTitle();
|
---|
741 | xaxe2->SetTitleSize(0.07);
|
---|
742 | yaxe2->SetTitleSize(0.07);
|
---|
743 | xaxe2->SetTitleOffset(0.7);
|
---|
744 | yaxe2->SetTitleOffset(0.55);
|
---|
745 | xaxe2->SetLabelSize(0.06);
|
---|
746 | yaxe2->SetLabelSize(0.06);
|
---|
747 |
|
---|
748 | pix.CreateGraphEvents();
|
---|
749 | TGraph *gr = pix.GetGraphEvents();
|
---|
750 |
|
---|
751 | xaxe2->SetTitle(gr->GetXaxis()->GetTitle());
|
---|
752 | yaxe2->SetTitle(gr->GetYaxis()->GetTitle());
|
---|
753 |
|
---|
754 | null2->Draw();
|
---|
755 |
|
---|
756 | pix.DrawEvents("same");
|
---|
757 |
|
---|
758 | return;
|
---|
759 | }
|
---|
760 |
|
---|