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

Last change on this file since 8339 was 8339, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 22.5 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: MHCalibrationPulseTimeCam.cc,v 1.26 2007-03-01 17:59:12 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 SetBinning(fgHiGainNbins, fgHiGainFirst, fgHiGainLast);
190
191 SetProbLimit(fgProbLimit);
192
193 SetHistName (gsHistName .Data());
194 SetHistTitle (gsHistTitle .Data());
195 SetHistXTitle(gsHistXTitle.Data());
196 SetHistYTitle(gsHistYTitle.Data());
197
198 SetReferenceFile();
199 SetLoGain(kFALSE);
200 SetOscillations(kFALSE);
201
202 SetSaturationLimit();
203 SetLowerSignalLimit();
204 SetNumPixelsRequired();
205
206 fInnerRefTime = 5.;
207 fOuterRefTime = 5.;
208}
209// --------------------------------------------------------------------------
210//
211// Creates new MHCalibrationPulseTimeCam only with the averaged areas:
212// the rest has to be retrieved directly, e.g. via:
213// MHCalibrationPulseTimeCam *cam = MParList::FindObject("MHCalibrationPulseTimeCam");
214// - cam->GetAverageSector(5).DrawClone();
215// - (*cam)[100].DrawClone()
216//
217TObject *MHCalibrationPulseTimeCam::Clone(const char *) const
218{
219
220 MHCalibrationPulseTimeCam *cam = new MHCalibrationPulseTimeCam();
221
222 //
223 // Copy the data members
224 //
225 cam->fColor = fColor;
226 cam->fRunNumbers = fRunNumbers;
227 cam->fPulserFrequency = fPulserFrequency;
228 cam->fFlags = fFlags;
229 cam->fNbins = fNbins;
230 cam->fFirst = fFirst;
231 cam->fLast = fLast;
232 cam->fReferenceFile = fReferenceFile;
233
234 if (!IsAverageing())
235 return cam;
236
237 const Int_t navhi = fAverageHiGainAreas->GetSize();
238
239 for (int i=0; i<navhi; i++)
240 cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
241
242 return cam;
243}
244
245// --------------------------------------------------------------------------
246//
247// Gets the pointers to:
248// - MRawEvtData
249//
250Bool_t MHCalibrationPulseTimeCam::SetupHists(const MParList *pList)
251{
252
253 fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
254 if (!fBadPixels)
255 {
256 *fLog << warn << GetDescriptor() << "MBadPixelsCam not found... " << endl;
257 }
258
259 return kTRUE;
260}
261
262// --------------------------------------------------------------------------
263//
264// Gets or creates the pointers to:
265// - MExtractedSignalCam
266// - MCalibrationPulseTimeCam or MCalibrationIntensityPulseTimeCam
267// - MBadPixelsCam
268//
269// Initializes the number of used FADC slices from MExtractedSignalCam
270// into MCalibrationPulseTimeCam and test for changes in that variable
271//
272// Calls:
273// - InitHiGainArrays()
274//
275// Sets:
276// - fSumhiarea to nareas
277// - fSumloarea to nareas
278// - fSumhisector to nsectors
279// - fSumlosector to nsectors
280//
281Bool_t MHCalibrationPulseTimeCam::ReInitHists(MParList *pList)
282{
283
284 MExtractedSignalCam *signal =
285 (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
286 if (!signal)
287 {
288 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
289 return kFALSE;
290 }
291
292 if (!InitCams(pList,"PulseTime"))
293 return kFALSE;
294
295 const Int_t npixels = fGeom->GetNumPixels();
296 const Int_t nsectors = fGeom->GetNumSectors();
297 const Int_t nareas = fGeom->GetNumAreas();
298
299 InitHiGainArrays(npixels,nareas,nsectors);
300
301 fSumhiarea .Set(nareas);
302 fSumhisector.Set(nsectors);
303
304 return kTRUE;
305}
306
307void MHCalibrationPulseTimeCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
308{
309
310 if (fHiGainArray->GetSize()==0)
311 {
312 for (Int_t i=0; i<npixels; i++)
313 {
314 fHiGainArray->AddAt(new MHCalibrationPix(Form("%sHiGainPix%04d",fHistName.Data(),i),
315 Form("%s High Gain Pixel %4d",fHistTitle.Data(),i)),i);
316
317 MHCalibrationPix &pix = (*this)[i];
318 pix.SetBinning(fNbins, fFirst, fLast);
319
320 MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
321 InitHists(pix,bad,i);
322
323 if (fCam)
324 (*fCam)[i].SetPixId(i);
325 }
326 }
327
328 if (!IsAverageing())
329 return;
330
331 if (fAverageHiGainAreas->GetSize()==0)
332 {
333 for (Int_t j=0; j<nareas; j++)
334 {
335 fAverageHiGainAreas->AddAt(new MHCalibrationPix(Form("%sHiGainArea%d",fHistName.Data(),j),
336 Form("%s High Gain Area Idx %d",fHistTitle.Data(),j)),j);
337
338 MHCalibrationPix &pix = GetAverageHiGainArea(j);
339 pix.SetBinning(fNbins, fFirst, fLast);
340
341 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
342 }
343 }
344
345 if (fAverageHiGainSectors->GetSize()==0)
346 {
347 for (Int_t j=0; j<nsectors; j++)
348 {
349 fAverageHiGainSectors->AddAt(new MHCalibrationPix(Form("%sHiGainSector%02d",fHistName.Data(),j),
350 Form("%s High Gain Sector %02d",fHistTitle.Data(),j)),j);
351 MHCalibrationPix &pix = GetAverageHiGainSector(j);
352 pix.SetBinning(fNbins, fFirst, fLast);
353
354 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
355 }
356 }
357}
358
359// --------------------------------------------------------------------------
360//
361// Retrieves from MExtractedSignalCam:
362// - first used LoGain FADC slice
363//
364// Retrieves from MGeomCam:
365// - number of pixels
366// - number of pixel areas
367// - number of sectors
368//
369// For all TOrdCollection's (including the averaged ones), the following steps are performed:
370//
371// 1) Fill PulseTimes histograms (MHGausEvents::FillHistAndArray()) with:
372// - MExtractedSignalPix::GetExtractedSignalHiGain();
373// - MExtractedSignalPix::GetExtractedSignalLoGain();
374//
375Bool_t MHCalibrationPulseTimeCam::FillHists(const MParContainer *par, const Stat_t w)
376{
377
378 MRawEvtData *data = (MRawEvtData*)par;
379 if (!data)
380 {
381 *fLog << err << "No argument in MHCalibrationPulseTimeCam::Fill... abort." << endl;
382 return kFALSE;
383 }
384
385 const UInt_t nareas = fGeom->GetNumAreas();
386 const UInt_t nsectors = fGeom->GetNumSectors();
387
388 fSumhiarea .Reset();
389 fSumhisector.Reset();
390 fAverageAreaNum.Reset();
391 fAverageSectorNum.Reset();
392
393 MRawEvtPixelIter pixel(data);
394 while (pixel.Next())
395 {
396
397 const Int_t i = pixel.GetPixelId();
398
399 if (fBadPixels)
400 {
401 MBadPixelsPix &bad = (*fBadPixels)[i];
402 if (bad.IsUnsuitable())
403 continue;
404 }
405
406 Byte_t *start = pixel.GetHiGainSamples();
407 Byte_t *end = start + pixel.GetNumHiGainSamples();
408 Byte_t *p = start;
409 Byte_t *max = start;
410 Int_t maxpos = 0;
411
412 while (p < end)
413 {
414 if (*p > *max)
415 {
416 max = p;
417 maxpos = p-start-1;
418 }
419 p++;
420 }
421
422 if (*max > fSaturationLimit)
423 continue;
424
425 start = pixel.GetLoGainSamples();
426 end = start + pixel.GetNumLoGainSamples();
427 p = start;
428
429 while (p < end)
430 {
431 if (*p > *max)
432 {
433 max = p;
434 maxpos = p-start-1 + pixel.GetNumHiGainSamples();
435 }
436 p++;
437 }
438
439 if (*max < fLowerSignalLimit || *max > fSaturationLimit)
440 continue;
441
442 const Float_t time = (Float_t)maxpos;
443
444 (*this)[i].FillHist(time);
445
446 const Int_t aidx = (*fGeom)[i].GetAidx();
447 const Int_t sector = (*fGeom)[i].GetSector();
448
449 fSumhiarea[aidx] += time;
450 fSumhisector[sector] += time;
451
452 fAverageAreaNum[aidx]++;
453 fAverageSectorNum[sector]++;
454 }
455
456 for (UInt_t j=0; j<nareas; j++)
457 {
458
459 const Int_t npix = fAverageAreaNum[j];
460
461 if (npix > fNumPixelsRequired)
462 {
463 if (IsOscillations())
464 GetAverageHiGainArea(j).FillHistAndArray(fSumhiarea[j]/npix);
465 else
466 GetAverageHiGainArea(j).FillHist(fSumhiarea[j]/npix);
467
468 }
469 }
470
471 for (UInt_t j=0; j<nsectors; j++)
472 {
473
474 const Int_t npix = fAverageSectorNum[j];
475
476 if (npix > 0)
477 {
478 if (IsOscillations())
479 GetAverageHiGainSector(j).FillHistAndArray(fSumhisector [j]/npix);
480 else
481 GetAverageHiGainSector(j).FillHist(fSumhisector [j]/npix);
482 }
483 }
484
485 return kTRUE;
486}
487
488// --------------------------------------------------------------------------
489//
490// For all TOrdCollection's (including the averaged ones), the following steps are performed:
491//
492// 1) Returns if the pixel is excluded.
493// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
494// or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
495// 3) Store the absolute arrival times in the MCalibrationPulseTimePix's. If flag
496// MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
497// otherwise the Hi-Gain ones.
498// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
499// with the flags:
500// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
501// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
502// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
503// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
504//
505Bool_t MHCalibrationPulseTimeCam::FinalizeHists()
506{
507
508 *fLog << endl;
509
510 MCalibrationCam &calcam = *(fIntensCam ? fIntensCam->GetCam() : fCam);
511 //
512 // Perform the fitting for the High Gain (done in MHCalibrationCam)
513 //
514 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
515 {
516
517 MHCalibrationPix &hist = (*this)[i];
518
519 if (hist.IsExcluded())
520 continue;
521
522 MCalibrationPix &pix = calcam[i];
523 CalcHists(hist,pix);
524 }
525
526 if (!IsAverageing())
527 return kTRUE;
528
529 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
530 {
531
532 MHCalibrationPix &hist = GetAverageHiGainArea(j);
533 MCalibrationPix &pix = calcam.GetAverageArea(j);
534 CalcHists(hist,pix);
535 }
536
537 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
538 {
539 MHCalibrationPix &hist = GetAverageHiGainSector(j);
540 MCalibrationPix &pix = calcam.GetAverageSector(j);
541 CalcHists(hist,pix);
542 }
543
544 return kTRUE;
545}
546
547void MHCalibrationPulseTimeCam::CalcHists(MHCalibrationPix &hist, MCalibrationPix &pix) const
548{
549
550 if (hist.IsEmpty())
551 {
552 *fLog << warn << hist.GetName() << ": Histogram empty." << endl;
553 return;
554 }
555 if (hist.IsOnlyOverflow())
556 {
557 *fLog << warn << hist.GetName() << ": Histogram contains only overflows." << endl;
558 return;
559 }
560 if (hist.IsOnlyUnderflow())
561 {
562 *fLog << warn << hist.GetName() << ": Histogram contains only underflows." << endl;
563 return;
564 }
565
566 hist.BypassFit();
567
568 pix.SetHiGainMean ( hist.GetMean() );
569 pix.SetHiGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
570 pix.SetHiGainRms ( hist.GetHistRms() );
571 pix.SetHiGainSigma ( hist.GetSigma() );
572 pix.SetHiGainSigmaVar ( hist.GetSigmaErr()* hist.GetSigmaErr() );
573
574 if (IsDebug())
575 {
576 *fLog << dbginf << GetDescriptor() << ": ID " << GetName()
577 << " "<<pix.GetPixId()
578 << " Mean: " << hist.GetMean ()
579 << " MeanErr: " << hist.GetMeanErr ()
580 << " MeanSigma: " << hist.GetSigma ()
581 << " MeanSigmaErr: " << hist.GetSigmaErr()
582 << " Prob: " << hist.GetProb ()
583 << endl;
584 }
585 return;
586}
587
588
589// --------------------------------------------------------------------------
590//
591// Calls MHCalibrationPix::DrawClone() for pixel idx
592//
593void MHCalibrationPulseTimeCam::DrawPixelContent(Int_t idx) const
594{
595 (*this)[idx].DrawClone();
596}
597
598
599// -----------------------------------------------------------------------------
600//
601// Default draw:
602//
603// Displays the averaged areas, both High Gain and Low Gain
604//
605// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
606//
607void MHCalibrationPulseTimeCam::Draw(const Option_t *opt)
608{
609
610 const Int_t nareas = fAverageHiGainAreas->GetSize();
611 if (nareas == 0)
612 return;
613
614 TString option(opt);
615 option.ToLower();
616
617 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
618 pad->SetBorderMode(0);
619 pad->Divide(1,nareas);
620
621 //
622 // Loop over inner and outer pixels
623 //
624 for (Int_t i=0; i<nareas;i++)
625 {
626
627 pad->cd(i+1);
628
629 MHCalibrationPix &hipix = GetAverageHiGainArea(i);
630 DrawDataCheckPixel(hipix,i ? fOuterRefTime : fInnerRefTime);
631 }
632}
633
634// -----------------------------------------------------------------------------
635//
636// Draw the average pixel for the datacheck:
637//
638// Displays the averaged areas, both High Gain and Low Gain
639//
640// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
641//
642void MHCalibrationPulseTimeCam::DrawDataCheckPixel(MHCalibrationPix &pix, const Float_t refline)
643{
644
645 gPad->SetTicks();
646
647 TH1F *hist = pix.GetHGausHist();
648
649 TH1F *null = new TH1F("Null",hist->GetTitle(),100,
650 pix.GetFirst() > 0. ? pix.GetFirst() : 0.,
651 pix.GetLast() > pix.GetFirst()
652 ? pix.GetLast() : pix.GetFirst()*2.);
653
654 null->SetMaximum(1.1*hist->GetMaximum());
655 null->SetDirectory(NULL);
656 null->SetBit(kCanDelete);
657 null->SetStats(kFALSE);
658 //
659 // set the labels bigger
660 //
661 TAxis *xaxe = null->GetXaxis();
662 TAxis *yaxe = null->GetYaxis();
663 xaxe->CenterTitle();
664 yaxe->CenterTitle();
665 xaxe->SetTitleSize(0.06);
666 yaxe->SetTitleSize(0.076);
667 xaxe->SetTitleOffset(0.6);
668 yaxe->SetTitleOffset(0.65);
669 xaxe->SetLabelSize(0.06);
670 yaxe->SetLabelSize(0.06);
671 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
672 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
673
674 null->Draw();
675 hist->Draw("same");
676
677 DisplayRefLines(null,refline);
678
679 return;
680
681}
682
683void MHCalibrationPulseTimeCam::DisplayRefLines(const TH1F *hist, const Float_t refline) const
684{
685
686 TGraph *gr = new TGraph(2);
687 gr->SetPoint(0,refline,0.);
688 gr->SetPoint(1,refline,hist->GetMaximum());
689 gr->SetBit(kCanDelete);
690 gr->SetLineColor(106);
691 gr->SetLineStyle(2);
692 gr->SetLineWidth(3);
693 gr->Draw("L");
694
695 TLegend *leg = new TLegend(0.8,0.35,0.99,0.65);
696 leg->SetBit(kCanDelete);
697 leg->AddEntry(gr,"Reference","l");
698
699 leg->Draw();
700}
701
702Int_t MHCalibrationPulseTimeCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
703{
704
705 Bool_t rc = kFALSE;
706
707 if (MHCalibrationCam::ReadEnv(env,prefix,print))
708 rc = kTRUE;
709
710 if (IsEnvDefined(env, prefix, "SaturationLimit", print))
711 {
712 SetSaturationLimit(GetEnvValue(env, prefix, "SaturationLimit", fSaturationLimit));
713 rc = kTRUE;
714 }
715
716 if (IsEnvDefined(env, prefix, "LowerSignalLimit", print))
717 {
718 SetLowerSignalLimit(GetEnvValue(env,prefix,"LowerSignalLimit",fLowerSignalLimit));
719 rc = kTRUE;
720 }
721
722 if (IsEnvDefined(env, prefix, "NumPixelsRequired", print))
723 {
724 SetNumPixelsRequired(GetEnvValue(env,prefix,"NumPixelsRequired",fNumPixelsRequired));
725 rc = kTRUE;
726 }
727
728 if (IsEnvDefined(env, prefix, "ReferenceFile", print))
729 {
730 SetReferenceFile(GetEnvValue(env,prefix,"ReferenceFile",fReferenceFile.Data()));
731 rc = kTRUE;
732 }
733
734 TEnv refenv(fReferenceFile);
735
736 fInnerRefTime = refenv.GetValue("InnerRefTime",fInnerRefTime);
737 fOuterRefTime = refenv.GetValue("OuterRefTime",fOuterRefTime);
738
739 return rc;
740}
Note: See TracBrowser for help on using the repository browser.