source: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc@ 4976

Last change on this file since 4976 was 4976, checked in by gaug, 21 years ago
*** empty log message ***
File size: 52.1 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// MHCalibrationChargeCam
27//
28// Fills the extracted signals of MExtractedSignalCam into the MHCalibrationPix-classes
29// MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
30//
31// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and
32// MHCalibrationCam::fLoGainArray
33//
34// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
35// stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
36// MHCalibrationCam::fAverageLoGainAreas
37//
38// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
39// stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and
40// MHCalibrationCam::fAverageLoGainSectors
41//
42// Every signal is taken from MExtractedSignalCam and filled into a histogram and
43// an array, in order to perform a Fourier analysis (see MHGausEvents).
44// The signals are moreover averaged on an event-by-event basis and written into
45// the corresponding average pixels.
46//
47// Additionally, the (FADC slice) position of the maximum is stored in an Absolute
48// Arrival Time histogram. This histogram serves for a rough cross-check if the
49// signal does not lie at or outside the edges of the extraction window.
50//
51// The Charge histograms are fitted to a Gaussian, mean and sigma with its errors
52// and the fit probability are extracted. If none of these values are NaN's and
53// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
54// the fit is declared valid.
55// Otherwise, the fit is repeated within ranges of the previous mean
56// +- MHCalibrationPix::fPickupLimit (default: 5) sigma (see MHCalibrationPix::RepeatFit())
57// In case this does not make the fit valid, the histogram means and RMS's are
58// taken directly (see MHCalibrationPix::BypassFit()) and the following flags are set:
59// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or
60// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and
61// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
62//
63// Outliers of more than MHCalibrationPix::fPickupLimit (default: 5) sigmas
64// from the mean are counted as Pickup events (stored in MHCalibrationPix::fPickup)
65//
66// Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC
67// slices show saturation, the following flag is set:
68// - MCalibrationChargePix::SetHiGainSaturation();
69// In that case, the calibration constants are derived from the low-gain results.
70//
71// If more than fNumLoGainSaturationLimit (default: 1%) of the overall
72// low-gain FADC slices saturate, the following flags are set:
73// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
74// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun )
75//
76// The class also fills arrays with the signal vs. event number, creates a fourier
77// spectrum and investigates if the projected fourier components follow an exponential
78// distribution. In case that the probability of the exponential fit is less than
79// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
80// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
81// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
82// - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
83//
84// This same procedure is performed for the average pixels.
85//
86// The following results are written into MCalibrationChargeCam:
87//
88// - MCalibrationPix::SetHiGainSaturation()
89// - MCalibrationPix::SetHiGainMean()
90// - MCalibrationPix::SetHiGainMeanErr()
91// - MCalibrationPix::SetHiGainSigma()
92// - MCalibrationPix::SetHiGainSigmaErr()
93// - MCalibrationPix::SetHiGainProb()
94// - MCalibrationPix::SetHiGainNumPickup()
95//
96// - MCalibrationPix::SetLoGainMean()
97// - MCalibrationPix::SetLoGainMeanErr()
98// - MCalibrationPix::SetLoGainSigma()
99// - MCalibrationPix::SetLoGainSigmaErr()
100// - MCalibrationPix::SetLoGainProb()
101// - MCalibrationPix::SetLoGainNumPickup()
102//
103// - MCalibrationChargePix::SetAbsTimeMean()
104// - MCalibrationChargePix::SetAbsTimeRms()
105//
106// For all averaged areas, the fitted sigma is multiplied with the square root of
107// the number involved pixels in order to be able to compare it to the average of
108// sigmas in the camera.
109//
110/////////////////////////////////////////////////////////////////////////////
111#include "MHCalibrationChargeCam.h"
112#include "MHCalibrationCam.h"
113
114#include "MLog.h"
115#include "MLogManip.h"
116
117#include "MParList.h"
118
119#include "MHCalibrationChargePix.h"
120#include "MHCalibrationPix.h"
121
122#include "MCalibrationIntensityCam.h"
123#include "MCalibrationChargeCam.h"
124#include "MCalibrationChargePix.h"
125
126#include "MGeomCam.h"
127#include "MGeomPix.h"
128
129#include "MBadPixelsCam.h"
130#include "MBadPixelsPix.h"
131
132#include "MRawEvtData.h"
133#include "MRawRunHeader.h"
134#include "MRawEvtPixelIter.h"
135
136#include "MExtractedSignalCam.h"
137#include "MExtractedSignalPix.h"
138
139#include "MArrayI.h"
140#include "MArrayD.h"
141
142#include <TPad.h>
143#include <TVirtualPad.h>
144#include <TCanvas.h>
145#include <TStyle.h>
146#include <TF1.h>
147#include <TLatex.h>
148#include <TLegend.h>
149#include <TGraph.h>
150
151ClassImp(MHCalibrationChargeCam);
152
153using namespace std;
154
155const Int_t MHCalibrationChargeCam::fgChargeHiGainNbins = 550;
156const Axis_t MHCalibrationChargeCam::fgChargeHiGainFirst = -100.5;
157const Axis_t MHCalibrationChargeCam::fgChargeHiGainLast = 999.5;
158const Int_t MHCalibrationChargeCam::fgChargeLoGainNbins = 325;
159const Axis_t MHCalibrationChargeCam::fgChargeLoGainFirst = -150.5;
160const Axis_t MHCalibrationChargeCam::fgChargeLoGainLast = 499.5;
161const TString MHCalibrationChargeCam::gsHistName = "Charge";
162const TString MHCalibrationChargeCam::gsHistTitle = "Signals";
163const TString MHCalibrationChargeCam::gsHistXTitle = "Signal [FADC counts]";
164const TString MHCalibrationChargeCam::gsHistYTitle = "Nr. events";
165const TString MHCalibrationChargeCam::gsAbsHistName = "AbsTime";
166const TString MHCalibrationChargeCam::gsAbsHistTitle = "Abs. Arr. Times";
167const TString MHCalibrationChargeCam::gsAbsHistXTitle = "Time [FADC slices]";
168const TString MHCalibrationChargeCam::gsAbsHistYTitle = "Nr. events";
169const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
170const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
171const Float_t MHCalibrationChargeCam::fgTimeLowerLimit = 1.;
172const Float_t MHCalibrationChargeCam::fgTimeUpperLimit = 2.;
173// 1Led Green, 1 LED blue, 5 LEDs blue, 10 LEDs blue, 10 LEDs UV, CT1, 5Leds Green
174const Float_t MHCalibrationChargeCam::gkHiGainInnerRefLines[7] = { 245., 323. , 1065., 1467., 180., 211. , 533.5};
175const Float_t MHCalibrationChargeCam::gkHiGainOuterRefLines[7] = { 217., 307.5, 932. , 1405., 167., 183.5, 405.5};
176const Float_t MHCalibrationChargeCam::gkLoGainInnerRefLines[7] = { 20.8, 28.0 , 121. , 200.2, 16.5, 13.5 , 41.7 };
177const Float_t MHCalibrationChargeCam::gkLoGainOuterRefLines[7] = { 18.9, 26.0 , 108.3, 198. , 14.0, 11. , 42. };
178// --------------------------------------------------------------------------
179//
180// Default Constructor.
181//
182// Sets:
183// - all pointers to NULL
184//
185// Initializes:
186// - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
187// - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
188// - fTimeLowerLimit to fgTimeLowerLimit
189// - fTimeUpperLimit to fgTimeUpperLimit
190//
191// - fNbins to fgChargeHiGainNbins
192// - fFirst to fgChargeHiGainFirst
193// - fLast to fgChargeHiGainLast
194//
195// - fLoGainNbins to fgChargeLoGainNbins
196// - fLoGainFirst to fgChargeLoGainFirst
197// - fLoGainLast to fgChargeLoGainLast
198//
199// - fHistName to gsHistName
200// - fHistTitle to gsHistTitle
201// - fHistXTitle to gsHistXTitle
202// - fHistYTitle to gsHistYTitle
203//
204// - fAbsHistName to gsAbsHistName
205// - fAbsHistTitle to gsAbsHistTitle
206// - fAbsHistXTitle to gsAbsHistXTitle
207// - fAbsHistYTitle to gsAbsHistYTitle
208//
209MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
210 : fRawEvt(NULL)
211{
212
213 fName = name ? name : "MHCalibrationChargeCam";
214 fTitle = title ? title : "Class to fill the calibration histograms ";
215
216 SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
217 SetNumLoGainSaturationLimit(fgNumLoGainSaturationLimit);
218 SetTimeLowerLimit();
219 SetTimeUpperLimit();
220
221 SetNbins(fgChargeHiGainNbins);
222 SetFirst(fgChargeHiGainFirst);
223 SetLast (fgChargeHiGainLast );
224
225 SetLoGainNbins(fgChargeLoGainNbins);
226 SetLoGainFirst(fgChargeLoGainFirst);
227 SetLoGainLast (fgChargeLoGainLast );
228
229 SetHistName (gsHistName .Data());
230 SetHistTitle (gsHistTitle .Data());
231 SetHistXTitle(gsHistXTitle.Data());
232 SetHistYTitle(gsHistYTitle.Data());
233
234 SetAbsHistName (gsAbsHistName .Data());
235 SetAbsHistTitle (gsAbsHistTitle .Data());
236 SetAbsHistXTitle(gsAbsHistXTitle.Data());
237 SetAbsHistYTitle(gsAbsHistYTitle.Data());
238}
239
240// --------------------------------------------------------------------------
241//
242// Gets the pointers to:
243// - MRawEvtData
244//
245Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
246{
247
248 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
249 if (!fRawEvt)
250 {
251 *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
252 return kFALSE;
253 }
254
255 return kTRUE;
256}
257
258// --------------------------------------------------------------------------
259//
260// Gets or creates the pointers to:
261// - MExtractedSignalCam
262// - MCalibrationChargeCam
263// - MBadPixelsCam
264//
265// Initializes the number of used FADC slices from MExtractedSignalCam
266// into MCalibrationChargeCam and test for changes in that variable
267//
268// Calls:
269// - InitHiGainArrays()
270// - InitLoGainArrays()
271//
272// Sets:
273// - fSumhiarea to nareas
274// - fSumloarea to nareas
275// - fTimehiarea to nareas
276// - fTimeloarea to nareas
277// - fSumhisector to nsectors
278// - fSumlosector to nsectors
279// - fTimehisector to nsectors
280// - fTimelosector to nsectors
281// - fSathiarea to nareas
282// - fSatloarea to nareas
283// - fSathisector to nsectors
284// - fSatlosector to nsectors
285//
286Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
287{
288
289 MExtractedSignalCam *signal =
290 (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
291 if (!signal)
292 {
293 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
294 return kFALSE;
295 }
296
297 fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityChargeCam"));
298 if (fIntensCam)
299 *fLog << inf << "Found MCalibrationIntensityChargeCam ... " << endl;
300 else
301 {
302 fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
303 if (!fCam)
304 {
305 fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
306 if (!fCam)
307 {
308 *fLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
309 return kFALSE;
310 }
311 fCam->Init(*fGeom);
312 }
313 }
314
315 fFirstHiGain = signal->GetFirstUsedSliceHiGain();
316 fLastHiGain = signal->GetLastUsedSliceHiGain();
317 fFirstLoGain = signal->GetFirstUsedSliceLoGain();
318 fLastLoGain = signal->GetLastUsedSliceLoGain();
319
320 /*
321 const Float_t numhigain = signal->GetNumUsedHiGainFADCSlices();
322 const Float_t numlogain = signal->GetNumUsedLoGainFADCSlices();
323
324
325 if (fCam)
326 {
327 if (fCam->GetNumHiGainFADCSlices() == 0.)
328 fCam->SetNumHiGainFADCSlices ( numhigain );
329 else if (fCam->GetNumHiGainFADCSlices() != numhigain)
330 {
331 *fLog << err << GetDescriptor()
332 << ": Number of High Gain FADC extraction slices has changed, abort..." << endl;
333 return kFALSE;
334 }
335
336 if (fCam->GetNumLoGainFADCSlices() == 0.)
337 fCam->SetNumLoGainFADCSlices ( numlogain );
338 else if (fCam->GetNumLoGainFADCSlices() != numlogain)
339 {
340 *fLog << err << GetDescriptor()
341 << ": Number of Low Gain FADC extraction slices has changes, abort..." << endl;
342 return kFALSE;
343 }
344 }
345 */
346
347 const Int_t npixels = fGeom->GetNumPixels();
348 const Int_t nsectors = fGeom->GetNumSectors();
349 const Int_t nareas = fGeom->GetNumAreas();
350
351 InitHiGainArrays(npixels,nareas,nsectors);
352 InitLoGainArrays(npixels,nareas,nsectors);
353
354 fSumhiarea .Set(nareas);
355 fSumloarea .Set(nareas);
356 fTimehiarea .Set(nareas);
357 fTimeloarea .Set(nareas);
358 fSumhisector.Set(nsectors);
359 fSumlosector.Set(nsectors);
360 fTimehisector.Set(nsectors);
361 fTimelosector.Set(nsectors);
362
363 fSathiarea .Set(nareas);
364 fSatloarea .Set(nareas);
365 fSathisector.Set(nsectors);
366 fSatlosector.Set(nsectors);
367
368 return kTRUE;
369}
370
371// --------------------------------------------------------------------------
372//
373// Retrieve:
374// - fRunHeader->GetNumSamplesHiGain();
375//
376// Initializes the High Gain Arrays:
377//
378// - Expand fHiGainArrays to npixels
379// - Expand fAverageHiGainAreas to nareas
380// - Expand fAverageHiGainSectors to nsectors
381//
382// - For every entry in the expanded arrays:
383// * Initialize an MHCalibrationPix
384// * Set Binning from fNbins, fFirst and fLast
385// * Set Binning of Abs Times histogram from fAbsNbins, fAbsFirst and fAbsLast
386// * Set Histgram names and titles from fHistName and fHistTitle
387// * Set Abs Times Histgram names and titles from fAbsHistName and fAbsHistTitle
388// * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
389// * Set X-axis and Y-axis titles of Abs Times Histogram from fAbsHistXTitle and fAbsHistYTitle
390// * Call InitHists
391//
392//
393void MHCalibrationChargeCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
394{
395
396 TH1F *h;
397
398 const Int_t higainsamples = fRunHeader->GetNumSamplesHiGain();
399
400 if (fHiGainArray->GetEntries()==0)
401 {
402 fHiGainArray->Expand(npixels);
403 for (Int_t i=0; i<npixels; i++)
404 {
405 (*fHiGainArray)[i] = new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"HiGainPix"),
406 Form("%s%s",fHistTitle.Data()," High Gain Pixel"));
407
408 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)(*this)[i];
409
410 pix.SetNbins(fNbins);
411 pix.SetFirst(fFirst);
412 pix.SetLast (fLast);
413
414 pix.SetAbsTimeNbins(higainsamples);
415 pix.SetAbsTimeFirst(-0.5);
416 pix.SetAbsTimeLast(higainsamples-0.5);
417
418 h = pix.GetHGausHist();
419
420 h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainPix"));
421 h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Pixel "));
422 h->SetXTitle(fHistXTitle.Data());
423 h->SetYTitle(fHistYTitle.Data());
424
425 h = pix.GetHAbsTime();
426
427 h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainPix"));
428 h->SetTitle(Form("%s%s",fAbsHistTitle.Data()," High Gain Pixel "));
429 h->SetXTitle(fAbsHistXTitle.Data());
430 h->SetYTitle(fAbsHistYTitle.Data());
431
432 InitHists((*this)[i],(*fBadPixels)[i],i);
433 }
434 }
435
436
437 if (fAverageHiGainAreas->GetEntries()==0)
438 {
439 fAverageHiGainAreas->Expand(nareas);
440
441 for (Int_t j=0; j<nareas; j++)
442 {
443 (*fAverageHiGainAreas)[j] =
444 new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"HiGainArea"),
445 Form("%s%s",fHistTitle.Data()," High Gain Area Idx "));
446
447 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
448
449 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
450 pix.SetFirst(fFirst);
451 pix.SetLast (fLast);
452
453 pix.SetAbsTimeNbins(higainsamples);
454 pix.SetAbsTimeFirst(-0.5);
455 pix.SetAbsTimeLast(higainsamples-0.5);
456
457 h = pix.GetHGausHist();
458
459 h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainArea"));
460 h->SetXTitle(fHistXTitle.Data());
461 h->SetYTitle(fHistYTitle.Data());
462
463 if (fGeom->InheritsFrom("MGeomCamMagic"))
464 {
465 h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
466 j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
467 pix.InitBins();
468 pix.SetEventFrequency(fPulserFrequency);
469 }
470 else
471 {
472 h->SetTitle(Form("%s%s",fHistTitle.Data(),
473 " averaged on event-by-event basis High Gain Area Idx "));
474 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
475 }
476
477 h = pix.GetHAbsTime();
478
479 h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainArea"));
480 h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
481 " averaged on event-by-event basis High Gain Area Idx "));
482 h->SetXTitle(fAbsHistXTitle.Data());
483 h->SetYTitle(fAbsHistYTitle.Data());
484 }
485 }
486
487 if (fAverageHiGainSectors->GetEntries()==0)
488 {
489 fAverageHiGainSectors->Expand(nsectors);
490
491 for (Int_t j=0; j<nsectors; j++)
492 {
493 (*fAverageHiGainSectors)[j] =
494 new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"HiGainSector"),
495 Form("%s%s",fHistTitle.Data()," High Gain Sector "));
496
497 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
498
499 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
500 pix.SetFirst(fFirst);
501 pix.SetLast (fLast);
502
503 pix.SetAbsTimeNbins(higainsamples);
504 pix.SetAbsTimeFirst(-0.5);
505 pix.SetAbsTimeLast(higainsamples-0.5);
506
507 h = pix.GetHGausHist();
508
509 h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainSector"));
510 h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Sector "));
511 h->SetXTitle(fHistXTitle.Data());
512 h->SetYTitle(fHistYTitle.Data());
513
514 h = pix.GetHAbsTime();
515
516 h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainSector"));
517 h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
518 " averaged on event-by-event basis High Gain Area Sector "));
519 h->SetXTitle(fAbsHistXTitle.Data());
520 h->SetYTitle(fAbsHistYTitle.Data());
521
522 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
523 }
524 }
525}
526
527//--------------------------------------------------------------------------------------
528//
529// Return, if IsLoGain() is kFALSE
530//
531// Retrieve:
532// - fRunHeader->GetNumSamplesHiGain();
533//
534// Initializes the Low Gain Arrays:
535//
536// - Expand fLoGainArrays to npixels
537// - Expand fAverageLoGainAreas to nareas
538// - Expand fAverageLoGainSectors to nsectors
539//
540// - For every entry in the expanded arrays:
541// * Initialize an MHCalibrationPix
542// * Set Binning from fNbins, fFirst and fLast
543// * Set Binning of Abs Times histogram from fAbsNbins, fAbsFirst and fAbsLast
544// * Set Histgram names and titles from fHistName and fHistTitle
545// * Set Abs Times Histgram names and titles from fAbsHistName and fAbsHistTitle
546// * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
547// * Set X-axis and Y-axis titles of Abs Times Histogram from fAbsHistXTitle and fAbsHistYTitle
548// * Call InitHists
549//
550void MHCalibrationChargeCam::InitLoGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
551{
552
553 if (!IsLoGain())
554 return;
555
556 const Int_t logainsamples = fRunHeader->GetNumSamplesLoGain();
557
558 TH1F *h;
559
560 if (fLoGainArray->GetEntries()==0 )
561 {
562 fLoGainArray->Expand(npixels);
563
564 for (Int_t i=0; i<npixels; i++)
565 {
566 (*fLoGainArray)[i] =
567 new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"LoGainPix"),
568 Form("%s%s",fHistTitle.Data()," Low Gain Pixel"));
569
570 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)(*this)(i);
571
572 pix.SetNbins(fLoGainNbins);
573 pix.SetFirst(fLoGainFirst);
574 pix.SetLast (fLoGainLast);
575
576 pix.SetAbsTimeNbins(logainsamples);
577 pix.SetAbsTimeFirst(-0.5);
578 pix.SetAbsTimeLast(logainsamples-0.5);
579
580 h = pix.GetHGausHist();
581
582 h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainPix"));
583 h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Pixel "));
584 h->SetXTitle(fHistXTitle.Data());
585 h->SetYTitle(fHistYTitle.Data());
586
587 h = pix.GetHAbsTime();
588
589 h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"HiGainPix"));
590 h->SetTitle(Form("%s%s",fAbsHistTitle.Data()," High Gain Pixel "));
591 h->SetXTitle(fAbsHistXTitle.Data());
592 h->SetYTitle(fAbsHistYTitle.Data());
593
594 InitHists(pix,(*fBadPixels)[i],i);
595 }
596 }
597
598 if (fAverageLoGainAreas->GetEntries()==0)
599 {
600 fAverageLoGainAreas->Expand(nareas);
601
602 for (Int_t j=0; j<nareas; j++)
603 {
604 (*fAverageLoGainAreas)[j] =
605 new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"LoGainArea"),
606 Form("%s%s",fHistTitle.Data()," Low Gain Area Idx "));
607
608 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
609
610 pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
611 pix.SetFirst(fLoGainFirst);
612 pix.SetLast (fLoGainLast);
613
614 pix.SetAbsTimeNbins(logainsamples);
615 pix.SetAbsTimeFirst(-0.5);
616 pix.SetAbsTimeLast(logainsamples-0.5);
617
618 h = pix.GetHGausHist();
619
620 h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainArea"));
621 h->SetXTitle(fHistXTitle.Data());
622 h->SetYTitle(fHistYTitle.Data());
623
624
625 if (fGeom->InheritsFrom("MGeomCamMagic"))
626 {
627 h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
628 j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
629 pix.InitBins();
630 pix.SetEventFrequency(fPulserFrequency);
631 }
632 else
633 {
634 h->SetTitle(Form("%s%s",fHistTitle.Data()," averaged on event-by-event basis Low Gain Area Idx "));
635 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
636 }
637
638 h = pix.GetHAbsTime();
639
640 h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"LoGainArea"));
641 h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
642 " averaged on event-by-event basis Low Gain Area Idx "));
643 h->SetXTitle(fAbsHistXTitle.Data());
644 h->SetYTitle(fAbsHistYTitle.Data());
645
646 }
647 }
648
649
650 if (fAverageLoGainSectors->GetEntries()==0 && IsLoGain())
651 {
652 fAverageLoGainSectors->Expand(nsectors);
653
654 for (Int_t j=0; j<nsectors; j++)
655 {
656 (*fAverageLoGainSectors)[j] =
657 new MHCalibrationChargePix(Form("%s%s",fHistName.Data(),"LoGainSector"),
658 Form("%s%s",fHistTitle.Data()," Low Gain Sector "));
659
660 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
661
662 pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
663 pix.SetFirst(fLoGainFirst);
664 pix.SetLast (fLoGainLast);
665
666 pix.SetAbsTimeNbins(logainsamples);
667 pix.SetAbsTimeFirst(-0.5);
668 pix.SetAbsTimeLast(logainsamples-0.5);
669
670 h = pix.GetHGausHist();
671
672 h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainSector"));
673 h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Sector "));
674 h->SetXTitle(fHistXTitle.Data());
675 h->SetYTitle(fHistYTitle.Data());
676
677 h = pix.GetHAbsTime();
678
679 h->SetName (Form("%s%s%s","H",fAbsHistName.Data(),"LoGainSector"));
680 h->SetTitle(Form("%s%s",fAbsHistTitle.Data(),
681 " averaged on event-by-event basis Low Gain Area Sector "));
682 h->SetXTitle(fAbsHistXTitle.Data());
683 h->SetYTitle(fAbsHistYTitle.Data());
684
685 //
686 // Adapt the range for the case, the intense blue is used:
687 // FIXME: this is a nasty workaround, but for the moment necessary
688 // in order to avoid default memory space.
689 //
690 if (fGeom->InheritsFrom("MGeomCamMagic"))
691 {
692 if ( fColor == MCalibrationCam::kBLUE)
693 {
694 pix.SetFirst(-10.5);
695 pix.SetLast(999.5);
696 pix.SetNbins(3030);
697 }
698 }
699
700 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
701 }
702 }
703}
704
705
706// --------------------------------------------------------------------------
707//
708// Retrieves from MExtractedSignalCam:
709// - first used LoGain FADC slice
710//
711// Retrieves from MGeomCam:
712// - number of pixels
713// - number of pixel areas
714// - number of sectors
715//
716// For all TObjArray's (including the averaged ones), the following steps are performed:
717//
718// 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
719// - MExtractedSignalPix::GetExtractedSignalHiGain();
720// - MExtractedSignalPix::GetExtractedSignalLoGain();
721//
722// 2) Set number of saturated slices (MHCalibrationChargePix::AddSaturated()) with:
723// - MExtractedSignalPix::GetNumHiGainSaturated();
724// - MExtractedSignalPix::GetNumLoGainSaturated();
725//
726// 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
727// - MRawEvtPixelIter::GetIdxMaxHiGainSample();
728// - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
729//
730Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
731{
732
733 MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
734 if (!signal)
735 {
736 *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
737 return kFALSE;
738 }
739
740 const UInt_t npixels = fGeom->GetNumPixels();
741 const UInt_t nareas = fGeom->GetNumAreas();
742 const UInt_t nsectors = fGeom->GetNumSectors();
743 const UInt_t lofirst = signal->GetFirstUsedSliceLoGain();
744
745 fSumhiarea .Reset();
746 fSumloarea .Reset();
747 fTimehiarea .Reset();
748 fTimeloarea .Reset();
749 fSumhisector.Reset();
750 fSumlosector.Reset();
751 fTimehisector.Reset();
752 fTimelosector.Reset();
753
754 fSathiarea .Reset();
755 fSatloarea .Reset();
756 fSathisector.Reset();
757 fSatlosector.Reset();
758
759 for (UInt_t i=0; i<npixels; i++)
760 {
761
762 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
763
764 if (histhi.IsExcluded())
765 continue;
766
767 const MExtractedSignalPix &pix = (*signal)[i];
768
769 const Float_t sumhi = pix.GetExtractedSignalHiGain();
770 const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
771
772 if (IsOscillations())
773 histhi.FillHistAndArray(sumhi);
774 else
775 histhi.FillHist(sumhi);
776
777 histhi.AddSaturated(sathi);
778
779 const Int_t aidx = (*fGeom)[i].GetAidx();
780 const Int_t sector = (*fGeom)[i].GetSector();
781
782 fSumhiarea[aidx] += sumhi;
783 fSathiarea[aidx] += sathi;
784
785 fSumhisector[sector] += sumhi;
786 fSathisector[sector] += sathi;
787
788 if (IsLoGain())
789 {
790 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
791 const Float_t sumlo = pix.GetExtractedSignalLoGain();
792 const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
793
794 if (IsOscillations())
795 histlo.FillHistAndArray(sumlo);
796 else
797 histlo.FillHist(sumlo);
798
799 histlo.AddSaturated(satlo);
800
801 fSumloarea[aidx] += sumlo;
802 fSatloarea[aidx] += satlo;
803 fSumlosector[sector] += sumlo;
804 fSatlosector[sector] += satlo;
805 }
806
807 }
808
809 MRawEvtPixelIter pixel(fRawEvt);
810 while (pixel.Next())
811 {
812
813 const UInt_t pixid = pixel.GetPixelId();
814
815 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
816
817 if (histhi.IsExcluded())
818 continue;
819
820 const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
821
822 histhi.FillAbsTime(timehi);
823
824 const Int_t aidx = (*fGeom)[pixid].GetAidx();
825 const Int_t sector = (*fGeom)[pixid].GetSector();
826
827 fTimehiarea [aidx] += timehi;
828 fTimehisector[sector] += timehi;
829
830 if (IsLoGain())
831 {
832 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
833
834 const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
835 histlo.FillAbsTime(timelo);
836
837 fTimeloarea[aidx] += timelo;
838 fTimelosector[sector] += timelo;
839 }
840 }
841
842 for (UInt_t j=0; j<nareas; j++)
843 {
844
845 const Int_t npix = fAverageAreaNum[j];
846
847 if (npix == 0)
848 continue;
849
850 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
851
852 if (IsOscillations())
853 hipix.FillHistAndArray(fSumhiarea [j]/npix);
854 else
855 hipix.FillHist(fSumhiarea[j]/npix);
856
857 hipix.AddSaturated ((Float_t)fSathiarea [j]/npix > 0.5 ? 1 : 0);
858 hipix.FillAbsTime (fTimehiarea[j]/npix);
859
860 if (IsLoGain())
861 {
862 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
863 if (IsOscillations())
864 lopix.FillHistAndArray(fSumloarea [j]/npix);
865 else
866 lopix.FillHist(fSumloarea [j]/npix);
867 lopix.AddSaturated ((Float_t)fSatloarea [j]/npix > 0.5 ? 1 : 0);
868 lopix.FillAbsTime (fTimeloarea[j]/npix);
869 }
870 }
871
872 for (UInt_t j=0; j<nsectors; j++)
873 {
874
875 const Int_t npix = fAverageSectorNum[j];
876
877 if (npix == 0)
878 continue;
879
880 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
881
882 if (IsOscillations())
883 hipix.FillHistAndArray(fSumhisector [j]/npix);
884 else
885 hipix.FillHist(fSumhisector [j]/npix);
886
887 hipix.AddSaturated ((Float_t)fSathisector[j]/npix > 0.5 ? 1 : 0);
888 hipix.FillAbsTime (fTimehisector[j]/npix);
889
890 if (IsLoGain())
891 {
892 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
893
894 if (IsOscillations())
895 lopix.FillHistAndArray(fSumlosector [j]/npix);
896 else
897 lopix.FillHist(fSumlosector [j]/npix);
898
899 lopix.AddSaturated ((Float_t)fSatlosector[j]/npix > 0.5 ? 1 : 0);
900 lopix.FillAbsTime (fTimelosector[j]/npix);
901 }
902 }
903
904 return kTRUE;
905}
906
907// --------------------------------------------------------------------------
908//
909// For all TObjArray's (including the averaged ones), the following steps are performed:
910//
911// 1) Returns if the pixel is excluded.
912// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
913// or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
914// 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
915// MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
916// otherwise the Hi-Gain ones.
917// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
918// with the flags:
919// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
920// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
921// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
922// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
923//
924Bool_t MHCalibrationChargeCam::FinalizeHists()
925{
926
927 *fLog << endl;
928
929 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
930 {
931
932 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
933
934 if (histhi.IsExcluded())
935 continue;
936
937 MCalibrationChargePix &pix = fIntensCam
938 ? (MCalibrationChargePix&)(*fIntensCam)[i]
939 : (MCalibrationChargePix&)(*fCam)[i];
940
941 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
942 {
943 pix.SetHiGainSaturation();
944 if (IsOscillations())
945 histhi.CreateFourierSpectrum();
946 continue;
947 }
948
949 MBadPixelsPix &bad = (*fBadPixels)[i];
950
951 Stat_t overflow = histhi.GetHGausHist()->GetBinContent(histhi.GetHGausHist()->GetNbinsX()+1);
952 if (overflow > 0.1)
953 {
954 *fLog << warn << GetDescriptor()
955 << ": HiGain Histogram Overflow occurred " << overflow
956 << " times in pixel: " << i << " (without saturation!) " << endl;
957 bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
958 }
959
960 overflow = histhi.GetHGausHist()->GetBinContent(0);
961 if (overflow > 0.1)
962 {
963 *fLog << warn << GetDescriptor()
964 << ": HiGain Histogram Underflow occurred " << overflow
965 << " times in pixel: " << i << " (without saturation!) " << endl;
966 bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
967 }
968
969 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
970 }
971
972 if (IsLoGain())
973 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
974 {
975
976 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
977 MBadPixelsPix &bad = (*fBadPixels)[i];
978
979 if (histlo.IsExcluded())
980 continue;
981
982 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
983 {
984 *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
985 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
986 if (IsOscillations())
987 histlo.CreateFourierSpectrum();
988 continue;
989 }
990
991 Stat_t overflow = histlo.GetHGausHist()->GetBinContent(histlo.GetHGausHist()->GetNbinsX()+1);
992 if (overflow > 0.1)
993 {
994 *fLog << warn << GetDescriptor()
995 << ": LoGain Histogram Overflow occurred " << overflow
996 << " times in pixel: " << i << " (without saturation!) " << endl;
997 bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow );
998 }
999
1000 overflow = histlo.GetHGausHist()->GetBinContent(0);
1001 if (overflow > 0.1)
1002 {
1003 *fLog << warn << GetDescriptor()
1004 << ": LoGain Histogram Underflow occurred " << overflow
1005 << " times in pixel: " << i << " (without saturation!) " << endl;
1006 bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow );
1007 }
1008
1009 MCalibrationChargePix &pix = fIntensCam
1010 ? (MCalibrationChargePix&)(*fIntensCam)[i]
1011 : (MCalibrationChargePix&)(*fCam)[i];
1012
1013 if (pix.IsHiGainSaturation())
1014 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1015 }
1016
1017 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
1018 {
1019
1020 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
1021 MCalibrationChargePix &pix = fIntensCam
1022 ? (MCalibrationChargePix&)fIntensCam->GetAverageArea(j)
1023 : (MCalibrationChargePix&)fCam->GetAverageArea(j);
1024
1025 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
1026 {
1027 pix.SetHiGainSaturation();
1028 if (IsOscillations())
1029 histhi.CreateFourierSpectrum();
1030 continue;
1031 }
1032
1033 MBadPixelsPix &bad = fIntensCam
1034 ? fIntensCam->GetAverageBadArea(j)
1035 : fCam->GetAverageBadArea(j);
1036
1037 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
1038 }
1039
1040 if (IsLoGain())
1041 for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
1042 {
1043
1044 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
1045
1046 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
1047 {
1048 *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
1049 histlo.CreateFourierSpectrum();
1050 continue;
1051 }
1052
1053 MCalibrationChargePix &pix = fIntensCam
1054 ? (MCalibrationChargePix&)fIntensCam->GetAverageArea(j)
1055 : (MCalibrationChargePix&)fCam->GetAverageArea(j) ;
1056
1057 if (pix.IsHiGainSaturation())
1058 {
1059 MBadPixelsPix &bad = fIntensCam
1060 ? fIntensCam->GetAverageBadArea(j)
1061 : fCam->GetAverageBadArea(j);
1062 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1063 }
1064
1065 }
1066
1067 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
1068 {
1069
1070 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
1071 MCalibrationChargePix &pix = fIntensCam
1072 ? (MCalibrationChargePix&)fIntensCam->GetAverageSector(j)
1073 : (MCalibrationChargePix&)fCam->GetAverageSector(j);
1074
1075 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
1076 {
1077 pix.SetHiGainSaturation();
1078 if (IsOscillations())
1079 histhi.CreateFourierSpectrum();
1080 continue;
1081 }
1082
1083 MBadPixelsPix &bad = fIntensCam
1084 ? fIntensCam->GetAverageBadSector(j)
1085 : fCam->GetAverageBadSector(j);
1086
1087 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
1088 }
1089
1090 if (IsLoGain())
1091 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
1092 {
1093
1094 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
1095 MBadPixelsPix &bad = fIntensCam
1096 ? fIntensCam->GetAverageBadSector(j)
1097 : fCam->GetAverageBadSector(j);
1098
1099 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
1100 {
1101 *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
1102 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
1103 if (IsOscillations())
1104 histlo.CreateFourierSpectrum();
1105 continue;
1106 }
1107
1108 MCalibrationChargePix &pix = fIntensCam
1109 ? (MCalibrationChargePix&)fIntensCam->GetAverageSector(j)
1110 : (MCalibrationChargePix&)fCam->GetAverageSector(j);
1111
1112 if (pix.IsHiGainSaturation())
1113 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1114 }
1115
1116 //
1117 // Perform the fitting for the High Gain (done in MHCalibrationCam)
1118 //
1119 FitHiGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
1120 *fBadPixels,
1121 MBadPixelsPix::kHiGainNotFitted,
1122 MBadPixelsPix::kHiGainOscillating);
1123
1124 //
1125 // Perform the fitting for the Low Gain (done in MHCalibrationCam)
1126 //
1127 if (IsLoGain())
1128 FitLoGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
1129 *fBadPixels,
1130 MBadPixelsPix::kLoGainNotFitted,
1131 MBadPixelsPix::kLoGainOscillating);
1132
1133 return kTRUE;
1134}
1135
1136// --------------------------------------------------------------------------------
1137//
1138// Fill the absolute time results into MCalibrationChargePix
1139//
1140// Check absolute time validity:
1141// - Mean arrival time is at least fTimeLowerLimit slices from the lower edge
1142// - Mean arrival time is at least fUpperLimit slices from the upper edge
1143//
1144void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
1145 Byte_t first, Byte_t last)
1146{
1147
1148 const Float_t mean = hist.GetAbsTimeMean();
1149 const Float_t rms = hist.GetAbsTimeRms();
1150
1151 pix.SetAbsTimeMean ( mean );
1152 pix.SetAbsTimeRms ( rms );
1153
1154 const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
1155 const Float_t upperlimit = (Float_t)last + fTimeUpperLimit;
1156
1157 if ( mean < lowerlimit)
1158 {
1159 *fLog << warn << GetDescriptor()
1160 << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," smaller than ",fTimeLowerLimit,
1161 " FADC slices from lower edge in pixel ",hist.GetPixId()) << endl;
1162 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
1163 }
1164
1165 if ( mean > upperlimit )
1166 {
1167 *fLog << warn << GetDescriptor()
1168 << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," greater than ",fTimeUpperLimit,
1169 " FADC slices from upper edge in pixel ",hist.GetPixId()) << endl;
1170 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
1171 }
1172}
1173
1174// --------------------------------------------------------------------------
1175//
1176// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
1177// - MBadPixelsPix::kLoGainSaturation
1178//
1179// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
1180// - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
1181// - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
1182// - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
1183// - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
1184//
1185void MHCalibrationChargeCam::FinalizeBadPixels()
1186{
1187
1188 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
1189 {
1190
1191 MBadPixelsPix &bad = (*fBadPixels)[i];
1192 MCalibrationPix &pix = fIntensCam ? (*fIntensCam)[i] : (*fCam)[i];
1193
1194 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
1195 if (!pix.IsHiGainSaturation())
1196 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1197
1198 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
1199 if (pix.IsHiGainSaturation())
1200 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1201
1202 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
1203 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
1204
1205 if (IsOscillations())
1206 {
1207 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
1208 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1209
1210 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
1211 if (pix.IsHiGainSaturation())
1212 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1213 }
1214 }
1215}
1216
1217// --------------------------------------------------------------------------
1218//
1219// Dummy, needed by MCamEvent
1220//
1221Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
1222{
1223 return kTRUE;
1224}
1225
1226// --------------------------------------------------------------------------
1227//
1228// Calls MHCalibrationPix::DrawClone() for pixel idx
1229//
1230void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
1231{
1232 (*this)[idx].DrawClone();
1233}
1234
1235
1236// -----------------------------------------------------------------------------
1237//
1238// Default draw:
1239//
1240// Displays the averaged areas, both High Gain and Low Gain
1241//
1242// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1243//
1244void MHCalibrationChargeCam::Draw(const Option_t *opt)
1245{
1246
1247 const Int_t nareas = fAverageHiGainAreas->GetEntries();
1248 if (nareas == 0)
1249 return;
1250
1251 TString option(opt);
1252 option.ToLower();
1253
1254 if (!option.Contains("datacheck"))
1255 {
1256 MHCalibrationCam::Draw(opt);
1257 return;
1258 }
1259
1260 //
1261 // From here on , the datacheck - Draw
1262 //
1263 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
1264 pad->SetBorderMode(0);
1265 pad->Divide(1,nareas);
1266
1267 //
1268 // Loop over inner and outer pixels
1269 //
1270 for (Int_t i=0; i<nareas;i++)
1271 {
1272
1273 pad->cd(i+1);
1274
1275 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
1276 //
1277 // Ask for Hi-Gain saturation
1278 //
1279 if (hipix.GetSaturated() > fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries() && IsLoGain())
1280 {
1281 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
1282 DrawDataCheckPixel(lopix,i ? gkLoGainOuterRefLines : gkLoGainInnerRefLines);
1283 }
1284 else
1285 DrawDataCheckPixel(hipix,i ? gkHiGainOuterRefLines : gkHiGainInnerRefLines);
1286 }
1287}
1288
1289
1290// --------------------------------------------------------------------------
1291//
1292// Our own clone function is necessary since root 3.01/06 or Mars 0.4
1293// I don't know the reason.
1294//
1295// Creates new MHCalibrationChargeCam only for the Averaged Areas,
1296// the rest has to be retrieved directly, e.g. via:
1297// MHCalibrationChargeCam *cam = MParList::FindObject("MHCalibrationChargeCam");
1298// - cam->GetAverageSector(5).DrawClone();
1299// - (*cam)[100].DrawClone()
1300//
1301TObject *MHCalibrationChargeCam::Clone(const char *name) const
1302{
1303
1304 const Int_t navhi = fAverageHiGainAreas->GetEntries();
1305 // const Int_t nsehi = fAverageHiGainSectors->GetEntries();
1306 // const Int_t nselo = fAverageLoGainSectors->GetEntries();
1307
1308 //
1309 // FIXME, this might be done faster and more elegant, by direct copy.
1310 //
1311 MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
1312
1313 cam->fColor = fColor;
1314 cam->fPulserFrequency = fPulserFrequency;
1315 cam->fFlags = fFlags;
1316 cam->fRunNumbers = fRunNumbers;
1317 cam->fNbins = fNbins;
1318 cam->fFirst = fFirst;
1319 cam->fLast = fLast;
1320
1321 if (!IsAverageing())
1322 return cam;
1323
1324 cam->fAverageHiGainAreas->Expand(navhi);
1325
1326 for (int i=0; i<navhi; i++)
1327 (*cam->fAverageHiGainAreas) [i] = (*fAverageHiGainAreas) [i]->Clone();
1328 // cam->fAverageHiGainSectors->Expand(nsehi);
1329 // for (int i=0; i<nsehi; i++)
1330 // (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
1331
1332 if (IsLoGain())
1333 {
1334 const Int_t navlo = fAverageLoGainAreas->GetEntries();
1335 cam->fAverageLoGainAreas->Expand(navlo);
1336
1337 for (int i=0; i<navlo; i++)
1338 (*cam->fAverageLoGainAreas) [i] = (*fAverageLoGainAreas) [i]->Clone();
1339 // cam->fAverageLoGainSectors->Expand(nselo);
1340 // for (int i=0; i<nselo; i++)
1341 // (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
1342 }
1343
1344 cam->fAverageAreaNum = fAverageAreaNum;
1345 cam->fAverageAreaSat = fAverageAreaSat;
1346 cam->fAverageAreaSigma = fAverageAreaSigma;
1347 cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
1348 cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
1349 cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
1350 cam->fAverageSectorNum = fAverageSectorNum;
1351
1352 return cam;
1353
1354}
1355
1356// -----------------------------------------------------------------------------
1357//
1358// Draw the average pixel for the datacheck:
1359//
1360// Displays the averaged areas, both High Gain and Low Gain
1361//
1362// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1363//
1364void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[])
1365{
1366
1367 TVirtualPad *newpad = gPad;
1368 newpad->Divide(1,2);
1369 newpad->cd(1);
1370
1371 gPad->SetTicks();
1372 if (!pix.IsEmpty() && !pix.IsOnlyOverflow() && !pix.IsOnlyUnderflow())
1373 gPad->SetLogy();
1374
1375 TH1F *hist = pix.GetHGausHist();
1376
1377 TH1F *null = new TH1F("Null",hist->GetTitle(),100,
1378 pix.GetFirst() > 0. ? pix.GetFirst() : 0.,
1379 pix.GetLast() > pix.GetFirst()
1380 ? ( pix.GetLast() > 450. ? 450. : pix.GetLast() )
1381 : pix.GetFirst()*2.);
1382
1383 null->SetMaximum(1.1*hist->GetMaximum());
1384 null->SetDirectory(NULL);
1385 null->SetBit(kCanDelete);
1386 null->SetStats(kFALSE);
1387 //
1388 // set the labels bigger
1389 //
1390 TAxis *xaxe = null->GetXaxis();
1391 TAxis *yaxe = null->GetYaxis();
1392 xaxe->CenterTitle();
1393 yaxe->CenterTitle();
1394 xaxe->SetTitleSize(0.07);
1395 yaxe->SetTitleSize(0.07);
1396 xaxe->SetTitleOffset(0.7);
1397 yaxe->SetTitleOffset(0.55);
1398 xaxe->SetLabelSize(0.06);
1399 yaxe->SetLabelSize(0.06);
1400 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
1401 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
1402
1403 null->Draw();
1404 hist->Draw("same");
1405
1406 gStyle->SetOptFit();
1407
1408 TF1 *fit = pix.GetFGausFit();
1409
1410 if (fit)
1411 {
1412 switch ( fColor )
1413 {
1414 case MCalibrationCam::kGREEN:
1415 fit->SetLineColor(kGreen);
1416 break;
1417 case MCalibrationCam::kBLUE:
1418 fit->SetLineColor(kBlue);
1419 break;
1420 case MCalibrationCam::kUV:
1421 fit->SetLineColor(106);
1422 break;
1423 case MCalibrationCam::kCT1:
1424 fit->SetLineColor(006);
1425 break;
1426 default:
1427 fit->SetLineColor(kRed);
1428 }
1429 fit->Draw("same");
1430 }
1431
1432 DisplayRefLines(null,refline);
1433
1434 newpad->cd(2);
1435 gPad->SetTicks();
1436
1437 TH1F *null2 = new TH1F("Null2",hist->GetTitle(),100,0.,pix.GetEvents()->GetSize()/pix.GetEventFrequency());
1438
1439 null2->SetMinimum(pix.GetMean()-10.*pix.GetSigma());
1440 null2->SetMaximum(pix.GetMean()+10.*pix.GetSigma());
1441 null2->SetDirectory(NULL);
1442 null2->SetBit(kCanDelete);
1443 null2->SetStats(kFALSE);
1444 //
1445 // set the labels bigger
1446 //
1447 TAxis *xaxe2 = null2->GetXaxis();
1448 TAxis *yaxe2 = null2->GetYaxis();
1449 xaxe2->CenterTitle();
1450 yaxe2->CenterTitle();
1451 xaxe2->SetTitleSize(0.07);
1452 yaxe2->SetTitleSize(0.07);
1453 xaxe2->SetTitleOffset(0.7);
1454 yaxe2->SetTitleOffset(0.55);
1455 xaxe2->SetLabelSize(0.06);
1456 yaxe2->SetLabelSize(0.06);
1457
1458 pix.CreateGraphEvents();
1459 TGraph *gr = pix.GetGraphEvents();
1460
1461 xaxe2->SetTitle(gr->GetXaxis()->GetTitle());
1462 yaxe2->SetTitle(gr->GetYaxis()->GetTitle());
1463
1464 null2->Draw();
1465
1466 pix.DrawEvents("same");
1467 return;
1468
1469}
1470
1471
1472void MHCalibrationChargeCam::DisplayRefLines(const TH1F *hist, const Float_t refline[]) const
1473{
1474
1475 TGraph *green1 = new TGraph(2);
1476 green1->SetPoint(0,refline[0],0.1);
1477 green1->SetPoint(1,refline[0],hist->GetMaximum());
1478 green1->SetBit(kCanDelete);
1479 green1->SetLineColor(kGreen);
1480 green1->SetLineStyle(2);
1481 green1->SetLineWidth(3);
1482 green1->Draw("L");
1483
1484 TGraph *green5 = new TGraph(2);
1485 green5->SetPoint(0,refline[6],0.1);
1486 green5->SetPoint(1,refline[6],hist->GetMaximum());
1487 green5->SetBit(kCanDelete);
1488 green5->SetLineColor(8);
1489 green5->SetLineStyle(2);
1490 green5->SetLineWidth(3);
1491 green5->Draw("L");
1492
1493 TGraph *blue1 = new TGraph(2);
1494 blue1->SetPoint(0,refline[1],0.1);
1495 blue1->SetPoint(1,refline[1],hist->GetMaximum());
1496 blue1->SetBit(kCanDelete);
1497 blue1->SetLineColor(227);
1498 blue1->SetLineStyle(2);
1499 blue1->SetLineWidth(3);
1500 blue1->Draw("L");
1501
1502 TGraph *blue5 = new TGraph(2);
1503 blue5->SetPoint(0,refline[2],0.1);
1504 blue5->SetPoint(1,refline[2],hist->GetMaximum());
1505 blue5->SetBit(kCanDelete);
1506 blue5->SetLineColor(68);
1507 blue5->SetLineStyle(2);
1508 blue5->SetLineWidth(3);
1509 blue5->Draw("L");
1510
1511 TGraph *blue10 = new TGraph(2);
1512 blue10->SetPoint(0,refline[3],0.1);
1513 blue10->SetPoint(1,refline[3],hist->GetMaximum());
1514 blue10->SetBit(kCanDelete);
1515 blue10->SetLineColor(4);
1516 blue10->SetLineStyle(2);
1517 blue10->SetLineWidth(3);
1518 blue10->Draw("L");
1519
1520 TGraph *uv10 = new TGraph(2);
1521 uv10->SetPoint(0,refline[4],0.1);
1522 uv10->SetPoint(1,refline[4],hist->GetMaximum());
1523 uv10->SetBit(kCanDelete);
1524 uv10->SetLineColor(106);
1525 uv10->SetLineStyle(2);
1526 uv10->SetLineWidth(3);
1527 uv10->Draw("L");
1528
1529 TGraph *ct1 = new TGraph(2);
1530 ct1->SetPoint(0,refline[5],0.1);
1531 ct1->SetPoint(1,refline[5],hist->GetMaximum());
1532 ct1->SetBit(kCanDelete);
1533 ct1->SetLineColor(6);
1534 ct1->SetLineStyle(2);
1535 ct1->SetLineWidth(3);
1536 ct1->Draw("L");
1537
1538 TLegend *leg = new TLegend(0.8,0.35,0.99,0.99);
1539 leg->SetBit(kCanDelete);
1540 leg->AddEntry(green1,"1 Led GREEN","l");
1541 leg->AddEntry(green5,"5 Leds GREEN","l");
1542 leg->AddEntry(blue1,"1 Led BLUE","l");
1543 leg->AddEntry(blue5,"5 Leds BLUE","l");
1544 leg->AddEntry(blue10,"10 Leds BLUE","l");
1545 leg->AddEntry(uv10,"10 Leds UV","l");
1546 leg->AddEntry(ct1,"CT1-Pulser","l");
1547
1548 leg->Draw();
1549}
Note: See TracBrowser for help on using the repository browser.