source: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePix.cc@ 4932

Last change on this file since 4932 was 4929, checked in by gaug, 20 years ago
*** empty log message ***
File size: 8.9 KB
Line 
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
48ClassImp(MHCalibrationChargePix);
49
50using namespace std;
51
52const Int_t MHCalibrationChargePix::fgChargeNbins = 2000;
53const Axis_t MHCalibrationChargePix::fgChargeFirst = -0.5;
54const Axis_t MHCalibrationChargePix::fgChargeLast = 1999.5;
55const Int_t MHCalibrationChargePix::fgAbsTimeNbins = 15;
56const Axis_t MHCalibrationChargePix::fgAbsTimeFirst = -0.5;
57const 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//
88MHCalibrationChargePix::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//
126void MHCalibrationChargePix::InitBins()
127{
128 MHGausEvents::InitBins();
129 fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
130}
131
132// --------------------------------------------------------------------------
133//
134// Empty function to overload MHGausEvents::Reset()
135//
136void MHCalibrationChargePix::Reset()
137{
138 MHGausEvents::Reset();
139 fHAbsTime.Reset();
140}
141
142// --------------------------------------------------------------------------
143//
144// Calls MHCalibrationPix::ChangeHistId()
145//
146// Add id to names and titles of:
147// - fHAbsTime
148//
149void MHCalibrationChargePix::ChangeHistId(Int_t id)
150{
151
152 MHCalibrationPix::ChangeHistId(id);
153
154 fHAbsTime.SetName (Form("%s%d", fHAbsTime.GetName(), id));
155 fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
156
157}
158
159// --------------------------------------------------------------------------
160//
161// returns fHGausHist.Integral("width")
162//
163const Float_t MHCalibrationChargePix::GetIntegral() const
164{
165 return fHGausHist.Integral("width");
166}
167
168// --------------------------------------------------------------------------
169//
170// returns fHAbsTime.GetMean()
171//
172const Float_t MHCalibrationChargePix::GetAbsTimeMean() const
173{
174 return fHAbsTime.GetMean();
175}
176
177// --------------------------------------------------------------------------
178//
179// returns fHAbsTime.GetRMS()
180//
181const Float_t MHCalibrationChargePix::GetAbsTimeRms() const
182{
183 return fHAbsTime.GetRMS();
184}
185
186// --------------------------------------------------------------------------
187//
188// Fills fHAbsTime with t
189// Returns kFALSE, if overflow or underflow occurred, else kTRUE
190//
191Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
192{
193 return fHAbsTime.Fill(t) > -1;
194}
195
196// -----------------------------------------------------------------------------
197//
198// Default draw:
199//
200// The following options can be chosen:
201//
202// "": displays the fHGausHist and the fHAbsTime
203// "all": executes additionally MHCalibrationPix::Draw(), with options
204//
205// The following picture shows a typical outcome of call to Draw("all"):
206// One the left side:
207// - The distribution of the values with the Gauss fit are shown (points connected
208// with each other). The line is green, thus the Gauss fit has a probability higher
209// than 0.5%.
210// - The distribution of the positions of the maximum (abs. arrival times)
211// is displayed. Most of the events have an arrival time of slice 7 (==hardware:8)
212//
213// On the right side:
214// - The first plot shows the distribution of the values with the Gauss fit
215// with error bars
216// - The second plot shows the TGraph with the events vs. time
217// - The third plot shows the fourier transform and a peak at 100 Hz.
218// - The fourth plot shows the projection of the fourier components and an exponential
219// fit, with the result that the observed deviation is not statistical, but signficant with a
220// probability smaller than 0.5%.
221//
222//Begin_Html
223/*
224<img src="images/MHCalibrationChargePixDraw.gif">
225*/
226//End_Html
227//
228void MHCalibrationChargePix::Draw(const Option_t *opt)
229{
230
231 TString option(opt);
232 option.ToLower();
233
234 Int_t win = 1;
235
236 TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
237 TVirtualPad *pad = NULL;
238
239 if (option.Contains("all"))
240 {
241 option.ReplaceAll("all","");
242 oldpad->Divide(2,1);
243 win = 2;
244 oldpad->cd(1);
245 TVirtualPad *newpad = gPad;
246 pad = newpad;
247 pad->Divide(1,2);
248 pad->cd(1);
249 }
250 else if (option.Contains("datacheck"))
251 {
252 MHCalibrationPix::Draw("events");
253 return;
254 }
255 else
256 {
257 pad = oldpad;
258 pad->Divide(1,2);
259 pad->cd(1);
260 }
261 /*
262 else
263 {
264 option.ReplaceAll("time","");
265 pad = oldpad;
266 pad->Divide(1,2);
267 pad->cd(1);
268 }
269 */
270 if (!IsEmpty() && !IsOnlyOverflow() && !IsOnlyUnderflow())
271 gPad->SetLogy();
272
273 gPad->SetTicks();
274
275 fHGausHist.GetXaxis()->SetLabelSize(0.06);
276 fHGausHist.GetYaxis()->SetLabelSize(0.07);
277 fHGausHist.GetXaxis()->SetLabelOffset(0.01);
278 fHGausHist.GetYaxis()->SetLabelOffset(0.01);
279 fHGausHist.GetXaxis()->SetTitleSize(0.065);
280 fHGausHist.GetYaxis()->SetTitleSize(0.07);
281 fHGausHist.GetXaxis()->SetTitleOffset(0.6);
282 fHGausHist.GetYaxis()->SetTitleOffset(0.6);
283 fHGausHist.Draw();
284 if (fFGausFit)
285 {
286 fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
287 fFGausFit->Draw("same");
288 }
289
290 pad->cd(2);
291 gPad->SetTicks();
292
293 fHAbsTime.GetXaxis()->SetLabelSize(0.06);
294 fHAbsTime.GetYaxis()->SetLabelSize(0.07);
295 fHAbsTime.GetXaxis()->SetLabelOffset(0.01);
296 fHAbsTime.GetYaxis()->SetLabelOffset(0.01);
297 fHAbsTime.GetXaxis()->SetTitleSize(0.065);
298 fHAbsTime.GetYaxis()->SetTitleSize(0.07);
299 fHAbsTime.GetXaxis()->SetTitleOffset(0.6);
300 fHAbsTime.GetYaxis()->SetTitleOffset(0.6);
301 fHAbsTime.Draw();
302
303 if (win < 2)
304 return;
305
306 oldpad->cd(2);
307 MHCalibrationPix::Draw("fourierevents");
308
309}
Note: See TracBrowser for help on using the repository browser.