source: branches/Mars_MC/mcalib/MCalibrationChargePINDiode.cc@ 17038

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