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

Last change on this file since 3234 was 3200, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.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 11/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2002
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 "MExtractedSignalPINDiode.h"
44
45ClassImp(MHCalibrationChargePINDiode);
46
47using namespace std;
48
49const Int_t MHCalibrationChargePINDiode::fgChargeNbins = 200;
50const Axis_t MHCalibrationChargePINDiode::fgChargeFirst = -0.5;
51const Axis_t MHCalibrationChargePINDiode::fgChargeLast = 199.5;
52const Int_t MHCalibrationChargePINDiode::fgRmsChargeNbins = 100;
53const Axis_t MHCalibrationChargePINDiode::fgRmsChargeFirst = 0.;
54const Axis_t MHCalibrationChargePINDiode::fgRmsChargeLast = 100.;
55const Int_t MHCalibrationChargePINDiode::fgAbsTimeNbins = 30;
56const Axis_t MHCalibrationChargePINDiode::fgAbsTimeFirst = -0.5;
57const Axis_t MHCalibrationChargePINDiode::fgAbsTimeLast = 29.5;
58// --------------------------------------------------------------------------
59//
60// Default Constructor.
61//
62MHCalibrationChargePINDiode::MHCalibrationChargePINDiode(const char *name, const char *title)
63 : fHRmsCharge()
64{
65
66 fName = name ? name : "MHCalibrationChargePINDiode";
67 fTitle = title ? title : "Fill the FADC sums of the PINDiode events and perform the fits";
68
69 SetChargeNbins();
70 SetChargeFirst();
71 SetChargeLast();
72
73 SetRmsChargeNbins();
74 SetRmsChargeFirst();
75 SetRmsChargeLast();
76
77 SetAbsTimeNbins();
78 SetAbsTimeFirst();
79 SetAbsTimeLast();
80
81 fHRmsCharge.SetName("HRmsCharge");
82 fHRmsCharge.SetTitle("Distribution of Variances of summed FADC slices");
83 fHRmsCharge.SetXTitle("RMS (sum) [FADC slices]");
84 fHRmsCharge.SetYTitle("Nr. of events");
85 fHRmsCharge.UseCurrentStyle();
86 fHRmsCharge.SetDirectory(NULL);
87
88 fExtractSlices = 0;
89}
90
91
92void MHCalibrationChargePINDiode::Init()
93{
94
95 fHGausHist.SetName("HCalibrationChargePINDiode");
96 fHGausHist.SetTitle("Distribution of Summed FADC slices PIN Diode");
97 fHGausHist.SetXTitle("Sum FADC Slices");
98 fHGausHist.SetYTitle("Nr. of events");
99 fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
100 // fHGausHist.Sumw2();
101
102 fHAbsTime.SetName("HAbsTimePINDiode");
103 fHAbsTime.SetTitle("Distribution of Absolute Arrival Times PIN Diode ");
104 fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
105 fHAbsTime.SetYTitle("Nr. of events");
106 fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
107
108 fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
109}
110
111
112void MHCalibrationChargePINDiode::Clear(Option_t *o)
113{
114
115 fExtractSlices = 0;
116
117 MHCalibrationChargePix::Clear();
118 return;
119}
120
121Bool_t MHCalibrationChargePINDiode::SetupFill(const MParList *pList)
122{
123
124 Init();
125 return kTRUE;
126}
127
128Bool_t MHCalibrationChargePINDiode::Fill(const MParContainer *par, const Stat_t w)
129{
130
131 MExtractedSignalPINDiode *extractor = (MExtractedSignalPINDiode*)par;
132
133 if (!extractor)
134 {
135 *fLog << err << "No argument in MExtractedSignalPINDiode::Fill... abort." << endl;
136 return kFALSE;
137 }
138
139 Float_t slices = (Float_t)extractor->GetNumFADCSamples();
140
141 if (slices == 0.)
142 {
143 *fLog << err << "Number of used signal slices in MExtractedSignalPINDiode is zero ... abort."
144 << endl;
145 return kFALSE;
146 }
147
148 if (fExtractSlices != 0. && slices != fExtractSlices )
149 {
150 gLog << err << "Number of used signal slices changed in MExtractedSignalCam ... abort."
151 << endl;
152 return kFALSE;
153 }
154
155 fExtractSlices = slices;
156
157 const Float_t signal = (float)extractor->GetExtractedSignal();
158 const Float_t time = extractor->GetExtractedTime();
159 const Float_t rms = extractor->GetExtractedRms();
160
161 FillHistAndArray(signal);
162 FillAbsTime(time);
163 FillRmsCharge(rms);
164
165 return kTRUE;
166}
167
168Bool_t MHCalibrationChargePINDiode::Finalize()
169{
170
171 if (IsGausFitOK() || IsEmpty())
172 return kTRUE;
173
174 FitGaus();
175 FitRmsCharge();
176 CreateFourierSpectrum();
177
178
179 return kTRUE;
180}
181
182Bool_t MHCalibrationChargePINDiode::FillRmsCharge(Float_t q)
183{
184 return fHRmsCharge.Fill(q) > -1;
185}
186
187// -----------------------------------------------------------
188//
189// Fits -- not yet implemented
190//
191Bool_t MHCalibrationChargePINDiode::FitRmsCharge(Option_t *option)
192{
193 return 1;
194}
195
196
197void MHCalibrationChargePINDiode::Draw(const Option_t *opt)
198{
199
200 TString option(opt);
201 option.ToLower();
202
203 Int_t win = 1;
204
205 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
206
207 pad->SetTicks();
208 pad->SetBorderMode(0);
209
210 if (option.Contains("RmsCharge"))
211 win++;
212
213 pad->Divide(1,win);
214 pad->cd(1);
215
216 if (!IsEmpty())
217 pad->SetLogy();
218
219 MHGausEvents::Draw(opt);
220
221 if (win > 1)
222 {
223 pad->cd(2);
224 fHRmsCharge.Draw(opt);
225 }
226}
Note: See TracBrowser for help on using the repository browser.