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 | // This is the storage container to hold informations about the pedestal //
|
---|
30 | // (offset) value of one Pixel (PMT). //
|
---|
31 | // //
|
---|
32 | /////////////////////////////////////////////////////////////////////////////
|
---|
33 | #include "MCalibrationChargePINDiode.h"
|
---|
34 |
|
---|
35 | #include "MLog.h"
|
---|
36 | #include "MLogManip.h"
|
---|
37 |
|
---|
38 | ClassImp(MCalibrationChargePINDiode);
|
---|
39 |
|
---|
40 | using namespace std;
|
---|
41 |
|
---|
42 | const Float_t MCalibrationChargePINDiode::fgChargeLimit = 3.;
|
---|
43 | const Float_t MCalibrationChargePINDiode::fgChargeErrLimit = 0.;
|
---|
44 | const Float_t MCalibrationChargePINDiode::fgChargeRelErrLimit = 1.;
|
---|
45 |
|
---|
46 | const Float_t MCalibrationChargePINDiode::fgConversionChargePhotons = -1.;
|
---|
47 | const Float_t MCalibrationChargePINDiode::fgConversionChargePhotonsErr = -1.;
|
---|
48 | //
|
---|
49 | // Area of Inner Pixel w.r.t. PIN Diode (which is 1 cm2)
|
---|
50 | //
|
---|
51 | // Distance of PIN Diode to pulser D1: 1.5 +- 0.3 m
|
---|
52 | // Distance of Inner Pixel to pulser D2: 18.0 +- 0.5 m
|
---|
53 | //
|
---|
54 | //
|
---|
55 | // D1*D1
|
---|
56 | // conversion C = ------ = 0.0069
|
---|
57 | // D2*D2
|
---|
58 | //
|
---|
59 | // Delta C / C = 2 * Sqrt( (Delta D1/D1)2 + (Delta D2/D2)2 )
|
---|
60 | // Delta C / C = 0.4
|
---|
61 | //
|
---|
62 | // C = 0.007 +- 0.003
|
---|
63 | //
|
---|
64 | const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiode = 0.007;
|
---|
65 | const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiodeErr = 0.003;
|
---|
66 | //
|
---|
67 | // Average QE of the PIN Diode
|
---|
68 | //
|
---|
69 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreen = -1.0;
|
---|
70 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlue = -1.0;
|
---|
71 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUV = -1.0;
|
---|
72 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1 = -1.0;
|
---|
73 | //
|
---|
74 | // Average QE of the PIN Diode
|
---|
75 | //
|
---|
76 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreenErr = -1.0;
|
---|
77 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlueErr = -1.0;
|
---|
78 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUVErr = -1.0;
|
---|
79 | const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1Err = -1.0;
|
---|
80 |
|
---|
81 | const Float_t MCalibrationChargePINDiode::gkPINDiodeArea = 100;
|
---|
82 | // --------------------------------------------------------------------------
|
---|
83 | //
|
---|
84 | // Default Constructor.
|
---|
85 | //
|
---|
86 | MCalibrationChargePINDiode::MCalibrationChargePINDiode(const char *name, const char *title)
|
---|
87 | : fFlags(0)
|
---|
88 | {
|
---|
89 |
|
---|
90 | fName = name ? name : "MCalibrationChargePINDiode";
|
---|
91 | fTitle = title ? title : "Container of the fit results of MHCalibrationChargePINDiode";
|
---|
92 |
|
---|
93 | Clear();
|
---|
94 |
|
---|
95 | SetChargeLimit();
|
---|
96 | SetChargeErrLimit();
|
---|
97 | SetChargeRelErrLimit();
|
---|
98 |
|
---|
99 | SetConversionChargePhotons();
|
---|
100 | SetConversionChargePhotonsErr();
|
---|
101 |
|
---|
102 | SetOscillating ( kFALSE );
|
---|
103 | SetExcluded ( kFALSE );
|
---|
104 | SetExcludeQualityCheck ( kFALSE );
|
---|
105 | }
|
---|
106 |
|
---|
107 | // ------------------------------------------------------------------------
|
---|
108 | //
|
---|
109 | // Invalidate values
|
---|
110 | //
|
---|
111 | void MCalibrationChargePINDiode::Clear(Option_t *o)
|
---|
112 | {
|
---|
113 |
|
---|
114 | SetChargeFitValid ( kFALSE );
|
---|
115 | SetTimeFitValid ( kFALSE );
|
---|
116 | SetMeanTimeInFirstBin ( kFALSE );
|
---|
117 | SetMeanTimeInLastBin ( kFALSE );
|
---|
118 |
|
---|
119 | fMeanCharge = -1.;
|
---|
120 | fMeanChargeErr = -1.;
|
---|
121 | fSigmaCharge = -1.;
|
---|
122 | fSigmaChargeErr = -1.;
|
---|
123 | fChargeProb = -1.;
|
---|
124 | fPed = -1.;
|
---|
125 | fPedRms = -1.;
|
---|
126 |
|
---|
127 | fRmsChargeMean = -1.;
|
---|
128 | fRmsChargeMeanErr = -1.;
|
---|
129 | fRmsChargeSigma = -1.;
|
---|
130 | fRmsChargeSigmaErr = -1.;
|
---|
131 |
|
---|
132 | fAbsTimeMean = -1.;
|
---|
133 | fAbsTimeRms = -1.;
|
---|
134 |
|
---|
135 | fTimeLowerEdge = -1.;
|
---|
136 | fTimeUpperEdge = -1.;
|
---|
137 |
|
---|
138 | fConvertedPhotons = -1.;
|
---|
139 | fConvertedPhotonsErr = -1.;
|
---|
140 |
|
---|
141 | fMeanFluxOutsidePlexiglass = -1.;
|
---|
142 | fMeanFluxErrOutsidePlexiglass = -1.;
|
---|
143 |
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|
147 | // --------------------------------------------------------------------------
|
---|
148 | //
|
---|
149 | // Set the pedestals from outside
|
---|
150 | //
|
---|
151 | void MCalibrationChargePINDiode::SetPedestal(Float_t ped, Float_t pedrms)
|
---|
152 | {
|
---|
153 |
|
---|
154 | fPed = ped;
|
---|
155 | fPedRms = pedrms;
|
---|
156 |
|
---|
157 | }
|
---|
158 |
|
---|
159 | // --------------------------------------------------------------------------
|
---|
160 | //
|
---|
161 | // Set the Oscillating Bit from outside
|
---|
162 | //
|
---|
163 | void MCalibrationChargePINDiode::SetOscillating( const Bool_t b)
|
---|
164 | {
|
---|
165 | b ? SETBIT(fFlags,kOscillating) : CLRBIT(fFlags,kOscillating);
|
---|
166 | }
|
---|
167 |
|
---|
168 | // --------------------------------------------------------------------------
|
---|
169 | //
|
---|
170 | // Set the Excluded Bit from outside
|
---|
171 | //
|
---|
172 | void MCalibrationChargePINDiode::SetExcluded(Bool_t b )
|
---|
173 | {
|
---|
174 | b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
|
---|
175 | }
|
---|
176 |
|
---|
177 |
|
---|
178 | // --------------------------------------------------------------------------
|
---|
179 | //
|
---|
180 | // Set the Excluded Bit from outside
|
---|
181 | //
|
---|
182 | void MCalibrationChargePINDiode::SetExcludeQualityCheck(Bool_t b )
|
---|
183 | {
|
---|
184 | b ? SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck);
|
---|
185 | }
|
---|
186 |
|
---|
187 | // --------------------------------------------------------------------------
|
---|
188 | //
|
---|
189 | // Set the Excluded Bit from outside
|
---|
190 | //
|
---|
191 | void MCalibrationChargePINDiode::SetChargeFitValid(Bool_t b )
|
---|
192 | {
|
---|
193 | b ? SETBIT(fFlags, kChargeFitValid) : CLRBIT(fFlags, kChargeFitValid);
|
---|
194 | }
|
---|
195 |
|
---|
196 | // --------------------------------------------------------------------------
|
---|
197 | //
|
---|
198 | // Set the Excluded Bit from outside
|
---|
199 | //
|
---|
200 | void MCalibrationChargePINDiode::SetTimeFitValid(Bool_t b )
|
---|
201 | {
|
---|
202 | b ? SETBIT(fFlags, kTimeFitValid) : CLRBIT(fFlags, kTimeFitValid);
|
---|
203 | }
|
---|
204 |
|
---|
205 | void MCalibrationChargePINDiode::SetFluxOutsidePlexiglassAvailable (const Bool_t b)
|
---|
206 | {
|
---|
207 | b ? SETBIT(fFlags, kFluxOutsidePlexiglassAvailable) : CLRBIT(fFlags, kFluxOutsidePlexiglassAvailable);
|
---|
208 | }
|
---|
209 |
|
---|
210 | void MCalibrationChargePINDiode::SetMeanTimeInFirstBin(const Bool_t b)
|
---|
211 | {
|
---|
212 | b ? SETBIT(fFlags,kMeanTimeInFirstBin) : CLRBIT(fFlags,kMeanTimeInFirstBin);
|
---|
213 | }
|
---|
214 |
|
---|
215 | void MCalibrationChargePINDiode::SetMeanTimeInLastBin(const Bool_t b)
|
---|
216 | {
|
---|
217 | b ? SETBIT(fFlags,kMeanTimeInLastBin) : CLRBIT(fFlags,kMeanTimeInLastBin);
|
---|
218 | }
|
---|
219 |
|
---|
220 | Bool_t MCalibrationChargePINDiode::IsMeanTimeInFirstBin() const
|
---|
221 | {
|
---|
222 | return TESTBIT(fFlags,kMeanTimeInFirstBin);
|
---|
223 | }
|
---|
224 |
|
---|
225 | Bool_t MCalibrationChargePINDiode::IsMeanTimeInLastBin() const
|
---|
226 | {
|
---|
227 | return TESTBIT(fFlags,kMeanTimeInLastBin);
|
---|
228 | }
|
---|
229 |
|
---|
230 | Bool_t MCalibrationChargePINDiode::IsExcluded() const
|
---|
231 | {
|
---|
232 | return TESTBIT(fFlags,kExcluded);
|
---|
233 | }
|
---|
234 |
|
---|
235 | Bool_t MCalibrationChargePINDiode::IsChargeFitValid() const
|
---|
236 | {
|
---|
237 | return TESTBIT(fFlags, kChargeFitValid);
|
---|
238 | }
|
---|
239 |
|
---|
240 | Bool_t MCalibrationChargePINDiode::IsTimeFitValid() const
|
---|
241 | {
|
---|
242 | return TESTBIT(fFlags, kTimeFitValid);
|
---|
243 | }
|
---|
244 |
|
---|
245 | //
|
---|
246 | // The check return kTRUE if:
|
---|
247 | //
|
---|
248 | // 1) PINDiode has a fitted charge greater than fChargeLimit*PedRMS
|
---|
249 | // 2) PINDiode has a fit error greater than fChargeErrLimit
|
---|
250 | // 3) PINDiode has a fitted charge greater its fChargeRelErrLimit times its charge error
|
---|
251 | // 4) PINDiode has a charge sigma bigger than its Pedestal RMS
|
---|
252 | //
|
---|
253 | Bool_t MCalibrationChargePINDiode::CheckChargeFitValidity()
|
---|
254 | {
|
---|
255 |
|
---|
256 |
|
---|
257 | if (fMeanCharge < fChargeLimit*GetPedRms())
|
---|
258 | {
|
---|
259 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
260 | << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
|
---|
261 | return kFALSE;
|
---|
262 | }
|
---|
263 |
|
---|
264 | if (fMeanChargeErr < fChargeErrLimit)
|
---|
265 | {
|
---|
266 | *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
|
---|
267 | << fChargeErrLimit << " in PINDiode " << endl;
|
---|
268 | return kFALSE;
|
---|
269 | }
|
---|
270 |
|
---|
271 | if (fMeanCharge < fChargeRelErrLimit*fMeanChargeErr)
|
---|
272 | {
|
---|
273 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
274 | << fChargeRelErrLimit << "* its error in PINDiode " << endl;
|
---|
275 | return kFALSE;
|
---|
276 | }
|
---|
277 |
|
---|
278 | if (fSigmaCharge < GetPedRms())
|
---|
279 | {
|
---|
280 | *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
|
---|
281 | return kFALSE;
|
---|
282 | }
|
---|
283 | return kTRUE;
|
---|
284 | }
|
---|
285 |
|
---|
286 | //
|
---|
287 | // The check returns kTRUE if:
|
---|
288 | //
|
---|
289 | // The mean arrival time is at least 1.0 slices from the used edge slices
|
---|
290 | //
|
---|
291 | Bool_t MCalibrationChargePINDiode::CheckTimeFitValidity()
|
---|
292 | {
|
---|
293 |
|
---|
294 | if ( fAbsTimeMean < fTimeLowerEdge+1.)
|
---|
295 | {
|
---|
296 | *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the PINDiode " << endl;
|
---|
297 | SetMeanTimeInFirstBin();
|
---|
298 | return kFALSE;
|
---|
299 | }
|
---|
300 |
|
---|
301 | if ( fAbsTimeMean > fTimeUpperEdge-1.)
|
---|
302 | {
|
---|
303 | *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the PINDiode " << endl;
|
---|
304 | SetMeanTimeInLastBin();
|
---|
305 | return kFALSE;
|
---|
306 | }
|
---|
307 |
|
---|
308 | return kTRUE;
|
---|
309 | }
|
---|
310 |
|
---|
311 | Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
|
---|
312 | {
|
---|
313 |
|
---|
314 | if (IsChargeFitValid())
|
---|
315 | return kFALSE;
|
---|
316 |
|
---|
317 | // Start calculation of number of photons per mm^2 on the camera
|
---|
318 | fMeanFluxOutsidePlexiglass = fConvertedPhotons * gkPINDiodeArea;
|
---|
319 | // Correct for the distance between camera and PIN Diode and for different areas.
|
---|
320 | fMeanFluxOutsidePlexiglass *= gkFluxCameravsPINDiode;
|
---|
321 |
|
---|
322 | // Start calculation of number of photons relative Variance (!!)
|
---|
323 | fMeanFluxErrOutsidePlexiglass = fConvertedPhotonsErr * fConvertedPhotonsErr
|
---|
324 | / fConvertedPhotons / fConvertedPhotons ;
|
---|
325 | fMeanFluxErrOutsidePlexiglass += gkFluxCameravsPINDiodeErr*gkFluxCameravsPINDiodeErr
|
---|
326 | / gkFluxCameravsPINDiode/gkFluxCameravsPINDiode;
|
---|
327 |
|
---|
328 | switch (fColor)
|
---|
329 | {
|
---|
330 | case kGREEN:
|
---|
331 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQEGreen;
|
---|
332 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEGreenErr*gkPINDiodeQEGreenErr
|
---|
333 | / gkPINDiodeQEGreen/gkPINDiodeQEGreen;
|
---|
334 | break;
|
---|
335 | case kBLUE:
|
---|
336 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQEBlue;
|
---|
337 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEBlueErr*gkPINDiodeQEBlueErr
|
---|
338 | / gkPINDiodeQEBlue/gkPINDiodeQEBlue;
|
---|
339 | break;
|
---|
340 | case kUV:
|
---|
341 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQEUV;
|
---|
342 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEUVErr*gkPINDiodeQEUVErr
|
---|
343 | / gkPINDiodeQEUV/gkPINDiodeQEUV;
|
---|
344 | break;
|
---|
345 | case kCT1:
|
---|
346 | default:
|
---|
347 | fMeanFluxOutsidePlexiglass /= gkPINDiodeQECT1;
|
---|
348 | fMeanFluxErrOutsidePlexiglass += gkPINDiodeQECT1Err*gkPINDiodeQECT1Err
|
---|
349 | / gkPINDiodeQECT1/gkPINDiodeQECT1;
|
---|
350 | break;
|
---|
351 | }
|
---|
352 |
|
---|
353 |
|
---|
354 | *fLog << inf << endl;
|
---|
355 | *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: "
|
---|
356 | << fMeanFluxOutsidePlexiglass << endl;
|
---|
357 |
|
---|
358 | if (fMeanFluxOutsidePlexiglass < 0.)
|
---|
359 | return kFALSE;
|
---|
360 |
|
---|
361 | if (fMeanFluxErrOutsidePlexiglass < 0.)
|
---|
362 | return kFALSE;
|
---|
363 |
|
---|
364 | SetFluxOutsidePlexiglassAvailable();
|
---|
365 |
|
---|
366 | // Finish calculation of errors -> convert from relative variance to absolute error
|
---|
367 | fMeanFluxErrOutsidePlexiglass = TMath::Sqrt(fMeanFluxErrOutsidePlexiglass);
|
---|
368 | fMeanFluxErrOutsidePlexiglass *= fMeanFluxOutsidePlexiglass;
|
---|
369 |
|
---|
370 | *fLog << inf << " Error on Photon flux [ph/mm^2] outside Plexiglass: "
|
---|
371 | << fMeanFluxErrOutsidePlexiglass << endl;
|
---|
372 | *fLog << inf << endl;
|
---|
373 |
|
---|
374 | return kTRUE;
|
---|
375 | }
|
---|
376 |
|
---|
377 |
|
---|
378 |
|
---|