source: trunk/MagicSoft/Mars/mhcalib/MHCalibrationPulseTimeCam.cc@ 8290

Last change on this file since 8290 was 8192, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 22.6 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: MHCalibrationPulseTimeCam.cc,v 1.25 2006-11-01 15:48:31 tbretz Exp $
3! --------------------------------------------------------------------------
4!
5! *
6! * This file is part of MARS, the MAGIC Analysis and Reconstruction
7! * Software. It is distributed to you in the hope that it can be a useful
8! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9! * It is distributed WITHOUT ANY WARRANTY.
10! *
11! * Permission to use, copy, modify and distribute this software and its
12! * documentation for any purpose is hereby granted without fee,
13! * provided that the above copyright notice appear in all copies and
14! * that both that copyright notice and this permission notice appear
15! * in supporting documentation. It is provided "as is" without express
16! * or implied warranty.
17! *
18!
19!
20! Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
21! Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
22!
23! Copyright: MAGIC Software Development, 2000-2006
24!
25!
26\* ======================================================================== */
27/////////////////////////////////////////////////////////////////////////////
28//
29// MHCalibrationPulseTimeCam
30//
31// Fills the extracted signals of MExtractedSignalCam into the MHCalibrationPix-classes
32// MHCalibrationPulseTimeHiGainPix and MHCalibrationPulseTimeLoGainPix for every:
33//
34// - Pixel, stored in the TOrdCollection's MHCalibrationCam::fHiGainArray and
35// MHCalibrationCam::fLoGainArray
36//
37// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
38// stored in the TOrdCollection's MHCalibrationCam::fAverageHiGainAreas and
39// MHCalibrationCam::fAverageLoGainAreas
40//
41// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
42// stored in the TOrdCollection's MHCalibrationCam::fAverageHiGainSectors and
43// MHCalibrationCam::fAverageLoGainSectors
44//
45// Every signal is taken from MExtractedSignalCam and filled into a histogram and
46// an array, in order to perform a Fourier analysis (see MHGausEvents).
47// The signals are moreover averaged on an event-by-event basis and written into
48// the corresponding average pixels.
49//
50// Additionally, the (FADC slice) position of the maximum is stored in an Absolute
51// Arrival Time histogram. This histogram serves for a rough cross-check if the
52// signal does not lie at or outside the edges of the extraction window.
53//
54// The PulseTime histograms are fitted to a Gaussian, mean and sigma with its errors
55// and the fit probability are extracted. If none of these values are NaN's and
56// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
57// the fit is declared valid.
58// Otherwise, the fit is repeated within ranges of the previous mean
59// +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
60// In case this does not make the fit valid, the histogram means and RMS's are
61// taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
62// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or
63// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
64// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
65//
66// Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas
67// from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup)
68//
69// Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
70// slices show saturation, the following flag is set:
71// - MCalibrationPulseTimePix::SetHiGainSaturation();
72// In that case, the calibration constants are derived from the low-gain results.
73//
74// If more than fNumLoGainSaturationLimit (default: 1%) of the overall
75// low-gain FADC slices saturate, the following flags are set:
76// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
77// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun )
78//
79// The class also fills arrays with the signal vs. event number, creates a fourier
80// spectrum and investigates if the projected fourier components follow an exponential
81// distribution. In case that the probability of the exponential fit is less than
82// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
83// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
84// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
85// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
86//
87// This same procedure is performed for the average pixels.
88//
89// The following results are written into MCalibrationPulseTimeCam:
90//
91// - MCalibrationPix::SetHiGainSaturation()
92// - MCalibrationPix::SetHiGainMean()
93// - MCalibrationPix::SetHiGainMeanErr()
94// - MCalibrationPix::SetHiGainSigma()
95// - MCalibrationPix::SetHiGainSigmaErr()
96// - MCalibrationPix::SetHiGainProb()
97// - MCalibrationPix::SetHiGainNumPickup()
98//
99// For all averaged areas, the fitted sigma is multiplied with the square root of
100// the number involved pixels in order to be able to compare it to the average of
101// sigmas in the camera.
102//
103/////////////////////////////////////////////////////////////////////////////
104#include "MHCalibrationPulseTimeCam.h"
105#include "MHCalibrationCam.h"
106
107#include <TOrdCollection.h>
108#include <TPad.h>
109#include <TVirtualPad.h>
110#include <TCanvas.h>
111#include <TStyle.h>
112#include <TF1.h>
113#include <TLatex.h>
114#include <TLegend.h>
115#include <TGraph.h>
116#include <TEnv.h>
117
118#include "MLog.h"
119#include "MLogManip.h"
120
121#include "MParList.h"
122
123#include "MHCalibrationPix.h"
124
125#include "MCalibrationIntensityCam.h"
126#include "MCalibrationChargeCam.h"
127#include "MCalibrationChargePix.h"
128
129#include "MGeomCam.h"
130#include "MGeomPix.h"
131
132#include "MBadPixelsIntensityCam.h"
133#include "MBadPixelsCam.h"
134#include "MBadPixelsPix.h"
135
136#include "MRawEvtData.h"
137#include "MRawRunHeader.h"
138#include "MRawEvtPixelIter.h"
139
140#include "MExtractedSignalCam.h"
141#include "MExtractedSignalPix.h"
142
143#include "MArrayI.h"
144#include "MArrayD.h"
145
146ClassImp(MHCalibrationPulseTimeCam);
147
148using namespace std;
149
150const Byte_t MHCalibrationPulseTimeCam::fgSaturationLimit = 254;
151const Byte_t MHCalibrationPulseTimeCam::fgLowerSignalLimit = 100;
152const Int_t MHCalibrationPulseTimeCam::fgNumPixelsRequired = 2;
153const Int_t MHCalibrationPulseTimeCam::fgHiGainNbins = 40;
154const Axis_t MHCalibrationPulseTimeCam::fgHiGainFirst = -0.5;
155const Axis_t MHCalibrationPulseTimeCam::fgHiGainLast = 19.5;
156const Float_t MHCalibrationPulseTimeCam::fgProbLimit = 0.001;
157const TString MHCalibrationPulseTimeCam::gsHistName = "PulseTime";
158const TString MHCalibrationPulseTimeCam::gsHistTitle = "Extracted Times";
159const TString MHCalibrationPulseTimeCam::gsHistXTitle = "Time [FADC slices]";
160const TString MHCalibrationPulseTimeCam::gsHistYTitle = "Nr. events";
161const TString MHCalibrationPulseTimeCam::fgReferenceFile = "mjobs/signalref.rc";
162// --------------------------------------------------------------------------
163//
164// Default Constructor.
165//
166// Sets:
167// - all pointers to NULL
168//
169// - fNbins to fgHiGainNbins
170// - fFirst to fgHiGainFirst
171// - fLast to fgHiGainLast
172//
173// - fHistName to gsHistName
174// - fHistTitle to gsHistTitle
175// - fHistXTitle to gsHistXTitle
176// - fHistYTitle to gsHistYTitle
177//
178// - fSaturationLimit to fgSaturationLimit
179// - fLowerSignalLimit to fgLowerSignalLimit
180// - fNumPixelsRequired to fgNumPixelsRequired
181//
182MHCalibrationPulseTimeCam::MHCalibrationPulseTimeCam(const char *name, const char *title)
183 : fBadPixels(NULL)
184{
185
186 fName = name ? name : "MHCalibrationPulseTimeCam";
187 fTitle = title ? title : "Class to fill the extracted pulse times for cosmics ";
188
189 SetNbins(fgHiGainNbins);
190 SetFirst(fgHiGainFirst);
191 SetLast (fgHiGainLast );
192
193 SetProbLimit(fgProbLimit);
194
195 SetHistName (gsHistName .Data());
196 SetHistTitle (gsHistTitle .Data());
197 SetHistXTitle(gsHistXTitle.Data());
198 SetHistYTitle(gsHistYTitle.Data());
199
200 SetReferenceFile();
201 SetLoGain(kFALSE);
202 SetOscillations(kFALSE);
203
204 SetSaturationLimit();
205 SetLowerSignalLimit();
206 SetNumPixelsRequired();
207
208 fInnerRefTime = 5.;
209 fOuterRefTime = 5.;
210}
211// --------------------------------------------------------------------------
212//
213// Creates new MHCalibrationPulseTimeCam only with the averaged areas:
214// the rest has to be retrieved directly, e.g. via:
215// MHCalibrationPulseTimeCam *cam = MParList::FindObject("MHCalibrationPulseTimeCam");
216// - cam->GetAverageSector(5).DrawClone();
217// - (*cam)[100].DrawClone()
218//
219TObject *MHCalibrationPulseTimeCam::Clone(const char *) const
220{
221
222 MHCalibrationPulseTimeCam *cam = new MHCalibrationPulseTimeCam();
223
224 //
225 // Copy the data members
226 //
227 cam->fColor = fColor;
228 cam->fRunNumbers = fRunNumbers;
229 cam->fPulserFrequency = fPulserFrequency;
230 cam->fFlags = fFlags;
231 cam->fNbins = fNbins;
232 cam->fFirst = fFirst;
233 cam->fLast = fLast;
234 cam->fReferenceFile = fReferenceFile;
235
236 if (!IsAverageing())
237 return cam;
238
239 const Int_t navhi = fAverageHiGainAreas->GetSize();
240
241 for (int i=0; i<navhi; i++)
242 cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
243
244 return cam;
245}
246
247// --------------------------------------------------------------------------
248//
249// Gets the pointers to:
250// - MRawEvtData
251//
252Bool_t MHCalibrationPulseTimeCam::SetupHists(const MParList *pList)
253{
254
255 fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
256 if (!fBadPixels)
257 {
258 *fLog << warn << GetDescriptor() << "MBadPixelsCam not found... " << endl;
259 }
260
261 return kTRUE;
262}
263
264// --------------------------------------------------------------------------
265//
266// Gets or creates the pointers to:
267// - MExtractedSignalCam
268// - MCalibrationPulseTimeCam or MCalibrationIntensityPulseTimeCam
269// - MBadPixelsCam
270//
271// Initializes the number of used FADC slices from MExtractedSignalCam
272// into MCalibrationPulseTimeCam and test for changes in that variable
273//
274// Calls:
275// - InitHiGainArrays()
276//
277// Sets:
278// - fSumhiarea to nareas
279// - fSumloarea to nareas
280// - fSumhisector to nsectors
281// - fSumlosector to nsectors
282//
283Bool_t MHCalibrationPulseTimeCam::ReInitHists(MParList *pList)
284{
285
286 MExtractedSignalCam *signal =
287 (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
288 if (!signal)
289 {
290 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
291 return kFALSE;
292 }
293
294 if (!InitCams(pList,"PulseTime"))
295 return kFALSE;
296
297 const Int_t npixels = fGeom->GetNumPixels();
298 const Int_t nsectors = fGeom->GetNumSectors();
299 const Int_t nareas = fGeom->GetNumAreas();
300
301 InitHiGainArrays(npixels,nareas,nsectors);
302
303 fSumhiarea .Set(nareas);
304 fSumhisector.Set(nsectors);
305
306 return kTRUE;
307}
308
309void MHCalibrationPulseTimeCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
310{
311
312 if (fHiGainArray->GetSize()==0)
313 {
314 for (Int_t i=0; i<npixels; i++)
315 {
316 fHiGainArray->AddAt(new MHCalibrationPix(Form("%sHiGainPix%04d",fHistName.Data(),i),
317 Form("%s High Gain Pixel %4d",fHistTitle.Data(),i)),i);
318
319 MHCalibrationPix &pix = (*this)[i];
320 pix.SetNbins(fNbins*2);
321 pix.SetFirst(fFirst);
322 pix.SetLast (fLast);
323
324 MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
325 InitHists(pix,bad,i);
326
327 if (fCam)
328 (*fCam)[i].SetPixId(i);
329 }
330 }
331
332 if (!IsAverageing())
333 return;
334
335 if (fAverageHiGainAreas->GetSize()==0)
336 {
337 for (Int_t j=0; j<nareas; j++)
338 {
339 fAverageHiGainAreas->AddAt(new MHCalibrationPix(Form("%sHiGainArea%d",fHistName.Data(),j),
340 Form("%s High Gain Area Idx %d",fHistTitle.Data(),j)),j);
341
342 MHCalibrationPix &pix = GetAverageHiGainArea(j);
343
344 pix.SetNbins(fNbins*2);
345 pix.SetFirst(fFirst);
346 pix.SetLast (fLast);
347
348 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
349 }
350 }
351
352 if (fAverageHiGainSectors->GetSize()==0)
353 {
354 for (Int_t j=0; j<nsectors; j++)
355 {
356 fAverageHiGainSectors->AddAt(new MHCalibrationPix(Form("%sHiGainSector%02d",fHistName.Data(),j),
357 Form("%s High Gain Sector %02d",fHistTitle.Data(),j)),j);
358 MHCalibrationPix &pix = GetAverageHiGainSector(j);
359
360 pix.SetNbins(fNbins);
361 pix.SetFirst(fFirst);
362 pix.SetLast (fLast);
363
364 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
365 }
366 }
367}
368
369// --------------------------------------------------------------------------
370//
371// Retrieves from MExtractedSignalCam:
372// - first used LoGain FADC slice
373//
374// Retrieves from MGeomCam:
375// - number of pixels
376// - number of pixel areas
377// - number of sectors
378//
379// For all TOrdCollection's (including the averaged ones), the following steps are performed:
380//
381// 1) Fill PulseTimes histograms (MHGausEvents::FillHistAndArray()) with:
382// - MExtractedSignalPix::GetExtractedSignalHiGain();
383// - MExtractedSignalPix::GetExtractedSignalLoGain();
384//
385Bool_t MHCalibrationPulseTimeCam::FillHists(const MParContainer *par, const Stat_t w)
386{
387
388 MRawEvtData *data = (MRawEvtData*)par;
389 if (!data)
390 {
391 *fLog << err << "No argument in MHCalibrationPulseTimeCam::Fill... abort." << endl;
392 return kFALSE;
393 }
394
395 const UInt_t nareas = fGeom->GetNumAreas();
396 const UInt_t nsectors = fGeom->GetNumSectors();
397
398 fSumhiarea .Reset();
399 fSumhisector.Reset();
400 fAverageAreaNum.Reset();
401 fAverageSectorNum.Reset();
402
403 MRawEvtPixelIter pixel(data);
404 while (pixel.Next())
405 {
406
407 const Int_t i = pixel.GetPixelId();
408
409 if (fBadPixels)
410 {
411 MBadPixelsPix &bad = (*fBadPixels)[i];
412 if (bad.IsUnsuitable())
413 continue;
414 }
415
416 Byte_t *start = pixel.GetHiGainSamples();
417 Byte_t *end = start + pixel.GetNumHiGainSamples();
418 Byte_t *p = start;
419 Byte_t *max = start;
420 Int_t maxpos = 0;
421
422 while (p < end)
423 {
424 if (*p > *max)
425 {
426 max = p;
427 maxpos = p-start-1;
428 }
429 p++;
430 }
431
432 if (*max > fSaturationLimit)
433 continue;
434
435 start = pixel.GetLoGainSamples();
436 end = start + pixel.GetNumLoGainSamples();
437 p = start;
438
439 while (p < end)
440 {
441 if (*p > *max)
442 {
443 max = p;
444 maxpos = p-start-1 + pixel.GetNumHiGainSamples();
445 }
446 p++;
447 }
448
449 if (*max < fLowerSignalLimit || *max > fSaturationLimit)
450 continue;
451
452 const Float_t time = (Float_t)maxpos;
453
454 (*this)[i].FillHist(time);
455
456 const Int_t aidx = (*fGeom)[i].GetAidx();
457 const Int_t sector = (*fGeom)[i].GetSector();
458
459 fSumhiarea[aidx] += time;
460 fSumhisector[sector] += time;
461
462 fAverageAreaNum[aidx]++;
463 fAverageSectorNum[sector]++;
464 }
465
466 for (UInt_t j=0; j<nareas; j++)
467 {
468
469 const Int_t npix = fAverageAreaNum[j];
470
471 if (npix > fNumPixelsRequired)
472 {
473 if (IsOscillations())
474 GetAverageHiGainArea(j).FillHistAndArray(fSumhiarea[j]/npix);
475 else
476 GetAverageHiGainArea(j).FillHist(fSumhiarea[j]/npix);
477
478 }
479 }
480
481 for (UInt_t j=0; j<nsectors; j++)
482 {
483
484 const Int_t npix = fAverageSectorNum[j];
485
486 if (npix > 0)
487 {
488 if (IsOscillations())
489 GetAverageHiGainSector(j).FillHistAndArray(fSumhisector [j]/npix);
490 else
491 GetAverageHiGainSector(j).FillHist(fSumhisector [j]/npix);
492 }
493 }
494
495 return kTRUE;
496}
497
498// --------------------------------------------------------------------------
499//
500// For all TOrdCollection's (including the averaged ones), the following steps are performed:
501//
502// 1) Returns if the pixel is excluded.
503// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
504// or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
505// 3) Store the absolute arrival times in the MCalibrationPulseTimePix's. If flag
506// MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
507// otherwise the Hi-Gain ones.
508// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
509// with the flags:
510// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
511// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
512// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
513// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
514//
515Bool_t MHCalibrationPulseTimeCam::FinalizeHists()
516{
517
518 *fLog << endl;
519
520 MCalibrationCam &calcam = *(fIntensCam ? fIntensCam->GetCam() : fCam);
521 //
522 // Perform the fitting for the High Gain (done in MHCalibrationCam)
523 //
524 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
525 {
526
527 MHCalibrationPix &hist = (*this)[i];
528
529 if (hist.IsExcluded())
530 continue;
531
532 MCalibrationPix &pix = calcam[i];
533 CalcHists(hist,pix);
534 }
535
536 if (!IsAverageing())
537 return kTRUE;
538
539 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
540 {
541
542 MHCalibrationPix &hist = GetAverageHiGainArea(j);
543 MCalibrationPix &pix = calcam.GetAverageArea(j);
544 CalcHists(hist,pix);
545 }
546
547 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
548 {
549 MHCalibrationPix &hist = GetAverageHiGainSector(j);
550 MCalibrationPix &pix = calcam.GetAverageSector(j);
551 CalcHists(hist,pix);
552 }
553
554 return kTRUE;
555}
556
557void MHCalibrationPulseTimeCam::CalcHists(MHCalibrationPix &hist, MCalibrationPix &pix) const
558{
559
560 if (hist.IsEmpty())
561 {
562 *fLog << warn << hist.GetName() << ": Histogram empty." << endl;
563 return;
564 }
565 if (hist.IsOnlyOverflow())
566 {
567 *fLog << warn << hist.GetName() << ": Histogram contains only overflows." << endl;
568 return;
569 }
570 if (hist.IsOnlyUnderflow())
571 {
572 *fLog << warn << hist.GetName() << ": Histogram contains only underflows." << endl;
573 return;
574 }
575
576 hist.BypassFit();
577
578 pix.SetHiGainMean ( hist.GetMean() );
579 pix.SetHiGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
580 pix.SetHiGainRms ( hist.GetHistRms() );
581 pix.SetHiGainSigma ( hist.GetSigma() );
582 pix.SetHiGainSigmaVar ( hist.GetSigmaErr()* hist.GetSigmaErr() );
583
584 if (IsDebug())
585 {
586 *fLog << dbginf << GetDescriptor() << ": ID " << GetName()
587 << " "<<pix.GetPixId()
588 << " Mean: " << hist.GetMean ()
589 << " MeanErr: " << hist.GetMeanErr ()
590 << " MeanSigma: " << hist.GetSigma ()
591 << " MeanSigmaErr: " << hist.GetSigmaErr()
592 << " Prob: " << hist.GetProb ()
593 << endl;
594 }
595 return;
596}
597
598
599// --------------------------------------------------------------------------
600//
601// Calls MHCalibrationPix::DrawClone() for pixel idx
602//
603void MHCalibrationPulseTimeCam::DrawPixelContent(Int_t idx) const
604{
605 (*this)[idx].DrawClone();
606}
607
608
609// -----------------------------------------------------------------------------
610//
611// Default draw:
612//
613// Displays the averaged areas, both High Gain and Low Gain
614//
615// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
616//
617void MHCalibrationPulseTimeCam::Draw(const Option_t *opt)
618{
619
620 const Int_t nareas = fAverageHiGainAreas->GetSize();
621 if (nareas == 0)
622 return;
623
624 TString option(opt);
625 option.ToLower();
626
627 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
628 pad->SetBorderMode(0);
629 pad->Divide(1,nareas);
630
631 //
632 // Loop over inner and outer pixels
633 //
634 for (Int_t i=0; i<nareas;i++)
635 {
636
637 pad->cd(i+1);
638
639 MHCalibrationPix &hipix = GetAverageHiGainArea(i);
640 DrawDataCheckPixel(hipix,i ? fOuterRefTime : fInnerRefTime);
641 }
642}
643
644// -----------------------------------------------------------------------------
645//
646// Draw the average pixel for the datacheck:
647//
648// Displays the averaged areas, both High Gain and Low Gain
649//
650// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
651//
652void MHCalibrationPulseTimeCam::DrawDataCheckPixel(MHCalibrationPix &pix, const Float_t refline)
653{
654
655 gPad->SetTicks();
656
657 TH1F *hist = pix.GetHGausHist();
658
659 TH1F *null = new TH1F("Null",hist->GetTitle(),100,
660 pix.GetFirst() > 0. ? pix.GetFirst() : 0.,
661 pix.GetLast() > pix.GetFirst()
662 ? pix.GetLast() : pix.GetFirst()*2.);
663
664 null->SetMaximum(1.1*hist->GetMaximum());
665 null->SetDirectory(NULL);
666 null->SetBit(kCanDelete);
667 null->SetStats(kFALSE);
668 //
669 // set the labels bigger
670 //
671 TAxis *xaxe = null->GetXaxis();
672 TAxis *yaxe = null->GetYaxis();
673 xaxe->CenterTitle();
674 yaxe->CenterTitle();
675 xaxe->SetTitleSize(0.06);
676 yaxe->SetTitleSize(0.076);
677 xaxe->SetTitleOffset(0.6);
678 yaxe->SetTitleOffset(0.65);
679 xaxe->SetLabelSize(0.06);
680 yaxe->SetLabelSize(0.06);
681 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
682 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
683
684 null->Draw();
685 hist->Draw("same");
686
687 DisplayRefLines(null,refline);
688
689 return;
690
691}
692
693void MHCalibrationPulseTimeCam::DisplayRefLines(const TH1F *hist, const Float_t refline) const
694{
695
696 TGraph *gr = new TGraph(2);
697 gr->SetPoint(0,refline,0.);
698 gr->SetPoint(1,refline,hist->GetMaximum());
699 gr->SetBit(kCanDelete);
700 gr->SetLineColor(106);
701 gr->SetLineStyle(2);
702 gr->SetLineWidth(3);
703 gr->Draw("L");
704
705 TLegend *leg = new TLegend(0.8,0.35,0.99,0.65);
706 leg->SetBit(kCanDelete);
707 leg->AddEntry(gr,"Reference","l");
708
709 leg->Draw();
710}
711
712Int_t MHCalibrationPulseTimeCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
713{
714
715 Bool_t rc = kFALSE;
716
717 if (MHCalibrationCam::ReadEnv(env,prefix,print))
718 rc = kTRUE;
719
720 if (IsEnvDefined(env, prefix, "SaturationLimit", print))
721 {
722 SetSaturationLimit(GetEnvValue(env, prefix, "SaturationLimit", fSaturationLimit));
723 rc = kTRUE;
724 }
725
726 if (IsEnvDefined(env, prefix, "LowerSignalLimit", print))
727 {
728 SetLowerSignalLimit(GetEnvValue(env,prefix,"LowerSignalLimit",fLowerSignalLimit));
729 rc = kTRUE;
730 }
731
732 if (IsEnvDefined(env, prefix, "NumPixelsRequired", print))
733 {
734 SetNumPixelsRequired(GetEnvValue(env,prefix,"NumPixelsRequired",fNumPixelsRequired));
735 rc = kTRUE;
736 }
737
738 if (IsEnvDefined(env, prefix, "ReferenceFile", print))
739 {
740 SetReferenceFile(GetEnvValue(env,prefix,"ReferenceFile",fReferenceFile.Data()));
741 rc = kTRUE;
742 }
743
744 TEnv refenv(fReferenceFile);
745
746 fInnerRefTime = refenv.GetValue("InnerRefTime",fInnerRefTime);
747 fOuterRefTime = refenv.GetValue("OuterRefTime",fOuterRefTime);
748
749 return rc;
750}
Note: See TracBrowser for help on using the repository browser.