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 | // MHCalibrationChargeCam
|
---|
27 | //
|
---|
28 | // Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes
|
---|
29 | // MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
|
---|
30 | //
|
---|
31 | // - pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and
|
---|
32 | // MHCalibrationCam::fLoGainArray
|
---|
33 | //
|
---|
34 | // - average pixel per area index (e.g. inner and outer for the MAGIC camera),
|
---|
35 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
|
---|
36 | // MHCalibrationCam::fAverageLoGainAreas
|
---|
37 | //
|
---|
38 | // - average pixel per camera sector (e.g. sectors 1-6 for the MAGIC camera),
|
---|
39 | // stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and
|
---|
40 | // MHCalibrationCam::fAverageLoGainSectors
|
---|
41 | //
|
---|
42 | // Every signal is filled into a Charge histogram and an array, in order to perform
|
---|
43 | // a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an
|
---|
44 | // event-by-event basis and written into the corresponding average pixels
|
---|
45 | //
|
---|
46 | // Additionally, the (FADC slice) position of the maximum is stored in an Absolute
|
---|
47 | // Arrival Time histogram. This histogram serves for a rough cross-check if the
|
---|
48 | // signal does not lie at or outside the edges of the extraction window.
|
---|
49 | //
|
---|
50 | // The Charge 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 fProbLimit (default: 0.5%), the fit is valid.
|
---|
53 | // Otherwise, the fit is repeated within ranges of the previous mean +- 5 sigma.
|
---|
54 | // In case this does not make the fit valid, the histogram means and RMS's are
|
---|
55 | // taken directly and the following flags are set:
|
---|
56 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or
|
---|
57 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
|
---|
58 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
59 | //
|
---|
60 | // Outliers of more than MHCalibrationChargePix::fPickupLimit (default: 5) sigmas
|
---|
61 | // from the mean are counted as PickUp events (stored in MHCalibrationChargePix::fPickup)
|
---|
62 | //
|
---|
63 | // Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
|
---|
64 | // slices show saturation, the following flag is set:
|
---|
65 | // - MCalibrationChargePix::SetHiGainSaturation();
|
---|
66 | // In that case, the calibration constants are derived from the low-gain results.
|
---|
67 | //
|
---|
68 | // If more than fNumLoGainSaturationLimit (default: 1%) of the overall
|
---|
69 | // low-gain FADC slices saturate, the following flags are set:
|
---|
70 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
|
---|
71 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun )
|
---|
72 | //
|
---|
73 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
---|
74 | // spectrum and investigates if the projected fourier components follow an exponential
|
---|
75 | // distribution. In case that the probability of the exponential fit is less than
|
---|
76 | // fProbLimit (default: 0.5%), the following flags are set:
|
---|
77 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
|
---|
78 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
|
---|
79 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
80 | //
|
---|
81 | // This same procedure is performed for the average pixels.
|
---|
82 | //
|
---|
83 | // The following results are written into MCalibrationChargeCam:
|
---|
84 | //
|
---|
85 | // - MCalibrationChargePix::SetHiGainSaturation(Bool_t b)
|
---|
86 | // - MCalibrationChargePix::SetHiGainMeanCharge()
|
---|
87 | // - MCalibrationChargePix::SetHiGainMeanChargeErr()
|
---|
88 | // - MCalibrationChargePix::SetHiGainSigmaCharge()
|
---|
89 | // - MCalibrationChargePix::SetHiGainSigmaChargeErr()
|
---|
90 | // - MCalibrationChargePix::SetHiGainChargeProb()
|
---|
91 | // - MCalibrationChargePix::SetHiGainNumPickup()
|
---|
92 | //
|
---|
93 | // - MCalibrationChargePix::SetLoGainMeanCharge()
|
---|
94 | // - MCalibrationChargePix::SetLoGainMeanChargeErr()
|
---|
95 | // - MCalibrationChargePix::SetLoGainSigmaCharge()
|
---|
96 | // - MCalibrationChargePix::SetLoGainSigmaChargeErr()
|
---|
97 | // - MCalibrationChargePix::SetLoGainChargeProb()
|
---|
98 | // - MCalibrationChargePix::SetLoGainNumPickup()
|
---|
99 | //
|
---|
100 | // - MCalibrationChargePix::SetAbsTimeMean()
|
---|
101 | // - MCalibrationChargePix::SetAbsTimeRms()
|
---|
102 | //
|
---|
103 | // The last two items are filled with the Hi-Gain or Lo-Gain result, depending on
|
---|
104 | // the saturation status.
|
---|
105 | //
|
---|
106 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
---|
107 | // the number involved pixels in order to be able to compare it to the average of
|
---|
108 | // sigmas in the camera.
|
---|
109 | //
|
---|
110 | /////////////////////////////////////////////////////////////////////////////
|
---|
111 | #include "MHCalibrationChargeCam.h"
|
---|
112 | #include "MHCalibrationCam.h"
|
---|
113 |
|
---|
114 | #include "MLog.h"
|
---|
115 | #include "MLogManip.h"
|
---|
116 |
|
---|
117 | #include "MParList.h"
|
---|
118 |
|
---|
119 | #include "MHCalibrationChargeHiGainPix.h"
|
---|
120 | #include "MHCalibrationChargeLoGainPix.h"
|
---|
121 | #include "MHCalibrationChargePix.h"
|
---|
122 |
|
---|
123 | #include "MCalibrationChargeCam.h"
|
---|
124 | #include "MCalibrationChargePix.h"
|
---|
125 |
|
---|
126 | #include "MGeomCam.h"
|
---|
127 | #include "MGeomPix.h"
|
---|
128 |
|
---|
129 | #include "MHGausEvents.h"
|
---|
130 |
|
---|
131 | #include "MBadPixelsCam.h"
|
---|
132 | #include "MBadPixelsPix.h"
|
---|
133 |
|
---|
134 | #include "MRawEvtData.h"
|
---|
135 | #include "MRawEvtPixelIter.h"
|
---|
136 |
|
---|
137 | #include "MExtractedSignalCam.h"
|
---|
138 | #include "MExtractedSignalPix.h"
|
---|
139 |
|
---|
140 | ClassImp(MHCalibrationChargeCam);
|
---|
141 |
|
---|
142 | using namespace std;
|
---|
143 |
|
---|
144 | const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
|
---|
145 | const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
|
---|
146 | // --------------------------------------------------------------------------
|
---|
147 | //
|
---|
148 | // Default Constructor.
|
---|
149 | //
|
---|
150 | // Sets:
|
---|
151 | // - all pointers to NULL
|
---|
152 | //
|
---|
153 | // Initializes:
|
---|
154 | // - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
|
---|
155 | // - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
|
---|
156 | //
|
---|
157 | MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
|
---|
158 | : fRawEvt(NULL)
|
---|
159 | {
|
---|
160 | fName = name ? name : "MHCalibrationChargeCam";
|
---|
161 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
---|
162 |
|
---|
163 | SetNumHiGainSaturationLimit();
|
---|
164 | SetNumLoGainSaturationLimit();
|
---|
165 | }
|
---|
166 |
|
---|
167 | // --------------------------------------------------------------------------
|
---|
168 | //
|
---|
169 | // Gets the pointers to:
|
---|
170 | // - MRawEvtData
|
---|
171 | //
|
---|
172 | Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
|
---|
173 | {
|
---|
174 |
|
---|
175 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
---|
176 | if (!fRawEvt)
|
---|
177 | {
|
---|
178 | *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
---|
179 | return kFALSE;
|
---|
180 | }
|
---|
181 |
|
---|
182 | return kTRUE;
|
---|
183 | }
|
---|
184 |
|
---|
185 | // --------------------------------------------------------------------------
|
---|
186 | //
|
---|
187 | // Gets or creates the pointers to:
|
---|
188 | // - MCalibrationChargeCam
|
---|
189 | //
|
---|
190 | // Searches pointer to:
|
---|
191 | // - MExtractedSignalCam
|
---|
192 | //
|
---|
193 | // Calls InitializeHists() for every entry in:
|
---|
194 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
195 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
196 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
197 | //
|
---|
198 | // Sets Titles and Names for the Charge Histograms and
|
---|
199 | // Sets number of bins to MHCalibrationCam::fAverageNbins for:
|
---|
200 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
201 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
202 | //
|
---|
203 | Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
|
---|
204 | {
|
---|
205 |
|
---|
206 | fCam = (MCalibrationCam*)pList->FindCreateObj("MCalibrationChargeCam");
|
---|
207 | if (!fCam)
|
---|
208 | return kFALSE;
|
---|
209 |
|
---|
210 | MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
---|
211 | if (!signal)
|
---|
212 | {
|
---|
213 | *fLog << err << "MExtractedSignalCam not found... abort." << endl;
|
---|
214 | return kFALSE;
|
---|
215 | }
|
---|
216 |
|
---|
217 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
218 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
219 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
220 |
|
---|
221 | if (fHiGainArray->GetEntries()==0)
|
---|
222 | {
|
---|
223 | fHiGainArray->Expand(npixels);
|
---|
224 | for (Int_t i=0; i<npixels; i++)
|
---|
225 | {
|
---|
226 | (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
|
---|
227 | InitHists((*this)[i],(*fBadPixels)[i],i);
|
---|
228 | }
|
---|
229 | }
|
---|
230 |
|
---|
231 | if (fLoGainArray->GetEntries()==0)
|
---|
232 | {
|
---|
233 | fLoGainArray->Expand(npixels);
|
---|
234 |
|
---|
235 | for (Int_t i=0; i<npixels; i++)
|
---|
236 | {
|
---|
237 | (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
|
---|
238 | InitHists((*this)(i),(*fBadPixels)[i],i);
|
---|
239 | }
|
---|
240 |
|
---|
241 | }
|
---|
242 |
|
---|
243 | if (fAverageHiGainAreas->GetEntries()==0)
|
---|
244 | {
|
---|
245 | fAverageHiGainAreas->Expand(nareas);
|
---|
246 |
|
---|
247 | for (Int_t j=0; j<nareas; j++)
|
---|
248 | {
|
---|
249 | (*fAverageHiGainAreas)[j] =
|
---|
250 | new MHCalibrationChargeHiGainPix("AverageHiGainArea",
|
---|
251 | "Average HiGain FADC sums area idx ");
|
---|
252 |
|
---|
253 | InitHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j);
|
---|
254 |
|
---|
255 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
---|
256 |
|
---|
257 | hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Area Idx ");
|
---|
258 | hist.SetNbins(fAverageNbins);
|
---|
259 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
|
---|
260 | }
|
---|
261 | }
|
---|
262 |
|
---|
263 | if (fAverageLoGainAreas->GetEntries()==0)
|
---|
264 | {
|
---|
265 | fAverageLoGainAreas->Expand(nareas);
|
---|
266 |
|
---|
267 | for (Int_t j=0; j<nareas; j++)
|
---|
268 | {
|
---|
269 | (*fAverageLoGainAreas)[j] =
|
---|
270 | new MHCalibrationChargeLoGainPix("AverageLoGainArea",
|
---|
271 | "Average LoGain FADC sums of pixel area idx ");
|
---|
272 |
|
---|
273 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
---|
274 |
|
---|
275 | InitHists(hist,fCam->GetAverageBadArea(j),j);
|
---|
276 |
|
---|
277 | hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Area Idx ");
|
---|
278 | hist.SetNbins(fAverageNbins);
|
---|
279 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
|
---|
280 |
|
---|
281 | }
|
---|
282 | }
|
---|
283 |
|
---|
284 | if (fAverageHiGainSectors->GetEntries()==0)
|
---|
285 | {
|
---|
286 | fAverageHiGainSectors->Expand(nsectors);
|
---|
287 |
|
---|
288 | for (Int_t j=0; j<nsectors; j++)
|
---|
289 | {
|
---|
290 | (*fAverageHiGainSectors)[j] =
|
---|
291 | new MHCalibrationChargeHiGainPix("AverageHiGainSector",
|
---|
292 | "Average HiGain FADC sums of pixel sector ");
|
---|
293 |
|
---|
294 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
---|
295 |
|
---|
296 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
---|
297 |
|
---|
298 | hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
|
---|
299 | hist.SetNbins(fAverageNbins);
|
---|
300 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
|
---|
301 |
|
---|
302 | }
|
---|
303 | }
|
---|
304 |
|
---|
305 | if (fAverageLoGainSectors->GetEntries()==0)
|
---|
306 | {
|
---|
307 | fAverageLoGainSectors->Expand(nsectors);
|
---|
308 |
|
---|
309 | for (Int_t j=0; j<nsectors; j++)
|
---|
310 | {
|
---|
311 | (*fAverageLoGainSectors)[j] =
|
---|
312 | new MHCalibrationChargeLoGainPix("AverageLoGainSector",
|
---|
313 | "Average LoGain FADC sums of pixel sector ");
|
---|
314 |
|
---|
315 | MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
---|
316 |
|
---|
317 | InitHists(hist,fCam->GetAverageBadSector(j),j);
|
---|
318 |
|
---|
319 | hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
|
---|
320 | hist.SetNbins(fAverageNbins);
|
---|
321 | hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
|
---|
322 |
|
---|
323 | }
|
---|
324 | }
|
---|
325 |
|
---|
326 | return kTRUE;
|
---|
327 | }
|
---|
328 |
|
---|
329 |
|
---|
330 | // --------------------------------------------------------------------------
|
---|
331 | //
|
---|
332 | // Retrieves from MExtractedSignalCam:
|
---|
333 | // - first used LoGain FADC slice
|
---|
334 | //
|
---|
335 | // Retrieves from MGeomCam:
|
---|
336 | // - number of pixels
|
---|
337 | // - number of pixel areas
|
---|
338 | // - number of sectors
|
---|
339 | //
|
---|
340 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
---|
341 | //
|
---|
342 | // 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
|
---|
343 | // - MExtractedSignalPix::GetExtractedSignalHiGain();
|
---|
344 | // - MExtractedSignalPix::GetExtractedSignalLoGain();
|
---|
345 | //
|
---|
346 | // 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
|
---|
347 | // - MExtractedSignalPix::GetNumHiGainSaturated();
|
---|
348 | // - MExtractedSignalPix::GetNumLoGainSaturated();
|
---|
349 | //
|
---|
350 | // 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
|
---|
351 | // - MRawEvtPixelIter::GetIdxMaxHiGainSample();
|
---|
352 | // - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
|
---|
353 | //
|
---|
354 | Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
|
---|
355 | {
|
---|
356 |
|
---|
357 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
---|
358 | if (!signal)
|
---|
359 | {
|
---|
360 | *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
|
---|
361 | return kFALSE;
|
---|
362 | }
|
---|
363 |
|
---|
364 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
365 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
366 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
367 | const Int_t lofirst = signal->GetFirstUsedSliceLoGain();
|
---|
368 |
|
---|
369 | Float_t sumhiarea [nareas], sumloarea [nareas], timehiarea [nareas], timeloarea [nareas];
|
---|
370 | Float_t sumhisector[nsectors], sumlosector[nsectors], timehisector[nsectors], timelosector[nsectors];
|
---|
371 | Int_t sathiarea [nareas], satloarea [nareas];
|
---|
372 | Int_t sathisector[nsectors], satlosector[nsectors];
|
---|
373 |
|
---|
374 | for (UInt_t j=0; j<nareas; j++)
|
---|
375 | {
|
---|
376 | sumhiarea [j] = sumloarea [j] = timehiarea [j] = timeloarea [j] = 0.;
|
---|
377 | sathiarea [j] = satloarea [j] = 0;
|
---|
378 | }
|
---|
379 |
|
---|
380 | for (UInt_t j=0; j<nsectors; j++)
|
---|
381 | {
|
---|
382 | sumhisector[j] = sumlosector[j] = timehisector[j] = timelosector[j] = 0.;
|
---|
383 | sathisector[j] = satlosector[j] = 0;
|
---|
384 | }
|
---|
385 |
|
---|
386 |
|
---|
387 | for (Int_t i=0; i<npixels; i++)
|
---|
388 | {
|
---|
389 |
|
---|
390 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
---|
391 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
---|
392 |
|
---|
393 | if (histhi.IsExcluded())
|
---|
394 | continue;
|
---|
395 |
|
---|
396 | const MExtractedSignalPix &pix = (*signal)[i];
|
---|
397 |
|
---|
398 | const Float_t sumhi = pix.GetExtractedSignalHiGain();
|
---|
399 | const Float_t sumlo = pix.GetExtractedSignalLoGain();
|
---|
400 |
|
---|
401 | histhi.FillHistAndArray(sumhi);
|
---|
402 | histlo.FillHistAndArray(sumlo);
|
---|
403 |
|
---|
404 | const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
|
---|
405 | const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
|
---|
406 |
|
---|
407 | histhi.SetSaturated(sathi);
|
---|
408 | histlo.SetSaturated(satlo);
|
---|
409 |
|
---|
410 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
---|
411 | const Int_t sector = (*fGeom)[i].GetSector();
|
---|
412 |
|
---|
413 | sumhiarea[aidx] += sumhi;
|
---|
414 | sumloarea[aidx] += sumlo;
|
---|
415 | sathiarea[aidx] += sathi;
|
---|
416 | satloarea[aidx] += satlo;
|
---|
417 |
|
---|
418 | sumhisector[sector] += sumhi;
|
---|
419 | sumlosector[sector] += sumlo;
|
---|
420 | sathisector[sector] += sathi;
|
---|
421 | satlosector[sector] += satlo;
|
---|
422 | }
|
---|
423 |
|
---|
424 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
425 | while (pixel.Next())
|
---|
426 | {
|
---|
427 |
|
---|
428 | const UInt_t pixid = pixel.GetPixelId();
|
---|
429 |
|
---|
430 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
|
---|
431 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
|
---|
432 |
|
---|
433 | if (histhi.IsExcluded())
|
---|
434 | continue;
|
---|
435 |
|
---|
436 | const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
|
---|
437 | const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
|
---|
438 |
|
---|
439 | histhi.FillAbsTime(timehi);
|
---|
440 | histlo.FillAbsTime(timelo);
|
---|
441 |
|
---|
442 | const Int_t aidx = (*fGeom)[pixid].GetAidx();
|
---|
443 | const Int_t sector = (*fGeom)[pixid].GetSector();
|
---|
444 |
|
---|
445 | timehiarea[aidx] += timehi;
|
---|
446 | timeloarea[aidx] += timelo;
|
---|
447 |
|
---|
448 | timehisector[sector] += timehi;
|
---|
449 | timelosector[sector] += timelo;
|
---|
450 | }
|
---|
451 |
|
---|
452 | for (UInt_t j=0; j<nareas; j++)
|
---|
453 | {
|
---|
454 |
|
---|
455 | const Int_t npix = fAverageAreaNum[j];
|
---|
456 |
|
---|
457 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
---|
458 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
---|
459 |
|
---|
460 | hipix.FillHistAndArray(sumhiarea[j]/npix);
|
---|
461 | lopix.FillHistAndArray(sumloarea[j]/npix);
|
---|
462 |
|
---|
463 | hipix.SetSaturated((Float_t)sathiarea[j]/npix);
|
---|
464 | lopix.SetSaturated((Float_t)satloarea[j]/npix);
|
---|
465 |
|
---|
466 | hipix.FillAbsTime(timehiarea[j]/npix);
|
---|
467 | lopix.FillAbsTime(timeloarea[j]/npix);
|
---|
468 |
|
---|
469 | }
|
---|
470 |
|
---|
471 | for (UInt_t j=0; j<nsectors; j++)
|
---|
472 | {
|
---|
473 |
|
---|
474 | const Int_t npix = fAverageSectorNum[j];
|
---|
475 |
|
---|
476 | MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
---|
477 | MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
---|
478 |
|
---|
479 | hipix.FillHistAndArray(sumhisector[j]/npix);
|
---|
480 | lopix.FillHistAndArray(sumlosector[j]/npix);
|
---|
481 |
|
---|
482 | hipix.SetSaturated((Float_t)sathisector[j]/npix);
|
---|
483 | lopix.SetSaturated((Float_t)satlosector[j]/npix);
|
---|
484 |
|
---|
485 | hipix.FillAbsTime(timehisector[j]/npix);
|
---|
486 | lopix.FillAbsTime(timelosector[j]/npix);
|
---|
487 |
|
---|
488 | }
|
---|
489 |
|
---|
490 | return kTRUE;
|
---|
491 | }
|
---|
492 |
|
---|
493 | // --------------------------------------------------------------------------
|
---|
494 | //
|
---|
495 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
---|
496 | //
|
---|
497 | // 1) Returns if the pixel is excluded.
|
---|
498 | // 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
|
---|
499 | // or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
|
---|
500 | // 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
|
---|
501 | // MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
|
---|
502 | // otherwise the Hi-Gain ones.
|
---|
503 | // 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
|
---|
504 | // and sets the flags (if occurring):
|
---|
505 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
|
---|
506 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
|
---|
507 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
|
---|
508 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
|
---|
509 | // 5) Retrieves the results and store them in MCalibrationChargePix
|
---|
510 | //
|
---|
511 | Bool_t MHCalibrationChargeCam::FinalizeHists()
|
---|
512 | {
|
---|
513 |
|
---|
514 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
---|
515 | {
|
---|
516 |
|
---|
517 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
|
---|
518 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
519 |
|
---|
520 | if (histhi.IsExcluded())
|
---|
521 | continue;
|
---|
522 |
|
---|
523 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
524 | {
|
---|
525 | pix.SetHiGainSaturation();
|
---|
526 | histhi.CreateFourierSpectrum();
|
---|
527 | continue;
|
---|
528 | }
|
---|
529 |
|
---|
530 | pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
|
---|
531 | pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
|
---|
532 | }
|
---|
533 |
|
---|
534 | for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
|
---|
535 | {
|
---|
536 |
|
---|
537 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
|
---|
538 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
539 |
|
---|
540 | if (histlo.IsExcluded())
|
---|
541 | continue;
|
---|
542 |
|
---|
543 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
---|
544 | {
|
---|
545 | *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
|
---|
546 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
---|
547 | histlo.CreateFourierSpectrum();
|
---|
548 | continue;
|
---|
549 | }
|
---|
550 |
|
---|
551 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
552 |
|
---|
553 | if (pix.IsHiGainSaturation())
|
---|
554 | {
|
---|
555 | pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
|
---|
556 | pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
|
---|
557 | }
|
---|
558 | }
|
---|
559 |
|
---|
560 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
---|
561 | {
|
---|
562 |
|
---|
563 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
|
---|
564 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
---|
565 |
|
---|
566 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
567 | {
|
---|
568 | pix.SetHiGainSaturation();
|
---|
569 | histhi.CreateFourierSpectrum();
|
---|
570 | continue;
|
---|
571 | }
|
---|
572 |
|
---|
573 | pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
|
---|
574 | pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
|
---|
575 | }
|
---|
576 |
|
---|
577 | for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
|
---|
578 | {
|
---|
579 |
|
---|
580 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
|
---|
581 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
|
---|
582 |
|
---|
583 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
---|
584 | {
|
---|
585 | *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
|
---|
586 | histlo.CreateFourierSpectrum();
|
---|
587 | continue;
|
---|
588 | }
|
---|
589 |
|
---|
590 | if (pix.IsHiGainSaturation())
|
---|
591 | {
|
---|
592 | pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
|
---|
593 | pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
|
---|
594 | }
|
---|
595 | }
|
---|
596 |
|
---|
597 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
---|
598 | {
|
---|
599 |
|
---|
600 | MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
|
---|
601 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
---|
602 |
|
---|
603 | if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
|
---|
604 | {
|
---|
605 | pix.SetHiGainSaturation();
|
---|
606 | histhi.CreateFourierSpectrum();
|
---|
607 | continue;
|
---|
608 | }
|
---|
609 |
|
---|
610 | pix.SetAbsTimeMean ( histhi.GetAbsTimeMean());
|
---|
611 | pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() );
|
---|
612 | }
|
---|
613 |
|
---|
614 | for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
|
---|
615 | {
|
---|
616 |
|
---|
617 | MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
|
---|
618 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
|
---|
619 | MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
|
---|
620 |
|
---|
621 | if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
|
---|
622 | {
|
---|
623 | *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
|
---|
624 | bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
|
---|
625 | histlo.CreateFourierSpectrum();
|
---|
626 | continue;
|
---|
627 | }
|
---|
628 |
|
---|
629 | if (pix.IsHiGainSaturation())
|
---|
630 | {
|
---|
631 | pix.SetAbsTimeMean ( histlo.GetAbsTimeMean());
|
---|
632 | pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() );
|
---|
633 | }
|
---|
634 | }
|
---|
635 |
|
---|
636 | //
|
---|
637 | // Perform the fitting for the High Gain (done in MHCalibrationCam)
|
---|
638 | //
|
---|
639 | FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
---|
640 | MBadPixelsPix::kHiGainNotFitted,
|
---|
641 | MBadPixelsPix::kHiGainOscillating);
|
---|
642 | //
|
---|
643 | // Perform the fitting for the Low Gain (done in MHCalibrationCam)
|
---|
644 | //
|
---|
645 | FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
|
---|
646 | MBadPixelsPix::kLoGainNotFitted,
|
---|
647 | MBadPixelsPix::kLoGainOscillating);
|
---|
648 |
|
---|
649 | return kTRUE;
|
---|
650 | }
|
---|
651 |
|
---|
652 | // --------------------------------------------------------------------------
|
---|
653 | //
|
---|
654 | // Takes the decisions under which conditions a pixel is declared:
|
---|
655 | // MBadPixelsPix::kUnsuitableRun or MBadPixelsPix::kUnreliableRun, namely:
|
---|
656 | // * if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
|
---|
657 | // sets MBadPixelsPix::kUnreliableRun
|
---|
658 | // * if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
|
---|
659 | // sets MBadPixelsPix::kUnreliableRun
|
---|
660 | // * if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
|
---|
661 | // sets MBadPixelsPix::kUnreliableRun
|
---|
662 | // * if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
|
---|
663 | // sets MBadPixelsPix::kUnreliableRun
|
---|
664 | // * if MBadPixelsPix::kLoGainSaturation
|
---|
665 | // sets MBadPixelsPix::kUnsuitableRun
|
---|
666 | //
|
---|
667 | void MHCalibrationChargeCam::FinalizeBadPixels()
|
---|
668 | {
|
---|
669 |
|
---|
670 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
671 | {
|
---|
672 |
|
---|
673 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
674 | MCalibrationPix &pix = (*fCam)[i];
|
---|
675 |
|
---|
676 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
|
---|
677 | if (!pix.IsHiGainSaturation())
|
---|
678 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
679 |
|
---|
680 | if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
|
---|
681 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
682 |
|
---|
683 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
|
---|
684 | if (pix.IsHiGainSaturation())
|
---|
685 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
686 |
|
---|
687 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
|
---|
688 | if (pix.IsHiGainSaturation())
|
---|
689 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
690 |
|
---|
691 | if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
|
---|
692 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
693 | }
|
---|
694 | }
|
---|
695 |
|
---|
696 | // --------------------------------------------------------------------------
|
---|
697 | //
|
---|
698 | // Dummy, needed by MCamEvent
|
---|
699 | //
|
---|
700 | Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
701 | {
|
---|
702 | return kTRUE;
|
---|
703 | }
|
---|
704 |
|
---|
705 | // --------------------------------------------------------------------------
|
---|
706 | //
|
---|
707 | // What MHCamera needs in order to draw an individual pixel in the camera
|
---|
708 | //
|
---|
709 | void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
|
---|
710 | {
|
---|
711 | (*this)[idx].DrawClone();
|
---|
712 | }
|
---|
713 |
|
---|