source: tags/Mars-V0.9.4/mhcalib/MHCalibrationChargeCam.cc

Last change on this file was 7188, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 48.4 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 TOrdCollection'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 TOrdCollection'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 TOrdCollection'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// If more than fNumHiGainSaturationLimit (default: 15%) 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// Class Version 2:
111// + Float_t fNumLoGainBlackoutLimit; // Rel. amount blackout logain events until pixel is declared unsuitable
112//
113/////////////////////////////////////////////////////////////////////////////
114#include "MHCalibrationChargeCam.h"
115#include "MHCalibrationCam.h"
116
117#include "MLog.h"
118#include "MLogManip.h"
119
120#include "MParList.h"
121
122#include "MHCalibrationChargePix.h"
123#include "MHCalibrationPix.h"
124
125#include "MCalibrationIntensityCam.h"
126#include "MCalibrationChargeCam.h"
127#include "MCalibrationChargePix.h"
128
129#include "MGeomCam.h"
130#include "MGeomPix.h"
131
132#include "MBadPixelsIntensityCam.h"
133#include "MBadPixelsCam.h"
134#include "MBadPixelsPix.h"
135
136#include "MRawEvtData.h"
137#include "MRawRunHeader.h"
138#include "MRawEvtPixelIter.h"
139
140#include "MExtractedSignalCam.h"
141#include "MExtractedSignalPix.h"
142
143#include "MArrayI.h"
144#include "MArrayD.h"
145
146#include <TOrdCollection.h>
147#include <TPad.h>
148#include <TVirtualPad.h>
149#include <TCanvas.h>
150#include <TStyle.h>
151#include <TF1.h>
152#include <TLatex.h>
153#include <TLegend.h>
154#include <TGraph.h>
155#include <TEnv.h>
156
157ClassImp(MHCalibrationChargeCam);
158
159using namespace std;
160
161const Int_t MHCalibrationChargeCam::fgChargeHiGainNbins = 500;
162const Axis_t MHCalibrationChargeCam::fgChargeHiGainFirst = -98.;
163const Axis_t MHCalibrationChargeCam::fgChargeHiGainLast = 1902.;
164const Int_t MHCalibrationChargeCam::fgChargeLoGainNbins = 500;
165const Axis_t MHCalibrationChargeCam::fgChargeLoGainFirst = -99.;
166const Axis_t MHCalibrationChargeCam::fgChargeLoGainLast = 901.;
167const Float_t MHCalibrationChargeCam::fgProbLimit = 0.00000001;
168const TString MHCalibrationChargeCam::gsHistName = "Charge";
169const TString MHCalibrationChargeCam::gsHistTitle = "Signals";
170const TString MHCalibrationChargeCam::gsHistXTitle = "Signal [FADC counts]";
171const TString MHCalibrationChargeCam::gsHistYTitle = "Nr. events";
172const TString MHCalibrationChargeCam::gsAbsHistName = "AbsTime";
173const TString MHCalibrationChargeCam::gsAbsHistTitle = "Abs. Arr. Times";
174const TString MHCalibrationChargeCam::gsAbsHistXTitle = "Time [FADC slices]";
175const TString MHCalibrationChargeCam::gsAbsHistYTitle = "Nr. events";
176const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.15;
177const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
178const Float_t MHCalibrationChargeCam::fgNumLoGainBlackoutLimit = 0.05;
179const Float_t MHCalibrationChargeCam::fgLoGainBlackoutLimit = 3.5;
180const Float_t MHCalibrationChargeCam::fgLoGainPickupLimit = 3.5;
181const Float_t MHCalibrationChargeCam::fgTimeLowerLimit = 1.;
182const Float_t MHCalibrationChargeCam::fgTimeUpperLimit = 3.;
183const TString MHCalibrationChargeCam::fgReferenceFile = "mjobs/calibrationref.rc";
184
185// --------------------------------------------------------------------------
186//
187// Default Constructor.
188//
189// Sets:
190// - all pointers to NULL
191//
192// Initializes:
193// - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
194// - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
195// - fTimeLowerLimit to fgTimeLowerLimit
196// - fTimeUpperLimit to fgTimeUpperLimit
197// - fNumLoGainBlackoutLimit to fgNumLoGainBlackoutLimit
198//
199// - fNbins to fgChargeHiGainNbins
200// - fFirst to fgChargeHiGainFirst
201// - fLast to fgChargeHiGainLast
202//
203// - fLoGainNbins to fgChargeLoGainNbins
204// - fLoGainFirst to fgChargeLoGainFirst
205// - fLoGainLast to fgChargeLoGainLast
206//
207// - fHistName to gsHistName
208// - fHistTitle to gsHistTitle
209// - fHistXTitle to gsHistXTitle
210// - fHistYTitle to gsHistYTitle
211//
212// - fAbsHistName to gsAbsHistName
213// - fAbsHistTitle to gsAbsHistTitle
214// - fAbsHistXTitle to gsAbsHistXTitle
215// - fAbsHistYTitle to gsAbsHistYTitle
216//
217MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
218 : fRawEvt(NULL)
219{
220
221 fName = name ? name : "MHCalibrationChargeCam";
222 fTitle = title ? title : "Class to fill the calibration histograms ";
223
224 SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
225 SetNumLoGainSaturationLimit(fgNumLoGainSaturationLimit);
226
227 SetNumLoGainBlackoutLimit (fgNumLoGainBlackoutLimit);
228
229 SetTimeLowerLimit();
230 SetTimeUpperLimit();
231
232 SetNbins(fgChargeHiGainNbins);
233 SetFirst(fgChargeHiGainFirst);
234 SetLast (fgChargeHiGainLast );
235
236 SetProbLimit(fgProbLimit);
237
238 SetLoGainNbins(fgChargeLoGainNbins);
239 SetLoGainFirst(fgChargeLoGainFirst);
240 SetLoGainLast (fgChargeLoGainLast );
241
242 SetHistName (gsHistName .Data());
243 SetHistTitle (gsHistTitle .Data());
244 SetHistXTitle(gsHistXTitle.Data());
245 SetHistYTitle(gsHistYTitle.Data());
246
247 SetAbsHistName (gsAbsHistName .Data());
248 SetAbsHistTitle (gsAbsHistTitle .Data());
249 SetAbsHistXTitle(gsAbsHistXTitle.Data());
250 SetAbsHistYTitle(gsAbsHistYTitle.Data());
251
252 SetReferenceFile();
253
254 fInnerRefCharge = 278.;
255 fOuterRefCharge = 282.;
256}
257
258// --------------------------------------------------------------------------
259//
260// Creates new MHCalibrationChargeCam only with the averaged areas:
261// the rest has to be retrieved directly, e.g. via:
262// MHCalibrationChargeCam *cam = MParList::FindObject("MHCalibrationChargeCam");
263// - cam->GetAverageSector(5).DrawClone();
264// - (*cam)[100].DrawClone()
265//
266TObject *MHCalibrationChargeCam::Clone(const char *) const
267{
268
269 MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
270
271 //
272 // Copy the data members
273 //
274 cam->fColor = fColor;
275 cam->fRunNumbers = fRunNumbers;
276 cam->fPulserFrequency = fPulserFrequency;
277 cam->fFlags = fFlags;
278 cam->fNbins = fNbins;
279 cam->fFirst = fFirst;
280 cam->fLast = fLast;
281 cam->fLoGainNbins = fLoGainNbins;
282 cam->fLoGainFirst = fLoGainFirst;
283 cam->fLoGainLast = fLoGainLast;
284 cam->fReferenceFile = fReferenceFile;
285
286 //
287 // Copy the MArrays
288 //
289 cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
290 cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
291 cam->fAverageAreaSat = fAverageAreaSat;
292 cam->fAverageAreaSigma = fAverageAreaSigma;
293 cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
294 cam->fAverageAreaNum = fAverageAreaNum;
295 cam->fAverageSectorNum = fAverageSectorNum;
296
297 if (!IsAverageing())
298 return cam;
299
300 const Int_t navhi = fAverageHiGainAreas->GetSize();
301
302 for (int i=0; i<navhi; i++)
303 cam->fAverageHiGainAreas->AddAt(GetAverageHiGainArea(i).Clone(),i);
304
305 if (IsLoGain())
306 {
307
308 const Int_t navlo = fAverageLoGainAreas->GetSize();
309 for (int i=0; i<navlo; i++)
310 cam->fAverageLoGainAreas->AddAt(GetAverageLoGainArea(i).Clone(),i);
311
312 }
313
314 return cam;
315}
316
317// --------------------------------------------------------------------------
318//
319// Gets the pointers to:
320// - MRawEvtData
321//
322Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
323{
324
325 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
326 if (!fRawEvt)
327 {
328 *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
329 return kFALSE;
330 }
331
332 return kTRUE;
333}
334
335// --------------------------------------------------------------------------
336//
337// Gets or creates the pointers to:
338// - MExtractedSignalCam
339// - MCalibrationChargeCam or MCalibrationIntensityChargeCam
340// - MBadPixelsCam
341//
342// Initializes the number of used FADC slices from MExtractedSignalCam
343// into MCalibrationChargeCam and test for changes in that variable
344//
345// Calls:
346// - InitHiGainArrays()
347// - InitLoGainArrays()
348//
349// Sets:
350// - fSumhiarea to nareas
351// - fSumloarea to nareas
352// - fTimehiarea to nareas
353// - fTimeloarea to nareas
354// - fSumhisector to nsectors
355// - fSumlosector to nsectors
356// - fTimehisector to nsectors
357// - fTimelosector to nsectors
358// - fSathiarea to nareas
359// - fSatloarea to nareas
360// - fSathisector to nsectors
361// - fSatlosector to nsectors
362//
363Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
364{
365
366 MExtractedSignalCam *signal =
367 (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
368 if (!signal)
369 {
370 *fLog << err << "MExtractedSignalCam not found... abort." << endl;
371 return kFALSE;
372 }
373
374 if (!InitCams(pList,"Charge"))
375 return kFALSE;
376
377 fFirstHiGain = signal->GetFirstUsedSliceHiGain();
378 fLastHiGain = signal->GetLastUsedSliceHiGain();
379 fFirstLoGain = signal->GetFirstUsedSliceLoGain();
380 fLastLoGain = signal->GetLastUsedSliceLoGain();
381
382 const Int_t npixels = fGeom->GetNumPixels();
383 const Int_t nsectors = fGeom->GetNumSectors();
384 const Int_t nareas = fGeom->GetNumAreas();
385
386 //
387 // In case of the intense blue, double the range
388 //
389 if (fGeom->InheritsFrom("MGeomCamMagic"))
390 if ( fColor == MCalibrationCam::kBLUE)
391 SetLoGainLast(2.*fLoGainLast - fLoGainFirst);
392
393 InitHiGainArrays(npixels,nareas,nsectors);
394 InitLoGainArrays(npixels,nareas,nsectors);
395
396 fSumhiarea .Set(nareas);
397 fSumloarea .Set(nareas);
398 fTimehiarea .Set(nareas);
399 fTimeloarea .Set(nareas);
400 fSumhisector.Set(nsectors);
401 fSumlosector.Set(nsectors);
402 fTimehisector.Set(nsectors);
403 fTimelosector.Set(nsectors);
404
405 fSathiarea .Set(nareas);
406 fSatloarea .Set(nareas);
407 fSathisector.Set(nsectors);
408 fSatlosector.Set(nsectors);
409
410 return kTRUE;
411}
412
413// --------------------------------------------------------------------------
414//
415// Retrieve:
416// - fRunHeader->GetNumSamplesHiGain();
417//
418// Initializes the High Gain Arrays:
419//
420// - For every entry in the expanded arrays:
421// * Initialize an MHCalibrationChargePix
422// * Set Binning from fNbins, fFirst and fLast
423// * Set Binning of Abs Times histogram from fAbsNbins, fAbsFirst and fAbsLast
424// * Set Histgram names and titles from fHistName and fHistTitle
425// * Set Abs Times Histgram names and titles from fAbsHistName and fAbsHistTitle
426// * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
427// * Set X-axis and Y-axis titles of Abs Times Histogram from fAbsHistXTitle and fAbsHistYTitle
428// * Call InitHists
429//
430//
431void MHCalibrationChargeCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
432{
433
434 MBadPixelsCam *badcam = fIntensBad
435 ? (MBadPixelsCam*) fIntensBad->GetCam() : fBadPixels;
436
437 TH1F *h;
438
439 const Int_t higainsamples = fRunHeader->GetNumSamplesHiGain();
440
441 if (fHiGainArray->GetSize()==0)
442 {
443 for (Int_t i=0; i<npixels; i++)
444 {
445 fHiGainArray->AddAt(new MHCalibrationChargePix(Form("%sHiGainPix%04d",fHistName.Data(),i),
446 Form("%s High Gain Pixel%04d",fHistTitle.Data(),i)),i);
447
448 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)(*this)[i];
449
450 pix.SetNbins(fNbins);
451 pix.SetFirst(fFirst);
452 pix.SetLast (fLast);
453
454 pix.SetProbLimit(fProbLimit);
455
456 pix.SetAbsTimeNbins(higainsamples);
457 pix.SetAbsTimeFirst(-0.5);
458 pix.SetAbsTimeLast(higainsamples-0.5);
459
460 InitHists(pix,(*badcam)[i],i);
461
462 h = pix.GetHAbsTime();
463
464 h->SetName (Form("H%sHiGainPix%04d",fAbsHistName.Data(),i));
465 h->SetTitle(Form("%s High Gain Pixel %04d",fAbsHistTitle.Data(),i));
466 h->SetXTitle(fAbsHistXTitle.Data());
467 h->SetYTitle(fAbsHistYTitle.Data());
468 }
469 }
470
471
472 if (fAverageHiGainAreas->GetSize()==0)
473 {
474 for (Int_t j=0; j<nareas; j++)
475 {
476 fAverageHiGainAreas->AddAt(new MHCalibrationChargePix(Form("%sHiGainArea%d",fHistName.Data(),j),
477 Form("%s High Gain Area Idx %d",fHistTitle.Data(),j)),j);
478
479 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
480
481 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
482 pix.SetFirst(fFirst);
483 pix.SetLast (fLast);
484
485 pix.SetAbsTimeNbins(higainsamples);
486 pix.SetAbsTimeFirst(-0.5);
487 pix.SetAbsTimeLast(higainsamples-0.5);
488
489 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
490
491 h = pix.GetHAbsTime();
492
493 h->SetName (Form("H%sHiGainArea%d",fAbsHistName.Data(),j));
494 h->SetTitle(Form("%s%s%d",fAbsHistTitle.Data(),
495 " averaged on event-by-event basis High Gain Area Idx ",j));
496 h->SetXTitle(fAbsHistXTitle.Data());
497 h->SetYTitle(fAbsHistYTitle.Data());
498 }
499 }
500
501 if (fAverageHiGainSectors->GetSize()==0)
502 {
503 for (Int_t j=0; j<nsectors; j++)
504 {
505 fAverageHiGainSectors->AddAt(new MHCalibrationChargePix(Form("%sHiGainSector%02d",fHistName.Data(),j),
506 Form("%s High Gain Sector %02d",fHistTitle.Data(),j)),j);
507
508 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
509
510 pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
511 pix.SetFirst(fFirst);
512 pix.SetLast (fLast);
513
514 pix.SetAbsTimeNbins(higainsamples);
515 pix.SetAbsTimeFirst(-0.5);
516 pix.SetAbsTimeLast(higainsamples-0.5);
517
518 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
519
520 h = pix.GetHAbsTime();
521
522 h->SetName (Form("H%sHiGainSector%02d",fAbsHistName.Data(),j));
523 h->SetTitle(Form("%s%s%02d",fAbsHistTitle.Data(),
524 " averaged on event-by-event basis High Gain Area Sector ",j));
525 h->SetXTitle(fAbsHistXTitle.Data());
526 h->SetYTitle(fAbsHistYTitle.Data());
527 }
528 }
529}
530
531//--------------------------------------------------------------------------------------
532//
533// Return, if IsLoGain() is kFALSE
534//
535// Retrieve:
536// - fRunHeader->GetNumSamplesHiGain();
537//
538// Initializes the Low Gain Arrays:
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
557 MBadPixelsCam *badcam = fIntensBad
558 ? (MBadPixelsCam*) fIntensBad->GetCam() : fBadPixels;
559
560 const Int_t logainsamples = fRunHeader->GetNumSamplesLoGain();
561
562 TH1F *h;
563
564 if (fLoGainArray->GetSize()==0 )
565 {
566 for (Int_t i=0; i<npixels; i++)
567 {
568 fLoGainArray->AddAt(new MHCalibrationChargePix(Form("%sLoGainPix%04d",fHistName.Data(),i),
569 Form("%s Low Gain Pixel %04d",fHistTitle.Data(),i)),i);
570
571 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)(*this)(i);
572
573 pix.SetNbins(fLoGainNbins);
574 pix.SetFirst(fLoGainFirst);
575 pix.SetLast (fLoGainLast);
576
577 pix.SetProbLimit(fProbLimit);
578
579 pix.SetAbsTimeNbins(logainsamples);
580 pix.SetAbsTimeFirst(-0.5);
581 pix.SetAbsTimeLast(logainsamples-0.5);
582 pix.SetPickupLimit(fgLoGainPickupLimit);
583 pix.SetBlackoutLimit(fgLoGainBlackoutLimit);
584
585 InitHists(pix,(*badcam)[i],i);
586
587 h = pix.GetHAbsTime();
588
589 h->SetName (Form("H%sLoGainPix%04d",fAbsHistName.Data(),i));
590 h->SetTitle(Form("%s Low Gain Pixel %04d",fAbsHistTitle.Data(),i));
591 h->SetXTitle(fAbsHistXTitle.Data());
592 h->SetYTitle(fAbsHistYTitle.Data());
593 }
594 }
595
596 if (fAverageLoGainAreas->GetSize()==0)
597 {
598 for (Int_t j=0; j<nareas; j++)
599 {
600 fAverageLoGainAreas->AddAt(new MHCalibrationChargePix(Form("%sLoGainArea%d",fHistName.Data(),j),
601 Form("%s Low Gain Area Idx %d",fHistTitle.Data(),j)),j);
602
603 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
604
605 pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
606 pix.SetFirst(fLoGainFirst);
607 pix.SetLast (fLoGainLast);
608
609 pix.SetAbsTimeNbins(logainsamples);
610 pix.SetAbsTimeFirst(-0.5);
611 pix.SetAbsTimeLast(logainsamples-0.5);
612
613 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
614
615 h = pix.GetHAbsTime();
616
617 h->SetName (Form("H%sLoGainArea%02d",fAbsHistName.Data(),j));
618 h->SetTitle(Form("%s%s%02d",fAbsHistTitle.Data(),
619 " averaged on event-by-event basis Low Gain Area Idx ",j));
620 h->SetXTitle(fAbsHistXTitle.Data());
621 h->SetYTitle(fAbsHistYTitle.Data());
622 }
623 }
624
625
626 if (fAverageLoGainSectors->GetSize()==0 && IsLoGain())
627 {
628 for (Int_t j=0; j<nsectors; j++)
629 {
630 fAverageLoGainSectors->AddAt(new MHCalibrationChargePix(Form("%sLoGainSector%02d",fHistName.Data(),j),
631 Form("%s Low Gain Sector %02d",fHistTitle.Data(),j)),j);
632
633 MHCalibrationChargePix &pix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
634
635 pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
636 pix.SetFirst(fLoGainFirst);
637 pix.SetLast (fLoGainLast);
638
639 pix.SetAbsTimeNbins(logainsamples);
640 pix.SetAbsTimeFirst(-0.5);
641 pix.SetAbsTimeLast(logainsamples-0.5);
642
643 InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
644
645 h = pix.GetHAbsTime();
646
647 h->SetName (Form("H%sLoGainSector%02d",fAbsHistName.Data(),j));
648 h->SetTitle(Form("%s%s%02d",fAbsHistTitle.Data(),
649 " averaged on event-by-event basis Low Gain Area Sector ",j));
650 h->SetXTitle(fAbsHistXTitle.Data());
651 h->SetYTitle(fAbsHistYTitle.Data());
652 }
653 }
654}
655
656
657// --------------------------------------------------------------------------
658//
659// Retrieves from MExtractedSignalCam:
660// - first used LoGain FADC slice
661//
662// Retrieves from MGeomCam:
663// - number of pixels
664// - number of pixel areas
665// - number of sectors
666//
667// For all TOrdCollection's (including the averaged ones), the following steps are performed:
668//
669// 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
670// - MExtractedSignalPix::GetExtractedSignalHiGain();
671// - MExtractedSignalPix::GetExtractedSignalLoGain();
672//
673// 2) Set number of saturated slices (MHCalibrationChargePix::AddSaturated()) with:
674// - MExtractedSignalPix::GetNumHiGainSaturated();
675// - MExtractedSignalPix::GetNumLoGainSaturated();
676//
677// 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
678// - MRawEvtPixelIter::GetIdxMaxHiGainSample();
679// - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
680//
681Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
682{
683
684 MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
685 if (!signal)
686 {
687 *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
688 return kFALSE;
689 }
690
691 const UInt_t npixels = fGeom->GetNumPixels();
692 const UInt_t nareas = fGeom->GetNumAreas();
693 const UInt_t nsectors = fGeom->GetNumSectors();
694 const UInt_t lofirst = signal->GetFirstUsedSliceLoGain();
695
696 fSumhiarea .Reset();
697 fSumloarea .Reset();
698 fTimehiarea .Reset();
699 fTimeloarea .Reset();
700 fSumhisector.Reset();
701 fSumlosector.Reset();
702 fTimehisector.Reset();
703 fTimelosector.Reset();
704
705 fSathiarea .Reset();
706 fSatloarea .Reset();
707 fSathisector.Reset();
708 fSatlosector.Reset();
709
710 for (UInt_t i=0; i<npixels; i++)
711 {
712
713 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
714
715 if (histhi.IsExcluded())
716 continue;
717
718 const MExtractedSignalPix &pix = (*signal)[i];
719
720 const Float_t sumhi = pix.GetExtractedSignalHiGain();
721 const Bool_t sathi = pix.GetNumHiGainSaturated()>0;
722
723 if (IsOscillations())
724 histhi.FillHistAndArray(sumhi);
725 else
726 histhi.FillHist(sumhi);
727
728 histhi.AddSaturated(sathi);
729
730 const Int_t aidx = (*fGeom)[i].GetAidx();
731 const Int_t sector = (*fGeom)[i].GetSector();
732
733 fSumhiarea[aidx] += sumhi;
734 fSumhisector[sector] += sumhi;
735 if (sathi)
736 {
737 fSathiarea[aidx]++;
738 fSathisector[sector]++;
739 }
740
741 if (IsLoGain())
742 {
743 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
744 const Float_t sumlo = pix.GetExtractedSignalLoGain();
745 const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
746
747 if (IsOscillations())
748 histlo.FillHistAndArray(sumlo);
749 else
750 histlo.FillHist(sumlo);
751
752 histlo.AddSaturated(satlo);
753
754 fSumloarea[aidx] += sumlo;
755 fSatloarea[aidx] += satlo;
756 fSumlosector[sector] += sumlo;
757 fSatlosector[sector] += satlo;
758 }
759
760 }
761
762 MRawEvtPixelIter pixel(fRawEvt);
763 while (pixel.Next())
764 {
765
766 const UInt_t pixid = pixel.GetPixelId();
767
768 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
769
770 if (histhi.IsExcluded())
771 continue;
772
773 const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
774
775 histhi.FillAbsTime(timehi);
776
777 const Int_t aidx = (*fGeom)[pixid].GetAidx();
778 const Int_t sector = (*fGeom)[pixid].GetSector();
779
780 fTimehiarea [aidx] += timehi;
781 fTimehisector[sector] += timehi;
782
783 if (IsLoGain())
784 {
785 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
786
787 const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
788 histlo.FillAbsTime(timelo);
789
790 fTimeloarea[aidx] += timelo;
791 fTimelosector[sector] += timelo;
792 }
793 }
794
795 for (UInt_t j=0; j<nareas; j++)
796 {
797
798 const Int_t npix = fAverageAreaNum[j];
799
800 if (npix == 0)
801 continue;
802
803 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
804
805
806 if (IsOscillations())
807 hipix.FillHistAndArray(fSumhiarea [j]/npix);
808 else
809 hipix.FillHist(fSumhiarea[j]/npix);
810
811 hipix.AddSaturated ((Float_t)fSathiarea [j]/npix > 0.5 ? 1 : 0);
812 hipix.FillAbsTime (fTimehiarea[j]/npix);
813
814 if (IsLoGain())
815 {
816 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
817 if (IsOscillations())
818 lopix.FillHistAndArray(fSumloarea [j]/npix);
819 else
820 lopix.FillHist(fSumloarea [j]/npix);
821 lopix.AddSaturated ((Float_t)fSatloarea [j]/npix > 0.5 ? 1 : 0);
822 lopix.FillAbsTime (fTimeloarea[j]/npix);
823 }
824 }
825
826 for (UInt_t j=0; j<nsectors; j++)
827 {
828
829 const Int_t npix = fAverageSectorNum[j];
830
831 if (npix == 0)
832 continue;
833
834 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
835
836 if (IsOscillations())
837 hipix.FillHistAndArray(fSumhisector [j]/npix);
838 else
839 hipix.FillHist(fSumhisector [j]/npix);
840
841 hipix.AddSaturated ((Float_t)fSathisector[j]/npix > 0.5 ? 1 : 0);
842 hipix.FillAbsTime (fTimehisector[j]/npix);
843
844 if (IsLoGain())
845 {
846 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
847
848 if (IsOscillations())
849 lopix.FillHistAndArray(fSumlosector [j]/npix);
850 else
851 lopix.FillHist(fSumlosector [j]/npix);
852
853 lopix.AddSaturated ((Float_t)fSatlosector[j]/npix > 0.5 ? 1 : 0);
854 lopix.FillAbsTime (fTimelosector[j]/npix);
855 }
856 }
857
858 return kTRUE;
859}
860
861// --------------------------------------------------------------------------
862//
863// For all TOrdCollection's (including the averaged ones), the following steps are performed:
864//
865// 1) Returns if the pixel is excluded.
866// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
867// or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
868// 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag
869// MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored,
870// otherwise the Hi-Gain ones.
871// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays()
872// with the flags:
873// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
874// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
875// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
876// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
877//
878Bool_t MHCalibrationChargeCam::FinalizeHists()
879{
880
881 *fLog << endl;
882
883 TH1F *h = NULL;
884
885 MCalibrationCam *chargecam = fIntensCam ? fIntensCam->GetCam() : fCam;
886 MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
887
888
889 for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
890 {
891
892 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
893
894 if (histhi.IsExcluded())
895 continue;
896
897 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
898
899 const Int_t numsat = histhi.GetSaturated();
900
901 pix.SetNumSaturated(numsat);
902
903 if (numsat > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
904 {
905 pix.SetHiGainSaturation();
906 if (IsOscillations())
907 histhi.CreateFourierSpectrum();
908 continue;
909 }
910
911 MBadPixelsPix &bad = (*badcam)[i];
912
913 h = histhi.GetHGausHist();
914
915 Stat_t overflow = h->GetBinContent(h->GetNbinsX()+1);
916 if (overflow > fOverflowLimit*histhi.GetHGausHist()->GetEntries())
917 {
918 *fLog << warn
919 << "HiGain Hist-overflow " << overflow
920 << " times in: " << histhi.GetName() << " (w/o saturation!) " << endl;
921 bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
922 }
923
924 overflow = h->GetBinContent(0);
925 if (overflow > fOverflowLimit*histhi.GetHGausHist()->GetEntries())
926 {
927 *fLog << warn
928 << "HiGain Hist-underflow " << overflow
929 << " times in pix: " << histhi.GetName() << " (w/o saturation!) " << endl;
930 bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow );
931 }
932
933 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
934 }
935
936 if (IsLoGain())
937 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
938 {
939
940 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
941 MBadPixelsPix &bad = (*badcam)[i];
942
943 if (histlo.IsExcluded())
944 continue;
945
946 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
947 {
948 *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
949 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
950 if (IsOscillations())
951 histlo.CreateFourierSpectrum();
952 continue;
953 }
954
955 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
956 if (!pix.IsHiGainSaturation())
957 continue;
958
959 h = histlo.GetHGausHist();
960
961 Stat_t overflow = h->GetBinContent(h->GetNbinsX()+1);
962 if (overflow > fOverflowLimit*histlo.GetHGausHist()->GetEntries())
963 {
964 *fLog << warn
965 << "LoGain Hist-overflow " << overflow
966 << " times in: " << histlo.GetName() << " (w/o saturation!) " << endl;
967 bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow );
968 }
969
970 overflow = h->GetBinContent(0);
971 if (overflow > fOverflowLimit*histlo.GetHGausHist()->GetEntries())
972 {
973 *fLog << warn
974 << "LoGain Hist-underflow " << overflow
975 << " times in: " << histlo.GetName() << " (w/o saturation!) " << endl;
976 bad.SetUncalibrated( MBadPixelsPix::kLoGainOverFlow );
977 }
978
979 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
980 }
981
982 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
983 {
984
985 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
986 MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(j);
987
988 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
989 {
990 pix.SetHiGainSaturation();
991 if (IsOscillations())
992 histhi.CreateFourierSpectrum();
993 continue;
994 }
995
996 MBadPixelsPix &bad = chargecam->GetAverageBadArea(j);
997 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
998 }
999
1000 if (IsLoGain())
1001 for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
1002 {
1003
1004 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
1005
1006 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
1007 {
1008 *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
1009 if (IsOscillations())
1010 histlo.CreateFourierSpectrum();
1011 continue;
1012 }
1013
1014 MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageArea(j);
1015
1016 if (pix.IsHiGainSaturation())
1017 {
1018 MBadPixelsPix &bad = chargecam->GetAverageBadArea(j);
1019 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1020 }
1021
1022 }
1023
1024 for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
1025 {
1026
1027 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
1028 MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageSector(j);
1029
1030 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
1031 {
1032 pix.SetHiGainSaturation();
1033 if (IsOscillations())
1034 histhi.CreateFourierSpectrum();
1035 continue;
1036 }
1037
1038 MBadPixelsPix &bad = chargecam->GetAverageBadSector(j);
1039 FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
1040 }
1041
1042 if (IsLoGain())
1043 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
1044 {
1045
1046 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
1047 MBadPixelsPix &bad = chargecam->GetAverageBadSector(j);
1048
1049 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
1050 {
1051 *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
1052 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );
1053 if (IsOscillations())
1054 histlo.CreateFourierSpectrum();
1055 continue;
1056 }
1057
1058 MCalibrationChargePix &pix = (MCalibrationChargePix&)chargecam->GetAverageSector(j);
1059
1060 if (pix.IsHiGainSaturation())
1061 FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
1062 }
1063
1064 //
1065 // Perform the fitting for the High Gain (done in MHCalibrationCam)
1066 //
1067 FitHiGainArrays(*chargecam, *badcam,
1068 MBadPixelsPix::kHiGainNotFitted,
1069 MBadPixelsPix::kHiGainOscillating);
1070
1071 //
1072 // Perform the fitting for the Low Gain (done in MHCalibrationCam)
1073 //
1074 if (IsLoGain())
1075 FitLoGainArrays(*chargecam, *badcam,
1076 MBadPixelsPix::kLoGainNotFitted,
1077 MBadPixelsPix::kLoGainOscillating);
1078
1079 //
1080 // Check for pixels which have the high-gain saturated, but the low-gain
1081 // switch not applied in sufficient cases. Have to exclude these pixels,
1082 // although they not abnormal. They simply cannot be calibrated...
1083 //
1084 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
1085 {
1086
1087 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
1088 if (histlo.IsExcluded())
1089 continue;
1090
1091 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
1092 if (!pix.IsHiGainSaturation())
1093 continue;
1094
1095 //
1096 // Now,treat only low-gain calibrated pixels:
1097 //
1098 const Double_t lim = fNumLoGainBlackoutLimit*histlo.GetHGausHist()->GetEntries();
1099 if (histlo.GetBlackout() <= lim)
1100 continue;
1101
1102 MBadPixelsPix &bad = (*badcam)[i];
1103 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
1104 bad.SetUncalibrated(MBadPixelsPix::kLoGainBlackout);
1105 }
1106
1107 return kTRUE;
1108}
1109
1110// --------------------------------------------------------------------------------
1111//
1112// Fill the absolute time results into MCalibrationChargePix
1113//
1114// Check absolute time validity:
1115// - Mean arrival time is at least fTimeLowerLimit slices from the lower edge
1116// - Mean arrival time is at least fUpperLimit slices from the upper edge
1117//
1118void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
1119 Byte_t first, Byte_t last)
1120{
1121
1122 const Float_t mean = hist.GetAbsTimeMean();
1123 const Float_t rms = hist.GetAbsTimeRms();
1124
1125 pix.SetAbsTimeMean ( mean );
1126 pix.SetAbsTimeRms ( rms );
1127
1128 const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
1129 const Float_t upperlimit = (Float_t)last - fTimeUpperLimit;
1130
1131 if ( mean < lowerlimit)
1132 {
1133 *fLog << warn
1134 << Form("Mean ArrivalTime: %3.1f < %2.1f slices from lower edge: %2i in pixel %s",
1135 mean,fTimeLowerLimit,(Int_t)first,hist.GetName()) << endl;
1136 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
1137 }
1138
1139 if ( mean > upperlimit )
1140 {
1141 *fLog << warn
1142 << Form("Mean ArrivalTime: %3.1f > %2.1f slices from upper edge: %2i in pixel %s",
1143 mean,fTimeUpperLimit,(Int_t)last,hist.GetName()) << endl;
1144 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
1145 }
1146}
1147
1148// --------------------------------------------------------------------------
1149//
1150// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
1151// - MBadPixelsPix::kLoGainSaturation
1152//
1153// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
1154// - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
1155// - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
1156// - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
1157// - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
1158//
1159void MHCalibrationChargeCam::FinalizeBadPixels()
1160{
1161
1162 MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
1163 MCalibrationCam *chargecam = fIntensCam ? fIntensCam->GetCam() : fCam;
1164
1165 for (Int_t i=0; i<badcam->GetSize(); i++)
1166 {
1167
1168 MBadPixelsPix &bad = (*badcam)[i];
1169 MCalibrationPix &pix = (*chargecam)[i];
1170
1171 if (bad.IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
1172 if (!pix.IsHiGainSaturation())
1173 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1174
1175 if (bad.IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
1176 if (pix.IsHiGainSaturation())
1177 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1178
1179 if (bad.IsUncalibrated(MBadPixelsPix::kLoGainSaturation))
1180 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
1181
1182 if (IsOscillations())
1183 {
1184 if (bad.IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
1185 if (!pix.IsHiGainSaturation())
1186 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1187
1188 if (bad.IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
1189 if (pix.IsHiGainSaturation())
1190 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1191 }
1192 }
1193}
1194
1195// --------------------------------------------------------------------------
1196//
1197// Calls MHCalibrationPix::DrawClone() for pixel idx
1198//
1199void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
1200{
1201 (*this)[idx].DrawClone();
1202}
1203
1204
1205// -----------------------------------------------------------------------------
1206//
1207// Default draw:
1208//
1209// Displays the averaged areas, both High Gain and Low Gain
1210//
1211// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1212//
1213void MHCalibrationChargeCam::Draw(const Option_t *opt)
1214{
1215
1216 const Int_t nareas = fAverageHiGainAreas->GetSize();
1217 if (nareas == 0)
1218 return;
1219
1220 TString option(opt);
1221 option.ToLower();
1222
1223 if (!option.Contains("datacheck"))
1224 {
1225 MHCalibrationCam::Draw(opt);
1226 return;
1227 }
1228
1229 //
1230 // From here on , the datacheck - Draw
1231 //
1232 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
1233 pad->SetBorderMode(0);
1234 pad->Divide(1,nareas);
1235
1236 //
1237 // Loop over inner and outer pixels
1238 //
1239 for (Int_t i=0; i<nareas;i++)
1240 {
1241
1242 pad->cd(i+1);
1243
1244 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
1245 //
1246 // Ask for Hi-Gain saturation
1247 //
1248 if (hipix.GetSaturated() > fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries() && IsLoGain())
1249 {
1250 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
1251 DrawDataCheckPixel(lopix,i ? fOuterRefCharge : fInnerRefCharge);
1252 }
1253 else
1254 DrawDataCheckPixel(hipix,i ? fOuterRefCharge : fInnerRefCharge);
1255
1256 }
1257}
1258
1259// -----------------------------------------------------------------------------
1260//
1261// Draw the average pixel for the datacheck:
1262//
1263// Displays the averaged areas, both High Gain and Low Gain
1264//
1265// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1266//
1267void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline)
1268{
1269 if (pix.IsEmpty())
1270 return;
1271
1272 TVirtualPad *newpad = gPad;
1273 newpad->Divide(1,2);
1274 newpad->cd(1);
1275
1276 gPad->SetTicks();
1277 if (!pix.IsEmpty() && !pix.IsOnlyOverflow() && !pix.IsOnlyUnderflow())
1278 gPad->SetLogy();
1279
1280 TH1F *hist = pix.GetHGausHist();
1281
1282 TH1F *null = new TH1F("Null",hist->GetTitle(),100,
1283 pix.GetFirst() > 0. ? pix.GetFirst() : 0.,
1284 pix.GetLast() > pix.GetFirst()
1285 ? ( pix.GetLast() > 450.
1286 ? ( fColor == MCalibrationCam::kBLUE ? 800. : 450. )
1287 : pix.GetLast() )
1288 : pix.GetFirst()*2.);
1289
1290 null->SetMaximum(1.1*hist->GetMaximum());
1291 null->SetDirectory(NULL);
1292 null->SetBit(kCanDelete);
1293 null->SetStats(kFALSE);
1294 //
1295 // set the labels bigger
1296 //
1297 TAxis *xaxe = null->GetXaxis();
1298 TAxis *yaxe = null->GetYaxis();
1299 xaxe->CenterTitle();
1300 yaxe->CenterTitle();
1301 xaxe->SetTitleSize(0.07);
1302 yaxe->SetTitleSize(0.07);
1303 xaxe->SetTitleOffset(0.7);
1304 yaxe->SetTitleOffset(0.55);
1305 xaxe->SetLabelSize(0.06);
1306 yaxe->SetLabelSize(0.06);
1307 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
1308 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
1309
1310 null->Draw();
1311 hist->Draw("same");
1312
1313 gStyle->SetOptFit();
1314
1315 TF1 *fit = pix.GetFGausFit();
1316
1317 if (fit)
1318 {
1319 switch ( fColor )
1320 {
1321 case MCalibrationCam::kGREEN:
1322 fit->SetLineColor(kGreen);
1323 break;
1324 case MCalibrationCam::kBLUE:
1325 fit->SetLineColor(kBlue);
1326 break;
1327 case MCalibrationCam::kUV:
1328 fit->SetLineColor(106);
1329 break;
1330 case MCalibrationCam::kCT1:
1331 fit->SetLineColor(006);
1332 break;
1333 default:
1334 fit->SetLineColor(kRed);
1335 }
1336 fit->Draw("same");
1337 }
1338
1339 DisplayRefLines(null,refline);
1340
1341 newpad->cd(2);
1342 gPad->SetTicks();
1343
1344 TH1F *null2 = new TH1F("Null2",hist->GetTitle(),100,0.,pix.GetEvents()->GetSize()/pix.GetEventFrequency());
1345
1346 null2->SetMinimum(pix.GetMean()-10.*pix.GetSigma());
1347 null2->SetMaximum(pix.GetMean()+10.*pix.GetSigma());
1348 null2->SetDirectory(NULL);
1349 null2->SetBit(kCanDelete);
1350 null2->SetStats(kFALSE);
1351 //
1352 // set the labels bigger
1353 //
1354 TAxis *xaxe2 = null2->GetXaxis();
1355 TAxis *yaxe2 = null2->GetYaxis();
1356 xaxe2->CenterTitle();
1357 yaxe2->CenterTitle();
1358 xaxe2->SetTitleSize(0.07);
1359 yaxe2->SetTitleSize(0.07);
1360 xaxe2->SetTitleOffset(0.7);
1361 yaxe2->SetTitleOffset(0.55);
1362 xaxe2->SetLabelSize(0.06);
1363 yaxe2->SetLabelSize(0.06);
1364
1365 pix.CreateGraphEvents();
1366 TGraph *gr = pix.GetGraphEvents();
1367 if (gr)
1368 {
1369 xaxe2->SetTitle(gr->GetXaxis()->GetTitle());
1370 yaxe2->SetTitle(gr->GetYaxis()->GetTitle());
1371 }
1372
1373 null2->Draw();
1374
1375 pix.DrawEvents("same");
1376
1377 // newpad->cd(3);
1378 // pix.DrawPowerSpectrum(*newpad,4);
1379
1380 return;
1381
1382}
1383
1384
1385void MHCalibrationChargeCam::DisplayRefLines(const TH1F *hist, const Float_t refline) const
1386{
1387
1388 TGraph *uv10 = new TGraph(2);
1389 uv10->SetPoint(0,refline,0.);
1390 uv10->SetPoint(1,refline,hist->GetMaximum());
1391 uv10->SetBit(kCanDelete);
1392 uv10->SetLineColor(106);
1393 uv10->SetLineStyle(2);
1394 uv10->SetLineWidth(3);
1395 uv10->Draw("L");
1396
1397 TLegend *leg = new TLegend(0.8,0.55,0.99,0.99);
1398 leg->SetBit(kCanDelete);
1399 leg->AddEntry(uv10,"10 Leds UV","l");
1400
1401 leg->Draw();
1402}
1403
1404Int_t MHCalibrationChargeCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
1405{
1406
1407 Bool_t rc = kFALSE;
1408
1409 if (MHCalibrationCam::ReadEnv(env,prefix,print))
1410 rc = kTRUE;
1411
1412 if (IsEnvDefined(env, prefix, "HiGainNbins", print))
1413 {
1414 SetNbins(GetEnvValue(env, prefix, "HiGainNbins", fNbins));
1415 rc = kTRUE;
1416 }
1417
1418 if (IsEnvDefined(env, prefix, "HiGainFirst", print))
1419 {
1420 SetFirst(GetEnvValue(env, prefix, "HiGainFirst", fFirst));
1421 rc = kTRUE;
1422 }
1423
1424 if (IsEnvDefined(env, prefix, "HiGainLast", print))
1425 {
1426 SetLast(GetEnvValue(env, prefix, "HiGainLast", fLast));
1427 rc = kTRUE;
1428 }
1429
1430 if (IsEnvDefined(env, prefix, "LoGainNbins", print))
1431 {
1432 SetLoGainNbins(GetEnvValue(env, prefix, "LoGainNbins", fLoGainNbins));
1433 rc = kTRUE;
1434 }
1435
1436 if (IsEnvDefined(env, prefix, "LoGainFirst", print))
1437 {
1438 SetLoGainFirst(GetEnvValue(env, prefix, "LoGainFirst", fLoGainFirst));
1439 rc = kTRUE;
1440 }
1441
1442 if (IsEnvDefined(env, prefix, "LoGainLast", print))
1443 {
1444 SetLoGainLast(GetEnvValue(env, prefix, "LoGainLast", fLoGainLast));
1445 rc = kTRUE;
1446 }
1447
1448 if (IsEnvDefined(env, prefix, "TimeLowerLimit", print))
1449 {
1450 SetTimeLowerLimit(GetEnvValue(env, prefix, "TimeLowerLimit", fTimeLowerLimit));
1451 rc = kTRUE;
1452 }
1453
1454 if (IsEnvDefined(env, prefix, "TimeUpperLimit", print))
1455 {
1456 SetTimeUpperLimit(GetEnvValue(env, prefix, "TimeUpperLimit", fTimeUpperLimit));
1457 rc = kTRUE;
1458 }
1459
1460 if (IsEnvDefined(env, prefix, "ReferenceFile", print))
1461 {
1462 SetReferenceFile(GetEnvValue(env,prefix,"ReferenceFile",fReferenceFile.Data()));
1463 rc = kTRUE;
1464 }
1465
1466 if (IsEnvDefined(env, prefix, "NumHiGainSaturationLimit", print))
1467 {
1468 SetNumHiGainSaturationLimit(GetEnvValue(env, prefix, "NumHiGainSaturationLimit", fNumHiGainSaturationLimit));
1469 rc = kTRUE;
1470 }
1471
1472 if (IsEnvDefined(env, prefix, "NumLoGainSaturationLimit", print))
1473 {
1474 SetNumLoGainSaturationLimit(GetEnvValue(env, prefix, "NumLoGainSaturationLimit", fNumLoGainSaturationLimit));
1475 rc = kTRUE;
1476 }
1477
1478 if (IsEnvDefined(env, prefix, "NumLoGainBlackoutLimit", print))
1479 {
1480 SetNumLoGainBlackoutLimit(GetEnvValue(env, prefix, "NumLoGainBlackoutLimit", fNumLoGainBlackoutLimit));
1481 rc = kTRUE;
1482 }
1483
1484
1485 TEnv refenv(fReferenceFile);
1486
1487 fInnerRefCharge = refenv.GetValue("InnerRefCharge",fInnerRefCharge);
1488 fOuterRefCharge = refenv.GetValue("OuterRefCharge",fOuterRefCharge);
1489
1490 return rc;
1491}
Note: See TracBrowser for help on using the repository browser.