source: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.cc@ 4671

Last change on this file since 4671 was 4671, checked in by gaug, 20 years ago
*** empty log message ***
File size: 15.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// MCalibrationChargeBlindPix
28//
29// Storage container of the fit results of the Blind Pixel signal
30// (from MHCalibrationChargeBlindPix).
31//
32// The Flux is calculated in photons per mm^2 in the camera plane.
33//
34// Currently, the following numbers are implemented:
35// - fArea: 100 mm^2
36// - Average QE of Blind Pixel:
37// fQEGreen: 0.154
38// fQEBlue : 0.226
39// fQEUV : 0.247
40// fQECT1 : 0.247
41// - Average QE Error of Blind Pixel:
42// fQEGreenErr: 0.015;
43// fQEBlueErr : 0.02;
44// fQEUVErr : 0.02;
45// fQECT1Err : 0.02;
46// - Attenuation factor Blind Pixel:
47// fAttGreen : 1.97;
48// fAttBlue : 1.96;
49// fAttUV : 1.95;
50// fAttCT1 : 1.95;
51//
52//
53/////////////////////////////////////////////////////////////////////////////
54#include "MCalibrationChargeBlindPix.h"
55#include "MCalibrationCam.h"
56
57#include <TH1.h>
58
59#include "MLog.h"
60#include "MLogManip.h"
61
62ClassImp(MCalibrationChargeBlindPix);
63
64using namespace std;
65const Float_t MCalibrationChargeBlindPix::fgArea = 100;
66const Float_t MCalibrationChargeBlindPix::fgAttGreen = 1.97;
67const Float_t MCalibrationChargeBlindPix::fgAttBlue = 1.96;
68const Float_t MCalibrationChargeBlindPix::fgAttUV = 1.95;
69const Float_t MCalibrationChargeBlindPix::fgAttCT1 = 1.95;
70const Float_t MCalibrationChargeBlindPix::fgAttErr = 0.01;
71const Float_t MCalibrationChargeBlindPix::fgQEGreen = 0.154;
72const Float_t MCalibrationChargeBlindPix::fgQEBlue = 0.226;
73const Float_t MCalibrationChargeBlindPix::fgQEUV = 0.247;
74const Float_t MCalibrationChargeBlindPix::fgQECT1 = 0.247;
75const Float_t MCalibrationChargeBlindPix::fgQEErrGreen = 0.005;
76const Float_t MCalibrationChargeBlindPix::fgQEErrBlue = 0.007;
77const Float_t MCalibrationChargeBlindPix::fgQEErrUV = 0.01;
78const Float_t MCalibrationChargeBlindPix::fgQEErrCT1 = 0.01;
79const Float_t MCalibrationChargeBlindPix::fgCollEffGreen = 0.99;
80const Float_t MCalibrationChargeBlindPix::fgCollEffBlue = 0.93;
81const Float_t MCalibrationChargeBlindPix::fgCollEffUV = 0.90;
82const Float_t MCalibrationChargeBlindPix::fgCollEffCT1 = 0.90;
83const Float_t MCalibrationChargeBlindPix::fgCollEffErr = 0.05;
84// --------------------------------------------------------------------------
85//
86// Default Constructor.
87//
88// Calls:
89// - Clear()
90//
91// For backward-compatibility reasons, quantum eff., coll. eff. and att.
92// are intialized from the static members. This should, however, be
93// overwritten by a class deriving from MCalibrationChargeBlindCam.
94//
95MCalibrationChargeBlindPix::MCalibrationChargeBlindPix(const char *name, const char *title)
96{
97
98 fName = name ? name : "MCalibrationChargeBlindPix";
99 fTitle = title ? title : "Container of the fit results of the blind pixel";
100
101 Clear();
102
103 fArea = fgArea;
104
105 fAtt .Set( MCalibrationCam::gkNumPulserColors );
106 fAttErr .Set( MCalibrationCam::gkNumPulserColors );
107 fQE .Set( MCalibrationCam::gkNumPulserColors );
108 fQEErr .Set( MCalibrationCam::gkNumPulserColors );
109 fCollEff .Set( MCalibrationCam::gkNumPulserColors );
110 fCollEffErr.Set( MCalibrationCam::gkNumPulserColors );
111
112 SetAtt ( fgAttGreen, MCalibrationCam::kGREEN );
113 SetAtt ( fgAttBlue, MCalibrationCam::kBLUE );
114 SetAtt ( fgAttUV , MCalibrationCam::kUV );
115 SetAtt ( fgAttCT1 , MCalibrationCam::kCT1 );
116
117 SetAttErr ( fgAttErr , MCalibrationCam::kGREEN );
118 SetAttErr ( fgAttErr , MCalibrationCam::kBLUE );
119 SetAttErr ( fgAttErr , MCalibrationCam::kUV );
120 SetAttErr ( fgAttErr , MCalibrationCam::kCT1 );
121
122 SetQE ( fgQEGreen, MCalibrationCam::kGREEN );
123 SetQE ( fgQEBlue, MCalibrationCam::kBLUE );
124 SetQE ( fgQEUV , MCalibrationCam::kUV );
125 SetQE ( fgQECT1 , MCalibrationCam::kCT1 );
126
127 SetQEErr ( fgQEErrGreen, MCalibrationCam::kGREEN );
128 SetQEErr ( fgQEErrBlue, MCalibrationCam::kBLUE );
129 SetQEErr ( fgQEErrUV , MCalibrationCam::kUV );
130 SetQEErr ( fgQEErrCT1 , MCalibrationCam::kCT1 );
131
132 SetCollEff ( fgCollEffGreen, MCalibrationCam::kGREEN );
133 SetCollEff ( fgCollEffBlue, MCalibrationCam::kBLUE );
134 SetCollEff ( fgCollEffUV , MCalibrationCam::kUV );
135 SetCollEff ( fgCollEffCT1 , MCalibrationCam::kCT1 );
136
137 SetCollEffErr ( fgCollEffErr, MCalibrationCam::kGREEN );
138 SetCollEffErr ( fgCollEffErr, MCalibrationCam::kBLUE );
139 SetCollEffErr ( fgCollEffErr, MCalibrationCam::kUV );
140 SetCollEffErr ( fgCollEffErr, MCalibrationCam::kCT1 );
141
142}
143
144
145// ------------------------------------------------------------------------
146//
147// Sets:
148// - all flags to kFALSE
149// - all variables to -1.
150// - the fColor to MCalibrationCam::kNONE
151//
152// Calls:
153// - MCalibrationChargePix::Clear()
154//
155void MCalibrationChargeBlindPix::Clear(Option_t *o)
156{
157
158 fFluxInsidePlexiglass = -1.;
159 fFluxInsidePlexiglassVar = -1.;
160 fLambda = -1.;
161 fLambdaCheck = -1.;
162 fLambdaVar = -1.;
163 fMu0 = -1.;
164 fMu0Err = -1.;
165 fMu1 = -1.;
166 fMu1Err = -1.;
167 fSigma0 = -1.;
168 fSigma0Err = -1.;
169 fSigma1 = -1.;
170 fSigma1Err = -1.;
171
172 SetOscillating ( kFALSE );
173 SetExcluded ( kFALSE );
174 SetChargeFitValid ( kFALSE );
175 SetPedestalFitOK ( kFALSE );
176 SetSinglePheFitOK ( kFALSE );
177 SetFluxInsidePlexiglassAvailable ( kFALSE );
178
179 SetColor(MCalibrationCam::kNONE);
180
181 MCalibrationPix::Clear();
182}
183
184void MCalibrationChargeBlindPix::SetFluxInsidePlexiglassAvailable( const Bool_t b)
185{
186 b ? SETBIT(fFlags,kFluxInsidePlexiglassAvailable) : CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
187}
188
189
190// --------------------------------------------------------------------------
191//
192// Set the Oscillating Bit from outside
193//
194void MCalibrationChargeBlindPix::SetOscillating( const Bool_t b)
195{
196 b ? SETBIT(fFlags,kOscillating) : CLRBIT(fFlags,kOscillating);
197}
198
199// --------------------------------------------------------------------------
200//
201// Set the ChargeFitValid Bit from outside
202//
203void MCalibrationChargeBlindPix::SetChargeFitValid( const Bool_t b)
204{
205 b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
206}
207
208// --------------------------------------------------------------------------
209//
210// Set the PedestalFitValid Bit from outside
211//
212void MCalibrationChargeBlindPix::SetPedestalFitOK( const Bool_t b)
213{
214 b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
215}
216
217// --------------------------------------------------------------------------
218//
219// Set the SinglePheFitValid Bit from outside
220//
221void MCalibrationChargeBlindPix::SetSinglePheFitOK( const Bool_t b)
222{
223 b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
224}
225
226// --------------------------------------------------------------------------
227//
228// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
229// Return square root of fFluxInsidePlexiglassVar
230//
231const Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassErr() const
232{
233 if (fFluxInsidePlexiglassVar < 0.)
234 return -1.;
235
236 return TMath::Sqrt(fFluxInsidePlexiglassVar);
237}
238
239// --------------------------------------------------------------------------
240//
241// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
242// Return -1 if fFluxInsidePlexiglass is 0.
243// Return fFluxInsidePlexiglassVar / fFluxInsidePlexiglass^2
244//
245const Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassRelVar() const
246{
247 if (fFluxInsidePlexiglassVar < 0.)
248 return -1.;
249
250 if (fFluxInsidePlexiglass == 0.)
251 return -1.;
252
253 return fFluxInsidePlexiglassVar / (fFluxInsidePlexiglass * fFluxInsidePlexiglass) ;
254}
255
256// --------------------------------------------------------------------------
257//
258// Return -1 if fLambdaVar is smaller than 0.
259// Return square root of fLambdaVar
260//
261const Float_t MCalibrationChargeBlindPix::GetLambdaErr() const
262{
263 if (fLambdaVar < 0.)
264 return -1.;
265
266 return TMath::Sqrt(fLambdaVar);
267}
268
269// --------------------------------------------------------------------------
270//
271// Return -1 if fLambdaVar is smaller than 0.
272// Return -1 if fLambda is 0.
273// Return fLambdaVar / (fLambda * fLambda )
274//
275const Float_t MCalibrationChargeBlindPix::GetLambdaRelVar() const
276{
277 if (fLambdaVar < 0.)
278 return -1.;
279
280 if (fLambda == 0.)
281 return -1.;
282
283 return fLambdaVar / fLambda / fLambda ;
284}
285
286// --------------------------------------------------------------------------
287//
288// Return TMath::Power(10,fAtt[fColor])
289//
290const Float_t MCalibrationChargeBlindPix::GetAtt() const
291{
292 return TMath::Power(10,fAtt[fColor]);
293}
294
295// --------------------------------------------------------------------------
296//
297// Return -1 if fAttErr[fColor] is smaller than 0.
298// Error of TMath::Power(10,fAtt[fColor]) = TMath::Power(10,fAtt[fColor])*ln(10.)*fAttErr[fColor]
299// Return fAttErr^2 / (fAtt^2 )
300//
301const Float_t MCalibrationChargeBlindPix::GetAttRelVar() const
302{
303
304 const Float_t err = fAttErr[fColor];
305
306 if (err < 0.)
307 return -1.;
308
309 return err*err*2.3;
310}
311
312// --------------------------------------------------------------------------
313//
314// Return fQE[fColor]
315//
316const Float_t MCalibrationChargeBlindPix::GetQE() const
317{
318 return fQE[fColor];
319}
320
321// --------------------------------------------------------------------------
322//
323// Return -1 if fQEErr[fColor] is smaller than 0.
324// Return fQEErr^2 / (fQE^2 )
325//
326const Float_t MCalibrationChargeBlindPix::GetQERelVar() const
327{
328
329 if (fQEErr[fColor] < 0.)
330 return -1.;
331
332 return fQEErr[fColor]* fQEErr[fColor] / GetQE() / GetQE();
333}
334
335// --------------------------------------------------------------------------
336//
337// Return fCollEff[fColor]
338//
339const Float_t MCalibrationChargeBlindPix::GetCollEff() const
340{
341 return fCollEff[fColor];
342}
343
344// --------------------------------------------------------------------------
345//
346// Return -1 if fCollEffErr[fColor] is smaller than 0.
347// Return fCollEffErr^2 / (fCollEff^2 )
348//
349const Float_t MCalibrationChargeBlindPix::GetCollEffRelVar() const
350{
351
352 if (fCollEffErr[fColor] < 0.)
353 return -1.;
354
355 return fCollEffErr[fColor]* fCollEffErr[fColor] / GetCollEff() / GetCollEff();
356}
357
358// --------------------------------------------------------------------------
359//
360// Test bit kChargeFitValid
361//
362const Bool_t MCalibrationChargeBlindPix::IsChargeFitValid() const
363{
364 return TESTBIT(fFlags,kChargeFitValid);
365}
366
367// --------------------------------------------------------------------------
368//
369// Test bit kOscillating
370//
371const Bool_t MCalibrationChargeBlindPix::IsOscillating() const
372{
373 return TESTBIT(fFlags,kOscillating);
374}
375
376// --------------------------------------------------------------------------
377//
378// Test bit kPedestalFitValid
379//
380const Bool_t MCalibrationChargeBlindPix::IsPedestalFitOK() const
381{
382 return TESTBIT(fFlags,kPedestalFitOK);
383}
384
385// --------------------------------------------------------------------------
386//
387// Test bit kSinglePheFitValid
388//
389const Bool_t MCalibrationChargeBlindPix::IsSinglePheFitOK() const
390{
391 return TESTBIT(fFlags,kSinglePheFitOK);
392}
393
394// --------------------------------------------------------------------------
395//
396// Test bit kFluxInsidePlexiglassAvailable
397//
398const Bool_t MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable() const
399{
400 return TESTBIT(fFlags,kFluxInsidePlexiglassAvailable);
401}
402
403
404// --------------------------------------------------------------------------
405//
406// Return kFALSE if IsChargeFitValid() is kFALSE
407//
408// Calculate fFluxInsidePlexiglass with the formula:
409// - fFluxInsidePlexiglass = fLambda
410// / GetCollEff()
411// / GetQE()
412// * GetAtt()
413// / fArea
414// - fFluxInsidePlexiglassVar = sqrt( fLambdaVar / ( fLambda * fLambda )
415// + GetQERelVar()
416// + GetCollEffRelVar()
417// + GetAttRelVar()
418// ) * fFluxInsidePlexiglass * * fFluxInsidePlexiglass
419//
420// If the fFluxInsidePlexiglass is smaller than 0., return kFALSE
421// If the Variance is smaller than 0., return kFALSE
422//
423// SetFluxInsidePlexiglassAvailable() and return kTRUE
424//
425Bool_t MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
426{
427
428 if (IsChargeFitValid())
429 return kFALSE;
430
431
432 //
433 // Start calculation of number of photons
434 // The blind pixel has exactly 100 mm^2 area (with negligible error),
435 //
436 fFluxInsidePlexiglass = fLambda / GetQE() * GetAtt() / GetCollEff() / fArea;
437
438 if (fFluxInsidePlexiglass < 0.)
439 return kFALSE;
440
441 fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetQERelVar() + GetAttRelVar() + GetCollEffRelVar();
442
443 //
444 // Finish calculation of errors -> convert from relative variance to absolute variance
445 //
446 fFluxInsidePlexiglassVar *= fFluxInsidePlexiglass * fFluxInsidePlexiglass;
447
448 if (fFluxInsidePlexiglassVar < 0.)
449 return kFALSE;
450
451 SetFluxInsidePlexiglassAvailable(kTRUE);
452
453 *fLog << inf << GetDescriptor()
454 << ": Photon flux [ph/mm^2] inside Plexiglass: "
455 << Form("%5.3f%s%5.3f",fFluxInsidePlexiglass," +- ",GetFluxInsidePlexiglassErr()) << endl;
456
457 return kTRUE;
458}
459
460void MCalibrationChargeBlindPix::Print(Option_t *opt) const
461{
462
463 *fLog << all << GetDescriptor()
464 << Form("%s%3i","BlindPixel: ",GetPixId())
465 << Form("%s%4.2f%s%4.2f"," Lambda: ",GetLambda(),"+-",GetLambdaErr())
466 << Form("%s%4.2f%s%4.2f"," Mu0: ",GetMu0(),"+-",GetMu0Err())
467 << Form("%s%4.2f%s%4.2f"," Mu1: ",GetMu1(),"+-",GetMu1Err())
468 << Form("%s%4.2f%s%4.2f"," Sigma0: ",GetSigma0(),"+-",GetSigma0Err())
469 << Form("%s%4.2f%s%4.2f"," Sigma1: ",GetSigma1(),"+-",GetSigma1Err())
470 << endl;
471 *fLog << all
472 << " Pedestal Fit OK? :" << IsPedestalFitOK()
473 << Form("%s%4.2f%s%4.2f"," Lambda (Check): " ,GetLambdaCheck(),"+-",GetLambdaCheckErr())
474 << endl;
475 *fLog << all
476 << " Flux available? :" << IsFluxInsidePlexiglassAvailable()
477 << Form("%s%4.2f%s%4.2f"," Flux: " ,GetFluxInsidePlexiglass(),"+-",GetFluxInsidePlexiglassErr())
478 << endl;
479}
480
481
482
483
484
485
486
487
488
Note: See TracBrowser for help on using the repository browser.