source: trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.cc@ 6194

Last change on this file since 6194 was 6178, checked in by gaug, 20 years ago
*** empty log message ***
File size: 24.3 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.000001;
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 histlo.FillHistAndArray(time-reftime);
354
355 fSumarealo [aidx] += time;
356 fNumarealo [aidx] ++;
357 fSumsectorlo[sector] += time;
358 fNumsectorlo[sector] ++;
359 }
360 else
361 {
362 const Float_t time = pix.GetArrivalTimeHiGain();
363
364 histhi.FillHistAndArray(time-reftime) ;
365 fSumareahi [aidx] += time;
366 fNumareahi [aidx] ++;
367 fSumsectorhi[sector] += time;
368 fNumsectorhi[sector] ++;
369 }
370 }
371
372 for (Int_t j=0; j<nareas; j++)
373 {
374 MHCalibrationPix &histhi = GetAverageHiGainArea(j);
375 histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
376
377 if (IsLoGain())
378 {
379 MHCalibrationPix &histlo = GetAverageLoGainArea(j);
380 histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
381 }
382 }
383
384 for (Int_t j=0; j<nsectors; j++)
385 {
386 MHCalibrationPix &histhi = GetAverageHiGainSector(j);
387 histhi.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
388
389 if (IsLoGain())
390 {
391 MHCalibrationPix &histlo = GetAverageLoGainSector(j);
392 histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
393 }
394 }
395
396 return kTRUE;
397}
398
399// --------------------------------------------------------------------------
400//
401// Calls:
402// - MHCalibrationCam::FitHiGainArrays() with flags:
403// MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
404// - MHCalibrationCam::FitLoGainArrays() with flags:
405// MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
406//
407Bool_t MHCalibrationRelTimeCam::FinalizeHists()
408{
409
410 *fLog << endl;
411
412 MCalibrationCam *relcam = fIntensCam ? fIntensCam->GetCam() : fCam;
413 MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
414
415 const Int_t nareas = fAverageHiGainAreas->GetSize();
416 const Int_t nsectors = fAverageHiGainSectors->GetSize();
417
418 TArrayI satarea(nareas);
419 TArrayI satsect(nsectors);
420 fNumareahi .Reset();
421 fNumsectorhi.Reset();
422
423 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
424 {
425
426 MHCalibrationPix &histhi = (*this)[i];
427
428 if (histhi.IsExcluded())
429 continue;
430
431 const Int_t aidx = (*fGeom)[i].GetAidx();
432 const Int_t sector = (*fGeom)[i].GetSector();
433
434 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*relcam)[i] ;
435
436 fNumareahi[aidx]++;
437 fNumsectorhi[sector]++;
438 //
439 // Check saturation
440 //
441 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
442 {
443 pix.SetHiGainSaturation();
444 histhi.SetExcluded();
445 satarea[aidx]++;
446 satsect[sector]++;
447 }
448 else
449 if (IsLoGain())
450 (*this)(i).SetExcluded();
451
452 //
453 // Check histogram overflow
454 //
455 CheckOverflow(histhi);
456 if (IsLoGain())
457 CheckOverflow((*this)(i));
458
459 }
460
461 for (Int_t j=0; j<nareas; j++)
462 {
463
464 MHCalibrationPix &histhi = GetAverageHiGainArea(j);
465 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)relcam->GetAverageArea(j);
466
467 if (satarea[j] > 0.5*fNumareahi[j])
468 {
469 pix.SetHiGainSaturation();
470 histhi.SetExcluded();
471 }
472 else
473 if (IsLoGain())
474 GetAverageLoGainArea(j).SetExcluded();
475
476 //
477 // Check histogram overflow
478 //
479 CheckOverflow(histhi);
480 if (IsLoGain())
481 CheckOverflow(GetAverageLoGainArea(j));
482 }
483
484 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
485 {
486
487 MHCalibrationPix &histhi = GetAverageHiGainSector(j);
488 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)relcam->GetAverageSector(j) ;
489
490 if (satsect[j] > 0.5*fNumsectorhi[j])
491 {
492 pix.SetHiGainSaturation();
493 histhi.SetExcluded();
494 }
495 else
496 if (IsLoGain())
497 GetAverageLoGainSector(j).SetExcluded();
498
499 //
500 // Check histogram overflow
501 //
502 CheckOverflow(histhi);
503 if (IsLoGain())
504 CheckOverflow(GetAverageLoGainSector(j));
505 }
506
507 FitHiGainArrays(*relcam,*badcam,
508 MBadPixelsPix::kRelTimeNotFitted,
509 MBadPixelsPix::kRelTimeOscillating);
510
511 if (IsLoGain())
512 FitLoGainArrays(*relcam,*badcam,
513 MBadPixelsPix::kRelTimeNotFitted,
514 MBadPixelsPix::kRelTimeOscillating);
515
516 return kTRUE;
517}
518
519// --------------------------------------------------------------------------
520//
521// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
522// - MBadPixelsPix::kRelTimeNotFitted
523// - MBadPixelsPix::kRelTimeOscillating
524//
525void MHCalibrationRelTimeCam::FinalizeBadPixels()
526{
527
528 MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
529
530 for (Int_t i=0; i<badcam->GetSize(); i++)
531 {
532 MBadPixelsPix &bad = (*badcam)[i];
533
534 if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted ))
535 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
536
537 if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
538 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
539
540 }
541}
542
543// --------------------------------------------------------------------------
544//
545// The types are as follows:
546//
547// Fitted values:
548// ==============
549//
550// 0: Fitted Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMean()
551// 1: Error Mean Relative Arrival Time in FADC slices (MHGausEvents::GetMeanErr()
552// 2: Sigma fitted Relative Arrival Time in FADC slices (MHGausEvents::GetSigma()
553// 3: Error Sigma Relative Arrival Time in FADC slices (MHGausEvents::GetSigmaErr()
554//
555// Useful variables derived from the fit results:
556// =============================================
557//
558// 4: Returned probability of Gauss fit (calls: MHGausEvents::GetProb())
559//
560// Localized defects:
561// ==================
562//
563// 5: Gaus fit not OK (calls: MHGausEvents::IsGausFitOK())
564// 6: Fourier spectrum not OK (calls: MHGausEvents::IsFourierSpectrumOK())
565//
566Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
567{
568
569 if (fHiGainArray->GetSize() <= idx)
570 return kFALSE;
571
572 const MHCalibrationPix &pix = (*this)[idx];
573
574 switch (type)
575 {
576 case 0:
577 val = pix.GetMean();
578 break;
579 case 1:
580 val = pix.GetMeanErr();
581 break;
582 case 2:
583 val = pix.GetSigma();
584 break;
585 case 3:
586 val = pix.GetSigmaErr();
587 break;
588 case 4:
589 val = pix.GetProb();
590 break;
591 case 5:
592 if (!pix.IsGausFitOK())
593 val = 1.;
594 break;
595 case 6:
596 if (!pix.IsFourierSpectrumOK())
597 val = 1.;
598 break;
599 default:
600 return kFALSE;
601 }
602 return kTRUE;
603}
604
605// --------------------------------------------------------------------------
606//
607// Calls MHCalibrationPix::DrawClone() for pixel idx
608//
609void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
610{
611 (*this)[idx].DrawClone();
612}
613
614// -----------------------------------------------------------------------------
615//
616// Default draw:
617//
618// Displays the averaged areas, both High Gain and Low Gain
619//
620// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
621//
622void MHCalibrationRelTimeCam::Draw(const Option_t *opt)
623{
624
625 const Int_t nareas = fAverageHiGainAreas->GetSize();
626 if (nareas == 0)
627 return;
628
629 TString option(opt);
630 option.ToLower();
631
632 if (!option.Contains("datacheck"))
633 {
634 MHCalibrationCam::Draw(opt);
635 return;
636 }
637
638 //
639 // From here on , the datacheck - Draw
640 //
641 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
642 pad->SetBorderMode(0);
643 pad->Divide(1,nareas);
644
645 //
646 // Loop over inner and outer pixels
647 //
648 for (Int_t i=0; i<nareas;i++)
649 {
650
651 pad->cd(i+1);
652
653 MHCalibrationPix &hipix = GetAverageHiGainArea(i);
654 //
655 // Ask for Hi-Gain saturation
656 //
657 if (hipix.IsExcluded() && IsLoGain())
658 {
659 MHCalibrationPix &lopix = GetAverageLoGainArea(i);
660 DrawDataCheckPixel(lopix,i ? fOuterRefTime+1.5 : fInnerRefTime+1.5);
661 }
662 else
663 DrawDataCheckPixel(hipix,i ? fOuterRefTime : fInnerRefTime);
664 }
665}
666
667void MHCalibrationRelTimeCam::CheckOverflow( MHCalibrationPix &pix )
668{
669
670 if (pix.IsExcluded())
671 return;
672
673 TH1F *hist = pix.GetHGausHist();
674
675 Stat_t overflow = hist->GetBinContent(hist->GetNbinsX()+1);
676 if (overflow > fOverflowLimit*hist->GetEntries())
677 {
678 *fLog << warn << "HiGain Hist-overflow " << overflow
679 << " times in " << pix.GetName() << " (w/o saturation!) " << endl;
680 }
681
682 overflow = hist->GetBinContent(0);
683 if (overflow > fOverflowLimit*hist->GetEntries())
684 {
685 *fLog << warn << "HiGain Hist-underflow " << overflow
686 << " times in " << pix.GetName() << " (w/o saturation!) " << endl;
687 }
688}
689
690
691// -----------------------------------------------------------------------------
692//
693// Draw the average pixel for the datacheck:
694//
695// Displays the averaged areas, both High Gain and Low Gain
696//
697// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
698//
699void MHCalibrationRelTimeCam::DrawDataCheckPixel(MHCalibrationPix &pix, const Float_t refline)
700{
701
702 TVirtualPad *newpad = gPad;
703 newpad->Divide(1,2);
704 newpad->cd(1);
705
706 gPad->SetTicks();
707 if (!pix.IsEmpty() && !pix.IsOnlyOverflow() && !pix.IsOnlyUnderflow())
708 gPad->SetLogy();
709
710 TH1F *hist = pix.GetHGausHist();
711
712 TH1F *null = new TH1F("Null",hist->GetTitle(),100,0.,pix.GetLast());
713
714 null->SetMaximum(1.1*hist->GetMaximum());
715 null->SetDirectory(NULL);
716 null->SetBit(kCanDelete);
717 null->SetStats(kFALSE);
718 //
719 // set the labels bigger
720 //
721 TAxis *xaxe = null->GetXaxis();
722 TAxis *yaxe = null->GetYaxis();
723 xaxe->CenterTitle();
724 yaxe->CenterTitle();
725 xaxe->SetTitleSize(0.07);
726 yaxe->SetTitleSize(0.07);
727 xaxe->SetTitleOffset(0.65);
728 yaxe->SetTitleOffset(0.55);
729 xaxe->SetLabelSize(0.06);
730 yaxe->SetLabelSize(0.06);
731 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
732 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
733
734 null->Draw();
735 hist->Draw("same");
736
737 gStyle->SetOptFit();
738
739 TF1 *fit = pix.GetFGausFit();
740
741 if (fit)
742 {
743 switch ( fColor )
744 {
745 case MCalibrationCam::kGREEN:
746 fit->SetLineColor(kGreen);
747 break;
748 case MCalibrationCam::kBLUE:
749 fit->SetLineColor(kBlue);
750 break;
751 case MCalibrationCam::kUV:
752 fit->SetLineColor(106);
753 break;
754 case MCalibrationCam::kCT1:
755 fit->SetLineColor(006);
756 break;
757 default:
758 fit->SetLineColor(kRed);
759 }
760 fit->Draw("same");
761 }
762
763 DisplayRefLines(null,refline);
764
765 newpad->cd(2);
766 gPad->SetTicks();
767
768 TH1F *null2 = new TH1F("Null2",hist->GetTitle(),100,0.,pix.GetEvents()->GetSize()/pix.GetEventFrequency());
769
770 null2->SetMinimum(pix.GetMean()-10.*pix.GetSigma());
771 null2->SetMaximum(pix.GetMean()+10.*pix.GetSigma());
772 null2->SetDirectory(NULL);
773 null2->SetBit(kCanDelete);
774 null2->SetStats(kFALSE);
775 //
776 // set the labels bigger
777 //
778 TAxis *xaxe2 = null2->GetXaxis();
779 TAxis *yaxe2 = null2->GetYaxis();
780 xaxe2->CenterTitle();
781 yaxe2->CenterTitle();
782 xaxe2->SetTitleSize(0.07);
783 yaxe2->SetTitleSize(0.07);
784 xaxe2->SetTitleOffset(0.65);
785 yaxe2->SetTitleOffset(0.55);
786 xaxe2->SetLabelSize(0.06);
787 yaxe2->SetLabelSize(0.06);
788
789 pix.CreateGraphEvents();
790 TGraph *gr = pix.GetGraphEvents();
791
792 xaxe2->SetTitle(gr->GetXaxis()->GetTitle());
793 yaxe2->SetTitle(gr->GetYaxis()->GetTitle());
794
795 null2->Draw();
796
797 pix.DrawEvents("same");
798
799 return;
800}
801
802void MHCalibrationRelTimeCam::DisplayRefLines(const TH1F *hist, const Float_t refline) const
803{
804
805 TGraph *gr = new TGraph(2);
806 gr->SetPoint(0,refline,0.);
807 gr->SetPoint(1,refline,hist->GetMaximum());
808 gr->SetBit(kCanDelete);
809 gr->SetLineColor(kGreen);
810 gr->SetLineStyle(2);
811 gr->SetLineWidth(3);
812 gr->Draw("L");
813
814 TLegend *leg = new TLegend(0.75,0.7,0.99,0.99);
815 leg->SetBit(kCanDelete);
816 leg->AddEntry(gr,"Trigger Calibration","l");
817 leg->Draw();
818}
819
820Int_t MHCalibrationRelTimeCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
821{
822
823 Bool_t rc = kFALSE;
824
825 if (IsEnvDefined(env, prefix, "ReferenceFile", print))
826 {
827 SetReferenceFile(GetEnvValue(env,prefix,"ReferenceFile",fReferenceFile.Data()));
828 rc = kTRUE;
829 }
830
831 TEnv refenv(fReferenceFile);
832
833 fInnerRefTime = refenv.GetValue("InnerRefTime",fInnerRefTime);
834 fOuterRefTime = refenv.GetValue("OuterRefTime",fOuterRefTime);
835
836 return MHCalibrationCam::ReadEnv(env,prefix,print) ? kTRUE : rc;
837
838}
Note: See TracBrowser for help on using the repository browser.