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

Last change on this file since 4042 was 3828, checked in by moralejo, 21 years ago
*** empty log message ***
File size: 10.3 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 IsHiGainSaturation()
135// Return -1, if the LoGain Mean is smaller than 0.5
136// Return -1, if the HiGain Mean is -1. (has not yet been set)
137// Return fHiGainMean / fLoGainMean
138//
139Float_t MCalibrationPix::GetHiLoMeansDivided() const
140{
141
142 if (IsHiGainSaturation())
143 return -1.;
144
145 if (fLoGainMean <= 0.5)
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 smaller than 0.5 (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//
162Float_t MCalibrationPix::GetHiLoMeansDividedErr() const
163{
164
165 if (IsHiGainSaturation())
166 return -1.;
167
168 if (fLoGainMean <= 0.5)
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 smaller than 0.01
192// Return -1, if the HiGain Sigma is -1. (has not yet been set)
193// Return fHiGainSigma / fLoGainSigma
194//
195Float_t MCalibrationPix::GetHiLoSigmasDivided() const
196{
197
198 if (IsHiGainSaturation())
199 return -1.;
200
201 if (fLoGainSigma <= 0.01)
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 variance is smaller than 0.
215// Return -1, if the LoGain Sigma is smaller than 0.01
216// Return -1, if the HiGain Sigma or its variance is -1. (has not yet been set)
217// Return propagated error of GetHiLoSigmasDivided()
218//
219Float_t MCalibrationPix::GetHiLoSigmasDividedErr() const
220{
221
222 if (IsHiGainSaturation())
223 return -1.;
224
225 if (fLoGainSigma <= 0.01)
226 return -1.;
227
228 if (fHiGainSigma == -1.)
229 return -1.;
230
231 if (fLoGainSigmaVar <= 0.)
232 return -1.;
233
234 if (fHiGainSigmaVar <= 0.)
235 return -1.;
236
237 const Float_t losigmasquare = fLoGainSigma * fLoGainSigma;
238 const Float_t deltaHi = fHiGainSigmaVar / losigmasquare;
239 const Float_t deltaLo = fLoGainSigmaVar / (losigmasquare * losigmasquare) * fHiGainSigma * fHiGainSigma;
240
241 return TMath::Sqrt(deltaHi + deltaLo);
242
243}
244
245
246// --------------------------------------------------------------------------
247//
248// Get the Relative Variance of either High Gain or Low Gain Mean
249// depending on IsHighGainSaturation()
250//
251// If variance is smaller than 0. return -1.
252//
253Float_t MCalibrationPix::GetMeanRelVar() const
254{
255
256 if (IsHiGainSaturation())
257 if (fLoGainMeanVar < 0.)
258 return -1.;
259 else
260 return fLoGainMeanVar / (fLoGainMean * fLoGainMean);
261 else
262 if (fHiGainMeanVar < 0.)
263 return -1.;
264 else
265 return fHiGainMeanVar / (fHiGainMean * fHiGainMean);
266}
267
268// --------------------------------------------------------------------------
269//
270// Get the Square of either High Gain or Low Gain Mean
271// depending on IsHighGainSaturation()
272//
273Float_t MCalibrationPix::GetMeanSquare() const
274{
275
276 if (IsHiGainSaturation())
277 return fLoGainMean == -1. ? -1. : fLoGainMean * fLoGainMean;
278 else
279 return fHiGainMean == -1. ? -1. : fHiGainMean * fHiGainMean;
280}
281
282
283// --------------------------------------------------------------------------
284//
285// Get the Relative Variance of either High Gain or Low Gain Sigma
286// depending on IsHighGainSaturation()
287//
288// If variance is smaller than 0. return -1.
289//
290Float_t MCalibrationPix::GetSigmaRelVar() const
291{
292
293 if (IsHiGainSaturation())
294 if (fLoGainSigmaVar < 0.)
295 return -1.;
296 else
297 return fLoGainSigmaVar / (fLoGainSigma * fLoGainSigma);
298 else
299 if (fHiGainSigmaVar < 0.)
300 return -1.;
301 else
302 return fHiGainSigmaVar / (fHiGainSigma * fHiGainSigma);
303}
304
305// --------------------------------------------------------------------------
306//
307// Get the High Gain Mean Error: Takes square root of fHiGainMeanVar
308//
309Float_t MCalibrationPix::GetHiGainMeanErr() const
310{
311 if (fLoGainMeanVar < 0.)
312 return -1.;
313
314 return TMath::Sqrt(fLoGainMeanVar);
315}
316
317
318// --------------------------------------------------------------------------
319//
320// Get the High Gain Sigma Error: Takes square root of fHiGainSigmaVar
321//
322Float_t MCalibrationPix::GetHiGainSigmaErr() const
323{
324 if (fHiGainSigmaVar < 0.)
325 return -1.;
326
327 return TMath::Sqrt(fHiGainSigmaVar);
328}
329
330// --------------------------------------------------------------------------
331//
332// Get the Low Gain Mean Error: Takes square root of fLoGainMeanVar
333//
334Float_t MCalibrationPix::GetLoGainMeanErr() const
335{
336 if (fLoGainMeanVar < 0.)
337 return -1.;
338
339 return TMath::Sqrt(fLoGainMeanVar);
340}
341
342// --------------------------------------------------------------------------
343//
344// Get the Low Gain Mean Rel Variance
345//
346Float_t MCalibrationPix::GetLoGainMeanRelVar() const
347{
348 if (fLoGainMeanVar < 0.)
349 return -1.;
350 if (fLoGainMean == 0.)
351 return -1.;
352
353 return fLoGainMeanVar / ( fLoGainMean * fLoGainMean);
354}
355
356// --------------------------------------------------------------------------
357//
358// Get the Low Gain Sigma Error: Takes square root of fHiGainSigmaVar
359//
360Float_t MCalibrationPix::GetLoGainSigmaErr() const
361{
362 if (fLoGainSigmaVar < 0.)
363 return -1.;
364
365 return TMath::Sqrt(fLoGainSigmaVar);
366}
367
368// --------------------------------------------------------------------------
369//
370// Test bit kHiGainSaturation
371//
372Bool_t MCalibrationPix::IsHiGainSaturation() const
373{
374 return TESTBIT(fFlags,kHiGainSaturation);
375}
376
377// --------------------------------------------------------------------------
378//
379// Test bit kExcluded
380//
381Bool_t MCalibrationPix::IsExcluded() const
382{
383 return TESTBIT(fFlags,kExcluded);
384}
385
386// --------------------------------------------------------------------------
387//
388// Test bit kValid
389//
390Bool_t MCalibrationPix::IsValid() const
391{
392 return TESTBIT(fFlags,kValid);
393}
394
Note: See TracBrowser for help on using the repository browser.