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 | // Storage container of the fit results of the Blind Pixel signal
|
---|
30 | // (from MHCalibrationChargeBlindPix).
|
---|
31 | //
|
---|
32 | // The Flux is calculated in photons per mm^2 in the camera plane.
|
---|
33 | //
|
---|
34 | // Currently, the following numbers are implemented:
|
---|
35 | // - gkBlindPixelArea: 100 mm^2
|
---|
36 | // - Average QE of Blind Pixel:
|
---|
37 | // gkBlindPixelQEGreen: 0.154
|
---|
38 | // gkBlindPixelQEBlue : 0.226
|
---|
39 | // gkBlindPixelQEUV : 0.247
|
---|
40 | // gkBlindPixelQECT1 : 0.247
|
---|
41 | // - Average QE Error of Blind Pixel:
|
---|
42 | // gkBlindPixelQEGreenErr: 0.015;
|
---|
43 | // gkBlindPixelQEBlueErr : 0.02;
|
---|
44 | // gkBlindPixelQEUVErr : 0.02;
|
---|
45 | // gkBlindPixelQECT1Err : 0.02;
|
---|
46 | // - Attenuation factor Blind Pixel:
|
---|
47 | // gkBlindPixelAttGreen : 1.97;
|
---|
48 | // gkBlindPixelAttBlue : 1.96;
|
---|
49 | // gkBlindPixelAttUV : 1.95;
|
---|
50 | // gkBlindPixelAttCT1 : 1.95;
|
---|
51 | //
|
---|
52 | //
|
---|
53 | /////////////////////////////////////////////////////////////////////////////
|
---|
54 | #include "MCalibrationChargeBlindPix.h"
|
---|
55 |
|
---|
56 | #include <TH1.h>
|
---|
57 |
|
---|
58 | #include "MLog.h"
|
---|
59 | #include "MLogManip.h"
|
---|
60 |
|
---|
61 | ClassImp(MCalibrationChargeBlindPix);
|
---|
62 |
|
---|
63 | using namespace std;
|
---|
64 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelArea = 100;
|
---|
65 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttGreen = 1.97;
|
---|
66 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttBlue = 1.96;
|
---|
67 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttUV = 1.95;
|
---|
68 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttCT1 = 1.95;
|
---|
69 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreen = 0.154;
|
---|
70 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlue = 0.226;
|
---|
71 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUV = 0.247;
|
---|
72 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1 = 0.247;
|
---|
73 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreenErr = 0.015;
|
---|
74 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlueErr = 0.02;
|
---|
75 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUVErr = 0.02;
|
---|
76 | const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1Err = 0.02;
|
---|
77 | // --------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // Default Constructor.
|
---|
80 | //
|
---|
81 | // Calls:
|
---|
82 | // - Clear()
|
---|
83 | //
|
---|
84 | MCalibrationChargeBlindPix::MCalibrationChargeBlindPix(const char *name, const char *title)
|
---|
85 | {
|
---|
86 |
|
---|
87 | fName = name ? name : "MCalibrationChargeBlindPix";
|
---|
88 | fTitle = title ? title : "Container of the fit results of the blind pixel";
|
---|
89 |
|
---|
90 | Clear();
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | // ------------------------------------------------------------------------
|
---|
95 | //
|
---|
96 | // Sets:
|
---|
97 | // - all flags to kFALSE
|
---|
98 | // - all variables to -1.
|
---|
99 | //
|
---|
100 | // Calls:
|
---|
101 | // - MCalibrationChargePix::Clear()
|
---|
102 | //
|
---|
103 | void MCalibrationChargeBlindPix::Clear(Option_t *o)
|
---|
104 | {
|
---|
105 |
|
---|
106 | fFluxInsidePlexiglass = -1.;
|
---|
107 | fFluxInsidePlexiglassVar = -1.;
|
---|
108 | fLambda = -1.;
|
---|
109 | fLambdaCheck = -1.;
|
---|
110 | fLambdaVar = -1.;
|
---|
111 | fMu0 = -1.;
|
---|
112 | fMu0Err = -1.;
|
---|
113 | fMu1 = -1.;
|
---|
114 | fMu1Err = -1.;
|
---|
115 | fSigma0 = -1.;
|
---|
116 | fSigma0Err = -1.;
|
---|
117 | fSigma1 = -1.;
|
---|
118 | fSigma1Err = -1.;
|
---|
119 |
|
---|
120 | SetOscillating ( kFALSE );
|
---|
121 | SetExcluded ( kFALSE );
|
---|
122 | SetChargeFitValid ( kFALSE );
|
---|
123 | SetPedestalFitOK ( kFALSE );
|
---|
124 | SetSinglePheFitOK ( kFALSE );
|
---|
125 | SetFluxInsidePlexiglassAvailable ( kFALSE );
|
---|
126 |
|
---|
127 | MCalibrationChargePix::Clear();
|
---|
128 | }
|
---|
129 |
|
---|
130 | void MCalibrationChargeBlindPix::SetFluxInsidePlexiglassAvailable( const Bool_t b)
|
---|
131 | {
|
---|
132 | b ? SETBIT(fFlags,kFluxInsidePlexiglassAvailable) : CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
|
---|
133 | }
|
---|
134 |
|
---|
135 | // --------------------------------------------------------------------------
|
---|
136 | //
|
---|
137 | // Set the Oscillating Bit from outside
|
---|
138 | //
|
---|
139 | void MCalibrationChargeBlindPix::SetOscillating( const Bool_t b)
|
---|
140 | {
|
---|
141 | b ? SETBIT(fFlags,kOscillating) : CLRBIT(fFlags,kOscillating);
|
---|
142 | }
|
---|
143 |
|
---|
144 | // --------------------------------------------------------------------------
|
---|
145 | //
|
---|
146 | // Set the ChargeFitValid Bit from outside
|
---|
147 | //
|
---|
148 | void MCalibrationChargeBlindPix::SetChargeFitValid( const Bool_t b)
|
---|
149 | {
|
---|
150 | b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
|
---|
151 | }
|
---|
152 |
|
---|
153 | // --------------------------------------------------------------------------
|
---|
154 | //
|
---|
155 | // Set the PedestalFitValid Bit from outside
|
---|
156 | //
|
---|
157 | void MCalibrationChargeBlindPix::SetPedestalFitOK( const Bool_t b)
|
---|
158 | {
|
---|
159 | b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
|
---|
160 | }
|
---|
161 |
|
---|
162 | // --------------------------------------------------------------------------
|
---|
163 | //
|
---|
164 | // Set the SinglePheFitValid Bit from outside
|
---|
165 | //
|
---|
166 | void MCalibrationChargeBlindPix::SetSinglePheFitOK( const Bool_t b)
|
---|
167 | {
|
---|
168 | b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
|
---|
169 | }
|
---|
170 |
|
---|
171 | // --------------------------------------------------------------------------
|
---|
172 | //
|
---|
173 | // Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
|
---|
174 | // Return square root of fFluxInsidePlexiglassVar
|
---|
175 | //
|
---|
176 | Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassErr() const
|
---|
177 | {
|
---|
178 | if (fFluxInsidePlexiglassVar < 0.)
|
---|
179 | return -1.;
|
---|
180 |
|
---|
181 | return TMath::Sqrt(fFluxInsidePlexiglassVar);
|
---|
182 | }
|
---|
183 |
|
---|
184 | // --------------------------------------------------------------------------
|
---|
185 | //
|
---|
186 | // Return -1 if fLambdaVar is smaller than 0.
|
---|
187 | // Return square root of fLambdaVar
|
---|
188 | //
|
---|
189 | Float_t MCalibrationChargeBlindPix::GetLambdaErr() const
|
---|
190 | {
|
---|
191 | if (fLambdaVar < 0.)
|
---|
192 | return -1.;
|
---|
193 |
|
---|
194 | return TMath::Sqrt(fLambdaVar);
|
---|
195 | }
|
---|
196 |
|
---|
197 | // --------------------------------------------------------------------------
|
---|
198 | //
|
---|
199 | // Test bit kChargeFitValid
|
---|
200 | //
|
---|
201 | Bool_t MCalibrationChargeBlindPix::IsChargeFitValid() const
|
---|
202 | {
|
---|
203 | return TESTBIT(fFlags,kChargeFitValid);
|
---|
204 | }
|
---|
205 |
|
---|
206 | // --------------------------------------------------------------------------
|
---|
207 | //
|
---|
208 | // Test bit kOscillating
|
---|
209 | //
|
---|
210 | Bool_t MCalibrationChargeBlindPix::IsOscillating() const
|
---|
211 | {
|
---|
212 | return TESTBIT(fFlags,kOscillating);
|
---|
213 | }
|
---|
214 |
|
---|
215 | // --------------------------------------------------------------------------
|
---|
216 | //
|
---|
217 | // Test bit kPedestalFitValid
|
---|
218 | //
|
---|
219 | Bool_t MCalibrationChargeBlindPix::IsPedestalFitOK() const
|
---|
220 | {
|
---|
221 | return TESTBIT(fFlags,kPedestalFitOK);
|
---|
222 | }
|
---|
223 |
|
---|
224 | // --------------------------------------------------------------------------
|
---|
225 | //
|
---|
226 | // Test bit kSinglePheFitValid
|
---|
227 | //
|
---|
228 | Bool_t MCalibrationChargeBlindPix::IsSinglePheFitOK() const
|
---|
229 | {
|
---|
230 | return TESTBIT(fFlags,kSinglePheFitOK);
|
---|
231 | }
|
---|
232 |
|
---|
233 | // --------------------------------------------------------------------------
|
---|
234 | //
|
---|
235 | // Test bit kFluxInsidePlexiglassAvailable
|
---|
236 | //
|
---|
237 | Bool_t MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable() const
|
---|
238 | {
|
---|
239 | return TESTBIT(fFlags,kFluxInsidePlexiglassAvailable);
|
---|
240 | }
|
---|
241 |
|
---|
242 |
|
---|
243 | // --------------------------------------------------------------------------
|
---|
244 | //
|
---|
245 | // Return kFALSE if IsChargeFitValid() is kFALSE
|
---|
246 | //
|
---|
247 | // Calculate fFluxInsidePlexiglass with the formula:
|
---|
248 | // - fFluxInsidePlexiglass = fLambda * gkBlindPixelArea / gkBlindPixelQE * 10**gkBlindPixelAtt
|
---|
249 | // - fFluxInsidePlexiglassVar = sqrt( fLambdaVar / ( fLambda * fLambda )
|
---|
250 | // + ( gkBlindPixelQEErr * gkBlindPixelQEErr / gkBlindPixelQE / gkBlindPixelQE )
|
---|
251 | // ) * fFluxInsidePlexiglass * * fFluxInsidePlexiglass
|
---|
252 | //
|
---|
253 | // If the fFluxInsidePlexiglass is smaller than 0., return kFALSE
|
---|
254 | // If the Variance is smaller than 0., return kFALSE
|
---|
255 | //
|
---|
256 | // SetFluxInsidePlexiglassAvailable() and return kTRUE
|
---|
257 | //
|
---|
258 | Bool_t MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
|
---|
259 | {
|
---|
260 |
|
---|
261 | if (IsChargeFitValid())
|
---|
262 | return kFALSE;
|
---|
263 |
|
---|
264 |
|
---|
265 | //
|
---|
266 | // Start calculation of number of photons
|
---|
267 | // The blind pixel has exactly 100 mm^2 area (with negligible error),
|
---|
268 | //
|
---|
269 | fFluxInsidePlexiglass = fLambda*gkBlindPixelArea;
|
---|
270 |
|
---|
271 | //
|
---|
272 | // Start calculation of number of photons relative Variance
|
---|
273 | //
|
---|
274 | const Float_t lambdaRelVar = fLambdaVar / ( fLambda * fLambda );
|
---|
275 | fFluxInsidePlexiglassVar = lambdaRelVar;
|
---|
276 |
|
---|
277 | switch (fColor)
|
---|
278 | {
|
---|
279 | case kGREEN:
|
---|
280 | fFluxInsidePlexiglass /= gkBlindPixelQEGreen;
|
---|
281 | fFluxInsidePlexiglassVar += gkBlindPixelQEGreenErr * gkBlindPixelQEGreenErr
|
---|
282 | / ( gkBlindPixelQEGreen * gkBlindPixelQEGreen );
|
---|
283 |
|
---|
284 | fFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttGreen); // correct for absorption
|
---|
285 | // attenuation has negligible error
|
---|
286 | break;
|
---|
287 | case kBLUE:
|
---|
288 | fFluxInsidePlexiglass /= gkBlindPixelQEBlue;
|
---|
289 | fFluxInsidePlexiglassVar += gkBlindPixelQEBlueErr * gkBlindPixelQEBlueErr
|
---|
290 | / ( gkBlindPixelQEBlue * gkBlindPixelQEBlue );
|
---|
291 |
|
---|
292 | fFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttBlue); // correct for absorption
|
---|
293 | // attenuation has negligible error
|
---|
294 | break;
|
---|
295 | case kUV:
|
---|
296 | fFluxInsidePlexiglass /= gkBlindPixelQEUV;
|
---|
297 | fFluxInsidePlexiglassVar += gkBlindPixelQEUVErr* gkBlindPixelQEUVErr
|
---|
298 | / ( gkBlindPixelQEUV * gkBlindPixelQEUV );
|
---|
299 |
|
---|
300 | fFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttUV); // correct for absorption
|
---|
301 | // attenuation has negligible error
|
---|
302 | break;
|
---|
303 | case kCT1:
|
---|
304 | default:
|
---|
305 | fFluxInsidePlexiglass /= gkBlindPixelQECT1;
|
---|
306 | fFluxInsidePlexiglassVar += gkBlindPixelQECT1Err * gkBlindPixelQECT1Err
|
---|
307 | / ( gkBlindPixelQECT1 * gkBlindPixelQECT1 );
|
---|
308 |
|
---|
309 | fFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttCT1); // correct for absorption
|
---|
310 | // attenuation has negligible error
|
---|
311 | break;
|
---|
312 | }
|
---|
313 |
|
---|
314 | *fLog << inf << endl;
|
---|
315 | *fLog << inf << " Photon flux [ph/mm^2] inside Plexiglass: "
|
---|
316 | << fFluxInsidePlexiglass << endl;
|
---|
317 |
|
---|
318 | if (fFluxInsidePlexiglass < 0.)
|
---|
319 | return kFALSE;
|
---|
320 |
|
---|
321 | if (fFluxInsidePlexiglassVar < 0.)
|
---|
322 | return kFALSE;
|
---|
323 |
|
---|
324 | SetFluxInsidePlexiglassAvailable(kTRUE);
|
---|
325 |
|
---|
326 | //
|
---|
327 | // Finish calculation of errors -> convert from relative variance to absolute variance
|
---|
328 | //
|
---|
329 | fFluxInsidePlexiglassVar *= fFluxInsidePlexiglass * fFluxInsidePlexiglass;
|
---|
330 |
|
---|
331 | *fLog << inf << " Error on photon flux [ph/mm^2] inside Plexiglass: "
|
---|
332 | << GetFluxInsidePlexiglass() << endl;
|
---|
333 | *fLog << inf << endl;
|
---|
334 |
|
---|
335 | return kTRUE;
|
---|
336 | }
|
---|
337 |
|
---|
338 |
|
---|
339 |
|
---|
340 |
|
---|
341 |
|
---|
342 |
|
---|
343 |
|
---|
344 |
|
---|
345 |
|
---|
346 |
|
---|