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

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