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 | !
|
---|
19 | ! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MHCalibrationChargeCam
|
---|
29 | //
|
---|
30 | // Fills the extracted signals of MExtractedSignalCam into the MH-classes:
|
---|
31 | //
|
---|
32 | // MHCalibrationChargeHiGainPix, MHCalibrationChargeLoGainPix for each pixel
|
---|
33 | // and additionally for an average of the inner and the outer pixels, respectively.
|
---|
34 | //
|
---|
35 | // By default, subsequently the hi-gain classes are treated unless
|
---|
36 | // more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
|
---|
37 | // slices show saturation. In that case, the low-gain classes are treated.
|
---|
38 | // If more than fNumLoGainSaturationLimit (default: 1%) of the overall
|
---|
39 | // low-gain FADC slices saturate, the pixel is declared not valid and no further
|
---|
40 | // treatment is pursued.
|
---|
41 | //
|
---|
42 | // The filled histograms are fitted to a Gaussian and the mean and sigma with
|
---|
43 | // its errors and the fit probability are extracted. If none of these values are
|
---|
44 | // NaN's and if the probability is bigger than fProbLimit (default: 0.5%), the fit
|
---|
45 | // is declared valid. Otherwise, the fit is repeated within ranges of the previous mean
|
---|
46 | // +- 5 sigma. In case that this does not help, the histogram means and RMS's are taken directly,
|
---|
47 | // but the flag kFitValid is set to FALSE. Outliers of more than fPickUpLimit (default: 5) sigmas
|
---|
48 | // from the mean are counted as PickUp events.
|
---|
49 | //
|
---|
50 | // Additionally, the slice number with the highest value is stored and a corresponding
|
---|
51 | // histogram is filled. This histogram serves only for a rough cross-check if the
|
---|
52 | // signal does not lie at the edges of chose extraction window.
|
---|
53 | //
|
---|
54 | // The class also fills arrays with the signal vs. event number, creates a fourier
|
---|
55 | // spectrum out of it and investigates if the projected frequencies follow an exponential
|
---|
56 | // distribution. In case that the probability of the exponential fit is less than
|
---|
57 | // fProbLimit, the pixel is declared HiGainOscillating or LoGainOscillating, respectively.
|
---|
58 | //
|
---|
59 | // The results are written into MCalibrationChargeCam.
|
---|
60 | //
|
---|
61 | /////////////////////////////////////////////////////////////////////////////
|
---|
62 | #include "MHCalibrationChargeCam.h"
|
---|
63 |
|
---|
64 | #include <TVirtualPad.h>
|
---|
65 | #include <TCanvas.h>
|
---|
66 | #include <TPad.h>
|
---|
67 |
|
---|
68 | #include "MLog.h"
|
---|
69 | #include "MLogManip.h"
|
---|
70 |
|
---|
71 | #include "MParList.h"
|
---|
72 |
|
---|
73 | #include "MHCalibrationChargeHiGainPix.h"
|
---|
74 | #include "MHCalibrationChargeLoGainPix.h"
|
---|
75 | #include "MHCalibrationChargePix.h"
|
---|
76 |
|
---|
77 | #include "MCalibrationChargeCam.h"
|
---|
78 | #include "MCalibrationChargePix.h"
|
---|
79 |
|
---|
80 | #include "MGeomCam.h"
|
---|
81 | #include "MGeomPix.h"
|
---|
82 |
|
---|
83 | #include "MBadPixelsCam.h"
|
---|
84 | #include "MBadPixelsPix.h"
|
---|
85 |
|
---|
86 | #include "MRawEvtData.h"
|
---|
87 | #include "MRawEvtPixelIter.h"
|
---|
88 |
|
---|
89 | #include "MExtractedSignalCam.h"
|
---|
90 | #include "MExtractedSignalPix.h"
|
---|
91 |
|
---|
92 | ClassImp(MHCalibrationChargeCam);
|
---|
93 |
|
---|
94 | using namespace std;
|
---|
95 |
|
---|
96 | const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.005;
|
---|
97 | const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
|
---|
98 | //
|
---|
99 | //
|
---|
100 | //
|
---|
101 | MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
|
---|
102 | : fRawEvt(NULL), fGeom(NULL), fBadPixels(NULL)
|
---|
103 | {
|
---|
104 | fName = name ? name : "MHCalibrationChargeCam";
|
---|
105 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
---|
106 |
|
---|
107 | fHiGainArray = new TObjArray;
|
---|
108 | fHiGainArray->SetOwner();
|
---|
109 |
|
---|
110 | fLoGainArray = new TObjArray;
|
---|
111 | fLoGainArray->SetOwner();
|
---|
112 |
|
---|
113 | fAverageHiGainInnerPix = new MHCalibrationChargeHiGainPix("AverageHiGainInnerPix","Average HiGain FADC sums of inner pixels");
|
---|
114 | fAverageLoGainInnerPix = new MHCalibrationChargeLoGainPix("AverageLoGainInnerPix","Average LoGain FADC sums of inner pixels");
|
---|
115 | fAverageHiGainOuterPix = new MHCalibrationChargeHiGainPix("AverageHiGainOuterPix","Average HiGain FADC sums of outer pixels");
|
---|
116 | fAverageLoGainOuterPix = new MHCalibrationChargeLoGainPix("AverageLoGainOuterPix","Average LoGain FADC sums of outer pixels");
|
---|
117 |
|
---|
118 | /*
|
---|
119 | fAverageHiGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerHiGainPix");
|
---|
120 | fAverageHiGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterHiGainPix");
|
---|
121 | fAverageLoGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerLoGainPix");
|
---|
122 | fAverageLoGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterLoGainPix");
|
---|
123 | */
|
---|
124 | fAverageHiGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels HiGain");
|
---|
125 | fAverageLoGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels LoGain");
|
---|
126 | fAverageHiGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels HiGain");
|
---|
127 | fAverageLoGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels LoGain");
|
---|
128 |
|
---|
129 | fAverageHiGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels HiGain");
|
---|
130 | fAverageLoGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels LoGain");
|
---|
131 | fAverageHiGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels HiGain");
|
---|
132 | fAverageLoGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels LoGain");
|
---|
133 |
|
---|
134 | fAverageHiGainInnerPix->SetChargeFirst(-1000.);
|
---|
135 | fAverageHiGainOuterPix->SetChargeFirst(-1000.);
|
---|
136 |
|
---|
137 | fAverageHiGainInnerPix->SetChargeLast(4000.);
|
---|
138 | fAverageLoGainInnerPix->SetChargeLast(4000.);
|
---|
139 | fAverageHiGainOuterPix->SetChargeLast(4000.);
|
---|
140 | fAverageLoGainOuterPix->SetChargeLast(4000.);
|
---|
141 |
|
---|
142 | fAverageHiGainInnerPix->SetChargeNbins(4000);
|
---|
143 | fAverageLoGainInnerPix->SetChargeNbins(4000);
|
---|
144 | fAverageHiGainOuterPix->SetChargeNbins(4000);
|
---|
145 | fAverageLoGainOuterPix->SetChargeNbins(4000);
|
---|
146 |
|
---|
147 | SetNumHiGainSaturationLimit();
|
---|
148 | SetNumLoGainSaturationLimit();
|
---|
149 |
|
---|
150 | fNumInnerPixels = 0;
|
---|
151 | fNumOuterPixels = 0;
|
---|
152 | fNumExcluded = 0;
|
---|
153 | }
|
---|
154 |
|
---|
155 | // --------------------------------------------------------------------------
|
---|
156 | //
|
---|
157 | // Delete the TClonesArray of MHCalibrationChargePix containers
|
---|
158 | // Delete the MHCalibrationPINDiode and the MHCalibrationBlindPix
|
---|
159 | //
|
---|
160 | // Delete the histograms if they exist
|
---|
161 | //
|
---|
162 | MHCalibrationChargeCam::~MHCalibrationChargeCam()
|
---|
163 | {
|
---|
164 | delete fHiGainArray;
|
---|
165 | delete fLoGainArray;
|
---|
166 |
|
---|
167 | delete fAverageHiGainInnerPix;
|
---|
168 | delete fAverageLoGainInnerPix;
|
---|
169 | delete fAverageHiGainOuterPix;
|
---|
170 | delete fAverageLoGainOuterPix;
|
---|
171 | }
|
---|
172 |
|
---|
173 | // --------------------------------------------------------------------------
|
---|
174 | //
|
---|
175 | // Get i-th pixel (pixel number)
|
---|
176 | //
|
---|
177 | MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i)
|
---|
178 | {
|
---|
179 | return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
|
---|
180 | }
|
---|
181 |
|
---|
182 | // --------------------------------------------------------------------------
|
---|
183 | //
|
---|
184 | // Get i-th pixel (pixel number)
|
---|
185 | //
|
---|
186 | const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i) const
|
---|
187 | {
|
---|
188 | return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
|
---|
189 | }
|
---|
190 |
|
---|
191 | // --------------------------------------------------------------------------
|
---|
192 | //
|
---|
193 | // Get i-th pixel (pixel number)
|
---|
194 | //
|
---|
195 | MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i)
|
---|
196 | {
|
---|
197 | return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
|
---|
198 | }
|
---|
199 |
|
---|
200 | // --------------------------------------------------------------------------
|
---|
201 | //
|
---|
202 | // Get i-th pixel (pixel number)
|
---|
203 | //
|
---|
204 | const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i) const
|
---|
205 | {
|
---|
206 | return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
|
---|
207 | }
|
---|
208 |
|
---|
209 |
|
---|
210 | #if 0
|
---|
211 | // --------------------------------------------------------------------------
|
---|
212 | //
|
---|
213 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
---|
214 | // I don't know the reason
|
---|
215 | //
|
---|
216 | TObject *MHCalibrationChargeCam::Clone(const char *) const
|
---|
217 | {
|
---|
218 |
|
---|
219 | const Int_t nhi = fHiGainArray->GetSize();
|
---|
220 | const Int_t nlo = fLoGainArray->GetSize();
|
---|
221 | //
|
---|
222 | // FIXME, this might be done faster and more elegant, by direct copy.
|
---|
223 | //
|
---|
224 | MHCalibrationChargeCam *cam = (MHCalibrationChargeCam*)(this)->Clone("");
|
---|
225 | // MHCalibrationChargeCam cam;
|
---|
226 | // Copy(*cam);
|
---|
227 |
|
---|
228 | /*
|
---|
229 | cam->fHiGainArray->Delete();
|
---|
230 | cam->fLoGainArray->Delete();
|
---|
231 |
|
---|
232 | cam->fHiGainArray->Expand(nhi);
|
---|
233 | cam->fLoGainArray->Expand(nlo);
|
---|
234 |
|
---|
235 | for (int i=0; i<nhi; i++)
|
---|
236 | {
|
---|
237 | delete (*cam->fHiGainArray)[i];
|
---|
238 | (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
|
---|
239 | }
|
---|
240 | for (int i=0; i<nlo; i++)
|
---|
241 | {
|
---|
242 | delete (*cam->fLoGainArray)[i];
|
---|
243 | (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
|
---|
244 | }
|
---|
245 | */
|
---|
246 |
|
---|
247 | /*
|
---|
248 | delete cam->fAverageHiGainInnerPix;
|
---|
249 | delete cam->fAverageLoGainInnerPix;
|
---|
250 | delete cam->fAverageHiGainOuterPix;
|
---|
251 | delete cam->fAverageLoGainOuterPix;
|
---|
252 |
|
---|
253 | cam->GetAverageHiGainInnerPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainInnerPix->Clone();
|
---|
254 | cam->GetAverageLoGainInnerPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainInnerPix->Clone();
|
---|
255 |
|
---|
256 | cam->GetAverageHiGainOuterPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainOuterPix->Clone();
|
---|
257 | cam->GetAverageLoGainOuterPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainOuterPix->Clone();
|
---|
258 |
|
---|
259 | fAverageHiGainInnerPix->Copy(cam->GetAverageHiGainInnerPix());
|
---|
260 | fAverageLoGainInnerPix->Copy(cam->GetAverageLoGainInnerPix());
|
---|
261 | fAverageHiGainOuterPix->Copy(cam->GetAverageHiGainOuterPix());
|
---|
262 | fAverageLoGainOuterPix->Copy(cam->GetAverageLoGainOuterPix());
|
---|
263 | */
|
---|
264 |
|
---|
265 | return cam;
|
---|
266 | }
|
---|
267 | #endif
|
---|
268 | // --------------------------------------------------------------------------
|
---|
269 | //
|
---|
270 | // To setup the object we get the number of pixels from a MGeomCam object
|
---|
271 | // in the Parameter list.
|
---|
272 | //
|
---|
273 | Bool_t MHCalibrationChargeCam::SetupFill(const MParList *pList)
|
---|
274 | {
|
---|
275 |
|
---|
276 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
---|
277 | if (!fRawEvt)
|
---|
278 | {
|
---|
279 | *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
---|
280 | return kFALSE;
|
---|
281 | }
|
---|
282 |
|
---|
283 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
284 | if (!fGeom)
|
---|
285 | {
|
---|
286 | *fLog << err << "MGeomCam not found... aborting." << endl;
|
---|
287 | return kFALSE;
|
---|
288 | }
|
---|
289 |
|
---|
290 | fHiGainArray->Delete();
|
---|
291 | fLoGainArray->Delete();
|
---|
292 |
|
---|
293 | fAverageHiGainInnerPix->Init();
|
---|
294 | fAverageLoGainInnerPix->Init();
|
---|
295 | fAverageHiGainOuterPix->Init();
|
---|
296 | fAverageLoGainOuterPix->Init();
|
---|
297 |
|
---|
298 | return kTRUE;
|
---|
299 | }
|
---|
300 |
|
---|
301 | Bool_t MHCalibrationChargeCam::ReInit(MParList *pList)
|
---|
302 | {
|
---|
303 |
|
---|
304 | fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
|
---|
305 | if (!fBadPixels)
|
---|
306 | return kFALSE;
|
---|
307 |
|
---|
308 |
|
---|
309 | fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
|
---|
310 | if (!fCam)
|
---|
311 | return kFALSE;
|
---|
312 |
|
---|
313 | MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
---|
314 | if (!signal)
|
---|
315 | {
|
---|
316 | *fLog << err << "MExtractedSignalCam not found... abort." << endl;
|
---|
317 | return kFALSE;
|
---|
318 | }
|
---|
319 |
|
---|
320 | const Int_t n = signal->GetSize();
|
---|
321 |
|
---|
322 | if (fHiGainArray->GetEntries()==0)
|
---|
323 | {
|
---|
324 | fHiGainArray->Expand(n);
|
---|
325 |
|
---|
326 | for (Int_t i=0; i<n; i++)
|
---|
327 | {
|
---|
328 | //
|
---|
329 | // Oscillating pixels
|
---|
330 | //
|
---|
331 | (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
|
---|
332 |
|
---|
333 | if ((*fBadPixels)[i].IsBad())
|
---|
334 | {
|
---|
335 | fNumExcluded++;
|
---|
336 | (*this)[i].SetExcluded();
|
---|
337 | }
|
---|
338 | (*this)[i].Init();
|
---|
339 | (*this)[i].ChangeHistId(i);
|
---|
340 | }
|
---|
341 | }
|
---|
342 |
|
---|
343 |
|
---|
344 | if (fLoGainArray->GetEntries()==0)
|
---|
345 | {
|
---|
346 | fLoGainArray->Expand(n);
|
---|
347 |
|
---|
348 | for (Int_t i=0; i<n; i++)
|
---|
349 | {
|
---|
350 | (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
|
---|
351 | //
|
---|
352 | // Pixels with non-valid behavior
|
---|
353 | //
|
---|
354 | if ((*fBadPixels)[i].IsBad())
|
---|
355 | (*this)(i).SetExcluded();
|
---|
356 |
|
---|
357 | (*this)(i).Init();
|
---|
358 | (*this)(i).ChangeHistId(i);
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 |
|
---|
363 | *fLog << inf << GetDescriptor() << ": " << fNumExcluded << " excluded Pixels " << endl;
|
---|
364 |
|
---|
365 | return kTRUE;
|
---|
366 | }
|
---|
367 |
|
---|
368 |
|
---|
369 | // --------------------------------------------------------------------------
|
---|
370 | Bool_t MHCalibrationChargeCam::Fill(const MParContainer *par, const Stat_t w)
|
---|
371 | {
|
---|
372 |
|
---|
373 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
---|
374 | if (!signal)
|
---|
375 | {
|
---|
376 | *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
|
---|
377 | return kFALSE;
|
---|
378 | }
|
---|
379 |
|
---|
380 | Int_t n = signal->GetSize();
|
---|
381 |
|
---|
382 | if (fHiGainArray->GetEntries() != n)
|
---|
383 | {
|
---|
384 | *fLog << err << "ERROR - Size mismatch... abort." << endl;
|
---|
385 | return kFALSE;
|
---|
386 | }
|
---|
387 |
|
---|
388 | if (fLoGainArray->GetEntries() != n)
|
---|
389 | {
|
---|
390 | *fLog << err << "ERROR - Size mismatch... abort." << endl;
|
---|
391 | return kFALSE;
|
---|
392 | }
|
---|
393 |
|
---|
394 | //
|
---|
395 | // First the extracted signal
|
---|
396 | //
|
---|
397 | Float_t sumhiinnertot = 0.;
|
---|
398 | Float_t sumloinnertot = 0.;
|
---|
399 | Float_t sumhioutertot = 0.;
|
---|
400 | Float_t sumlooutertot = 0.;
|
---|
401 | Int_t sumhiinnersat = 0;
|
---|
402 | Int_t sumloinnersat = 0;
|
---|
403 | Int_t sumhioutersat = 0;
|
---|
404 | Int_t sumlooutersat = 0;
|
---|
405 |
|
---|
406 | fNumInnerPixels = fNumOuterPixels = 0;
|
---|
407 |
|
---|
408 | for (int i=0; i<n; i++)
|
---|
409 | {
|
---|
410 |
|
---|
411 | if ((*this)[i].IsExcluded())
|
---|
412 | continue;
|
---|
413 |
|
---|
414 | const MExtractedSignalPix &pix = (*signal)[i];
|
---|
415 |
|
---|
416 | const Float_t sumhi = pix.GetExtractedSignalHiGain();
|
---|
417 | const Float_t sumlo = pix.GetExtractedSignalLoGain();
|
---|
418 |
|
---|
419 | (*this)[i].FillHistAndArray(sumhi);
|
---|
420 | (*this)(i).FillHistAndArray(sumlo);
|
---|
421 |
|
---|
422 | const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
|
---|
423 | const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
|
---|
424 |
|
---|
425 | (*this)[i].SetSaturated(sathi);
|
---|
426 | (*this)(i).SetSaturated(satlo);
|
---|
427 |
|
---|
428 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
429 | {
|
---|
430 | sumhiinnertot += sumhi;
|
---|
431 | sumloinnertot += sumlo;
|
---|
432 | sumhiinnersat += sathi;
|
---|
433 | sumloinnersat += satlo;
|
---|
434 | fNumInnerPixels++;
|
---|
435 | }
|
---|
436 | else
|
---|
437 | {
|
---|
438 | sumhioutertot += sumhi;
|
---|
439 | sumlooutertot += sumlo;
|
---|
440 | sumhioutersat += sathi;
|
---|
441 | sumlooutersat += satlo;
|
---|
442 | fNumOuterPixels++;
|
---|
443 | }
|
---|
444 |
|
---|
445 | }
|
---|
446 |
|
---|
447 | fAverageHiGainInnerPix->FillHistAndArray(sumhiinnertot/fNumInnerPixels);
|
---|
448 | fAverageLoGainInnerPix->FillHistAndArray(sumloinnertot/fNumInnerPixels);
|
---|
449 | fAverageHiGainOuterPix->FillHistAndArray(sumhioutertot/fNumOuterPixels);
|
---|
450 | fAverageLoGainOuterPix->FillHistAndArray(sumlooutertot/fNumOuterPixels);
|
---|
451 |
|
---|
452 | fAverageHiGainInnerPix->SetSaturated((Float_t)sumhiinnersat/fNumInnerPixels);
|
---|
453 | fAverageLoGainInnerPix->SetSaturated((Float_t)sumloinnersat/fNumInnerPixels);
|
---|
454 | fAverageHiGainOuterPix->SetSaturated((Float_t)sumhioutersat/fNumOuterPixels);
|
---|
455 | fAverageLoGainOuterPix->SetSaturated((Float_t)sumlooutersat/fNumOuterPixels);
|
---|
456 |
|
---|
457 | //
|
---|
458 | // Now the times
|
---|
459 | //
|
---|
460 | sumhiinnertot = sumloinnertot = sumhioutertot = sumlooutertot = 0.;
|
---|
461 | fNumInnerPixels = fNumOuterPixels = 0;
|
---|
462 |
|
---|
463 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
464 | while (pixel.Next())
|
---|
465 | {
|
---|
466 |
|
---|
467 | const UInt_t pixid = pixel.GetPixelId();
|
---|
468 |
|
---|
469 | if ((*this)[pixid].IsExcluded())
|
---|
470 | continue;
|
---|
471 |
|
---|
472 | const Int_t timehi = (Int_t)pixel.GetIdxMaxHiGainSample();
|
---|
473 | const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample() + 15.;
|
---|
474 |
|
---|
475 | (*this)[pixid].FillAbsTime(timehi);
|
---|
476 | (*this)(pixid).FillAbsTime(timelo);
|
---|
477 |
|
---|
478 | if (fGeom->GetPixRatio(pixel.GetPixelId()) == 1.)
|
---|
479 | {
|
---|
480 | sumhiinnertot += timehi;
|
---|
481 | sumloinnertot += timelo;
|
---|
482 | fNumInnerPixels++;
|
---|
483 | }
|
---|
484 | else
|
---|
485 | {
|
---|
486 | sumhioutertot += timehi;
|
---|
487 | sumlooutertot += timelo;
|
---|
488 | fNumOuterPixels++;
|
---|
489 | }
|
---|
490 | }
|
---|
491 |
|
---|
492 | fAverageHiGainInnerPix-> FillAbsTime(sumhiinnertot/fNumInnerPixels);
|
---|
493 | fAverageLoGainInnerPix-> FillAbsTime(sumloinnertot/fNumInnerPixels);
|
---|
494 | fAverageHiGainOuterPix-> FillAbsTime(sumhioutertot/fNumOuterPixels);
|
---|
495 | fAverageLoGainOuterPix-> FillAbsTime(sumlooutertot/fNumOuterPixels);
|
---|
496 |
|
---|
497 | return kTRUE;
|
---|
498 | }
|
---|
499 |
|
---|
500 | // --------------------------------------------------------------------------
|
---|
501 | //
|
---|
502 | // 1) Return if the charge distribution is already succesfully fitted
|
---|
503 | // or if the histogram is empty
|
---|
504 | // 2) Fit the histograms with a Gaussian
|
---|
505 | // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
|
---|
506 | // 4) Check for pickup noise
|
---|
507 | // 5) Check the fourier spectrum
|
---|
508 | // 5) Retrieve the results and store them in this class
|
---|
509 | //
|
---|
510 | Bool_t MHCalibrationChargeCam::Finalize()
|
---|
511 | {
|
---|
512 |
|
---|
513 | for (int i=0; i<fHiGainArray->GetSize(); i++)
|
---|
514 | {
|
---|
515 |
|
---|
516 | MCalibrationChargePix &pix = (*fCam)[i];
|
---|
517 | MHCalibrationChargeHiGainPix &histhi = (*this)[i];
|
---|
518 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
519 |
|
---|
520 | FinalizeHiGainHists(histhi,pix,bad);
|
---|
521 |
|
---|
522 | }
|
---|
523 |
|
---|
524 | for (int i=0; i<fLoGainArray->GetSize(); i++)
|
---|
525 | {
|
---|
526 |
|
---|
527 | if ((*this)(i).IsExcluded())
|
---|
528 | continue;
|
---|
529 |
|
---|
530 | MHCalibrationChargeLoGainPix &histlo = (*this)(i);
|
---|
531 | MCalibrationChargePix &pix = (*fCam)[i];
|
---|
532 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
533 |
|
---|
534 | FinalizeLoGainHists(histlo,pix,bad);
|
---|
535 |
|
---|
536 | }
|
---|
537 |
|
---|
538 | FinalizeHiGainHists(*fAverageHiGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
|
---|
539 | FinalizeLoGainHists(*fAverageLoGainInnerPix,*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
|
---|
540 | FinalizeHiGainHists(*fAverageHiGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
|
---|
541 | FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
|
---|
542 |
|
---|
543 | fCam->GetAverageInnerPix()->SetSigmaCharge (fCam->GetAverageInnerPix()->GetSigmaCharge()
|
---|
544 | *TMath::Sqrt((Float_t)fNumInnerPixels));
|
---|
545 | fCam->GetAverageOuterPix()->SetSigmaCharge (fCam->GetAverageOuterPix()->GetSigmaCharge()
|
---|
546 | *TMath::Sqrt((Float_t)fNumOuterPixels));
|
---|
547 | fCam->GetAverageInnerPix()->SetSigmaChargeErr(fCam->GetAverageInnerPix()->GetSigmaChargeErr()
|
---|
548 | *TMath::Sqrt((Float_t)fNumInnerPixels));
|
---|
549 | fCam->GetAverageOuterPix()->SetSigmaChargeErr(fCam->GetAverageOuterPix()->GetSigmaChargeErr()
|
---|
550 | *TMath::Sqrt((Float_t)fNumOuterPixels));
|
---|
551 |
|
---|
552 | return kTRUE;
|
---|
553 | }
|
---|
554 |
|
---|
555 | void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist,
|
---|
556 | MCalibrationChargePix &pix,
|
---|
557 | MBadPixelsPix &bad)
|
---|
558 | {
|
---|
559 |
|
---|
560 | if (hist.IsEmpty())
|
---|
561 | return;
|
---|
562 |
|
---|
563 | if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries())
|
---|
564 | {
|
---|
565 | pix.SetHiGainSaturation();
|
---|
566 | bad.SetHiGainSaturation();
|
---|
567 | return;
|
---|
568 | }
|
---|
569 |
|
---|
570 | //
|
---|
571 | // 2) Fit the Hi Gain histograms with a Gaussian
|
---|
572 | //
|
---|
573 | if (!hist.FitGaus())
|
---|
574 | //
|
---|
575 | // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
|
---|
576 | //
|
---|
577 | if (!hist.RepeatFit())
|
---|
578 | {
|
---|
579 | hist.BypassFit();
|
---|
580 | bad.SetHiGainNotFitted();
|
---|
581 | bad.SetUnreliableRun();
|
---|
582 | }
|
---|
583 |
|
---|
584 | //
|
---|
585 | // 4) Check for pickup
|
---|
586 | //
|
---|
587 | hist.CountPickup();
|
---|
588 |
|
---|
589 | //
|
---|
590 | // 5) Check for oscillations
|
---|
591 | //
|
---|
592 | hist.CreateFourierSpectrum();
|
---|
593 |
|
---|
594 | //
|
---|
595 | // 6) Retrieve the results and store them in this class
|
---|
596 | //
|
---|
597 | pix.SetHiGainMeanCharge( hist.GetMean() );
|
---|
598 | pix.SetHiGainMeanChargeErr( hist.GetMeanErr() );
|
---|
599 | pix.SetHiGainSigmaCharge( hist.GetSigma() );
|
---|
600 | pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
|
---|
601 | pix.SetHiGainChargeProb ( hist.GetProb() );
|
---|
602 |
|
---|
603 | pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
|
---|
604 | pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
|
---|
605 |
|
---|
606 | pix.SetHiGainNumPickup ( hist.GetPickup() );
|
---|
607 |
|
---|
608 | if (!hist.IsFourierSpectrumOK())
|
---|
609 | {
|
---|
610 | bad.SetHiGainOscillating();
|
---|
611 | bad.SetUnreliableRun();
|
---|
612 | }
|
---|
613 | }
|
---|
614 |
|
---|
615 |
|
---|
616 | void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist,
|
---|
617 | MCalibrationChargePix &pix,
|
---|
618 | MBadPixelsPix &bad)
|
---|
619 | {
|
---|
620 |
|
---|
621 |
|
---|
622 | if (hist.IsEmpty())
|
---|
623 | return;
|
---|
624 |
|
---|
625 | if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
|
---|
626 | {
|
---|
627 | pix.SetLoGainSaturation();
|
---|
628 | bad.SetLoGainSaturation();
|
---|
629 | bad.SetUnsuitableRun();
|
---|
630 | return;
|
---|
631 | }
|
---|
632 | //
|
---|
633 | // 2) Fit the Lo Gain histograms with a Gaussian
|
---|
634 | //
|
---|
635 | if (!hist.FitGaus())
|
---|
636 | //
|
---|
637 | // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
|
---|
638 | //
|
---|
639 | if (!hist.RepeatFit())
|
---|
640 | {
|
---|
641 | hist.BypassFit();
|
---|
642 | bad.SetLoGainNotFitted();
|
---|
643 | if (pix.IsHiGainSaturation())
|
---|
644 | bad.SetUnreliableRun();
|
---|
645 | }
|
---|
646 |
|
---|
647 | //
|
---|
648 | // 4) Check for pickup
|
---|
649 | //
|
---|
650 | hist.CountPickup();
|
---|
651 |
|
---|
652 | //
|
---|
653 | // 5) Check for oscillations
|
---|
654 | //
|
---|
655 | hist.CreateFourierSpectrum();
|
---|
656 |
|
---|
657 | //
|
---|
658 | // 6) Retrieve the results and store them in this class
|
---|
659 | //
|
---|
660 | pix.SetLoGainMeanCharge( hist.GetMean() );
|
---|
661 | pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );
|
---|
662 | pix.SetLoGainSigmaCharge( hist.GetSigma() );
|
---|
663 | pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );
|
---|
664 | pix.SetLoGainChargeProb ( hist.GetProb() );
|
---|
665 |
|
---|
666 | if (pix.IsHiGainSaturation())
|
---|
667 | {
|
---|
668 | pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
|
---|
669 | pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
|
---|
670 | }
|
---|
671 |
|
---|
672 | pix.SetLoGainNumPickup ( hist.GetPickup() );
|
---|
673 |
|
---|
674 | if (!hist.IsFourierSpectrumOK())
|
---|
675 | {
|
---|
676 | bad.SetLoGainOscillating();
|
---|
677 | if (pix.IsHiGainSaturation())
|
---|
678 | bad.SetUnreliableRun();
|
---|
679 | }
|
---|
680 | }
|
---|
681 |
|
---|
682 | Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
683 | {
|
---|
684 | return kTRUE;
|
---|
685 | }
|
---|
686 |
|
---|
687 | // --------------------------------------------------------------------------
|
---|
688 | //
|
---|
689 | // What MHCamera needs in order to draw an individual pixel in the camera
|
---|
690 | //
|
---|
691 | void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
|
---|
692 | {
|
---|
693 |
|
---|
694 | if (idx == -1)
|
---|
695 | fAverageHiGainInnerPix->DrawClone();
|
---|
696 | if (idx == -2)
|
---|
697 | fAverageHiGainOuterPix->DrawClone();
|
---|
698 | if (idx == -3)
|
---|
699 | fAverageLoGainInnerPix->DrawClone();
|
---|
700 | if (idx == -4)
|
---|
701 | fAverageLoGainOuterPix->DrawClone();
|
---|
702 | (*this)[idx].DrawClone();
|
---|
703 |
|
---|
704 | }
|
---|
705 |
|
---|
706 |
|
---|
707 | void MHCalibrationChargeCam::Draw(const Option_t *opt)
|
---|
708 | {
|
---|
709 |
|
---|
710 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
711 | pad->SetBorderMode(0);
|
---|
712 |
|
---|
713 | pad->Divide(2,2);
|
---|
714 |
|
---|
715 | pad->cd(1);
|
---|
716 |
|
---|
717 | if (!fAverageHiGainInnerPix->IsEmpty())
|
---|
718 | gPad->SetLogy();
|
---|
719 | fAverageHiGainInnerPix->Draw(opt);
|
---|
720 |
|
---|
721 | pad->cd(2);
|
---|
722 |
|
---|
723 | if (!fAverageLoGainInnerPix->IsEmpty())
|
---|
724 | gPad->SetLogy();
|
---|
725 | fAverageLoGainInnerPix->Draw(opt);
|
---|
726 |
|
---|
727 | pad->cd(3);
|
---|
728 |
|
---|
729 | if (!fAverageHiGainOuterPix->IsEmpty())
|
---|
730 | gPad->SetLogy();
|
---|
731 | fAverageHiGainOuterPix->Draw(opt);
|
---|
732 |
|
---|
733 | pad->cd(4);
|
---|
734 |
|
---|
735 | if (!fAverageLoGainOuterPix->IsEmpty())
|
---|
736 | gPad->SetLogy();
|
---|
737 | fAverageLoGainOuterPix->Draw(opt);
|
---|
738 |
|
---|
739 | }
|
---|