source: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.cc@ 3295

Last change on this file since 3295 was 3293, checked in by gaug, 21 years ago
*** empty log message ***
File size: 9.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/////////////////////////////////////////////////////////////////////////////
26// //
27// MCalibrationChargeBlindPix //
28// //
29// This is the storage container to hold informations about the calibration//
30// blind pixel //
31// //
32/////////////////////////////////////////////////////////////////////////////
33#include "MCalibrationChargeBlindPix.h"
34
35#include <TH1.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40ClassImp(MCalibrationChargeBlindPix);
41
42using namespace std;
43const Float_t MCalibrationChargeBlindPix::gkBlindPixelArea = 100;
44// Average QE of Blind Pixel (three colours)
45const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreen = 0.154;
46const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlue = 0.226;
47const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUV = 0.247;
48const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1 = 0.247;
49// Average QE Error of Blind Pixel (three colours)
50const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreenErr = 0.015;
51const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlueErr = 0.02;
52const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUVErr = 0.02;
53const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1Err = 0.02;
54// Attenuation factor Blind Pixel (three colours)
55const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttGreen = 1.97;
56const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttBlue = 1.96;
57const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttUV = 1.95;
58const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttCT1 = 1.95;
59
60const Float_t MCalibrationChargeBlindPix::fgLambdaCheckLimit = 0.2;
61const Float_t MCalibrationChargeBlindPix::fgLambdaErrLimit = 0.2;
62// --------------------------------------------------------------------------
63//
64// Default Constructor.
65//
66MCalibrationChargeBlindPix::MCalibrationChargeBlindPix(const char *name, const char *title)
67{
68
69 fName = name ? name : "MCalibrationChargeBlindPix";
70 fTitle = title ? title : "Container of the fit results of the blind pixel";
71
72 SetLambdaCheckLimit();
73 SetLambdaErrLimit();
74
75 Clear();
76}
77
78
79// ------------------------------------------------------------------------
80//
81// Invalidate values
82//
83void MCalibrationChargeBlindPix::Clear(Option_t *o)
84{
85
86 fLambda = -1.;
87 fLambdaCheck = -1.;
88 fMu0 = -1.;
89 fMu1 = -1.;
90 fSigma0 = -1.;
91 fSigma1 = -1.;
92 fLambdaErr = -1.;
93 fMu0Err = -1.;
94 fMu1Err = -1.;
95 fSigma0Err = -1.;
96 fSigma1Err = -1.;
97
98 fMeanFluxInsidePlexiglass = -1.;
99 fMeanFluxErrInsidePlexiglass = -1.;
100
101 SetOscillating ( kFALSE );
102 SetExcluded ( kFALSE );
103 SetChargeFitValid ( kFALSE );
104 SetPedestalFitOK ( kFALSE );
105 SetSinglePheFitOK ( kFALSE );
106 SetFluxInsidePlexiglassAvailable ( kFALSE );
107
108}
109
110void MCalibrationChargeBlindPix::SetFluxInsidePlexiglassAvailable( const Bool_t b)
111{
112 b ? SETBIT(fFlags,kFluxInsidePlexiglassAvailable) : CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
113}
114
115void MCalibrationChargeBlindPix::SetOscillating( const Bool_t b)
116{
117 b ? SETBIT(fFlags,kOscillating) : CLRBIT(fFlags,kOscillating);
118}
119
120void MCalibrationChargeBlindPix::SetChargeFitValid( const Bool_t b)
121{
122 b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
123}
124void MCalibrationChargeBlindPix::SetPedestalFitOK( const Bool_t b)
125{
126 b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
127}
128
129void MCalibrationChargeBlindPix::SetSinglePheFitOK( const Bool_t b)
130{
131 b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
132}
133
134void MCalibrationChargeBlindPix::SetExcluded( const Bool_t b)
135{
136 b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded);
137}
138
139Bool_t MCalibrationChargeBlindPix::IsExcluded() const
140{
141 return TESTBIT(fFlags,kExcluded);
142}
143
144Bool_t MCalibrationChargeBlindPix::IsOscillating() const
145{
146 return TESTBIT(fFlags,kOscillating);
147}
148
149Bool_t MCalibrationChargeBlindPix::IsChargeFitValid() const
150{
151 return TESTBIT(fFlags,kChargeFitValid);
152}
153
154Bool_t MCalibrationChargeBlindPix::IsPedestalFitOK() const
155{
156 return TESTBIT(fFlags,kPedestalFitOK);
157}
158
159Bool_t MCalibrationChargeBlindPix::IsSinglePheFitOK() const
160{
161 return TESTBIT(fFlags,kSinglePheFitOK);
162}
163
164Bool_t MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable() const
165{
166 return TESTBIT(fFlags,kFluxInsidePlexiglassAvailable);
167}
168
169
170//
171// The check return kTRUE if:
172//
173// 1) fLambda and fLambdaCheck are separated relatively by fLambdaCheckLimit
174// 2) BlindPixel has an fLambdaErr smaller than fLambdaErrLimit
175//
176Bool_t MCalibrationChargeBlindPix::CheckChargeFitValidity()
177{
178
179 if (2.*(fLambdaCheck-fLambda)/(fLambdaCheck+fLambda) < fLambdaCheckLimit)
180 {
181 *fLog << warn << "WARNING: Lambda and Lambda-Check differ by more than "
182 << fLambdaCheckLimit << " in the Blind Pixel " << endl;
183 return kFALSE;
184 }
185
186 if (fLambdaErr < fLambdaErrLimit)
187 {
188 *fLog << warn << "WARNING: Error of Fitted Lambda is greater than "
189 << fLambdaErrLimit << " in Blind Pixel " << endl;
190 return kFALSE;
191 }
192
193 return kTRUE;
194}
195
196
197
198// --------------------------------------------------------------------------
199//
200//
201//
202Bool_t MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
203{
204
205 if (IsChargeFitValid())
206 return kFALSE;
207
208
209 //
210 // Start calculation of number of photons
211 //
212 // The blind pixel has exactly 100 mm^2 area (with negligible error),
213 //
214 fMeanFluxInsidePlexiglass = fLambda*gkBlindPixelArea;
215
216 // Start calculation of number of photons relative Variance
217 fMeanFluxErrInsidePlexiglass = fLambdaErr*fLambdaErr/fLambda/fLambda;
218
219 switch (fColor)
220 {
221 case kEGreen:
222 fMeanFluxInsidePlexiglass /= gkBlindPixelQEGreen;
223 fMeanFluxErrInsidePlexiglass += gkBlindPixelQEGreenErr*gkBlindPixelQEGreenErr
224 / gkBlindPixelQEGreen / gkBlindPixelQEGreen;
225
226 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttGreen); // correct for absorption
227 // attenuation has negligible error
228 break;
229 case kEBlue:
230 fMeanFluxInsidePlexiglass /= gkBlindPixelQEBlue;
231 fMeanFluxErrInsidePlexiglass += gkBlindPixelQEBlueErr*gkBlindPixelQEBlueErr
232 / gkBlindPixelQEBlue / gkBlindPixelQEBlue;
233
234 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttBlue); // correct for absorption
235 // attenuation has negligible error
236 break;
237 case kEUV:
238 fMeanFluxInsidePlexiglass /= gkBlindPixelQEUV;
239 fMeanFluxErrInsidePlexiglass += gkBlindPixelQEUVErr*gkBlindPixelQEUVErr
240 / gkBlindPixelQEUV / gkBlindPixelQEUV;
241
242 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttUV); // correct for absorption
243 // attenuation has negligible error
244 break;
245 case kECT1:
246 default:
247 fMeanFluxInsidePlexiglass /= gkBlindPixelQECT1;
248 fMeanFluxErrInsidePlexiglass += gkBlindPixelQECT1Err*gkBlindPixelQECT1Err
249 / gkBlindPixelQECT1 / gkBlindPixelQECT1;
250
251 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttCT1); // correct for absorption
252 // attenuation has negligible error
253 break;
254 }
255
256 *fLog << inf << endl;
257 *fLog << inf << " Photon flux [ph/mm^2] inside Plexiglass: "
258 << fMeanFluxInsidePlexiglass << endl;
259
260 if (fMeanFluxInsidePlexiglass < 0.)
261 return kFALSE;
262
263 if (fMeanFluxErrInsidePlexiglass < 0.)
264 return kFALSE;
265
266 SetFluxInsidePlexiglassAvailable(kTRUE);
267
268 // Finish calculation of errors -> convert from relative variance to absolute error
269 fMeanFluxErrInsidePlexiglass = TMath::Sqrt(fMeanFluxErrInsidePlexiglass);
270 fMeanFluxErrInsidePlexiglass *= fMeanFluxInsidePlexiglass;
271
272 *fLog << inf << " Error on photon flux [ph/mm^2] inside Plexiglass: "
273 << fMeanFluxErrInsidePlexiglass << endl;
274 *fLog << inf << endl;
275
276 return kTRUE;
277}
278
279
280
281
282
283
284
285
286
287
Note: See TracBrowser for help on using the repository browser.