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 | // MHCalibrationChargePINDiode
|
---|
28 | //
|
---|
29 | // Performs all the necessary fits to extract the mean number of photons
|
---|
30 | // out of the derived light flux
|
---|
31 | //
|
---|
32 | //////////////////////////////////////////////////////////////////////////////
|
---|
33 | #include "MHCalibrationChargePINDiode.h"
|
---|
34 |
|
---|
35 | #include <TH1.h>
|
---|
36 | #include <TF1.h>
|
---|
37 | #include <TPad.h>
|
---|
38 | #include <TVirtualPad.h>
|
---|
39 | #include <TCanvas.h>
|
---|
40 |
|
---|
41 | #include "MLog.h"
|
---|
42 | #include "MLogManip.h"
|
---|
43 |
|
---|
44 | #include "MParList.h"
|
---|
45 |
|
---|
46 | #include "MExtractedSignalPINDiode.h"
|
---|
47 | #include "MCalibrationChargePINDiode.h"
|
---|
48 |
|
---|
49 | ClassImp(MHCalibrationChargePINDiode);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | const Int_t MHCalibrationChargePINDiode::fgChargeNbins = 200;
|
---|
54 | const Axis_t MHCalibrationChargePINDiode::fgChargeFirst = -0.5;
|
---|
55 | const Axis_t MHCalibrationChargePINDiode::fgChargeLast = 199.5;
|
---|
56 | const Int_t MHCalibrationChargePINDiode::fgRmsChargeNbins = 100;
|
---|
57 | const Axis_t MHCalibrationChargePINDiode::fgRmsChargeFirst = 0.;
|
---|
58 | const Axis_t MHCalibrationChargePINDiode::fgRmsChargeLast = 100.;
|
---|
59 | const Int_t MHCalibrationChargePINDiode::fgAbsTimeNbins = 30;
|
---|
60 | const Axis_t MHCalibrationChargePINDiode::fgAbsTimeFirst = -0.5;
|
---|
61 | const Axis_t MHCalibrationChargePINDiode::fgAbsTimeLast = 29.5;
|
---|
62 | // --------------------------------------------------------------------------
|
---|
63 | //
|
---|
64 | // Default Constructor.
|
---|
65 | //
|
---|
66 | // Sets:
|
---|
67 | // - the default number for fChargeNbins (fgChargeNbins)
|
---|
68 | // - the default number for fChargeFirst (fgChargeFirst)
|
---|
69 | // - the default number for fChargeLast (fgChargeLast)
|
---|
70 | // - the default number for fRmsChargeNbins (fgRmsChargeNbins)
|
---|
71 | // - the default number for fRmsChargeFirst (fgRmsChargeFirst)
|
---|
72 | // - the default number for fRmsChargeLast (fgRmsChargeLast)
|
---|
73 | // - the default number for fAbsTimeNbins (fgAbsTimeNbins)
|
---|
74 | // - the default number for fAbsTimeFirst (fgAbsTimeFirst)
|
---|
75 | // - the default number for fAbsTimeLast (fgAbsTimeLast)
|
---|
76 | //
|
---|
77 | // - the default name of the fHGausHist ("HCalibrationChargePINDiode")
|
---|
78 | // - the default title of the fHGausHist ("Distribution of Summed FADC slices PIN Diode")
|
---|
79 | // - the default x-axis title for fHGausHist ("Sum FADC Slices")
|
---|
80 | // - the default y-axis title for fHGausHist ("Nr. of events")
|
---|
81 | // - the default name of the fHAbsTime ("HAbsTimePINDiode")
|
---|
82 | // - the default title of the fHAbsTime ("Distribution of Absolute Arrival Times PIN Diode")
|
---|
83 | // - the default x-axis title for fHAbsTime ("Absolute Arrival Time [FADC slice nr]")
|
---|
84 | // - the default y-axis title for fHAbsTime ("Nr. of events")
|
---|
85 | // - the default name of the fHRmsCharge ("HRmsChargePINDiode")
|
---|
86 | // - the default title of the fHRmsCharge ("Distribution of Variances of summed FADC slices PIN Diode")
|
---|
87 | // - the default x-axis title for fHRmsCharge ("RMS (sum) [FADC slices]")
|
---|
88 | // - the default y-axis title for fHRmsCharge ("Nr. of events")
|
---|
89 | // - the default directory of the fHRmsCharge (NULL)
|
---|
90 | //
|
---|
91 | // Initializes:
|
---|
92 | // - fHRmsCharge()
|
---|
93 | // - all pointers to NULL
|
---|
94 | // - all variables to 0.
|
---|
95 | // - all flags to kFALSE
|
---|
96 | //
|
---|
97 | MHCalibrationChargePINDiode::MHCalibrationChargePINDiode(const char *name, const char *title)
|
---|
98 | : fPINDiode(NULL), fHRmsCharge()
|
---|
99 | {
|
---|
100 |
|
---|
101 | fName = name ? name : "MHCalibrationChargePINDiode";
|
---|
102 | fTitle = title ? title : "Fill the FADC sums of the PINDiode events and perform the fits";
|
---|
103 |
|
---|
104 | SetChargeNbins();
|
---|
105 | SetChargeFirst();
|
---|
106 | SetChargeLast();
|
---|
107 |
|
---|
108 | SetRmsChargeNbins();
|
---|
109 | SetRmsChargeFirst();
|
---|
110 | SetRmsChargeLast();
|
---|
111 |
|
---|
112 | SetAbsTimeNbins();
|
---|
113 | SetAbsTimeFirst();
|
---|
114 | SetAbsTimeLast();
|
---|
115 |
|
---|
116 | fHGausHist.SetName("HCalibrationChargePINDiode");
|
---|
117 | fHGausHist.SetTitle("Distribution of Summed FADC slices PIN Diode");
|
---|
118 | fHGausHist.SetXTitle("Sum FADC Slices");
|
---|
119 | fHGausHist.SetYTitle("Nr. of events");
|
---|
120 |
|
---|
121 | fHAbsTime.SetName("HAbsTimePINDiode");
|
---|
122 | fHAbsTime.SetTitle("Distribution of Absolute Arrival Times PIN Diode");
|
---|
123 | fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
|
---|
124 | fHAbsTime.SetYTitle("Nr. of events");
|
---|
125 |
|
---|
126 | fHRmsCharge.SetName("HRmsChargePINDiode");
|
---|
127 | fHRmsCharge.SetTitle("Distribution of Variances of summed FADC slices PIN Diode");
|
---|
128 | fHRmsCharge.SetXTitle("RMS (sum) [FADC slices]");
|
---|
129 | fHRmsCharge.SetYTitle("Nr. of events");
|
---|
130 | fHRmsCharge.UseCurrentStyle();
|
---|
131 | fHRmsCharge.SetDirectory(NULL);
|
---|
132 |
|
---|
133 | Clear();
|
---|
134 | }
|
---|
135 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // Initializes Binning of the following histograms:
|
---|
139 | // - fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
|
---|
140 | // - fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
|
---|
141 | // - fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
|
---|
142 | //
|
---|
143 | Bool_t MHCalibrationChargePINDiode::SetupFill(const MParList *pList)
|
---|
144 | {
|
---|
145 |
|
---|
146 | fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
|
---|
147 | fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
|
---|
148 | fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
|
---|
149 |
|
---|
150 | return kTRUE;
|
---|
151 |
|
---|
152 | }
|
---|
153 |
|
---|
154 | // --------------------------------------------------------------------------
|
---|
155 | //
|
---|
156 | // Gets or creates the pointers to:
|
---|
157 | // - MCalibrationChargePINDiode
|
---|
158 | //
|
---|
159 | Bool_t MHCalibrationChargePINDiode::ReInit(MParList *pList)
|
---|
160 | {
|
---|
161 |
|
---|
162 | fPINDiode = (MCalibrationChargePINDiode*)pList->FindCreateObj("MCalibrationChargePINDiode");
|
---|
163 | if (!fPINDiode)
|
---|
164 | {
|
---|
165 | *fLog << err << "MCalibrationChargePINDiode not found... aborting " << endl;
|
---|
166 | return kFALSE;
|
---|
167 | }
|
---|
168 |
|
---|
169 | return kTRUE;
|
---|
170 | }
|
---|
171 |
|
---|
172 | // --------------------------------------------------------------------------
|
---|
173 | //
|
---|
174 | // Retrieves from MExtractedSignalPINDiode:
|
---|
175 | // - Number of used FADC samples
|
---|
176 | // - Extracted signal
|
---|
177 | // - Signal Rms
|
---|
178 | // - Arrival Time
|
---|
179 | //
|
---|
180 | // Fills the following histograms:
|
---|
181 | // - MHGausEvents::FillHistAndArray(signal)
|
---|
182 | // - FillAbsTime(time);
|
---|
183 | // - FillRmsCharge(rms);
|
---|
184 | //
|
---|
185 | Bool_t MHCalibrationChargePINDiode::Fill(const MParContainer *par, const Stat_t w)
|
---|
186 | {
|
---|
187 |
|
---|
188 | MExtractedSignalPINDiode *extractor = (MExtractedSignalPINDiode*)par;
|
---|
189 |
|
---|
190 | if (!extractor)
|
---|
191 | {
|
---|
192 | *fLog << err << "No argument in MExtractedSignalPINDiode::Fill... abort." << endl;
|
---|
193 | return kFALSE;
|
---|
194 | }
|
---|
195 |
|
---|
196 | Float_t slices = (Float_t)extractor->GetNumFADCSamples();
|
---|
197 |
|
---|
198 | if (slices == 0.)
|
---|
199 | {
|
---|
200 | *fLog << err << "Number of used signal slices in MExtractedSignalPINDiode is zero ... abort."
|
---|
201 | << endl;
|
---|
202 | return kFALSE;
|
---|
203 | }
|
---|
204 |
|
---|
205 | const Float_t signal = (float)extractor->GetExtractedSignal();
|
---|
206 | const Float_t time = extractor->GetExtractedTime();
|
---|
207 | const Float_t rms = extractor->GetExtractedRms();
|
---|
208 |
|
---|
209 | FillHistAndArray(signal);
|
---|
210 | FillAbsTime(time);
|
---|
211 | FillRmsCharge(rms);
|
---|
212 |
|
---|
213 | return kTRUE;
|
---|
214 | }
|
---|
215 |
|
---|
216 | // --------------------------------------------------------------------------
|
---|
217 | //
|
---|
218 | // Returns kFALSE, if empty
|
---|
219 | //
|
---|
220 | // Performs the following fits:
|
---|
221 | // - MHGausEvents::FitGaus()
|
---|
222 | // - FitRmsCharge()
|
---|
223 | //
|
---|
224 | // Creates the fourier spectrum and sets bit IsFourierSpectrumOK()
|
---|
225 | // Retrieves the results of the following fits and stores them in MCalibrationChargePINDiode:
|
---|
226 | // - Mean Charge and Error
|
---|
227 | // - Sigma Charge and Error
|
---|
228 | // - Abs Time Mean
|
---|
229 | // - Abs Time Rms
|
---|
230 | // - Rms Charge Mean and Error
|
---|
231 | // - Rms Charge Sigma and Error
|
---|
232 | //
|
---|
233 | Bool_t MHCalibrationChargePINDiode::Finalize()
|
---|
234 | {
|
---|
235 |
|
---|
236 | if (IsGausFitOK() || IsEmpty())
|
---|
237 | return kTRUE;
|
---|
238 |
|
---|
239 | FitGaus();
|
---|
240 | FitRmsCharge();
|
---|
241 |
|
---|
242 | CreateFourierSpectrum();
|
---|
243 | fPINDiode->SetOscillating ( !IsFourierSpectrumOK() );
|
---|
244 |
|
---|
245 | fPINDiode->SetMeanCharge( GetMean() );
|
---|
246 | fPINDiode->SetMeanChargeErr( GetMeanErr() );
|
---|
247 | fPINDiode->SetSigmaCharge( GetSigma() );
|
---|
248 | fPINDiode->SetSigmaChargeErr( GetSigmaErr() );
|
---|
249 |
|
---|
250 | fPINDiode->SetAbsTimeMean( GetAbsTimeMean() );
|
---|
251 | fPINDiode->SetAbsTimeRms( GetAbsTimeRms() );
|
---|
252 |
|
---|
253 | fPINDiode->SetRmsChargeMean( GetRmsChargeMean() );
|
---|
254 | fPINDiode->SetRmsChargeMeanErr( GetRmsChargeMeanErr() );
|
---|
255 | fPINDiode->SetRmsChargeSigma( GetRmsChargeSigma() );
|
---|
256 | fPINDiode->SetRmsChargeSigmaErr( GetRmsChargeSigmaErr() );
|
---|
257 |
|
---|
258 | return kTRUE;
|
---|
259 | }
|
---|
260 |
|
---|
261 | // --------------------------------------------------------------------------
|
---|
262 | //
|
---|
263 | // Fills fHRmsCharge with q
|
---|
264 | // Returns kFALSE, if overflow or underflow occurred, else kTRUE
|
---|
265 | //
|
---|
266 | Bool_t MHCalibrationChargePINDiode::FillRmsCharge(const Float_t q)
|
---|
267 | {
|
---|
268 | return fHRmsCharge.Fill(q) > -1;
|
---|
269 | }
|
---|
270 |
|
---|
271 | // -----------------------------------------------------------
|
---|
272 | //
|
---|
273 | // Fits -- not yet implemented
|
---|
274 | //
|
---|
275 | Bool_t MHCalibrationChargePINDiode::FitRmsCharge(Option_t *option)
|
---|
276 | {
|
---|
277 | return 1;
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 | // -------------------------------------------------------------------------
|
---|
282 | //
|
---|
283 | // Draw the histogram
|
---|
284 | //
|
---|
285 | // The following options can be chosen:
|
---|
286 | //
|
---|
287 | // "": displays the fHGausHist with fits and fHRmsCharge
|
---|
288 | // "all": executes additionally MHGausEvents::Draw(), with option "fourierevents"
|
---|
289 | //
|
---|
290 | void MHCalibrationChargePINDiode::Draw(const Option_t *opt)
|
---|
291 | {
|
---|
292 |
|
---|
293 | TString option(opt);
|
---|
294 | option.ToLower();
|
---|
295 |
|
---|
296 | Int_t win = 1;
|
---|
297 |
|
---|
298 | TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,900, 600);
|
---|
299 | TVirtualPad *pad = NULL;
|
---|
300 |
|
---|
301 | oldpad->SetBorderMode(0);
|
---|
302 |
|
---|
303 | if (option.Contains("all"))
|
---|
304 | {
|
---|
305 | option.ReplaceAll("all","");
|
---|
306 | oldpad->Divide(2,1);
|
---|
307 | win = 2;
|
---|
308 | oldpad->cd(1);
|
---|
309 | TVirtualPad *newpad = gPad;
|
---|
310 | pad = newpad;
|
---|
311 | pad->Divide(1,2);
|
---|
312 | pad->cd(1);
|
---|
313 | }
|
---|
314 | else
|
---|
315 | {
|
---|
316 | pad = oldpad;
|
---|
317 | pad->Divide(1,2);
|
---|
318 | pad->cd(1);
|
---|
319 | }
|
---|
320 |
|
---|
321 | if (!IsEmpty())
|
---|
322 | gPad->SetLogy();
|
---|
323 |
|
---|
324 | gPad->SetTicks();
|
---|
325 |
|
---|
326 | fHGausHist.Draw(opt);
|
---|
327 | if (fFGausFit)
|
---|
328 | {
|
---|
329 | fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
|
---|
330 | fFGausFit->Draw("same");
|
---|
331 | }
|
---|
332 |
|
---|
333 | pad->cd(2);
|
---|
334 | fHRmsCharge.Draw(opt);
|
---|
335 |
|
---|
336 | oldpad->cd(2);
|
---|
337 | MHGausEvents::Draw("fourierevents");
|
---|
338 | }
|
---|
339 |
|
---|
340 |
|
---|
341 |
|
---|
342 |
|
---|