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

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