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