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 | // MHCalibrationChargePix
|
---|
27 | //
|
---|
28 | // Histogram class for the charge calibration.
|
---|
29 | // Stores and fits the charges and stores the location of the maximum FADC
|
---|
30 | // slice. Charges are taken from MExtractedSignalPix.
|
---|
31 | //
|
---|
32 | //////////////////////////////////////////////////////////////////////////////
|
---|
33 | #include "MHCalibrationChargePix.h"
|
---|
34 |
|
---|
35 | #include <TH1.h>
|
---|
36 | #include <TF1.h>
|
---|
37 |
|
---|
38 | #include <TVirtualPad.h>
|
---|
39 | #include <TCanvas.h>
|
---|
40 | #include <TPad.h>
|
---|
41 | #include <TGraph.h>
|
---|
42 |
|
---|
43 | #include "MH.h"
|
---|
44 |
|
---|
45 | #include "MLog.h"
|
---|
46 | #include "MLogManip.h"
|
---|
47 |
|
---|
48 | ClassImp(MHCalibrationChargePix);
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | const Int_t MHCalibrationChargePix::fgChargeNbins = 2000;
|
---|
53 | const Axis_t MHCalibrationChargePix::fgChargeFirst = -0.5;
|
---|
54 | const Axis_t MHCalibrationChargePix::fgChargeLast = 1999.5;
|
---|
55 | const Int_t MHCalibrationChargePix::fgAbsTimeNbins = 15;
|
---|
56 | const Axis_t MHCalibrationChargePix::fgAbsTimeFirst = -0.5;
|
---|
57 | const Axis_t MHCalibrationChargePix::fgAbsTimeLast = 14.5;
|
---|
58 | // --------------------------------------------------------------------------
|
---|
59 | //
|
---|
60 | // Default Constructor.
|
---|
61 | //
|
---|
62 | // Sets:
|
---|
63 | // - the default number for fNbins (fgChargeNbins)
|
---|
64 | // - the default number for fFirst (fgChargeFirst)
|
---|
65 | // - the default number for fLast (fgChargeLast)
|
---|
66 | // - the default number for fAbsTimeNbins (fgAbsTimeNbins)
|
---|
67 | // - the default number for fAbsTimeFirst (fgAbsTimeFirst)
|
---|
68 | // - the default number for fAbsTimeLast (fgAbsTimeLast)
|
---|
69 | //
|
---|
70 | // - the default name of the fHGausHist ("HCalibrationCharge")
|
---|
71 | // - the default title of the fHGausHist ("Distribution of Summed FADC slices Pixel ")
|
---|
72 | // - the default x-axis title for fHGausHist ("Sum FADC Slices")
|
---|
73 | // - the default y-axis title for fHGausHist ("Nr. of events")
|
---|
74 | //
|
---|
75 | // - the default name of the fHAbsTime ("HAbsTimePixel")
|
---|
76 | // - the default title of the fHAbsTime ("Distribution of Absolute Arrival Times Pixel ")
|
---|
77 | // - the default x-axis title for fHAbsTime ("Absolute Arrival Time [FADC slice nr]")
|
---|
78 | // - the default y-axis title for fHAbsTime ("Nr. of events");
|
---|
79 | // - the default directory of the fHAbsTime (NULL)
|
---|
80 | // - the current style for fHAbsTime
|
---|
81 | //
|
---|
82 | // Initializes:
|
---|
83 | // - fHAbsTime()
|
---|
84 | //
|
---|
85 | // Calls:
|
---|
86 | // - Clear();
|
---|
87 | //
|
---|
88 | MHCalibrationChargePix::MHCalibrationChargePix(const char *name, const char *title)
|
---|
89 | : fHAbsTime()
|
---|
90 | {
|
---|
91 |
|
---|
92 | fName = name ? name : "MHCalibrationChargePix";
|
---|
93 | fTitle = title ? title : "Statistics of the FADC sums of calibration events";
|
---|
94 |
|
---|
95 | SetNbins ( fgChargeNbins );
|
---|
96 | SetFirst ( fgChargeFirst );
|
---|
97 | SetLast ( fgChargeLast );
|
---|
98 |
|
---|
99 | SetAbsTimeNbins();
|
---|
100 | SetAbsTimeFirst();
|
---|
101 | SetAbsTimeLast();
|
---|
102 |
|
---|
103 | fHGausHist.SetName("HCalibrationCharge");
|
---|
104 | fHGausHist.SetTitle("Distribution of Summed FADC slices Pixel");
|
---|
105 | fHGausHist.SetXTitle("Sum FADC Slices");
|
---|
106 | fHGausHist.SetYTitle("Nr. of events");
|
---|
107 |
|
---|
108 | fHAbsTime.SetName("HAbsTimePixel");
|
---|
109 | fHAbsTime.SetTitle("Distribution of Absolute Arrival Times Pixel ");
|
---|
110 | fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
|
---|
111 | fHAbsTime.SetYTitle("Nr. of events");
|
---|
112 |
|
---|
113 | fHAbsTime.UseCurrentStyle();
|
---|
114 | fHAbsTime.SetDirectory(NULL);
|
---|
115 |
|
---|
116 | Clear();
|
---|
117 |
|
---|
118 | }
|
---|
119 |
|
---|
120 | // --------------------------------------------------------------------------
|
---|
121 | //
|
---|
122 | // Sets:
|
---|
123 | // - fHGausHist.SetBins(fNbins,fFirst,fLast);
|
---|
124 | // - fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
|
---|
125 | //
|
---|
126 | void MHCalibrationChargePix::InitBins()
|
---|
127 | {
|
---|
128 | MHGausEvents::InitBins();
|
---|
129 | fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
|
---|
130 | }
|
---|
131 |
|
---|
132 | // --------------------------------------------------------------------------
|
---|
133 | //
|
---|
134 | // Sets:
|
---|
135 | // - fSaturated to 0.
|
---|
136 | //
|
---|
137 | // Executes:
|
---|
138 | // - MHGausEvents::Clear()
|
---|
139 | //
|
---|
140 | void MHCalibrationChargePix::Clear(Option_t *o)
|
---|
141 | {
|
---|
142 |
|
---|
143 | fSaturated = 0.;
|
---|
144 |
|
---|
145 | MHGausEvents::Clear();
|
---|
146 | return;
|
---|
147 | }
|
---|
148 |
|
---|
149 | // --------------------------------------------------------------------------
|
---|
150 | //
|
---|
151 | // Empty function to overload MHGausEvents::Reset()
|
---|
152 | //
|
---|
153 | void MHCalibrationChargePix::Reset()
|
---|
154 | {
|
---|
155 | }
|
---|
156 |
|
---|
157 | // --------------------------------------------------------------------------
|
---|
158 | //
|
---|
159 | // Calls MHGausEvents::ChangeHistId()
|
---|
160 | //
|
---|
161 | // Add id to names and titles of:
|
---|
162 | // - fHAbsTime
|
---|
163 | //
|
---|
164 | void MHCalibrationChargePix::ChangeHistId(Int_t id)
|
---|
165 | {
|
---|
166 |
|
---|
167 | MHGausEvents::ChangeHistId(id);
|
---|
168 |
|
---|
169 | fHAbsTime.SetName (Form("%s%d", fHAbsTime.GetName(), id));
|
---|
170 | fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
|
---|
171 |
|
---|
172 | }
|
---|
173 |
|
---|
174 | // --------------------------------------------------------------------------
|
---|
175 | //
|
---|
176 | // returns fHGausHist.Integral("width")
|
---|
177 | //
|
---|
178 | const Float_t MHCalibrationChargePix::GetIntegral() const
|
---|
179 | {
|
---|
180 | return fHGausHist.Integral("width");
|
---|
181 | }
|
---|
182 |
|
---|
183 | // --------------------------------------------------------------------------
|
---|
184 | //
|
---|
185 | // returns fHAbsTime.GetMean()
|
---|
186 | //
|
---|
187 | const Float_t MHCalibrationChargePix::GetAbsTimeMean() const
|
---|
188 | {
|
---|
189 | return fHAbsTime.GetMean();
|
---|
190 | }
|
---|
191 |
|
---|
192 | // --------------------------------------------------------------------------
|
---|
193 | //
|
---|
194 | // returns fHAbsTime.GetRMS()
|
---|
195 | //
|
---|
196 | const Float_t MHCalibrationChargePix::GetAbsTimeRms() const
|
---|
197 | {
|
---|
198 | return fHAbsTime.GetRMS();
|
---|
199 | }
|
---|
200 |
|
---|
201 | // --------------------------------------------------------------------------
|
---|
202 | //
|
---|
203 | // Fills fHAbsTime with t
|
---|
204 | // Returns kFALSE, if overflow or underflow occurred, else kTRUE
|
---|
205 | //
|
---|
206 | Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
|
---|
207 | {
|
---|
208 | return fHAbsTime.Fill(t) > -1;
|
---|
209 | }
|
---|
210 |
|
---|
211 | // -----------------------------------------------------------------------------
|
---|
212 | //
|
---|
213 | // Default draw:
|
---|
214 | //
|
---|
215 | // The following options can be chosen:
|
---|
216 | //
|
---|
217 | // "": displays the fHGausHist and the fHAbsTime
|
---|
218 | // "all": executes additionally MHGausEvents::Draw(), with options
|
---|
219 | //
|
---|
220 | void MHCalibrationChargePix::Draw(const Option_t *opt)
|
---|
221 | {
|
---|
222 |
|
---|
223 | TString option(opt);
|
---|
224 | option.ToLower();
|
---|
225 |
|
---|
226 | Int_t win = 1;
|
---|
227 |
|
---|
228 | TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
|
---|
229 | TVirtualPad *pad = NULL;
|
---|
230 |
|
---|
231 | if (option.Contains("all"))
|
---|
232 | {
|
---|
233 | option.ReplaceAll("all","");
|
---|
234 | oldpad->Divide(2,1);
|
---|
235 | win = 2;
|
---|
236 | oldpad->cd(1);
|
---|
237 | TVirtualPad *newpad = gPad;
|
---|
238 | pad = newpad;
|
---|
239 | pad->Divide(1,2);
|
---|
240 | pad->cd(1);
|
---|
241 | }
|
---|
242 | else
|
---|
243 | {
|
---|
244 | pad = oldpad;
|
---|
245 | pad->Divide(1,2);
|
---|
246 | pad->cd(1);
|
---|
247 | }
|
---|
248 |
|
---|
249 | if (!IsEmpty())
|
---|
250 | gPad->SetLogy();
|
---|
251 |
|
---|
252 | gPad->SetTicks();
|
---|
253 |
|
---|
254 | fHGausHist.GetXaxis()->SetLabelSize(0.06);
|
---|
255 | fHGausHist.GetYaxis()->SetLabelSize(0.07);
|
---|
256 | fHGausHist.GetXaxis()->SetLabelOffset(0.01);
|
---|
257 | fHGausHist.GetYaxis()->SetLabelOffset(0.01);
|
---|
258 | fHGausHist.GetXaxis()->SetTitleSize(0.065);
|
---|
259 | fHGausHist.GetYaxis()->SetTitleSize(0.07);
|
---|
260 | fHGausHist.GetXaxis()->SetTitleOffset(0.6);
|
---|
261 | fHGausHist.GetYaxis()->SetTitleOffset(0.6);
|
---|
262 | fHGausHist.Draw(opt);
|
---|
263 | if (fFGausFit)
|
---|
264 | {
|
---|
265 | fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
|
---|
266 | fFGausFit->Draw("same");
|
---|
267 | }
|
---|
268 |
|
---|
269 | pad->cd(2);
|
---|
270 | gPad->SetTicks();
|
---|
271 |
|
---|
272 | fHAbsTime.GetXaxis()->SetLabelSize(0.06);
|
---|
273 | fHAbsTime.GetYaxis()->SetLabelSize(0.07);
|
---|
274 | fHAbsTime.GetXaxis()->SetLabelOffset(0.01);
|
---|
275 | fHAbsTime.GetYaxis()->SetLabelOffset(0.01);
|
---|
276 | fHAbsTime.GetXaxis()->SetTitleSize(0.065);
|
---|
277 | fHAbsTime.GetYaxis()->SetTitleSize(0.07);
|
---|
278 | fHAbsTime.GetXaxis()->SetTitleOffset(0.6);
|
---|
279 | fHAbsTime.GetYaxis()->SetTitleOffset(0.6);
|
---|
280 | fHAbsTime.Draw(opt);
|
---|
281 |
|
---|
282 | if (win < 2)
|
---|
283 | return;
|
---|
284 |
|
---|
285 | oldpad->cd(2);
|
---|
286 | MHGausEvents::Draw("fourierevents");
|
---|
287 |
|
---|
288 | }
|
---|