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

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