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

Last change on this file since 4693 was 4673, checked in by gaug, 20 years ago
*** empty log message ***
File size: 16.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// 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// copy 'constructor'
202//
203void MCalibrationChargeBlindPix::Copy(TObject& object) const
204{
205
206 MCalibrationChargeBlindPix &pix = (MCalibrationChargeBlindPix&)object;
207
208 //
209 // Copy the data members
210 //
211 pix.fArea = fArea;
212 pix.fAtt = fAtt;
213 pix.fAttErr = fAttErr;
214 pix.fQE = fQE;
215 pix.fQEErr = fQEErr;
216 pix.fCollEff = fCollEff;
217 pix.fCollEffErr = fCollEffErr;
218
219 pix.fLambda = fLambda;
220 pix.fLambdaCheck = fLambdaCheck;
221 pix.fLambdaCheckErr = fLambdaCheckErr;
222 pix.fLambdaVar = fLambdaVar;
223 pix.fFluxInsidePlexiglass = fFluxInsidePlexiglass;
224 pix.fFluxInsidePlexiglassVar = fFluxInsidePlexiglassVar;
225 pix.fMu0 = fMu0;
226 pix.fMu0Err = fMu0Err;
227 pix.fMu1 = fMu1;
228 pix.fMu1Err = fMu1Err;
229 pix.fSigma0 = fSigma0;
230 pix.fSigma0Err = fSigma0Err;
231 pix.fSigma1 = fSigma1;
232 pix.fSigma1Err = fSigma1Err;
233
234 pix.fColor = fColor;
235 pix.fPixId = fPixId;
236 pix.fFlags = fFlags;
237
238}
239
240
241// --------------------------------------------------------------------------
242//
243// Set the ChargeFitValid Bit from outside
244//
245void MCalibrationChargeBlindPix::SetChargeFitValid( const Bool_t b)
246{
247 b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
248}
249
250// --------------------------------------------------------------------------
251//
252// Set the PedestalFitValid Bit from outside
253//
254void MCalibrationChargeBlindPix::SetPedestalFitOK( const Bool_t b)
255{
256 b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
257}
258
259// --------------------------------------------------------------------------
260//
261// Set the SinglePheFitValid Bit from outside
262//
263void MCalibrationChargeBlindPix::SetSinglePheFitOK( const Bool_t b)
264{
265 b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
266}
267
268// --------------------------------------------------------------------------
269//
270// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
271// Return square root of fFluxInsidePlexiglassVar
272//
273const Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassErr() const
274{
275 if (fFluxInsidePlexiglassVar < 0.)
276 return -1.;
277
278 return TMath::Sqrt(fFluxInsidePlexiglassVar);
279}
280
281// --------------------------------------------------------------------------
282//
283// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
284// Return -1 if fFluxInsidePlexiglass is 0.
285// Return fFluxInsidePlexiglassVar / fFluxInsidePlexiglass^2
286//
287const Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassRelVar() const
288{
289 if (fFluxInsidePlexiglassVar < 0.)
290 return -1.;
291
292 if (fFluxInsidePlexiglass == 0.)
293 return -1.;
294
295 return fFluxInsidePlexiglassVar / (fFluxInsidePlexiglass * fFluxInsidePlexiglass) ;
296}
297
298// --------------------------------------------------------------------------
299//
300// Return -1 if fLambdaVar is smaller than 0.
301// Return square root of fLambdaVar
302//
303const Float_t MCalibrationChargeBlindPix::GetLambdaErr() const
304{
305 if (fLambdaVar < 0.)
306 return -1.;
307
308 return TMath::Sqrt(fLambdaVar);
309}
310
311// --------------------------------------------------------------------------
312//
313// Return -1 if fLambdaVar is smaller than 0.
314// Return -1 if fLambda is 0.
315// Return fLambdaVar / (fLambda * fLambda )
316//
317const Float_t MCalibrationChargeBlindPix::GetLambdaRelVar() const
318{
319 if (fLambdaVar < 0.)
320 return -1.;
321
322 if (fLambda == 0.)
323 return -1.;
324
325 return fLambdaVar / fLambda / fLambda ;
326}
327
328// --------------------------------------------------------------------------
329//
330// Return TMath::Power(10,fAtt[fColor])
331//
332const Float_t MCalibrationChargeBlindPix::GetAtt() const
333{
334 return TMath::Power(10,fAtt[fColor]);
335}
336
337// --------------------------------------------------------------------------
338//
339// Return -1 if fAttErr[fColor] is smaller than 0.
340// Error of TMath::Power(10,fAtt[fColor]) = TMath::Power(10,fAtt[fColor])*ln(10.)*fAttErr[fColor]
341// Return fAttErr^2 / (fAtt^2 )
342//
343const Float_t MCalibrationChargeBlindPix::GetAttRelVar() const
344{
345
346 const Float_t err = fAttErr[fColor];
347
348 if (err < 0.)
349 return -1.;
350
351 return err*err*2.3;
352}
353
354// --------------------------------------------------------------------------
355//
356// Return fQE[fColor]
357//
358const Float_t MCalibrationChargeBlindPix::GetQE() const
359{
360 return fQE[fColor];
361}
362
363// --------------------------------------------------------------------------
364//
365// Return -1 if fQEErr[fColor] is smaller than 0.
366// Return fQEErr^2 / (fQE^2 )
367//
368const Float_t MCalibrationChargeBlindPix::GetQERelVar() const
369{
370
371 if (fQEErr[fColor] < 0.)
372 return -1.;
373
374 return fQEErr[fColor]* fQEErr[fColor] / GetQE() / GetQE();
375}
376
377// --------------------------------------------------------------------------
378//
379// Return fCollEff[fColor]
380//
381const Float_t MCalibrationChargeBlindPix::GetCollEff() const
382{
383 return fCollEff[fColor];
384}
385
386// --------------------------------------------------------------------------
387//
388// Return -1 if fCollEffErr[fColor] is smaller than 0.
389// Return fCollEffErr^2 / (fCollEff^2 )
390//
391const Float_t MCalibrationChargeBlindPix::GetCollEffRelVar() const
392{
393
394 if (fCollEffErr[fColor] < 0.)
395 return -1.;
396
397 return fCollEffErr[fColor]* fCollEffErr[fColor] / GetCollEff() / GetCollEff();
398}
399
400// --------------------------------------------------------------------------
401//
402// Test bit kChargeFitValid
403//
404const Bool_t MCalibrationChargeBlindPix::IsChargeFitValid() const
405{
406 return TESTBIT(fFlags,kChargeFitValid);
407}
408
409// --------------------------------------------------------------------------
410//
411// Test bit kOscillating
412//
413const Bool_t MCalibrationChargeBlindPix::IsOscillating() const
414{
415 return TESTBIT(fFlags,kOscillating);
416}
417
418// --------------------------------------------------------------------------
419//
420// Test bit kPedestalFitValid
421//
422const Bool_t MCalibrationChargeBlindPix::IsPedestalFitOK() const
423{
424 return TESTBIT(fFlags,kPedestalFitOK);
425}
426
427// --------------------------------------------------------------------------
428//
429// Test bit kSinglePheFitValid
430//
431const Bool_t MCalibrationChargeBlindPix::IsSinglePheFitOK() const
432{
433 return TESTBIT(fFlags,kSinglePheFitOK);
434}
435
436// --------------------------------------------------------------------------
437//
438// Test bit kFluxInsidePlexiglassAvailable
439//
440const Bool_t MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable() const
441{
442 return TESTBIT(fFlags,kFluxInsidePlexiglassAvailable);
443}
444
445
446// --------------------------------------------------------------------------
447//
448// Return kFALSE if IsChargeFitValid() is kFALSE
449//
450// Calculate fFluxInsidePlexiglass with the formula:
451// - fFluxInsidePlexiglass = fLambda
452// / GetCollEff()
453// / GetQE()
454// * GetAtt()
455// / fArea
456// - fFluxInsidePlexiglassVar = sqrt( fLambdaVar / ( fLambda * fLambda )
457// + GetQERelVar()
458// + GetCollEffRelVar()
459// + GetAttRelVar()
460// ) * fFluxInsidePlexiglass * * fFluxInsidePlexiglass
461//
462// If the fFluxInsidePlexiglass is smaller than 0., return kFALSE
463// If the Variance is smaller than 0., return kFALSE
464//
465// SetFluxInsidePlexiglassAvailable() and return kTRUE
466//
467Bool_t MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
468{
469
470 if (IsChargeFitValid())
471 return kFALSE;
472
473
474 //
475 // Start calculation of number of photons
476 // The blind pixel has exactly 100 mm^2 area (with negligible error),
477 //
478 fFluxInsidePlexiglass = fLambda / GetQE() * GetAtt() / GetCollEff() / fArea;
479
480 if (fFluxInsidePlexiglass < 0.)
481 return kFALSE;
482
483 fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetQERelVar() + GetAttRelVar() + GetCollEffRelVar();
484
485 //
486 // Finish calculation of errors -> convert from relative variance to absolute variance
487 //
488 fFluxInsidePlexiglassVar *= fFluxInsidePlexiglass * fFluxInsidePlexiglass;
489
490 if (fFluxInsidePlexiglassVar < 0.)
491 return kFALSE;
492
493 SetFluxInsidePlexiglassAvailable(kTRUE);
494
495 *fLog << inf << GetDescriptor()
496 << ": Blind Pixel Nr. " << fPixId << ": Photon flux [ph/mm^2] inside Plexiglass: "
497 << Form("%5.3f%s%5.3f",fFluxInsidePlexiglass," +- ",GetFluxInsidePlexiglassErr()) << endl;
498
499 return kTRUE;
500}
501
502void MCalibrationChargeBlindPix::Print(Option_t *opt) const
503{
504
505 *fLog << all << GetDescriptor()
506 << Form("%s%3i","BlindPixel: ",GetPixId())
507 << Form("%s%4.2f%s%4.2f"," Lambda: ",GetLambda(),"+-",GetLambdaErr())
508 << Form("%s%4.2f%s%4.2f"," Mu0: ",GetMu0(),"+-",GetMu0Err())
509 << Form("%s%4.2f%s%4.2f"," Mu1: ",GetMu1(),"+-",GetMu1Err())
510 << Form("%s%4.2f%s%4.2f"," Sigma0: ",GetSigma0(),"+-",GetSigma0Err())
511 << Form("%s%4.2f%s%4.2f"," Sigma1: ",GetSigma1(),"+-",GetSigma1Err())
512 << endl;
513 *fLog << all
514 << " Pedestal Fit OK? :" << IsPedestalFitOK()
515 << Form("%s%4.2f%s%4.2f"," Lambda (Check): " ,GetLambdaCheck(),"+-",GetLambdaCheckErr())
516 << endl;
517 *fLog << all
518 << " Flux available? :" << IsFluxInsidePlexiglassAvailable()
519 << Form("%s%4.2f%s%4.2f"," Flux: " ,GetFluxInsidePlexiglass(),"+-",GetFluxInsidePlexiglassErr())
520 << endl;
521}
522
523
524
525
526
527
528
529
530
Note: See TracBrowser for help on using the repository browser.