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

Last change on this file since 3663 was 3662, checked in by gaug, 21 years ago
*** empty log message ***
File size: 10.1 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
115 fAbsTimeMean = -1.;
116 fAbsTimeRms = -1.;
117 fFluxOutsidePlexiglass = -1.;
118 fFluxOutsidePlexiglassVar = -1.;
119 fNumPhotons = -1.;
120 fNumPhotonsVar = -1.;
121 fPed = -1.;
122 fPedRms = -1.;
123 fRmsChargeMean = -1.;
124 fRmsChargeMeanErr = -1.;
125 fRmsChargeSigma = -1.;
126 fRmsChargeSigmaErr = -1.;
127
128 MCalibrationPix::Clear();
129}
130
131
132// --------------------------------------------------------------------------
133//
134// Set the pedestals from outside
135//
136void MCalibrationChargePINDiode::SetPedestal(Float_t ped, Float_t pedrms)
137{
138
139 fPed = ped;
140 fPedRms = pedrms;
141
142}
143
144// --------------------------------------------------------------------------
145//
146// Set the Oscillating Bit from outside
147//
148void MCalibrationChargePINDiode::SetOscillating( const Bool_t b)
149{
150 b ? SETBIT(fCalibFlags,kOscillating) : CLRBIT(fCalibFlags,kOscillating);
151}
152
153
154// --------------------------------------------------------------------------
155//
156// Set the ChargeFitValid Bit from outside
157//
158void MCalibrationChargePINDiode::SetChargeFitValid(Bool_t b )
159{
160 b ? SETBIT(fCalibFlags, kChargeFitValid) : CLRBIT(fCalibFlags, kChargeFitValid);
161}
162
163// --------------------------------------------------------------------------
164//
165// Set the TimeFitValid Bit from outside
166//
167void MCalibrationChargePINDiode::SetTimeFitValid(Bool_t b )
168{
169 b ? SETBIT(fCalibFlags, kTimeFitValid) : CLRBIT(fCalibFlags, kTimeFitValid);
170}
171
172// --------------------------------------------------------------------------
173//
174// Set the FluxOutsidePlexiglassAvailable Bit from outside
175//
176void MCalibrationChargePINDiode::SetFluxOutsidePlexiglassAvailable (const Bool_t b)
177{
178 b ? SETBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable)
179 : CLRBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable);
180}
181
182// --------------------------------------------------------------------------
183//
184// Return -1 if fFluxOutsidePlexiglassVar is smaller than 0.
185// Return square root of fFluxOutsidePlexiglassVar
186//
187Float_t MCalibrationChargePINDiode::GetFluxOutsidePlexiglassErr() const
188{
189 if (fFluxOutsidePlexiglassVar < 0.)
190 return -1.;
191
192 return TMath::Sqrt(fFluxOutsidePlexiglassVar);
193}
194
195
196// --------------------------------------------------------------------------
197//
198// Test bit kChargeFitValid
199//
200Bool_t MCalibrationChargePINDiode::IsChargeFitValid() const
201{
202 return TESTBIT(fCalibFlags, kChargeFitValid);
203}
204
205// --------------------------------------------------------------------------
206//
207// Test bit kFluxOutsidePlexiglassAvailable
208//
209Bool_t MCalibrationChargePINDiode::IsFluxOutsidePlexiglassAvailable() const
210{
211 return TESTBIT(fFlags,kFluxOutsidePlexiglassAvailable);
212}
213
214
215// --------------------------------------------------------------------------
216//
217// Test bit kTimeFitValid
218//
219Bool_t MCalibrationChargePINDiode::IsTimeFitValid() const
220{
221 return TESTBIT(fCalibFlags, kTimeFitValid);
222}
223
224// --------------------------------------------------------------------------
225//
226// Test bit kOscillating
227//
228Bool_t MCalibrationChargePINDiode::IsOscillating() const
229{
230 return TESTBIT(fCalibFlags, kOscillating);
231}
232
233// --------------------------------------------------------------------------
234//
235// Return kFALSE if IsChargeFitValid() is kFALSE
236//
237// Calculate fFluxOutsidePlexiglass with the formula:
238// - fFluxOutsidePlexiglass = fNumPhotons*gkSolidAngleRatio / gkPINDiodeQE (of the corr. colour)
239// - fFluxOutsidePlexiglassVar = sqrt( fNumPhotonsVar / ( fNumPhotons * fNumPhotons )
240// + ( gkSolidAngleRatioErr * gkSolidAngleRatioErr / gkSolidAngleRatio / gkSolidAngleRatio )
241// + ( gkPINDiodeQEErr * gkPINDiodeQEErr / gkPINDiodeQE / gkPINDiodeQE )
242// ) * fFluxOutsidePlexiglass * * fFluxOutsidePlexiglass
243//
244// If the fFluxOutsidePlexiglass is smaller than 0., return kFALSE
245// If the Variance is smaller than 0., return kFALSE
246//
247// SetFluxOutsidePlexiglassAvailable() and return kTRUE
248//
249Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
250{
251
252 if (IsChargeFitValid())
253 return kFALSE;
254
255 //
256 // Start calculation of number of photons per mm^2 on an inner pixel:
257 // Correct for the distance between camera and PIN Diode and for different areas.
258 //
259 fFluxOutsidePlexiglass = fNumPhotons * gkSolidAngleRatio;
260
261 //
262 // Start calculation of number of photons relative Variance (!!)
263 //
264 const Float_t numphotRelVar = fNumPhotonsVar / ( fNumPhotons * fNumPhotons ) ;
265 const Float_t solidangleRelVar = gkSolidAngleRatioErr* gkSolidAngleRatioErr
266 / ( gkSolidAngleRatio * gkSolidAngleRatio );
267 Float_t fluxRelVar = numphotRelVar + solidangleRelVar ;
268
269 switch (fColor)
270 {
271 case kGREEN:
272 fFluxOutsidePlexiglass /= gkPINDiodeQEGreen;
273 fluxRelVar += gkPINDiodeQEGreenErr* gkPINDiodeQEGreenErr
274 / ( gkPINDiodeQEGreen * gkPINDiodeQEGreen );
275 break;
276 case kBLUE:
277 fFluxOutsidePlexiglass /= gkPINDiodeQEBlue;
278 fluxRelVar += gkPINDiodeQEBlueErr* gkPINDiodeQEBlueErr
279 / ( gkPINDiodeQEBlue * gkPINDiodeQEBlue );
280 break;
281 case kUV:
282 fFluxOutsidePlexiglass /= gkPINDiodeQEUV;
283 fluxRelVar += gkPINDiodeQEUVErr* gkPINDiodeQEUVErr
284 / ( gkPINDiodeQEUV * gkPINDiodeQEUV );
285 break;
286 case kCT1:
287 default:
288 fFluxOutsidePlexiglass /= gkPINDiodeQECT1;
289 fluxRelVar += gkPINDiodeQECT1Err* gkPINDiodeQECT1Err
290 / ( gkPINDiodeQECT1 * gkPINDiodeQECT1 );
291 break;
292 }
293
294
295 *fLog << inf << endl;
296 *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: "
297 << fFluxOutsidePlexiglass << endl;
298
299 if (fFluxOutsidePlexiglass < 0.)
300 return kFALSE;
301
302 if (fluxRelVar < 0.)
303 return kFALSE;
304
305 SetFluxOutsidePlexiglassAvailable();
306
307 //
308 // Finish calculation of errors -> convert from relative variance to absolute variance
309 //
310 fFluxOutsidePlexiglassVar *= fluxRelVar * fFluxOutsidePlexiglass * fFluxOutsidePlexiglass;
311
312 *fLog << inf << " Error on Photon flux [ph/mm^2] outside Plexiglass: "
313 << GetFluxOutsidePlexiglassErr() << endl;
314 *fLog << inf << endl;
315
316 return kTRUE;
317}
Note: See TracBrowser for help on using the repository browser.