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