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

Last change on this file since 8179 was 8147, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 48.5 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::IsHiGainSaturated();
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 Int_t sathi = pix.IsHiGainSaturated() ? 1 : 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 = pix.IsLoGainSaturated() ? 1 : 0;
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 const Float_t mean = hist.GetAbsTimeMean();
1122 const Float_t rms = hist.GetAbsTimeRms();
1123
1124 pix.SetAbsTimeMean(mean);
1125 pix.SetAbsTimeRms(rms);
1126
1127 const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
1128 const Float_t upperlimit = (Float_t)last - fTimeUpperLimit;
1129
1130 if (mean<lowerlimit)
1131 {
1132 *fLog << warn << hist.GetName() << ": Mean Arr.Time: "
1133 << Form("%4.1f < %4.1f, %3.1f", mean, TMath::Floor(first)+fTimeLowerLimit, fTimeLowerLimit)
1134 << " slices below " << Form("%2i", (Int_t)first) << endl;
1135 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
1136 }
1137
1138 if (mean>upperlimit)
1139 {
1140 *fLog << warn << hist.GetName() << ": Mean Arr.Time: "
1141 << Form("%4.1f > %4.1f, %3.1f", mean, TMath::Floor(last)-fTimeUpperLimit, fTimeUpperLimit)
1142 << " slices above " << Form("%2i", (Int_t)last) << endl;
1143 bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
1144 }
1145}
1146
1147// --------------------------------------------------------------------------
1148//
1149// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
1150// - MBadPixelsPix::kLoGainSaturation
1151//
1152// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
1153// - if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation()
1154// - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
1155// - if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation()
1156// - if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation()
1157//
1158void MHCalibrationChargeCam::FinalizeBadPixels()
1159{
1160
1161 MBadPixelsCam *badcam = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
1162 MCalibrationCam *chargecam = fIntensCam ? fIntensCam->GetCam() : fCam;
1163
1164 for (Int_t i=0; i<badcam->GetSize(); i++)
1165 {
1166
1167 MBadPixelsPix &bad = (*badcam)[i];
1168 MCalibrationPix &pix = (*chargecam)[i];
1169
1170 if (bad.IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
1171 if (!pix.IsHiGainSaturation())
1172 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1173
1174 if (bad.IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
1175 if (pix.IsHiGainSaturation())
1176 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1177
1178 if (bad.IsUncalibrated(MBadPixelsPix::kLoGainSaturation))
1179 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
1180
1181 if (IsOscillations())
1182 {
1183 if (bad.IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
1184 if (!pix.IsHiGainSaturation())
1185 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1186
1187 if (bad.IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
1188 if (pix.IsHiGainSaturation())
1189 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);
1190 }
1191 }
1192}
1193
1194// --------------------------------------------------------------------------
1195//
1196// Calls MHCalibrationPix::DrawClone() for pixel idx
1197//
1198void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
1199{
1200 (*this)[idx].DrawClone();
1201}
1202
1203
1204// -----------------------------------------------------------------------------
1205//
1206// Default draw:
1207//
1208// Displays the averaged areas, both High Gain and Low Gain
1209//
1210// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1211//
1212void MHCalibrationChargeCam::Draw(const Option_t *opt)
1213{
1214
1215 const Int_t nareas = fAverageHiGainAreas->GetSize();
1216 if (nareas == 0)
1217 return;
1218
1219 TString option(opt);
1220 option.ToLower();
1221
1222 if (!option.Contains("datacheck"))
1223 {
1224 MHCalibrationCam::Draw(opt);
1225 return;
1226 }
1227
1228 //
1229 // From here on , the datacheck - Draw
1230 //
1231 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
1232 pad->SetBorderMode(0);
1233 pad->Divide(1,nareas);
1234
1235 //
1236 // Loop over inner and outer pixels
1237 //
1238 for (Int_t i=0; i<nareas;i++)
1239 {
1240
1241 pad->cd(i+1);
1242
1243 MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
1244 //
1245 // Ask for Hi-Gain saturation
1246 //
1247 if (hipix.GetSaturated() > fNumHiGainSaturationLimit*hipix.GetHGausHist()->GetEntries() && IsLoGain())
1248 {
1249 MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
1250 DrawDataCheckPixel(lopix,i ? fOuterRefCharge : fInnerRefCharge);
1251 }
1252 else
1253 DrawDataCheckPixel(hipix,i ? fOuterRefCharge : fInnerRefCharge);
1254
1255 }
1256}
1257
1258// -----------------------------------------------------------------------------
1259//
1260// Draw the average pixel for the datacheck:
1261//
1262// Displays the averaged areas, both High Gain and Low Gain
1263//
1264// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
1265//
1266void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline)
1267{
1268 if (pix.IsEmpty())
1269 return;
1270
1271 TVirtualPad *newpad = gPad;
1272 newpad->Divide(1,2);
1273 newpad->cd(1);
1274
1275 gPad->SetTicks();
1276 if (!pix.IsEmpty() && !pix.IsOnlyOverflow() && !pix.IsOnlyUnderflow())
1277 gPad->SetLogy();
1278
1279 TH1F *hist = pix.GetHGausHist();
1280
1281 TH1F *null = new TH1F("Null",hist->GetTitle(),100,
1282 pix.GetFirst() > 0. ? pix.GetFirst() : 0.,
1283 pix.GetLast() > pix.GetFirst()
1284 ? ( pix.GetLast() > 450.
1285 ? ( fColor == MCalibrationCam::kBLUE ? 800. : 450. )
1286 : pix.GetLast() )
1287 : pix.GetFirst()*2.);
1288
1289 null->SetMaximum(1.1*hist->GetMaximum());
1290 null->SetDirectory(NULL);
1291 null->SetBit(kCanDelete);
1292 null->SetStats(kFALSE);
1293 //
1294 // set the labels bigger
1295 //
1296 TAxis *xaxe = null->GetXaxis();
1297 TAxis *yaxe = null->GetYaxis();
1298 xaxe->CenterTitle();
1299 yaxe->CenterTitle();
1300 xaxe->SetTitleSize(0.07);
1301 yaxe->SetTitleSize(0.07);
1302 xaxe->SetTitleOffset(0.7);
1303 yaxe->SetTitleOffset(0.55);
1304 xaxe->SetLabelSize(0.06);
1305 yaxe->SetLabelSize(0.06);
1306 xaxe->SetTitle(hist->GetXaxis()->GetTitle());
1307 yaxe->SetTitle(hist->GetYaxis()->GetTitle());
1308
1309 null->Draw();
1310 hist->Draw("same");
1311
1312 gStyle->SetOptFit();
1313
1314 TF1 *fit = pix.GetFGausFit();
1315
1316 if (fit)
1317 {
1318 switch ( fColor )
1319 {
1320 case MCalibrationCam::kGREEN:
1321 fit->SetLineColor(kGreen);
1322 break;
1323 case MCalibrationCam::kBLUE:
1324 fit->SetLineColor(kBlue);
1325 break;
1326 case MCalibrationCam::kUV:
1327 fit->SetLineColor(106);
1328 break;
1329 case MCalibrationCam::kCT1:
1330 fit->SetLineColor(006);
1331 break;
1332 default:
1333 fit->SetLineColor(kRed);
1334 }
1335 fit->Draw("same");
1336 }
1337
1338 DisplayRefLines(null,refline);
1339
1340 newpad->cd(2);
1341 gPad->SetTicks();
1342
1343 TH1F *null2 = new TH1F("Null2",hist->GetTitle(),100,0.,pix.GetEvents()->GetSize()/pix.GetEventFrequency());
1344
1345 null2->SetMinimum(pix.GetMean()-10.*pix.GetSigma());
1346 null2->SetMaximum(pix.GetMean()+10.*pix.GetSigma());
1347 null2->SetDirectory(NULL);
1348 null2->SetBit(kCanDelete);
1349 null2->SetStats(kFALSE);
1350 //
1351 // set the labels bigger
1352 //
1353 TAxis *xaxe2 = null2->GetXaxis();
1354 TAxis *yaxe2 = null2->GetYaxis();
1355 xaxe2->CenterTitle();
1356 yaxe2->CenterTitle();
1357 xaxe2->SetTitleSize(0.07);
1358 yaxe2->SetTitleSize(0.07);
1359 xaxe2->SetTitleOffset(0.7);
1360 yaxe2->SetTitleOffset(0.55);
1361 xaxe2->SetLabelSize(0.06);
1362 yaxe2->SetLabelSize(0.06);
1363
1364 pix.CreateGraphEvents();
1365 TGraph *gr = pix.GetGraphEvents();
1366 if (gr)
1367 {
1368 xaxe2->SetTitle(gr->GetXaxis()->GetTitle());
1369 yaxe2->SetTitle(gr->GetYaxis()->GetTitle());
1370 }
1371
1372 null2->Draw();
1373
1374 pix.DrawEvents("same");
1375
1376 // newpad->cd(3);
1377 // pix.DrawPowerSpectrum(*newpad,4);
1378
1379 return;
1380
1381}
1382
1383
1384void MHCalibrationChargeCam::DisplayRefLines(const TH1F *hist, const Float_t refline) const
1385{
1386
1387 TGraph *uv10 = new TGraph(2);
1388 uv10->SetPoint(0,refline,0.);
1389 uv10->SetPoint(1,refline,hist->GetMaximum());
1390 uv10->SetBit(kCanDelete);
1391 uv10->SetLineColor(106);
1392 uv10->SetLineStyle(2);
1393 uv10->SetLineWidth(3);
1394 uv10->Draw("L");
1395
1396 TLegend *leg = new TLegend(0.8,0.55,0.99,0.99);
1397 leg->SetBit(kCanDelete);
1398 leg->AddEntry(uv10,"10 Leds UV","l");
1399
1400 leg->Draw();
1401}
1402
1403Int_t MHCalibrationChargeCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
1404{
1405
1406 Bool_t rc = kFALSE;
1407
1408 if (MHCalibrationCam::ReadEnv(env,prefix,print))
1409 rc = kTRUE;
1410
1411 if (IsEnvDefined(env, prefix, "HiGainNbins", print))
1412 {
1413 SetNbins(GetEnvValue(env, prefix, "HiGainNbins", fNbins));
1414 rc = kTRUE;
1415 }
1416
1417 if (IsEnvDefined(env, prefix, "HiGainFirst", print))
1418 {
1419 SetFirst(GetEnvValue(env, prefix, "HiGainFirst", fFirst));
1420 rc = kTRUE;
1421 }
1422
1423 if (IsEnvDefined(env, prefix, "HiGainLast", print))
1424 {
1425 SetLast(GetEnvValue(env, prefix, "HiGainLast", fLast));
1426 rc = kTRUE;
1427 }
1428
1429 if (IsEnvDefined(env, prefix, "LoGainNbins", print))
1430 {
1431 SetLoGainNbins(GetEnvValue(env, prefix, "LoGainNbins", fLoGainNbins));
1432 rc = kTRUE;
1433 }
1434
1435 if (IsEnvDefined(env, prefix, "LoGainFirst", print))
1436 {
1437 SetLoGainFirst(GetEnvValue(env, prefix, "LoGainFirst", fLoGainFirst));
1438 rc = kTRUE;
1439 }
1440
1441 if (IsEnvDefined(env, prefix, "LoGainLast", print))
1442 {
1443 SetLoGainLast(GetEnvValue(env, prefix, "LoGainLast", fLoGainLast));
1444 rc = kTRUE;
1445 }
1446
1447 if (IsEnvDefined(env, prefix, "TimeLowerLimit", print))
1448 {
1449 SetTimeLowerLimit(GetEnvValue(env, prefix, "TimeLowerLimit", fTimeLowerLimit));
1450 rc = kTRUE;
1451 }
1452
1453 if (IsEnvDefined(env, prefix, "TimeUpperLimit", print))
1454 {
1455 SetTimeUpperLimit(GetEnvValue(env, prefix, "TimeUpperLimit", fTimeUpperLimit));
1456 rc = kTRUE;
1457 }
1458
1459 if (IsEnvDefined(env, prefix, "ReferenceFile", print))
1460 {
1461 SetReferenceFile(GetEnvValue(env,prefix,"ReferenceFile",fReferenceFile.Data()));
1462 rc = kTRUE;
1463 }
1464
1465 if (IsEnvDefined(env, prefix, "NumHiGainSaturationLimit", print))
1466 {
1467 SetNumHiGainSaturationLimit(GetEnvValue(env, prefix, "NumHiGainSaturationLimit", fNumHiGainSaturationLimit));
1468 rc = kTRUE;
1469 }
1470
1471 if (IsEnvDefined(env, prefix, "NumLoGainSaturationLimit", print))
1472 {
1473 SetNumLoGainSaturationLimit(GetEnvValue(env, prefix, "NumLoGainSaturationLimit", fNumLoGainSaturationLimit));
1474 rc = kTRUE;
1475 }
1476
1477 if (IsEnvDefined(env, prefix, "NumLoGainBlackoutLimit", print))
1478 {
1479 SetNumLoGainBlackoutLimit(GetEnvValue(env, prefix, "NumLoGainBlackoutLimit", fNumLoGainBlackoutLimit));
1480 rc = kTRUE;
1481 }
1482
1483
1484 TEnv refenv(fReferenceFile);
1485
1486 fInnerRefCharge = refenv.GetValue("InnerRefCharge",fInnerRefCharge);
1487 fOuterRefCharge = refenv.GetValue("OuterRefCharge",fOuterRefCharge);
1488
1489 return rc;
1490}
Note: See TracBrowser for help on using the repository browser.