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

Last change on this file since 3676 was 3676, checked in by gaug, 21 years ago
*** empty log message ***
File size: 7.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//
41/////////////////////////////////////////////////////////////////////////////
42#include "MCalibrationPix.h"
43
44ClassImp(MCalibrationPix);
45
46using namespace std;
47
48// --------------------------------------------------------------------------
49//
50// Default Constructor:
51//
52// Sets:
53// - fPixId to -1
54// - fFlags to 0
55//
56// Calls:
57// - Clear()
58//
59MCalibrationPix::MCalibrationPix(const char *name, const char *title)
60 : fPixId(-1),
61 fFlags(0)
62{
63
64 fName = name ? name : "MCalibrationPix";
65 fTitle = title ? title : "Container of the fit results of MHCalibrationPixs ";
66
67 Clear();
68
69}
70
71// ------------------------------------------------------------------------
72//
73// Sets:
74// - all variables to -1
75// - all flags to kFALSE
76//
77void MCalibrationPix::Clear(Option_t *o)
78{
79
80 fHiGainNumBlackout = -1 ;
81 fHiGainNumPickup = -1 ;
82 fHiGainMean = -1.;
83 fHiGainMeanVar = -1.;
84 fHiGainProb = -1.;
85 fHiGainSigma = -1.;
86 fHiGainSigmaVar = -1.;
87
88 fLoGainNumBlackout = -1 ;
89 fLoGainNumPickup = -1 ;
90 fLoGainMean = -1.;
91 fLoGainMeanVar = -1.;
92 fLoGainProb = -1.;
93 fLoGainSigma = -1.;
94 fLoGainSigmaVar = -1.;
95
96 SetHiGainSaturation ( kFALSE );
97 SetExcluded ( kFALSE );
98 SetValid ( kFALSE );
99
100}
101
102// --------------------------------------------------------------------------
103//
104// Set the Hi Gain Saturation Bit from outside
105//
106void MCalibrationPix::SetHiGainSaturation(Bool_t b)
107{
108 b ? SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation);
109}
110
111
112// --------------------------------------------------------------------------
113//
114// Set the Excluded Bit from outside
115//
116void MCalibrationPix::SetExcluded(Bool_t b )
117{
118 b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
119}
120
121// --------------------------------------------------------------------------
122//
123// Set the Valid Bit from outside
124//
125void MCalibrationPix::SetValid(Bool_t b )
126{
127 b ? SETBIT(fFlags, kValid) : CLRBIT(fFlags, kValid);
128}
129
130// --------------------------------------------------------------------------
131//
132// Get the Relative Variance of either High Gain or Low Gain Mean
133// depending on IsHighGainSaturation()
134//
135// If variance is smaller than 0. return -1.
136//
137Float_t MCalibrationPix::GetMeanRelVar() const
138{
139
140 if (IsHiGainSaturation())
141 if (fLoGainMeanVar < 0.)
142 return -1.;
143 else
144 return fLoGainMeanVar / (fLoGainMean * fLoGainMean);
145 else
146 if (fHiGainMeanVar < 0.)
147 return -1.;
148 else
149 return fHiGainMeanVar / (fHiGainMean * fHiGainMean);
150}
151
152// --------------------------------------------------------------------------
153//
154// Get the Relative Variance of either High Gain or Low Gain Sigma
155// depending on IsHighGainSaturation()
156//
157// If variance is smaller than 0. return -1.
158//
159Float_t MCalibrationPix::GetSigmaRelVar() const
160{
161
162 if (IsHiGainSaturation())
163 if (fLoGainSigmaVar < 0.)
164 return -1.;
165 else
166 return fLoGainSigmaVar / (fLoGainSigma * fLoGainSigma);
167 else
168 if (fHiGainSigmaVar < 0.)
169 return -1.;
170 else
171 return fHiGainSigmaVar / (fHiGainSigma * fHiGainSigma);
172}
173
174// --------------------------------------------------------------------------
175//
176// Get the High Gain Mean Error: Takes square root of fHiGainMeanVar
177//
178Float_t MCalibrationPix::GetHiGainMeanErr() const
179{
180 if (fLoGainMeanVar < 0.)
181 return -1.;
182
183 return TMath::Sqrt(fLoGainMeanVar);
184}
185
186
187// --------------------------------------------------------------------------
188//
189// Get the High Gain Sigma Error: Takes square root of fHiGainSigmaVar
190//
191Float_t MCalibrationPix::GetHiGainSigmaErr() const
192{
193 if (fHiGainSigmaVar < 0.)
194 return -1.;
195
196 return TMath::Sqrt(fHiGainSigmaVar);
197}
198
199// --------------------------------------------------------------------------
200//
201// Get the Low Gain Mean Error: Takes square root of fLoGainMeanVar
202//
203Float_t MCalibrationPix::GetLoGainMeanErr() const
204{
205 if (fLoGainMeanVar < 0.)
206 return -1.;
207
208 return TMath::Sqrt(fLoGainMeanVar);
209}
210
211// --------------------------------------------------------------------------
212//
213// Get the Low Gain Mean Rel Variance
214//
215Float_t MCalibrationPix::GetLoGainMeanRelVar() const
216{
217 if (fLoGainMeanVar < 0.)
218 return -1.;
219 if (fLoGainMean == 0.)
220 return -1.;
221
222 return fLoGainMeanVar / ( fLoGainMean * fLoGainMean);
223}
224
225// --------------------------------------------------------------------------
226//
227// Get the Low Gain Sigma Error: Takes square root of fHiGainSigmaVar
228//
229Float_t MCalibrationPix::GetLoGainSigmaErr() const
230{
231 if (fLoGainSigmaVar < 0.)
232 return -1.;
233
234 return TMath::Sqrt(fLoGainSigmaVar);
235}
236
237// --------------------------------------------------------------------------
238//
239// Test bit kHiGainSaturation
240//
241Bool_t MCalibrationPix::IsHiGainSaturation() const
242{
243 return TESTBIT(fFlags,kHiGainSaturation);
244}
245
246// --------------------------------------------------------------------------
247//
248// Test bit kExcluded
249//
250Bool_t MCalibrationPix::IsExcluded() const
251{
252 return TESTBIT(fFlags,kExcluded);
253}
254
255// --------------------------------------------------------------------------
256//
257// Test bit kValid
258//
259Bool_t MCalibrationPix::IsValid() const
260{
261 return TESTBIT(fFlags,kValid);
262}
263
Note: See TracBrowser for help on using the repository browser.