source: trunk/MagicSoft/Mars/mcalib/MCalibrationPulseTimeCam.cc@ 6721

Last change on this file since 6721 was 6680, checked in by gaug, 20 years ago
*** empty log message ***
File size: 7.2 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-2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MCalibrationPulseTimeCam
28//
29// Storage container for relative arrival time calibration results
30// of the whole camera.
31//
32// Individual pixels have to be cast when retrieved e.g.:
33// MCalibrationPix &avpix = (MCalibrationPix&)(*fPulseCam)[i]
34//
35// The following "calibration" constants can be retrieved from each pixel:
36// - GetTimeOffset(): The mean offset in relative times,
37// has to be added to any calculated relative time in the camera.
38// - GetTimePrecision(): The Gauss sigma of histogrammed relative arrival
39// times for the calibration run. Gives an estimate about the timing
40// resolution.
41//
42// ALL RELATIVE TIMES HAVE TO BE CALCULATED W.R.T. PIXEL IDX 1
43// (HARDWARE NUMBER: 2) !!
44//
45// Averaged values over one whole area index (e.g. inner or outer pixels for
46// the MAGIC camera), can be retrieved via:
47// MCalibrationPix &avpix = (MCalibrationPix&)fPulseCam->GetAverageArea(i)
48//
49// Averaged values over one whole camera sector can be retrieved via:
50// MCalibrationPix &avpix = (MCalibrationPix&)fPulseCam->GetAverageSector(i)
51//
52// Note the averageing has been done on an event-by-event basis. Resulting
53// Sigma's of the Gauss fit have been multiplied with the square root of the number
54// of involved pixels in order to make a direct comparison possible with the mean of
55// sigmas.
56//
57// See also: MHCalibrationPix, MHCalibrationPulseTimeCam
58//
59// The calculated values (types of GetPixelContent) are:
60//
61// Fitted values:
62// ==============
63//
64// 0: Mean Time Offset
65// 1: Error of Mean Time Offset
66// 2: Sigma of Time Offset == Time Resolution
67// 3: Error of Sigma of Time Offset
68//
69// Useful variables derived from the fit results:
70// =============================================
71//
72// 4: Returned probability of Gauss fit to Pulse. Arrival Time distribution
73//
74/////////////////////////////////////////////////////////////////////////////
75#include "MCalibrationPulseTimeCam.h"
76#include "MCalibrationCam.h"
77
78#include <TOrdCollection.h>
79
80#include "MLog.h"
81#include "MLogManip.h"
82
83#include "MGeomCam.h"
84#include "MGeomPix.h"
85
86#include "MCalibrationPix.h"
87
88ClassImp(MCalibrationPulseTimeCam);
89
90using namespace std;
91
92// --------------------------------------------------------------------------
93//
94// Default constructor.
95//
96MCalibrationPulseTimeCam::MCalibrationPulseTimeCam(const char *name, const char *title)
97{
98
99 fName = name ? name : "MCalibrationPulseTimeCam";
100 fTitle = title ? title : "Container for Pulse Time Information";
101
102}
103
104void MCalibrationPulseTimeCam::Add(const UInt_t a, const UInt_t b)
105{
106 for (UInt_t i=a; i<b; i++)
107 fPixels->AddAt(new MCalibrationPix,i);
108}
109
110
111void MCalibrationPulseTimeCam::AddArea(const UInt_t a, const UInt_t b)
112{
113 for (UInt_t i=a; i<b; i++)
114 fAverageAreas->AddAt(new MCalibrationPix,i);
115}
116
117void MCalibrationPulseTimeCam::AddSector(const UInt_t a, const UInt_t b)
118{
119 for (UInt_t i=a; i<b; i++)
120 fAverageSectors->AddAt(new MCalibrationPix,i);
121}
122
123// --------------------------------------------------------------------------
124//
125// Print first the well fitted pixels
126// and then the ones which are not Valid
127//
128void MCalibrationPulseTimeCam::Print(Option_t *o) const
129{
130
131 *fLog << all << GetDescriptor() << ":" << endl;
132 int id = 0;
133
134 *fLog << all << "Calibrated pixels:" << endl;
135 *fLog << all << endl;
136
137 TIter Next(fPixels);
138 MCalibrationPix *pix;
139 while ((pix=(MCalibrationPix*)Next()))
140 {
141
142 if (!pix->IsExcluded())
143 {
144
145 *fLog << all
146 << Form("Pix %4i: Mean Time: %4.2f+-%4.2f Time Jitter: %4.2f+-%4.2f",pix->GetPixId(),
147 pix->GetMean(),pix->GetMeanErr(),pix->GetSigma(),pix->GetSigmaErr())
148 << endl;
149 id++;
150 }
151 }
152
153 *fLog << all << id << " pixels" << endl;
154 id = 0;
155
156
157 *fLog << all << endl;
158 *fLog << all << "Excluded pixels:" << endl;
159 *fLog << all << endl;
160
161 id = 0;
162
163 TIter Next4(fPixels);
164 while ((pix=(MCalibrationPix*)Next4()))
165 {
166 if (pix->IsExcluded())
167 {
168 *fLog << all << pix->GetPixId() << endl;
169 id++;
170 }
171 }
172 *fLog << all << id << " Excluded pixels " << endl;
173 *fLog << endl;
174
175 TIter Next5(fAverageAreas);
176 while ((pix=(MCalibrationPix*)Next5()))
177 {
178 *fLog << all
179 << Form("Pix %4i: Mean Time: %4.2f+-%4.2f Time Jitter: %4.2f+-%4.2f",pix->GetPixId(),
180 pix->GetMean(),pix->GetMeanErr(),pix->GetSigma(),pix->GetSigmaErr())
181 << endl;
182 }
183
184 TIter Next6(fAverageSectors);
185 while ((pix=(MCalibrationPix*)Next5()))
186 {
187 *fLog << all
188 << Form("Pix %4i: Mean Time: %4.2f+-%4.2f Time Jitter: %4.2f+-%4.2f",pix->GetPixId(),
189 pix->GetMean(),pix->GetMeanErr(),pix->GetSigma(),pix->GetSigmaErr())
190 << endl;
191 }
192}
193
194
195// --------------------------------------------------------------------------
196//
197// The types are as follows:
198//
199// Fitted values:
200// ==============
201//
202// 0: Fitted PulseTime
203// 1: Error of fitted PulseTime
204// 2: Sigma of fitted PulseTime
205// 3: Error of Sigma of fitted PulseTime
206//
207// Useful variables derived from the fit results:
208// =============================================
209//
210// 4: Returned probability of Gauss fit to PulseTime distribution
211//
212Bool_t MCalibrationPulseTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
213{
214
215 if (idx > GetSize())
216 return kFALSE;
217
218 Float_t area = cam[idx].GetA();
219
220 if (area == 0)
221 return kFALSE;
222
223 MCalibrationPix &pix = (MCalibrationPix&)(*this)[idx];
224
225 switch (type)
226 {
227 case 0:
228 if (pix.IsExcluded())
229 return kFALSE;
230 val = pix.GetHiGainMean();
231 break;
232 case 1:
233 if (pix.IsExcluded())
234 return kFALSE;
235 val = pix.GetHiGainMeanErr();
236 break;
237 case 2:
238 if (pix.IsExcluded())
239 return kFALSE;
240 val = pix.GetHiGainSigma();
241 break;
242 case 3:
243 if (pix.IsExcluded())
244 return kFALSE;
245 val = pix.GetHiGainSigmaErr();
246 break;
247 case 4:
248 if (pix.IsExcluded())
249 return kFALSE;
250 val = pix.GetProb();
251 break;
252 default:
253 return kFALSE;
254 }
255
256 return val!=-1.;
257
258}
259
Note: See TracBrowser for help on using the repository browser.