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 | //
|
---|
27 | // MHCalibrationChargeBlindPix
|
---|
28 | //
|
---|
29 | // Histogram class for the charge calibration of the Blind Pixel.
|
---|
30 | // Stores and fits the charges and stores the averaged assumed pedestal and
|
---|
31 | // single-phe FADC slice entries. Charges are taken from MExtractedSignalBlindPix.
|
---|
32 | // Performs the Single Photo-electron fit to extract the Poisson mean and its errors.
|
---|
33 | //
|
---|
34 | // Different fits can be chosen with the function ChangeFitFunc().
|
---|
35 | //
|
---|
36 | // The fit result is accepted under the condition that:
|
---|
37 | // 1) the Probability is greater than fProbLimit (default 0.001 == 99.7%)
|
---|
38 | // 2) at least fNumSinglePheLimit events are found in the single Photo-electron peak
|
---|
39 | //
|
---|
40 | // The single FADC slice entries are averaged and stored in fASinglePheFADCSlices, if
|
---|
41 | // their sum exceeds fSinglePheCut, otherwise in fAPedestalFADCSlices.
|
---|
42 | //
|
---|
43 | // Used numbers are the following:
|
---|
44 | //
|
---|
45 | // Electronic conversion factor:
|
---|
46 | // Assume, we have N_e electrons at the anode,
|
---|
47 | // thus a charge of N_e*e (e = electron charge) Coulomb.
|
---|
48 | //
|
---|
49 | // This charge is AC coupled and runs into a R_pre = 50 Ohm resistency.
|
---|
50 | // The corresponding current is amplified by a gain factor G_pre = 400
|
---|
51 | // (the precision of this value still has to be checked !!!) and again AC coupled to
|
---|
52 | // the output.
|
---|
53 | // The corresponding signal goes through the whole transmission and
|
---|
54 | // amplification chain and is digitized in the FADCs.
|
---|
55 | // The conversion Signal Area to FADC counts (Conv_trans) has been measured
|
---|
56 | // by David and Oscar to be approx. 3.9 pVs^-1
|
---|
57 | //
|
---|
58 | // Thus: Conversion FADC counts to Number of Electrons at Anode:
|
---|
59 | // FADC counts = (1/Conv_tran) * G_pre * R_pre * e * N_e = 8 * 10^-4 N_e.
|
---|
60 | //
|
---|
61 | // Also: FADC counts = 8*10^-4 * GAIN * N_phe
|
---|
62 | //
|
---|
63 | // In the blind pixel, there is an additional pre-amplifier with an amplification of
|
---|
64 | // about 10. Therefore, we have for the blind pixel:
|
---|
65 | //
|
---|
66 | // FADC counts (Blind Pixel) = 8*10^-3 * GAIN * N_phe
|
---|
67 | //
|
---|
68 | //////////////////////////////////////////////////////////////////////////////
|
---|
69 | #include "MHCalibrationChargeBlindPix.h"
|
---|
70 |
|
---|
71 | #include <TStyle.h>
|
---|
72 | #include <TCanvas.h>
|
---|
73 | #include <TPaveText.h>
|
---|
74 |
|
---|
75 | #include <TVector.h>
|
---|
76 | #include <TF1.h>
|
---|
77 | #include <TH1.h>
|
---|
78 | #include <TRandom.h>
|
---|
79 |
|
---|
80 | #include "MLog.h"
|
---|
81 | #include "MLogManip.h"
|
---|
82 |
|
---|
83 | #include "MParList.h"
|
---|
84 |
|
---|
85 | #include "MRawEvtData.h"
|
---|
86 | #include "MRawEvtPixelIter.h"
|
---|
87 |
|
---|
88 | #include "MExtractedSignalBlindPixel.h"
|
---|
89 | #include "MCalibrationChargeBlindPix.h"
|
---|
90 |
|
---|
91 | ClassImp(MHCalibrationChargeBlindPix);
|
---|
92 |
|
---|
93 | using namespace std;
|
---|
94 |
|
---|
95 | const Double_t MHCalibrationChargeBlindPix::gkElectronicAmp = 0.008;
|
---|
96 | const Double_t MHCalibrationChargeBlindPix::gkElectronicAmpErr = 0.002;
|
---|
97 |
|
---|
98 | const Int_t MHCalibrationChargeBlindPix::fgChargeNbins = 5300;
|
---|
99 | const Axis_t MHCalibrationChargeBlindPix::fgChargeFirst = -100.5;
|
---|
100 | const Axis_t MHCalibrationChargeBlindPix::fgChargeLast = 5199.5;
|
---|
101 | const Float_t MHCalibrationChargeBlindPix::fgSinglePheCut = 200.;
|
---|
102 | const Float_t MHCalibrationChargeBlindPix::fgNumSinglePheLimit = 50.;
|
---|
103 | // --------------------------------------------------------------------------
|
---|
104 | //
|
---|
105 | // Default Constructor.
|
---|
106 | //
|
---|
107 | // Sets:
|
---|
108 | // - the default number for fNbins (fgChargeNbins)
|
---|
109 | // - the default number for fFirst (fgChargeFirst)
|
---|
110 | // - the default number for fLast (fgChargeLast)
|
---|
111 | // - the default number for fSinglePheCut (fgSingePheCut)
|
---|
112 | // - the default number for fNumSinglePheLimit (fgNumSinglePheLimit)
|
---|
113 | // - the default number of bins after stripping (30)
|
---|
114 | //
|
---|
115 | // - the default name of the fHGausHist ("HCalibrationChargeBlindPix")
|
---|
116 | // - the default title of the fHGausHist ("Distribution of Summed FADC slices Blind Pixel ")
|
---|
117 | // - the default x-axis title for fHGausHist ("Sum FADC Slices")
|
---|
118 | // - the default y-axis title for fHGausHist ("Nr. of events")
|
---|
119 | //
|
---|
120 | // Initializes:
|
---|
121 | // - all pointers to NULL
|
---|
122 | //
|
---|
123 | // Calls:
|
---|
124 | // - Clear()
|
---|
125 | //
|
---|
126 | MHCalibrationChargeBlindPix::MHCalibrationChargeBlindPix(const char *name, const char *title)
|
---|
127 | : fBlindPix(NULL), fSignal(NULL), fRawEvt(NULL),
|
---|
128 | fSinglePheFit(NULL),
|
---|
129 | fFitLegend(NULL),
|
---|
130 | fHSinglePheFADCSlices(NULL), fHPedestalFADCSlices(NULL)
|
---|
131 | {
|
---|
132 |
|
---|
133 | fName = name ? name : "MHCalibrationChargeBlindPix";
|
---|
134 | fTitle = title ? title : "Statistics of the FADC sums of Blind Pixel calibration events";
|
---|
135 |
|
---|
136 | SetNbins( fgChargeNbins );
|
---|
137 | SetFirst( fgChargeFirst );
|
---|
138 | SetLast ( fgChargeLast );
|
---|
139 |
|
---|
140 | SetSinglePheCut();
|
---|
141 | SetNumSinglePheLimit();
|
---|
142 |
|
---|
143 | SetBinsAfterStripping(30);
|
---|
144 |
|
---|
145 | fHGausHist.SetName("HCalibrationChargeBlindPix");
|
---|
146 | fHGausHist.SetTitle("Distribution of Summed FADC slices Blind Pixel");
|
---|
147 | fHGausHist.SetXTitle("Sum FADC Slices");
|
---|
148 | fHGausHist.SetYTitle("Nr. of events");
|
---|
149 |
|
---|
150 | Clear();
|
---|
151 | }
|
---|
152 |
|
---|
153 | // --------------------------------------------------------------------------
|
---|
154 | //
|
---|
155 | // Default Destructor.
|
---|
156 | //
|
---|
157 | // Deletes (if Pointer is not NULL):
|
---|
158 | //
|
---|
159 | // - fSinglePheFit
|
---|
160 | // - fFitLegend
|
---|
161 | // - fHSinglePheFADCSlices
|
---|
162 | // - fHPedestalFADCSlices
|
---|
163 | //
|
---|
164 | MHCalibrationChargeBlindPix::~MHCalibrationChargeBlindPix()
|
---|
165 | {
|
---|
166 |
|
---|
167 | if (fSinglePheFit)
|
---|
168 | delete fSinglePheFit;
|
---|
169 |
|
---|
170 | if (fFitLegend)
|
---|
171 | delete fFitLegend;
|
---|
172 |
|
---|
173 | if (fHSinglePheFADCSlices)
|
---|
174 | delete fHSinglePheFADCSlices;
|
---|
175 |
|
---|
176 | if (fHPedestalFADCSlices)
|
---|
177 | delete fHPedestalFADCSlices;
|
---|
178 |
|
---|
179 | }
|
---|
180 |
|
---|
181 | // --------------------------------------------------------------------------
|
---|
182 | //
|
---|
183 | // Sets:
|
---|
184 | // - all variables to 0., except the fit result variables to -999.
|
---|
185 | // - all flags to kFALSE
|
---|
186 | // - all pointers to NULL
|
---|
187 | // - the default fit function (kEPoisson5)
|
---|
188 | //
|
---|
189 | // Deletes:
|
---|
190 | // - all pointers unequal NULL
|
---|
191 | //
|
---|
192 | // Calls:
|
---|
193 | // - MHCalibrationChargePix::Clear()
|
---|
194 | //
|
---|
195 | void MHCalibrationChargeBlindPix::Clear(Option_t *o)
|
---|
196 | {
|
---|
197 |
|
---|
198 | fLambda = -999.;
|
---|
199 | fMu0 = -999.;
|
---|
200 | fMu1 = -999.;
|
---|
201 | fSigma0 = -999.;
|
---|
202 | fSigma1 = -999.;
|
---|
203 |
|
---|
204 | fLambdaErr = -999.;
|
---|
205 | fMu0Err = -999.;
|
---|
206 | fMu1Err = -999.;
|
---|
207 | fSigma0Err = -999.;
|
---|
208 | fSigma1Err = -999.;
|
---|
209 |
|
---|
210 | fLambdaCheck = -999.;
|
---|
211 | fLambdaCheckErr = -999.;
|
---|
212 |
|
---|
213 | fFitFunc = kEPoisson5;
|
---|
214 |
|
---|
215 | fNumSinglePhes = 0;
|
---|
216 | fNumPedestals = 0;
|
---|
217 |
|
---|
218 | fChisquare = 0.;
|
---|
219 | fNDF = 0 ;
|
---|
220 | fProb = 0.;
|
---|
221 |
|
---|
222 | SetSinglePheFitOK ( kFALSE );
|
---|
223 | SetPedestalFitOK ( kFALSE );
|
---|
224 |
|
---|
225 | if (fFitLegend)
|
---|
226 | {
|
---|
227 | delete fFitLegend;
|
---|
228 | fFitLegend = NULL;
|
---|
229 | }
|
---|
230 |
|
---|
231 | if (fSinglePheFit)
|
---|
232 | {
|
---|
233 | delete fSinglePheFit;
|
---|
234 | fSinglePheFit = NULL;
|
---|
235 | }
|
---|
236 |
|
---|
237 | if (fHSinglePheFADCSlices)
|
---|
238 | {
|
---|
239 | delete fHSinglePheFADCSlices;
|
---|
240 | fHSinglePheFADCSlices = NULL;
|
---|
241 | }
|
---|
242 |
|
---|
243 | if (fHPedestalFADCSlices)
|
---|
244 | {
|
---|
245 | delete fHPedestalFADCSlices;
|
---|
246 | fHPedestalFADCSlices = NULL;
|
---|
247 | }
|
---|
248 |
|
---|
249 |
|
---|
250 | MHCalibrationChargePix::Clear();
|
---|
251 | return;
|
---|
252 | }
|
---|
253 |
|
---|
254 | // --------------------------------------------------------------------------
|
---|
255 | //
|
---|
256 | // Set bit kSinglePheFitOK from outside
|
---|
257 | //
|
---|
258 | void MHCalibrationChargeBlindPix::SetSinglePheFitOK (const Bool_t b)
|
---|
259 | {
|
---|
260 | b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
|
---|
261 | }
|
---|
262 |
|
---|
263 | // --------------------------------------------------------------------------
|
---|
264 | //
|
---|
265 | // Set bit kPedestalFitOK from outside
|
---|
266 | //
|
---|
267 | void MHCalibrationChargeBlindPix::SetPedestalFitOK(const Bool_t b)
|
---|
268 | {
|
---|
269 | b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
|
---|
270 | }
|
---|
271 |
|
---|
272 | // --------------------------------------------------------------------------
|
---|
273 | //
|
---|
274 | // Ask for status of bit kSinglePheFitOK
|
---|
275 | //
|
---|
276 | const Bool_t MHCalibrationChargeBlindPix::IsSinglePheFitOK() const
|
---|
277 | {
|
---|
278 | return TESTBIT(fFlags,kSinglePheFitOK);
|
---|
279 | }
|
---|
280 |
|
---|
281 | // --------------------------------------------------------------------------
|
---|
282 | //
|
---|
283 | // Ask for status of bit kPedestalFitOK
|
---|
284 | //
|
---|
285 | const Bool_t MHCalibrationChargeBlindPix::IsPedestalFitOK() const
|
---|
286 | {
|
---|
287 | return TESTBIT(fFlags,kPedestalFitOK);
|
---|
288 | }
|
---|
289 |
|
---|
290 | // --------------------------------------------------------------------------
|
---|
291 | //
|
---|
292 | // Gets the pointers to:
|
---|
293 | // - MRawEvtData
|
---|
294 | // - MExtractedSignalBlindPixel
|
---|
295 | //
|
---|
296 | // Initializes:
|
---|
297 | // - fASinglePheFADCSlices(0);
|
---|
298 | // - fAPedestalFADCSlices(0);
|
---|
299 | //
|
---|
300 | // Calls:
|
---|
301 | // - MHGausHist::InitBins()
|
---|
302 | //
|
---|
303 | Bool_t MHCalibrationChargeBlindPix::SetupFill(const MParList *pList)
|
---|
304 | {
|
---|
305 |
|
---|
306 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
---|
307 | if (!fRawEvt)
|
---|
308 | {
|
---|
309 | *fLog << err << "MRawEvtData not found... aborting." << endl;
|
---|
310 | return kFALSE;
|
---|
311 | }
|
---|
312 |
|
---|
313 | fSignal = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
|
---|
314 | if (!fSignal)
|
---|
315 | {
|
---|
316 | *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
|
---|
317 | return kFALSE;
|
---|
318 | }
|
---|
319 |
|
---|
320 | fASinglePheFADCSlices(0);
|
---|
321 | fAPedestalFADCSlices(0);
|
---|
322 |
|
---|
323 | InitBins();
|
---|
324 |
|
---|
325 | return kTRUE;
|
---|
326 | }
|
---|
327 |
|
---|
328 | // --------------------------------------------------------------------------
|
---|
329 | //
|
---|
330 | // Gets or creates the pointers to:
|
---|
331 | // - MCalibrationChargeBlindPix
|
---|
332 | //
|
---|
333 | Bool_t MHCalibrationChargeBlindPix::ReInit(MParList *pList)
|
---|
334 | {
|
---|
335 |
|
---|
336 | fBlindPix = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
|
---|
337 | if (!fBlindPix)
|
---|
338 | return kFALSE;
|
---|
339 |
|
---|
340 | return kTRUE;
|
---|
341 | }
|
---|
342 |
|
---|
343 | // --------------------------------------------------------------------------
|
---|
344 | //
|
---|
345 | // Retrieves from MExtractedSignalBlindPixel:
|
---|
346 | // - number of FADC samples
|
---|
347 | // - extracted signal
|
---|
348 | // - blind Pixel ID
|
---|
349 | //
|
---|
350 | // Resizes (if necessary):
|
---|
351 | // - fASinglePheFADCSlices to sum of HiGain and LoGain samples
|
---|
352 | // - fAPedestalFADCSlices to sum of HiGain and LoGain samples
|
---|
353 | //
|
---|
354 | // Fills the following histograms:
|
---|
355 | // - MHGausEvents::FillHistAndArray(signal)
|
---|
356 | //
|
---|
357 | // Creates MRawEvtPixelIter, jumps to blind pixel ID,
|
---|
358 | // fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices
|
---|
359 | // with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
|
---|
360 | //
|
---|
361 | Bool_t MHCalibrationChargeBlindPix::Fill(const MParContainer *par, const Stat_t w)
|
---|
362 | {
|
---|
363 |
|
---|
364 | const Int_t samples = (Int_t)fRawEvt->GetNumHiGainSamples()+(Int_t)fRawEvt->GetNumLoGainSamples();
|
---|
365 |
|
---|
366 | if (fASinglePheFADCSlices.GetNrows() != samples)
|
---|
367 | {
|
---|
368 | fASinglePheFADCSlices.ResizeTo(samples);
|
---|
369 | fAPedestalFADCSlices.ResizeTo(samples);
|
---|
370 | }
|
---|
371 |
|
---|
372 | Float_t slices = (Float_t)fSignal->GetNumFADCSamples();
|
---|
373 |
|
---|
374 | if (slices == 0.)
|
---|
375 | {
|
---|
376 | *fLog << err << "Number of used signal slices in MExtractedSignalBlindPix is zero ... abort."
|
---|
377 | << endl;
|
---|
378 | return kFALSE;
|
---|
379 | }
|
---|
380 |
|
---|
381 | //
|
---|
382 | // Signal extraction and histogram filling
|
---|
383 | //
|
---|
384 | const Float_t signal = (Float_t)fSignal->GetExtractedSignal();
|
---|
385 | FillHistAndArray(signal);
|
---|
386 |
|
---|
387 | //
|
---|
388 | // IN order to study the single-phe posistion, we extract the slices
|
---|
389 | //
|
---|
390 | const Int_t blindpixIdx = fSignal->GetBlindPixelIdx();
|
---|
391 |
|
---|
392 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
393 | pixel.Jump(blindpixIdx);
|
---|
394 |
|
---|
395 | if (signal > fSinglePheCut)
|
---|
396 | FillSinglePheFADCSlices(pixel);
|
---|
397 | else
|
---|
398 | FillPedestalFADCSlices(pixel);
|
---|
399 |
|
---|
400 | return kTRUE;
|
---|
401 | }
|
---|
402 |
|
---|
403 | // --------------------------------------------------------------------------
|
---|
404 | //
|
---|
405 | // Returns kFALSE, if empty
|
---|
406 | //
|
---|
407 | // - Creates the fourier spectrum and sets bit MHGausEvents::IsFourierSpectrumOK()
|
---|
408 | // - Retrieves the pedestals from MExtractedSignalBlindPixel
|
---|
409 | // - Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
|
---|
410 | // - Executes FitPedestal()
|
---|
411 | // - Executes FitSinglePhe()
|
---|
412 | // - Retrieves fit results and stores them in MCalibrationChargeBlindPix
|
---|
413 | //
|
---|
414 | Bool_t MHCalibrationChargeBlindPix::Finalize()
|
---|
415 | {
|
---|
416 |
|
---|
417 | if (IsEmpty())
|
---|
418 | {
|
---|
419 | *fLog << err << GetDescriptor() << ": My histogram has not been filled !! " << endl;
|
---|
420 | return kFALSE;
|
---|
421 | }
|
---|
422 |
|
---|
423 | CreateFourierSpectrum();
|
---|
424 | fBlindPix->SetOscillating ( !IsFourierSpectrumOK() );
|
---|
425 |
|
---|
426 | fMeanPedestal = fSignal->GetPed();
|
---|
427 | fMeanPedestalErr = fSignal->GetPedErr();
|
---|
428 | fSigmaPedestal = fSignal->GetPedRms();
|
---|
429 | fSigmaPedestalErr = fSignal->GetPedRmsErr();
|
---|
430 |
|
---|
431 | if (fNumSinglePhes > 1)
|
---|
432 | for (Int_t i=0;i<fASinglePheFADCSlices.GetNrows();i++)
|
---|
433 | fASinglePheFADCSlices[i] = fASinglePheFADCSlices[i]/fNumSinglePhes;
|
---|
434 | if (fNumPedestals > 1)
|
---|
435 | for (Int_t i=0;i<fAPedestalFADCSlices.GetNrows();i++)
|
---|
436 | fAPedestalFADCSlices[i] = fAPedestalFADCSlices[i]/fNumPedestals;
|
---|
437 |
|
---|
438 | FitPedestal();
|
---|
439 |
|
---|
440 | if (FitSinglePhe())
|
---|
441 | fBlindPix->SetSinglePheFitOK();
|
---|
442 |
|
---|
443 | fBlindPix->SetLambda ( fLambda );
|
---|
444 | fBlindPix->SetLambdaVar ( fLambdaErr*fLambdaErr );
|
---|
445 | fBlindPix->SetMu0 ( fMu0 );
|
---|
446 | fBlindPix->SetMu0Err ( fMu0Err );
|
---|
447 | fBlindPix->SetMu1 ( fMu1 );
|
---|
448 | fBlindPix->SetMu1Err ( fMu1Err );
|
---|
449 | fBlindPix->SetSigma0 ( fSigma0 );
|
---|
450 | fBlindPix->SetSigma0Err ( fSigma0Err );
|
---|
451 | fBlindPix->SetSigma1 ( fSigma1 );
|
---|
452 | fBlindPix->SetSigma1Err ( fSigma1Err );
|
---|
453 | fBlindPix->SetProb ( fProb );
|
---|
454 |
|
---|
455 | fBlindPix->SetLambdaCheck ( fLambdaCheck );
|
---|
456 | fBlindPix->SetLambdaCheckErr ( fLambdaCheckErr );
|
---|
457 |
|
---|
458 | return kTRUE;
|
---|
459 | }
|
---|
460 |
|
---|
461 |
|
---|
462 | // --------------------------------------------------------------------------
|
---|
463 | //
|
---|
464 | // Checks again for the size and fills fASinglePheFADCSlices with the FADC slice entries
|
---|
465 | //
|
---|
466 | void MHCalibrationChargeBlindPix::FillSinglePheFADCSlices(const MRawEvtPixelIter &iter)
|
---|
467 | {
|
---|
468 |
|
---|
469 | const Int_t n = iter.GetNumHiGainSamples() + iter.GetNumLoGainSamples();
|
---|
470 |
|
---|
471 | if (fASinglePheFADCSlices.GetNrows() < n)
|
---|
472 | fASinglePheFADCSlices.ResizeTo(n);
|
---|
473 |
|
---|
474 | Int_t i=0;
|
---|
475 |
|
---|
476 | Byte_t *start = iter.GetHiGainSamples();
|
---|
477 | Byte_t *end = start + iter.GetNumHiGainSamples();
|
---|
478 |
|
---|
479 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
---|
480 | fASinglePheFADCSlices(i) = fASinglePheFADCSlices(i) + (Float_t)*ptr;
|
---|
481 |
|
---|
482 | start = iter.GetLoGainSamples();
|
---|
483 | end = start + iter.GetNumLoGainSamples();
|
---|
484 |
|
---|
485 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
---|
486 | fASinglePheFADCSlices(i) = fASinglePheFADCSlices(i) + (Float_t)*ptr;
|
---|
487 |
|
---|
488 | fNumSinglePhes++;
|
---|
489 | }
|
---|
490 |
|
---|
491 | // --------------------------------------------------------------------------
|
---|
492 | //
|
---|
493 | // Checks again for the size and fills fAPedestalFADCSlices with the FADC slice entries
|
---|
494 | //
|
---|
495 | void MHCalibrationChargeBlindPix::FillPedestalFADCSlices(const MRawEvtPixelIter &iter)
|
---|
496 | {
|
---|
497 |
|
---|
498 | const Int_t n = iter.GetNumHiGainSamples() + iter.GetNumLoGainSamples();
|
---|
499 |
|
---|
500 | if (fAPedestalFADCSlices.GetNrows() < n)
|
---|
501 | fAPedestalFADCSlices.ResizeTo(n);
|
---|
502 |
|
---|
503 | Int_t i = 0;
|
---|
504 | Byte_t *start = iter.GetHiGainSamples();
|
---|
505 | Byte_t *end = start + iter.GetNumHiGainSamples();
|
---|
506 |
|
---|
507 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
---|
508 | fAPedestalFADCSlices(i) = fAPedestalFADCSlices(i)+ (Float_t)*ptr;
|
---|
509 |
|
---|
510 | start = iter.GetLoGainSamples();
|
---|
511 | end = start + iter.GetNumLoGainSamples();
|
---|
512 |
|
---|
513 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
---|
514 | fAPedestalFADCSlices(i) = fAPedestalFADCSlices(i)+ (Float_t)*ptr;
|
---|
515 |
|
---|
516 | fNumPedestals++;
|
---|
517 | }
|
---|
518 |
|
---|
519 |
|
---|
520 | // --------------------------------------------------------------------------
|
---|
521 | //
|
---|
522 | // Task to simulate single phe spectrum with the given parameters
|
---|
523 | //
|
---|
524 | Bool_t MHCalibrationChargeBlindPix::SimulateSinglePhe(Double_t lambda, Double_t mu0, Double_t mu1, Double_t sigma0, Double_t sigma1)
|
---|
525 | {
|
---|
526 |
|
---|
527 | gRandom->SetSeed();
|
---|
528 |
|
---|
529 | if (fHGausHist.GetIntegral() != 0)
|
---|
530 | {
|
---|
531 | *fLog << err << "Histogram " << fHGausHist.GetTitle() << " is already filled. " << endl;
|
---|
532 | *fLog << err << "Create new class MHCalibrationBlindPixel for simulation! " << endl;
|
---|
533 | return kFALSE;
|
---|
534 | }
|
---|
535 |
|
---|
536 | if (!InitFit())
|
---|
537 | return kFALSE;
|
---|
538 |
|
---|
539 | for (Int_t i=0;i<10000; i++)
|
---|
540 | fHGausHist.Fill(fSinglePheFit->GetRandom());
|
---|
541 |
|
---|
542 | return kTRUE;
|
---|
543 | }
|
---|
544 |
|
---|
545 | // --------------------------------------------------------------------------
|
---|
546 | //
|
---|
547 | // - Get the ranges from the stripped histogram
|
---|
548 | // - choose reasonable start values for the fit
|
---|
549 | // - initialize the fit function depending on fFitFunc
|
---|
550 | // - initialize parameter names and limits depending on fFitFunc
|
---|
551 | //
|
---|
552 | Bool_t MHCalibrationChargeBlindPix::InitFit()
|
---|
553 | {
|
---|
554 |
|
---|
555 | //
|
---|
556 | // Get the fitting ranges
|
---|
557 | //
|
---|
558 | Axis_t rmin = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst());
|
---|
559 | Axis_t rmax = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetLast());
|
---|
560 |
|
---|
561 | if (rmin < 0.)
|
---|
562 | rmin = 0.;
|
---|
563 |
|
---|
564 | //
|
---|
565 | // First guesses for the fit (should be as close to reality as possible,
|
---|
566 | // otherwise the fit goes gaga because of high number of dimensions ...
|
---|
567 | //
|
---|
568 | const Stat_t entries = fHGausHist.Integral("width");
|
---|
569 | const Double_t lambda_guess = 0.1;
|
---|
570 | const Double_t maximum_bin = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
|
---|
571 | const Double_t norm = entries/TMath::Sqrt(TMath::TwoPi());
|
---|
572 |
|
---|
573 | //
|
---|
574 | // Initialize the fit function
|
---|
575 | //
|
---|
576 | switch (fFitFunc)
|
---|
577 | {
|
---|
578 | case kEPoisson4:
|
---|
579 | fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto4,rmin,rmax,6);
|
---|
580 | break;
|
---|
581 | case kEPoisson5:
|
---|
582 | fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto5,rmin,rmax,6);
|
---|
583 | break;
|
---|
584 | case kEPoisson6:
|
---|
585 | fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto6,rmin,rmax,6);
|
---|
586 | break;
|
---|
587 | case kEPolya:
|
---|
588 | fSinglePheFit = new TF1("SinglePheFit",&fPolya,rmin,rmax,8);
|
---|
589 | break;
|
---|
590 | case kEMichele:
|
---|
591 | break;
|
---|
592 |
|
---|
593 | default:
|
---|
594 | *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
|
---|
595 | return kFALSE;
|
---|
596 | break;
|
---|
597 | }
|
---|
598 |
|
---|
599 | if (!fSinglePheFit)
|
---|
600 | {
|
---|
601 | *fLog << warn << dbginf << "WARNING: Could not create fit function for Single Phe fit" << endl;
|
---|
602 | return kFALSE;
|
---|
603 | }
|
---|
604 |
|
---|
605 | const Double_t mu_0_guess = maximum_bin;
|
---|
606 | const Double_t si_0_guess = 40.;
|
---|
607 | const Double_t mu_1_guess = mu_0_guess + 100.;
|
---|
608 | const Double_t si_1_guess = si_0_guess + si_0_guess;
|
---|
609 | // Michele
|
---|
610 | // const Double_t lambda_1cat_guess = 0.5;
|
---|
611 | // const Double_t lambda_1dyn_guess = 0.5;
|
---|
612 | // const Double_t mu_1cat_guess = mu_0_guess + 50.;
|
---|
613 | // const Double_t mu_1dyn_guess = mu_0_guess + 20.;
|
---|
614 | // const Double_t si_1cat_guess = si_0_guess + si_0_guess;
|
---|
615 | // const Double_t si_1dyn_guess = si_0_guess;
|
---|
616 | // Polya
|
---|
617 | const Double_t excessPoisson_guess = 0.5;
|
---|
618 | const Double_t delta1_guess = 8.;
|
---|
619 | const Double_t delta2_guess = 5.;
|
---|
620 | const Double_t electronicAmp_guess = gkElectronicAmp;
|
---|
621 | const Double_t electronicAmp_limit = gkElectronicAmpErr;
|
---|
622 |
|
---|
623 | //
|
---|
624 | // Initialize boundaries and start parameters
|
---|
625 | //
|
---|
626 | switch (fFitFunc)
|
---|
627 | {
|
---|
628 |
|
---|
629 | case kEPoisson4:
|
---|
630 | fSinglePheFit->SetParNames( "#lambda", "#mu_{0}", "#mu_{1}", "#sigma_{0}", "#sigma_{1}","Area");
|
---|
631 | fSinglePheFit->SetParameters(lambda_guess,fMeanPedestal,mu_1_guess,fSigmaPedestal,si_1_guess,norm);
|
---|
632 |
|
---|
633 | fSinglePheFit->SetParLimits(0,0.,0.5);
|
---|
634 | fSinglePheFit->SetParLimits(1,
|
---|
635 | fMeanPedestal-5.*fMeanPedestalErr,
|
---|
636 | fMeanPedestal+5.*fMeanPedestalErr);
|
---|
637 | fSinglePheFit->SetParLimits(2,rmin,rmax);
|
---|
638 | fSinglePheFit->SetParLimits(3,
|
---|
639 | fSigmaPedestal-5.*fSigmaPedestalErr,
|
---|
640 | fSigmaPedestal+5.*fSigmaPedestalErr);
|
---|
641 | fSinglePheFit->SetParLimits(4,0.,(rmax-rmin));
|
---|
642 | fSinglePheFit->SetParLimits(5,norm-(0.5*norm),norm+(0.5*norm));
|
---|
643 | break;
|
---|
644 | case kEPoisson5:
|
---|
645 | case kEPoisson6:
|
---|
646 | fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
|
---|
647 | fSinglePheFit->SetParNames("#lambda","#mu_{0}","#mu_{1}","#sigma_{0}","#sigma_{1}","Area");
|
---|
648 | fSinglePheFit->SetParLimits(0,0.,1.);
|
---|
649 | fSinglePheFit->SetParLimits(1,rmin,(rmax-rmin)/1.5);
|
---|
650 | fSinglePheFit->SetParLimits(2,(rmax-rmin)/2.,(rmax-0.05*(rmax-rmin)));
|
---|
651 | fSinglePheFit->SetParLimits(3,1.0,(rmax-rmin)/2.0);
|
---|
652 | fSinglePheFit->SetParLimits(4,1.0,(rmax-rmin)/2.5);
|
---|
653 | fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1);
|
---|
654 | break;
|
---|
655 |
|
---|
656 | case kEPolya:
|
---|
657 | fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
|
---|
658 | delta1_guess,delta2_guess,
|
---|
659 | electronicAmp_guess,
|
---|
660 | fSigmaPedestal,
|
---|
661 | norm,
|
---|
662 | fMeanPedestal);
|
---|
663 | fSinglePheFit->SetParNames("#lambda","b_{tot}",
|
---|
664 | "#delta_{1}","#delta_{2}",
|
---|
665 | "amp_{e}","#sigma_{0}",
|
---|
666 | "Area", "#mu_{0}");
|
---|
667 | fSinglePheFit->SetParLimits(0,0.,1.);
|
---|
668 | fSinglePheFit->SetParLimits(1,0.,1.);
|
---|
669 | fSinglePheFit->SetParLimits(2,6.,12.);
|
---|
670 | fSinglePheFit->SetParLimits(3,3.,8.);
|
---|
671 | fSinglePheFit->SetParLimits(4,electronicAmp_guess-electronicAmp_limit,
|
---|
672 | electronicAmp_guess+electronicAmp_limit);
|
---|
673 | fSinglePheFit->SetParLimits(5,
|
---|
674 | fSigmaPedestal-3.*fSigmaPedestalErr,
|
---|
675 | fSigmaPedestal+3.*fSigmaPedestalErr);
|
---|
676 | fSinglePheFit->SetParLimits(6,norm-0.1,norm+0.1);
|
---|
677 | fSinglePheFit->SetParLimits(7,
|
---|
678 | fMeanPedestal-3.*fMeanPedestalErr,
|
---|
679 | fMeanPedestal+3.*fMeanPedestalErr);
|
---|
680 | break;
|
---|
681 | case kEMichele:
|
---|
682 | break;
|
---|
683 |
|
---|
684 | default:
|
---|
685 | *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
|
---|
686 | return kFALSE;
|
---|
687 | break;
|
---|
688 | }
|
---|
689 |
|
---|
690 | fSinglePheFit->SetRange(rmin,rmax);
|
---|
691 |
|
---|
692 | return kTRUE;
|
---|
693 | }
|
---|
694 |
|
---|
695 | // --------------------------------------------------------------------------
|
---|
696 | //
|
---|
697 | // - Retrieve the parameters depending on fFitFunc
|
---|
698 | // - Retrieve probability, Chisquare and NDF
|
---|
699 | //
|
---|
700 | void MHCalibrationChargeBlindPix::ExitFit()
|
---|
701 | {
|
---|
702 |
|
---|
703 |
|
---|
704 | //
|
---|
705 | // Finalize
|
---|
706 | //
|
---|
707 | switch (fFitFunc)
|
---|
708 | {
|
---|
709 |
|
---|
710 | case kEPoisson4:
|
---|
711 | case kEPoisson5:
|
---|
712 | case kEPoisson6:
|
---|
713 | case kEPoisson7:
|
---|
714 | fLambda = fSinglePheFit->GetParameter(0);
|
---|
715 | fMu0 = fSinglePheFit->GetParameter(1);
|
---|
716 | fMu1 = fSinglePheFit->GetParameter(2);
|
---|
717 | fSigma0 = fSinglePheFit->GetParameter(3);
|
---|
718 | fSigma1 = fSinglePheFit->GetParameter(4);
|
---|
719 |
|
---|
720 | fLambdaErr = fSinglePheFit->GetParError(0);
|
---|
721 | fMu0Err = fSinglePheFit->GetParError(1);
|
---|
722 | fMu1Err = fSinglePheFit->GetParError(2);
|
---|
723 | fSigma0Err = fSinglePheFit->GetParError(3);
|
---|
724 | fSigma1Err = fSinglePheFit->GetParError(4);
|
---|
725 | break;
|
---|
726 | case kEPolya:
|
---|
727 | fLambda = fSinglePheFit->GetParameter(0);
|
---|
728 | fMu0 = fSinglePheFit->GetParameter(7);
|
---|
729 | fMu1 = 0.;
|
---|
730 | fSigma0 = fSinglePheFit->GetParameter(5);
|
---|
731 | fSigma1 = 0.;
|
---|
732 |
|
---|
733 | fLambdaErr = fSinglePheFit->GetParError(0);
|
---|
734 | fMu0Err = fSinglePheFit->GetParError(7);
|
---|
735 | fMu1Err = 0.;
|
---|
736 | fSigma0Err = fSinglePheFit->GetParError(5);
|
---|
737 | fSigma1Err = 0.;
|
---|
738 | default:
|
---|
739 | break;
|
---|
740 | }
|
---|
741 |
|
---|
742 | fProb = fSinglePheFit->GetProb();
|
---|
743 | fChisquare = fSinglePheFit->GetChisquare();
|
---|
744 | fNDF = fSinglePheFit->GetNDF();
|
---|
745 |
|
---|
746 | *fLog << all << "Results of the Blind Pixel Fit: " << endl;
|
---|
747 | *fLog << all << "Chisquare: " << fChisquare << endl;
|
---|
748 | *fLog << all << "DoF: " << fNDF << endl;
|
---|
749 | *fLog << all << "Probability: " << fProb << endl;
|
---|
750 |
|
---|
751 | }
|
---|
752 |
|
---|
753 | // --------------------------------------------------------------------------
|
---|
754 | //
|
---|
755 | // - Executes InitFit()
|
---|
756 | // - Fits the fHGausHist with fSinglePheFit
|
---|
757 | // - Executes ExitFit()
|
---|
758 | //
|
---|
759 | // The fit result is accepted under condition:
|
---|
760 | // 1) The results are not nan's
|
---|
761 | // 2) The NDF is not smaller than fNDFLimit (5)
|
---|
762 | // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
|
---|
763 | // 4) at least fNumSinglePheLimit events are in the single Photo-electron peak
|
---|
764 | //
|
---|
765 | Bool_t MHCalibrationChargeBlindPix::FitSinglePhe(Option_t *opt)
|
---|
766 | {
|
---|
767 |
|
---|
768 | if (!InitFit())
|
---|
769 | return kFALSE;
|
---|
770 |
|
---|
771 | fHGausHist.Fit(fSinglePheFit,opt);
|
---|
772 |
|
---|
773 | ExitFit();
|
---|
774 |
|
---|
775 | //
|
---|
776 | // The fit result is accepted under condition:
|
---|
777 | // 1) The results are not nan's
|
---|
778 | // 2) The NDF is not smaller than fNDFLimit (5)
|
---|
779 | // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
|
---|
780 | // 4) at least fNumSinglePheLimit events are in the single Photo-electron peak
|
---|
781 | //
|
---|
782 | if ( TMath::IsNaN(fLambda)
|
---|
783 | || TMath::IsNaN(fLambdaErr)
|
---|
784 | || TMath::IsNaN(fProb)
|
---|
785 | || TMath::IsNaN(fMu0)
|
---|
786 | || TMath::IsNaN(fMu0Err)
|
---|
787 | || TMath::IsNaN(fMu1)
|
---|
788 | || TMath::IsNaN(fMu1Err)
|
---|
789 | || TMath::IsNaN(fSigma0)
|
---|
790 | || TMath::IsNaN(fSigma0Err)
|
---|
791 | || TMath::IsNaN(fSigma1)
|
---|
792 | || TMath::IsNaN(fSigma1Err)
|
---|
793 | || fNDF < fNDFLimit
|
---|
794 | || fProb < fProbLimit )
|
---|
795 | return kFALSE;
|
---|
796 |
|
---|
797 | const Stat_t entries = fHGausHist.Integral("width");
|
---|
798 | const Float_t numSinglePhe = TMath::Exp(-1.0*fLambda)*fLambda*entries;
|
---|
799 |
|
---|
800 | if (numSinglePhe < fNumSinglePheLimit)
|
---|
801 | {
|
---|
802 | *fLog << warn << "WARNING - Statistics is too low: Only " << numSinglePhe
|
---|
803 | << " in the Single Photo-Electron peak " << endl;
|
---|
804 | return kFALSE;
|
---|
805 | }
|
---|
806 | else
|
---|
807 | *fLog << all << numSinglePhe << " in Single Photo-Electron peak " << endl;
|
---|
808 |
|
---|
809 | SetSinglePheFitOK();
|
---|
810 | return kTRUE;
|
---|
811 | }
|
---|
812 |
|
---|
813 | // --------------------------------------------------------------------------
|
---|
814 | //
|
---|
815 | // - Retrieves limits for the fit
|
---|
816 | // - Fits the fHGausHist with Gauss
|
---|
817 | // - Retrieves the results to fLambdaCheck and fLambdaCheckErr
|
---|
818 | // - Sets a flag IsPedestalFitOK()
|
---|
819 | //
|
---|
820 | void MHCalibrationChargeBlindPix::FitPedestal (Option_t *opt)
|
---|
821 | {
|
---|
822 |
|
---|
823 | // Perform the cross-check fitting only the pedestal:
|
---|
824 | const Axis_t rmin = 0.;
|
---|
825 | const Axis_t rmax = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
|
---|
826 |
|
---|
827 | FitGaus(opt, rmin, rmax);
|
---|
828 |
|
---|
829 | const Stat_t entries = fHGausHist.Integral("width");
|
---|
830 | const Double_t fitarea = fFGausFit->GetParameter(0);
|
---|
831 | const Double_t pedarea = fitarea * TMath::Sqrt(TMath::TwoPi()) * fFGausFit->GetParameter(2);
|
---|
832 |
|
---|
833 | fLambdaCheck = TMath::Log(entries/pedarea);
|
---|
834 | fLambdaCheckErr = fFGausFit->GetParError(0)/fFGausFit->GetParameter(0)
|
---|
835 | + fFGausFit->GetParError(2)/fFGausFit->GetParameter(2);
|
---|
836 |
|
---|
837 |
|
---|
838 | SetPedestalFitOK();
|
---|
839 | return;
|
---|
840 | }
|
---|
841 |
|
---|
842 |
|
---|
843 | // -------------------------------------------------------------------------
|
---|
844 | //
|
---|
845 | // Draw a legend with the fit results
|
---|
846 | //
|
---|
847 | void MHCalibrationChargeBlindPix::DrawLegend()
|
---|
848 | {
|
---|
849 |
|
---|
850 | if (!fFitLegend)
|
---|
851 | {
|
---|
852 | fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
|
---|
853 | fFitLegend->SetLabel(Form("%s%s", "Results of the single PhE Fit (",
|
---|
854 | (fFitFunc = kEPoisson4) ? "Poisson(k=4))" :
|
---|
855 | (fFitFunc = kEPoisson5) ? "Poisson(k=5))" :
|
---|
856 | (fFitFunc = kEPoisson6) ? "Poisson(k=4))" :
|
---|
857 | (fFitFunc = kEPolya ) ? "Polya(k=4))" :
|
---|
858 | (fFitFunc = kEMichele ) ? "Michele)" : " none )" ));
|
---|
859 | fFitLegend->SetTextSize(0.05);
|
---|
860 | }
|
---|
861 | else
|
---|
862 | fFitLegend->Clear();
|
---|
863 |
|
---|
864 | const TString line1 =
|
---|
865 | Form("Mean: #lambda = %2.2f #pm %2.2f",fLambda,fLambdaErr);
|
---|
866 | TText *t1 = fFitLegend->AddText(line1.Data());
|
---|
867 | t1->SetBit(kCanDelete);
|
---|
868 |
|
---|
869 | const TString line6 =
|
---|
870 | Form("Mean #lambda (check) = %2.2f #pm %2.2f",fLambdaCheck,fLambdaCheckErr);
|
---|
871 | TText *t2 = fFitLegend->AddText(line6.Data());
|
---|
872 | t2->SetBit(kCanDelete);
|
---|
873 |
|
---|
874 | const TString line2 =
|
---|
875 | Form("Pedestal: #mu_{0} = %2.2f #pm %2.2f",fMu0,fMu0Err);
|
---|
876 | TText *t3 = fFitLegend->AddText(line2.Data());
|
---|
877 | t3->SetBit(kCanDelete);
|
---|
878 |
|
---|
879 | const TString line3 =
|
---|
880 | Form("Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",fSigma0,fSigma0Err);
|
---|
881 | TText *t4 = fFitLegend->AddText(line3.Data());
|
---|
882 | t4->SetBit(kCanDelete);
|
---|
883 |
|
---|
884 | const TString line4 =
|
---|
885 | Form("1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",fMu1,fMu1Err);
|
---|
886 | TText *t5 = fFitLegend->AddText(line4.Data());
|
---|
887 | t5->SetBit(kCanDelete);
|
---|
888 |
|
---|
889 | const TString line5 =
|
---|
890 | Form("Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",fSigma1,fSigma1Err);
|
---|
891 | TText *t6 = fFitLegend->AddText(line5.Data());
|
---|
892 | t6->SetBit(kCanDelete);
|
---|
893 |
|
---|
894 | const TString line7 =
|
---|
895 | Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChisquare,fNDF);
|
---|
896 | TText *t7 = fFitLegend->AddText(line7.Data());
|
---|
897 | t7->SetBit(kCanDelete);
|
---|
898 |
|
---|
899 | const TString line8 =
|
---|
900 | Form("Probability: %4.2f ",fProb);
|
---|
901 | TText *t8 = fFitLegend->AddText(line8.Data());
|
---|
902 | t8->SetBit(kCanDelete);
|
---|
903 |
|
---|
904 | if (IsSinglePheFitOK())
|
---|
905 | {
|
---|
906 | TText *t = fFitLegend->AddText(0.,0.,"Result of the Fit: OK");
|
---|
907 | t->SetBit(kCanDelete);
|
---|
908 | }
|
---|
909 | else
|
---|
910 | {
|
---|
911 | TText *t = fFitLegend->AddText("Result of the Fit: NOT OK");
|
---|
912 | t->SetBit(kCanDelete);
|
---|
913 | }
|
---|
914 |
|
---|
915 | fFitLegend->SetFillColor(IsSinglePheFitOK() ? 80 : 2);
|
---|
916 | fFitLegend->Draw();
|
---|
917 |
|
---|
918 | return;
|
---|
919 | }
|
---|
920 |
|
---|
921 |
|
---|
922 | // -------------------------------------------------------------------------
|
---|
923 | //
|
---|
924 | // Draw the histogram
|
---|
925 | //
|
---|
926 | // The following options can be chosen:
|
---|
927 | //
|
---|
928 | // "": displays the fHGausHist, the legend and fASinglePheFADCSlices and fAPedestalFADCSlices
|
---|
929 | // "all": executes additionally MHGausEvents::Draw(), with option "fourierevents"
|
---|
930 | //
|
---|
931 | void MHCalibrationChargeBlindPix::Draw(Option_t *opt)
|
---|
932 | {
|
---|
933 |
|
---|
934 | TString option(opt);
|
---|
935 | option.ToLower();
|
---|
936 |
|
---|
937 | Int_t win = 1;
|
---|
938 |
|
---|
939 | TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,900, 600);
|
---|
940 | TVirtualPad *pad = NULL;
|
---|
941 |
|
---|
942 | oldpad->SetBorderMode(0);
|
---|
943 |
|
---|
944 | if (option.Contains("all"))
|
---|
945 | {
|
---|
946 | option.ReplaceAll("all","");
|
---|
947 | oldpad->Divide(2,1);
|
---|
948 | win = 2;
|
---|
949 | oldpad->cd(1);
|
---|
950 | TVirtualPad *newpad = gPad;
|
---|
951 | pad = newpad;
|
---|
952 | pad->Divide(2,2);
|
---|
953 | pad->cd(1);
|
---|
954 | }
|
---|
955 | else
|
---|
956 | {
|
---|
957 | pad = oldpad;
|
---|
958 | pad->Divide(2,2);
|
---|
959 | pad->cd(1);
|
---|
960 | }
|
---|
961 |
|
---|
962 | if (!IsEmpty())
|
---|
963 | gPad->SetLogy();
|
---|
964 |
|
---|
965 | gPad->SetTicks();
|
---|
966 |
|
---|
967 | fHGausHist.Draw(opt);
|
---|
968 | if (fFGausFit)
|
---|
969 | {
|
---|
970 | fFGausFit->SetLineColor(kBlue);
|
---|
971 | fFGausFit->Draw("same");
|
---|
972 | }
|
---|
973 | if (fSinglePheFit)
|
---|
974 | {
|
---|
975 | fSinglePheFit->SetLineColor(IsSinglePheFitOK() ? kGreen : kRed);
|
---|
976 | fSinglePheFit->Draw("same");
|
---|
977 | }
|
---|
978 |
|
---|
979 | pad->cd(2);
|
---|
980 | DrawLegend();
|
---|
981 |
|
---|
982 | pad->cd(3);
|
---|
983 | if (fHSinglePheFADCSlices)
|
---|
984 | delete fHSinglePheFADCSlices;
|
---|
985 |
|
---|
986 | fHSinglePheFADCSlices = new TH1F(fASinglePheFADCSlices);
|
---|
987 | fHSinglePheFADCSlices->SetName("SinglePheFADCSlices");
|
---|
988 | fHSinglePheFADCSlices->SetTitle(Form("%s%f","Assumed Single Phe FADC Slices, Sum > ",fSinglePheCut));
|
---|
989 | fHSinglePheFADCSlices->SetXTitle("FADC slice number");
|
---|
990 | fHSinglePheFADCSlices->SetYTitle("FADC counts");
|
---|
991 | fHSinglePheFADCSlices->Draw(opt);
|
---|
992 |
|
---|
993 | pad->cd(4);
|
---|
994 | if (fHPedestalFADCSlices)
|
---|
995 | delete fHPedestalFADCSlices;
|
---|
996 |
|
---|
997 | fHPedestalFADCSlices = new TH1F(fAPedestalFADCSlices);
|
---|
998 | fHPedestalFADCSlices->SetName("PedestalFADCSlices");
|
---|
999 | fHPedestalFADCSlices->SetTitle(Form("%s%f","Pedestal FADC Slices, Sum < ",fSinglePheCut));
|
---|
1000 | fHPedestalFADCSlices->SetXTitle("FADC slice number");
|
---|
1001 | fHPedestalFADCSlices->SetYTitle("FADC counts");
|
---|
1002 | fHPedestalFADCSlices->Draw(opt);
|
---|
1003 |
|
---|
1004 | if (win < 2)
|
---|
1005 | return;
|
---|
1006 |
|
---|
1007 | oldpad->cd(2);
|
---|
1008 | MHGausEvents::Draw("fourierevents");
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 |
|
---|
1012 |
|
---|
1013 |
|
---|
1014 |
|
---|
1015 |
|
---|
1016 |
|
---|
1017 |
|
---|
1018 |
|
---|
1019 |
|
---|
1020 |
|
---|