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 | // MCalibrationChargePINDiode
|
---|
28 | //
|
---|
29 | // Storage container of the fit results of the PIN Diode signal
|
---|
30 | // (from MHCalibrationChargePINDiode). The PIN Diode is not yet working, so
|
---|
31 | // is the documentation for the moment.
|
---|
32 | //
|
---|
33 | // The Flux is calculated in photons per mm^2 in the camera plane.
|
---|
34 | //
|
---|
35 | // Currently, the following numbers are implemented:
|
---|
36 | //
|
---|
37 | // Area of PIN Diode Ap: 100.000 +- 10 mm^2
|
---|
38 | //
|
---|
39 | // Ratio of areas:
|
---|
40 | //
|
---|
41 | // Distance of PIN Diode to pulser D1: 1.5 +- 0.3 m
|
---|
42 | // Distance of Inner Pixel to pulser D2: 18.0 +- 0.5 m
|
---|
43 | //
|
---|
44 | // D1*D1
|
---|
45 | // gkSolidAngleRatio = -------- = 0.00007
|
---|
46 | // Ap*D2*D2
|
---|
47 | //
|
---|
48 | // gkSolidAngleRatioErr = 0.00002
|
---|
49 | //
|
---|
50 | /////////////////////////////////////////////////////////////////////////////
|
---|
51 | #include "MCalibrationChargePINDiode.h"
|
---|
52 | #include "MCalibrationChargePix.h"
|
---|
53 |
|
---|
54 | #include "MCalibrationCam.h"
|
---|
55 |
|
---|
56 | #include "MLog.h"
|
---|
57 | #include "MLogManip.h"
|
---|
58 |
|
---|
59 | ClassImp(MCalibrationChargePINDiode);
|
---|
60 |
|
---|
61 | using namespace std;
|
---|
62 |
|
---|
63 | const Float_t MCalibrationChargePINDiode::fgChargeToPhotons = -1.;
|
---|
64 | const Float_t MCalibrationChargePINDiode::fgChargeToPhotonsErr = -1.;
|
---|
65 | const Float_t MCalibrationChargePINDiode::gkSolidAngleRatio = 0.00007;
|
---|
66 | const Float_t MCalibrationChargePINDiode::gkSolidAngleRatioErr = 0.00002;
|
---|
67 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreen = -1.0;
|
---|
68 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlue = -1.0;
|
---|
69 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUV = -1.0;
|
---|
70 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1 = -1.0;
|
---|
71 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreenErr = -1.0;
|
---|
72 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlueErr = -1.0;
|
---|
73 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUVErr = -1.0;
|
---|
74 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1Err = -1.0;
|
---|
75 | // --------------------------------------------------------------------------
|
---|
76 | //
|
---|
77 | // Default Constructor.
|
---|
78 | //
|
---|
79 | // Sets:
|
---|
80 | // - fCalibFlags to 0
|
---|
81 | // - fChargeToPhotons to fgChargeToPhotons
|
---|
82 | // - fChargeToPhotonsVar to fgChargeToPhotonsErr*fgChargeToPhotonsErr
|
---|
83 | //
|
---|
84 | // Calls:
|
---|
85 | // - Clear()
|
---|
86 | //
|
---|
87 | MCalibrationChargePINDiode::MCalibrationChargePINDiode(const char *name, const char *title)
|
---|
88 | : fCalibFlags(0)
|
---|
89 | {
|
---|
90 |
|
---|
91 | fName = name ? name : "MCalibrationChargePINDiode";
|
---|
92 | fTitle = title ? title : "Container of the fit results of MHCalibrationChargePINDiode";
|
---|
93 |
|
---|
94 | SetChargeToPhotons();
|
---|
95 | SetChargeToPhotonsErr();
|
---|
96 |
|
---|
97 | Clear();
|
---|
98 |
|
---|
99 | }
|
---|
100 |
|
---|
101 | // ------------------------------------------------------------------------
|
---|
102 | //
|
---|
103 | // Sets:
|
---|
104 | // - all flags to kFALSE
|
---|
105 | // - all variables to -1.
|
---|
106 | //
|
---|
107 | // Calls:
|
---|
108 | // - MCalibrationPix::Clear()
|
---|
109 | //
|
---|
110 | void MCalibrationChargePINDiode::Clear(Option_t *o)
|
---|
111 | {
|
---|
112 |
|
---|
113 | SetOscillating ( kFALSE );
|
---|
114 | SetChargeFitValid ( kFALSE );
|
---|
115 | SetTimeFitValid ( kFALSE );
|
---|
116 |
|
---|
117 | fAbsTimeMean = -1.;
|
---|
118 | fAbsTimeRms = -1.;
|
---|
119 | fFluxOutsidePlexiglass = -1.;
|
---|
120 | fFluxOutsidePlexiglassVar = -1.;
|
---|
121 | fNumPhotons = -1.;
|
---|
122 | fNumPhotonsVar = -1.;
|
---|
123 | fPed = -1.;
|
---|
124 | fPedRms = -1.;
|
---|
125 | fRmsChargeMean = -1.;
|
---|
126 | fRmsChargeMeanErr = -1.;
|
---|
127 | fRmsChargeSigma = -1.;
|
---|
128 | fRmsChargeSigmaErr = -1.;
|
---|
129 |
|
---|
130 | MCalibrationPix::Clear();
|
---|
131 | }
|
---|
132 |
|
---|
133 |
|
---|
134 | // --------------------------------------------------------------------------
|
---|
135 | //
|
---|
136 | // Set the pedestals from outside
|
---|
137 | //
|
---|
138 | void MCalibrationChargePINDiode::SetPedestal(Float_t ped, Float_t pedrms)
|
---|
139 | {
|
---|
140 |
|
---|
141 | fPed = ped;
|
---|
142 | fPedRms = pedrms;
|
---|
143 |
|
---|
144 | }
|
---|
145 |
|
---|
146 | // --------------------------------------------------------------------------
|
---|
147 | //
|
---|
148 | // Set the Oscillating Bit from outside
|
---|
149 | //
|
---|
150 | void MCalibrationChargePINDiode::SetOscillating( const Bool_t b)
|
---|
151 | {
|
---|
152 | b ? SETBIT(fCalibFlags,kOscillating) : CLRBIT(fCalibFlags,kOscillating);
|
---|
153 | }
|
---|
154 |
|
---|
155 |
|
---|
156 | // --------------------------------------------------------------------------
|
---|
157 | //
|
---|
158 | // Set the ChargeFitValid Bit from outside
|
---|
159 | //
|
---|
160 | void MCalibrationChargePINDiode::SetChargeFitValid(Bool_t b )
|
---|
161 | {
|
---|
162 | b ? SETBIT(fCalibFlags, kChargeFitValid) : CLRBIT(fCalibFlags, kChargeFitValid);
|
---|
163 | }
|
---|
164 |
|
---|
165 | // --------------------------------------------------------------------------
|
---|
166 | //
|
---|
167 | // Set the TimeFitValid Bit from outside
|
---|
168 | //
|
---|
169 | void MCalibrationChargePINDiode::SetTimeFitValid(Bool_t b )
|
---|
170 | {
|
---|
171 | b ? SETBIT(fCalibFlags, kTimeFitValid) : CLRBIT(fCalibFlags, kTimeFitValid);
|
---|
172 | }
|
---|
173 |
|
---|
174 | // --------------------------------------------------------------------------
|
---|
175 | //
|
---|
176 | // Set the FluxOutsidePlexiglassAvailable Bit from outside
|
---|
177 | //
|
---|
178 | void MCalibrationChargePINDiode::SetFluxOutsidePlexiglassAvailable (const Bool_t b)
|
---|
179 | {
|
---|
180 | b ? SETBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable)
|
---|
181 | : CLRBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable);
|
---|
182 | }
|
---|
183 |
|
---|
184 | // --------------------------------------------------------------------------
|
---|
185 | //
|
---|
186 | // Return -1 if fFluxOutsidePlexiglassVar is smaller than 0.
|
---|
187 | // Return square root of fFluxOutsidePlexiglassVar
|
---|
188 | //
|
---|
189 | Float_t MCalibrationChargePINDiode::GetFluxOutsidePlexiglassErr() const
|
---|
190 | {
|
---|
191 | if (fFluxOutsidePlexiglassVar < 0.)
|
---|
192 | return -1.;
|
---|
193 |
|
---|
194 | return TMath::Sqrt(fFluxOutsidePlexiglassVar);
|
---|
195 | }
|
---|
196 |
|
---|
197 | // --------------------------------------------------------------------------
|
---|
198 | //
|
---|
199 | // Return -1 if fFluxOutsidePlexiglassVar is smaller than 0.
|
---|
200 | // Return -1 if fFluxOutsidePlexiglass is 0.
|
---|
201 | // Return fFluxOutsidePlexiglassVar / fFluxOutsidePlexiglass^2
|
---|
202 | //
|
---|
203 | Float_t MCalibrationChargePINDiode::GetFluxOutsidePlexiglassRelVar() const
|
---|
204 | {
|
---|
205 | if (fFluxOutsidePlexiglassVar < 0.)
|
---|
206 | return -1.;
|
---|
207 |
|
---|
208 | if (fFluxOutsidePlexiglass == 0.)
|
---|
209 | return -1.;
|
---|
210 |
|
---|
211 | return fFluxOutsidePlexiglassVar / (fFluxOutsidePlexiglass * fFluxOutsidePlexiglass );
|
---|
212 | }
|
---|
213 |
|
---|
214 | // --------------------------------------------------------------------------
|
---|
215 | //
|
---|
216 | // Return -1 if fNumPhotonsVar is smaller than 0.
|
---|
217 | // Return square root of fNumPhotonsVar
|
---|
218 | //
|
---|
219 | Float_t MCalibrationChargePINDiode::GetNumPhotonsErr() const
|
---|
220 | {
|
---|
221 | if (fNumPhotonsVar < 0.)
|
---|
222 | return -1.;
|
---|
223 |
|
---|
224 | return TMath::Sqrt(fNumPhotonsVar);
|
---|
225 | }
|
---|
226 |
|
---|
227 | // --------------------------------------------------------------------------
|
---|
228 | //
|
---|
229 | // Return -1 if fNumPhotonsVar is smaller than 0.
|
---|
230 | // Return -1 if fNumPhotons is 0.
|
---|
231 | // Return fNumPhotonsVar / (fNumPhotons^2 )
|
---|
232 | //
|
---|
233 | Float_t MCalibrationChargePINDiode::GetNumPhotonsRelVar() const
|
---|
234 | {
|
---|
235 | if (fNumPhotonsVar < 0.)
|
---|
236 | return -1.;
|
---|
237 |
|
---|
238 | if (fNumPhotons == 0.)
|
---|
239 | return -1.;
|
---|
240 |
|
---|
241 | return fNumPhotonsVar / fNumPhotons / fNumPhotons ;
|
---|
242 | }
|
---|
243 |
|
---|
244 |
|
---|
245 | // --------------------------------------------------------------------------
|
---|
246 | //
|
---|
247 | // Return -1 if gkPINDiodeQEGreenErr is smaller than 0.
|
---|
248 | // Return -1 if gkPINDiodeQEGreen is 0.
|
---|
249 | // Return gkPINDiodeQEGreenErr^2 / (gkPINDiodeQEGreen^2 )
|
---|
250 | //
|
---|
251 | const Float_t MCalibrationChargePINDiode::GetPINDiodeQEGreenRelVar() const
|
---|
252 | {
|
---|
253 | if (gkPINDiodeQEGreenErr < 0.)
|
---|
254 | return -1.;
|
---|
255 |
|
---|
256 | if (gkPINDiodeQEGreen == 0.)
|
---|
257 | return -1.;
|
---|
258 |
|
---|
259 | return gkPINDiodeQEGreenErr * gkPINDiodeQEGreenErr / gkPINDiodeQEGreen / gkPINDiodeQEGreen ;
|
---|
260 | }
|
---|
261 |
|
---|
262 | // --------------------------------------------------------------------------
|
---|
263 | //
|
---|
264 | // Return -1 if gkPINDiodeQEBlueErr is smaller than 0.
|
---|
265 | // Return -1 if gkPINDiodeQEBlue is 0.
|
---|
266 | // Return gkPINDiodeQEBlueErr^2 / gkPINDiodeQEBlue^2
|
---|
267 | //
|
---|
268 | const Float_t MCalibrationChargePINDiode::GetPINDiodeQEBlueRelVar() const
|
---|
269 | {
|
---|
270 | if (gkPINDiodeQEBlueErr < 0.)
|
---|
271 | return -1.;
|
---|
272 |
|
---|
273 | if (gkPINDiodeQEBlue == 0.)
|
---|
274 | return -1.;
|
---|
275 |
|
---|
276 | return gkPINDiodeQEBlueErr * gkPINDiodeQEBlueErr / gkPINDiodeQEBlue / gkPINDiodeQEBlue ;
|
---|
277 | }
|
---|
278 |
|
---|
279 | // --------------------------------------------------------------------------
|
---|
280 | //
|
---|
281 | // Return -1 if gkPINDiodeQEUVErr is smaller than 0.
|
---|
282 | // Return -1 if gkPINDiodeQEUV is 0.
|
---|
283 | // Return gkPINDiodeQEUVErr ^2 / gkPINDiodeQEUV^2
|
---|
284 | //
|
---|
285 | const Float_t MCalibrationChargePINDiode::GetPINDiodeQEUVRelVar() const
|
---|
286 | {
|
---|
287 | if (gkPINDiodeQEUVErr < 0.)
|
---|
288 | return -1.;
|
---|
289 |
|
---|
290 | if (gkPINDiodeQEUV == 0.)
|
---|
291 | return -1.;
|
---|
292 |
|
---|
293 | return gkPINDiodeQEUVErr * gkPINDiodeQEUVErr / gkPINDiodeQEUV / gkPINDiodeQEUV ;
|
---|
294 | }
|
---|
295 |
|
---|
296 | // --------------------------------------------------------------------------
|
---|
297 | //
|
---|
298 | // Return -1 if gkPINDiodeQECT1Err is smaller than 0.
|
---|
299 | // Return -1 if gkPINDiodeQECT1 is 0.
|
---|
300 | // Return gkPINDiodeQECT1Err ^2 / gkPINDiodeQECT1^2
|
---|
301 | //
|
---|
302 | const Float_t MCalibrationChargePINDiode::GetPINDiodeQECT1RelVar() const
|
---|
303 | {
|
---|
304 | if (gkPINDiodeQECT1Err < 0.)
|
---|
305 | return -1.;
|
---|
306 |
|
---|
307 | if (gkPINDiodeQECT1 == 0.)
|
---|
308 | return -1.;
|
---|
309 |
|
---|
310 | return gkPINDiodeQECT1Err * gkPINDiodeQECT1Err / gkPINDiodeQECT1 / gkPINDiodeQECT1 ;
|
---|
311 | }
|
---|
312 |
|
---|
313 | // --------------------------------------------------------------------------
|
---|
314 | //
|
---|
315 | // Return -1 if gkSolidAngleRatioErr is smaller than 0.
|
---|
316 | // Return -1 if gkSolidAngleRatio is 0.
|
---|
317 | // Return gkSolidAngleRatioErr ^2 / gkSolidAngleRatio^2
|
---|
318 | //
|
---|
319 | const Float_t MCalibrationChargePINDiode::GetSolidAngleRatioRelVar() const
|
---|
320 | {
|
---|
321 | if (gkSolidAngleRatioErr < 0.)
|
---|
322 | return -1.;
|
---|
323 |
|
---|
324 | if (gkSolidAngleRatio == 0.)
|
---|
325 | return -1.;
|
---|
326 |
|
---|
327 | return gkSolidAngleRatioErr * gkSolidAngleRatioErr / gkSolidAngleRatio / gkSolidAngleRatio ;
|
---|
328 | }
|
---|
329 |
|
---|
330 |
|
---|
331 | // --------------------------------------------------------------------------
|
---|
332 | //
|
---|
333 | // Test bit kChargeFitValid
|
---|
334 | //
|
---|
335 | Bool_t MCalibrationChargePINDiode::IsChargeFitValid() const
|
---|
336 | {
|
---|
337 | return TESTBIT(fCalibFlags, kChargeFitValid);
|
---|
338 | }
|
---|
339 |
|
---|
340 | // --------------------------------------------------------------------------
|
---|
341 | //
|
---|
342 | // Test bit kFluxOutsidePlexiglassAvailable
|
---|
343 | //
|
---|
344 | Bool_t MCalibrationChargePINDiode::IsFluxOutsidePlexiglassAvailable() const
|
---|
345 | {
|
---|
346 | return TESTBIT(fFlags,kFluxOutsidePlexiglassAvailable);
|
---|
347 | }
|
---|
348 |
|
---|
349 |
|
---|
350 | // --------------------------------------------------------------------------
|
---|
351 | //
|
---|
352 | // Test bit kTimeFitValid
|
---|
353 | //
|
---|
354 | Bool_t MCalibrationChargePINDiode::IsTimeFitValid() const
|
---|
355 | {
|
---|
356 | return TESTBIT(fCalibFlags, kTimeFitValid);
|
---|
357 | }
|
---|
358 |
|
---|
359 | // --------------------------------------------------------------------------
|
---|
360 | //
|
---|
361 | // Test bit kOscillating
|
---|
362 | //
|
---|
363 | Bool_t MCalibrationChargePINDiode::IsOscillating() const
|
---|
364 | {
|
---|
365 | return TESTBIT(fCalibFlags, kOscillating);
|
---|
366 | }
|
---|
367 |
|
---|
368 | // --------------------------------------------------------------------------
|
---|
369 | //
|
---|
370 | // Return kFALSE if IsChargeFitValid() is kFALSE
|
---|
371 | //
|
---|
372 | // Calculate fFluxOutsidePlexiglass with the formula:
|
---|
373 | // - fFluxOutsidePlexiglass = fNumPhotons*gkSolidAngleRatio / gkPINDiodeQE (of the corr. colour)
|
---|
374 | // - fFluxOutsidePlexiglassVar = sqrt( fNumPhotonsVar / ( fNumPhotons * fNumPhotons )
|
---|
375 | // + ( gkSolidAngleRatioErr * gkSolidAngleRatioErr / gkSolidAngleRatio / gkSolidAngleRatio )
|
---|
376 | // + ( gkPINDiodeQEErr * gkPINDiodeQEErr / gkPINDiodeQE / gkPINDiodeQE )
|
---|
377 | // ) * fFluxOutsidePlexiglass * * fFluxOutsidePlexiglass
|
---|
378 | //
|
---|
379 | // If the fFluxOutsidePlexiglass is smaller than 0., return kFALSE
|
---|
380 | // If the Variance is smaller than 0., return kFALSE
|
---|
381 | //
|
---|
382 | // SetFluxOutsidePlexiglassAvailable() and return kTRUE
|
---|
383 | //
|
---|
384 | Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
|
---|
385 | {
|
---|
386 |
|
---|
387 | if (IsChargeFitValid())
|
---|
388 | return kFALSE;
|
---|
389 |
|
---|
390 | //
|
---|
391 | // Start calculation of number of photons per mm^2 on an inner pixel:
|
---|
392 | // Correct for the distance between camera and PIN Diode and for different areas.
|
---|
393 | //
|
---|
394 | switch (fColor)
|
---|
395 | {
|
---|
396 | case MCalibrationCam::kGREEN:
|
---|
397 | fFluxOutsidePlexiglass = fNumPhotons * gkSolidAngleRatio * gkPINDiodeQEGreen;
|
---|
398 | fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar() + GetPINDiodeQEGreenRelVar();
|
---|
399 | break;
|
---|
400 | case MCalibrationCam::kBLUE:
|
---|
401 | fFluxOutsidePlexiglass = fNumPhotons * gkSolidAngleRatio * gkPINDiodeQEBlue;
|
---|
402 | fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar() + GetPINDiodeQEBlueRelVar();
|
---|
403 | break;
|
---|
404 | case MCalibrationCam::kUV:
|
---|
405 | fFluxOutsidePlexiglass = fNumPhotons * gkSolidAngleRatio * gkPINDiodeQEUV;
|
---|
406 | fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar() + GetPINDiodeQEUVRelVar();
|
---|
407 | break;
|
---|
408 | case MCalibrationCam::kCT1:
|
---|
409 | default:
|
---|
410 | fFluxOutsidePlexiglass = fNumPhotons * gkSolidAngleRatio * gkPINDiodeQECT1;
|
---|
411 | fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar() + GetPINDiodeQECT1RelVar();
|
---|
412 | break;
|
---|
413 | }
|
---|
414 |
|
---|
415 | //
|
---|
416 | // Finish calculation of errors -> convert from relative variance to absolute variance
|
---|
417 | //
|
---|
418 | fFluxOutsidePlexiglassVar *= fFluxOutsidePlexiglass * fFluxOutsidePlexiglass;
|
---|
419 |
|
---|
420 | if (fFluxOutsidePlexiglass < 0.)
|
---|
421 | return kFALSE;
|
---|
422 |
|
---|
423 | if (fFluxOutsidePlexiglassVar < 0.)
|
---|
424 | return kFALSE;
|
---|
425 |
|
---|
426 | SetFluxOutsidePlexiglassAvailable();
|
---|
427 |
|
---|
428 | *fLog << inf << endl;
|
---|
429 | *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: "
|
---|
430 | << Form("%5.3f%s%5.3f",fFluxOutsidePlexiglass," +- ",GetFluxOutsidePlexiglassErr()) << endl;
|
---|
431 |
|
---|
432 | return kTRUE;
|
---|
433 | }
|
---|