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

Last change on this file since 3697 was 3677, checked in by gaug, 21 years ago
*** empty log message ***
File size: 7.5 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// Get the Relative Variance of either High Gain or Low Gain Mean
134// depending on IsHighGainSaturation()
135//
136// If variance is smaller than 0. return -1.
137//
138Float_t MCalibrationPix::GetMeanRelVar() const
139{
140
141 if (IsHiGainSaturation())
142 if (fLoGainMeanVar < 0.)
143 return -1.;
144 else
145 return fLoGainMeanVar / (fLoGainMean * fLoGainMean);
146 else
147 if (fHiGainMeanVar < 0.)
148 return -1.;
149 else
150 return fHiGainMeanVar / (fHiGainMean * fHiGainMean);
151}
152
153// --------------------------------------------------------------------------
154//
155// Get the Square of either High Gain or Low Gain Mean
156// depending on IsHighGainSaturation()
157//
158Float_t MCalibrationPix::GetMeanSquare() const
159{
160
161 if (IsHiGainSaturation())
162 return fLoGainMean == -1. ? -1. : fLoGainMean * fLoGainMean;
163 else
164 return fHiGainMean == -1. ? -1. : fHiGainMean * fHiGainMean;
165}
166
167
168// --------------------------------------------------------------------------
169//
170// Get the Relative Variance of either High Gain or Low Gain Sigma
171// depending on IsHighGainSaturation()
172//
173// If variance is smaller than 0. return -1.
174//
175Float_t MCalibrationPix::GetSigmaRelVar() const
176{
177
178 if (IsHiGainSaturation())
179 if (fLoGainSigmaVar < 0.)
180 return -1.;
181 else
182 return fLoGainSigmaVar / (fLoGainSigma * fLoGainSigma);
183 else
184 if (fHiGainSigmaVar < 0.)
185 return -1.;
186 else
187 return fHiGainSigmaVar / (fHiGainSigma * fHiGainSigma);
188}
189
190// --------------------------------------------------------------------------
191//
192// Get the High Gain Mean Error: Takes square root of fHiGainMeanVar
193//
194Float_t MCalibrationPix::GetHiGainMeanErr() const
195{
196 if (fLoGainMeanVar < 0.)
197 return -1.;
198
199 return TMath::Sqrt(fLoGainMeanVar);
200}
201
202
203// --------------------------------------------------------------------------
204//
205// Get the High Gain Sigma Error: Takes square root of fHiGainSigmaVar
206//
207Float_t MCalibrationPix::GetHiGainSigmaErr() const
208{
209 if (fHiGainSigmaVar < 0.)
210 return -1.;
211
212 return TMath::Sqrt(fHiGainSigmaVar);
213}
214
215// --------------------------------------------------------------------------
216//
217// Get the Low Gain Mean Error: Takes square root of fLoGainMeanVar
218//
219Float_t MCalibrationPix::GetLoGainMeanErr() const
220{
221 if (fLoGainMeanVar < 0.)
222 return -1.;
223
224 return TMath::Sqrt(fLoGainMeanVar);
225}
226
227// --------------------------------------------------------------------------
228//
229// Get the Low Gain Mean Rel Variance
230//
231Float_t MCalibrationPix::GetLoGainMeanRelVar() const
232{
233 if (fLoGainMeanVar < 0.)
234 return -1.;
235 if (fLoGainMean == 0.)
236 return -1.;
237
238 return fLoGainMeanVar / ( fLoGainMean * fLoGainMean);
239}
240
241// --------------------------------------------------------------------------
242//
243// Get the Low Gain Sigma Error: Takes square root of fHiGainSigmaVar
244//
245Float_t MCalibrationPix::GetLoGainSigmaErr() const
246{
247 if (fLoGainSigmaVar < 0.)
248 return -1.;
249
250 return TMath::Sqrt(fLoGainSigmaVar);
251}
252
253// --------------------------------------------------------------------------
254//
255// Test bit kHiGainSaturation
256//
257Bool_t MCalibrationPix::IsHiGainSaturation() const
258{
259 return TESTBIT(fFlags,kHiGainSaturation);
260}
261
262// --------------------------------------------------------------------------
263//
264// Test bit kExcluded
265//
266Bool_t MCalibrationPix::IsExcluded() const
267{
268 return TESTBIT(fFlags,kExcluded);
269}
270
271// --------------------------------------------------------------------------
272//
273// Test bit kValid
274//
275Bool_t MCalibrationPix::IsValid() const
276{
277 return TESTBIT(fFlags,kValid);
278}
279
Note: See TracBrowser for help on using the repository browser.