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 |
|
---|
40 | ClassImp(MCalibrationChargeBlindPix);
|
---|
41 |
|
---|
42 | using namespace std;
|
---|
43 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelArea = 100;
|
---|
44 | // Average QE of Blind Pixel (three colours)
|
---|
45 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreen = 0.154;
|
---|
46 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlue = 0.226;
|
---|
47 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUV = 0.247;
|
---|
48 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1 = 0.247;
|
---|
49 | // Average QE Error of Blind Pixel (three colours)
|
---|
50 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreenErr = 0.015;
|
---|
51 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlueErr = 0.02;
|
---|
52 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUVErr = 0.02;
|
---|
53 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1Err = 0.02;
|
---|
54 | // Attenuation factor Blind Pixel (three colours)
|
---|
55 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttGreen = 1.97;
|
---|
56 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttBlue = 1.96;
|
---|
57 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttUV = 1.95;
|
---|
58 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttCT1 = 1.95;
|
---|
59 |
|
---|
60 | const Float_t MCalibrationChargeBlindPix::fgLambdaCheckLimit = 0.2;
|
---|
61 | const Float_t MCalibrationChargeBlindPix::fgLambdaErrLimit = 0.2;
|
---|
62 | // --------------------------------------------------------------------------
|
---|
63 | //
|
---|
64 | // Default Constructor.
|
---|
65 | //
|
---|
66 | MCalibrationChargeBlindPix::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 | //
|
---|
83 | void 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 |
|
---|
110 | void MCalibrationChargeBlindPix::SetFluxInsidePlexiglassAvailable( const Bool_t b)
|
---|
111 | {
|
---|
112 | b ? SETBIT(fFlags,kFluxInsidePlexiglassAvailable) : CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
|
---|
113 | }
|
---|
114 |
|
---|
115 | void MCalibrationChargeBlindPix::SetOscillating( const Bool_t b)
|
---|
116 | {
|
---|
117 | b ? SETBIT(fFlags,kOscillating) : CLRBIT(fFlags,kOscillating);
|
---|
118 | }
|
---|
119 |
|
---|
120 | void MCalibrationChargeBlindPix::SetChargeFitValid( const Bool_t b)
|
---|
121 | {
|
---|
122 | b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
|
---|
123 | }
|
---|
124 | void MCalibrationChargeBlindPix::SetPedestalFitOK( const Bool_t b)
|
---|
125 | {
|
---|
126 | b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
|
---|
127 | }
|
---|
128 |
|
---|
129 | void MCalibrationChargeBlindPix::SetSinglePheFitOK( const Bool_t b)
|
---|
130 | {
|
---|
131 | b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
|
---|
132 | }
|
---|
133 |
|
---|
134 | void MCalibrationChargeBlindPix::SetExcluded( const Bool_t b)
|
---|
135 | {
|
---|
136 | b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded);
|
---|
137 | }
|
---|
138 |
|
---|
139 | Bool_t MCalibrationChargeBlindPix::IsExcluded() const
|
---|
140 | {
|
---|
141 | return TESTBIT(fFlags,kExcluded);
|
---|
142 | }
|
---|
143 |
|
---|
144 | Bool_t MCalibrationChargeBlindPix::IsOscillating() const
|
---|
145 | {
|
---|
146 | return TESTBIT(fFlags,kOscillating);
|
---|
147 | }
|
---|
148 |
|
---|
149 | Bool_t MCalibrationChargeBlindPix::IsChargeFitValid() const
|
---|
150 | {
|
---|
151 | return TESTBIT(fFlags,kChargeFitValid);
|
---|
152 | }
|
---|
153 |
|
---|
154 | Bool_t MCalibrationChargeBlindPix::IsPedestalFitOK() const
|
---|
155 | {
|
---|
156 | return TESTBIT(fFlags,kPedestalFitOK);
|
---|
157 | }
|
---|
158 |
|
---|
159 | Bool_t MCalibrationChargeBlindPix::IsSinglePheFitOK() const
|
---|
160 | {
|
---|
161 | return TESTBIT(fFlags,kSinglePheFitOK);
|
---|
162 | }
|
---|
163 |
|
---|
164 | Bool_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 | //
|
---|
176 | Bool_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 | Bool_t MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
|
---|
201 | {
|
---|
202 |
|
---|
203 | if (IsChargeFitValid())
|
---|
204 | return kFALSE;
|
---|
205 |
|
---|
206 |
|
---|
207 | //
|
---|
208 | // Start calculation of number of photons
|
---|
209 | //
|
---|
210 | // The blind pixel has exactly 100 mm^2 area (with negligible error),
|
---|
211 | //
|
---|
212 | fMeanFluxInsidePlexiglass = fLambda*gkBlindPixelArea;
|
---|
213 |
|
---|
214 | // Start calculation of number of photons relative Variance
|
---|
215 | fMeanFluxErrInsidePlexiglass = fLambdaErr*fLambdaErr/fLambda/fLambda;
|
---|
216 |
|
---|
217 | switch (fColor)
|
---|
218 | {
|
---|
219 | case kGREEN:
|
---|
220 | fMeanFluxInsidePlexiglass /= gkBlindPixelQEGreen;
|
---|
221 | fMeanFluxErrInsidePlexiglass += gkBlindPixelQEGreenErr*gkBlindPixelQEGreenErr
|
---|
222 | / gkBlindPixelQEGreen / gkBlindPixelQEGreen;
|
---|
223 |
|
---|
224 | fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttGreen); // correct for absorption
|
---|
225 | // attenuation has negligible error
|
---|
226 | break;
|
---|
227 | case kBLUE:
|
---|
228 | fMeanFluxInsidePlexiglass /= gkBlindPixelQEBlue;
|
---|
229 | fMeanFluxErrInsidePlexiglass += gkBlindPixelQEBlueErr*gkBlindPixelQEBlueErr
|
---|
230 | / gkBlindPixelQEBlue / gkBlindPixelQEBlue;
|
---|
231 |
|
---|
232 | fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttBlue); // correct for absorption
|
---|
233 | // attenuation has negligible error
|
---|
234 | break;
|
---|
235 | case kUV:
|
---|
236 | fMeanFluxInsidePlexiglass /= gkBlindPixelQEUV;
|
---|
237 | fMeanFluxErrInsidePlexiglass += gkBlindPixelQEUVErr*gkBlindPixelQEUVErr
|
---|
238 | / gkBlindPixelQEUV / gkBlindPixelQEUV;
|
---|
239 |
|
---|
240 | fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttUV); // correct for absorption
|
---|
241 | // attenuation has negligible error
|
---|
242 | break;
|
---|
243 | case kCT1:
|
---|
244 | default:
|
---|
245 | fMeanFluxInsidePlexiglass /= gkBlindPixelQECT1;
|
---|
246 | fMeanFluxErrInsidePlexiglass += gkBlindPixelQECT1Err*gkBlindPixelQECT1Err
|
---|
247 | / gkBlindPixelQECT1 / gkBlindPixelQECT1;
|
---|
248 |
|
---|
249 | fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttCT1); // correct for absorption
|
---|
250 | // attenuation has negligible error
|
---|
251 | break;
|
---|
252 | }
|
---|
253 |
|
---|
254 | *fLog << inf << endl;
|
---|
255 | *fLog << inf << " Photon flux [ph/mm^2] inside Plexiglass: "
|
---|
256 | << fMeanFluxInsidePlexiglass << endl;
|
---|
257 |
|
---|
258 | if (fMeanFluxInsidePlexiglass < 0.)
|
---|
259 | return kFALSE;
|
---|
260 |
|
---|
261 | if (fMeanFluxErrInsidePlexiglass < 0.)
|
---|
262 | return kFALSE;
|
---|
263 |
|
---|
264 | SetFluxInsidePlexiglassAvailable(kTRUE);
|
---|
265 |
|
---|
266 | // Finish calculation of errors -> convert from relative variance to absolute error
|
---|
267 | fMeanFluxErrInsidePlexiglass = TMath::Sqrt(fMeanFluxErrInsidePlexiglass);
|
---|
268 | fMeanFluxErrInsidePlexiglass *= fMeanFluxInsidePlexiglass;
|
---|
269 |
|
---|
270 | *fLog << inf << " Error on photon flux [ph/mm^2] inside Plexiglass: "
|
---|
271 | << fMeanFluxErrInsidePlexiglass << endl;
|
---|
272 | *fLog << inf << endl;
|
---|
273 |
|
---|
274 | return kTRUE;
|
---|
275 | }
|
---|
276 |
|
---|
277 |
|
---|
278 |
|
---|
279 |
|
---|
280 |
|
---|
281 |
|
---|
282 |
|
---|
283 |
|
---|
284 |
|
---|
285 |
|
---|