source: tags/Mars-V1.2/mcalib/MCalibrationPix.cc

Last change on this file was 5916, checked in by mazin, 20 years ago
*** empty log message ***
File size: 12.0 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 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
45ClassImp(MCalibrationPix);
46
47using 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//
60MCalibrationPix::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//
78void MCalibrationPix::Clear(Option_t *o)
79{
80
81 fHiGainNumBlackout = -1 ;
82 fHiGainNumPickup = -1 ;
83 fHiGainMean = -1.;
84 fHiGainMeanVar = -1.;
85 fHiGainProb = -1.;
86 fHiGainRms = -1.;
87 fHiGainSigma = -1.;
88 fHiGainSigmaVar = -1.;
89
90 fLoGainNumBlackout = -1 ;
91 fLoGainNumPickup = -1 ;
92 fLoGainMean = -1.;
93 fLoGainMeanVar = -1.;
94 fLoGainProb = -1.;
95 fLoGainRms = -1.;
96 fLoGainSigma = -1.;
97 fLoGainSigmaVar = -1.;
98
99 SetHiGainSaturation ( kFALSE );
100 SetExcluded ( kFALSE );
101 SetValid ( kFALSE );
102 SetDebug ( kFALSE );
103
104}
105
106
107// -----------------------------------------------------
108//
109// copy 'constructor'
110//
111void MCalibrationPix::Copy(TObject& object) const
112{
113
114 MCalibrationPix &pix = (MCalibrationPix&)object;
115
116 //
117 // Copy the data members
118 //
119 pix.fPixId = fPixId;
120 pix.fFlags = fFlags;
121 pix.fHiGainMean = fHiGainMean;
122 pix.fHiGainMeanVar = fHiGainMeanVar;
123 pix.fHiGainNumBlackout = fHiGainNumBlackout;
124 pix.fHiGainNumPickup = fHiGainNumPickup;
125 pix.fHiGainSigma = fHiGainSigma;
126 pix.fHiGainSigmaVar = fHiGainSigmaVar;
127 pix.fHiGainProb = fHiGainProb;
128 pix.fLoGainMean = fLoGainMean;
129 pix.fLoGainMeanVar = fLoGainMeanVar;
130 pix.fLoGainNumBlackout = fLoGainNumBlackout;
131 pix.fLoGainNumPickup = fLoGainNumPickup;
132 pix.fLoGainSigma = fLoGainSigma;
133 pix.fLoGainSigmaVar = fLoGainSigmaVar;
134 pix.fLoGainProb = fLoGainProb;
135
136}
137
138
139// --------------------------------------------------------------------------
140//
141// Set the Hi Gain Saturation Bit from outside
142//
143void MCalibrationPix::SetHiGainSaturation(Bool_t b)
144{
145 b ? SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation);
146}
147
148// --------------------------------------------------------------------------
149//
150// Set the Valid Bit from outside
151//
152void MCalibrationPix::SetDebug(Bool_t b )
153{
154 b ? SETBIT(fFlags, kDebug) : CLRBIT(fFlags, kDebug);
155}
156
157// --------------------------------------------------------------------------
158//
159// Set the Excluded Bit from outside
160//
161void MCalibrationPix::SetExcluded(Bool_t b )
162{
163 b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
164}
165
166// --------------------------------------------------------------------------
167//
168// Set the Valid Bit from outside
169//
170void MCalibrationPix::SetValid(Bool_t b )
171{
172 b ? SETBIT(fFlags, kValid) : CLRBIT(fFlags, kValid);
173}
174
175
176// --------------------------------------------------------------------------
177//
178// Return -1, if IsHiGainSaturation()
179// Return -1, if the LoGain Mean is smaller than 0.5
180// Return -1, if the HiGain Mean is -1. (has not yet been set)
181// Return fHiGainMean / fLoGainMean
182//
183Float_t MCalibrationPix::GetHiLoMeansDivided() const
184{
185
186 if (IsHiGainSaturation())
187 return -1.;
188
189 if (fLoGainMean <= 0.5)
190 return -1.;
191
192 if (fHiGainMean == -1.)
193 return -1.;
194
195 return fHiGainMean / fLoGainMean;
196
197}
198
199// ----------------------------------------------------------------------------------
200//
201// Return -1, if IsHiGainSaturation()
202// Return -1, if the LoGain Mean or its variance is smaller than 0.5 (has not yet been set)
203// Return -1, if the HiGain Mean or its variance is -1. (has not yet been set)
204// Return propagated error of GetHiLoMeansDivided()
205//
206Float_t MCalibrationPix::GetHiLoMeansDividedErr() const
207{
208
209 if (IsHiGainSaturation())
210 return -1.;
211
212 if (fLoGainMean <= 0.5)
213 return -1.;
214
215 if (fHiGainMean == -1.)
216 return -1.;
217
218 if (fLoGainMeanVar <= 0.)
219 return -1.;
220
221 if (fHiGainMeanVar <= 0.)
222 return -1.;
223
224 const Float_t lomeansquare = fLoGainMean * fLoGainMean;
225 const Float_t deltaHi = fHiGainMeanVar / lomeansquare;
226 const Float_t deltaLo = fLoGainMeanVar / (lomeansquare * lomeansquare) * fHiGainMean * fHiGainMean;
227
228 return TMath::Sqrt(deltaHi + deltaLo);
229
230}
231
232// --------------------------------------------------------------------------
233//
234// Return -1, if IsHiGainSaturation()
235// Return -1, if the LoGain Sigma is smaller than 0.01
236// Return -1, if the HiGain Sigma is -1. (has not yet been set)
237// Return fHiGainSigma / fLoGainSigma
238//
239Float_t MCalibrationPix::GetHiLoSigmasDivided() const
240{
241
242 if (IsHiGainSaturation())
243 return -1.;
244
245 if (fLoGainSigma <= 0.01)
246 return -1.;
247
248 if (fHiGainSigma == -1.)
249 return -1.;
250
251 return fHiGainSigma / fLoGainSigma;
252
253}
254
255// ----------------------------------------------------------------------------------
256//
257// Return -1, if IsHiGainSaturation()
258// Return -1, if the LoGain Sigma variance is smaller than 0.
259// Return -1, if the LoGain Sigma is smaller than 0.01
260// Return -1, if the HiGain Sigma or its variance is -1. (has not yet been set)
261// Return propagated error of GetHiLoSigmasDivided()
262//
263Float_t MCalibrationPix::GetHiLoSigmasDividedErr() const
264{
265
266 if (IsHiGainSaturation())
267 return -1.;
268
269 if (fLoGainSigma <= 0.01)
270 return -1.;
271
272 if (fHiGainSigma == -1.)
273 return -1.;
274
275 if (fLoGainSigmaVar <= 0.)
276 return -1.;
277
278 if (fHiGainSigmaVar <= 0.)
279 return -1.;
280
281 const Float_t losigmasquare = fLoGainSigma * fLoGainSigma;
282 const Float_t deltaHi = fHiGainSigmaVar / losigmasquare;
283 const Float_t deltaLo = fLoGainSigmaVar / (losigmasquare * losigmasquare) * fHiGainSigma * fHiGainSigma;
284
285 return TMath::Sqrt(deltaHi + deltaLo);
286
287}
288
289
290// --------------------------------------------------------------------------
291//
292// Get the Relative Variance of either High Gain or Low Gain Mean
293// depending on IsHighGainSaturation()
294//
295// If variance is smaller than 0. return -1.
296//
297Float_t MCalibrationPix::GetMeanRelVar() const
298{
299
300 if (IsHiGainSaturation())
301 if (fLoGainMeanVar < 0. || fLoGainMean < 0.)
302 return -1.;
303 else
304 return fLoGainMeanVar / (fLoGainMean * fLoGainMean);
305 else
306 if (fHiGainMeanVar < 0. || fHiGainMean < 0.)
307 return -1.;
308 else
309 return fHiGainMeanVar / (fHiGainMean * fHiGainMean);
310}
311
312// --------------------------------------------------------------------------
313//
314// Get the Square of either High Gain or Low Gain Mean
315// depending on IsHighGainSaturation()
316//
317Float_t MCalibrationPix::GetMeanSquare() const
318{
319
320 if (IsHiGainSaturation())
321 return fLoGainMean == -1. ? -1. : fLoGainMean * fLoGainMean;
322 else
323 return fHiGainMean == -1. ? -1. : fHiGainMean * fHiGainMean;
324}
325
326
327// --------------------------------------------------------------------------
328//
329// Get the Relative Variance of either High Gain or Low Gain Sigma
330// depending on IsHighGainSaturation()
331//
332// If variance is smaller than 0. return -1.
333//
334Float_t MCalibrationPix::GetSigmaRelVar() const
335{
336
337 if (IsHiGainSaturation())
338 if (fLoGainSigmaVar < 0.)
339 return -1.;
340 else
341 return fLoGainSigmaVar / (fLoGainSigma * fLoGainSigma);
342 else
343 if (fHiGainSigmaVar < 0.)
344 return -1.;
345 else
346 return fHiGainSigmaVar / (fHiGainSigma * fHiGainSigma);
347}
348
349// --------------------------------------------------------------------------
350//
351// Get the High Gain Mean Error: Takes square root of fHiGainMeanVar
352//
353Float_t MCalibrationPix::GetHiGainMeanErr() const
354{
355 if (fHiGainMeanVar < 0.)
356 return -1.;
357
358 return TMath::Sqrt(fHiGainMeanVar);
359}
360
361
362// --------------------------------------------------------------------------
363//
364// Get the High Gain Sigma Error: Takes square root of fHiGainSigmaVar
365//
366Float_t MCalibrationPix::GetHiGainSigmaErr() const
367{
368 if (fHiGainSigmaVar < 0.)
369 return -1.;
370
371 return TMath::Sqrt(fHiGainSigmaVar);
372}
373
374// --------------------------------------------------------------------------
375//
376// Get the Low Gain Mean Error: Takes square root of fLoGainMeanVar
377//
378Float_t MCalibrationPix::GetLoGainMeanErr() const
379{
380 if (fLoGainMeanVar < 0.)
381 return -1.;
382
383 return TMath::Sqrt(fLoGainMeanVar);
384}
385
386// --------------------------------------------------------------------------
387//
388// Get the Low Gain Mean Rel Variance
389//
390Float_t MCalibrationPix::GetLoGainMeanRelVar() const
391{
392 if (fLoGainMeanVar < 0.)
393 return -1.;
394 if (fLoGainMean == 0.)
395 return -1.;
396
397 return fLoGainMeanVar / ( fLoGainMean * fLoGainMean);
398}
399
400// --------------------------------------------------------------------------
401//
402// Get the High Gain Mean Rel Variance
403//
404Float_t MCalibrationPix::GetHiGainMeanRelVar() const
405{
406 if (fHiGainMeanVar < 0.)
407 return -1.;
408 if (fHiGainMean == 0.)
409 return -1.;
410
411 return fHiGainMeanVar / ( fHiGainMean * fHiGainMean);
412}
413
414// --------------------------------------------------------------------------
415//
416// Get the Low Gain Sigma Error: Takes square root of fHiGainSigmaVar
417//
418Float_t MCalibrationPix::GetLoGainSigmaErr() const
419{
420 if (fLoGainSigmaVar < 0.)
421 return -1.;
422
423 return TMath::Sqrt(fLoGainSigmaVar);
424}
425
426// --------------------------------------------------------------------------
427//
428// Test bit kHiGainSaturation
429//
430Bool_t MCalibrationPix::IsHiGainSaturation() const
431{
432 return TESTBIT(fFlags,kHiGainSaturation);
433}
434
435// --------------------------------------------------------------------------
436//
437// Test bit kDebug
438//
439Bool_t MCalibrationPix::IsDebug() const
440{
441 return TESTBIT(fFlags,kDebug);
442}
443
444// --------------------------------------------------------------------------
445//
446// Test bit kExcluded
447//
448Bool_t MCalibrationPix::IsExcluded() const
449{
450 return TESTBIT(fFlags,kExcluded);
451}
452
453// --------------------------------------------------------------------------
454//
455// Test bit kValid
456//
457Bool_t MCalibrationPix::IsValid() const
458{
459 return TESTBIT(fFlags,kValid);
460}
461
Note: See TracBrowser for help on using the repository browser.