source: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc@ 3253

Last change on this file since 3253 was 3247, checked in by gaug, 21 years ago
*** empty log message ***
File size: 33.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 11/2003 <mailto:markus@ifae.es>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MCalibrationChargeCam
29//
30// Hold the whole Calibration results of the camera:
31//
32// 1) MCalibrationChargeCam initializes a TClonesArray whose elements are
33// pointers to MCalibrationPix Containers
34// 2) It initializes a pointer to an MCalibrationBlindPix container
35// 3) It initializes a pointer to an MCalibrationPINDiode container
36//
37//
38// The calculated values (types of GetPixelContent) are:
39//
40// Fitted values:
41// ==============
42//
43// 0: Fitted Charge
44// 1: Error of fitted Charge
45// 2: Sigma of fitted Charge
46// 3: Error of Sigma of fitted Charge
47//
48// Useful variables derived from the fit results:
49// =============================================
50//
51// 4: Returned probability of Gauss fit to Charge distribution
52// 5: Reduced Sigma of fitted Charge --> sqrt(sigma_Q^2 - PedRMS^2)
53// 6: Error Reduced Sigma of fitted Charge
54// 7: Reduced Sigma per Charge
55// 8: Error of Reduced Sigma per Charge
56//
57// Results of the different calibration methods:
58// =============================================
59//
60// 9: Number of Photo-electrons obtained with the F-Factor method
61// 10: Error on Number of Photo-electrons obtained with the F-Factor method
62// 11: Mean conversion factor obtained with the F-Factor method
63// 12: Error on the mean conversion factor obtained with the F-Factor method
64// 13: Overall F-Factor of the readout obtained with the F-Factor method
65// 14: Error on Overall F-Factor of the readout obtained with the F-Factor method
66// 15: Number of Photons inside Plexiglass obtained with the Blind Pixel method
67// 16: Error on Number of Photons inside Plexiglass obtained with the Blind Pixel method
68// 17: Mean conversion factor obtained with the Blind Pixel method
69// 18: Error on the mean conversion factor obtained with the Blind Pixel method
70// 19: Overall F-Factor of the readout obtained with the Blind Pixel method
71// 20: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
72// 21: Number of Photons outside Plexiglass obtained with the PIN Diode method
73// 22: Error on Number of Photons outside Plexiglass obtained with the PIN Diode method
74// 23: Mean conversion factor obtained with the PIN Diode method
75// 24: Error on the mean conversion factor obtained with the PIN Diode method
76// 25: Overall F-Factor of the readout obtained with the PIN Diode method
77// 26: Error on Overall F-Factor of the readout obtained with the PIN Diode method
78//
79// Localized defects:
80// ==================
81//
82// 27: Excluded Pixels
83// 28: Pixels where the fit did not succeed --> results obtained only from the histograms
84// 29: Pixels with succeeded fit, but apparently wrong results
85// 30: Pixels with un-expected behavior in the fourier spectrum (e.g. oscillations)
86//
87// Other classifications of pixels:
88// ================================
89//
90// 31: Pixels with saturated Hi-Gain
91//
92// Classification of validity of the calibrations:
93// ===============================================
94//
95// 32: Pixels with valid calibration by the F-Factor-Method
96// 33: Pixels with valid calibration by the Blind Pixel-Method
97// 34: Pixels with valid calibration by the PIN Diode-Method
98//
99// Used Pedestals:
100// ===============
101//
102// 35: Mean Pedestal over the entire range of signal extraction
103// 36: Error on the Mean Pedestal over the entire range of signal extraction
104// 37: Pedestal RMS over the entire range of signal extraction
105// 38: Error on the Pedestal RMS over the entire range of signal extraction
106//
107// Calculated absolute arrival times (very low precision!):
108// ========================================================
109//
110// 39: Absolute Arrival time of the signal
111// 40: Error on the Absolute Arrival time of the signal
112// 41: RMS of the Absolute Arrival time of the signal
113// 42: Error on the RMS of the Absolute Arrival time of the signal
114//
115/////////////////////////////////////////////////////////////////////////////
116#include "MCalibrationChargeCam.h"
117
118#include <TH2.h>
119#include <TCanvas.h>
120#include <TClonesArray.h>
121
122#include "MLog.h"
123#include "MLogManip.h"
124
125#include "MGeomCam.h"
126#include "MGeomPix.h"
127
128#include "MCalibrationPix.h"
129#include "MCalibrationBlindPix.h"
130#include "MCalibrationChargePINDiode.h"
131
132#include "MHCalibrationPixel.h"
133
134ClassImp(MCalibrationChargeCam);
135
136using namespace std;
137
138const Int_t MCalibrationChargeCam::gkBlindPixelId = 559;
139const Int_t MCalibrationChargeCam::gkPINDiodeId = 9999;
140const Float_t MCalibrationChargeCam::gkBlindPixelArea = 100;
141// Average QE of Blind Pixel (three colours)
142const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQEGreen = 0.154;
143const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQEBlue = 0.226;
144const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQEUV = 0.247;
145const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQECT1 = 0.247;
146// Average QE Error of Blind Pixel (three colours)
147const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQEGreenErr = 0.015;
148const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQEBlueErr = 0.02;
149const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQEUVErr = 0.02;
150const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelQECT1Err = 0.02;
151// Attenuation factor Blind Pixel (three colours)
152const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelAttGreen = 1.97;
153const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelAttBlue = 1.96;
154const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelAttUV = 1.95;
155const Float_t MCalibrationChargeCam::gkCalibrationBlindPixelAttCT1 = 1.95;
156
157// --------------------------------------------------------------------------
158//
159// Default constructor.
160//
161// Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry
162// Later, a call to MCalibrationChargeCam::InitSize(Int_t size) has to be performed
163//
164// Creates an MCalibrationBlindPix container
165//
166MCalibrationChargeCam::MCalibrationChargeCam(const char *name, const char *title)
167 : fBlindPixel(NULL),
168 fPINDiode(NULL),
169 fOffsets(NULL),
170 fSlopes(NULL),
171 fOffvsSlope(NULL)
172{
173 fName = name ? name : "MCalibrationChargeCam";
174 fTitle = title ? title : "Storage container for the Calibration Information in the camera";
175
176 fPixels = new TClonesArray("MCalibrationPix",1);
177 fBlindPixel = new MCalibrationBlindPix();
178
179 Clear();
180}
181
182// --------------------------------------------------------------------------
183//
184// Delete the TClonesArray of MCalibrationPix containers
185// Delete the MCalibrationPINDiode and the MCalibrationBlindPix
186//
187// Delete the histograms if they exist
188//
189MCalibrationChargeCam::~MCalibrationChargeCam()
190{
191
192 //
193 // delete fPixels should delete all Objects stored inside
194 //
195 delete fPixels;
196 delete fBlindPixel;
197
198 if (fOffsets)
199 delete fOffsets;
200 if (fSlopes)
201 delete fSlopes;
202 if (fOffvsSlope)
203 delete fOffvsSlope;
204
205}
206
207// -------------------------------------------------------------------
208//
209// This function simply allocates memory via the ROOT command:
210// (TObject**) TStorage::ReAlloc(fCont, newSize * sizeof(TObject*),
211// fSize * sizeof(TObject*));
212// newSize corresponds to size in our case
213// fSize is the old size (in most cases: 1)
214//
215void MCalibrationChargeCam::InitSize(const UInt_t i)
216{
217
218 //
219 // check if we have already initialized to size
220 //
221 if (CheckBounds(i))
222 return;
223
224 fPixels->ExpandCreate(i);
225
226}
227
228// --------------------------------------------------------------------------
229//
230// This function returns the current size of the TClonesArray
231// independently if the MCalibrationPix is filled with values or not.
232//
233// It is the size of the array fPixels.
234//
235Int_t MCalibrationChargeCam::GetSize() const
236{
237 return fPixels->GetEntriesFast();
238}
239
240// --------------------------------------------------------------------------
241//
242// Check if position i is inside the current bounds of the TClonesArray
243//
244Bool_t MCalibrationChargeCam::CheckBounds(Int_t i) const
245{
246 return i < GetSize();
247}
248
249
250// --------------------------------------------------------------------------
251//
252// Get i-th pixel (pixel number)
253//
254MCalibrationPix &MCalibrationChargeCam::operator[](UInt_t i)
255{
256 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
257}
258
259// --------------------------------------------------------------------------
260//
261// Get i-th pixel (pixel number)
262//
263const MCalibrationPix &MCalibrationChargeCam::operator[](UInt_t i) const
264{
265 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
266}
267
268
269// --------------------------------------
270//
271void MCalibrationChargeCam::Clear(Option_t *o)
272{
273
274 fPixels->ForEach(TObject, Clear)();
275 fBlindPixel->Clear();
276
277 fMeanFluxInsidePlexiglass = -1.;
278 fMeanFluxErrInsidePlexiglass = -1.;
279
280 fNumExcludedPixels = 0;
281
282 CLRBIT(fFlags,kBlindPixelMethodValid);
283 CLRBIT(fFlags,kPINDiodeMethodValid);
284 CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
285
286 return;
287}
288
289void MCalibrationChargeCam::SetBlindPixelMethodValid(const Bool_t b)
290{
291 b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
292}
293
294void MCalibrationChargeCam::SetPINDiodeMethodValid(const Bool_t b)
295{
296 b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
297}
298
299Bool_t MCalibrationChargeCam::IsBlindPixelMethodValid() const
300{
301 return TESTBIT(fFlags,kBlindPixelMethodValid);
302}
303
304Bool_t MCalibrationChargeCam::IsPINDiodeMethodValid() const
305{
306 return TESTBIT(fFlags,kPINDiodeMethodValid);
307}
308
309
310Bool_t MCalibrationChargeCam::IsFluxInsidePlexiglassAvailable() const
311{
312 return TESTBIT(fFlags,kFluxInsidePlexiglassAvailable);
313}
314
315
316// --------------------------------------------------------------------------
317//
318// Print first the well fitted pixels
319// and then the ones which are not FitValid
320//
321void MCalibrationChargeCam::Print(Option_t *o) const
322{
323
324 *fLog << all << GetDescriptor() << ":" << endl;
325 int id = 0;
326
327 *fLog << all << "Succesfully calibrated pixels:" << endl;
328 *fLog << all << endl;
329
330 TIter Next(fPixels);
331 MCalibrationPix *pix;
332 while ((pix=(MCalibrationPix*)Next()))
333 {
334
335 if (pix->IsChargeValid() && !pix->IsExcluded() && !pix->IsOscillating() && pix->IsFitted())
336 {
337
338 *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
339 << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
340 << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge()
341 << " Nr Phe's: " << pix->GetPheFFactorMethod() << endl;
342 id++;
343 }
344 }
345
346 *fLog << all << id << " succesful pixels :-))" << endl;
347 id = 0;
348
349 *fLog << all << endl;
350 *fLog << all << "Pixels with errors:" << endl;
351 *fLog << all << endl;
352
353 TIter Next2(fPixels);
354 while ((pix=(MCalibrationPix*)Next2()))
355 {
356
357 if (!pix->IsChargeValid() && !pix->IsExcluded() && !pix->IsFitted())
358 {
359
360 *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
361 << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
362 << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge() << endl;
363 id++;
364 }
365 }
366 *fLog << all << id << " pixels with errors :-((" << endl;
367
368 *fLog << all << endl;
369 *fLog << all << "Pixels with oscillations:" << endl;
370 *fLog << all << endl;
371
372 id = 0;
373
374 TIter Next3(fPixels);
375 while ((pix=(MCalibrationPix*)Next3()))
376 {
377
378 if (pix->IsOscillating() && !pix->IsExcluded())
379 {
380
381 *fLog << all << pix->GetPixId() << " Pedestals: " << pix->GetPed() << " +- "
382 << pix->GetPedRms() << " Reduced Charge: " << pix->GetCharge() << " +- "
383 << pix->GetSigmaCharge() << " Reduced Sigma: " << pix->GetRSigmaCharge() << endl;
384 id++;
385 }
386 }
387 *fLog << all << id << " Oscillating pixels :-((" << endl;
388
389
390 *fLog << all << endl;
391 *fLog << all << "Excluded pixels:" << endl;
392 *fLog << all << endl;
393
394 TIter Next4(fPixels);
395 while ((pix=(MCalibrationPix*)Next4()))
396 if (pix->IsExcluded())
397 *fLog << all << pix->GetPixId() << endl;
398
399 *fLog << all << fNumExcludedPixels << " excluded pixels " << endl;
400}
401
402// --------------------------------------------------------------------------
403//
404// Return true if pixel is inside bounds of the TClonesArray fPixels
405//
406Bool_t MCalibrationChargeCam::IsPixelUsed(Int_t idx) const
407{
408 if (!CheckBounds(idx))
409 return kFALSE;
410
411 return kTRUE;
412}
413
414// --------------------------------------------------------------------------
415//
416// Return true if pixel has already been fitted once (independent of the result)
417//
418Bool_t MCalibrationChargeCam::IsPixelFitted(Int_t idx) const
419{
420
421 if (!CheckBounds(idx))
422 return kFALSE;
423
424 return (*this)[idx].IsFitted();
425}
426
427// --------------------------------------------------------------------------
428//
429// Sets the user ranges of all histograms such that
430// empty bins at the edges are not used. Additionally, it rebins the
431// histograms such that in total, 50 bins are used.
432//
433void MCalibrationChargeCam::CutEdges()
434{
435
436 fBlindPixel->GetHist()->CutAllEdges();
437
438 TIter Next(fPixels);
439 MCalibrationPix *pix;
440 while ((pix=(MCalibrationPix*)Next()))
441 {
442 pix->GetHist()->CutAllEdges();
443 }
444
445 return;
446}
447
448// --------------------------------------------------------------------------
449//
450// The types are as follows:
451//
452// Fitted values:
453// ==============
454//
455// 0: Fitted Charge
456// 1: Error of fitted Charge
457// 2: Sigma of fitted Charge
458// 3: Error of Sigma of fitted Charge
459//
460// Useful variables derived from the fit results:
461// =============================================
462//
463// 4: Returned probability of Gauss fit to Charge distribution
464// 5: Reduced Sigma of fitted Charge --> sqrt(sigma_Q^2 - PedRMS^2)
465// 6: Error Reduced Sigma of fitted Charge
466// 7: Reduced Sigma per Charge
467// 8: Error of Reduced Sigma per Charge
468//
469// Results of the different calibration methods:
470// =============================================
471//
472// 9: Number of Photo-electrons obtained with the F-Factor method
473// 10: Error on Number of Photo-electrons obtained with the F-Factor method
474// 11: Mean conversion factor obtained with the F-Factor method
475// 12: Error on the mean conversion factor obtained with the F-Factor method
476// 13: Overall F-Factor of the readout obtained with the F-Factor method
477// 14: Error on Overall F-Factor of the readout obtained with the F-Factor method
478// 15: Number of Photons inside Plexiglass obtained with the Blind Pixel method
479// 16: Error on Number of Photons inside Plexiglass obtained with the Blind Pixel method
480// 17: Mean conversion factor obtained with the Blind Pixel method
481// 18: Error on the mean conversion factor obtained with the Blind Pixel method
482// 19: Overall F-Factor of the readout obtained with the Blind Pixel method
483// 20: Error on Overall F-Factor of the readout obtained with the Blind Pixel method
484// 21: Number of Photons outside Plexiglass obtained with the PIN Diode method
485// 22: Error on Number of Photons outside Plexiglass obtained with the PIN Diode method
486// 23: Mean conversion factor obtained with the PIN Diode method
487// 24: Error on the mean conversion factor obtained with the PIN Diode method
488// 25: Overall F-Factor of the readout obtained with the PIN Diode method
489// 26: Error on Overall F-Factor of the readout obtained with the PIN Diode method
490//
491// Localized defects:
492// ==================
493//
494// 27: Excluded Pixels
495// 28: Pixels where the fit did not succeed --> results obtained only from the histograms
496// 29: Pixels with succeeded fit, but apparently wrong results
497// 30: Pixels with un-expected behavior in the fourier spectrum (e.g. oscillations)
498//
499// Other classifications of pixels:
500// ================================
501//
502// 31: Pixels with saturated Hi-Gain
503//
504// Classification of validity of the calibrations:
505// ===============================================
506//
507// 32: Pixels with valid calibration by the F-Factor-Method
508// 33: Pixels with valid calibration by the Blind Pixel-Method
509// 34: Pixels with valid calibration by the PIN Diode-Method
510//
511// Used Pedestals:
512// ===============
513//
514// 35: Mean Pedestal over the entire range of signal extraction
515// 36: Error on the Mean Pedestal over the entire range of signal extraction
516// 37: Pedestal RMS over the entire range of signal extraction
517// 38: Error on the Pedestal RMS over the entire range of signal extraction
518//
519// Calculated absolute arrival times (very low precision!):
520// ========================================================
521//
522// 39: Absolute Arrival time of the signal
523// 40: Error on the Absolute Arrival time of the signal
524// 41: RMS of the Absolute Arrival time of the signal
525// 42: Error on the RMS of the Absolute Arrival time of the signal
526//
527Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
528{
529
530 if (idx > GetSize())
531 return kFALSE;
532
533 Float_t area = cam[idx].GetA();
534
535 if (area == 0)
536 return kFALSE;
537
538 switch (type)
539 {
540 case 0:
541 if ((*this)[idx].IsExcluded())
542 return kFALSE;
543 val = (*this)[idx].GetCharge();
544 break;
545 case 1:
546 if ((*this)[idx].IsExcluded())
547 return kFALSE;
548 val = (*this)[idx].GetChargeErr();
549 break;
550 case 2:
551 if ((*this)[idx].IsExcluded())
552 return kFALSE;
553 val = (*this)[idx].GetSigmaCharge();
554 break;
555 case 3:
556 if ((*this)[idx].IsExcluded())
557 return kFALSE;
558 val = (*this)[idx].GetSigmaChargeErr();
559 break;
560 case 4:
561 if ((*this)[idx].IsExcluded())
562 return kFALSE;
563 val = (*this)[idx].GetChargeProb();
564 break;
565 case 5:
566 if ((*this)[idx].IsExcluded())
567 return kFALSE;
568 val = (*this)[idx].GetRSigmaCharge();
569 break;
570 case 6:
571 if ((*this)[idx].IsExcluded())
572 return kFALSE;
573 val = (*this)[idx].GetRSigmaChargeErr();
574 break;
575 case 7:
576 if ((*this)[idx].IsExcluded())
577 return kFALSE;
578 val = (*this)[idx].GetRSigmaCharge() / (*this)[idx].GetCharge();
579 break;
580 case 8:
581 if ((*this)[idx].IsExcluded())
582 return kFALSE;
583 // relative error RsigmaCharge square
584 val = (*this)[idx].GetRSigmaChargeErr()* (*this)[idx].GetRSigmaChargeErr()
585 / ((*this)[idx].GetRSigmaCharge() * (*this)[idx].GetRSigmaCharge() );
586 // relative error Charge square
587 val += (*this)[idx].GetChargeErr() * (*this)[idx].GetChargeErr()
588 / ((*this)[idx].GetCharge() * (*this)[idx].GetCharge() );
589 // calculate relative error out of squares
590 val = TMath::Sqrt(val) ;
591 // multiply with value to get absolute error
592 val *= (*this)[idx].GetRSigmaCharge() / (*this)[idx].GetCharge();
593 break;
594 case 9:
595 if ((*this)[idx].IsExcluded())
596 return kFALSE;
597 val = (*this)[idx].GetPheFFactorMethod();
598 break;
599 case 10:
600 if ((*this)[idx].IsExcluded())
601 return kFALSE;
602 val = (*this)[idx].GetPheFFactorMethodErr();
603 break;
604 case 11:
605 if ((*this)[idx].IsExcluded())
606 return kFALSE;
607 val = (*this)[idx].GetMeanConversionFFactorMethod();
608 break;
609 case 12:
610 if ((*this)[idx].IsExcluded())
611 return kFALSE;
612 val = (*this)[idx].GetConversionFFactorMethodErr();
613 break;
614 case 13:
615 if ((*this)[idx].IsExcluded())
616 return kFALSE;
617 val = (*this)[idx].GetTotalFFactorFFactorMethod();
618 break;
619 case 14:
620 if ((*this)[idx].IsExcluded())
621 return kFALSE;
622 val = (*this)[idx].GetTotalFFactorErrFFactorMethod();
623 break;
624 case 15:
625 if ((*this)[idx].IsExcluded())
626 return kFALSE;
627 val = GetMeanFluxInsidePlexiglass()*area;
628 break;
629 case 16:
630 if ((*this)[idx].IsExcluded())
631 return kFALSE;
632 val = GetMeanFluxInsidePlexiglass()*area;
633 break;
634 case 17:
635 if ((*this)[idx].IsExcluded())
636 return kFALSE;
637 val = (*this)[idx].GetMeanConversionBlindPixelMethod();
638 break;
639 case 18:
640 if ((*this)[idx].IsExcluded())
641 return kFALSE;
642 val = (*this)[idx].GetConversionBlindPixelMethodErr();
643 break;
644 case 19:
645 if ((*this)[idx].IsExcluded())
646 return kFALSE;
647 val = (*this)[idx].GetTotalFFactorBlindPixelMethod();
648 break;
649 case 20:
650 if ((*this)[idx].IsExcluded())
651 return kFALSE;
652 val = (*this)[idx].GetTotalFFactorErrBlindPixelMethod();
653 break;
654 case 21:
655 if ((*this)[idx].IsExcluded())
656 return kFALSE;
657 val = fPINDiode->GetMeanFluxOutsidePlexiglass()*area;
658 break;
659 case 22:
660 if ((*this)[idx].IsExcluded())
661 return kFALSE;
662 val = fPINDiode->GetMeanFluxOutsidePlexiglass()*area;
663 break;
664 case 23:
665 if ((*this)[idx].IsExcluded())
666 return kFALSE;
667 val = (*this)[idx].GetMeanConversionPINDiodeMethod();
668 break;
669 case 24:
670 if ((*this)[idx].IsExcluded())
671 return kFALSE;
672 val = (*this)[idx].GetConversionPINDiodeMethodErr();
673 break;
674 case 25:
675 if ((*this)[idx].IsExcluded())
676 return kFALSE;
677 val = (*this)[idx].GetTotalFFactorBlindPixelMethod();
678 break;
679 case 26:
680 if ((*this)[idx].IsExcluded())
681 return kFALSE;
682 val = (*this)[idx].GetTotalFFactorErrBlindPixelMethod();
683 break;
684 case 27:
685 if ((*this)[idx].IsExcluded())
686 val = 1.;
687 else
688 return kFALSE;
689 break;
690 case 28:
691 if ((*this)[idx].IsExcluded())
692 return kFALSE;
693 if (!(*this)[idx].IsFitted())
694 val = 1;
695 else
696 return kFALSE;
697 break;
698 case 29:
699 if ((*this)[idx].IsExcluded())
700 return kFALSE;
701 if (!(*this)[idx].IsFitted())
702 return kFALSE;
703 if (!(*this)[idx].IsChargeValid())
704 val = 1;
705 else
706 return kFALSE;
707 break;
708 case 30:
709 if ((*this)[idx].IsExcluded())
710 return kFALSE;
711 if ((*this)[idx].IsOscillating())
712 val = 1;
713 else
714 return kFALSE;
715 break;
716 case 31:
717 if ((*this)[idx].IsExcluded())
718 return kFALSE;
719 if ((*this)[idx].IsHiGainSaturation())
720 val = 1;
721 else
722 return kFALSE;
723 break;
724 case 32:
725 if ((*this)[idx].IsExcluded())
726 return kFALSE;
727 if ((*this)[idx].IsFFactorMethodValid())
728 val = 1;
729 else
730 return kFALSE;
731 break;
732 case 33:
733 if ((*this)[idx].IsExcluded())
734 return kFALSE;
735 if ((*this)[idx].IsBlindPixelMethodValid())
736 val = 1;
737 else
738 return kFALSE;
739 break;
740 case 34:
741 if ((*this)[idx].IsExcluded())
742 return kFALSE;
743 if ((*this)[idx].IsPINDiodeMethodValid())
744 val = 1;
745 else
746 return kFALSE;
747 break;
748 case 35:
749 if ((*this)[idx].IsExcluded())
750 return kFALSE;
751 val = (*this)[idx].GetPed();
752 break;
753 case 36:
754 if ((*this)[idx].IsExcluded())
755 return kFALSE;
756 val = 1.;
757 // val = (*this)[idx].GetPedError();
758 break;
759 case 37:
760 if ((*this)[idx].IsExcluded())
761 return kFALSE;
762 val = (*this)[idx].GetPedRms();
763 break;
764 case 38:
765 if ((*this)[idx].IsExcluded())
766 return kFALSE;
767 val = 1.;
768 // val = (*this)[idx].GetPedRmsError();
769 break;
770 case 39:
771 if ((*this)[idx].IsExcluded())
772 return kFALSE;
773 val = (*this)[idx].GetAbsTimeMean();
774 break;
775 case 40:
776 if ((*this)[idx].IsExcluded())
777 return kFALSE;
778 val = (*this)[idx].GetAbsTimeMeanErr();
779 break;
780 case 41:
781 if ((*this)[idx].IsExcluded())
782 return kFALSE;
783 val = (*this)[idx].GetAbsTimeRms();
784 break;
785 case 42:
786 if ((*this)[idx].IsExcluded())
787 return kFALSE;
788 val = (*this)[idx].GetAbsTimeMeanErr()/TMath::Sqrt(2.);
789 break;
790 default:
791 return kFALSE;
792 }
793 return val!=-1.;
794}
795
796// --------------------------------------------------------------------------
797//
798// What MHCamera needs in order to draw an individual pixel in the camera
799//
800void MCalibrationChargeCam::DrawPixelContent(Int_t idx) const
801{
802 (*this)[idx].DrawClone();
803}
804
805
806// --------------------------------------------------------------------------
807//
808//
809//
810Bool_t MCalibrationChargeCam::CalcFluxInsidePlexiglass()
811{
812
813 if (!fBlindPixel->IsFitOK())
814 return kFALSE;
815
816 const Float_t mean = fBlindPixel->GetLambda();
817 const Float_t merr = fBlindPixel->GetErrLambda();
818
819 //
820 // Start calculation of number of photons
821 //
822 // The blind pixel has exactly 100 mm^2 area (with negligible error),
823 //
824 fMeanFluxInsidePlexiglass = mean*gkBlindPixelArea;
825
826 // Start calculation of number of photons relative Variance (!!)
827 fMeanFluxErrInsidePlexiglass = merr*merr/mean/mean;
828
829 switch (fColor)
830 {
831 case kEGreen:
832 fMeanFluxInsidePlexiglass /= gkCalibrationBlindPixelQEGreen;
833 fMeanFluxErrInsidePlexiglass += gkCalibrationBlindPixelQEGreenErr*gkCalibrationBlindPixelQEGreenErr
834 / gkCalibrationBlindPixelQEGreen / gkCalibrationBlindPixelQEGreen;
835
836 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttGreen); // correct for absorption
837 // attenuation has negligible error
838 break;
839 case kEBlue:
840 fMeanFluxInsidePlexiglass /= gkCalibrationBlindPixelQEBlue;
841 fMeanFluxErrInsidePlexiglass += gkCalibrationBlindPixelQEBlueErr*gkCalibrationBlindPixelQEBlueErr
842 / gkCalibrationBlindPixelQEBlue / gkCalibrationBlindPixelQEBlue;
843
844 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttBlue); // correct for absorption
845 // attenuation has negligible error
846 break;
847 case kEUV:
848 fMeanFluxInsidePlexiglass /= gkCalibrationBlindPixelQEUV;
849 fMeanFluxErrInsidePlexiglass += gkCalibrationBlindPixelQEUVErr*gkCalibrationBlindPixelQEUVErr
850 / gkCalibrationBlindPixelQEUV / gkCalibrationBlindPixelQEUV;
851
852 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttUV); // correct for absorption
853 // attenuation has negligible error
854 break;
855 case kECT1:
856 default:
857 fMeanFluxInsidePlexiglass /= gkCalibrationBlindPixelQECT1;
858 fMeanFluxErrInsidePlexiglass += gkCalibrationBlindPixelQECT1Err*gkCalibrationBlindPixelQECT1Err
859 / gkCalibrationBlindPixelQECT1 / gkCalibrationBlindPixelQECT1;
860
861 fMeanFluxInsidePlexiglass *= TMath::Power(10,gkCalibrationBlindPixelAttCT1); // correct for absorption
862 // attenuation has negligible error
863 break;
864 }
865
866 *fLog << inf << endl;
867 *fLog << inf << " Photon flux [ph/mm^2] inside Plexiglass: "
868 << fMeanFluxInsidePlexiglass << endl;
869
870 if (fMeanFluxInsidePlexiglass > 0.)
871 SETBIT(fFlags,kFluxInsidePlexiglassAvailable);
872 else
873 {
874 CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
875 return kFALSE;
876 }
877
878 if (fMeanFluxErrInsidePlexiglass < 0.)
879 {
880 *fLog << warn << " Relative Variance on Photon flux inside Plexiglass: "
881 << fMeanFluxErrInsidePlexiglass << endl;
882 CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
883 return kFALSE;
884 }
885
886 // Finish calculation of errors -> convert from relative variance to absolute error
887 fMeanFluxErrInsidePlexiglass = TMath::Sqrt(fMeanFluxErrInsidePlexiglass);
888 fMeanFluxErrInsidePlexiglass *= fMeanFluxInsidePlexiglass;
889
890 *fLog << inf << " Error on photon flux [ph/mm^2] inside Plexiglass: "
891 << fMeanFluxErrInsidePlexiglass << endl;
892 *fLog << inf << endl;
893
894 TIter Next(fPixels);
895 MCalibrationPix *pix;
896 while ((pix=(MCalibrationPix*)Next()))
897 {
898
899 if(pix->IsChargeValid())
900 {
901
902 const Int_t idx = pix->GetPixId();
903
904 const Float_t charge = pix->GetCharge();
905 const Float_t area = (*fGeomCam)[idx].GetA();
906 const Float_t chargeerr = pix->GetChargeErr();
907
908 const Float_t nphot = fMeanFluxInsidePlexiglass*area;
909 const Float_t nphoterr = fMeanFluxErrInsidePlexiglass*area;
910 const Float_t conversion = nphot/charge;
911 Float_t conversionerr;
912
913 conversionerr = nphoterr/charge
914 * nphoterr/charge ;
915 conversionerr += chargeerr/charge
916 * chargeerr/charge
917 * conversion*conversion;
918 conversionerr = TMath::Sqrt(conversionerr);
919
920 const Float_t conversionsigma = 0.;
921
922 pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
923
924 if (conversionerr/conversion < 0.1)
925 pix->SetBlindPixelMethodValid();
926 }
927 }
928 return kTRUE;
929}
930
931
932void MCalibrationChargeCam::ApplyPINDiodeCalibration()
933{
934
935 Float_t flux = fPINDiode->GetMeanFluxOutsidePlexiglass();
936 Float_t fluxerr = fPINDiode->GetMeanFluxErrOutsidePlexiglass();
937
938 TIter Next(fPixels);
939 MCalibrationPix *pix;
940 while ((pix=(MCalibrationPix*)Next()))
941 {
942
943 if (pix->IsChargeValid())
944 {
945
946 const Int_t idx = pix->GetPixId();
947
948 const Float_t charge = pix->GetCharge();
949 const Float_t area = (*fGeomCam)[idx].GetA();
950 const Float_t chargeerr = pix->GetChargeErr();
951
952 const Float_t nphot = flux * area;
953 const Float_t nphoterr = fluxerr * area;
954 const Float_t conversion = nphot/charge;
955
956 Float_t conversionerr;
957
958 conversionerr = nphoterr/charge
959 * nphoterr/charge ;
960 conversionerr += chargeerr/charge
961 * chargeerr/charge
962 * conversion*conversion;
963 if (conversionerr > 0.)
964 conversionerr = TMath::Sqrt(conversionerr);
965
966 const Float_t conversionsigma = 0.;
967
968 pix->SetConversionPINDiodeMethod(conversion, conversionerr, conversionsigma);
969
970 if (conversionerr/conversion < 0.1)
971 pix->SetPINDiodeMethodValid();
972
973 }
974 }
975}
976
977
978
979Bool_t MCalibrationChargeCam::GetConversionFactorBlindPixel(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
980{
981
982 if (ipx < 0 || !IsPixelFitted(ipx))
983 return kFALSE;
984
985 if (!IsFluxInsidePlexiglassAvailable())
986 if (!CalcFluxInsidePlexiglass())
987 return kFALSE;
988
989 mean = (*this)[ipx].GetMeanConversionBlindPixelMethod();
990 err = (*this)[ipx].GetConversionBlindPixelMethodErr();
991 sigma = (*this)[ipx].GetSigmaConversionBlindPixelMethod();
992
993 return kTRUE;
994}
995
996
997Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
998{
999
1000 if (ipx < 0 || !IsPixelFitted(ipx))
1001 return kFALSE;
1002
1003 Float_t conv = (*this)[ipx].GetMeanConversionFFactorMethod();
1004
1005 if (conv < 0.)
1006 return kFALSE;
1007
1008 mean = conv;
1009 err = (*this)[ipx].GetConversionFFactorMethodErr();
1010 sigma = (*this)[ipx].GetSigmaConversionFFactorMethod();
1011
1012 return kTRUE;
1013}
1014
1015
1016//-----------------------------------------------------------------------------------
1017//
1018// Calculates the conversion factor between the integral of FADCs slices
1019// (as defined in the signal extractor MExtractSignal.cc)
1020// and the number of photons reaching the plexiglass for one Inner Pixel
1021//
1022// FIXME: The PINDiode is still not working and so is the code
1023//
1024Bool_t MCalibrationChargeCam::GetConversionFactorPINDiode(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
1025{
1026
1027 if (ipx < 0 || !IsPixelFitted(ipx))
1028 return kFALSE;
1029
1030 mean = (*this)[ipx].GetMeanConversionPINDiodeMethod();
1031 err = (*this)[ipx].GetConversionPINDiodeMethodErr();
1032 sigma = (*this)[ipx].GetSigmaConversionPINDiodeMethod();
1033
1034 return kFALSE;
1035
1036}
1037
1038//-----------------------------------------------------------------------------------
1039//
1040// Calculates the best combination of the three used methods possible
1041// between the integral of FADCs slices
1042// (as defined in the signal extractor MExtractSignal.cc)
1043// and the number of photons reaching one Inner Pixel.
1044// The procedure is not yet defined.
1045//
1046// FIXME: The PINDiode is still not working and so is the code
1047//
1048Bool_t MCalibrationChargeCam::GetConversionFactorCombined(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
1049{
1050
1051 if (ipx < 0 || !IsPixelFitted(ipx))
1052 return kFALSE;
1053
1054 return kFALSE;
1055
1056}
1057
1058/*
1059void MCalibrationChargeCam::DrawHiLoFits()
1060{
1061
1062 if (!fOffsets)
1063 fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
1064 if (!fSlopes)
1065 fSlopes = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
1066 if (!fOffvsSlope)
1067 fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
1068
1069 TIter Next(fPixels);
1070 MCalibrationPix *pix;
1071 MHCalibrationPixel *hist;
1072 while ((pix=(MCalibrationPix*)Next()))
1073 {
1074 hist = pix->GetHist();
1075 hist->FitHiGainvsLoGain();
1076 fOffsets->Fill(hist->GetOffset(),1.);
1077 fSlopes->Fill(hist->GetSlope(),1.);
1078 fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
1079 }
1080
1081 TCanvas *c1 = new TCanvas();
1082
1083 c1->Divide(1,3);
1084 c1->cd(1);
1085 fOffsets->Draw();
1086 gPad->Modified();
1087 gPad->Update();
1088
1089 c1->cd(2);
1090 fSlopes->Draw();
1091 gPad->Modified();
1092 gPad->Update();
1093
1094 c1->cd(3);
1095 fOffvsSlope->Draw("col1");
1096 gPad->Modified();
1097 gPad->Update();
1098}
1099
1100*/
Note: See TracBrowser for help on using the repository browser.