source: trunk/MagicSoft/Mars/mcalib/MHCalibrationRelTimeCam.cc@ 3211

Last change on this file since 3211 was 3181, checked in by gaug, 21 years ago
*** empty log message ***
File size: 7.3 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// MHCalibrationRelTimeCam //
28// //
29// Hold the CalibrationRelTime information for all pixels in the camera //
30// //
31/////////////////////////////////////////////////////////////////////////////
32#include "MHCalibrationRelTimeCam.h"
33
34#include "MLog.h"
35#include "MLogManip.h"
36
37#include "MParList.h"
38
39#include "MHCalibrationRelTimePix.h"
40
41#include "MArrivalTime.h"
42
43ClassImp(MHCalibrationRelTimeCam);
44
45using namespace std;
46const Float_t MHCalibrationRelTimeCam::fgTimeSliceWidth = 3.3;
47// --------------------------------------------------------------------------
48//
49// Default constructor. Creates a MHCalibrationRelTimePix object for each pixel
50//
51MHCalibrationRelTimeCam::MHCalibrationRelTimeCam(const char *name, const char *title)
52{
53
54 fName = name ? name : "MHCalibrationRelTimeCam";
55 fTitle = title ? title : "Histogram container for the relative time calibration of the camera";
56
57 //
58 // loop over all Pixels and create two histograms
59 // one for the Low and one for the High gain
60 // connect all the histogram with the container fHist
61 //
62 fArray = new TObjArray;
63 fArray->SetOwner();
64
65
66 SetTimeSliceWidth();
67}
68
69// --------------------------------------------------------------------------
70//
71// Delete the array conatining the pixel pedest information
72//
73MHCalibrationRelTimeCam::~MHCalibrationRelTimeCam()
74{
75 delete fArray;
76}
77
78// --------------------------------------
79//
80void MHCalibrationRelTimeCam::Clear(Option_t *o)
81{
82
83 fArray->ForEach(TObject, Clear)();
84 return;
85}
86
87// --------------------------------------------------------------------------
88//
89// Get i-th pixel (pixel number)
90//
91MHCalibrationRelTimePix &MHCalibrationRelTimeCam::operator[](UInt_t i)
92{
93 return *(MHCalibrationRelTimePix*)(fArray->At(i));
94}
95
96// --------------------------------------------------------------------------
97//
98// Get i-th pixel (pixel number)
99//
100const MHCalibrationRelTimePix &MHCalibrationRelTimeCam::operator[](UInt_t i) const
101{
102 return *(MHCalibrationRelTimePix*)(fArray->At(i));
103}
104
105
106// --------------------------------------------------------------------------
107//
108// Our own clone function is necessary since root 3.01/06 or Mars 0.4
109// I don't know the reason
110//
111TObject *MHCalibrationRelTimeCam::Clone(const char *) const
112{
113
114 const Int_t n = fArray->GetSize();
115
116 //
117 // FIXME, this might be done faster and more elegant, by direct copy.
118 //
119 MHCalibrationRelTimeCam *cam = new MHCalibrationRelTimeCam;
120
121 cam->fArray->Expand(n);
122
123 for (int i=0; i<n; i++)
124 {
125 delete (*cam->fArray)[i];
126 (*cam->fArray)[i] = (*fArray)[i]->Clone();
127 }
128
129 return cam;
130}
131
132
133
134// --------------------------------------------------------------------------
135//
136//
137Bool_t MHCalibrationRelTimeCam::SetupFill(const MParList *pList)
138{
139
140 return kTRUE;
141
142}
143
144// --------------------------------------------------------------------------
145//
146Bool_t MHCalibrationRelTimeCam::Fill(const MParContainer *par, const Stat_t w)
147{
148
149 MArrivalTime *arrtime = (MArrivalTime*)par;
150 if (!arrtime)
151 {
152 gLog << err << "No argument in MArrivalTime::Fill... abort." << endl;
153 return kFALSE;
154 }
155
156 const Int_t n = arrtime->GetSize();
157
158 if (fArray->GetEntries()==0)
159 {
160 fArray->Expand(n);
161
162 for (Int_t i=0; i<n; i++)
163 {
164 (*fArray)[i] = new MHCalibrationRelTimePix;
165 MHCalibrationRelTimePix &hist = (*this)[i];
166 hist.ChangeHistId(i);
167 hist.InitBins();
168 }
169 }
170
171 if (fArray->GetEntries() != n)
172 {
173 gLog << err << "ERROR - Size mismatch... abort." << endl;
174 return kFALSE;
175 }
176
177 for (Int_t i=0; i<n; i++)
178 {
179
180 const Float_t reltime = (*arrtime)[i] - (*arrtime)[1];
181
182 MHCalibrationRelTimePix &hist = (*this)[i];
183 hist.FillHistAndArray(reltime);
184 }
185
186 return kTRUE;
187}
188
189Bool_t MHCalibrationRelTimeCam::Finalize()
190{
191
192 for (Int_t i=0; i<fArray->GetSize(); i++)
193 {
194
195 MHCalibrationRelTimePix &hist = (*this)[i];
196
197 //
198 // 1) Return if the charge distribution is already succesfully fitted
199 // or if the histogram is empty
200 //
201 if (hist.IsGausFitOK() || hist.IsEmpty())
202 continue;
203
204 //
205 // 2) Fit the Hi Gain histograms with a Gaussian
206 //
207 hist.FitGaus();
208
209 //
210 // 3) If fit does not succeed , bypass the fit and take the histogram means and sigmas
211 //
212 if (!hist.IsGausFitOK())
213 hist.BypassFit();
214
215 //
216 // 4) Create the fourier transform of the arrays
217 //
218 hist.CreateFourierSpectrum();
219
220 //
221 // 5) Renormalize to the real time in ns.
222 //
223 hist.Renorm(fTimeSliceWidth);
224
225 }
226 return kTRUE;
227}
228
229// --------------------------------------------------------------------------
230//
231// The types are as follows:
232//
233// Fitted values:
234// ==============
235//
236// 0: Fitted Mean Relative Arrival Time
237// 1: Error of fitted Mean Relative Arrival Time
238// 2: Sigma of fitted Relative Arrival Time
239// 3: Error of Sigma of fitted Relative Arrival Time
240//
241//
242// Useful variables derived from the fit results:
243// =============================================
244//
245// 4: Returned probability of Gauss fit to Charge distribution
246//
247// Localized defects:
248// ==================
249//
250// 5: Gaus fit not OK
251// 6: Fourier spectrum not OK
252//
253Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
254{
255
256 if (fArray->GetSize() <= idx)
257 return kFALSE;
258
259 switch (type)
260 {
261 case 0:
262 val = (*this)[idx].GetMean();
263 break;
264 case 1:
265 val = (*this)[idx].GetMeanErr();
266 break;
267 case 2:
268 val = (*this)[idx].GetSigma();
269 break;
270 case 3:
271 val = (*this)[idx].GetSigmaErr();
272 break;
273 case 4:
274 val = (*this)[idx].GetProb();
275 break;
276 case 5:
277 if (!(*this)[idx].IsGausFitOK())
278 val = 1.;
279 break;
280 case 6:
281 if (!(*this)[idx].IsFourierSpectrumOK())
282 val = 1.;
283 break;
284 default:
285 return kFALSE;
286 }
287 return kTRUE;
288}
289
290void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
291{
292 (*this)[idx].DrawClone();
293}
Note: See TracBrowser for help on using the repository browser.