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