source: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc@ 7599

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