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

Last change on this file since 3253 was 3247, checked in by gaug, 21 years ago
*** empty log message ***
File size: 11.7 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
195
196void MCalibrationChargePINDiode::SetMeanTimeInFirstBin(const Bool_t b)
197{
198 b ? SETBIT(fFlags,kMeanTimeInFirstBin) : CLRBIT(fFlags,kMeanTimeInFirstBin);
199}
200
201void MCalibrationChargePINDiode::SetMeanTimeInLastBin(const Bool_t b)
202{
203 b ? SETBIT(fFlags,kMeanTimeInLastBin) : CLRBIT(fFlags,kMeanTimeInLastBin);
204}
205
206Bool_t MCalibrationChargePINDiode::IsMeanTimeInFirstBin() const
207{
208 return TESTBIT(fFlags,kMeanTimeInFirstBin);
209}
210
211Bool_t MCalibrationChargePINDiode::IsMeanTimeInLastBin() const
212{
213 return TESTBIT(fFlags,kMeanTimeInLastBin);
214}
215
216Bool_t MCalibrationChargePINDiode::IsExcluded() const
217{
218 return TESTBIT(fFlags,kExcluded);
219}
220
221Bool_t MCalibrationChargePINDiode::IsChargeFitValid() const
222{
223 return TESTBIT(fFlags, kChargeFitValid);
224}
225
226Bool_t MCalibrationChargePINDiode::IsTimeFitValid() const
227{
228 return TESTBIT(fFlags, kTimeFitValid);
229}
230
231//
232// The check return kTRUE if:
233//
234// 1) PINDiode has a fitted charge greater than fChargeLimit*PedRMS
235// 2) PINDiode has a fit error greater than fChargeErrLimit
236// 3) PINDiode has a fitted charge greater its fChargeRelErrLimit times its charge error
237// 4) PINDiode has a charge sigma bigger than its Pedestal RMS
238//
239Bool_t MCalibrationChargePINDiode::CheckChargeFitValidity()
240{
241
242 if (TESTBIT(fFlags,kExcludeQualityCheck))
243 return kTRUE;
244
245 if (fMeanCharge < fChargeLimit*GetPedRms())
246 {
247 *fLog << warn << "WARNING: Fitted Charge is smaller than "
248 << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
249 return kFALSE;
250 }
251
252 if (fMeanChargeErr < fChargeErrLimit)
253 {
254 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
255 << fChargeErrLimit << " in PINDiode " << endl;
256 return kFALSE;
257 }
258
259 if (fMeanCharge < fChargeRelErrLimit*fMeanChargeErr)
260 {
261 *fLog << warn << "WARNING: Fitted Charge is smaller than "
262 << fChargeRelErrLimit << "* its error in PINDiode " << endl;
263 return kFALSE;
264 }
265
266 if (fSigmaCharge < GetPedRms())
267 {
268 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
269 return kFALSE;
270 }
271 return kTRUE;
272}
273
274//
275// The check returns kTRUE if:
276//
277// The mean arrival time is at least 1.0 slices from the used edge slices
278//
279Bool_t MCalibrationChargePINDiode::CheckTimeFitValidity()
280{
281
282 if (TESTBIT(fFlags,kExcludeQualityCheck))
283 return kTRUE;
284
285 if ( fAbsTimeMean < fTimeLowerEdge+1.)
286 {
287 *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the PINDiode " << endl;
288 SetMeanTimeInFirstBin();
289 return kFALSE;
290 }
291
292 if ( fAbsTimeMean > fTimeUpperEdge-1.)
293 {
294 *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the PINDiode " << endl;
295 SetMeanTimeInLastBin();
296 return kFALSE;
297 }
298
299 return kTRUE;
300}
301
302Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
303{
304
305 if (IsChargeFitValid())
306 return kFALSE;
307
308 // Start calculation of number of photons per mm^2 on the camera
309 fMeanFluxOutsidePlexiglass = fConvertedPhotons * gkPINDiodeArea;
310 // Correct for the distance between camera and PIN Diode and for different areas.
311 fMeanFluxOutsidePlexiglass *= gkFluxCameravsPINDiode;
312
313 // Start calculation of number of photons relative Variance (!!)
314 fMeanFluxErrOutsidePlexiglass = fConvertedPhotonsErr * fConvertedPhotonsErr
315 / fConvertedPhotons / fConvertedPhotons ;
316 fMeanFluxErrOutsidePlexiglass += gkFluxCameravsPINDiodeErr*gkFluxCameravsPINDiodeErr
317 / gkFluxCameravsPINDiode/gkFluxCameravsPINDiode;
318
319 switch (fColor)
320 {
321 case kEGreen:
322 fMeanFluxOutsidePlexiglass /= gkPINDiodeQEGreen;
323 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEGreenErr*gkPINDiodeQEGreenErr
324 / gkPINDiodeQEGreen/gkPINDiodeQEGreen;
325 break;
326 case kEBlue:
327 fMeanFluxOutsidePlexiglass /= gkPINDiodeQEBlue;
328 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEBlueErr*gkPINDiodeQEBlueErr
329 / gkPINDiodeQEBlue/gkPINDiodeQEBlue;
330 break;
331 case kEUV:
332 fMeanFluxOutsidePlexiglass /= gkPINDiodeQEUV;
333 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQEUVErr*gkPINDiodeQEUVErr
334 / gkPINDiodeQEUV/gkPINDiodeQEUV;
335 break;
336 case kECT1:
337 default:
338 fMeanFluxOutsidePlexiglass /= gkPINDiodeQECT1;
339 fMeanFluxErrOutsidePlexiglass += gkPINDiodeQECT1Err*gkPINDiodeQECT1Err
340 / gkPINDiodeQECT1/gkPINDiodeQECT1;
341 break;
342 }
343
344
345 *fLog << inf << endl;
346 *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: "
347 << fMeanFluxOutsidePlexiglass << endl;
348
349 if (fMeanFluxOutsidePlexiglass > 0.)
350 SETBIT(fFlags,kFluxOutsidePlexiglassAvailable);
351 else
352 {
353 CLRBIT(fFlags,kFluxOutsidePlexiglassAvailable);
354 return kFALSE;
355 }
356
357 if (fMeanFluxErrOutsidePlexiglass < 0.)
358 {
359 *fLog << warn << "Relative Variance on Photon flux outside Plexiglass: "
360 << fMeanFluxErrOutsidePlexiglass << endl;
361 CLRBIT(fFlags,kFluxOutsidePlexiglassAvailable);
362 return kFALSE;
363 }
364
365 // Finish calculation of errors -> convert from relative variance to absolute error
366 fMeanFluxErrOutsidePlexiglass = TMath::Sqrt(fMeanFluxErrOutsidePlexiglass);
367 fMeanFluxErrOutsidePlexiglass *= fMeanFluxOutsidePlexiglass;
368
369 *fLog << inf << " Error on Photon flux [ph/mm^2] outside Plexiglass: "
370 << fMeanFluxErrOutsidePlexiglass << endl;
371 *fLog << inf << endl;
372
373 return kTRUE;
374}
375
376
377
Note: See TracBrowser for help on using the repository browser.