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

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