source: tags/Mars-V0.9.1/mhcalib/MHCalibrationRelTimeCam.cc

Last change on this file was 6919, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 24.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! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24/////////////////////////////////////////////////////////////////////////////
25//
26// MHCalibrationRelTimeCam
27//
28// Fills the extracted relative arrival times of MArrivalTimeCam into
29// the MHCalibrationPix-classes MHCalibrationPix for every:
30//
31// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray
32// or MHCalibrationCam::fHiGainArray, respectively, depending if
33// MArrivalTimePix::IsLoGainUsed() is set.
34//
35// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
36// stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
37// MHCalibrationCam::fAverageHiGainAreas
38//
39// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
40// stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors
41// and MHCalibrationCam::fAverageHiGainSectors
42//
43// Every relative time is calculated as the difference between the individual
44// pixel arrival time and the one of pixel 1 (hardware number: 2).
45// The relative times are filled into a histogram and an array, in order to perform
46// a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an
47// event-by-event basis and written into the corresponding average pixels.
48//
49// The histograms are fitted to a Gaussian, mean and sigma with its errors
50// and the fit probability are extracted. If none of these values are NaN's and
51// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
52// the fit is declared valid.
53// Otherwise, the fit is repeated within ranges of the previous mean
54// +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
55// In case this does not make the fit valid, the histogram means and RMS's are
56// taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
57// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeNotFitted ) and
58// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
59//
60// Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas
61// from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup)
62//
63// The class also fills arrays with the signal vs. event number, creates a fourier
64// spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the
65// projected fourier components follow an exponential distribution.
66// In case that the probability of the exponential fit is less than
67// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
68// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeOscillating ) and
69// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
70//
71// This same procedure is performed for the average pixels.
72//
73// The following results are written into MCalibrationRelTimeCam:
74//
75// - MCalibrationPix::SetMean()
76// - MCalibrationPix::SetMeanErr()
77// - MCalibrationPix::SetSigma()
78// - MCalibrationPix::SetSigmaErr()
79// - MCalibrationPix::SetProb()
80// - MCalibrationPix::SetNumPickup()
81//
82// For all averaged areas, the fitted sigma is multiplied with the square root of
83// the number involved pixels in order to be able to compare it to the average of
84// sigmas in the camera.
85//
86/////////////////////////////////////////////////////////////////////////////
87#include "MHCalibrationRelTimeCam.h"
88#include "MHCalibrationPix.h"
89
90#include "MLog.h"
91#include "MLogManip.h"
92
93#include "MParList.h"
94
95#include "MCalibrationIntensityRelTimeCam.h"
96
97#include "MCalibrationRelTimeCam.h"
98#include "MCalibrationRelTimePix.h"
99#include "MCalibrationPix.h"
100
101#include "MArrivalTimeCam.h"
102#include "MArrivalTimePix.h"
103
104#include "MGeomCam.h"
105#include "MGeomPix.h"
106
107#include "MBadPixelsIntensityCam.h"
108#include "MBadPixelsCam.h"
109#include "MBadPixelsPix.h"
110
111#include <TOrdCollection.h>
112#include <TPad.h>
113#include <TVirtualPad.h>
114#include <TCanvas.h>
115#include <TStyle.h>
116#include <TF1.h>
117#include <TLine.h>
118#include <TLatex.h>
119#include <TLegend.h>
120#include <TGraph.h>
121#include <TEnv.h>
122
123ClassImp(MHCalibrationRelTimeCam);
124
125using namespace std;
126
127const Float_t MHCalibrationRelTimeCam::fgNumHiGainSaturationLimit = 0.25;
128const UInt_t MHCalibrationRelTimeCam::fgReferencePixel = 1;
129const Int_t MHCalibrationRelTimeCam::fgNbins = 300;
130const Axis_t MHCalibrationRelTimeCam::fgFirst = -4.975;
131const Axis_t MHCalibrationRelTimeCam::fgLast = 10.025;
132const Float_t MHCalibrationRelTimeCam::fgProbLimit = 0.0;
133const TString MHCalibrationRelTimeCam::gsHistName = "RelTime";
134const TString MHCalibrationRelTimeCam::gsHistTitle = "Arr. Times";
135const TString MHCalibrationRelTimeCam::gsHistXTitle = "Arr. Time [FADC slices]";
136const TString MHCalibrationRelTimeCam::gsHistYTitle = "Nr. events";
137const TString MHCalibrationRelTimeCam::fgReferenceFile = "mjobs/calibrationref.rc";
138// --------------------------------------------------------------------------
139//
140// Default Constructor.
141//
142// Sets:
143// - fReferencePixel to fgReferencePixel
144// - fNbins to fgNbins
145// - fFirst to fgFirst
146// - fLast to fgLast
147//
148// - fHistName to gsHistName
149// - fHistTitle to gsHistTitle
150// - fHistXTitle to gsHistXTitle
151// - fHistYTitle to gsHistYTitle
152//
153MHCalibrationRelTimeCam::MHCalibrationRelTimeCam(const char *name, const char *title)
154{
155
156 fName = name ? name : "MHCalibrationRelTimeCam";
157 fTitle = title ? title : "Histogram class for the relative time calibration of the camera";
158
159 SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
160
161 SetReferencePixel();
162
163 SetNbins(fgNbins);
164 SetFirst(fgFirst);
165 SetLast (fgLast );
166
167 SetProbLimit(fgProbLimit);
168
169 SetHistName (gsHistName .Data());
170 SetHistTitle (gsHistTitle .Data());
171 SetHistXTitle(gsHistXTitle.Data());
172 SetHistYTitle(gsHistYTitle.Data());
173
174 SetReferenceFile();
175
176 fInnerRefTime = 2.95;
177 fOuterRefTime = 3.6;
178}
179
180// --------------------------------------------------------------------------
181//
182// Creates new MHCalibrationRelTimeCam only with the averaged areas:
183// the rest has to be retrieved directly, e.g. via:
184// MHCalibrationRelTimeCam *cam = MParList::FindObject("MHCalibrationRelTimeCam");
185// - cam->GetAverageSector(5).DrawClone();
186// - (*cam)[100].DrawClone()
187//
188TObject *MHCalibrationRelTimeCam::Clone(const char *) const
189{
190
191 MHCalibrationRelTimeCam *cam = new MHCalibrationRelTimeCam();
192
193 //
194 // Copy the data members
195 //
196 cam->fColor = fColor;
197 cam->fRunNumbers = fRunNumbers;
198 cam->fPulserFrequency = fPulserFrequency;
199 cam->fFlags = fFlags;
200 cam->fNbins = fNbins;
201 cam->fFirst = fFirst;
202 cam->fLast = fLast;
203
204 cam->fReferenceFile = fReferenceFile;
205 cam->fInnerRefTime = fInnerRefTime;
206 cam->fOuterRefTime = fOuterRefTime;
207
208 //
209 // Copy the MArrays
210 //
211 cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
212 cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
213 cam->fAverageAreaSat = fAverageAreaSat;
214 cam->fAverageAreaSigma = fAverageAreaSigma;
215 cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
216 cam->fAverageAreaNum = fAverageAreaNum;
217 cam->fAverageSectorNum = fAverageSectorNum;
218
219 if (!IsAverageing())
220 return cam;
221
222 const Int_t navhi = fAverageHiGainAreas->GetSize();
223
224 for (int i=0; i<navhi; i++)
225 cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
226
227 if (IsLoGain())
228 {
229
230 const Int_t navlo = fAverageLoGainAreas->GetSize();
231 for (int i=0; i<navlo; i++)
232 cam->fAverageLoGainAreas->AddAt(GetAverageLoGainArea(i).Clone(),i);
233
234 }
235
236 return cam;
237}
238
239// --------------------------------------------------------------------------
240//
241// Gets or creates the pointers to:
242// - MCalibrationRelTimeCam
243//
244// Searches pointer to:
245// - MArrivalTimeCam
246//
247// Calls:
248// - MHCalibrationCam::InitHiGainArrays()
249// - MHCalibrationCam::InitLoGainArrays()
250//
251// Sets:
252// - fSumareahi to nareas
253// - fSumarealo to nareas
254// - fSumsectorhi to nareas
255// - fSumsectorlo to nareas
256// - fNumareahi to nareas
257// - fNumarealo to nareas
258// - fNumsectorhi to nareas
259// - fNumsectorlo to nareas
260//
261Bool_t MHCalibrationRelTimeCam::ReInitHists(MParList *pList)
262{
263
264 if (!InitCams(pList,"RelTime"))
265 return kFALSE;
266
267 MArrivalTimeCam *signal = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
268 if (!signal)
269 {
270 *fLog << err << "MArrivalTimeCam not found... abort." << endl;
271 return kFALSE;
272 }
273
274 const Int_t npixels = fGeom->GetNumPixels();
275 const Int_t nsectors = fGeom->GetNumSectors();
276 const Int_t nareas = fGeom->GetNumAreas();
277
278 InitHiGainArrays(npixels,nareas,nsectors);
279 InitLoGainArrays(npixels,nareas,nsectors);
280
281 fSumareahi .Set(nareas);
282 fSumarealo .Set(nareas);
283 fSumsectorhi.Set(nsectors);
284 fSumsectorlo.Set(nsectors);
285 fNumareahi .Set(nareas);
286 fNumarealo .Set(nareas);
287 fNumsectorhi.Set(nsectors);
288 fNumsectorlo.Set(nsectors);
289
290 return kTRUE;
291}
292
293
294// -------------------------------------------------------------------------------
295//
296// Retrieves pointer to MArrivalTimeCam:
297//
298// Retrieves from MGeomCam:
299// - number of pixels
300// - number of pixel areas
301// - number of sectors
302//
303// Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
304// depending on MArrivalTimePix::IsLoGainUsed(), with:
305// - MArrivalTimePix::GetArrivalTime(pixid) - MArrivalTimePix::GetArrivalTime(1);
306// (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
307//
308Bool_t MHCalibrationRelTimeCam::FillHists(const MParContainer *par, const Stat_t w)
309{
310
311 MArrivalTimeCam *arrtime = (MArrivalTimeCam*)par;
312 if (!arrtime)
313 {
314 gLog << err << "No argument in MArrivalTime::Fill... abort." << endl;
315 return kFALSE;
316 }
317
318 const Int_t npixels = fGeom->GetNumPixels();
319 const Int_t nareas = fGeom->GetNumAreas();
320 const Int_t nsectors = fGeom->GetNumSectors();
321
322 fSumareahi .Reset();
323 fSumarealo .Reset();
324 fSumsectorhi.Reset();
325 fSumsectorlo.Reset();
326 fNumareahi .Reset();
327 fNumarealo .Reset();
328 fNumsectorhi.Reset();
329 fNumsectorlo.Reset();
330
331 const MArrivalTimePix &refpix = (*arrtime)[fReferencePixel];
332 const Float_t reftime = refpix.IsLoGainUsed()
333 ? refpix.GetArrivalTimeLoGain() : refpix.GetArrivalTimeHiGain();
334
335 for (Int_t i=0; i<npixels; i++)
336 {
337
338 MHCalibrationPix &histhi = (*this)[i];
339
340 if (histhi.IsExcluded())
341 continue;
342
343 const MArrivalTimePix &pix = (*arrtime)[i];
344 const Int_t aidx = (*fGeom)[i].GetAidx();
345 const Int_t sector = (*fGeom)[i].GetSector();
346
347 if (pix.IsLoGainUsed() && IsLoGain())
348 {
349 const Float_t time = pix.GetArrivalTimeLoGain();
350 histhi.AddSaturated(1);
351
352 MHCalibrationPix &histlo = (*this)(i);
353 if (IsOscillations())
354 histlo.FillHistAndArray(time-reftime);
355 else
356 histlo.FillHist(time-reftime);
357
358 fSumarealo [aidx] += time;
359 fNumarealo [aidx] ++;
360 fSumsectorlo[sector] += time;
361 fNumsectorlo[sector] ++;
362 }
363 else
364 {
365 const Float_t time = pix.GetArrivalTimeHiGain();
366
367 if (IsOscillations())
368 histhi.FillHistAndArray(time-reftime);
369 else
370 histhi.FillHist(time-reftime);
371
372 fSumareahi [aidx] += time;
373 fNumareahi [aidx] ++;
374 fSumsectorhi[sector] += time;
375 fNumsectorhi[sector] ++;
376 }
377 }
378
379 for (Int_t j=0; j<nareas; j++)
380 {
381 MHCalibrationPix &histhi = GetAverageHiGainArea(j);
382 if (IsOscillations())
383 histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
384 else
385 histhi.FillHist(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
386
387 if (IsLoGain())
388 {
389 MHCalibrationPix &histlo = GetAverageLoGainArea(j);
390 if (IsOscillations())
391 histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
392 else
393 histlo.FillHist(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
394 }
395 }
396
397 for (Int_t j=0; j<nsectors; j++)
398 {
399 MHCalibrationPix &histhi = GetAverageHiGainSector(j);
400 if (IsOscillations())
401 histhi.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
402 else
403 histhi.FillHist(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
404
405 if (IsLoGain())
406 {
407 MHCalibrationPix &histlo = GetAverageLoGainSector(j);
408 if (IsOscillations())
409 histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
410 else
411 histlo.FillHist(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
412 }
413 }
414
415 return kTRUE;
416}
417
418// --------------------------------------------------------------------------
419//
420// Calls:
421// - MHCalibrationCam::FitHiGainArrays() with flags:
422// MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
423// - MHCalibrationCam::FitLoGainArrays() with flags:
424// MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
425//
426Bool_t MHCalibrationRelTimeCam::FinalizeHists()
427{
428
429 *fLog << endl;
430
431 MCalibrationCam *relcam = fIntensCam ? fIntensCam->GetCam() : fCam;
432 MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
433
434 const Int_t nareas = fAverageHiGainAreas->GetSize();
435 const Int_t nsectors = fAverageHiGainSectors->GetSize();
436
437 TArrayI satarea(nareas);
438 TArrayI satsect(nsectors);
439 fNumareahi .Reset();
440 fNumsectorhi.Reset();
441
442 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
443 {
444
445 MHCalibrationPix &histhi = (*this)[i];
446
447 if (histhi.IsExcluded())
448 continue;
449
450 const Int_t aidx = (*fGeom)[i].GetAidx();
451 const Int_t sector = (*fGeom)[i].GetSector();
452
453 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*relcam)[i] ;
454
455 fNumareahi[aidx]++;
456 fNumsectorhi[sector]++;
457 //
458 // Check saturation
459 //
460 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
461 {
462 pix.SetHiGainSaturation();
463 histhi.SetExcluded();
464 satarea[aidx]++;
465 satsect[sector]++;
466 }
467 else
468 if (IsLoGain())
469 (*this)(i).SetExcluded();
470
471 //
472 // Check histogram overflow
473 //
474 CheckOverflow(histhi);
475 if (IsLoGain())
476 CheckOverflow((*this)(i));
477
478 }
479
480 for (Int_t j=0; j<nareas; j++)
481 {
482
483 MHCalibrationPix &histhi = GetAverageHiGainArea(j);
484 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)relcam->GetAverageArea(j);
485
486 if (satarea[j] > 0.5*fNumareahi[j])
487 {
488 pix.SetHiGainSaturation();
489 histhi.SetExcluded();
490 }
491 else
492 if (IsLoGain())
493 GetAverageLoGainArea(j).SetExcluded();
494
495 //
496 // Check histogram overflow
497 //
498 CheckOverflow(histhi);
499 if (IsLoGain())
500 CheckOverflow(GetAverageLoGainArea(j));
501 }
502
503 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
504 {
505
506 MHCalibrationPix &histhi = GetAverageHiGainSector(j);
507 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)relcam->GetAverageSector(j) ;
508
509 if (satsect[j] > 0.5*fNumsectorhi[j])
510 {
511 pix.SetHiGainSaturation();
512 histhi.SetExcluded();
513 }
514 else
515 if (IsLoGain())
516 GetAverageLoGainSector(j).SetExcluded();
517
518 //
519 // Check histogram overflow
520 //
521 CheckOverflow(histhi);
522 if (IsLoGain())
523 CheckOverflow(GetAverageLoGainSector(j));
524 }
525
526 FitHiGainArrays(*relcam,*badcam,
527 MBadPixelsPix::kRelTimeNotFitted,
528 MBadPixelsPix::kRelTimeOscillating);
529
530 if (IsLoGain())
531 FitLoGainArrays(*relcam,*badcam,
532 MBadPixelsPix::kRelTimeNotFitted,
533 MBadPixelsPix::kRelTimeOscillating);
534
535 return kTRUE;
536}
537
538// --------------------------------------------------------------------------
539//
540// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
541// - MBadPixelsPix::kRelTimeNotFitted
542// - MBadPixelsPix::kRelTimeOscillating
543//
544void MHCalibrationRelTimeCam::FinalizeBadPixels()
545{
546
547 MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
548
549 for (Int_t i=0; i<badcam->GetSize(); i++)
550 {
551 MBadPixelsPix &bad = (*badcam)[i];
552
553 if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted ))
554 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
555
556 if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
557 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
558
559 }
560}
561
562// --------------------------------------------------------------------------
563//
564// The types are as follows:
565//
566// Fitted values:
567// ==============
568//
569// 0: Fitted Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMean()
570// 1: Error Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMeanErr()
571// 2: Sigma fitted Relative Arrival Time in FADC slices (MHGausEvents::GetSigma()
572// 3: Error Sigma Relative Arrival Time in FADC slices (MHGausEvents::GetSigmaErr()
573//
574// Useful variables derived from the fit results:
575// =============================================
576//
577// 4: Returned probability of Gauss fit (calls: MHGausEvents::GetProb())
578//
579// Localized defects:
580// ==================
581//
582// 5: Gaus fit not OK (calls: MHGausEvents::IsGausFitOK())
583// 6: Fourier spectrum not OK (calls: MHGausEvents::IsFourierSpectrumOK())
584//
585Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
586{
587
588 if (fHiGainArray->GetSize() <= idx)
589 return kFALSE;
590
591 const MHCalibrationPix &pix = (*this)[idx];
592
593 switch (type)
594 {
595 case 0:
596 val = pix.GetMean();
597 break;
598 case 1:
599 val = pix.GetMeanErr();
600 break;
601 case 2:
602 val = pix.GetSigma();
603 break;
604 case 3:
605 val = pix.GetSigmaErr();
606 break;
607 case 4:
608 val = pix.GetProb();
609 break;
610 case 5:
611 if (!pix.IsGausFitOK())
612 val = 1.;
613 break;
614 case 6:
615 if (!pix.IsFourierSpectrumOK())
616 val = 1.;
617 break;
618 default:
619 return kFALSE;
620 }
621 return kTRUE;
622}
623
624// --------------------------------------------------------------------------
625//
626// Calls MHCalibrationPix::DrawClone() for pixel idx
627//
628void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
629{
630 (*this)[idx].DrawClone();
631}
632
633// -----------------------------------------------------------------------------
634//
635// Default draw:
636//
637// Displays the averaged areas, both High Gain and Low Gain
638//
639// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
640//
641void MHCalibrationRelTimeCam::Draw(const Option_t *opt)
642{
643
644 const Int_t nareas = fAverageHiGainAreas->GetSize();
645 if (nareas == 0)
646 return;
647
648 TString option(opt);
649 option.ToLower();
650
651 if (!option.Contains("datacheck"))
652 {
653 MHCalibrationCam::Draw(opt);
654 return;
655 }
656
657 //
658 // From here on , the datacheck - Draw
659 //
660 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
661 pad->SetBorderMode(0);
662 pad->Divide(1,nareas);
663
664 //
665 // Loop over inner and outer pixels
666 //
667 for (Int_t i=0; i<nareas;i++)
668 {
669
670 pad->cd(i+1);
671
672 MHCalibrationPix &hipix = GetAverageHiGainArea(i);
673 //
674 // Ask for Hi-Gain saturation
675 //
676 if (hipix.IsExcluded() && IsLoGain())
677 {
678 MHCalibrationPix &lopix = GetAverageLoGainArea(i);
679 DrawDataCheckPixel(lopix,i ? fOuterRefTime+1.5 : fInnerRefTime+1.5);
680 }
681 else
682 DrawDataCheckPixel(hipix,i ? fOuterRefTime : fInnerRefTime);
683 }
684}
685
686void MHCalibrationRelTimeCam::CheckOverflow( MHCalibrationPix &pix )
687{
688
689 if (pix.IsExcluded())
690 return;
691
692 TH1F *hist = pix.GetHGausHist();
693
694 Stat_t overflow = hist->GetBinContent(hist->GetNbinsX()+1);
695 if (overflow > fOverflowLimit*hist->GetEntries())
696 {
697 *fLog << warn << "HiGain Hist-overflow " << overflow
698 << " times in " << pix.GetName() << " (w/o saturation!) " << endl;
699 }
700
701 overflow = hist->GetBinContent(0);
702 if (overflow > fOverflowLimit*hist->GetEntries())
703 {
704 *fLog << warn << "HiGain Hist-underflow " << overflow
705 << " times in " << pix.GetName() << " (w/o saturation!) " << endl;
706 }
707}
708
709
710// -----------------------------------------------------------------------------
711//
712// Draw the average pixel for the datacheck:
713//
714// Displays the averaged areas, both High Gain and Low Gain
715//
716// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
717//
718void MHCalibrationRelTimeCam::DrawDataCheckPixel(MHCalibrationPix &pix, const Float_t refline)
719{
720
721 TVirtualPad *newpad = gPad;
722 newpad->Divide(1,2);
723 newpad->cd(1);
724
725 gPad->SetTicks();
726 if (!pix.IsEmpty() && !pix.IsOnlyOverflow() && !pix.IsOnlyUnderflow())
727 gPad->SetLogy();
728
729 TH1F *hist = pix.GetHGausHist();
730
731 TH1F *null = new TH1F("Null",hist->GetTitle(),100,0.,pix.GetLast());
732
733 null->SetMaximum(1.1*hist->GetMaximum());
734 null->SetDirectory(NULL);
735 null->SetBit(kCanDelete);
736 null->SetStats(kFALSE);
737 //
738 // set the labels bigger
739 //
740 TAxis *xaxe = null->GetXaxis();
741 TAxis *yaxe = null->GetYaxis();
742 xaxe->CenterTitle();
743 yaxe->CenterTitle();
744 xaxe->SetTitleSize(0.07);
745 yaxe->SetTitleSize(0.07);
746 xaxe->SetTitleOffset(0.65);
747 yaxe->SetTitleOffset(0.55);
748 xaxe->SetLabelSize(0.06);
749 yaxe->SetLabelSize(0.06);
750 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
751 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
752
753 null->Draw();
754 hist->Draw("same");
755
756 gStyle->SetOptFit();
757
758 TF1 *fit = pix.GetFGausFit();
759
760 if (fit)
761 {
762 switch ( fColor )
763 {
764 case MCalibrationCam::kGREEN:
765 fit->SetLineColor(kGreen);
766 break;
767 case MCalibrationCam::kBLUE:
768 fit->SetLineColor(kBlue);
769 break;
770 case MCalibrationCam::kUV:
771 fit->SetLineColor(106);
772 break;
773 case MCalibrationCam::kCT1:
774 fit->SetLineColor(006);
775 break;
776 default:
777 fit->SetLineColor(kRed);
778 }
779 fit->Draw("same");
780 }
781
782 DisplayRefLines(null,refline);
783
784 newpad->cd(2);
785 gPad->SetTicks();
786
787 TH1F *null2 = new TH1F("Null2",hist->GetTitle(),100,0.,pix.GetEvents()->GetSize()/pix.GetEventFrequency());
788
789 null2->SetMinimum(pix.GetMean()-10.*pix.GetSigma());
790 null2->SetMaximum(pix.GetMean()+10.*pix.GetSigma());
791 null2->SetDirectory(NULL);
792 null2->SetBit(kCanDelete);
793 null2->SetStats(kFALSE);
794 //
795 // set the labels bigger
796 //
797 TAxis *xaxe2 = null2->GetXaxis();
798 TAxis *yaxe2 = null2->GetYaxis();
799 xaxe2->CenterTitle();
800 yaxe2->CenterTitle();
801 xaxe2->SetTitleSize(0.07);
802 yaxe2->SetTitleSize(0.07);
803 xaxe2->SetTitleOffset(0.65);
804 yaxe2->SetTitleOffset(0.55);
805 xaxe2->SetLabelSize(0.06);
806 yaxe2->SetLabelSize(0.06);
807
808 pix.CreateGraphEvents();
809 TGraph *gr = pix.GetGraphEvents();
810
811 xaxe2->SetTitle(gr->GetXaxis()->GetTitle());
812 yaxe2->SetTitle(gr->GetYaxis()->GetTitle());
813
814 null2->Draw();
815
816 pix.DrawEvents("same");
817
818 return;
819}
820
821void MHCalibrationRelTimeCam::DisplayRefLines(const TH1F *hist, const Float_t refline) const
822{
823
824 TGraph *gr = new TGraph(2);
825 gr->SetPoint(0,refline,0.);
826 gr->SetPoint(1,refline,hist->GetMaximum());
827 gr->SetBit(kCanDelete);
828 gr->SetLineColor(kGreen);
829 gr->SetLineStyle(2);
830 gr->SetLineWidth(3);
831 gr->Draw("L");
832
833 TLegend *leg = new TLegend(0.75,0.7,0.99,0.99);
834 leg->SetBit(kCanDelete);
835 leg->AddEntry(gr,"Trigger Calibration","l");
836 leg->Draw();
837}
838
839Int_t MHCalibrationRelTimeCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
840{
841
842 Bool_t rc = kFALSE;
843
844 if (IsEnvDefined(env, prefix, "ReferenceFile", print))
845 {
846 SetReferenceFile(GetEnvValue(env,prefix,"ReferenceFile",fReferenceFile.Data()));
847 rc = kTRUE;
848 }
849
850 TEnv refenv(fReferenceFile);
851
852 fInnerRefTime = refenv.GetValue("InnerRefTime",fInnerRefTime);
853 fOuterRefTime = refenv.GetValue("OuterRefTime",fOuterRefTime);
854
855 return MHCalibrationCam::ReadEnv(env,prefix,print) ? kTRUE : rc;
856
857}
Note: See TracBrowser for help on using the repository browser.