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

Last change on this file since 4991 was 4983, checked in by gaug, 20 years ago
*** empty log message ***
File size: 53.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 or MCalibrationIntensityChargeCam
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 MHCalibrationChargePix
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 MHCalibrationChargePix
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 TH1F *h = NULL;
930
931 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
932 {
933
934 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
935
936 if (histhi.IsExcluded())
937 continue;
938
939 MCalibrationChargePix &pix = fIntensCam
940 ? (MCalibrationChargePix&)(*fIntensCam)[i]
941 : (MCalibrationChargePix&)(*fCam)[i];
942
943 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
944 {
945 pix.SetHiGainSaturation();
946 if (IsOscillations())
947 histhi.CreateFourierSpectrum();
948 continue;
949 }
950
951 MBadPixelsPix &bad = (*fBadPixels)[i];
952
953 h = histhi.GetHGausHist();
954
955 Stat_t overflow = h->GetBinContent(h->GetNbinsX()+1);
956 if (overflow > 0.1)
957 {
958 *fLog << warn << GetDescriptor()
959 << ": HiGain Histogram Overflow occurred " << overflow
960 << " times in pixel: " << i << " (without saturation!) " << endl;
961 bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
962 }
963
964 overflow = h->GetBinContent(0);
965 if (overflow > 0.1)
966 {
967 *fLog << warn << GetDescriptor()
968 << ": HiGain Histogram Underflow occurred " << overflow
969 << " times in pixel: " << i << " (without saturation!) " << endl;
970 bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
971 }
972
973 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
974 }
975
976 if (IsLoGain())
977 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
978 {
979
980 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
981 MBadPixelsPix &bad = (*fBadPixels)[i];
982
983 if (histlo.IsExcluded())
984 continue;
985
986 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
987 {
988 *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
989 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
990 if (IsOscillations())
991 histlo.CreateFourierSpectrum();
992 continue;
993 }
994
995 h = histlo.GetHGausHist();
996
997 Stat_t overflow = h->GetBinContent(h->GetNbinsX()+1);
998 if (overflow > 0.1)
999 {
1000 *fLog << warn << GetDescriptor()
1001 << ": LoGain Histogram Overflow occurred " << overflow
1002 << " times in pixel: " << i << " (without saturation!) " << endl;
1003 bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow );
1004 }
1005
1006 overflow = h->GetBinContent(0);
1007 if (overflow > 0.1)
1008 {
1009 *fLog << warn << GetDescriptor()
1010 << ": LoGain Histogram Underflow occurred " << overflow
1011 << " times in pixel: " << i << " (without saturation!) " << endl;
1012 bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow );
1013 }
1014
1015 MCalibrationChargePix &pix = fIntensCam
1016 ? (MCalibrationChargePix&)(*fIntensCam)[i]
1017 : (MCalibrationChargePix&)(*fCam)[i];
1018
1019 if (pix.IsHiGainSaturation())
1020 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1021 }
1022
1023 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
1024 {
1025
1026 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
1027 MCalibrationChargePix &pix = fIntensCam
1028 ? (MCalibrationChargePix&)fIntensCam->GetAverageArea(j)
1029 : (MCalibrationChargePix&)fCam->GetAverageArea(j);
1030
1031 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
1032 {
1033 pix.SetHiGainSaturation();
1034 if (IsOscillations())
1035 histhi.CreateFourierSpectrum();
1036 continue;
1037 }
1038
1039 MBadPixelsPix &bad = fIntensCam
1040 ? fIntensCam->GetAverageBadArea(j)
1041 : fCam->GetAverageBadArea(j);
1042
1043 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
1044 }
1045
1046 if (IsLoGain())
1047 for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
1048 {
1049
1050 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
1051
1052 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
1053 {
1054 *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
1055 histlo.CreateFourierSpectrum();
1056 continue;
1057 }
1058
1059 MCalibrationChargePix &pix = fIntensCam
1060 ? (MCalibrationChargePix&)fIntensCam->GetAverageArea(j)
1061 : (MCalibrationChargePix&)fCam->GetAverageArea(j) ;
1062
1063 if (pix.IsHiGainSaturation())
1064 {
1065 MBadPixelsPix &bad = fIntensCam
1066 ? fIntensCam->GetAverageBadArea(j)
1067 : fCam->GetAverageBadArea(j);
1068 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1069 }
1070
1071 }
1072
1073 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
1074 {
1075
1076 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
1077 MCalibrationChargePix &pix = fIntensCam
1078 ? (MCalibrationChargePix&)fIntensCam->GetAverageSector(j)
1079 : (MCalibrationChargePix&)fCam->GetAverageSector(j);
1080
1081 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
1082 {
1083 pix.SetHiGainSaturation();
1084 if (IsOscillations())
1085 histhi.CreateFourierSpectrum();
1086 continue;
1087 }
1088
1089 MBadPixelsPix &bad = fIntensCam
1090 ? fIntensCam->GetAverageBadSector(j)
1091 : fCam->GetAverageBadSector(j);
1092
1093 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
1094 }
1095
1096 if (IsLoGain())
1097 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
1098 {
1099
1100 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
1101 MBadPixelsPix &bad = fIntensCam
1102 ? fIntensCam->GetAverageBadSector(j)
1103 : fCam->GetAverageBadSector(j);
1104
1105 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
1106 {
1107 *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
1108 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
1109 if (IsOscillations())
1110 histlo.CreateFourierSpectrum();
1111 continue;
1112 }
1113
1114 MCalibrationChargePix &pix = fIntensCam
1115 ? (MCalibrationChargePix&)fIntensCam->GetAverageSector(j)
1116 : (MCalibrationChargePix&)fCam->GetAverageSector(j);
1117
1118 if (pix.IsHiGainSaturation())
1119 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1120 }
1121
1122 //
1123 // Perform the fitting for the High Gain (done in MHCalibrationCam)
1124 //
1125 FitHiGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
1126 *fBadPixels,
1127 MBadPixelsPix::kHiGainNotFitted,
1128 MBadPixelsPix::kHiGainOscillating);
1129
1130 //
1131 // Perform the fitting for the Low Gain (done in MHCalibrationCam)
1132 //
1133 if (IsLoGain())
1134 FitLoGainArrays(fIntensCam ? (MCalibrationCam&)(*fIntensCam->GetCam()) : (MCalibrationCam&)(*fCam),
1135 *fBadPixels,
1136 MBadPixelsPix::kLoGainNotFitted,
1137 MBadPixelsPix::kLoGainOscillating);
1138
1139 return kTRUE;
1140}
1141
1142// --------------------------------------------------------------------------------
1143//
1144// Fill the absolute time results into MCalibrationChargePix
1145//
1146// Check absolute time validity:
1147// - Mean arrival time is at least fTimeLowerLimit slices from the lower edge
1148// - Mean arrival time is at least fUpperLimit slices from the upper edge
1149//
1150void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
1151 Byte_t first, Byte_t last)
1152{
1153
1154 const Float_t mean = hist.GetAbsTimeMean();
1155 const Float_t rms = hist.GetAbsTimeRms();
1156
1157 pix.SetAbsTimeMean ( mean );
1158 pix.SetAbsTimeRms ( rms );
1159
1160 const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
1161 const Float_t upperlimit = (Float_t)last + fTimeUpperLimit;
1162
1163 if ( mean < lowerlimit)
1164 {
1165 *fLog << warn << GetDescriptor()
1166 << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," smaller than ",fTimeLowerLimit,
1167 " FADC slices from lower edge in pixel ",hist.GetPixId()) << endl;
1168 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
1169 }
1170
1171 if ( mean > upperlimit )
1172 {
1173 *fLog << warn << GetDescriptor()
1174 << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," greater than ",fTimeUpperLimit,
1175 " FADC slices from upper edge in pixel ",hist.GetPixId()) << endl;
1176 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
1177 }
1178}
1179
1180// --------------------------------------------------------------------------
1181//
1182// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
1183// - MBadPixelsPix::kLoGainSaturation
1184//
1185// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
1186// - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
1187// - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
1188// - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
1189// - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
1190//
1191void MHCalibrationChargeCam::FinalizeBadPixels()
1192{
1193
1194 for (Int_t i=0; i<fBadPixels->GetSize(); i++)
1195 {
1196
1197 MBadPixelsPix &bad = (*fBadPixels)[i];
1198 MCalibrationPix &pix = fIntensCam ? (*fIntensCam)[i] : (*fCam)[i];
1199
1200 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
1201 if (!pix.IsHiGainSaturation())
1202 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1203
1204 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
1205 if (pix.IsHiGainSaturation())
1206 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1207
1208 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
1209 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
1210
1211 if (IsOscillations())
1212 {
1213 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
1214 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1215
1216 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
1217 if (pix.IsHiGainSaturation())
1218 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
1219 }
1220 }
1221}
1222
1223// --------------------------------------------------------------------------
1224//
1225// Dummy, needed by MCamEvent
1226//
1227Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
1228{
1229 return kTRUE;
1230}
1231
1232// --------------------------------------------------------------------------
1233//
1234// Calls MHCalibrationPix::DrawClone() for pixel idx
1235//
1236void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
1237{
1238 (*this)[idx].DrawClone();
1239}
1240
1241
1242// -----------------------------------------------------------------------------
1243//
1244// Default draw:
1245//
1246// Displays the averaged areas, both High Gain and Low Gain
1247//
1248// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1249//
1250void MHCalibrationChargeCam::Draw(const Option_t *opt)
1251{
1252
1253 const Int_t nareas = fAverageHiGainAreas->GetEntries();
1254 if (nareas == 0)
1255 return;
1256
1257 TString option(opt);
1258 option.ToLower();
1259
1260 if (!option.Contains("datacheck"))
1261 {
1262 MHCalibrationCam::Draw(opt);
1263 return;
1264 }
1265
1266 //
1267 // From here on , the datacheck - Draw
1268 //
1269 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
1270 pad->SetBorderMode(0);
1271 pad->Divide(1,nareas);
1272
1273 //
1274 // Loop over inner and outer pixels
1275 //
1276 for (Int_t i=0; i<nareas;i++)
1277 {
1278
1279 pad->cd(i+1);
1280
1281 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
1282 //
1283 // Ask for Hi-Gain saturation
1284 //
1285 if (hipix.GetSaturated() > fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries() && IsLoGain())
1286 {
1287 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
1288 DrawDataCheckPixel(lopix,i ? gkLoGainOuterRefLines : gkLoGainInnerRefLines);
1289 }
1290 else
1291 DrawDataCheckPixel(hipix,i ? gkHiGainOuterRefLines : gkHiGainInnerRefLines);
1292 }
1293}
1294
1295
1296// --------------------------------------------------------------------------
1297//
1298// Our own clone function is necessary since root 3.01/06 or Mars 0.4
1299// I don't know the reason.
1300//
1301// Creates new MHCalibrationChargeCam only for the Averaged Areas,
1302// the rest has to be retrieved directly, e.g. via:
1303// MHCalibrationChargeCam *cam = MParList::FindObject("MHCalibrationChargeCam");
1304// - cam->GetAverageSector(5).DrawClone();
1305// - (*cam)[100].DrawClone()
1306//
1307TObject *MHCalibrationChargeCam::Clone(const char *name) const
1308{
1309
1310 const Int_t navhi = fAverageHiGainAreas->GetEntries();
1311 // const Int_t nsehi = fAverageHiGainSectors->GetEntries();
1312 // const Int_t nselo = fAverageLoGainSectors->GetEntries();
1313
1314 //
1315 // FIXME, this might be done faster and more elegant, by direct copy.
1316 //
1317 MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
1318
1319 cam->fColor = fColor;
1320 cam->fPulserFrequency = fPulserFrequency;
1321 cam->fFlags = fFlags;
1322 cam->fRunNumbers = fRunNumbers;
1323 cam->fNbins = fNbins;
1324 cam->fFirst = fFirst;
1325 cam->fLast = fLast;
1326
1327 if (!IsAverageing())
1328 return cam;
1329
1330 cam->fAverageHiGainAreas->Expand(navhi);
1331
1332 for (int i=0; i<navhi; i++)
1333 (*cam->fAverageHiGainAreas) [i] = (*fAverageHiGainAreas) [i]->Clone();
1334 // cam->fAverageHiGainSectors->Expand(nsehi);
1335 // for (int i=0; i<nsehi; i++)
1336 // (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
1337
1338 if (IsLoGain())
1339 {
1340 const Int_t navlo = fAverageLoGainAreas->GetEntries();
1341 cam->fAverageLoGainAreas->Expand(navlo);
1342
1343 for (int i=0; i<navlo; i++)
1344 (*cam->fAverageLoGainAreas) [i] = (*fAverageLoGainAreas) [i]->Clone();
1345 // cam->fAverageLoGainSectors->Expand(nselo);
1346 // for (int i=0; i<nselo; i++)
1347 // (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
1348 }
1349
1350 cam->fAverageAreaNum = fAverageAreaNum;
1351 cam->fAverageAreaSat = fAverageAreaSat;
1352 cam->fAverageAreaSigma = fAverageAreaSigma;
1353 cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
1354 cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
1355 cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
1356 cam->fAverageSectorNum = fAverageSectorNum;
1357
1358 return cam;
1359
1360}
1361
1362// -----------------------------------------------------------------------------
1363//
1364// Draw the average pixel for the datacheck:
1365//
1366// Displays the averaged areas, both High Gain and Low Gain
1367//
1368// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1369//
1370void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[])
1371{
1372
1373 TVirtualPad *newpad = gPad;
1374 newpad->Divide(1,2);
1375 newpad->cd(1);
1376
1377 gPad->SetTicks();
1378 if (!pix.IsEmpty() && !pix.IsOnlyOverflow() && !pix.IsOnlyUnderflow())
1379 gPad->SetLogy();
1380
1381 TH1F *hist = pix.GetHGausHist();
1382
1383 TH1F *null = new TH1F("Null",hist->GetTitle(),100,
1384 pix.GetFirst() > 0. ? pix.GetFirst() : 0.,
1385 pix.GetLast() > pix.GetFirst()
1386 ? ( pix.GetLast() > 450. ? 450. : pix.GetLast() )
1387 : pix.GetFirst()*2.);
1388
1389 null->SetMaximum(1.1*hist->GetMaximum());
1390 null->SetDirectory(NULL);
1391 null->SetBit(kCanDelete);
1392 null->SetStats(kFALSE);
1393 //
1394 // set the labels bigger
1395 //
1396 TAxis *xaxe = null->GetXaxis();
1397 TAxis *yaxe = null->GetYaxis();
1398 xaxe->CenterTitle();
1399 yaxe->CenterTitle();
1400 xaxe->SetTitleSize(0.07);
1401 yaxe->SetTitleSize(0.07);
1402 xaxe->SetTitleOffset(0.7);
1403 yaxe->SetTitleOffset(0.55);
1404 xaxe->SetLabelSize(0.06);
1405 yaxe->SetLabelSize(0.06);
1406 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
1407 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
1408
1409 null->Draw();
1410 hist->Draw("same");
1411
1412 gStyle->SetOptFit();
1413
1414 TF1 *fit = pix.GetFGausFit();
1415
1416 if (fit)
1417 {
1418 switch ( fColor )
1419 {
1420 case MCalibrationCam::kGREEN:
1421 fit->SetLineColor(kGreen);
1422 break;
1423 case MCalibrationCam::kBLUE:
1424 fit->SetLineColor(kBlue);
1425 break;
1426 case MCalibrationCam::kUV:
1427 fit->SetLineColor(106);
1428 break;
1429 case MCalibrationCam::kCT1:
1430 fit->SetLineColor(006);
1431 break;
1432 default:
1433 fit->SetLineColor(kRed);
1434 }
1435 fit->Draw("same");
1436 }
1437
1438 DisplayRefLines(null,refline);
1439
1440 newpad->cd(2);
1441 gPad->SetTicks();
1442
1443 TH1F *null2 = new TH1F("Null2",hist->GetTitle(),100,0.,pix.GetEvents()->GetSize()/pix.GetEventFrequency());
1444
1445 null2->SetMinimum(pix.GetMean()-10.*pix.GetSigma());
1446 null2->SetMaximum(pix.GetMean()+10.*pix.GetSigma());
1447 null2->SetDirectory(NULL);
1448 null2->SetBit(kCanDelete);
1449 null2->SetStats(kFALSE);
1450 //
1451 // set the labels bigger
1452 //
1453 TAxis *xaxe2 = null2->GetXaxis();
1454 TAxis *yaxe2 = null2->GetYaxis();
1455 xaxe2->CenterTitle();
1456 yaxe2->CenterTitle();
1457 xaxe2->SetTitleSize(0.07);
1458 yaxe2->SetTitleSize(0.07);
1459 xaxe2->SetTitleOffset(0.7);
1460 yaxe2->SetTitleOffset(0.55);
1461 xaxe2->SetLabelSize(0.06);
1462 yaxe2->SetLabelSize(0.06);
1463
1464 pix.CreateGraphEvents();
1465 TGraph *gr = pix.GetGraphEvents();
1466
1467 xaxe2->SetTitle(gr->GetXaxis()->GetTitle());
1468 yaxe2->SetTitle(gr->GetYaxis()->GetTitle());
1469
1470 null2->Draw();
1471
1472 pix.DrawEvents("same");
1473 return;
1474
1475}
1476
1477
1478void MHCalibrationChargeCam::DisplayRefLines(const TH1F *hist, const Float_t refline[]) const
1479{
1480
1481 TGraph *green1 = new TGraph(2);
1482 green1->SetPoint(0,refline[0],0.1);
1483 green1->SetPoint(1,refline[0],hist->GetMaximum());
1484 green1->SetBit(kCanDelete);
1485 green1->SetLineColor(kGreen);
1486 green1->SetLineStyle(2);
1487 green1->SetLineWidth(3);
1488 green1->Draw("L");
1489
1490 TGraph *green5 = new TGraph(2);
1491 green5->SetPoint(0,refline[6],0.1);
1492 green5->SetPoint(1,refline[6],hist->GetMaximum());
1493 green5->SetBit(kCanDelete);
1494 green5->SetLineColor(8);
1495 green5->SetLineStyle(2);
1496 green5->SetLineWidth(3);
1497 green5->Draw("L");
1498
1499 TGraph *blue1 = new TGraph(2);
1500 blue1->SetPoint(0,refline[1],0.1);
1501 blue1->SetPoint(1,refline[1],hist->GetMaximum());
1502 blue1->SetBit(kCanDelete);
1503 blue1->SetLineColor(227);
1504 blue1->SetLineStyle(2);
1505 blue1->SetLineWidth(3);
1506 blue1->Draw("L");
1507
1508 TGraph *blue5 = new TGraph(2);
1509 blue5->SetPoint(0,refline[2],0.1);
1510 blue5->SetPoint(1,refline[2],hist->GetMaximum());
1511 blue5->SetBit(kCanDelete);
1512 blue5->SetLineColor(68);
1513 blue5->SetLineStyle(2);
1514 blue5->SetLineWidth(3);
1515 blue5->Draw("L");
1516
1517 TGraph *blue10 = new TGraph(2);
1518 blue10->SetPoint(0,refline[3],0.1);
1519 blue10->SetPoint(1,refline[3],hist->GetMaximum());
1520 blue10->SetBit(kCanDelete);
1521 blue10->SetLineColor(4);
1522 blue10->SetLineStyle(2);
1523 blue10->SetLineWidth(3);
1524 blue10->Draw("L");
1525
1526 TGraph *uv10 = new TGraph(2);
1527 uv10->SetPoint(0,refline[4],0.1);
1528 uv10->SetPoint(1,refline[4],hist->GetMaximum());
1529 uv10->SetBit(kCanDelete);
1530 uv10->SetLineColor(106);
1531 uv10->SetLineStyle(2);
1532 uv10->SetLineWidth(3);
1533 uv10->Draw("L");
1534
1535 TGraph *ct1 = new TGraph(2);
1536 ct1->SetPoint(0,refline[5],0.1);
1537 ct1->SetPoint(1,refline[5],hist->GetMaximum());
1538 ct1->SetBit(kCanDelete);
1539 ct1->SetLineColor(6);
1540 ct1->SetLineStyle(2);
1541 ct1->SetLineWidth(3);
1542 ct1->Draw("L");
1543
1544 TLegend *leg = new TLegend(0.8,0.35,0.99,0.99);
1545 leg->SetBit(kCanDelete);
1546 leg->AddEntry(green1,"1 Led GREEN","l");
1547 leg->AddEntry(green5,"5 Leds GREEN","l");
1548 leg->AddEntry(blue1,"1 Led BLUE","l");
1549 leg->AddEntry(blue5,"5 Leds BLUE","l");
1550 leg->AddEntry(blue10,"10 Leds BLUE","l");
1551 leg->AddEntry(uv10,"10 Leds UV","l");
1552 leg->AddEntry(ct1,"CT1-Pulser","l");
1553
1554 leg->Draw();
1555}
1556
1557Int_t MHCalibrationChargeCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
1558{
1559
1560 Bool_t rc = kFALSE;
1561
1562 if (MHCalibrationCam::ReadEnv(env,prefix,print))
1563 rc = kTRUE;
1564
1565 if (IsEnvDefined(env, prefix, "LoGainNbins", print))
1566 {
1567 SetLoGainNbins(GetEnvValue(env, prefix, "LoGainNbins", fLoGainNbins));
1568 rc = kTRUE;
1569 }
1570
1571 if (IsEnvDefined(env, prefix, "LoGainFirst", print))
1572 {
1573 SetLoGainFirst(GetEnvValue(env, prefix, "LoGainFirst", fLoGainFirst));
1574 rc = kTRUE;
1575 }
1576
1577 if (IsEnvDefined(env, prefix, "LoGainLast", print))
1578 {
1579 SetLoGainLast(GetEnvValue(env, prefix, "LoGainLast", fLoGainLast));
1580 rc = kTRUE;
1581 }
1582
1583 if (IsEnvDefined(env, prefix, "TimeLowerLimit", print))
1584 {
1585 SetTimeLowerLimit(GetEnvValue(env, prefix, "TimeLowerLimit", fTimeLowerLimit));
1586 rc = kTRUE;
1587 }
1588
1589 if (IsEnvDefined(env, prefix, "TimeUpperLimit", print))
1590 {
1591 SetTimeUpperLimit(GetEnvValue(env, prefix, "TimeUpperLimit", fTimeUpperLimit));
1592 rc = kTRUE;
1593 }
1594
1595
1596 return rc;
1597}
Note: See TracBrowser for help on using the repository browser.