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 | // MCalibrationPix
|
---|
26 | //
|
---|
27 | // Base Storage container for a calibration pixel. Holds mean and sigmas,
|
---|
28 | // their errors, the fit probability and the number of pickup events for
|
---|
29 | // the high-gain and the low-gain derived values.
|
---|
30 | //
|
---|
31 | // Errors are stored internally as variances, but are returned and filled
|
---|
32 | // as square root of the variances.
|
---|
33 | //
|
---|
34 | // Calls to GetMean(), GetMeanErr(), GetSigma(), GetSigmaErr(), GetProb() or
|
---|
35 | // GetNumPickup() and GetNumBlackout() test first the bit kHiGainSaturation
|
---|
36 | // before returning the high-gain or low-gain value, analogue for the
|
---|
37 | // corr. Setters.
|
---|
38 | //
|
---|
39 | // The three flags: kValid, kExcluded and kHiGainSaturation may be set.
|
---|
40 | // The colors: kGREEN, kBLUE, kUV and kCT1 may be set.
|
---|
41 | //
|
---|
42 | /////////////////////////////////////////////////////////////////////////////
|
---|
43 | #include "MCalibrationPix.h"
|
---|
44 |
|
---|
45 | ClassImp(MCalibrationPix);
|
---|
46 |
|
---|
47 | using namespace std;
|
---|
48 |
|
---|
49 | // --------------------------------------------------------------------------
|
---|
50 | //
|
---|
51 | // Default Constructor:
|
---|
52 | //
|
---|
53 | // Sets:
|
---|
54 | // - fPixId to -1
|
---|
55 | // - fFlags to 0
|
---|
56 | //
|
---|
57 | // Calls:
|
---|
58 | // - Clear()
|
---|
59 | //
|
---|
60 | MCalibrationPix::MCalibrationPix(const char *name, const char *title)
|
---|
61 | : fPixId(-1),
|
---|
62 | fFlags(0)
|
---|
63 | {
|
---|
64 |
|
---|
65 | fName = name ? name : "MCalibrationPix";
|
---|
66 | fTitle = title ? title : "Container of the fit results of MHCalibrationPixs ";
|
---|
67 |
|
---|
68 | Clear();
|
---|
69 |
|
---|
70 | }
|
---|
71 |
|
---|
72 | // ------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | // Sets:
|
---|
75 | // - all variables to -1
|
---|
76 | // - all flags to kFALSE
|
---|
77 | //
|
---|
78 | void MCalibrationPix::Clear(Option_t *o)
|
---|
79 | {
|
---|
80 |
|
---|
81 | fHiGainNumBlackout = -1 ;
|
---|
82 | fHiGainNumPickup = -1 ;
|
---|
83 | fHiGainMean = -1.;
|
---|
84 | fHiGainMeanVar = -1.;
|
---|
85 | fHiGainProb = -1.;
|
---|
86 | fHiGainSigma = -1.;
|
---|
87 | fHiGainSigmaVar = -1.;
|
---|
88 |
|
---|
89 | fLoGainNumBlackout = -1 ;
|
---|
90 | fLoGainNumPickup = -1 ;
|
---|
91 | fLoGainMean = -1.;
|
---|
92 | fLoGainMeanVar = -1.;
|
---|
93 | fLoGainProb = -1.;
|
---|
94 | fLoGainSigma = -1.;
|
---|
95 | fLoGainSigmaVar = -1.;
|
---|
96 |
|
---|
97 | SetHiGainSaturation ( kFALSE );
|
---|
98 | SetExcluded ( kFALSE );
|
---|
99 | SetValid ( kFALSE );
|
---|
100 |
|
---|
101 | }
|
---|
102 |
|
---|
103 | // --------------------------------------------------------------------------
|
---|
104 | //
|
---|
105 | // Set the Hi Gain Saturation Bit from outside
|
---|
106 | //
|
---|
107 | void MCalibrationPix::SetHiGainSaturation(Bool_t b)
|
---|
108 | {
|
---|
109 | b ? SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation);
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | // --------------------------------------------------------------------------
|
---|
114 | //
|
---|
115 | // Set the Excluded Bit from outside
|
---|
116 | //
|
---|
117 | void MCalibrationPix::SetExcluded(Bool_t b )
|
---|
118 | {
|
---|
119 | b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
|
---|
120 | }
|
---|
121 |
|
---|
122 | // --------------------------------------------------------------------------
|
---|
123 | //
|
---|
124 | // Set the Valid Bit from outside
|
---|
125 | //
|
---|
126 | void MCalibrationPix::SetValid(Bool_t b )
|
---|
127 | {
|
---|
128 | b ? SETBIT(fFlags, kValid) : CLRBIT(fFlags, kValid);
|
---|
129 | }
|
---|
130 |
|
---|
131 |
|
---|
132 | // --------------------------------------------------------------------------
|
---|
133 | //
|
---|
134 | // Return -1, if IsHiGainSaturation()
|
---|
135 | // Return -1, if the LoGain Mean is zero or -1. (has not yet been set)
|
---|
136 | // Return -1, if the HiGain Mean is -1. (has not yet been set)
|
---|
137 | // Return fHiGainMean / fLoGainMean
|
---|
138 | //
|
---|
139 | Float_t MCalibrationPix::GetHiLoMeansDivided() const
|
---|
140 | {
|
---|
141 |
|
---|
142 | if (IsHiGainSaturation())
|
---|
143 | return -1.;
|
---|
144 |
|
---|
145 | if (fLoGainMean == 0. || fLoGainMean == -1.)
|
---|
146 | return -1.;
|
---|
147 |
|
---|
148 | if (fHiGainMean == -1.)
|
---|
149 | return -1.;
|
---|
150 |
|
---|
151 | return fHiGainMean / fLoGainMean;
|
---|
152 |
|
---|
153 | }
|
---|
154 |
|
---|
155 | // ----------------------------------------------------------------------------------
|
---|
156 | //
|
---|
157 | // Return -1, if IsHiGainSaturation()
|
---|
158 | // Return -1, if the LoGain Mean or its variance is zero or -1. (has not yet been set)
|
---|
159 | // Return -1, if the HiGain Mean or its variance is -1. (has not yet been set)
|
---|
160 | // Return propagated error of GetHiLoMeansDivided()
|
---|
161 | //
|
---|
162 | Float_t MCalibrationPix::GetHiLoMeansDividedErr() const
|
---|
163 | {
|
---|
164 |
|
---|
165 | if (IsHiGainSaturation())
|
---|
166 | return -1.;
|
---|
167 |
|
---|
168 | if (fLoGainMean == 0. || fLoGainMean == -1.)
|
---|
169 | return -1.;
|
---|
170 |
|
---|
171 | if (fHiGainMean == -1.)
|
---|
172 | return -1.;
|
---|
173 |
|
---|
174 | if (fLoGainMeanVar <= 0.)
|
---|
175 | return -1.;
|
---|
176 |
|
---|
177 | if (fHiGainMeanVar <= 0.)
|
---|
178 | return -1.;
|
---|
179 |
|
---|
180 | const Float_t lomeansquare = fLoGainMean * fLoGainMean;
|
---|
181 | const Float_t deltaHi = fHiGainMeanVar / lomeansquare;
|
---|
182 | const Float_t deltaLo = fLoGainMeanVar / (lomeansquare * lomeansquare) * fHiGainMean * fHiGainMean;
|
---|
183 |
|
---|
184 | return TMath::Sqrt(deltaHi + deltaLo);
|
---|
185 |
|
---|
186 | }
|
---|
187 |
|
---|
188 | // --------------------------------------------------------------------------
|
---|
189 | //
|
---|
190 | // Return -1, if IsHiGainSaturation()
|
---|
191 | // Return -1, if the LoGain Sigma is zero or -1. (has not yet been set)
|
---|
192 | // Return -1, if the HiGain Sigma is -1. (has not yet been set)
|
---|
193 | // Return fHiGainSigma / fLoGainSigma
|
---|
194 | //
|
---|
195 | Float_t MCalibrationPix::GetHiLoSigmasDivided() const
|
---|
196 | {
|
---|
197 |
|
---|
198 | if (IsHiGainSaturation())
|
---|
199 | return -1.;
|
---|
200 |
|
---|
201 | if (fLoGainSigma == 0. || fLoGainSigma == -1.)
|
---|
202 | return -1.;
|
---|
203 |
|
---|
204 | if (fHiGainSigma == -1.)
|
---|
205 | return -1.;
|
---|
206 |
|
---|
207 | return fHiGainSigma / fLoGainSigma;
|
---|
208 |
|
---|
209 | }
|
---|
210 |
|
---|
211 | // ----------------------------------------------------------------------------------
|
---|
212 | //
|
---|
213 | // Return -1, if IsHiGainSaturation()
|
---|
214 | // Return -1, if the LoGain Sigma or its variance is zero or -1. (has not yet been set)
|
---|
215 | // Return -1, if the HiGain Sigma or its variance is -1. (has not yet been set)
|
---|
216 | // Return propagated error of GetHiLoSigmasDivided()
|
---|
217 | //
|
---|
218 | Float_t MCalibrationPix::GetHiLoSigmasDividedErr() const
|
---|
219 | {
|
---|
220 |
|
---|
221 | if (IsHiGainSaturation())
|
---|
222 | return -1.;
|
---|
223 |
|
---|
224 | if (fLoGainSigma == 0. || fLoGainSigma == -1.)
|
---|
225 | return -1.;
|
---|
226 |
|
---|
227 | if (fHiGainSigma == -1.)
|
---|
228 | return -1.;
|
---|
229 |
|
---|
230 | if (fLoGainSigmaVar <= 0.)
|
---|
231 | return -1.;
|
---|
232 |
|
---|
233 | if (fHiGainSigmaVar <= 0.)
|
---|
234 | return -1.;
|
---|
235 |
|
---|
236 | const Float_t losigmasquare = fLoGainSigma * fLoGainSigma;
|
---|
237 | const Float_t deltaHi = fHiGainSigmaVar / losigmasquare;
|
---|
238 | const Float_t deltaLo = fLoGainSigmaVar / (losigmasquare * losigmasquare) * fHiGainSigma * fHiGainSigma;
|
---|
239 |
|
---|
240 | return TMath::Sqrt(deltaHi + deltaLo);
|
---|
241 |
|
---|
242 | }
|
---|
243 |
|
---|
244 |
|
---|
245 | // --------------------------------------------------------------------------
|
---|
246 | //
|
---|
247 | // Get the Relative Variance of either High Gain or Low Gain Mean
|
---|
248 | // depending on IsHighGainSaturation()
|
---|
249 | //
|
---|
250 | // If variance is smaller than 0. return -1.
|
---|
251 | //
|
---|
252 | Float_t MCalibrationPix::GetMeanRelVar() const
|
---|
253 | {
|
---|
254 |
|
---|
255 | if (IsHiGainSaturation())
|
---|
256 | if (fLoGainMeanVar < 0.)
|
---|
257 | return -1.;
|
---|
258 | else
|
---|
259 | return fLoGainMeanVar / (fLoGainMean * fLoGainMean);
|
---|
260 | else
|
---|
261 | if (fHiGainMeanVar < 0.)
|
---|
262 | return -1.;
|
---|
263 | else
|
---|
264 | return fHiGainMeanVar / (fHiGainMean * fHiGainMean);
|
---|
265 | }
|
---|
266 |
|
---|
267 | // --------------------------------------------------------------------------
|
---|
268 | //
|
---|
269 | // Get the Square of either High Gain or Low Gain Mean
|
---|
270 | // depending on IsHighGainSaturation()
|
---|
271 | //
|
---|
272 | Float_t MCalibrationPix::GetMeanSquare() const
|
---|
273 | {
|
---|
274 |
|
---|
275 | if (IsHiGainSaturation())
|
---|
276 | return fLoGainMean == -1. ? -1. : fLoGainMean * fLoGainMean;
|
---|
277 | else
|
---|
278 | return fHiGainMean == -1. ? -1. : fHiGainMean * fHiGainMean;
|
---|
279 | }
|
---|
280 |
|
---|
281 |
|
---|
282 | // --------------------------------------------------------------------------
|
---|
283 | //
|
---|
284 | // Get the Relative Variance of either High Gain or Low Gain Sigma
|
---|
285 | // depending on IsHighGainSaturation()
|
---|
286 | //
|
---|
287 | // If variance is smaller than 0. return -1.
|
---|
288 | //
|
---|
289 | Float_t MCalibrationPix::GetSigmaRelVar() const
|
---|
290 | {
|
---|
291 |
|
---|
292 | if (IsHiGainSaturation())
|
---|
293 | if (fLoGainSigmaVar < 0.)
|
---|
294 | return -1.;
|
---|
295 | else
|
---|
296 | return fLoGainSigmaVar / (fLoGainSigma * fLoGainSigma);
|
---|
297 | else
|
---|
298 | if (fHiGainSigmaVar < 0.)
|
---|
299 | return -1.;
|
---|
300 | else
|
---|
301 | return fHiGainSigmaVar / (fHiGainSigma * fHiGainSigma);
|
---|
302 | }
|
---|
303 |
|
---|
304 | // --------------------------------------------------------------------------
|
---|
305 | //
|
---|
306 | // Get the High Gain Mean Error: Takes square root of fHiGainMeanVar
|
---|
307 | //
|
---|
308 | Float_t MCalibrationPix::GetHiGainMeanErr() const
|
---|
309 | {
|
---|
310 | if (fLoGainMeanVar < 0.)
|
---|
311 | return -1.;
|
---|
312 |
|
---|
313 | return TMath::Sqrt(fLoGainMeanVar);
|
---|
314 | }
|
---|
315 |
|
---|
316 |
|
---|
317 | // --------------------------------------------------------------------------
|
---|
318 | //
|
---|
319 | // Get the High Gain Sigma Error: Takes square root of fHiGainSigmaVar
|
---|
320 | //
|
---|
321 | Float_t MCalibrationPix::GetHiGainSigmaErr() const
|
---|
322 | {
|
---|
323 | if (fHiGainSigmaVar < 0.)
|
---|
324 | return -1.;
|
---|
325 |
|
---|
326 | return TMath::Sqrt(fHiGainSigmaVar);
|
---|
327 | }
|
---|
328 |
|
---|
329 | // --------------------------------------------------------------------------
|
---|
330 | //
|
---|
331 | // Get the Low Gain Mean Error: Takes square root of fLoGainMeanVar
|
---|
332 | //
|
---|
333 | Float_t MCalibrationPix::GetLoGainMeanErr() const
|
---|
334 | {
|
---|
335 | if (fLoGainMeanVar < 0.)
|
---|
336 | return -1.;
|
---|
337 |
|
---|
338 | return TMath::Sqrt(fLoGainMeanVar);
|
---|
339 | }
|
---|
340 |
|
---|
341 | // --------------------------------------------------------------------------
|
---|
342 | //
|
---|
343 | // Get the Low Gain Mean Rel Variance
|
---|
344 | //
|
---|
345 | Float_t MCalibrationPix::GetLoGainMeanRelVar() const
|
---|
346 | {
|
---|
347 | if (fLoGainMeanVar < 0.)
|
---|
348 | return -1.;
|
---|
349 | if (fLoGainMean == 0.)
|
---|
350 | return -1.;
|
---|
351 |
|
---|
352 | return fLoGainMeanVar / ( fLoGainMean * fLoGainMean);
|
---|
353 | }
|
---|
354 |
|
---|
355 | // --------------------------------------------------------------------------
|
---|
356 | //
|
---|
357 | // Get the Low Gain Sigma Error: Takes square root of fHiGainSigmaVar
|
---|
358 | //
|
---|
359 | Float_t MCalibrationPix::GetLoGainSigmaErr() const
|
---|
360 | {
|
---|
361 | if (fLoGainSigmaVar < 0.)
|
---|
362 | return -1.;
|
---|
363 |
|
---|
364 | return TMath::Sqrt(fLoGainSigmaVar);
|
---|
365 | }
|
---|
366 |
|
---|
367 | // --------------------------------------------------------------------------
|
---|
368 | //
|
---|
369 | // Test bit kHiGainSaturation
|
---|
370 | //
|
---|
371 | Bool_t MCalibrationPix::IsHiGainSaturation() const
|
---|
372 | {
|
---|
373 | return TESTBIT(fFlags,kHiGainSaturation);
|
---|
374 | }
|
---|
375 |
|
---|
376 | // --------------------------------------------------------------------------
|
---|
377 | //
|
---|
378 | // Test bit kExcluded
|
---|
379 | //
|
---|
380 | Bool_t MCalibrationPix::IsExcluded() const
|
---|
381 | {
|
---|
382 | return TESTBIT(fFlags,kExcluded);
|
---|
383 | }
|
---|
384 |
|
---|
385 | // --------------------------------------------------------------------------
|
---|
386 | //
|
---|
387 | // Test bit kValid
|
---|
388 | //
|
---|
389 | Bool_t MCalibrationPix::IsValid() const
|
---|
390 | {
|
---|
391 | return TESTBIT(fFlags,kValid);
|
---|
392 | }
|
---|
393 |
|
---|