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 | // MCalibrationHiLoCam
|
---|
28 | //
|
---|
29 | // Storage container for ratio between higain and logain charge extraction
|
---|
30 | // calibration results of the whole camera.
|
---|
31 | //
|
---|
32 | // Individual pixels have to be cast when retrieved e.g.:
|
---|
33 | // MCalibrationHiLoPix &avpix = (MCalibrationHiLoPix&)(*fHiLoCam)[i]
|
---|
34 | //
|
---|
35 | // The following "calibration" constants can be retrieved from each pixel:
|
---|
36 | // - GetHiLoRatio(): The mean signal ratio between high-gain and low-gain
|
---|
37 | // - GetHiLoRatioErr(): The Gauss sigma of histogrammed signal ratios
|
---|
38 | //
|
---|
39 | // Averaged values over one whole area index (e.g. inner or outer pixels for
|
---|
40 | // the MAGIC camera), can be retrieved via:
|
---|
41 | // MCalibrationHiLoPix &avpix = (MCalibrationHiLoPix&)fRelCam->GetAverageArea(i)
|
---|
42 | //
|
---|
43 | // Averaged values over one whole camera sector can be retrieved via:
|
---|
44 | // MCalibrationHiLoPix &avpix = (MCalibrationHiLoPix&)fRelCam->GetAverageSector(i)
|
---|
45 | //
|
---|
46 | // Note the averageing has been done on an event-by-event basis. Resulting
|
---|
47 | // Sigma's of the Gauss fit have been multiplied with the square root of the number
|
---|
48 | // of involved pixels in order to make a direct comparison possible with the mean of
|
---|
49 | // sigmas.
|
---|
50 | //
|
---|
51 | // See also: MHCalibrationHiLoPix, MHCalibrationHiLoCam
|
---|
52 | //
|
---|
53 | // The calculated values (types of GetPixelContent) are:
|
---|
54 | //
|
---|
55 | // Fitted values:
|
---|
56 | // ==============
|
---|
57 | //
|
---|
58 | // 0: HiLo Ratio
|
---|
59 | // 1: Error of HiLo Ratio
|
---|
60 | // 2: Sigma of HiLo Ratio == Resolution
|
---|
61 | // 3: Error of Sigma of HiLo Ratio
|
---|
62 | //
|
---|
63 | // Useful variables derived from the fit results:
|
---|
64 | // =============================================
|
---|
65 | //
|
---|
66 | // 4: Returned probability of Gauss fit to distribution
|
---|
67 | //
|
---|
68 | /////////////////////////////////////////////////////////////////////////////
|
---|
69 | #include "MCalibrationHiLoCam.h"
|
---|
70 | #include "MCalibrationCam.h"
|
---|
71 |
|
---|
72 | #include <TOrdCollection.h>
|
---|
73 |
|
---|
74 | #include "MLog.h"
|
---|
75 | #include "MLogManip.h"
|
---|
76 |
|
---|
77 | #include "MGeomCam.h"
|
---|
78 | #include "MGeomPix.h"
|
---|
79 |
|
---|
80 | #include "MCalibrationHiLoPix.h"
|
---|
81 |
|
---|
82 | ClassImp(MCalibrationHiLoCam);
|
---|
83 |
|
---|
84 | using namespace std;
|
---|
85 |
|
---|
86 | // --------------------------------------------------------------------------
|
---|
87 | //
|
---|
88 | // Default constructor.
|
---|
89 | //
|
---|
90 | MCalibrationHiLoCam::MCalibrationHiLoCam(const char *name, const char *title)
|
---|
91 | {
|
---|
92 |
|
---|
93 | fName = name ? name : "MCalibrationHiLoCam";
|
---|
94 | fTitle = title ? title : "Container for High Gain vs. Low Gain amplification ratio";
|
---|
95 |
|
---|
96 | }
|
---|
97 |
|
---|
98 | void MCalibrationHiLoCam::Add(const UInt_t a, const UInt_t b)
|
---|
99 | {
|
---|
100 | for (UInt_t i=a; i<b; i++)
|
---|
101 | fPixels->AddAt(new MCalibrationHiLoPix,i);
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | void MCalibrationHiLoCam::AddArea(const UInt_t a, const UInt_t b)
|
---|
106 | {
|
---|
107 | for (UInt_t i=a; i<b; i++)
|
---|
108 | fAverageAreas->AddAt(new MCalibrationHiLoPix,i);
|
---|
109 | }
|
---|
110 |
|
---|
111 | void MCalibrationHiLoCam::AddSector(const UInt_t a, const UInt_t b)
|
---|
112 | {
|
---|
113 | for (UInt_t i=a; i<b; i++)
|
---|
114 | fAverageSectors->AddAt(new MCalibrationHiLoPix,i);
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MCalibrationHiLoCam::PrintPix(const MCalibrationHiLoPix &pix, const char *type) const
|
---|
118 | {
|
---|
119 | *fLog << all << setw(7) << type << Form("%4i", pix.GetPixId()) << ": ";
|
---|
120 | *fLog << " Ratio: " << Form("%4.2f", pix.GetHiLoChargeRatio());
|
---|
121 | *fLog << " +- " << Form("%4.2f", pix.GetHiLoChargeRatioErr());
|
---|
122 | *fLog << " Sigma: " << Form("%4.2f", pix.GetHiLoChargeRatioSigma());
|
---|
123 | *fLog << " +- " << Form("%4.2f", pix.GetHiLoChargeRatioSigmaErr());
|
---|
124 | *fLog << endl;
|
---|
125 | }
|
---|
126 |
|
---|
127 | // --------------------------------------------------------------------------
|
---|
128 | //
|
---|
129 | // Print first the well fitted pixels
|
---|
130 | // and then the ones which are not Valid
|
---|
131 | //
|
---|
132 | void MCalibrationHiLoCam::Print(Option_t *o) const
|
---|
133 | {
|
---|
134 |
|
---|
135 | *fLog << all << GetDescriptor() << ":" << endl;
|
---|
136 | int id = 0;
|
---|
137 |
|
---|
138 | *fLog << all << "Calibrated pixels:" << endl;
|
---|
139 | *fLog << all << endl;
|
---|
140 |
|
---|
141 | TIter Next(fPixels);
|
---|
142 | MCalibrationHiLoPix *pix;
|
---|
143 | while ((pix=(MCalibrationHiLoPix*)Next()))
|
---|
144 | if (!pix->IsExcluded())
|
---|
145 | {
|
---|
146 | PrintPix(*pix, "Pixel");
|
---|
147 | id++;
|
---|
148 | }
|
---|
149 |
|
---|
150 | *fLog << all << id << " pixels" << endl;
|
---|
151 | id = 0;
|
---|
152 |
|
---|
153 |
|
---|
154 | *fLog << all << endl;
|
---|
155 | *fLog << all << "Excluded pixels:" << endl;
|
---|
156 | *fLog << all << endl;
|
---|
157 |
|
---|
158 | id = 0;
|
---|
159 |
|
---|
160 | TIter Next4(fPixels);
|
---|
161 | while ((pix=(MCalibrationHiLoPix*)Next4()))
|
---|
162 | {
|
---|
163 | if (pix->IsExcluded())
|
---|
164 | {
|
---|
165 | *fLog << all << pix->GetPixId() << endl;
|
---|
166 | id++;
|
---|
167 | }
|
---|
168 | }
|
---|
169 | *fLog << all << id << " Excluded pixels " << endl;
|
---|
170 | *fLog << endl;
|
---|
171 |
|
---|
172 | TIter Next5(fAverageAreas);
|
---|
173 | while ((pix=(MCalibrationHiLoPix*)Next5()))
|
---|
174 | PrintPix(*pix, "Area");
|
---|
175 |
|
---|
176 | TIter Next6(fAverageSectors);
|
---|
177 | while ((pix=(MCalibrationHiLoPix*)Next5()))
|
---|
178 | PrintPix(*pix, "Sector");
|
---|
179 | }
|
---|
180 |
|
---|
181 |
|
---|
182 | // --------------------------------------------------------------------------
|
---|
183 | //
|
---|
184 | // The types are as follows:
|
---|
185 | //
|
---|
186 | // Fitted values:
|
---|
187 | // ==============
|
---|
188 | //
|
---|
189 | // 0: Fitted HiLo
|
---|
190 | // 1: Error of fitted HiLo
|
---|
191 | // 2: Sigma of fitted HiLo
|
---|
192 | // 3: Error of Sigma of fitted HiLo
|
---|
193 | //
|
---|
194 | // Useful variables derived from the fit results:
|
---|
195 | // =============================================
|
---|
196 | //
|
---|
197 | // 4: Returned probability of Gauss fit to HiLo distribution
|
---|
198 | //
|
---|
199 | Bool_t MCalibrationHiLoCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
200 | {
|
---|
201 |
|
---|
202 | if (idx > GetSize())
|
---|
203 | return kFALSE;
|
---|
204 |
|
---|
205 | Float_t area = cam[idx].GetA();
|
---|
206 |
|
---|
207 | if (area == 0)
|
---|
208 | return kFALSE;
|
---|
209 |
|
---|
210 | MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)(*this)[idx];
|
---|
211 |
|
---|
212 | switch (type)
|
---|
213 | {
|
---|
214 | case 0:
|
---|
215 | if (pix.IsExcluded())
|
---|
216 | return kFALSE;
|
---|
217 | val = pix.GetHiLoChargeRatio();
|
---|
218 | break;
|
---|
219 | case 1:
|
---|
220 | if (pix.IsExcluded())
|
---|
221 | return kFALSE;
|
---|
222 | val = pix.GetHiLoChargeRatioErr();
|
---|
223 | break;
|
---|
224 | case 2:
|
---|
225 | if (pix.IsExcluded())
|
---|
226 | return kFALSE;
|
---|
227 | val = pix.GetHiLoChargeRatioSigma();
|
---|
228 | break;
|
---|
229 | case 3:
|
---|
230 | if (pix.IsExcluded())
|
---|
231 | return kFALSE;
|
---|
232 | val = pix.GetHiLoChargeRatioSigmaErr();
|
---|
233 | break;
|
---|
234 | case 4:
|
---|
235 | if (pix.IsExcluded())
|
---|
236 | return kFALSE;
|
---|
237 | val = pix.GetHiLoChargeRatioProb();
|
---|
238 | break;
|
---|
239 | case 5:
|
---|
240 | if (pix.IsExcluded())
|
---|
241 | return kFALSE;
|
---|
242 | val = pix.GetHiLoTimeDiff();
|
---|
243 | break;
|
---|
244 | case 6:
|
---|
245 | if (pix.IsExcluded())
|
---|
246 | return kFALSE;
|
---|
247 | val = pix.GetHiLoTimeDiffErr();
|
---|
248 | break;
|
---|
249 | case 7:
|
---|
250 | if (pix.IsExcluded())
|
---|
251 | return kFALSE;
|
---|
252 | val = pix.GetHiLoTimeDiffSigma();
|
---|
253 | break;
|
---|
254 | case 8:
|
---|
255 | if (pix.IsExcluded())
|
---|
256 | return kFALSE;
|
---|
257 | val = pix.GetHiLoTimeDiffSigmaErr();
|
---|
258 | break;
|
---|
259 | case 9:
|
---|
260 | if (pix.IsExcluded())
|
---|
261 | return kFALSE;
|
---|
262 | val = pix.GetHiLoTimeDiffProb();
|
---|
263 | break;
|
---|
264 | default:
|
---|
265 | return kFALSE;
|
---|
266 | }
|
---|
267 |
|
---|
268 | return val!=-1.;
|
---|
269 |
|
---|
270 | }
|
---|
271 |
|
---|