source: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc@ 3308

Last change on this file since 3308 was 3280, checked in by gaug, 21 years ago
*** empty log message ***
File size: 6.8 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// MHCalibrationChargePINDiode
28//
29// Performs all the necessary fits to extract the mean number of photons
30// out of the derived light flux
31//
32//////////////////////////////////////////////////////////////////////////////
33#include "MHCalibrationChargePINDiode.h"
34
35#include <TH1.h>
36#include <TPad.h>
37#include <TVirtualPad.h>
38#include <TCanvas.h>
39
40#include "MLog.h"
41#include "MLogManip.h"
42
43#include "MParList.h"
44
45#include "MExtractedSignalPINDiode.h"
46#include "MCalibrationChargePINDiode.h"
47
48ClassImp(MHCalibrationChargePINDiode);
49
50using namespace std;
51
52const Int_t MHCalibrationChargePINDiode::fgChargeNbins = 200;
53const Axis_t MHCalibrationChargePINDiode::fgChargeFirst = -0.5;
54const Axis_t MHCalibrationChargePINDiode::fgChargeLast = 199.5;
55const Int_t MHCalibrationChargePINDiode::fgRmsChargeNbins = 100;
56const Axis_t MHCalibrationChargePINDiode::fgRmsChargeFirst = 0.;
57const Axis_t MHCalibrationChargePINDiode::fgRmsChargeLast = 100.;
58const Int_t MHCalibrationChargePINDiode::fgAbsTimeNbins = 30;
59const Axis_t MHCalibrationChargePINDiode::fgAbsTimeFirst = -0.5;
60const Axis_t MHCalibrationChargePINDiode::fgAbsTimeLast = 29.5;
61// --------------------------------------------------------------------------
62//
63// Default Constructor.
64//
65MHCalibrationChargePINDiode::MHCalibrationChargePINDiode(const char *name, const char *title)
66 : fPINDiode(NULL), fHRmsCharge()
67{
68
69 fName = name ? name : "MHCalibrationChargePINDiode";
70 fTitle = title ? title : "Fill the FADC sums of the PINDiode events and perform the fits";
71
72 SetChargeNbins();
73 SetChargeFirst();
74 SetChargeLast();
75
76 SetRmsChargeNbins();
77 SetRmsChargeFirst();
78 SetRmsChargeLast();
79
80 SetAbsTimeNbins();
81 SetAbsTimeFirst();
82 SetAbsTimeLast();
83
84 fHRmsCharge.SetName("HRmsCharge");
85 fHRmsCharge.SetTitle("Distribution of Variances of summed FADC slices");
86 fHRmsCharge.SetXTitle("RMS (sum) [FADC slices]");
87 fHRmsCharge.SetYTitle("Nr. of events");
88 fHRmsCharge.UseCurrentStyle();
89 fHRmsCharge.SetDirectory(NULL);
90
91 Clear();
92}
93
94
95void MHCalibrationChargePINDiode::Init()
96{
97
98 fHGausHist.SetName("HCalibrationChargePINDiode");
99 fHGausHist.SetTitle("Distribution of Summed FADC slices PIN Diode");
100 fHGausHist.SetXTitle("Sum FADC Slices");
101 fHGausHist.SetYTitle("Nr. of events");
102 fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
103 // fHGausHist.Sumw2();
104
105 fHAbsTime.SetName("HAbsTimePINDiode");
106 fHAbsTime.SetTitle("Distribution of Absolute Arrival Times PIN Diode ");
107 fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
108 fHAbsTime.SetYTitle("Nr. of events");
109 fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
110
111 fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
112}
113
114
115void MHCalibrationChargePINDiode::Clear(Option_t *o)
116{
117
118 fExtractSlices = 0;
119
120 MHCalibrationChargePix::Clear();
121 return;
122}
123
124Bool_t MHCalibrationChargePINDiode::SetupFill(const MParList *pList)
125{
126 Init();
127 return kTRUE;
128}
129
130Bool_t MHCalibrationChargePINDiode::ReInit(MParList *pList)
131{
132
133 fPINDiode = (MCalibrationChargePINDiode*)pList->FindCreateObj("MCalibrationChargePINDiode");
134 if (!fPINDiode)
135 {
136 *fLog << err << GetDescriptor() << ": ERROR: Could not find MCalibrationChargePINDiode ... aborting " << endl;
137 return kFALSE;
138 }
139
140 return kTRUE;
141}
142
143Bool_t MHCalibrationChargePINDiode::Fill(const MParContainer *par, const Stat_t w)
144{
145
146 MExtractedSignalPINDiode *extractor = (MExtractedSignalPINDiode*)par;
147
148 if (!extractor)
149 {
150 *fLog << err << "No argument in MExtractedSignalPINDiode::Fill... abort." << endl;
151 return kFALSE;
152 }
153
154 Float_t slices = (Float_t)extractor->GetNumFADCSamples();
155
156 if (slices == 0.)
157 {
158 *fLog << err << "Number of used signal slices in MExtractedSignalPINDiode is zero ... abort."
159 << endl;
160 return kFALSE;
161 }
162
163 if (fExtractSlices != 0. && slices != fExtractSlices )
164 {
165 gLog << err << "Number of used signal slices changed in MExtractedSignalCam ... abort."
166 << endl;
167 return kFALSE;
168 }
169
170 fExtractSlices = slices;
171
172 const Float_t signal = (float)extractor->GetExtractedSignal();
173 const Float_t time = extractor->GetExtractedTime();
174 const Float_t rms = extractor->GetExtractedRms();
175
176 FillHistAndArray(signal);
177 FillAbsTime(time);
178 FillRmsCharge(rms);
179
180 return kTRUE;
181}
182
183Bool_t MHCalibrationChargePINDiode::Finalize()
184{
185
186 if (IsGausFitOK() || IsEmpty())
187 return kTRUE;
188
189 FitGaus();
190 FitRmsCharge();
191 CreateFourierSpectrum();
192
193 fPINDiode->SetMeanCharge( GetMean() );
194 fPINDiode->SetMeanChargeErr( GetMeanErr() );
195 fPINDiode->SetSigmaCharge( GetSigma() );
196 fPINDiode->SetSigmaChargeErr( GetSigmaErr() );
197
198 fPINDiode->SetAbsTimeMean( GetAbsTimeMean() );
199 fPINDiode->SetAbsTimeRms( GetAbsTimeRms() );
200
201 fPINDiode->SetRmsChargeMean( GetRmsChargeMean() );
202 fPINDiode->SetRmsChargeMeanErr( GetRmsChargeMeanErr() );
203 fPINDiode->SetRmsChargeSigma( GetRmsChargeSigma() );
204 fPINDiode->SetRmsChargeSigmaErr( GetRmsChargeSigmaErr() );
205
206 return kTRUE;
207}
208
209Bool_t MHCalibrationChargePINDiode::FillRmsCharge(const Float_t q)
210{
211 return fHRmsCharge.Fill(q) > -1;
212}
213
214// -----------------------------------------------------------
215//
216// Fits -- not yet implemented
217//
218Bool_t MHCalibrationChargePINDiode::FitRmsCharge(Option_t *option)
219{
220 return 1;
221}
222
223
224void MHCalibrationChargePINDiode::Draw(const Option_t *opt)
225{
226
227 TString option(opt);
228 option.ToLower();
229
230 Int_t win = 1;
231
232 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
233
234 pad->SetTicks();
235 pad->SetBorderMode(0);
236
237 if (option.Contains("rmscharge"))
238 win++;
239
240 pad->Divide(1,win);
241 pad->cd(1);
242
243 if (!IsEmpty())
244 gPad->SetLogy();
245
246 MHGausEvents::Draw(opt);
247
248 if (win > 1)
249 {
250 pad->cd(2);
251 fHRmsCharge.Draw(opt);
252 }
253}
254
255
256
257
Note: See TracBrowser for help on using the repository browser.