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 "MRawEvtData.h"
|
---|
84 | #include "MRawEvtPixelIter.h"
|
---|
85 |
|
---|
86 | #include "MExtractedSignalCam.h"
|
---|
87 | #include "MExtractedSignalPix.h"
|
---|
88 |
|
---|
89 | ClassImp(MHCalibrationChargeCam);
|
---|
90 |
|
---|
91 | using namespace std;
|
---|
92 |
|
---|
93 | const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
|
---|
94 | const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.01;
|
---|
95 | //
|
---|
96 | //
|
---|
97 | //
|
---|
98 | MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
|
---|
99 | {
|
---|
100 | fName = name ? name : "MHCalibrationChargeCam";
|
---|
101 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
---|
102 |
|
---|
103 | fHiGainArray = new TObjArray;
|
---|
104 | fHiGainArray->SetOwner();
|
---|
105 |
|
---|
106 | fLoGainArray = new TObjArray;
|
---|
107 | fLoGainArray->SetOwner();
|
---|
108 |
|
---|
109 | fAverageHiGainInnerPix = new MHCalibrationChargeHiGainPix("AverageHiGainInnerPix","Average HiGain FADC sums of inner pixels");
|
---|
110 | fAverageLoGainInnerPix = new MHCalibrationChargeLoGainPix("AverageLoGainInnerPix","Average LoGain FADC sums of inner pixels");
|
---|
111 | fAverageHiGainOuterPix = new MHCalibrationChargeHiGainPix("AverageHiGainOuterPix","Average HiGain FADC sums of outer pixels");
|
---|
112 | fAverageLoGainOuterPix = new MHCalibrationChargeLoGainPix("AverageLoGainOuterPix","Average LoGain FADC sums of outer pixels");
|
---|
113 |
|
---|
114 | /*
|
---|
115 | fAverageHiGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerHiGainPix");
|
---|
116 | fAverageHiGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterHiGainPix");
|
---|
117 | fAverageLoGainInnerPix->GetHGausHist()->SetName("HCalibrationChargeAverageInnerLoGainPix");
|
---|
118 | fAverageLoGainOuterPix->GetHGausHist()->SetName("HCalibrationChargeAverageOuterLoGainPix");
|
---|
119 | */
|
---|
120 | fAverageHiGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels HiGain");
|
---|
121 | fAverageLoGainInnerPix->GetHGausHist()->SetTitle("Summed FADC slices average Inner pixels LoGain");
|
---|
122 | fAverageHiGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels HiGain");
|
---|
123 | fAverageLoGainOuterPix->GetHGausHist()->SetTitle("Summed FADC slices average Outer pixels LoGain");
|
---|
124 |
|
---|
125 | fAverageHiGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels HiGain");
|
---|
126 | fAverageLoGainInnerPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Inner pixels LoGain");
|
---|
127 | fAverageHiGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels HiGain");
|
---|
128 | fAverageLoGainOuterPix->GetHAbsTime()->SetTitle("Absolute Arrival Time average Outer pixels LoGain");
|
---|
129 |
|
---|
130 | fAverageHiGainInnerPix->SetChargeLast(1000.);
|
---|
131 | fAverageLoGainInnerPix->SetChargeLast(100.);
|
---|
132 | fAverageHiGainOuterPix->SetChargeLast(1000.);
|
---|
133 | fAverageLoGainOuterPix->SetChargeLast(100.);
|
---|
134 |
|
---|
135 | fAverageHiGainInnerPix->SetChargeNbins(4000);
|
---|
136 | fAverageLoGainInnerPix->SetChargeNbins(4000);
|
---|
137 | fAverageHiGainOuterPix->SetChargeNbins(4000);
|
---|
138 | fAverageLoGainOuterPix->SetChargeNbins(4000);
|
---|
139 |
|
---|
140 | SetNumHiGainSaturationLimit();
|
---|
141 | SetNumLoGainSaturationLimit();
|
---|
142 |
|
---|
143 | fNumInnerPixels = 0;
|
---|
144 | fNumOuterPixels = 0;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // --------------------------------------------------------------------------
|
---|
148 | //
|
---|
149 | // Delete the TClonesArray of MHCalibrationChargePix containers
|
---|
150 | // Delete the MHCalibrationPINDiode and the MHCalibrationBlindPix
|
---|
151 | //
|
---|
152 | // Delete the histograms if they exist
|
---|
153 | //
|
---|
154 | MHCalibrationChargeCam::~MHCalibrationChargeCam()
|
---|
155 | {
|
---|
156 | delete fHiGainArray;
|
---|
157 | delete fLoGainArray;
|
---|
158 |
|
---|
159 | delete fAverageHiGainInnerPix;
|
---|
160 | delete fAverageLoGainInnerPix;
|
---|
161 | delete fAverageHiGainOuterPix;
|
---|
162 | delete fAverageLoGainOuterPix;
|
---|
163 | }
|
---|
164 |
|
---|
165 | // --------------------------------------------------------------------------
|
---|
166 | //
|
---|
167 | // Get i-th pixel (pixel number)
|
---|
168 | //
|
---|
169 | MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i)
|
---|
170 | {
|
---|
171 | return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
|
---|
172 | }
|
---|
173 |
|
---|
174 | // --------------------------------------------------------------------------
|
---|
175 | //
|
---|
176 | // Get i-th pixel (pixel number)
|
---|
177 | //
|
---|
178 | const MHCalibrationChargeHiGainPix &MHCalibrationChargeCam::operator[](UInt_t i) const
|
---|
179 | {
|
---|
180 | return *static_cast<MHCalibrationChargeHiGainPix*>(fHiGainArray->UncheckedAt(i));
|
---|
181 | }
|
---|
182 |
|
---|
183 | // --------------------------------------------------------------------------
|
---|
184 | //
|
---|
185 | // Get i-th pixel (pixel number)
|
---|
186 | //
|
---|
187 | MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i)
|
---|
188 | {
|
---|
189 | return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
|
---|
190 | }
|
---|
191 |
|
---|
192 | // --------------------------------------------------------------------------
|
---|
193 | //
|
---|
194 | // Get i-th pixel (pixel number)
|
---|
195 | //
|
---|
196 | const MHCalibrationChargeLoGainPix &MHCalibrationChargeCam::operator()(UInt_t i) const
|
---|
197 | {
|
---|
198 | return *static_cast<MHCalibrationChargeLoGainPix*>(fLoGainArray->UncheckedAt(i));
|
---|
199 | }
|
---|
200 |
|
---|
201 |
|
---|
202 | #if 0
|
---|
203 | // --------------------------------------------------------------------------
|
---|
204 | //
|
---|
205 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
---|
206 | // I don't know the reason
|
---|
207 | //
|
---|
208 | TObject *MHCalibrationChargeCam::Clone(const char *) const
|
---|
209 | {
|
---|
210 |
|
---|
211 | const Int_t nhi = fHiGainArray->GetSize();
|
---|
212 | const Int_t nlo = fLoGainArray->GetSize();
|
---|
213 | //
|
---|
214 | // FIXME, this might be done faster and more elegant, by direct copy.
|
---|
215 | //
|
---|
216 | MHCalibrationChargeCam *cam = (MHCalibrationChargeCam*)(this)->Clone("");
|
---|
217 | // MHCalibrationChargeCam cam;
|
---|
218 | // Copy(*cam);
|
---|
219 |
|
---|
220 | /*
|
---|
221 | cam->fHiGainArray->Delete();
|
---|
222 | cam->fLoGainArray->Delete();
|
---|
223 |
|
---|
224 | cam->fHiGainArray->Expand(nhi);
|
---|
225 | cam->fLoGainArray->Expand(nlo);
|
---|
226 |
|
---|
227 | for (int i=0; i<nhi; i++)
|
---|
228 | {
|
---|
229 | delete (*cam->fHiGainArray)[i];
|
---|
230 | (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
|
---|
231 | }
|
---|
232 | for (int i=0; i<nlo; i++)
|
---|
233 | {
|
---|
234 | delete (*cam->fLoGainArray)[i];
|
---|
235 | (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
|
---|
236 | }
|
---|
237 | */
|
---|
238 |
|
---|
239 | /*
|
---|
240 | delete cam->fAverageHiGainInnerPix;
|
---|
241 | delete cam->fAverageLoGainInnerPix;
|
---|
242 | delete cam->fAverageHiGainOuterPix;
|
---|
243 | delete cam->fAverageLoGainOuterPix;
|
---|
244 |
|
---|
245 | cam->GetAverageHiGainInnerPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainInnerPix->Clone();
|
---|
246 | cam->GetAverageLoGainInnerPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainInnerPix->Clone();
|
---|
247 |
|
---|
248 | cam->GetAverageHiGainOuterPix() = *(MHCalibrationChargeHiGainPix*)fAverageHiGainOuterPix->Clone();
|
---|
249 | cam->GetAverageLoGainOuterPix() = *(MHCalibrationChargeLoGainPix*)fAverageLoGainOuterPix->Clone();
|
---|
250 |
|
---|
251 | fAverageHiGainInnerPix->Copy(cam->GetAverageHiGainInnerPix());
|
---|
252 | fAverageLoGainInnerPix->Copy(cam->GetAverageLoGainInnerPix());
|
---|
253 | fAverageHiGainOuterPix->Copy(cam->GetAverageHiGainOuterPix());
|
---|
254 | fAverageLoGainOuterPix->Copy(cam->GetAverageLoGainOuterPix());
|
---|
255 | */
|
---|
256 |
|
---|
257 | return cam;
|
---|
258 | }
|
---|
259 | #endif
|
---|
260 | // --------------------------------------------------------------------------
|
---|
261 | //
|
---|
262 | // To setup the object we get the number of pixels from a MGeomCam object
|
---|
263 | // in the Parameter list.
|
---|
264 | //
|
---|
265 | Bool_t MHCalibrationChargeCam::SetupFill(const MParList *pList)
|
---|
266 | {
|
---|
267 |
|
---|
268 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
---|
269 |
|
---|
270 | if (!fRawEvt)
|
---|
271 | {
|
---|
272 | gLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
|
---|
273 | return kFALSE;
|
---|
274 | }
|
---|
275 |
|
---|
276 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
277 |
|
---|
278 | if (!fGeom)
|
---|
279 | {
|
---|
280 | gLog << err << dbginf << "MGeomCam not found... aborting." << endl;
|
---|
281 | return kFALSE;
|
---|
282 | }
|
---|
283 |
|
---|
284 | fHiGainArray->Delete();
|
---|
285 | fLoGainArray->Delete();
|
---|
286 |
|
---|
287 | fAverageHiGainInnerPix->Init();
|
---|
288 | fAverageLoGainInnerPix->Init();
|
---|
289 | fAverageHiGainOuterPix->Init();
|
---|
290 | fAverageLoGainOuterPix->Init();
|
---|
291 |
|
---|
292 | return kTRUE;
|
---|
293 | }
|
---|
294 |
|
---|
295 | Bool_t MHCalibrationChargeCam::ReInit(MParList *pList)
|
---|
296 | {
|
---|
297 |
|
---|
298 | fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
|
---|
299 | if (!fCam)
|
---|
300 | {
|
---|
301 | gLog << err << GetDescriptor() << ": ERROR: Could not find MCalibrationChargeCam ... aborting " << endl;
|
---|
302 | return kFALSE;
|
---|
303 | }
|
---|
304 |
|
---|
305 | MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
---|
306 | if (!signal)
|
---|
307 | {
|
---|
308 | gLog << err << "No argument in MExtractedSignalCam::ReInit... abort." << endl;
|
---|
309 | return kFALSE;
|
---|
310 | }
|
---|
311 |
|
---|
312 | const Int_t n = signal->GetSize();
|
---|
313 |
|
---|
314 | if (fHiGainArray->GetEntries()==0)
|
---|
315 | {
|
---|
316 | fHiGainArray->Expand(n);
|
---|
317 |
|
---|
318 | for (Int_t i=0; i<n; i++)
|
---|
319 | {
|
---|
320 | (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
|
---|
321 | (*this)[i].Init();
|
---|
322 | (*this)[i].ChangeHistId(i);
|
---|
323 |
|
---|
324 | }
|
---|
325 | }
|
---|
326 |
|
---|
327 | if (fLoGainArray->GetEntries()==0)
|
---|
328 | {
|
---|
329 | fLoGainArray->Expand(n);
|
---|
330 |
|
---|
331 | for (Int_t i=0; i<n; i++)
|
---|
332 | {
|
---|
333 | (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
|
---|
334 | (*this)(i).Init();
|
---|
335 | (*this)(i).ChangeHistId(i);
|
---|
336 | }
|
---|
337 | }
|
---|
338 |
|
---|
339 | return kTRUE;
|
---|
340 | }
|
---|
341 |
|
---|
342 |
|
---|
343 | // --------------------------------------------------------------------------
|
---|
344 | Bool_t MHCalibrationChargeCam::Fill(const MParContainer *par, const Stat_t w)
|
---|
345 | {
|
---|
346 |
|
---|
347 | MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
|
---|
348 | if (!signal)
|
---|
349 | {
|
---|
350 | gLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
|
---|
351 | return kFALSE;
|
---|
352 | }
|
---|
353 |
|
---|
354 | Int_t n = signal->GetSize();
|
---|
355 |
|
---|
356 | if (fHiGainArray->GetEntries() != n)
|
---|
357 | {
|
---|
358 | gLog << err << "ERROR - Size mismatch... abort." << endl;
|
---|
359 | return kFALSE;
|
---|
360 | }
|
---|
361 |
|
---|
362 | if (fLoGainArray->GetEntries() != n)
|
---|
363 | {
|
---|
364 | gLog << err << "ERROR - Size mismatch... abort." << endl;
|
---|
365 | return kFALSE;
|
---|
366 | }
|
---|
367 |
|
---|
368 | //
|
---|
369 | // First the extracted signal
|
---|
370 | //
|
---|
371 | Float_t sumhiinnertot = 0.;
|
---|
372 | Float_t sumloinnertot = 0.;
|
---|
373 | Float_t sumhioutertot = 0.;
|
---|
374 | Float_t sumlooutertot = 0.;
|
---|
375 | Int_t sumhiinnersat = 0;
|
---|
376 | Int_t sumloinnersat = 0;
|
---|
377 | Int_t sumhioutersat = 0;
|
---|
378 | Int_t sumlooutersat = 0;
|
---|
379 |
|
---|
380 | fNumInnerPixels = fNumOuterPixels = 0;
|
---|
381 |
|
---|
382 | for (int i=0; i<n; i++)
|
---|
383 | {
|
---|
384 |
|
---|
385 | const MExtractedSignalPix &pix = (*signal)[i];
|
---|
386 |
|
---|
387 | const Float_t sumhi = pix.GetExtractedSignalHiGain();
|
---|
388 | const Float_t sumlo = pix.GetExtractedSignalLoGain();
|
---|
389 |
|
---|
390 | (*this)[i].FillHistAndArray(sumhi);
|
---|
391 | (*this)(i).FillHistAndArray(sumlo);
|
---|
392 |
|
---|
393 | const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
|
---|
394 | const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
|
---|
395 |
|
---|
396 | (*this)[i].SetSaturated(sathi);
|
---|
397 | (*this)(i).SetSaturated(satlo);
|
---|
398 |
|
---|
399 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
400 | {
|
---|
401 | sumhiinnertot += sumhi;
|
---|
402 | sumloinnertot += sumlo;
|
---|
403 | sumhiinnersat += sathi;
|
---|
404 | sumloinnersat += satlo;
|
---|
405 | fNumInnerPixels++;
|
---|
406 | }
|
---|
407 | else
|
---|
408 | {
|
---|
409 | sumhioutertot += sumhi;
|
---|
410 | sumlooutertot += sumlo;
|
---|
411 | sumhioutersat += sathi;
|
---|
412 | sumlooutersat += satlo;
|
---|
413 | fNumOuterPixels++;
|
---|
414 | }
|
---|
415 |
|
---|
416 | }
|
---|
417 |
|
---|
418 | fAverageHiGainInnerPix->FillHistAndArray(sumhiinnertot/fNumInnerPixels);
|
---|
419 | fAverageLoGainInnerPix->FillHistAndArray(sumloinnertot/fNumInnerPixels);
|
---|
420 | fAverageHiGainOuterPix->FillHistAndArray(sumhioutertot/fNumOuterPixels);
|
---|
421 | fAverageLoGainOuterPix->FillHistAndArray(sumlooutertot/fNumOuterPixels);
|
---|
422 |
|
---|
423 | fAverageHiGainInnerPix->SetSaturated((Float_t)sumhiinnersat/fNumInnerPixels);
|
---|
424 | fAverageLoGainInnerPix->SetSaturated((Float_t)sumloinnersat/fNumInnerPixels);
|
---|
425 | fAverageHiGainOuterPix->SetSaturated((Float_t)sumhioutersat/fNumOuterPixels);
|
---|
426 | fAverageLoGainOuterPix->SetSaturated((Float_t)sumlooutersat/fNumOuterPixels);
|
---|
427 |
|
---|
428 | //
|
---|
429 | // Now the times
|
---|
430 | //
|
---|
431 | sumhiinnertot = sumloinnertot = sumhioutertot = sumlooutertot = 0.;
|
---|
432 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
433 | while (pixel.Next())
|
---|
434 | {
|
---|
435 |
|
---|
436 | const UInt_t pixid = pixel.GetPixelId();
|
---|
437 |
|
---|
438 | const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
|
---|
439 | const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample() + 15.;
|
---|
440 |
|
---|
441 | (*this)[pixid].FillAbsTime(timehi);
|
---|
442 | (*this)(pixid).FillAbsTime(timelo);
|
---|
443 |
|
---|
444 | if (fGeom->GetPixRatio(pixel.GetPixelId()) == 1.)
|
---|
445 | {
|
---|
446 | sumhiinnertot += timehi;
|
---|
447 | sumloinnertot += timelo;
|
---|
448 | }
|
---|
449 | else
|
---|
450 | {
|
---|
451 | sumhioutertot += timehi;
|
---|
452 | sumlooutertot += timelo;
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | fAverageHiGainInnerPix-> FillAbsTime(sumhiinnertot/fNumInnerPixels);
|
---|
457 | fAverageLoGainInnerPix-> FillAbsTime(sumloinnertot/fNumInnerPixels);
|
---|
458 | fAverageHiGainOuterPix-> FillAbsTime(sumhioutertot/fNumOuterPixels);
|
---|
459 | fAverageLoGainOuterPix-> FillAbsTime(sumlooutertot/fNumOuterPixels);
|
---|
460 |
|
---|
461 | return kTRUE;
|
---|
462 | }
|
---|
463 |
|
---|
464 | // --------------------------------------------------------------------------
|
---|
465 | //
|
---|
466 | // 1) Return if the charge distribution is already succesfully fitted
|
---|
467 | // or if the histogram is empty
|
---|
468 | // 2) Fit the histograms with a Gaussian
|
---|
469 | // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
|
---|
470 | // 4) Check for pickup noise
|
---|
471 | // 5) Check the fourier spectrum
|
---|
472 | // 5) Retrieve the results and store them in this class
|
---|
473 | //
|
---|
474 | Bool_t MHCalibrationChargeCam::Finalize()
|
---|
475 | {
|
---|
476 |
|
---|
477 | for (int i=0; i<fHiGainArray->GetSize(); i++)
|
---|
478 | {
|
---|
479 |
|
---|
480 | MHCalibrationChargeHiGainPix &histhi = (*this)[i];
|
---|
481 | MCalibrationChargePix &pix = (*fCam)[i];
|
---|
482 |
|
---|
483 | FinalizeHiGainHists(histhi,pix);
|
---|
484 | }
|
---|
485 |
|
---|
486 | for (int i=0; i<fLoGainArray->GetSize(); i++)
|
---|
487 | {
|
---|
488 |
|
---|
489 | MHCalibrationChargeLoGainPix &histlo = (*this)(i);
|
---|
490 | MCalibrationChargePix &pix = (*fCam)[i];
|
---|
491 |
|
---|
492 | FinalizeLoGainHists(histlo,pix);
|
---|
493 | }
|
---|
494 |
|
---|
495 | FinalizeHiGainHists(*fAverageHiGainInnerPix,*fCam->GetAverageInnerPix());
|
---|
496 | FinalizeLoGainHists(*fAverageLoGainInnerPix,*fCam->GetAverageInnerPix());
|
---|
497 | FinalizeHiGainHists(*fAverageHiGainOuterPix,*fCam->GetAverageOuterPix());
|
---|
498 | FinalizeLoGainHists(*fAverageLoGainOuterPix,*fCam->GetAverageOuterPix());
|
---|
499 |
|
---|
500 | fCam->GetAverageInnerPix()->SetSigmaCharge (fCam->GetAverageInnerPix()->GetSigmaCharge() *TMath::Sqrt((Float_t)fNumInnerPixels));
|
---|
501 | fCam->GetAverageOuterPix()->SetSigmaCharge (fCam->GetAverageOuterPix()->GetSigmaCharge() *TMath::Sqrt((Float_t)fNumOuterPixels));
|
---|
502 | fCam->GetAverageInnerPix()->SetSigmaChargeErr(fCam->GetAverageInnerPix()->GetSigmaChargeErr()*TMath::Sqrt((Float_t)fNumInnerPixels));
|
---|
503 | fCam->GetAverageOuterPix()->SetSigmaChargeErr(fCam->GetAverageOuterPix()->GetSigmaChargeErr()*TMath::Sqrt((Float_t)fNumOuterPixels));
|
---|
504 |
|
---|
505 | return kTRUE;
|
---|
506 | }
|
---|
507 |
|
---|
508 | void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargeHiGainPix &hist, MCalibrationChargePix &pix)
|
---|
509 | {
|
---|
510 |
|
---|
511 | if (hist.IsEmpty())
|
---|
512 | return;
|
---|
513 |
|
---|
514 | if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries())
|
---|
515 | {
|
---|
516 | pix.SetHiGainSaturation();
|
---|
517 | return;
|
---|
518 | }
|
---|
519 |
|
---|
520 | //
|
---|
521 | // 2) Fit the Hi Gain histograms with a Gaussian
|
---|
522 | //
|
---|
523 | if (hist.FitGaus())
|
---|
524 | pix.SetHiGainFitted();
|
---|
525 | //
|
---|
526 | // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
|
---|
527 | //
|
---|
528 | else if (hist.RepeatFit())
|
---|
529 | pix.SetHiGainFitted();
|
---|
530 | else
|
---|
531 | hist.BypassFit();
|
---|
532 |
|
---|
533 | //
|
---|
534 | // 4) Check for pickup
|
---|
535 | //
|
---|
536 | hist.CountPickup();
|
---|
537 |
|
---|
538 | //
|
---|
539 | // 5) Check for oscillations
|
---|
540 | //
|
---|
541 | hist.CreateFourierSpectrum();
|
---|
542 |
|
---|
543 | //
|
---|
544 | // 6) Retrieve the results and store them in this class
|
---|
545 | //
|
---|
546 | pix.SetHiGainMeanCharge( hist.GetMean() );
|
---|
547 | pix.SetHiGainMeanChargeErr( hist.GetMeanErr() );
|
---|
548 | pix.SetHiGainSigmaCharge( hist.GetSigma() );
|
---|
549 | pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() );
|
---|
550 | pix.SetHiGainChargeProb ( hist.GetProb() );
|
---|
551 |
|
---|
552 | pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
|
---|
553 | pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
|
---|
554 |
|
---|
555 | pix.SetHiGainOscillating ( !hist.IsFourierSpectrumOK() );
|
---|
556 | pix.SetHiGainNumPickup ( hist.GetPickup() );
|
---|
557 |
|
---|
558 | }
|
---|
559 |
|
---|
560 |
|
---|
561 | void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargeLoGainPix &hist, MCalibrationChargePix &pix)
|
---|
562 | {
|
---|
563 |
|
---|
564 |
|
---|
565 | if (hist.IsEmpty())
|
---|
566 | return;
|
---|
567 |
|
---|
568 | if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())
|
---|
569 | {
|
---|
570 | pix.SetLoGainSaturation();
|
---|
571 | return;
|
---|
572 | }
|
---|
573 | //
|
---|
574 | // 2) Fit the Lo Gain histograms with a Gaussian
|
---|
575 | //
|
---|
576 | if (hist.FitGaus())
|
---|
577 | pix.SetLoGainFitted();
|
---|
578 | //
|
---|
579 | // 3) In case of failure set the bit kFitted to false and take histogram means and RMS
|
---|
580 | //
|
---|
581 | else if (hist.RepeatFit())
|
---|
582 | pix.SetLoGainFitted();
|
---|
583 | else
|
---|
584 | hist.BypassFit();
|
---|
585 |
|
---|
586 | //
|
---|
587 | // 4) Check for pickup
|
---|
588 | //
|
---|
589 | hist.CountPickup();
|
---|
590 |
|
---|
591 | //
|
---|
592 | // 5) Check for oscillations
|
---|
593 | //
|
---|
594 | hist.CreateFourierSpectrum();
|
---|
595 |
|
---|
596 | //
|
---|
597 | // 6) Retrieve the results and store them in this class
|
---|
598 | //
|
---|
599 | pix.SetLoGainMeanCharge( hist.GetMean() );
|
---|
600 | pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );
|
---|
601 | pix.SetLoGainSigmaCharge( hist.GetSigma() );
|
---|
602 | pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );
|
---|
603 | pix.SetLoGainChargeProb ( hist.GetProb() );
|
---|
604 |
|
---|
605 | if (pix.IsHiGainSaturation())
|
---|
606 | {
|
---|
607 | pix.SetAbsTimeMean ( hist.GetAbsTimeMean());
|
---|
608 | pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );
|
---|
609 | }
|
---|
610 |
|
---|
611 | pix.SetLoGainOscillating ( !hist.IsFourierSpectrumOK() );
|
---|
612 | pix.SetLoGainNumPickup ( hist.GetPickup() );
|
---|
613 |
|
---|
614 | }
|
---|
615 |
|
---|
616 | Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
617 | {
|
---|
618 | return kTRUE;
|
---|
619 | }
|
---|
620 |
|
---|
621 | // --------------------------------------------------------------------------
|
---|
622 | //
|
---|
623 | // What MHCamera needs in order to draw an individual pixel in the camera
|
---|
624 | //
|
---|
625 | void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
|
---|
626 | {
|
---|
627 |
|
---|
628 | if (idx == -1)
|
---|
629 | fAverageHiGainInnerPix->DrawClone();
|
---|
630 | if (idx == -2)
|
---|
631 | fAverageHiGainOuterPix->DrawClone();
|
---|
632 | if (idx == -3)
|
---|
633 | fAverageLoGainInnerPix->DrawClone();
|
---|
634 | if (idx == -4)
|
---|
635 | fAverageLoGainOuterPix->DrawClone();
|
---|
636 | (*this)[idx].DrawClone();
|
---|
637 |
|
---|
638 | }
|
---|
639 |
|
---|
640 |
|
---|
641 | void MHCalibrationChargeCam::Draw(const Option_t *opt)
|
---|
642 | {
|
---|
643 |
|
---|
644 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
645 | pad->SetBorderMode(0);
|
---|
646 |
|
---|
647 | pad->Divide(2,2);
|
---|
648 |
|
---|
649 | pad->cd(1);
|
---|
650 |
|
---|
651 | if (!fAverageHiGainInnerPix->IsEmpty())
|
---|
652 | gPad->SetLogy();
|
---|
653 | fAverageHiGainInnerPix->Draw(opt);
|
---|
654 |
|
---|
655 | pad->cd(2);
|
---|
656 |
|
---|
657 | if (!fAverageLoGainInnerPix->IsEmpty())
|
---|
658 | gPad->SetLogy();
|
---|
659 | fAverageLoGainInnerPix->Draw(opt);
|
---|
660 |
|
---|
661 | pad->cd(3);
|
---|
662 |
|
---|
663 | if (!fAverageHiGainOuterPix->IsEmpty())
|
---|
664 | gPad->SetLogy();
|
---|
665 | fAverageHiGainOuterPix->Draw(opt);
|
---|
666 |
|
---|
667 | pad->cd(4);
|
---|
668 |
|
---|
669 | if (!fAverageLoGainOuterPix->IsEmpty())
|
---|
670 | gPad->SetLogy();
|
---|
671 | fAverageLoGainOuterPix->Draw(opt);
|
---|
672 |
|
---|
673 | }
|
---|