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 "MBadPixelsCam.h"
|
---|
108 | #include "MBadPixelsPix.h"
|
---|
109 |
|
---|
110 | ClassImp(MHCalibrationRelTimeCam);
|
---|
111 |
|
---|
112 | using namespace std;
|
---|
113 |
|
---|
114 | const Float_t MHCalibrationRelTimeCam::fgNumHiGainSaturationLimit = 0.25;
|
---|
115 | const UInt_t MHCalibrationRelTimeCam::fgReferencePixel = 1;
|
---|
116 | const Int_t MHCalibrationRelTimeCam::fgRelTimeNbins = 900;
|
---|
117 | const Axis_t MHCalibrationRelTimeCam::fgRelTimeFirst = -5.;
|
---|
118 | const Axis_t MHCalibrationRelTimeCam::fgRelTimeLast = 5.;
|
---|
119 | // --------------------------------------------------------------------------
|
---|
120 | //
|
---|
121 | // Default Constructor.
|
---|
122 | //
|
---|
123 | // Sets:
|
---|
124 | // - fReferencePixel to fgReferencePixel
|
---|
125 | // - fRelTimeNbins to fgRelTimeNbins
|
---|
126 | // - fRelTimeFirst to fgRelTimeFirst
|
---|
127 | // - fRelTimeLast to fgRelTimeLast
|
---|
128 | //
|
---|
129 | MHCalibrationRelTimeCam::MHCalibrationRelTimeCam(const char *name, const char *title)
|
---|
130 | {
|
---|
131 |
|
---|
132 | fName = name ? name : "MHCalibrationRelTimeCam";
|
---|
133 | fTitle = title ? title : "Histogram class for the relative time calibration of the camera";
|
---|
134 |
|
---|
135 | SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
|
---|
136 |
|
---|
137 | SetReferencePixel();
|
---|
138 |
|
---|
139 | SetRelTimeNbins();
|
---|
140 | SetRelTimeFirst();
|
---|
141 | SetRelTimeLast ();
|
---|
142 | }
|
---|
143 |
|
---|
144 | // --------------------------------------------------------------------------
|
---|
145 | //
|
---|
146 | // Gets or creates the pointers to:
|
---|
147 | // - MCalibrationRelTimeCam
|
---|
148 | //
|
---|
149 | // Searches pointer to:
|
---|
150 | // - MArrivalTimeCam
|
---|
151 | //
|
---|
152 | // Initializes, if empty to MGeomCam::GetNumPixels():
|
---|
153 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
154 | //
|
---|
155 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
---|
156 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
157 | //
|
---|
158 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
---|
159 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
160 | //
|
---|
161 | // Calls MHCalibrationCam::InitHists() for every entry in:
|
---|
162 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
163 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
164 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
165 | //
|
---|
166 | // Sets Titles and Names for the Histograms
|
---|
167 | // - MHCalibrationCam::fAverageHiGainAreas
|
---|
168 | // - MHCalibrationCam::fAverageHiGainSectors
|
---|
169 | //
|
---|
170 | Bool_t MHCalibrationRelTimeCam::ReInitHists(MParList *pList)
|
---|
171 | {
|
---|
172 |
|
---|
173 | fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityRelTimeCam"));
|
---|
174 | if (fIntensCam)
|
---|
175 | *fLog << inf << "Found MCalibrationIntensityRelTimeCam ... " << endl;
|
---|
176 | else
|
---|
177 | {
|
---|
178 | fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
179 | if (!fCam)
|
---|
180 | {
|
---|
181 | fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
182 | if (!fCam)
|
---|
183 | {
|
---|
184 | *fLog << err << "Cannot find nor create MCalibrationRelTimeCam ... abort." << endl;
|
---|
185 | return kFALSE;
|
---|
186 | }
|
---|
187 | fCam->Init(*fGeom);
|
---|
188 | }
|
---|
189 | }
|
---|
190 |
|
---|
191 | MArrivalTimeCam *signal = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
|
---|
192 | if (!signal)
|
---|
193 | {
|
---|
194 | *fLog << err << "MArrivalTimeCam not found... abort." << endl;
|
---|
195 | return kFALSE;
|
---|
196 | }
|
---|
197 |
|
---|
198 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
199 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
200 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
201 |
|
---|
202 | if (fHiGainArray->GetEntries()==0)
|
---|
203 | {
|
---|
204 | fHiGainArray->Expand(npixels);
|
---|
205 | for (Int_t i=0; i<npixels; i++)
|
---|
206 | {
|
---|
207 | (*fHiGainArray)[i] = new MHCalibrationPix("RelTimePixHiGain",
|
---|
208 | "Rel. Arr. Time High Gain Pixel ");
|
---|
209 |
|
---|
210 | MHCalibrationPix &pix = (*this)[i];
|
---|
211 | pix.SetNbins(fRelTimeNbins);
|
---|
212 | pix.SetFirst(fRelTimeFirst);
|
---|
213 | pix.SetLast (fRelTimeLast);
|
---|
214 |
|
---|
215 | TH1F *h = pix.GetHGausHist();
|
---|
216 |
|
---|
217 | h->SetName ("HRelTimeHiGainPix");
|
---|
218 | h->SetTitle("Rel. Times High Gain Pixel ");
|
---|
219 | h->SetXTitle("Rel. Arr. Time [FADC slices]");
|
---|
220 | h->SetYTitle("Nr. of events");
|
---|
221 |
|
---|
222 | InitHists(pix,(*fBadPixels)[i],i);
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | if (fLoGainArray->GetEntries()==0 && IsLoGain() )
|
---|
227 | {
|
---|
228 | fLoGainArray->Expand(npixels);
|
---|
229 | for (Int_t i=0; i<npixels; i++)
|
---|
230 | {
|
---|
231 | (*fLoGainArray)[i] = new MHCalibrationPix("RelTimePixLoGain",
|
---|
232 | "Rel. Arr. Time Low Gain Pixel ");
|
---|
233 | MHCalibrationPix &pix = (*this)(i);
|
---|
234 |
|
---|
235 | pix.SetNbins(fRelTimeNbins);
|
---|
236 | pix.SetFirst(fRelTimeFirst);
|
---|
237 | pix.SetLast (fRelTimeLast);
|
---|
238 |
|
---|
239 | TH1F *h = pix.GetHGausHist();
|
---|
240 |
|
---|
241 | h->SetName ("HRelTimeLoGainPix");
|
---|
242 | h->SetTitle("Rel. Times Low Gain Pixel ");
|
---|
243 | h->SetXTitle("Rel. Arr. Time [FADC slices]");
|
---|
244 | h->SetYTitle("Nr. of events");
|
---|
245 |
|
---|
246 | InitHists((*this)(i),(*fBadPixels)[i],i);
|
---|
247 | }
|
---|
248 | }
|
---|
249 |
|
---|
250 |
|
---|
251 | if (fAverageHiGainAreas->GetEntries()==0)
|
---|
252 | {
|
---|
253 | fAverageHiGainAreas->Expand(nareas);
|
---|
254 |
|
---|
255 | for (Int_t j=0; j<nareas; j++)
|
---|
256 | {
|
---|
257 | (*fAverageHiGainAreas)[j] =
|
---|
258 | new MHCalibrationPix("RelTimeAverageHiGainArea",
|
---|
259 | "Average Rel. Arr. Times High Gain Area Idx ");
|
---|
260 |
|
---|
261 | MHCalibrationPix &pix = GetAverageHiGainArea(j);
|
---|
262 |
|
---|
263 | pix.SetNbins(fRelTimeNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
|
---|
264 | pix.SetFirst(fRelTimeFirst);
|
---|
265 | pix.SetLast (fRelTimeLast);
|
---|
266 |
|
---|
267 | TH1F *h = pix.GetHGausHist();
|
---|
268 |
|
---|
269 | h->SetName ("HRelTimeHiGainArea");
|
---|
270 | h->SetXTitle("Rel. Arr. Time [FADC slices]");
|
---|
271 | h->SetYTitle("Nr. of events");
|
---|
272 |
|
---|
273 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
274 | {
|
---|
275 | h->SetTitle(Form("%s%s%s","Rel. Times averaged on event-by-event basis ",
|
---|
276 | j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
|
---|
277 | pix.InitBins();
|
---|
278 | pix.SetEventFrequency(fPulserFrequency);
|
---|
279 | }
|
---|
280 | else
|
---|
281 | {
|
---|
282 | h->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
|
---|
283 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
|
---|
284 | }
|
---|
285 | }
|
---|
286 | }
|
---|
287 |
|
---|
288 | if (fAverageLoGainAreas->GetEntries()==0 && IsLoGain() )
|
---|
289 | {
|
---|
290 | fAverageLoGainAreas->Expand(nareas);
|
---|
291 |
|
---|
292 | for (Int_t j=0; j<nareas; j++)
|
---|
293 | {
|
---|
294 | (*fAverageLoGainAreas)[j] =
|
---|
295 | new MHCalibrationPix("RelTimeAverageAreaLoGain",
|
---|
296 | "Average Rel. Arr. Times Low Gain Area Idx ");
|
---|
297 |
|
---|
298 | MHCalibrationPix &pix = GetAverageLoGainArea(j);
|
---|
299 |
|
---|
300 | pix.SetNbins(fRelTimeNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
|
---|
301 | pix.SetFirst(fRelTimeFirst);
|
---|
302 | pix.SetLast (fRelTimeLast);
|
---|
303 |
|
---|
304 | TH1F *h = pix.GetHGausHist();
|
---|
305 |
|
---|
306 | h->SetName ("HRelTimeLoGainArea");
|
---|
307 | h->SetXTitle("Rel. Arr. Time [FADC slices]");
|
---|
308 | h->SetYTitle("Nr. of events");
|
---|
309 |
|
---|
310 | if (fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
311 | {
|
---|
312 | h->SetTitle(Form("%s%s%s","Rel. Times averaged on event-by-event basis ",
|
---|
313 | j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
|
---|
314 | pix.InitBins();
|
---|
315 | pix.SetEventFrequency(fPulserFrequency);
|
---|
316 | }
|
---|
317 | else
|
---|
318 | {
|
---|
319 | h->SetTitle("Rel. Times averaged on event-by-event basis Low Gain Area Idx ");
|
---|
320 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
|
---|
321 | }
|
---|
322 | }
|
---|
323 | }
|
---|
324 |
|
---|
325 | if (fAverageHiGainSectors->GetEntries()==0)
|
---|
326 | {
|
---|
327 | fAverageHiGainSectors->Expand(nsectors);
|
---|
328 |
|
---|
329 | for (Int_t j=0; j<nsectors; j++)
|
---|
330 | {
|
---|
331 | (*fAverageHiGainSectors)[j] =
|
---|
332 | new MHCalibrationPix("RelTimeAverageSectorHiGain",
|
---|
333 | "Average Rel. Arr. Times High Gain Sector ");
|
---|
334 |
|
---|
335 | MHCalibrationPix &pix = GetAverageHiGainSector(j);
|
---|
336 |
|
---|
337 | pix.SetNbins(fRelTimeNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors));
|
---|
338 | pix.SetFirst(fRelTimeFirst);
|
---|
339 | pix.SetLast (fRelTimeLast);
|
---|
340 |
|
---|
341 | TH1F *h = pix.GetHGausHist();
|
---|
342 |
|
---|
343 | h->SetName ("HRelTimeHiGainSector");
|
---|
344 | h->SetTitle("Rel. Times average High Gain Sector ");
|
---|
345 | h->SetXTitle("Rel. Arr. Time [FADC slices]");
|
---|
346 | h->SetYTitle("Nr. of events");
|
---|
347 |
|
---|
348 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
|
---|
349 | }
|
---|
350 | }
|
---|
351 |
|
---|
352 | if (fAverageLoGainSectors->GetEntries()==0 && IsLoGain() )
|
---|
353 | {
|
---|
354 | fAverageLoGainSectors->Expand(nsectors);
|
---|
355 |
|
---|
356 | for (Int_t j=0; j<nsectors; j++)
|
---|
357 | {
|
---|
358 | (*fAverageLoGainSectors)[j] =
|
---|
359 | new MHCalibrationPix("RelTimeAverageSectorLoGain",
|
---|
360 | "Average Rel. Arr. Times Low Gain Sector ");
|
---|
361 |
|
---|
362 | MHCalibrationPix &pix = GetAverageLoGainSector(j);
|
---|
363 |
|
---|
364 | pix.SetNbins(fRelTimeNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors));
|
---|
365 | pix.SetFirst(fRelTimeFirst);
|
---|
366 | pix.SetLast (fRelTimeLast);
|
---|
367 |
|
---|
368 | TH1F *h = pix.GetHGausHist();
|
---|
369 |
|
---|
370 | h->SetName ("HRelTimeLoGainSector");
|
---|
371 | h->SetTitle("Rel. Times average Low Gain Sector ");
|
---|
372 | h->SetXTitle("Rel. Arr. Time [FADC slices]");
|
---|
373 | h->SetYTitle("Nr. of events");
|
---|
374 |
|
---|
375 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
|
---|
376 | }
|
---|
377 | }
|
---|
378 |
|
---|
379 | fSumareahi .Set(nareas);
|
---|
380 | fSumarealo .Set(nareas);
|
---|
381 | fSumsectorhi.Set(nsectors);
|
---|
382 | fSumsectorlo.Set(nsectors);
|
---|
383 | fNumareahi .Set(nareas);
|
---|
384 | fNumarealo .Set(nareas);
|
---|
385 | fNumsectorhi.Set(nsectors);
|
---|
386 | fNumsectorlo.Set(nsectors);
|
---|
387 |
|
---|
388 | return kTRUE;
|
---|
389 | }
|
---|
390 |
|
---|
391 |
|
---|
392 | // -------------------------------------------------------------------------------
|
---|
393 | //
|
---|
394 | // Retrieves pointer to MArrivalTimeCam:
|
---|
395 | //
|
---|
396 | // Retrieves from MGeomCam:
|
---|
397 | // - number of pixels
|
---|
398 | // - number of pixel areas
|
---|
399 | // - number of sectors
|
---|
400 | //
|
---|
401 | // Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
|
---|
402 | // depending on MArrivalTimePix::IsLoGainUsed(), with:
|
---|
403 | // - MArrivalTimePix::GetArrivalTime(pixid) - MArrivalTimePix::GetArrivalTime(1);
|
---|
404 | // (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
|
---|
405 | //
|
---|
406 | Bool_t MHCalibrationRelTimeCam::FillHists(const MParContainer *par, const Stat_t w)
|
---|
407 | {
|
---|
408 |
|
---|
409 | MArrivalTimeCam *arrtime = (MArrivalTimeCam*)par;
|
---|
410 | if (!arrtime)
|
---|
411 | {
|
---|
412 | gLog << err << "No argument in MArrivalTime::Fill... abort." << endl;
|
---|
413 | return kFALSE;
|
---|
414 | }
|
---|
415 |
|
---|
416 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
417 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
418 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
419 |
|
---|
420 | fSumareahi .Reset();
|
---|
421 | fSumarealo .Reset();
|
---|
422 | fSumsectorhi.Reset();
|
---|
423 | fSumsectorlo.Reset();
|
---|
424 | fNumareahi .Reset();
|
---|
425 | fNumarealo .Reset();
|
---|
426 | fNumsectorhi.Reset();
|
---|
427 | fNumsectorlo.Reset();
|
---|
428 |
|
---|
429 | const MArrivalTimePix &refpix = (*arrtime)[fReferencePixel];
|
---|
430 | const Float_t reftime = refpix.IsLoGainUsed()
|
---|
431 | ? refpix.GetArrivalTimeLoGain() : refpix.GetArrivalTimeHiGain();
|
---|
432 |
|
---|
433 | for (Int_t i=0; i<npixels; i++)
|
---|
434 | {
|
---|
435 |
|
---|
436 | MHCalibrationPix &histhi = (*this)[i];
|
---|
437 | MHCalibrationPix &histlo = (*this)(i);
|
---|
438 |
|
---|
439 | if (histhi.IsExcluded())
|
---|
440 | continue;
|
---|
441 |
|
---|
442 | const MArrivalTimePix &pix = (*arrtime)[i];
|
---|
443 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
---|
444 | const Int_t sector = (*fGeom)[i].GetSector();
|
---|
445 |
|
---|
446 | if (pix.IsLoGainUsed() && IsLoGain())
|
---|
447 | {
|
---|
448 | const Float_t reltime = pix.GetArrivalTimeLoGain() - reftime;
|
---|
449 | histhi.SetSaturated(1);
|
---|
450 | histlo.FillHistAndArray(reltime);
|
---|
451 | fSumarealo [aidx] += reltime;
|
---|
452 | fNumarealo [aidx] ++;
|
---|
453 | fSumsectorlo[sector] += reltime;
|
---|
454 | fNumsectorlo[sector] ++;
|
---|
455 | }
|
---|
456 | else
|
---|
457 | {
|
---|
458 | const Float_t reltime = pix.GetArrivalTimeHiGain() - reftime;
|
---|
459 |
|
---|
460 | histhi.FillHistAndArray(reltime) ;
|
---|
461 | fSumareahi [aidx] += reltime;
|
---|
462 | fNumareahi [aidx] ++;
|
---|
463 | fSumsectorhi[sector] += reltime;
|
---|
464 | fNumsectorhi[sector] ++;
|
---|
465 | }
|
---|
466 | }
|
---|
467 |
|
---|
468 | for (Int_t j=0; j<nareas; j++)
|
---|
469 | {
|
---|
470 | MHCalibrationPix &histhi = GetAverageHiGainArea(j);
|
---|
471 | histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
|
---|
472 |
|
---|
473 | if (IsLoGain())
|
---|
474 | {
|
---|
475 | MHCalibrationPix &histlo = GetAverageLoGainArea(j);
|
---|
476 | histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
|
---|
477 | }
|
---|
478 | }
|
---|
479 |
|
---|
480 | for (Int_t j=0; j<nsectors; j++)
|
---|
481 | {
|
---|
482 | MHCalibrationPix &histhi = GetAverageHiGainSector(j);
|
---|
483 | histhi.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
|
---|
484 |
|
---|
485 | if (IsLoGain())
|
---|
486 | {
|
---|
487 | MHCalibrationPix &histlo = GetAverageLoGainSector(j);
|
---|
488 | histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
|
---|
489 | }
|
---|
490 | }
|
---|
491 |
|
---|
492 | return kTRUE;
|
---|
493 | }
|
---|
494 |
|
---|
495 | // --------------------------------------------------------------------------
|
---|
496 | //
|
---|
497 | // Calls:
|
---|
498 | // - MHCalibrationCam::FitHiGainArrays() with flags:
|
---|
499 | // MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
|
---|
500 | // - MHCalibrationCam::FitLoGainArrays() with flags:
|
---|
501 | // MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
|
---|
502 | //
|
---|
503 | Bool_t MHCalibrationRelTimeCam::FinalizeHists()
|
---|
504 | {
|
---|
505 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
---|
506 | {
|
---|
507 |
|
---|
508 | MHCalibrationPix &histhi = (*this)[i];
|
---|
509 |
|
---|
510 | if (histhi.IsExcluded())
|
---|
511 | continue;
|
---|
512 |
|
---|
513 | MCalibrationRelTimePix &pix = fIntensCam
|
---|
514 | ? (MCalibrationRelTimePix&)(*fIntensCam)[i]
|
---|
515 | : (MCalibrationRelTimePix&)(*fCam)[i];
|
---|
516 |
|
---|
517 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
518 | {
|
---|
519 | pix.SetHiGainSaturation();
|
---|
520 | histhi.SetExcluded();
|
---|
521 | }
|
---|
522 | else
|
---|
523 | if (IsLoGain())
|
---|
524 | (*this)(i).SetExcluded();
|
---|
525 |
|
---|
526 | Stat_t overflow = histhi.GetHGausHist()->GetBinContent(histhi.GetHGausHist()->GetNbinsX()+1);
|
---|
527 | if (overflow > 0.1)
|
---|
528 | {
|
---|
529 | *fLog << warn << GetDescriptor()
|
---|
530 | << ": HiGain Histogram Overflow occurred " << overflow
|
---|
531 | << " times in pixel: " << i << " (without saturation!) " << endl;
|
---|
532 | // bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
|
---|
533 | }
|
---|
534 |
|
---|
535 | overflow = histhi.GetHGausHist()->GetBinContent(0);
|
---|
536 | if (overflow > 0.1)
|
---|
537 | {
|
---|
538 | *fLog << warn << GetDescriptor()
|
---|
539 | << ": HiGain Histogram Underflow occurred " << overflow
|
---|
540 | << " times in pixel: " << i << " (without saturation!) " << endl;
|
---|
541 | // bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
|
---|
542 | }
|
---|
543 | }
|
---|
544 |
|
---|
545 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
---|
546 | {
|
---|
547 |
|
---|
548 | MHCalibrationPix &histhi = GetAverageHiGainArea(j);
|
---|
549 |
|
---|
550 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
551 | {
|
---|
552 | MCalibrationRelTimePix &pix = fIntensCam
|
---|
553 | ? (MCalibrationRelTimePix&)fIntensCam->GetAverageArea(j)
|
---|
554 | : (MCalibrationRelTimePix&)fCam->GetAverageArea(j);
|
---|
555 | pix.SetHiGainSaturation();
|
---|
556 | histhi.SetExcluded();
|
---|
557 | }
|
---|
558 | else
|
---|
559 | if (IsLoGain())
|
---|
560 | GetAverageLoGainArea(j).SetExcluded();
|
---|
561 |
|
---|
562 | }
|
---|
563 |
|
---|
564 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
---|
565 | {
|
---|
566 |
|
---|
567 | MHCalibrationPix &histhi = GetAverageHiGainSector(j);
|
---|
568 | MCalibrationRelTimePix &pix = fIntensCam
|
---|
569 | ? (MCalibrationRelTimePix&)fIntensCam->GetAverageSector(j)
|
---|
570 | : (MCalibrationRelTimePix&)fCam->GetAverageSector(j);
|
---|
571 |
|
---|
572 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
573 | {
|
---|
574 | pix.SetHiGainSaturation();
|
---|
575 | histhi.SetExcluded();
|
---|
576 | }
|
---|
577 | else
|
---|
578 | if (IsLoGain())
|
---|
579 | GetAverageLoGainSector(j).SetExcluded();
|
---|
580 | }
|
---|
581 |
|
---|
582 | FitHiGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
|
---|
583 | *fBadPixels,
|
---|
584 | MBadPixelsPix::kRelTimeNotFitted,
|
---|
585 | MBadPixelsPix::kRelTimeOscillating);
|
---|
586 |
|
---|
587 | if (IsLoGain())
|
---|
588 | FitLoGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
|
---|
589 | *fBadPixels,
|
---|
590 | MBadPixelsPix::kRelTimeNotFitted,
|
---|
591 | MBadPixelsPix::kRelTimeOscillating);
|
---|
592 |
|
---|
593 | return kTRUE;
|
---|
594 | }
|
---|
595 |
|
---|
596 | // --------------------------------------------------------------------------
|
---|
597 | //
|
---|
598 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
---|
599 | // - MBadPixelsPix::kRelTimeNotFitted
|
---|
600 | // - MBadPixelsPix::kRelTimeOscillating
|
---|
601 | //
|
---|
602 | void MHCalibrationRelTimeCam::FinalizeBadPixels()
|
---|
603 | {
|
---|
604 |
|
---|
605 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
606 | {
|
---|
607 |
|
---|
608 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
609 |
|
---|
610 | if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted ))
|
---|
611 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
612 |
|
---|
613 | if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
|
---|
614 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
615 |
|
---|
616 | }
|
---|
617 | }
|
---|
618 |
|
---|
619 | // --------------------------------------------------------------------------
|
---|
620 | //
|
---|
621 | // The types are as follows:
|
---|
622 | //
|
---|
623 | // Fitted values:
|
---|
624 | // ==============
|
---|
625 | //
|
---|
626 | // 0: Fitted Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMean()
|
---|
627 | // 1: Error Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMeanErr()
|
---|
628 | // 2: Sigma fitted Relative Arrival Time in FADC slices (MHGausEvents::GetSigma()
|
---|
629 | // 3: Error Sigma Relative Arrival Time in FADC slices (MHGausEvents::GetSigmaErr()
|
---|
630 | //
|
---|
631 | // Useful variables derived from the fit results:
|
---|
632 | // =============================================
|
---|
633 | //
|
---|
634 | // 4: Returned probability of Gauss fit (calls: MHGausEvents::GetProb())
|
---|
635 | //
|
---|
636 | // Localized defects:
|
---|
637 | // ==================
|
---|
638 | //
|
---|
639 | // 5: Gaus fit not OK (calls: MHGausEvents::IsGausFitOK())
|
---|
640 | // 6: Fourier spectrum not OK (calls: MHGausEvents::IsFourierSpectrumOK())
|
---|
641 | //
|
---|
642 | Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
643 | {
|
---|
644 |
|
---|
645 | if (fHiGainArray->GetSize() <= idx)
|
---|
646 | return kFALSE;
|
---|
647 |
|
---|
648 | const MHCalibrationPix &pix = (*this)[idx];
|
---|
649 |
|
---|
650 | switch (type)
|
---|
651 | {
|
---|
652 | case 0:
|
---|
653 | val = pix.GetMean();
|
---|
654 | break;
|
---|
655 | case 1:
|
---|
656 | val = pix.GetMeanErr();
|
---|
657 | break;
|
---|
658 | case 2:
|
---|
659 | val = pix.GetSigma();
|
---|
660 | break;
|
---|
661 | case 3:
|
---|
662 | val = pix.GetSigmaErr();
|
---|
663 | break;
|
---|
664 | case 4:
|
---|
665 | val = pix.GetProb();
|
---|
666 | break;
|
---|
667 | case 5:
|
---|
668 | if (!pix.IsGausFitOK())
|
---|
669 | val = 1.;
|
---|
670 | break;
|
---|
671 | case 6:
|
---|
672 | if (!pix.IsFourierSpectrumOK())
|
---|
673 | val = 1.;
|
---|
674 | break;
|
---|
675 | default:
|
---|
676 | return kFALSE;
|
---|
677 | }
|
---|
678 | return kTRUE;
|
---|
679 | }
|
---|
680 |
|
---|
681 | // --------------------------------------------------------------------------
|
---|
682 | //
|
---|
683 | // Calls MHCalibrationPix::DrawClone() for pixel idx
|
---|
684 | //
|
---|
685 | void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
|
---|
686 | {
|
---|
687 | (*this)[idx].DrawClone();
|
---|
688 | }
|
---|