source: trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc@ 5124

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