source: trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc@ 5860

Last change on this file since 5860 was 5858, checked in by gaug, 20 years ago
*** empty log message ***
File size: 44.1 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// MHCalibrationCam
27//
28// Base class for camera calibration classes. Incorporates the TOrdCollection's:
29// - fHiGainArray (for calibrated High Gains per pixel)
30// - fLoGainArray (for calibrated Low Gains per pixel)
31// - fAverageHiGainAreas (for averaged High Gains events per camera area index)
32// - fAverageLoGainAreas (for averaged High Gains events per camera area index)
33// - fAverageHiGainSectors (for averaged High Gains events per camera sector )
34// - fAverageLoGainSectors (for averaged High Gains events per camera sector )
35// These TOrdCollection's are called by their default constructors, thus no objects
36// are created, until the derived class does so.
37//
38// The corresponding operators: [],() and the operators GetAverageHiGainArea(),
39// GetAverageLoGainArea(), GetAverageHiGainSector() and GetAverageLoGainSector()
40// have to be cast to the corresponding class. It is assumed that all classes
41// dealing with calibration pixels derive from MHCalibrationPix.
42//
43// The following flag can be set:
44// - SetAverageing() for calculating the event-by-event averages.
45// - SetDebug() for debug output.
46// - SetLoGain() for the case that low-gain slices are available, but
47// MRawRunHeader::GetNumLoGainSlices() gives still 0.
48// - SetCheckSize() for testing the sizes of the f*Arrays in ReInit() if they
49// are coinciding with the equiv. sizes in MGeomCam
50//
51// The flag kLoGain steers if the low-gain signal is treated at all or not.
52// The flag kAverageing steers if the event-by-event averages are treated at all.
53//
54/////////////////////////////////////////////////////////////////////////////
55#include "MHCalibrationCam.h"
56#include "MHCalibrationPix.h"
57
58#include <TVirtualPad.h>
59#include <TCanvas.h>
60#include <TPad.h>
61#include <TText.h>
62#include <TPaveText.h>
63#include <TOrdCollection.h>
64#include <TROOT.h>
65
66#include "MLog.h"
67#include "MLogManip.h"
68
69#include "MCalibrationIntensityCam.h"
70#include "MCalibrationCam.h"
71#include "MCalibrationPix.h"
72
73#include "MBadPixelsIntensityCam.h"
74#include "MBadPixelsCam.h"
75#include "MBadPixelsPix.h"
76
77#include "MGeomCam.h"
78#include "MGeomPix.h"
79
80#include "MParList.h"
81
82#include "MRawRunHeader.h"
83
84ClassImp(MHCalibrationCam);
85
86using namespace std;
87
88const Int_t MHCalibrationCam::fgPulserFrequency = 500;
89const Float_t MHCalibrationCam::fgProbLimit = 0.0001;
90const TString MHCalibrationCam::gsHistName = "Hist";
91const TString MHCalibrationCam::gsHistTitle = "";
92const TString MHCalibrationCam::gsHistXTitle = "";
93const TString MHCalibrationCam::gsHistYTitle = "Nr. events";
94// --------------------------------------------------------------------------
95//
96// Default Constructor.
97//
98// Sets:
99// - all pointers to NULL
100//
101// Initializes and sets owner of:
102// - fHiGainArray, fLoGainArray
103// - fAverageHiGainAreas, fAverageLoGainAreas
104// - fAverageHiGainSectors, fAverageLoGainSectors
105//
106// Initializes:
107// - fPulserFrequency to fgPulserFrequency
108// - fProbLimit to fgProbLimit
109//
110// - SetAveregeing (kTRUE);
111// - SetDebug (kFALSE);
112// - SetLoGain (kTRUE);
113//- SetOscillations(kTRUE);
114//- SetSizeCheck (kTRUE);
115//- SetInterlaced (kFALSE);
116//
117MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
118 : fHistName(gsHistName),fHistTitle(gsHistTitle),
119 fHistXTitle(gsHistXTitle),fHistYTitle(gsHistYTitle),
120 fColor(MCalibrationCam::kNONE), fIntensBad(NULL),
121 fBadPixels(NULL), fIntensCam(NULL), fCam(NULL), fGeom(NULL),
122 fRunHeader(NULL)
123{
124
125 fHiGainArray = new TOrdCollection;
126 fHiGainArray->SetOwner();
127
128 fLoGainArray = new TOrdCollection;
129 fLoGainArray->SetOwner();
130
131 fAverageHiGainAreas = new TOrdCollection;
132 fAverageHiGainAreas->SetOwner();
133
134 fAverageLoGainAreas = new TOrdCollection;
135 fAverageLoGainAreas->SetOwner();
136
137 fAverageHiGainSectors = new TOrdCollection;
138 fAverageHiGainSectors->SetOwner();
139
140 fAverageLoGainSectors = new TOrdCollection;
141 fAverageLoGainSectors->SetOwner();
142
143 SetPulserFrequency();
144 SetProbLimit();
145
146 SetAverageing (kTRUE);
147 SetDebug (kFALSE);
148 SetLoGain (kTRUE);
149 SetOscillations(kTRUE);
150 SetSizeCheck (kTRUE);
151}
152
153// --------------------------------------------------------------------------
154//
155// Deletes the TOrdCollection of:
156// - fHiGainArray, fLoGainArray
157// - fAverageHiGainAreas, fAverageLoGainAreas
158// - fAverageHiGainSectors, fAverageLoGainSectors
159//
160MHCalibrationCam::~MHCalibrationCam()
161{
162
163 delete fHiGainArray;
164 delete fLoGainArray;
165
166 delete fAverageHiGainAreas;
167 delete fAverageLoGainAreas;
168
169 delete fAverageHiGainSectors;
170 delete fAverageLoGainSectors;
171 /*
172
173 Remove ( fHiGainArray );
174 Remove ( fLoGainArray );
175
176 Remove ( fAverageHiGainAreas );
177 Remove ( fAverageLoGainAreas );
178
179 Remove ( fAverageHiGainSectors );
180 Remove ( fAverageLoGainSectors );
181 */
182
183}
184
185void MHCalibrationCam::Remove(TOrdCollection *col)
186{
187
188 if (!col)
189 return;
190
191 TOrdCollectionIter Next(col);
192
193 Int_t count = 0;
194
195 while (MHCalibrationPix *obj = (MHCalibrationPix*)Next())
196 {
197 *fLog << ++count << " " << obj << flush;
198 if (obj && obj->IsOnHeap())
199 {
200 obj->Draw();
201 delete obj;
202 }
203 }
204
205 delete col;
206}
207
208// --------------------------------------------------------------------------
209//
210// Returns size of fHiGainArray
211//
212const Int_t MHCalibrationCam::GetSize() const
213{
214 return fHiGainArray->GetSize();
215}
216
217// --------------------------------------------------------------------------
218//
219// Get i-th High Gain pixel (pixel number)
220//
221MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i)
222{
223 return *static_cast<MHCalibrationPix*>(fHiGainArray->At(i));
224}
225
226// --------------------------------------------------------------------------
227//
228// Get i-th High Gain pixel (pixel number)
229//
230const MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i) const
231{
232 return *static_cast<MHCalibrationPix*>(fHiGainArray->At(i));
233}
234
235// --------------------------------------------------------------------------
236//
237// Get i-th Low Gain pixel (pixel number)
238//
239MHCalibrationPix &MHCalibrationCam::operator()(UInt_t i)
240{
241 return *static_cast<MHCalibrationPix*>(fLoGainArray->At(i));
242}
243
244// --------------------------------------------------------------------------
245//
246// Get i-th Low Gain pixel (pixel number)
247//
248const MHCalibrationPix &MHCalibrationCam::operator()(UInt_t i) const
249{
250 return *static_cast<MHCalibrationPix*>(fLoGainArray->At(i));
251}
252
253// --------------------------------------------------------------------------
254//
255// Returns the current size of the TOrdCollection fAverageHiGainAreas
256// independently if the MHCalibrationPix is filled with values or not.
257//
258const Int_t MHCalibrationCam::GetAverageAreas() const
259{
260 return fAverageHiGainAreas->GetSize();
261}
262
263// --------------------------------------------------------------------------
264//
265// Get i-th High Gain pixel Area (area number)
266//
267MHCalibrationPix &MHCalibrationCam::GetAverageHiGainArea(UInt_t i)
268{
269 return *static_cast<MHCalibrationPix*>(fAverageHiGainAreas->At(i));
270}
271
272// --------------------------------------------------------------------------
273//
274// Get i-th High Gain pixel Area (area number)
275//
276const MHCalibrationPix &MHCalibrationCam::GetAverageHiGainArea(UInt_t i) const
277{
278 return *static_cast<MHCalibrationPix *>(fAverageHiGainAreas->At(i));
279}
280
281// --------------------------------------------------------------------------
282//
283// Get i-th Low Gain pixel Area (area number)
284//
285MHCalibrationPix &MHCalibrationCam::GetAverageLoGainArea(UInt_t i)
286{
287 return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->At(i));
288}
289
290// --------------------------------------------------------------------------
291//
292// Get i-th Low Gain pixel Area (area number)
293//
294const MHCalibrationPix &MHCalibrationCam::GetAverageLoGainArea(UInt_t i) const
295{
296 return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->At(i));
297}
298
299// --------------------------------------------------------------------------
300//
301// Returns the current size of the TOrdCollection fAverageHiGainSectors
302// independently if the MHCalibrationPix is filled with values or not.
303//
304const Int_t MHCalibrationCam::GetAverageSectors() const
305{
306 return fAverageHiGainSectors->GetSize();
307}
308
309// --------------------------------------------------------------------------
310//
311// Get i-th High Gain Sector (sector number)
312//
313MHCalibrationPix &MHCalibrationCam::GetAverageHiGainSector(UInt_t i)
314{
315 return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->At(i));
316}
317
318// --------------------------------------------------------------------------
319//
320// Get i-th High Gain Sector (sector number)
321//
322const MHCalibrationPix &MHCalibrationCam::GetAverageHiGainSector(UInt_t i) const
323{
324 return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->At(i));
325}
326
327// --------------------------------------------------------------------------
328//
329// Get i-th Low Gain Sector (sector number)
330//
331MHCalibrationPix &MHCalibrationCam::GetAverageLoGainSector(UInt_t i)
332{
333 return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->At(i));
334}
335
336// --------------------------------------------------------------------------
337//
338// Get i-th Low Gain Sector (sector number)
339//
340const MHCalibrationPix &MHCalibrationCam::GetAverageLoGainSector(UInt_t i) const
341{
342 return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->At(i));
343}
344
345// --------------------------------------------------------------------------
346//
347// Calls ResetHistTitles()
348//
349// Calls Reset() for each entry in:
350// - fHiGainArray, fLoGainArray
351// - fAverageHiGainAreas, fAverageLoGainAreas
352// - fAverageHiGainSectors, fAverageLoGainSectors
353//
354void MHCalibrationCam::ResetHists()
355{
356
357 ResetHistTitles();
358
359 if (fHiGainArray)
360 { fHiGainArray->ForEach(MHCalibrationPix,Reset)(); }
361
362 if (IsAverageing())
363 {
364 if (fAverageHiGainAreas)
365 { fAverageHiGainAreas->ForEach(MHCalibrationPix,Reset)(); }
366 if (fAverageHiGainSectors)
367 { fAverageHiGainSectors->ForEach(MHCalibrationPix,Reset)(); }
368 }
369
370 if (!IsLoGain())
371 return;
372
373 if (fLoGainArray)
374 { fLoGainArray->ForEach(MHCalibrationPix,Reset)(); }
375 if (IsAverageing())
376 {
377 if (fAverageLoGainAreas)
378 { fAverageLoGainAreas->ForEach(MHCalibrationPix,Reset)(); }
379 if (fAverageLoGainSectors)
380 { fAverageLoGainSectors->ForEach(MHCalibrationPix,Reset)(); }
381 }
382}
383
384// --------------------------------------------------------------------------
385//
386// Resets the histogram titles for each entry in:
387// - fHiGainArray, fLoGainArray
388// - fAverageHiGainAreas, fAverageLoGainAreas
389// - fAverageHiGainSectors, fAverageLoGainSectors
390//
391void MHCalibrationCam::ResetHistTitles()
392{
393
394 TH1F *h;
395
396 if (fHiGainArray)
397 for (Int_t i=0;i<fHiGainArray->GetSize(); i++)
398 {
399 MHCalibrationPix &pix = (*this)[i];
400 h = pix.GetHGausHist();
401 h->SetName (Form("%s%s%s%4i","H",fHistName.Data(),"HiGainPix",i));
402 h->SetTitle(Form("%s%s%4i%s",fHistTitle.Data()," High Gain Pixel ",i," Runs: "));
403 h->SetXTitle(fHistXTitle.Data());
404 h->SetYTitle(fHistYTitle.Data());
405 }
406
407 if (IsAverageing())
408 {
409 if (fAverageHiGainAreas)
410 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
411 {
412 MHCalibrationPix &pix = GetAverageHiGainArea(j);
413 h = pix.GetHGausHist();
414 h->SetName (Form("%s%s%s%d","H",fHistName.Data(),"HiGainArea",j));
415 h->SetXTitle(fHistXTitle.Data());
416 h->SetYTitle(fHistYTitle.Data());
417 if (fGeom->InheritsFrom("MGeomCamMagic"))
418 h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
419 j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
420 else
421 h->SetTitle(Form("%s%s%d%s",fHistTitle.Data(),
422 " averaged on event-by-event basis High Gain Area Idx ",j," Runs: "));
423 }
424
425 if (fAverageHiGainSectors)
426 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
427 {
428 MHCalibrationPix &pix = GetAverageHiGainSector(j);
429 h = pix.GetHGausHist();
430 h->SetName (Form("%s%s%s%2i","H",fHistName.Data(),"HiGainSector",j));
431 h->SetTitle(Form("%s%s%2i%s",fHistTitle.Data(),
432 " averaged on event-by-event basis High Gain Sector ",j," Runs: "));
433 h->SetXTitle(fHistXTitle.Data());
434 h->SetYTitle(fHistYTitle.Data());
435 }
436 }
437
438 if (!IsLoGain())
439 return;
440
441 if (fLoGainArray)
442 for (Int_t i=0;i<fLoGainArray->GetSize(); i++)
443 {
444 MHCalibrationPix &pix = (*this)(i);
445 h = pix.GetHGausHist();
446 h->SetName (Form("%s%s%s%4i","H",fHistName.Data(),"LoGainPix",i));
447 h->SetTitle(Form("%s%s%4i%s",fHistTitle.Data()," Low Gain Pixel ",i," Runs: "));
448 h->SetXTitle(fHistXTitle.Data());
449 h->SetYTitle(fHistYTitle.Data());
450 }
451
452 if (IsAverageing())
453 {
454 if (fAverageLoGainAreas)
455 for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
456 {
457 MHCalibrationPix &pix = GetAverageLoGainArea(j);
458 h = pix.GetHGausHist();
459 h->SetName (Form("%s%s%s%d","H",fHistName.Data(),"LoGainArea",j));
460 h->SetXTitle(fHistXTitle.Data());
461 h->SetYTitle(fHistYTitle.Data());
462 if (fGeom->InheritsFrom("MGeomCamMagic"))
463 h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
464 j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
465 else
466 h->SetTitle(Form("%s%s%d%s",fHistTitle.Data(),
467 " averaged on event-by-event basis Low Gain Area Idx ",j," Runs: "));
468 }
469
470 if (fAverageLoGainSectors)
471 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
472 {
473 MHCalibrationPix &pix = GetAverageLoGainSector(j);
474 h = pix.GetHGausHist();
475 h->SetName (Form("%s%s%s%2i","H",fHistName.Data(),"LoGainSector",j));
476 h->SetTitle(Form("%s%s%2i%s",fHistTitle.Data(),
477 " averaged on event-by-event basis Low Gain Sector ",j," Runs: "));
478 h->SetXTitle(fHistXTitle.Data());
479 h->SetYTitle(fHistYTitle.Data());
480 }
481 }
482}
483
484// --------------------------------------------------------------------------
485//
486// Gets the pointers to:
487// - MGeomCam
488//
489// Calls SetupHists(const MParList *pList)
490//
491// Calls Delete-Function of:
492// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
493// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
494// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
495//
496Bool_t MHCalibrationCam::SetupFill(const MParList *pList)
497{
498
499 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
500 if (!fGeom)
501 {
502 *fLog << err << GetDescriptor()
503 << ": MGeomCam not found... aborting." << endl;
504 return kFALSE;
505 }
506
507 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
508 if (!fRunHeader)
509 {
510 *fLog << warn << GetDescriptor()
511 << ": MRawRunHeader not found... will not store run numbers." << endl;
512 }
513
514 return SetupHists(pList);
515}
516
517
518// --------------------------------------------------------------------------
519//
520// Searches MRawEvtHeader to find the correct pulser colour
521//
522// Gets or creates the pointers to:
523// - MBadPixelsIntensityCam
524// - MBadPixelsCam
525//
526// Searches pointer to:
527// - MArrivalTimeCam
528//
529// Initializes, if empty to MArrivalTimeCam::GetSize() for:
530// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
531//
532// Initializes, if empty to MGeomCam::GetNumAreas() for:
533// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
534//
535// Initializes, if empty to MGeomCam::GetNumSectors() for:
536// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
537//
538// Initializes TArray's to MGeomCam::GetNumAreas and MGeomCam::GetNumSectors, respectively
539// Fills with number of valid pixels (if !MBadPixelsPix::IsBad()):
540// - MHCalibrationCam::fAverageAreaNum[area index]
541// - MHCalibrationCam::fAverageSectorNum[area index]
542//
543// Calls InitializeHists() for every entry in:
544// - MHCalibrationCam::fHiGainArray
545// - MHCalibrationCam::fAverageHiGainAreas
546// - MHCalibrationCam::fAverageHiGainSectors
547//
548// Sets Titles and Names for the Histograms
549// - MHCalibrationCam::fAverageHiGainAreas
550// - MHCalibrationCam::fAverageHiGainSectors
551//
552// Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
553//
554Bool_t MHCalibrationCam::ReInit(MParList *pList)
555{
556
557 const Int_t npixels = fGeom->GetNumPixels();
558 const Int_t nsectors = fGeom->GetNumSectors();
559 const Int_t nareas = fGeom->GetNumAreas();
560
561 fIntensBad = (MBadPixelsIntensityCam*)pList->FindObject(AddSerialNumber("MBadPixelsIntensityCam"));
562 if (fIntensBad)
563 *fLog << inf << "Found MBadPixelsIntensityCam ... " << endl;
564 else
565 {
566 fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
567 if (!fBadPixels)
568 {
569
570 fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
571 if (!fBadPixels)
572 {
573 *fLog << err << "Cannot find nor create MBadPixelsCam ... abort." << endl;
574 return kFALSE;
575 }
576 else
577 fBadPixels->InitSize(npixels);
578 }
579 }
580
581 if (IsAverageing())
582 {
583 //
584 // The function TArrayF::Set() already sets all entries to 0.
585 //
586 fAverageAreaNum. Set(nareas);
587 fAverageAreaSat. Set(nareas);
588 fAverageAreaSigma. Set(nareas);
589 fAverageAreaSigmaVar. Set(nareas);
590 fAverageAreaRelSigma. Set(nareas);
591 fAverageAreaRelSigmaVar.Set(nareas);
592 fAverageSectorNum. Set(nsectors);
593
594 for (Int_t aidx=0; aidx<nareas; aidx++)
595 fAverageAreaNum[aidx] = 0;
596
597 for (Int_t sector=0; sector<nsectors; sector++)
598 fAverageSectorNum[sector] = 0;
599
600 for (Int_t i=0; i<npixels; i++)
601 {
602
603 MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
604 if (bad.IsBad())
605 continue;
606
607 fAverageAreaNum [(*fGeom)[i].GetAidx() ]++;
608 fAverageSectorNum[(*fGeom)[i].GetSector()]++;
609 }
610 }
611
612 //
613 // Because ReInit has been called, a new run number is added
614 //
615 fRunNumbers.Set(fRunNumbers.GetSize()+1);
616
617 if (fRunHeader)
618 {
619 fRunNumbers[fRunNumbers.GetSize()-1] = fRunHeader->GetRunNumber();
620 if (IsLoGain())
621 SetLoGain(fRunHeader->GetNumSamplesLoGain());
622 }
623
624 if (!ReInitHists(pList))
625 return kFALSE;
626
627 ResetHistTitles();
628
629 if (!fRunHeader)
630 return kTRUE;
631
632 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
633 {
634 TH1F *h = (*this)[i].GetHGausHist();
635 h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
636 }
637
638 if (IsLoGain())
639 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
640 {
641 TH1F *h = (*this)(i).GetHGausHist();
642 h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
643 }
644
645 if (!IsAverageing())
646 return kTRUE;
647
648 for (Int_t j=0; j<nareas; j++)
649 {
650 TH1F *h = GetAverageHiGainArea(j).GetHGausHist();
651 h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
652 }
653
654 if (IsLoGain())
655 for (Int_t j=0; j<nareas; j++)
656 {
657 TH1F *h = GetAverageLoGainArea(j).GetHGausHist();
658 h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
659 }
660
661 for (Int_t j=0; j<nsectors; j++)
662 {
663 TH1F *h = GetAverageHiGainSector(j).GetHGausHist();
664 h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
665 }
666
667 if (IsLoGain())
668 for (Int_t j=0; j<nsectors; j++)
669 {
670 TH1F *h = GetAverageLoGainSector(j).GetHGausHist();
671 h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
672 }
673
674 return kTRUE;
675}
676
677//--------------------------------------------------------------------------------------
678//
679// Initializes the High Gain Arrays:
680//
681// - For every entry in the expanded arrays:
682// * Initialize an MHCalibrationPix
683// * Set Binning from fNbins, fFirst and fLast
684// * Set Histgram names and titles from fHistName and fHistTitle
685// * Set X-axis and Y-axis titles with fHistXTitle and fHistYTitle
686// * Call InitHists
687//
688void MHCalibrationCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
689{
690
691 if (fHiGainArray->GetSize()==0)
692 {
693 for (Int_t i=0; i<npixels; i++)
694 {
695 fHiGainArray->AddAt(new MHCalibrationPix(Form("%sHiGainPix%04d",fHistName.Data(),i),
696 Form("%s High Gain Pixel %4d",fHistTitle.Data(),i)),i);
697
698 MHCalibrationPix &pix = (*this)[i];
699 pix.SetNbins(fNbins);
700 pix.SetFirst(fFirst);
701 pix.SetLast (fLast);
702 pix.SetProbLimit(fProbLimit);
703
704 MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
705 InitHists(pix,bad,i);
706 }
707 }
708
709 if (!IsAverageing())
710 return;
711
712 if (fAverageHiGainAreas->GetSize()==0)
713 {
714 for (Int_t j=0; j<nareas; j++)
715 {
716 fAverageHiGainAreas->AddAt(new MHCalibrationPix(Form("%sHiGainArea%d",fHistName.Data(),j),
717 Form("%s High Gain Area Idx %d",fHistTitle.Data(),j)),j);
718
719 MHCalibrationPix &pix = GetAverageHiGainArea(j);
720
721 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
722 pix.SetFirst(fFirst);
723 pix.SetLast (fLast);
724
725 if (fGeom && fGeom->InheritsFrom("MGeomCamMagic"))
726 {
727 pix.InitBins();
728 pix.SetEventFrequency(fPulserFrequency);
729 }
730 else
731 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
732 }
733 }
734
735 if (fAverageHiGainSectors->GetSize()==0)
736 {
737 for (Int_t j=0; j<nsectors; j++)
738 {
739 fAverageHiGainSectors->AddAt(new MHCalibrationPix(Form("%sHiGainSector%02d",fHistName.Data(),j),
740 Form("%s High Gain Sector %02d",fHistTitle.Data(),j)),j);
741 MHCalibrationPix &pix = GetAverageHiGainSector(j);
742
743 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors));
744 pix.SetFirst(fFirst);
745 pix.SetLast (fLast);
746
747 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
748 }
749 }
750}
751
752//--------------------------------------------------------------------------------------
753//
754// Return, if IsLoGain() is kFALSE
755//
756// Initializes the Low Gain Arrays:
757//
758// - For every entry in the expanded arrays:
759// * Initialize an MHCalibrationPix
760// * Set Binning from fNbins, fFirst and fLast
761// * Set Histgram names and titles from fHistName and fHistTitle
762// * Set X-axis and Y-axis titles with fHistXTitle and fHistYTitle
763// * Call InitHists
764//
765void MHCalibrationCam::InitLoGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
766{
767
768 if (!IsLoGain())
769 return;
770
771 if (fLoGainArray->GetSize()==0)
772 {
773 for (Int_t i=0; i<npixels; i++)
774 {
775 fLoGainArray->AddAt(new MHCalibrationPix(Form("%sLoGainPix%04d",fHistName.Data(),i),
776 Form("%s Low Gain Pixel%04d",fHistTitle.Data(),i)),i);
777
778 MHCalibrationPix &pix = (*this)(i);
779 pix.SetNbins(fNbins);
780 pix.SetFirst(fFirst);
781 pix.SetLast (fLast);
782 pix.SetProbLimit(fProbLimit);
783
784 MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
785 InitHists(pix,bad,i);
786 }
787 }
788
789 if (!IsAverageing())
790 return;
791
792 if (fAverageLoGainAreas->GetSize()==0)
793 {
794 for (Int_t j=0; j<nareas; j++)
795 {
796 fAverageLoGainAreas->AddAt(new MHCalibrationPix(Form("%sLoGainArea%d",fHistName.Data(),j),
797 Form("%s Low Gain Area Idx %d",fHistTitle.Data(),j)),j);
798
799 MHCalibrationPix &pix = GetAverageLoGainArea(j);
800
801 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
802 pix.SetFirst(fFirst);
803 pix.SetLast (fLast);
804
805 if (fGeom && fGeom->InheritsFrom("MGeomCamMagic"))
806 {
807 pix.InitBins();
808 pix.SetEventFrequency(fPulserFrequency);
809 }
810 else
811 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
812 }
813 }
814
815 if (fAverageLoGainSectors->GetSize()==0)
816 {
817 for (Int_t j=0; j<nsectors; j++)
818 {
819 fAverageLoGainSectors->AddAt(new MHCalibrationPix(Form("%sLoGainSector%02d",fHistName.Data(),j),
820 Form("%s Low Gain Sector %02d",fHistTitle.Data(),j)),j);
821 MHCalibrationPix &pix = GetAverageLoGainSector(j);
822
823 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors));
824 pix.SetFirst(fFirst);
825 pix.SetLast (fLast);
826
827 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
828 }
829 }
830}
831
832//--------------------------------------------------------------------------------
833//
834// Retrieves from MGeomCam:
835// - number of pixels
836// - number of pixel areas
837// - number of sectors
838//
839// Return kFALSE, if sizes of the TOrdCollections do not match npixels, nareas or nsectors
840//
841// Call FillHists()
842//
843Bool_t MHCalibrationCam::Fill(const MParContainer *par, const Stat_t w)
844{
845
846 if (!IsSizeCheck())
847 return FillHists(par,w);
848
849 const Int_t npixels = fGeom->GetNumPixels();
850 const Int_t nareas = fGeom->GetNumAreas();
851 const Int_t nsectors = fGeom->GetNumSectors();
852
853 //
854 // Hi-Gain OrdCollections
855 //
856 if (fHiGainArray->GetSize() != npixels)
857 {
858 *fLog << err << "ERROR - Size mismatch in number of pixels... abort." << endl;
859 return kFALSE;
860 }
861
862 if (IsLoGain())
863 {
864 if (fLoGainArray->GetSize() != npixels)
865 {
866 *fLog << err << "ERROR - Size mismatch in number of pixels... abort." << endl;
867 return kFALSE;
868 }
869 }
870
871 if (!IsAverageing())
872 return FillHists(par,w);
873
874 if (fAverageHiGainAreas->GetSize() != nareas)
875 {
876 *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
877 return kFALSE;
878 }
879
880 if (fAverageHiGainSectors->GetSize() != nsectors)
881 {
882 *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
883 return kFALSE;
884 }
885
886 if (IsLoGain())
887 {
888
889 if (fAverageLoGainAreas->GetSize() != nareas)
890 {
891 *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
892 return kFALSE;
893 }
894
895 if (fAverageLoGainSectors->GetSize() != nsectors)
896 {
897 *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
898 return kFALSE;
899 }
900 }
901
902 return FillHists(par, w);
903}
904
905// --------------------------------------------------------------------------
906//
907// 0) Ask if fHiGainArray and fLoGainArray have been initialized,
908// otherwise return kFALSE.
909// 1) FinalizeHists()
910// 2) FinalizeBadPixels()
911// 3) CalcAverageSigma()
912//
913Bool_t MHCalibrationCam::Finalize()
914{
915
916 if (fHiGainArray->GetSize() == 0 && fLoGainArray->GetSize() == 0)
917 {
918 *fLog << err << GetDescriptor()
919 << ": ERROR: Both (HiGain and LoGain) histogram arrays have not been initialized... abort." << endl;
920 return kFALSE;
921 }
922
923 for (Int_t i=0; i<fAverageHiGainAreas->GetSize(); i++)
924 {
925 TH1F *h = GetAverageHiGainArea(i).GetHGausHist();
926 switch (fColor)
927 {
928 case MCalibrationCam::kNONE:
929 break;
930 case MCalibrationCam::kBLUE:
931 h->SetTitle( Form("%s%s", h->GetTitle(),"BLUE "));
932 break;
933 case MCalibrationCam::kGREEN:
934 h->SetTitle( Form("%s%s", h->GetTitle(),"GREEN "));
935 break;
936 case MCalibrationCam::kUV:
937 h->SetTitle( Form("%s%s", h->GetTitle(),"UV "));
938 break;
939 case MCalibrationCam::kCT1:
940 h->SetTitle( Form("%s%s", h->GetTitle(),"CT1-Pulser "));
941 break;
942 }
943 }
944
945 for (Int_t i=0; i<fAverageLoGainAreas->GetSize(); i++)
946 {
947 TH1F *h = GetAverageLoGainArea(i).GetHGausHist();
948 switch (fColor)
949 {
950 case MCalibrationCam::kNONE:
951 break;
952 case MCalibrationCam::kBLUE:
953 h->SetTitle( Form("%s%s", h->GetTitle(),"BLUE "));
954 break;
955 case MCalibrationCam::kGREEN:
956 h->SetTitle( Form("%s%s", h->GetTitle(),"GREEN "));
957 break;
958 case MCalibrationCam::kUV:
959 h->SetTitle( Form("%s%s", h->GetTitle(),"UV "));
960 break;
961 case MCalibrationCam::kCT1:
962 h->SetTitle( Form("%s%s", h->GetTitle(),"CT1-Pulser "));
963 break;
964 }
965 }
966
967 if (!FinalizeHists())
968 return kFALSE;
969
970
971 FinalizeBadPixels();
972 CalcAverageSigma();
973
974 return kTRUE;
975}
976
977// -------------------------------------------------------------
978//
979// If MBadPixelsPix::IsBad():
980// - calls MHCalibrationPix::SetExcluded()
981//
982// Calls:
983// - MHGausEvents::InitBins()
984// - MHCalibrationPix::ChangeHistId(i)
985// - MHCalibrationPix::SetEventFrequency(fPulserFrequency)
986//
987void MHCalibrationCam::InitHists(MHCalibrationPix &hist, MBadPixelsPix &bad, const Int_t i)
988{
989
990 if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
991 hist.SetExcluded();
992
993 hist.InitBins();
994 hist.SetEventFrequency(fPulserFrequency);
995}
996
997// --------------------------------------------------------------------------
998//
999// Calls FitHiGainHists for every entry in:
1000// - fHiGainArray
1001// - fAverageHiGainAreas
1002// - fAverageHiGainSectors
1003//
1004void MHCalibrationCam::FitHiGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
1005 MBadPixelsPix::UncalibratedType_t fittyp,
1006 MBadPixelsPix::UncalibratedType_t osctyp)
1007{
1008
1009 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
1010 {
1011
1012 MHCalibrationPix &hist = (*this)[i];
1013
1014 if (hist.IsExcluded())
1015 continue;
1016
1017 MCalibrationPix &pix = calcam[i];
1018 MBadPixelsPix &bad = badcam[i];
1019
1020 FitHiGainHists(hist,pix,bad,fittyp,osctyp);
1021 }
1022
1023 if (!IsAverageing())
1024 return;
1025
1026 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
1027 {
1028
1029 MHCalibrationPix &hist = GetAverageHiGainArea(j);
1030 MCalibrationPix &pix = calcam.GetAverageArea(j);
1031 MBadPixelsPix &bad = calcam.GetAverageBadArea(j);
1032
1033 FitHiGainHists(hist,pix,bad,fittyp,osctyp);
1034 }
1035
1036 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
1037 {
1038 MHCalibrationPix &hist = GetAverageHiGainSector(j);
1039 MCalibrationPix &pix = calcam.GetAverageSector(j);
1040 MBadPixelsPix &bad = calcam.GetAverageBadSector(j);
1041
1042 FitHiGainHists(hist,pix,bad,fittyp,osctyp);
1043 }
1044}
1045
1046// --------------------------------------------------------------------------
1047//
1048// Calls FitLoGainHists for every entry in:
1049// - fLoGainArray
1050// - fAverageLoGainAreas
1051// - fAverageLoGainSectors
1052//
1053void MHCalibrationCam::FitLoGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
1054 MBadPixelsPix::UncalibratedType_t fittyp,
1055 MBadPixelsPix::UncalibratedType_t osctyp)
1056{
1057
1058 if (!IsLoGain())
1059 return;
1060
1061 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
1062 {
1063
1064 MHCalibrationPix &hist = (*this)(i);
1065
1066 if (hist.IsExcluded())
1067 continue;
1068
1069 MCalibrationPix &pix = calcam[i];
1070 MBadPixelsPix &bad = badcam[i];
1071
1072 FitLoGainHists(hist,pix,bad,fittyp,osctyp);
1073
1074 }
1075
1076 if (!IsAverageing())
1077 return;
1078
1079 for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
1080 {
1081
1082 MHCalibrationPix &hist = GetAverageLoGainArea(j);
1083 MCalibrationPix &pix = calcam.GetAverageArea(j);
1084 MBadPixelsPix &bad = calcam.GetAverageBadArea(j);
1085
1086 FitLoGainHists(hist,pix,bad,fittyp,osctyp);
1087 }
1088
1089 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
1090 {
1091
1092 MHCalibrationPix &hist = GetAverageLoGainSector(j);
1093 MCalibrationPix &pix = calcam.GetAverageSector(j);
1094 MBadPixelsPix &bad = calcam.GetAverageBadSector(j);
1095
1096 FitLoGainHists(hist,pix,bad,fittyp,osctyp);
1097 }
1098}
1099
1100//------------------------------------------------------------
1101//
1102// For all averaged areas, the fitted sigma is multiplied with the square root of
1103// the number involved pixels
1104//
1105void MHCalibrationCam::CalcAverageSigma()
1106{
1107
1108 if (!fCam)
1109 return;
1110
1111 if (!IsAverageing())
1112 return;
1113
1114 for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
1115 {
1116
1117 MCalibrationPix &pix = fCam->GetAverageArea(j);
1118
1119 const Float_t numsqr = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
1120 fAverageAreaSigma[j] = pix.GetSigma () * numsqr;
1121 fAverageAreaSigmaVar[j] = pix.GetSigmaErr () * pix.GetSigmaErr() * numsqr;
1122
1123 pix.SetSigma (fAverageAreaSigma[j]);
1124 pix.SetSigmaVar(fAverageAreaSigmaVar[j]);
1125
1126 fAverageAreaRelSigma [j] = fAverageAreaSigma[j] / pix.GetMean();
1127 fAverageAreaRelSigmaVar[j] = fAverageAreaSigmaVar[j] / (fAverageAreaSigma[j]*fAverageAreaSigma[j]);
1128 fAverageAreaRelSigmaVar[j] += pix.GetMeanRelVar();
1129 fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
1130 }
1131}
1132
1133// ---------------------------------------------------------------------------
1134//
1135// Returns if the histogram is empty and sets the following flag:
1136// - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
1137//
1138// Fits the histograms with a Gaussian, in case of failure
1139// calls MHCalibrationPix::RepeatFit(), in case of repeated failure
1140// calls MHCalibrationPix::BypassFit() and sets the following flags:
1141// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
1142// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
1143//
1144// Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
1145// In case no, sets the following flags:
1146// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
1147// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
1148//
1149// Retrieves the results and store them in MCalibrationPix
1150//
1151void MHCalibrationCam::FitHiGainHists(MHCalibrationPix &hist,
1152 MCalibrationPix &pix,
1153 MBadPixelsPix &bad,
1154 MBadPixelsPix::UncalibratedType_t fittyp,
1155 MBadPixelsPix::UncalibratedType_t osctyp)
1156{
1157
1158 if (hist.IsEmpty() || hist.IsOnlyOverflow() || hist.IsOnlyUnderflow())
1159 return;
1160
1161 //
1162 // 2) Fit the Hi Gain histograms with a Gaussian
1163 //
1164 if (!hist.FitGaus())
1165 //
1166 // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
1167 //
1168 if (!hist.RepeatFit())
1169 {
1170 hist.BypassFit();
1171 bad.SetUncalibrated( fittyp );
1172 }
1173
1174 //
1175 // 4) Check for oscillations
1176 //
1177 if (IsOscillations())
1178 {
1179 hist.CreateFourierSpectrum();
1180
1181 if (!hist.IsFourierSpectrumOK())
1182 bad.SetUncalibrated( osctyp );
1183 }
1184
1185 //
1186 // 5) Retrieve the results and store them in this class
1187 //
1188 pix.SetHiGainMean ( hist.GetMean() );
1189 pix.SetHiGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
1190 pix.SetHiGainRms ( hist.GetHistRms() );
1191 pix.SetHiGainSigma ( hist.GetSigma() );
1192 pix.SetHiGainSigmaVar ( hist.GetSigmaErr()* hist.GetSigmaErr() );
1193 pix.SetHiGainProb ( hist.GetProb() );
1194 pix.SetHiGainNumBlackout( hist.GetBlackout() );
1195 pix.SetHiGainNumPickup ( hist.GetPickup() );
1196
1197 if (IsDebug())
1198 {
1199 *fLog << dbginf << GetDescriptor() << ": ID " << GetName()
1200 << " HiGainSaturation: " << pix.IsHiGainSaturation()
1201 << " HiGainMean: " << hist.GetMean ()
1202 << " HiGainMeanErr: " << hist.GetMeanErr ()
1203 << " HiGainMeanSigma: " << hist.GetSigma ()
1204 << " HiGainMeanSigmaErr: " << hist.GetSigmaErr()
1205 << " HiGainMeanProb: " << hist.GetProb ()
1206 << " HiGainNumBlackout: " << hist.GetBlackout()
1207 << " HiGainNumPickup : " << hist.GetPickup ()
1208 << endl;
1209 }
1210
1211}
1212
1213
1214// ---------------------------------------------------------------------------
1215//
1216// Returns if the histogram is empty and sets the following flag:
1217// - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
1218//
1219// Fits the histograms with a Gaussian, in case of failure
1220// calls MHCalibrationPix::RepeatFit(), in case of repeated failure
1221// calls MHCalibrationPix::BypassFit() and sets the following flags:
1222// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
1223// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
1224//
1225// Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
1226// In case no, sets the following flags:
1227// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
1228// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
1229//
1230// Retrieves the results and store them in MCalibrationPix
1231//
1232void MHCalibrationCam::FitLoGainHists(MHCalibrationPix &hist,
1233 MCalibrationPix &pix,
1234 MBadPixelsPix &bad,
1235 MBadPixelsPix::UncalibratedType_t fittyp,
1236 MBadPixelsPix::UncalibratedType_t osctyp)
1237{
1238
1239 if (hist.IsEmpty() || hist.IsOnlyOverflow() || hist.IsOnlyUnderflow())
1240 return;
1241
1242
1243 //
1244 // 2) Fit the Hi Gain histograms with a Gaussian
1245 //
1246 if (!hist.FitGaus())
1247 //
1248 // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
1249 //
1250 if (!hist.RepeatFit())
1251 {
1252 hist.BypassFit();
1253 if (pix.IsHiGainSaturation())
1254 bad.SetUncalibrated( fittyp );
1255 }
1256
1257 //
1258 // 4) Check for oscillations
1259 //
1260 if (IsOscillations())
1261 {
1262 hist.CreateFourierSpectrum();
1263
1264 if (!hist.IsFourierSpectrumOK())
1265 bad.SetUncalibrated( osctyp );
1266 }
1267
1268 //
1269 // 5) Retrieve the results and store them in this class
1270 //
1271 pix.SetLoGainMean ( hist.GetMean() );
1272 pix.SetLoGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
1273 pix.SetLoGainRms ( hist.GetHistRms() );
1274 pix.SetLoGainSigma ( hist.GetSigma() );
1275 pix.SetLoGainSigmaVar ( hist.GetSigmaErr() * hist.GetSigmaErr() );
1276 pix.SetLoGainProb ( hist.GetProb() );
1277 pix.SetLoGainNumBlackout( hist.GetBlackout() );
1278 pix.SetLoGainNumPickup ( hist.GetPickup() );
1279
1280 if (IsDebug())
1281 {
1282 *fLog << dbginf << GetDescriptor() << "ID: " << hist.GetName()
1283 << " HiGainSaturation: " << pix.IsHiGainSaturation()
1284 << " LoGainMean: " << hist.GetMean ()
1285 << " LoGainMeanErr: " << hist.GetMeanErr ()
1286 << " LoGainMeanSigma: " << hist.GetSigma ()
1287 << " LoGainMeanSigmaErr: " << hist.GetSigmaErr()
1288 << " LoGainMeanProb: " << hist.GetProb ()
1289 << " LoGainNumBlackout: " << hist.GetBlackout()
1290 << " LoGainNumPickup : " << hist.GetPickup ()
1291 << endl;
1292 }
1293
1294}
1295
1296
1297
1298// -----------------------------------------------------------------------------
1299//
1300// Default draw:
1301//
1302// Displays the averaged areas, both High Gain and Low Gain
1303//
1304// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1305//
1306void MHCalibrationCam::Draw(const Option_t *opt)
1307{
1308
1309 if (!IsAverageing())
1310 return;
1311
1312 const Int_t nareas = fAverageHiGainAreas->GetSize();
1313 if (nareas == 0)
1314 return;
1315
1316 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
1317 pad->SetBorderMode(0);
1318
1319 pad->Divide(IsLoGain() ? 2 : 1,nareas);
1320
1321 for (Int_t i=0; i<nareas;i++)
1322 {
1323
1324 pad->cd(IsLoGain() ? 2*(i+1)-1 : i+1);
1325 GetAverageHiGainArea(i).Draw(opt);
1326
1327 if (!fAverageAreaSat[i])
1328 DrawAverageSigma(fAverageAreaSat[i], i,
1329 fAverageAreaSigma[i], fAverageAreaSigmaVar[i],
1330 fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
1331
1332 if (IsLoGain())
1333 {
1334 pad->cd(2*(i+1));
1335 GetAverageLoGainArea(i).Draw(opt);
1336 }
1337
1338 if (fAverageAreaSat[i])
1339 DrawAverageSigma(fAverageAreaSat[i], i,
1340 fAverageAreaSigma[i], fAverageAreaSigmaVar[i],
1341 fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
1342 }
1343
1344}
1345
1346// -----------------------------------------------------------------------------
1347//
1348// Default draw:
1349//
1350// Displays a TPaveText with the re-normalized sigmas of the average area
1351//
1352void MHCalibrationCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
1353 Float_t sigma, Float_t sigmavar,
1354 Float_t relsigma, Float_t relsigmavar) const
1355{
1356
1357 if (sigma != 0 && sigmavar >= 0 && relsigmavar >= 0.)
1358 {
1359
1360 TPad *newpad = new TPad("newpad","transparent",0,0,1,1);
1361 newpad->SetFillStyle(4000);
1362 newpad->Draw();
1363 newpad->cd();
1364
1365 TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
1366 text->SetTextSize(0.07);
1367 const TString line1 = Form("%s%s%s",inner ? "Outer" : "Inner",
1368 " Pixels ", sat ? "Low Gain" : "High Gain");
1369 TText *txt1 = text->AddText(line1.Data());
1370 const TString line2 = Form("#sigma per pix: %2.2f #pm %2.2f",sigma,TMath::Sqrt(sigmavar));
1371 TText *txt2 = text->AddText(line2.Data());
1372 const TString line3 = Form("Rel. #sigma per pix: %2.2f #pm %2.2f",relsigma,TMath::Sqrt(relsigmavar));
1373 TText *txt3 = text->AddText(line3.Data());
1374 text->Draw("");
1375
1376 text->SetBit(kCanDelete);
1377 txt1->SetBit(kCanDelete);
1378 txt2->SetBit(kCanDelete);
1379 txt3->SetBit(kCanDelete);
1380 newpad->SetBit(kCanDelete);
1381 }
1382}
1383
1384Int_t MHCalibrationCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
1385{
1386
1387 Bool_t rc = kFALSE;
1388 if (IsEnvDefined(env, prefix, "Debug", print))
1389 {
1390 SetDebug(GetEnvValue(env, prefix, "Debug", IsDebug()));
1391 rc = kTRUE;
1392 }
1393 if (IsEnvDefined(env, prefix, "LoGain", print))
1394 {
1395 SetDebug(GetEnvValue(env, prefix, "LoGain", IsLoGain()));
1396 rc = kTRUE;
1397 }
1398 if (IsEnvDefined(env, prefix, "Oscillations", print))
1399 {
1400 SetOscillations(GetEnvValue(env, prefix, "Oscillations", IsOscillations()));
1401 rc = kTRUE;
1402 }
1403 if (IsEnvDefined(env, prefix, "SizeCheck", print))
1404 {
1405 SetSizeCheck(GetEnvValue(env, prefix, "SizeCheck", IsSizeCheck()));
1406 rc = kTRUE;
1407 }
1408 if (IsEnvDefined(env, prefix, "Averageing", print))
1409 {
1410 SetAverageing(GetEnvValue(env, prefix, "Averageing", IsAverageing()));
1411 rc = kTRUE;
1412 }
1413
1414 if (IsEnvDefined(env, prefix, "Nbins", print))
1415 {
1416 SetNbins(GetEnvValue(env, prefix, "Nbins", fNbins));
1417 rc = kTRUE;
1418 }
1419 if (IsEnvDefined(env, prefix, "First", print))
1420 {
1421 SetFirst(GetEnvValue(env, prefix, "First", fFirst));
1422 rc = kTRUE;
1423 }
1424 if (IsEnvDefined(env, prefix, "Last", print))
1425 {
1426 SetLast(GetEnvValue(env, prefix, "Last", fLast));
1427 rc = kTRUE;
1428 }
1429
1430 return rc;
1431}
1432
Note: See TracBrowser for help on using the repository browser.