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

Last change on this file since 4951 was 4950, checked in by gaug, 21 years ago
*** empty log message ***
File size: 7.7 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
52// --------------------------------------------------------------------------
53//
54// Default Constructor.
55//
56// Sets:
57// - the default x-axis title for fHAbsTime ("Absolute Arrival Time [FADC slice nr]")
58// - the default y-axis title for fHAbsTime ("Nr. of events");
59// - the default directory of the fHAbsTime (NULL)
60// - the current style for fHAbsTime
61//
62// Initializes:
63// - fHAbsTime()
64//
65// Calls:
66// - Clear();
67//
68MHCalibrationChargePix::MHCalibrationChargePix(const char *name, const char *title)
69 : fHAbsTime(),
70 fAbsTimeNbins(1), fAbsTimeFirst(0.), fAbsTimeLast(1.)
71{
72
73 fName = name ? name : "MHCalibrationChargePix";
74 fTitle = title ? title : "Statistics of the FADC sums of calibration events";
75
76 fHAbsTime.UseCurrentStyle();
77 fHAbsTime.SetDirectory(NULL);
78
79 Clear();
80
81}
82
83// --------------------------------------------------------------------------
84//
85// Use the MHGausEvents::Clone function and clone additionally the rest of the
86// data members.
87//
88TObject *MHCalibrationChargePix::Clone(const char *name) const
89{
90
91 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)*MHCalibrationPix::Clone(name);
92 //
93 // Copy data members
94 //
95 pix.fHAbsTime = fHAbsTime;
96
97 return &pix;
98}
99
100// --------------------------------------------------------------------------
101//
102// Sets:
103// - fHGausHist.SetBins(fNbins,fFirst,fLast);
104// - fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
105//
106void MHCalibrationChargePix::InitBins()
107{
108 MHGausEvents::InitBins();
109 fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
110}
111
112// --------------------------------------------------------------------------
113//
114// Empty function to overload MHGausEvents::Reset()
115//
116void MHCalibrationChargePix::Reset()
117{
118 MHGausEvents::Reset();
119 fHAbsTime.Reset();
120}
121
122// --------------------------------------------------------------------------
123//
124// Calls MHCalibrationPix::ChangeHistId()
125//
126// Add id to names and titles of:
127// - fHAbsTime
128//
129void MHCalibrationChargePix::ChangeHistId(Int_t id)
130{
131
132 MHCalibrationPix::ChangeHistId(id);
133
134 fHAbsTime.SetName (Form("%s%d", fHAbsTime.GetName(), id));
135 fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
136
137}
138
139// --------------------------------------------------------------------------
140//
141// returns fHGausHist.Integral("width")
142//
143const Float_t MHCalibrationChargePix::GetIntegral() const
144{
145 return fHGausHist.Integral("width");
146}
147
148// --------------------------------------------------------------------------
149//
150// returns fHAbsTime.GetMean()
151//
152const Float_t MHCalibrationChargePix::GetAbsTimeMean() const
153{
154 return fHAbsTime.GetMean();
155}
156
157// --------------------------------------------------------------------------
158//
159// returns fHAbsTime.GetRMS()
160//
161const Float_t MHCalibrationChargePix::GetAbsTimeRms() const
162{
163 return fHAbsTime.GetRMS();
164}
165
166// --------------------------------------------------------------------------
167//
168// Fills fHAbsTime with t
169// Returns kFALSE, if overflow or underflow occurred, else kTRUE
170//
171Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
172{
173 return fHAbsTime.Fill(t) > -1;
174}
175
176// -----------------------------------------------------------------------------
177//
178// Default draw:
179//
180// The following options can be chosen:
181//
182// "": displays the fHGausHist and the fHAbsTime
183// "all": executes additionally MHCalibrationPix::Draw(), with options
184//
185// The following picture shows a typical outcome of call to Draw("all"):
186// One the left side:
187// - The distribution of the values with the Gauss fit are shown (points connected
188// with each other). The line is green, thus the Gauss fit has a probability higher
189// than 0.5%.
190// - The distribution of the positions of the maximum (abs. arrival times)
191// is displayed. Most of the events have an arrival time of slice 7 (==hardware:8)
192//
193// On the right side:
194// - The first plot shows the distribution of the values with the Gauss fit
195// with error bars
196// - The second plot shows the TGraph with the events vs. time
197// - The third plot shows the fourier transform and a peak at 100 Hz.
198// - The fourth plot shows the projection of the fourier components and an exponential
199// fit, with the result that the observed deviation is not statistical, but signficant with a
200// probability smaller than 0.5%.
201//
202//Begin_Html
203/*
204<img src="images/MHCalibrationChargePixDraw.gif">
205*/
206//End_Html
207//
208void MHCalibrationChargePix::Draw(const Option_t *opt)
209{
210
211 TString option(opt);
212 option.ToLower();
213
214 Int_t win = 1;
215
216 TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
217 TVirtualPad *pad = NULL;
218
219 if (option.Contains("all"))
220 {
221 option.ReplaceAll("all","");
222 oldpad->Divide(2,1);
223 win = 2;
224 oldpad->cd(1);
225 TVirtualPad *newpad = gPad;
226 pad = newpad;
227 pad->Divide(1,2);
228 pad->cd(1);
229 }
230 else if (option.Contains("datacheck"))
231 {
232 MHCalibrationPix::Draw("events");
233 return;
234 }
235 else
236 {
237 pad = oldpad;
238 pad->Divide(1,2);
239 pad->cd(1);
240 }
241 /*
242 else
243 {
244 option.ReplaceAll("time","");
245 pad = oldpad;
246 pad->Divide(1,2);
247 pad->cd(1);
248 }
249 */
250 if (!IsEmpty() && !IsOnlyOverflow() && !IsOnlyUnderflow())
251 gPad->SetLogy();
252
253 gPad->SetTicks();
254
255 fHGausHist.GetXaxis()->SetLabelSize(0.06);
256 fHGausHist.GetYaxis()->SetLabelSize(0.07);
257 fHGausHist.GetXaxis()->SetLabelOffset(0.01);
258 fHGausHist.GetYaxis()->SetLabelOffset(0.01);
259 fHGausHist.GetXaxis()->SetTitleSize(0.065);
260 fHGausHist.GetYaxis()->SetTitleSize(0.07);
261 fHGausHist.GetXaxis()->SetTitleOffset(0.6);
262 fHGausHist.GetYaxis()->SetTitleOffset(0.6);
263 fHGausHist.Draw();
264 if (fFGausFit)
265 {
266 fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
267 fFGausFit->Draw("same");
268 }
269
270 pad->cd(2);
271 gPad->SetTicks();
272
273 fHAbsTime.GetXaxis()->SetLabelSize(0.06);
274 fHAbsTime.GetYaxis()->SetLabelSize(0.07);
275 fHAbsTime.GetXaxis()->SetLabelOffset(0.01);
276 fHAbsTime.GetYaxis()->SetLabelOffset(0.01);
277 fHAbsTime.GetXaxis()->SetTitleSize(0.065);
278 fHAbsTime.GetYaxis()->SetTitleSize(0.07);
279 fHAbsTime.GetXaxis()->SetTitleOffset(0.6);
280 fHAbsTime.GetYaxis()->SetTitleOffset(0.6);
281 fHAbsTime.Draw();
282
283 if (win < 2)
284 return;
285
286 oldpad->cd(2);
287 MHCalibrationPix::Draw("fourierevents");
288
289}
Note: See TracBrowser for help on using the repository browser.