source: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc@ 4603

Last change on this file since 4603 was 4269, checked in by gaug, 20 years ago
*** empty log message ***
File size: 8.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// MCalibrationRelTimeCam
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// MCalibrationRelTimePix &avpix = (MCalibrationRelTimePix&)(*fRelCam)[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// MCalibrationRelTimePix &avpix = (MCalibrationRelTimePix&)fRelCam->GetAverageArea(i)
48//
49// Averaged values over one whole camera sector can be retrieved via:
50// MCalibrationRelTimePix &avpix = (MCalibrationRelTimePix&)fRelCam->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: MHCalibrationRelTimePix, MHCalibrationRelTimeCam
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 Rel. Arrival Time distribution
73//
74/////////////////////////////////////////////////////////////////////////////
75#include "MCalibrationRelTimeCam.h"
76#include "MCalibrationCam.h"
77
78#include <TClonesArray.h>
79
80#include "MLog.h"
81#include "MLogManip.h"
82
83#include "MGeomCam.h"
84#include "MGeomPix.h"
85
86#include "MCalibrationRelTimePix.h"
87
88ClassImp(MCalibrationRelTimeCam);
89
90using namespace std;
91
92// --------------------------------------------------------------------------
93//
94// Default constructor.
95//
96// Creates a TClonesArray of MCalibrationRelTimePix containers, initialized to 1 entry, destinated
97// to hold one container per pixel. Later, a call to MCalibrationRelTimeCam::InitSize()
98// has to be performed (in MGeomApply).
99//
100// Creates a TClonesArray of MCalibrationRelTimePix containers, initialized to 1 entry, destinated
101// to hold one container per pixel AREA. Later, a call to MCalibrationRelTimeCam::InitAreas()
102// has to be performed (in MGeomApply).
103//
104// Creates a TClonesArray of MCalibrationRelTimePix containers, initialized to 1 entry, destinated
105// to hold one container per camera SECTOR. Later, a call to MCalibrationRelTimeCam::InitSectors()
106// has to be performed (in MGeomApply).
107//
108MCalibrationRelTimeCam::MCalibrationRelTimeCam(const char *name, const char *title)
109{
110
111 fName = name ? name : "MCalibrationRelTimeCam";
112 fTitle = title ? title : "Container for Relative Time Calibration Information";
113
114 fPixels = new TClonesArray("MCalibrationRelTimePix",1);
115 fAverageAreas = new TClonesArray("MCalibrationRelTimePix",1);
116 fAverageSectors = new TClonesArray("MCalibrationRelTimePix",1);
117
118}
119
120// --------------------------------------------------------------------------
121//
122// Print first the well fitted pixels
123// and then the ones which are not Valid
124//
125void MCalibrationRelTimeCam::Print(Option_t *o) const
126{
127
128 *fLog << all << GetDescriptor() << ":" << endl;
129 int id = 0;
130
131 *fLog << all << "Calibrated pixels:" << endl;
132 *fLog << all << endl;
133
134 TIter Next(fPixels);
135 MCalibrationRelTimePix *pix;
136 while ((pix=(MCalibrationRelTimePix*)Next()))
137 {
138
139 if (!pix->IsExcluded())
140 {
141
142 *fLog << all
143 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Pix ",pix->GetPixId(),
144 ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
145 " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
146 << endl;
147 id++;
148 }
149 }
150
151 *fLog << all << id << " pixels" << endl;
152 id = 0;
153
154
155 *fLog << all << endl;
156 *fLog << all << "Excluded pixels:" << endl;
157 *fLog << all << endl;
158
159 id = 0;
160
161 TIter Next4(fPixels);
162 while ((pix=(MCalibrationRelTimePix*)Next4()))
163 {
164 if (pix->IsExcluded())
165 {
166 *fLog << all << pix->GetPixId() << endl;
167 id++;
168 }
169 }
170 *fLog << all << id << " Excluded pixels " << endl;
171 *fLog << endl;
172
173 TIter Next5(fAverageAreas);
174 while ((pix=(MCalibrationRelTimePix*)Next5()))
175 {
176 *fLog << all
177 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Area ",pix->GetPixId(),
178 ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
179 " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
180 << endl;
181 }
182
183 TIter Next6(fAverageSectors);
184 while ((pix=(MCalibrationRelTimePix*)Next5()))
185 {
186 *fLog << all
187 << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Sector ",pix->GetPixId(),
188 ": Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
189 " Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
190 << endl;
191 }
192}
193
194
195// --------------------------------------------------------------------------
196//
197// The types are as follows:
198//
199// Fitted values:
200// ==============
201//
202// 0: Fitted RelTime
203// 1: Error of fitted RelTime
204// 2: Sigma of fitted RelTime
205// 3: Error of Sigma of fitted RelTime
206//
207// Useful variables derived from the fit results:
208// =============================================
209//
210// 4: Returned probability of Gauss fit to RelTime distribution
211//
212Bool_t MCalibrationRelTimeCam::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 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*this)[idx];
224
225 switch (type)
226 {
227 case 0:
228 if (pix.IsExcluded())
229 return kFALSE;
230 val = pix.GetMean();
231 break;
232 case 1:
233 if (pix.IsExcluded())
234 return kFALSE;
235 val = pix.GetMeanErr();
236 break;
237 case 2:
238 if (pix.IsExcluded())
239 return kFALSE;
240 val = pix.GetSigma();
241 break;
242 case 3:
243 if (pix.IsExcluded())
244 return kFALSE;
245 val = pix.GetSigmaErr();
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
260// --------------------------------------------------------------------------
261//
262// Calls MCalibrationPix::DrawClone()
263//
264void MCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
265{
266 (*this)[idx].DrawClone();
267}
268
Note: See TracBrowser for help on using the repository browser.