source: trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc@ 3687

Last change on this file since 3687 was 3681, checked in by gaug, 22 years ago
*** empty log message ***
File size: 13.9 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!
19! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MCalibrationQECam
29//
30// Storage container for the calibrated Quantum Efficiency of the whole camera.
31//
32// For a complete description of the quantum efficiency calibration process,
33// see MCalibrationQEPix.
34//
35// Individual pixels have to be cast when retrieved e.g.:
36// MCalibrationQEPix &avpix = (MCalibrationQEPix&)(*fQECam)[i]
37//
38// Averaged values over one whole area index (e.g. inner or outer pixels for
39// the MAGIC camera), can be retrieved via:
40// MCalibrationQEPix &avpix = (MCalibrationQEPix&)fRelCam->GetAverageArea(i)
41//
42// Averaged values over one whole camera sector can be retrieved via:
43// MCalibrationQEPix &avpix = (MCalibrationQEPix&)fRelCam->GetAverageSector(i)
44//
45// The following "calibration" constants can be retrieved from each pixel:
46// - GetQEBlindPixel ( const PulserColor_t color ): The mean quantum
47// efficiency obtained with the calibration pulser color (e.g. kGREEN, kBLUE, kUV)
48// after the Blind Pixel Method
49// - GetQEFFactor ( const PulserColor_t color ): The mean quantum
50// efficiency obtained with the calibration pulser color (e.g. kGREEN, kBLUE, kUV)
51// after the F-Factor Method
52// - GetQEPINDiode ( const PulserColor_t color ): The mean quantum
53// efficiency obtained with the calibration pulser color (e.g. kGREEN, kBLUE, kUV)
54// after the PIN Diode Method
55// - GetQECombined ( const PulserColor_t color ): The mean quantum
56// efficiency obtained with the calibration pulser color (e.g. kGREEN, kBLUE, kUV)
57// after the combination of the three methods
58//
59// See also: MCalibrationQEPix, MCalibrationChargeCam, MCalibrationChargeCalc
60// MCalibrationChargeBlindPix, MCalibrationChargePINDiode, MCalibrationChargePix
61//
62//
63// The calculated values (types of GetPixelContent) are:
64//
65// 0: Mean Quantum Efficiency of the color: kCT1
66// 1: Error of the Mean Quantum Efficiency of the color: kCT1
67// 2: Mean Quantum Efficiency of the color: kGREEN
68// 3: Error of the Mean Quantum Efficiency of the color: kGreen
69// 4: Mean Quantum Efficiency of the color: kBLUE
70// 5: Error of the Mean Quantum Efficiency of the color: kBlue
71// 6: Mean Quantum Efficiency of the color: kUV
72// 7: Error of the Mean Quantum Efficiency of the color: kUV
73//
74/////////////////////////////////////////////////////////////////////////////
75#include "MCalibrationQECam.h"
76#include "MCalibrationCam.h"
77
78#include <TClonesArray.h>
79
80#include "MLog.h"
81#include "MLogManip.h"
82
83#include "MCalibrationQEPix.h"
84
85ClassImp(MCalibrationQECam);
86
87using namespace std;
88
89const Float_t MCalibrationQECam::gkPlexiglassQE = 0.96;
90const Float_t MCalibrationQECam::gkPlexiglassQEErr = 0.01;
91// --------------------------------------------------------------------------
92//
93// Default constructor.
94//
95// Creates a TClonesArray of MCalibrationQEPix containers, initialized to 1 entry, destinated
96// to hold one container per pixel. Later, a call to MCalibrationQECam::InitSize()
97// has to be performed (in MGeomApply).
98//
99MCalibrationQECam::MCalibrationQECam(const char *name, const char *title)
100 : fFlags(MCalibrationCam::gkNumPulserColors)
101{
102 fName = name ? name : "MCalibrationQECam";
103 fTitle = title ? title : "Storage container for the calibrated Quantrum Efficiency of the camera";
104
105 fPixels = new TClonesArray("MCalibrationQEPix",1);
106 fAverageAreas = new TClonesArray("MCalibrationQEPix",1);
107 fAverageSectors = new TClonesArray("MCalibrationQEPix",1);
108
109 Clear();
110}
111
112// ------------------------------------------------------------------------
113//
114// Sets all bits to kFALSE
115//
116// Calls:
117// - MCalibrationCam::Clear()
118//
119void MCalibrationQECam::Clear(Option_t *o)
120{
121
122 SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kGREEN);
123 SetFFactorMethodValid ( kFALSE, MCalibrationCam::kGREEN);
124 SetCombinedMethodValid ( kFALSE, MCalibrationCam::kGREEN);
125 SetPINDiodeMethodValid ( kFALSE, MCalibrationCam::kGREEN);
126 SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kBLUE);
127 SetFFactorMethodValid ( kFALSE, MCalibrationCam::kBLUE);
128 SetCombinedMethodValid ( kFALSE, MCalibrationCam::kBLUE);
129 SetPINDiodeMethodValid ( kFALSE, MCalibrationCam::kBLUE);
130 SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kUV);
131 SetFFactorMethodValid ( kFALSE, MCalibrationCam::kUV);
132 SetCombinedMethodValid ( kFALSE, MCalibrationCam::kUV);
133 SetPINDiodeMethodValid ( kFALSE, MCalibrationCam::kUV);
134 SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kCT1);
135 SetFFactorMethodValid ( kFALSE, MCalibrationCam::kCT1);
136 SetCombinedMethodValid ( kFALSE, MCalibrationCam::kCT1);
137 SetPINDiodeMethodValid ( kFALSE, MCalibrationCam::kCT1);
138
139 MCalibrationCam::Clear();
140}
141
142// --------------------------------------------------------------------------
143//
144// Return -1 if gkPlexiglassQEErr is smaller than 0.
145// Return -1 if gkPlexiglassQE is 0.
146// Return gkPlexiglassQEErr^2 / (gkPlexiglassQE^2 )
147//
148Float_t MCalibrationQECam::GetPlexiglassQERelVar() const
149{
150 if (gkPlexiglassQEErr < 0.)
151 return -1.;
152
153 if (gkPlexiglassQE == 0.)
154 return -1.;
155
156 return gkPlexiglassQEErr * gkPlexiglassQEErr / gkPlexiglassQE / gkPlexiglassQE ;
157}
158
159
160void MCalibrationQECam::SetBlindPixelMethodValid ( Bool_t b )
161{
162 SetBlindPixelMethodValid ( b, MCalibrationCam::kGREEN);
163 SetBlindPixelMethodValid ( b, MCalibrationCam::kBLUE );
164 SetBlindPixelMethodValid ( b, MCalibrationCam::kUV );
165 SetBlindPixelMethodValid ( b, MCalibrationCam::kCT1 );
166}
167
168void MCalibrationQECam::SetCombinedMethodValid ( Bool_t b )
169{
170 SetCombinedMethodValid ( b, MCalibrationCam::kGREEN);
171 SetCombinedMethodValid ( b, MCalibrationCam::kBLUE );
172 SetCombinedMethodValid ( b, MCalibrationCam::kUV );
173 SetCombinedMethodValid ( b, MCalibrationCam::kCT1 );
174}
175
176void MCalibrationQECam::SetFFactorMethodValid ( Bool_t b )
177{
178 SetFFactorMethodValid ( b, MCalibrationCam::kGREEN);
179 SetFFactorMethodValid ( b, MCalibrationCam::kBLUE );
180 SetFFactorMethodValid ( b, MCalibrationCam::kUV );
181 SetFFactorMethodValid ( b, MCalibrationCam::kCT1 );
182}
183
184void MCalibrationQECam::SetPINDiodeMethodValid ( Bool_t b )
185{
186 SetPINDiodeMethodValid ( b, MCalibrationCam::kGREEN);
187 SetPINDiodeMethodValid ( b, MCalibrationCam::kBLUE );
188 SetPINDiodeMethodValid ( b, MCalibrationCam::kUV );
189 SetPINDiodeMethodValid ( b, MCalibrationCam::kCT1 );
190}
191
192void MCalibrationQECam::SetBlindPixelMethodValid ( Bool_t b, MCalibrationCam::PulserColor_t col )
193{
194 if (b)
195 SETBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
196 else
197 CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
198}
199
200void MCalibrationQECam::SetPINDiodeMethodValid ( Bool_t b, MCalibrationCam::PulserColor_t col )
201{
202 if (b)
203 SETBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
204 else
205 CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
206}
207
208void MCalibrationQECam::SetFFactorMethodValid ( Bool_t b, MCalibrationCam::PulserColor_t col )
209{
210 if (b)
211 SETBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
212 else
213 CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
214}
215
216void MCalibrationQECam::SetCombinedMethodValid ( Bool_t b, MCalibrationCam::PulserColor_t col )
217{
218 if (b)
219 SETBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
220 else
221 CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
222}
223
224Bool_t MCalibrationQECam::IsBlindPixelMethodValid () const
225{
226 if (IsBlindPixelMethodValid (MCalibrationCam::kGREEN))
227 return kTRUE;
228 if (IsBlindPixelMethodValid (MCalibrationCam::kBLUE ))
229 return kTRUE;
230 if (IsBlindPixelMethodValid (MCalibrationCam::kUV ))
231 return kTRUE;
232 if (IsBlindPixelMethodValid (MCalibrationCam::kCT1 ))
233 return kTRUE;
234
235 return kFALSE;
236}
237
238Bool_t MCalibrationQECam::IsCombinedMethodValid () const
239{
240 if (IsCombinedMethodValid (MCalibrationCam::kGREEN))
241 return kTRUE;
242 if (IsCombinedMethodValid (MCalibrationCam::kBLUE ))
243 return kTRUE;
244 if (IsCombinedMethodValid (MCalibrationCam::kUV ))
245 return kTRUE;
246 if (IsCombinedMethodValid (MCalibrationCam::kCT1 ))
247 return kTRUE;
248
249 return kFALSE;
250}
251
252Bool_t MCalibrationQECam::IsFFactorMethodValid () const
253{
254 if (IsFFactorMethodValid (MCalibrationCam::kGREEN))
255 return kTRUE;
256 if (IsFFactorMethodValid (MCalibrationCam::kBLUE ))
257 return kTRUE;
258 if (IsFFactorMethodValid (MCalibrationCam::kUV ))
259 return kTRUE;
260 if (IsFFactorMethodValid (MCalibrationCam::kCT1 ))
261 return kTRUE;
262
263 return kFALSE;
264}
265
266
267Bool_t MCalibrationQECam::IsPINDiodeMethodValid () const
268{
269 if (IsPINDiodeMethodValid (MCalibrationCam::kGREEN))
270 return kTRUE;
271 if (IsPINDiodeMethodValid (MCalibrationCam::kBLUE ))
272 return kTRUE;
273 if (IsPINDiodeMethodValid (MCalibrationCam::kUV ))
274 return kTRUE;
275 if (IsPINDiodeMethodValid (MCalibrationCam::kCT1 ))
276 return kTRUE;
277
278 return kFALSE;
279}
280
281Bool_t MCalibrationQECam::IsBlindPixelMethodValid (MCalibrationCam::PulserColor_t col) const
282{
283 return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
284}
285
286Bool_t MCalibrationQECam::IsCombinedMethodValid (MCalibrationCam::PulserColor_t col) const
287{
288 return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
289}
290
291Bool_t MCalibrationQECam::IsFFactorMethodValid (MCalibrationCam::PulserColor_t col) const
292{
293 return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
294}
295
296Bool_t MCalibrationQECam::IsPINDiodeMethodValid (MCalibrationCam::PulserColor_t col) const
297{
298 return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
299}
300
301// --------------------------------------------------------------------------
302//
303// Print first the well fitted pixels
304// and then the ones which are not FitValid
305//
306void MCalibrationQECam::Print(Option_t *o) const
307{
308
309 *fLog << all << GetDescriptor() << ":" << endl;
310 int id = 0;
311
312 TIter Next(fPixels);
313 MCalibrationQEPix *pix;
314 while ((pix=(MCalibrationQEPix*)Next()))
315 {
316
317 if (!pix->IsExcluded() && pix->IsValid())
318 {
319 id++;
320 }
321 }
322
323 *fLog << all << id << " succesful pixels :-))" << endl;
324 id = 0;
325
326 *fLog << all << endl;
327 *fLog << all << "Pixels with errors:" << endl;
328 *fLog << all << endl;
329
330 TIter Next2(fPixels);
331 while ((pix=(MCalibrationQEPix*)Next2()))
332 {
333
334 if (!pix->IsExcluded() && !pix->IsValid())
335 {
336 id++;
337 }
338 }
339 *fLog << all << id << " pixels with errors :-((" << endl;
340
341
342 *fLog << all << endl;
343 *fLog << all << "Excluded pixels:" << endl;
344 *fLog << all << endl;
345
346 id = 0;
347
348 TIter Next4(fPixels);
349 while ((pix=(MCalibrationQEPix*)Next4()))
350 {
351 if (pix->IsExcluded())
352 {
353 *fLog << all << pix->GetPixId() << endl;
354 id++;
355 }
356 }
357 *fLog << all << id << " Excluded pixels " << endl;
358}
359
360// --------------------------------------------------------------------
361//
362// The calculated values (types) are:
363//
364// 0: Mean Quantum Efficiency of the color: kCT1
365// 1: Error of the Mean Quantum Efficiency of the color: kCT1
366// 2: Mean Quantum Efficiency of the color: kGREEN
367// 3: Error of the Mean Quantum Efficiency of the color: kGreen
368// 4: Mean Quantum Efficiency of the color: kBLUE
369// 5: Error of the Mean Quantum Efficiency of the color: kBlue
370// 6: Mean Quantum Efficiency of the color: kUV
371// 7: Error of the Mean Quantum Efficiency of the color: kUV
372//
373Bool_t MCalibrationQECam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
374{
375
376 if (idx > GetSize())
377 return kFALSE;
378
379 MCalibrationQEPix &pix = (MCalibrationQEPix&)(*this)[idx];
380
381 if (pix.IsExcluded())
382 return kFALSE;
383
384 switch (type)
385 {
386 case 0:
387 val = pix.GetQECascadesFFactor();
388 break;
389 case 1:
390 val = pix.GetQECascadesFFactorErr();
391 break;
392 case 2:
393 val = pix.GetQECascadesBlindPixel();
394 break;
395 case 3:
396 val = pix.GetQECascadesBlindPixelErr();
397 break;
398 case 4:
399 val = pix.GetQECascadesPINDiode();
400 break;
401 case 5:
402 val = pix.GetQECascadesPINDiodeErr();
403 break;
404 case 6:
405 val = pix.GetQECascadesCombined();
406 break;
407 case 7:
408 val = pix.GetQECascadesCombinedErr();
409 break;
410 case 8:
411 val = pix.GetQEFFactor(kCT1);
412 break;
413 case 9:
414 val = pix.GetQEFFactorErr(kCT1);
415 break;
416 case 10:
417 val = pix.GetQEFFactor(kGREEN);
418 break;
419 case 11:
420 val = pix.GetQEFFactorErr(kGREEN);
421 break;
422 case 12:
423 val = pix.GetQEFFactor(kBLUE);
424 break;
425 case 13:
426 val = pix.GetQEFFactorErr(kBLUE);
427 break;
428 case 14:
429 val = pix.GetQEFFactor(kUV);
430 break;
431 case 15:
432 val = pix.GetQEFFactorErr(kUV);
433 break;
434 default:
435 return kFALSE;
436 }
437 return val!=-1.;
438}
439
440// --------------------------------------------------------------------------
441//
442// Not yet implemented
443//
444void MCalibrationQECam::DrawPixelContent(Int_t idx) const
445{
446 return;
447}
448
449
450
451
452
453
454
455
456
Note: See TracBrowser for help on using the repository browser.