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

Last change on this file since 3256 was 3256, checked in by gaug, 21 years ago
*** empty log message ***
File size: 4.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//
27// MHCalibrationChargePix
28//
29// Histogram class for charge calibration analysis. Holds the histogrammed
30// summed FADC slices and some rough absolute timing. Calculates the mean
31// sum of FADC slices and its sigma
32//
33//////////////////////////////////////////////////////////////////////////////
34#include "MHCalibrationChargePix.h"
35
36#include <TH1.h>
37#include <TF1.h>
38
39#include <TVirtualPad.h>
40#include <TCanvas.h>
41#include <TPad.h>
42#include <TGraph.h>
43
44#include "MH.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49ClassImp(MHCalibrationChargePix);
50
51using namespace std;
52
53const Int_t MHCalibrationChargePix::fgChargeNbins = 2000;
54const Axis_t MHCalibrationChargePix::fgChargeFirst = -0.5;
55const Axis_t MHCalibrationChargePix::fgChargeLast = 1999.5;
56const Int_t MHCalibrationChargePix::fgAbsTimeNbins = 15;
57const Axis_t MHCalibrationChargePix::fgAbsTimeFirst = -0.5;
58const Axis_t MHCalibrationChargePix::fgAbsTimeLast = 14.5;
59
60const Int_t MHCalibrationChargePix::fgPulserFrequency = 200;
61// --------------------------------------------------------------------------
62//
63// Default Constructor.
64//
65MHCalibrationChargePix::MHCalibrationChargePix(const char *name, const char *title)
66 : fHAbsTime()
67{
68
69 fName = name ? name : "MHCalibrationChargePix";
70 fTitle = title ? title : "Fill the FADC sums of calibration events and perform the fits";
71
72 SetChargeNbins();
73 SetChargeFirst();
74 SetChargeLast();
75
76 SetAbsTimeNbins();
77 SetAbsTimeFirst();
78 SetAbsTimeLast();
79
80 fHAbsTime.UseCurrentStyle();
81 fHAbsTime.SetDirectory(NULL);
82
83 Clear();
84
85 SetPulserFrequency();
86}
87
88void MHCalibrationChargePix::Init()
89{
90
91 fHGausHist.SetName("HCalibrationCharge");
92 fHGausHist.SetTitle("Distribution of Summed FADC slices Pixel");
93 fHGausHist.SetXTitle("Sum FADC Slices");
94 fHGausHist.SetYTitle("Nr. of events");
95 fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
96 fHGausHist.Sumw2();
97
98 fHAbsTime.SetName("HAbsTimePixel");
99 fHAbsTime.SetTitle("Distribution of Absolute Arrival Times Pixel ");
100 fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
101 fHAbsTime.SetYTitle("Nr. of events");
102 fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
103
104}
105
106
107
108void MHCalibrationChargePix::Clear(Option_t *o)
109{
110
111 fPixId = -1;
112
113 MHGausEvents::Clear();
114 return;
115}
116
117
118void MHCalibrationChargePix::Reset()
119{
120}
121
122
123void MHCalibrationChargePix::ChangeHistId(Int_t id)
124{
125
126 fPixId = id;
127
128 fHGausHist.SetName(Form("%s%d", fHGausHist.GetName(), id));
129 fHGausHist.SetTitle(Form("%s%d", fHGausHist.GetTitle(), id));
130
131 fHAbsTime.SetName(Form("%s%d", fHAbsTime.GetName(), id));
132 fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
133}
134
135
136const Float_t MHCalibrationChargePix::GetIntegral() const
137{
138 return fHGausHist.Integral("width");
139}
140
141const Float_t MHCalibrationChargePix::GetAbsTimeMean() const
142{
143 return fHAbsTime.GetMean();
144}
145
146const Float_t MHCalibrationChargePix::GetAbsTimeRms() const
147{
148 return fHAbsTime.GetRMS();
149}
150
151void MHCalibrationChargePix::SetPulserFrequency(Float_t f)
152{
153 SetEventFrequency(f);
154}
155
156Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
157{
158 return fHAbsTime.Fill(t) > -1;
159}
160
161
162void MHCalibrationChargePix::Draw(const Option_t *opt)
163{
164
165 TString option(opt);
166 option.ToLower();
167
168 Int_t win = 1;
169
170 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
171
172 pad->SetTicks();
173 pad->SetBorderMode(0);
174
175 if (option.Contains("time"))
176 win++;
177
178 pad->SetTicks();
179 pad->SetBorderMode(0);
180 pad->Divide(1,win);
181 pad->cd(1);
182
183 if (!IsEmpty())
184 pad->SetLogy();
185
186 MHGausEvents::Draw(opt);
187
188 if (win > 1)
189 {
190 pad->cd(2);
191 fHAbsTime.Draw(opt);
192 }
193}
194
195void MHCalibrationChargePix::BypassFit()
196{
197
198 //
199 // In case, we do not obtain reasonable values
200 // with the fit, we take the histogram values
201 //
202 SetMean(fHGausHist.GetMean());
203 SetMeanErr(fHGausHist.GetRMS()/fHGausHist.GetEntries());
204 SetSigma(fHGausHist.GetRMS());
205 SetSigmaErr(fHGausHist.GetRMS()/fHGausHist.GetEntries()/2.);
206}
207
Note: See TracBrowser for help on using the repository browser.