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

Last change on this file since 3421 was 3315, checked in by gaug, 21 years ago
*** empty log message ***
File size: 11.5 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// 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
38ClassImp(MCalibrationChargePINDiode);
39
40using namespace std;
41
42const Float_t MCalibrationChargePINDiode::fgChargeLimit = 3.;
43const Float_t MCalibrationChargePINDiode::fgChargeErrLimit = 0.;
44const Float_t MCalibrationChargePINDiode::fgChargeRelErrLimit = 1.;
45
46const Float_t MCalibrationChargePINDiode::fgConversionChargePhotons = -1.;
47const 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//
64const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiode = 0.007;
65const Float_t MCalibrationChargePINDiode::gkFluxCameravsPINDiodeErr = 0.003;
66//
67// Average QE of the PIN Diode
68//
69const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreen = -1.0;
70const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlue = -1.0;
71const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUV = -1.0;
72const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1 = -1.0;
73//
74// Average QE of the PIN Diode
75//
76const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreenErr = -1.0;
77const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlueErr = -1.0;
78const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUVErr = -1.0;
79const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1Err = -1.0;
80
81const Float_t MCalibrationChargePINDiode::gkPINDiodeArea = 100;
82// --------------------------------------------------------------------------
83//
84// Default Constructor.
85//
86MCalibrationChargePINDiode::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 SetExcluded(kFALSE);
103 SetExcludeQualityCheck(kFALSE);
104}
105
106// ------------------------------------------------------------------------
107//
108// Invalidate values
109//
110void MCalibrationChargePINDiode::Clear(Option_t *o)
111{
112
113 SetChargeFitValid ( kFALSE );
114 SetTimeFitValid ( kFALSE );
115 SetMeanTimeInFirstBin ( kFALSE );
116 SetMeanTimeInLastBin ( kFALSE );
117
118 fMeanCharge = -1.;
119 fMeanChargeErr = -1.;
120 fSigmaCharge = -1.;
121 fSigmaChargeErr = -1.;
122 fChargeProb = -1.;
123 fPed = -1.;
124 fPedRms = -1.;
125
126 fRmsChargeMean = -1.;
127 fRmsChargeMeanErr = -1.;
128 fRmsChargeSigma = -1.;
129 fRmsChargeSigmaErr = -1.;
130
131 fAbsTimeMean = -1.;
132 fAbsTimeRms = -1.;
133
134 fTimeLowerEdge = -1.;
135 fTimeUpperEdge = -1.;
136
137 fConvertedPhotons = -1.;
138 fConvertedPhotonsErr = -1.;
139
140 fMeanFluxOutsidePlexiglass = -1.;
141 fMeanFluxErrOutsidePlexiglass = -1.;
142
143}
144
145
146// --------------------------------------------------------------------------
147//
148// Set the pedestals from outside
149//
150void MCalibrationChargePINDiode::SetPedestal(Float_t ped, Float_t pedrms)
151{
152
153 fPed = ped;
154 fPedRms = pedrms;
155
156}
157
158// --------------------------------------------------------------------------
159//
160// Set the Excluded Bit from outside
161//
162void MCalibrationChargePINDiode::SetExcluded(Bool_t b )
163{
164 b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
165}
166
167
168// --------------------------------------------------------------------------
169//
170// Set the Excluded Bit from outside
171//
172void MCalibrationChargePINDiode::SetExcludeQualityCheck(Bool_t b )
173{
174 b ? SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck);
175}
176
177// --------------------------------------------------------------------------
178//
179// Set the Excluded Bit from outside
180//
181void MCalibrationChargePINDiode::SetChargeFitValid(Bool_t b )
182{
183 b ? SETBIT(fFlags, kChargeFitValid) : CLRBIT(fFlags, kChargeFitValid);
184}
185
186// --------------------------------------------------------------------------
187//
188// Set the Excluded Bit from outside
189//
190void MCalibrationChargePINDiode::SetTimeFitValid(Bool_t b )
191{
192 b ? SETBIT(fFlags, kTimeFitValid) : CLRBIT(fFlags, kTimeFitValid);
193}
194
195void MCalibrationChargePINDiode::SetFluxOutsidePlexiglassAvailable (const Bool_t b)
196{
197 b ? SETBIT(fFlags, kFluxOutsidePlexiglassAvailable) : CLRBIT(fFlags, kFluxOutsidePlexiglassAvailable);
198}
199
200void MCalibrationChargePINDiode::SetMeanTimeInFirstBin(const Bool_t b)
201{
202 b ? SETBIT(fFlags,kMeanTimeInFirstBin) : CLRBIT(fFlags,kMeanTimeInFirstBin);
203}
204
205void MCalibrationChargePINDiode::SetMeanTimeInLastBin(const Bool_t b)
206{
207 b ? SETBIT(fFlags,kMeanTimeInLastBin) : CLRBIT(fFlags,kMeanTimeInLastBin);
208}
209
210Bool_t MCalibrationChargePINDiode::IsMeanTimeInFirstBin() const
211{
212 return TESTBIT(fFlags,kMeanTimeInFirstBin);
213}
214
215Bool_t MCalibrationChargePINDiode::IsMeanTimeInLastBin() const
216{
217 return TESTBIT(fFlags,kMeanTimeInLastBin);
218}
219
220Bool_t MCalibrationChargePINDiode::IsExcluded() const
221{
222 return TESTBIT(fFlags,kExcluded);
223}
224
225Bool_t MCalibrationChargePINDiode::IsChargeFitValid() const
226{
227 return TESTBIT(fFlags, kChargeFitValid);
228}
229
230Bool_t MCalibrationChargePINDiode::IsTimeFitValid() const
231{
232 return TESTBIT(fFlags, kTimeFitValid);
233}
234
235//
236// The check return kTRUE if:
237//
238// 1) PINDiode has a fitted charge greater than fChargeLimit*PedRMS
239// 2) PINDiode has a fit error greater than fChargeErrLimit
240// 3) PINDiode has a fitted charge greater its fChargeRelErrLimit times its charge error
241// 4) PINDiode has a charge sigma bigger than its Pedestal RMS
242//
243Bool_t MCalibrationChargePINDiode::CheckChargeFitValidity()
244{
245
246
247 if (fMeanCharge < fChargeLimit*GetPedRms())
248 {
249 *fLog << warn << "WARNING: Fitted Charge is smaller than "
250 << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
251 return kFALSE;
252 }
253
254 if (fMeanChargeErr < fChargeErrLimit)
255 {
256 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
257 << fChargeErrLimit << " in PINDiode " << endl;
258 return kFALSE;
259 }
260
261 if (fMeanCharge < fChargeRelErrLimit*fMeanChargeErr)
262 {
263 *fLog << warn << "WARNING: Fitted Charge is smaller than "
264 << fChargeRelErrLimit << "* its error in PINDiode " << endl;
265 return kFALSE;
266 }
267
268 if (fSigmaCharge < GetPedRms())
269 {
270 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
271 return kFALSE;
272 }
273 return kTRUE;
274}
275
276//
277// The check returns kTRUE if:
278//
279// The mean arrival time is at least 1.0 slices from the used edge slices
280//
281Bool_t MCalibrationChargePINDiode::CheckTimeFitValidity()
282{
283
284 if ( fAbsTimeMean < fTimeLowerEdge+1.)
285 {
286 *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the PINDiode " << endl;
287 SetMeanTimeInFirstBin();
288 return kFALSE;
289 }
290
291 if ( fAbsTimeMean > fTimeUpperEdge-1.)
292 {
293 *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the PINDiode " << endl;
294 SetMeanTimeInLastBin();
295 return kFALSE;
296 }
297
298 return kTRUE;
299}
300
301Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
302{
303
304 if (IsChargeFitValid())
305 return kFALSE;
306
307 // Start calculation of number of photons per mm^2 on the camera
308 fMeanFluxOutsidePlexiglass = fConvertedPhotons * gkPINDiodeArea;
309 // Correct for the distance between camera and PIN Diode and for different areas.
310 fMeanFluxOutsidePlexiglass *= gkFluxCameravsPINDiode;
311
312 // Start calculation of number of photons relative Variance (!!)
313 fMeanFluxErrOutsidePlexiglass = fConvertedPhotonsErr * fConvertedPhotonsErr
314 / fConvertedPhotons / fConvertedPhotons ;
315 fMeanFluxErrOutsidePlexiglass += gkFluxCameravsPINDiodeErr*gkFluxCameravsPINDiodeErr
316 / gkFluxCameravsPINDiode/gkFluxCameravsPINDiode;
317
318 switch (fColor)
319 {
320 case kGREEN:
321 fMeanFluxOutsidePlexiglass /= gkPINDiodeQEGreen;
322 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEGreenErr*gkPINDiodeQEGreenErr
323 / gkPINDiodeQEGreen/gkPINDiodeQEGreen;
324 break;
325 case kBLUE:
326 fMeanFluxOutsidePlexiglass /= gkPINDiodeQEBlue;
327 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEBlueErr*gkPINDiodeQEBlueErr
328 / gkPINDiodeQEBlue/gkPINDiodeQEBlue;
329 break;
330 case kUV:
331 fMeanFluxOutsidePlexiglass /= gkPINDiodeQEUV;
332 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEUVErr*gkPINDiodeQEUVErr
333 / gkPINDiodeQEUV/gkPINDiodeQEUV;
334 break;
335 case kCT1:
336 default:
337 fMeanFluxOutsidePlexiglass /= gkPINDiodeQECT1;
338 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQECT1Err*gkPINDiodeQECT1Err
339 / gkPINDiodeQECT1/gkPINDiodeQECT1;
340 break;
341 }
342
343
344 *fLog << inf << endl;
345 *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: "
346 << fMeanFluxOutsidePlexiglass << endl;
347
348 if (fMeanFluxOutsidePlexiglass < 0.)
349 return kFALSE;
350
351 if (fMeanFluxErrOutsidePlexiglass < 0.)
352 return kFALSE;
353
354 SetFluxOutsidePlexiglassAvailable();
355
356 // Finish calculation of errors -> convert from relative variance to absolute error
357 fMeanFluxErrOutsidePlexiglass = TMath::Sqrt(fMeanFluxErrOutsidePlexiglass);
358 fMeanFluxErrOutsidePlexiglass *= fMeanFluxOutsidePlexiglass;
359
360 *fLog << inf << " Error on Photon flux [ph/mm^2] outside Plexiglass: "
361 << fMeanFluxErrOutsidePlexiglass << endl;
362 *fLog << inf << endl;
363
364 return kTRUE;
365}
366
367
368
Note: See TracBrowser for help on using the repository browser.