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

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