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 <TOrdCollection.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 |
|
---|
88 | ClassImp(MCalibrationRelTimeCam);
|
---|
89 |
|
---|
90 | using namespace std;
|
---|
91 |
|
---|
92 | // --------------------------------------------------------------------------
|
---|
93 | //
|
---|
94 | // Default constructor.
|
---|
95 | //
|
---|
96 | MCalibrationRelTimeCam::MCalibrationRelTimeCam(const char *name, const char *title)
|
---|
97 | {
|
---|
98 |
|
---|
99 | fName = name ? name : "MCalibrationRelTimeCam";
|
---|
100 | fTitle = title ? title : "Container for Relative Time Calibration Information";
|
---|
101 |
|
---|
102 | }
|
---|
103 |
|
---|
104 | void MCalibrationRelTimeCam::Add(const UInt_t a, const UInt_t b)
|
---|
105 | {
|
---|
106 | for (UInt_t i=a; i<b; i++)
|
---|
107 | fPixels->AddAt(new MCalibrationRelTimePix,i);
|
---|
108 | }
|
---|
109 |
|
---|
110 |
|
---|
111 | void MCalibrationRelTimeCam::AddArea(const UInt_t a, const UInt_t b)
|
---|
112 | {
|
---|
113 | for (UInt_t i=a; i<b; i++)
|
---|
114 | fAverageAreas->AddAt(new MCalibrationRelTimePix,i);
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MCalibrationRelTimeCam::AddSector(const UInt_t a, const UInt_t b)
|
---|
118 | {
|
---|
119 | for (UInt_t i=a; i<b; i++)
|
---|
120 | fAverageSectors->AddAt(new MCalibrationRelTimePix,i);
|
---|
121 | }
|
---|
122 |
|
---|
123 | // --------------------------------------------------------------------------
|
---|
124 | //
|
---|
125 | // Print first the well fitted pixels
|
---|
126 | // and then the ones which are not Valid
|
---|
127 | //
|
---|
128 | void MCalibrationRelTimeCam::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 | MCalibrationRelTimePix *pix;
|
---|
139 | while ((pix=(MCalibrationRelTimePix*)Next()))
|
---|
140 | {
|
---|
141 | if (!pix->IsExcluded())
|
---|
142 | {
|
---|
143 | *fLog << all
|
---|
144 | << "Pix " << Form("%4i", pix->GetPixId()) << ": "
|
---|
145 | << " Offset: "
|
---|
146 | << Form("%4.2f +- %4,2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr())
|
---|
147 | << " Precision: "
|
---|
148 | << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr())
|
---|
149 | << endl;
|
---|
150 | id++;
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | *fLog << all << id << " pixels" << endl;
|
---|
155 | id = 0;
|
---|
156 |
|
---|
157 |
|
---|
158 | *fLog << all << endl;
|
---|
159 | *fLog << all << "Excluded pixels:" << endl;
|
---|
160 | *fLog << all << endl;
|
---|
161 |
|
---|
162 | id = 0;
|
---|
163 |
|
---|
164 | TIter Next4(fPixels);
|
---|
165 | while ((pix=(MCalibrationRelTimePix*)Next4()))
|
---|
166 | {
|
---|
167 | if (pix->IsExcluded())
|
---|
168 | {
|
---|
169 | *fLog << all << pix->GetPixId() << endl;
|
---|
170 | id++;
|
---|
171 | }
|
---|
172 | }
|
---|
173 | *fLog << all << id << " Excluded pixels " << endl;
|
---|
174 | *fLog << endl;
|
---|
175 |
|
---|
176 | TIter Next5(fAverageAreas);
|
---|
177 | while ((pix=(MCalibrationRelTimePix*)Next5()))
|
---|
178 | {
|
---|
179 | *fLog << all
|
---|
180 | << "Average Area " << Form("%4i", pix->GetPixId()) << ":"
|
---|
181 | << "Offset: "
|
---|
182 | << Form("%4.2f +- %4,2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr())
|
---|
183 | << " Precision: "
|
---|
184 | << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr())
|
---|
185 | << endl;
|
---|
186 | }
|
---|
187 |
|
---|
188 | TIter Next6(fAverageSectors);
|
---|
189 | while ((pix=(MCalibrationRelTimePix*)Next5()))
|
---|
190 | {
|
---|
191 | *fLog << all
|
---|
192 | << "Average Sector " << Form("%4i", pix->GetPixId()) << ":"
|
---|
193 | << "Offset: "
|
---|
194 | << Form("%4.2f +- %4.2f", pix->GetTimeOffset(), pix->GetTimeOffsetErr())
|
---|
195 | << " Precision: "
|
---|
196 | << Form("%4.2f +- %4.2f", pix->GetTimePrecision(), pix->GetTimePrecisionErr())
|
---|
197 | << endl;
|
---|
198 | }
|
---|
199 | }
|
---|
200 |
|
---|
201 |
|
---|
202 | // --------------------------------------------------------------------------
|
---|
203 | //
|
---|
204 | // The types are as follows:
|
---|
205 | //
|
---|
206 | // Fitted values:
|
---|
207 | // ==============
|
---|
208 | //
|
---|
209 | // 0: Fitted RelTime
|
---|
210 | // 1: Error of fitted RelTime
|
---|
211 | // 2: Sigma of fitted RelTime
|
---|
212 | // 3: Error of Sigma of fitted RelTime
|
---|
213 | //
|
---|
214 | // Useful variables derived from the fit results:
|
---|
215 | // =============================================
|
---|
216 | //
|
---|
217 | // 4: Returned probability of Gauss fit to RelTime distribution
|
---|
218 | //
|
---|
219 | Bool_t MCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
220 | {
|
---|
221 |
|
---|
222 | if (idx > GetSize())
|
---|
223 | return kFALSE;
|
---|
224 |
|
---|
225 | Float_t area = cam[idx].GetA();
|
---|
226 |
|
---|
227 | if (area == 0)
|
---|
228 | return kFALSE;
|
---|
229 |
|
---|
230 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*this)[idx];
|
---|
231 |
|
---|
232 | switch (type)
|
---|
233 | {
|
---|
234 | case 0:
|
---|
235 | if (pix.IsExcluded())
|
---|
236 | return kFALSE;
|
---|
237 | val = pix.GetMean();
|
---|
238 | return val!=-1.;
|
---|
239 | case 1:
|
---|
240 | if (pix.IsExcluded())
|
---|
241 | return kFALSE;
|
---|
242 | val = pix.GetMeanErr();
|
---|
243 | break;
|
---|
244 | case 2:
|
---|
245 | if (pix.IsExcluded())
|
---|
246 | return kFALSE;
|
---|
247 | val = pix.GetSigma();
|
---|
248 | break;
|
---|
249 | case 3:
|
---|
250 | if (pix.IsExcluded())
|
---|
251 | return kFALSE;
|
---|
252 | val = pix.GetSigmaErr();
|
---|
253 | break;
|
---|
254 | case 4:
|
---|
255 | if (pix.IsExcluded())
|
---|
256 | return kFALSE;
|
---|
257 | val = pix.GetProb();
|
---|
258 | break;
|
---|
259 | default:
|
---|
260 | return kFALSE;
|
---|
261 | }
|
---|
262 |
|
---|
263 | return val>=0;
|
---|
264 |
|
---|
265 | }
|
---|
266 |
|
---|