source: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc@ 3636

Last change on this file since 3636 was 3636, checked in by gaug, 20 years ago
*** empty log message ***
File size: 7.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 charge calibration analysis. Holds the histogrammed
29// summed FADC slices and some rough absolute timing. Calculates the mean
30// sum of FADC slices and its sigma and perform a Fourier analysis.
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 (fgAbstTimeNbins)
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//
81// Initializes:
82// - fHAbsTime()
83// - fPixId to -1
84// - all variables to 0.
85// - all flags to kFALSE
86//
87MHCalibrationChargePix::MHCalibrationChargePix(const char *name, const char *title)
88 : fHAbsTime()
89{
90
91 fName = name ? name : "MHCalibrationChargePix";
92 fTitle = title ? title : "Statistics of the FADC sums of calibration events";
93
94 SetNbins ( fgChargeNbins );
95 SetFirst ( fgChargeFirst );
96 SetLast ( fgChargeLast );
97
98 SetAbsTimeNbins();
99 SetAbsTimeFirst();
100 SetAbsTimeLast();
101
102 fHGausHist.SetName("HCalibrationCharge");
103 fHGausHist.SetTitle("Distribution of Summed FADC slices Pixel");
104 fHGausHist.SetXTitle("Sum FADC Slices");
105 fHGausHist.SetYTitle("Nr. of events");
106
107 fHAbsTime.SetName("HAbsTimePixel");
108 fHAbsTime.SetTitle("Distribution of Absolute Arrival Times Pixel ");
109 fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
110 fHAbsTime.SetYTitle("Nr. of events");
111
112 fHAbsTime.UseCurrentStyle();
113 fHAbsTime.SetDirectory(NULL);
114
115 Clear();
116
117}
118
119// --------------------------------------------------------------------------
120//
121// Sets:
122// - fHGausHist.SetBins(fNbins,fFirst,fLast);
123// - fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
124//
125void MHCalibrationChargePix::InitBins()
126{
127 MHGausEvents::InitBins();
128 fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
129}
130
131// --------------------------------------------------------------------------
132//
133// Sets:
134// - all variables to 0.
135//
136// Executes:
137// - MHGausEvents::Clear()
138//
139void MHCalibrationChargePix::Clear(Option_t *o)
140{
141
142 fSaturated = 0.;
143
144 MHGausEvents::Clear();
145 return;
146}
147
148// --------------------------------------------------------------------------
149//
150// Empty function to overload MHGausEvents::Reset()
151//
152void MHCalibrationChargePix::Reset()
153{
154}
155
156// --------------------------------------------------------------------------
157//
158// Calls MHGausEvents::ChangeHistId()
159//
160// Add id to names and titles of:
161// - fHAbsTime
162//
163void MHCalibrationChargePix::ChangeHistId(Int_t id)
164{
165
166 MHGausEvents::ChangeHistId(id);
167
168 fHAbsTime.SetName (Form("%s%d", fHAbsTime.GetName(), id));
169 fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
170
171}
172
173// --------------------------------------------------------------------------
174//
175// returns fHGausHist.Integral("width")
176//
177const Float_t MHCalibrationChargePix::GetIntegral() const
178{
179 return fHGausHist.Integral("width");
180}
181
182// --------------------------------------------------------------------------
183//
184// returns fHAbsTime.GetMean()
185//
186const Float_t MHCalibrationChargePix::GetAbsTimeMean() const
187{
188 return fHAbsTime.GetMean();
189}
190
191// --------------------------------------------------------------------------
192//
193// returns fHAbsTime.GetRMS()
194//
195const Float_t MHCalibrationChargePix::GetAbsTimeRms() const
196{
197 return fHAbsTime.GetRMS();
198}
199
200// --------------------------------------------------------------------------
201//
202// Fills fHAbsTime with t
203// Returns kFALSE, if overflow or underflow occurred, else kTRUE
204//
205Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
206{
207 return fHAbsTime.Fill(t) > -1;
208}
209
210// -----------------------------------------------------------------------------
211//
212// Default draw:
213//
214// The following options can be chosen:
215//
216// "": displays the fHGausHist and the fHAbsTime
217// "all": executes additionally MHGausEvents::Draw(), with options
218//
219void MHCalibrationChargePix::Draw(const Option_t *opt)
220{
221
222 TString option(opt);
223 option.ToLower();
224
225 Int_t win = 1;
226
227 TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
228 TVirtualPad *pad = NULL;
229
230 if (option.Contains("all"))
231 {
232 option.ReplaceAll("all","");
233 oldpad->Divide(2,1);
234 win = 2;
235 oldpad->cd(1);
236 TVirtualPad *newpad = gPad;
237 pad = newpad;
238 pad->Divide(1,2);
239 pad->cd(1);
240 }
241 else
242 {
243 pad = oldpad;
244 pad->Divide(1,2);
245 pad->cd(1);
246 }
247
248 if (!IsEmpty())
249 gPad->SetLogy();
250
251 gPad->SetTicks();
252
253 fHGausHist.GetXaxis()->SetLabelSize(0.06);
254 fHGausHist.GetYaxis()->SetLabelSize(0.07);
255 fHGausHist.GetXaxis()->SetLabelOffset(0.01);
256 fHGausHist.GetYaxis()->SetLabelOffset(0.01);
257 fHGausHist.GetXaxis()->SetTitleSize(0.065);
258 fHGausHist.GetYaxis()->SetTitleSize(0.07);
259 fHGausHist.GetXaxis()->SetTitleOffset(0.6);
260 fHGausHist.GetYaxis()->SetTitleOffset(0.6);
261 fHGausHist.Draw(opt);
262 if (fFGausFit)
263 {
264 fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
265 fFGausFit->Draw("same");
266 }
267
268 pad->cd(2);
269 gPad->SetTicks();
270
271 fHAbsTime.GetXaxis()->SetLabelSize(0.06);
272 fHAbsTime.GetYaxis()->SetLabelSize(0.07);
273 fHAbsTime.GetXaxis()->SetLabelOffset(0.01);
274 fHAbsTime.GetYaxis()->SetLabelOffset(0.01);
275 fHAbsTime.GetXaxis()->SetTitleSize(0.065);
276 fHAbsTime.GetYaxis()->SetTitleSize(0.07);
277 fHAbsTime.GetXaxis()->SetTitleOffset(0.6);
278 fHAbsTime.GetYaxis()->SetTitleOffset(0.6);
279 fHAbsTime.Draw(opt);
280
281 if (win < 2)
282 return;
283
284 oldpad->cd(2);
285 MHGausEvents::Draw("fourierevents");
286
287}
Note: See TracBrowser for help on using the repository browser.