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

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