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

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