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

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