source: trunk/Mars/mhcalib/MHCalibrationHiLoPix.cc@ 10058

Last change on this file since 10058 was 7187, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 7.1 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 06/2005 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2005
21!
22!
23\* ======================================================================== */
24//////////////////////////////////////////////////////////////////////////////
25//
26// MHCalibrationHiLoPix
27//
28// Histogram class for the charge calibration.
29// Stores and fits the charges and stores the location of the maximum FADC
30// slice. HiLos are taken from MExtractedSignalPix.
31//
32//////////////////////////////////////////////////////////////////////////////
33#include "MHCalibrationHiLoPix.h"
34
35#include <TF1.h>
36
37#include <TVirtualPad.h>
38#include <TCanvas.h>
39#include <TPad.h>
40#include <TGraph.h>
41#include <TStyle.h>
42
43#include "MH.h"
44
45#include "MLog.h"
46#include "MLogManip.h"
47
48ClassImp(MHCalibrationHiLoPix);
49
50using namespace std;
51
52// --------------------------------------------------------------------------
53//
54// Default Constructor.
55//
56// Sets:
57// - the default x-axis title for fHivsLo ("High-gain Charge [FADC slices]")
58// - the default y-axis title for fHivsLo ("Low-gain Charge [FADC slices]");
59// - the default directory of the fHivsLo (NULL)
60// - the current style for fHivsLo
61//
62// Initializes:
63// - fHivsLo()
64//
65// Calls:
66// - Clear();
67//
68MHCalibrationHiLoPix::MHCalibrationHiLoPix(const char *name, const char *title)
69 : fHivsLo(),
70 fHivsLoNbins(1), fHivsLoFirst(0.), fHivsLoLast(1.)
71{
72
73 fName = name ? name : "MHCalibrationHiLoPix";
74 fTitle = title ? title : "High-gain vs. Low-gain intercalibration";
75
76 fHivsLo.UseCurrentStyle();
77 fHivsLo.SetDirectory(NULL);
78
79 Clear();
80
81}
82
83// --------------------------------------------------------------------------
84//
85// Sets:
86// - fHGausHist.SetBins(fNbins,fFirst,fLast);
87// - fHivsLo.SetBins(fHivsLoNbins,fHivsLoFirst,fHivsLoLast);
88//
89void MHCalibrationHiLoPix::InitBins()
90{
91 MHGausEvents::InitBins();
92 fHivsLo.SetBins(fHivsLoNbins,fHivsLoFirst,fHivsLoLast);
93}
94
95// --------------------------------------------------------------------------
96//
97// Empty function to overload MHGausEvents::Reset()
98//
99void MHCalibrationHiLoPix::Reset()
100{
101 MHGausEvents::Reset();
102 fHivsLo.Reset();
103}
104
105// --------------------------------------------------------------------------
106//
107// returns probability of fit. If fit does not exist,
108// returns -1.
109//
110const Float_t MHCalibrationHiLoPix::GetHivsLoProb() const
111{
112 const TF1 *fit = fHivsLo.GetFunction("pol1");
113 return fit ? fit->GetProb() : -1.;
114}
115
116// --------------------------------------------------------------------------
117//
118// returns parameter 0 of fit. If fit does not exist,
119// returns -1.
120//
121const Float_t MHCalibrationHiLoPix::GetHivsLoP0() const
122{
123 const TF1 *fit = fHivsLo.GetFunction("pol1");
124 return fit ? fit->GetParameter(0) : -1.;
125}
126
127// --------------------------------------------------------------------------
128//
129// returns parameter 1 of fit. If fit does not exist,
130// returns -1.
131//
132const Float_t MHCalibrationHiLoPix::GetHivsLoP1() const
133{
134 const TF1 *fit = fHivsLo.GetFunction("pol1");
135 return fit ? fit->GetParameter(1) : -1.;
136}
137
138// --------------------------------------------------------------------------
139//
140// Fills fHivsLo with t
141// Returns kFALSE, if overflow or underflow occurred, else kTRUE
142//
143Bool_t MHCalibrationHiLoPix::FillHivsLo(Float_t t,Float_t w)
144{
145 return fHivsLo.Fill(t,w) > -1;
146}
147
148// -----------------------------------------------------------------------------
149//
150// Default draw:
151//
152// The following options can be chosen:
153//
154// "": displays the fHGausHist and the fHivsLo
155// "all": executes additionally MHCalibrationPix::Draw(), with options
156//
157// The following picture shows a typical outcome of call to Draw("all"):
158// One the left side:
159// - The distribution of the values with the Gauss fit are shown (points connected
160// with each other). The line is green, thus the Gauss fit has a probability higher
161// than 0.5%.
162// - The distribution of the positions of the maximum (abs. arrival times)
163// is displayed. Most of the events have an arrival time of slice 7 (==hardware:8)
164//
165// On the right side:
166// - The first plot shows the distribution of the values with the Gauss fit
167// with error bars
168// - The second plot shows the TGraph with the events vs. time
169// - The third plot shows the fourier transform and a peak at 100 Hz.
170// - The fourth plot shows the projection of the fourier components and an exponential
171// fit, with the result that the observed deviation is not statistical, but signficant with a
172// probability smaller than 0.5%.
173//
174//Begin_Html
175/*
176<img src="images/MHCalibrationHiLoPixDraw.gif">
177*/
178//End_Html
179//
180void MHCalibrationHiLoPix::Draw(const Option_t *opt)
181{
182
183 TString option(opt);
184 option.ToLower();
185
186 Int_t win = 1;
187
188 TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
189 TVirtualPad *pad = NULL;
190
191 if (option.Contains("all"))
192 {
193 option.ReplaceAll("all","");
194 oldpad->Divide(2,1);
195 win = 2;
196 oldpad->cd(1);
197 TVirtualPad *newpad = gPad;
198 pad = newpad;
199 pad->Divide(1,2);
200 pad->cd(1);
201 }
202 else if (option.Contains("datacheck"))
203 {
204 MHCalibrationPix::Draw("events");
205 return;
206 }
207 else
208 {
209 pad = oldpad;
210 pad->Divide(1,2);
211 pad->cd(1);
212 }
213 /*
214 else
215 {
216 option.ReplaceAll("time","");
217 pad = oldpad;
218 pad->Divide(1,2);
219 pad->cd(1);
220 }
221 */
222 if (!IsEmpty() && !IsOnlyOverflow() && !IsOnlyUnderflow())
223 gPad->SetLogy();
224
225 gPad->SetTicks();
226
227 fHGausHist.GetXaxis()->SetLabelSize(0.06);
228 fHGausHist.GetYaxis()->SetLabelSize(0.07);
229 fHGausHist.GetXaxis()->SetLabelOffset(0.01);
230 fHGausHist.GetYaxis()->SetLabelOffset(0.01);
231 fHGausHist.GetXaxis()->SetTitleSize(0.065);
232 fHGausHist.GetYaxis()->SetTitleSize(0.07);
233 fHGausHist.GetXaxis()->SetTitleOffset(0.6);
234 fHGausHist.GetYaxis()->SetTitleOffset(0.6);
235 fHGausHist.Draw();
236 if (fFGausFit)
237 {
238 fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
239 fFGausFit->Draw("same");
240 }
241
242 pad->cd(2);
243 gPad->SetTicks();
244 gStyle->SetOptFit();
245
246 fHivsLo.GetXaxis()->SetLabelSize(0.06);
247 fHivsLo.GetYaxis()->SetLabelSize(0.07);
248 fHivsLo.GetXaxis()->SetLabelOffset(0.01);
249 fHivsLo.GetYaxis()->SetLabelOffset(0.01);
250 fHivsLo.GetXaxis()->SetTitleSize(0.065);
251 fHivsLo.GetYaxis()->SetTitleSize(0.07);
252 fHivsLo.GetXaxis()->SetTitleOffset(0.6);
253 fHivsLo.GetYaxis()->SetTitleOffset(0.6);
254 fHivsLo.Draw();
255
256 if (win < 2)
257 return;
258
259 oldpad->cd(2);
260 MHCalibrationPix::Draw("fourierevents");
261}
Note: See TracBrowser for help on using the repository browser.