source: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc@ 5342

Last change on this file since 5342 was 5310, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 64.1 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Markus Gaug, 02/2004 <mailto:markus@ifae.es>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25/////////////////////////////////////////////////////////////////////////////
26//
27// MJCalibration
28//
29// Do one calibration loop over serious of runs with the same pulser
30// colour and the same intensity. The following containers (rectangular) and
31// tasks (ellipses) are called to produce an MCalibrationChargeCam and to
32// update the MCalibrationQECam: (MCalibrate is not called from this class)
33//
34//Begin_Html
35/*
36<img src="images/CalibClasses.gif">
37*/
38//End_Html
39//
40// Different signal extractors can be set with the command SetExtractor()
41// Only extractors deriving from MExtractor can be set, default is MExtractSlidingWindow
42//
43// Different arrival time extractors can be set with the command SetTimeExtractor()
44// Only extractors deriving from MExtractTime can be set, default is MExtractTimeSpline
45//
46// At the end of the eventloop, plots and results are displayed, depending on
47// the flags set (see DisplayResult())
48//
49// If the flag SetFullDisplay() is set, all MHCameras will be displayed.
50// if the flag SetDataCheckDisplay() is set, only the most important ones are displayed
51// Otherwise, (default: SetNormalDisplay()), a good selection of plots is given
52//
53// If the flag SetDataCheck() is set, the calibration is used as in the data check at
54// La Palma, which mean especially running on raw data files.
55//
56// The absolute light calibration devices Blind Pixel and PIN Diode can be switched on
57// and off with the commands:
58//
59// - SetUseBlindPixel(Bool_t )
60// - SetUsePINDiode(Bool_t )
61//
62// See also: MHCalibrationChargePix, MHCalibrationChargeCam, MHGausEvents
63// MHCalibrationChargeBlindPix, MHCalibrationChargePINDiode
64// MCalibrationChargePix, MCalibrationChargeCam, MCalibrationChargeCalc
65// MCalibrationBlindPix, MCalibrationChargePINDiode,
66// MCalibrationQECam, MBadPixelsPix, MBadPixelsCam
67//
68// If the flag RelTimeCalibration() is set, a calibration of the relative arrival
69// times is also performed. The following containers (rectangular) and
70// tasks (ellipses) are called to produce an MCalibrationRelTimeCam used by
71// MCalibrateTime to correct timing offset between pixels: (MCalibrateTime is not
72// called from this class)
73//
74//Begin_Html
75/*
76<img src="images/RelTimeClasses.gif">
77*/
78//End_Html
79//
80// Different arrival time extractors can be set directly with the command SetTimeExtractor(MExtractor *)
81//
82// See also: MHCalibrationRelTimePix, MHCalibrationRelTimeCam, MHGausEvents
83// MCalibrationRelTimePix, MCalibrationRelTimeCam
84// MBadPixelsPix, MBadPixelsCam
85//
86/////////////////////////////////////////////////////////////////////////////
87#include "MJCalibration.h"
88
89#include <TFile.h>
90#include <TF1.h>
91#include <TStyle.h>
92#include <TCanvas.h>
93#include <TSystem.h>
94#include <TLine.h>
95#include <TLatex.h>
96#include <TLegend.h>
97#include <TRegexp.h>
98#include <TPaveText.h>
99#include <TPaveStats.h>
100
101#include "MLog.h"
102#include "MLogManip.h"
103
104#include "MRunIter.h"
105#include "MSequence.h"
106#include "MParList.h"
107#include "MTaskList.h"
108#include "MEvtLoop.h"
109
110#include "MHCamera.h"
111#include "MGeomCam.h"
112
113#include "MPedestalCam.h"
114#include "MCalibColorSteer.h"
115
116#include "MCalibrationIntensityChargeCam.h"
117#include "MCalibrationIntensityBlindCam.h"
118#include "MCalibrationIntensityRelTimeCam.h"
119#include "MCalibrationIntensityQECam.h"
120
121#include "MCalibrationCam.h"
122#include "MCalibrationQECam.h"
123#include "MCalibrationQEPix.h"
124#include "MCalibrationChargeCam.h"
125#include "MCalibrationChargePix.h"
126#include "MCalibrationChargePINDiode.h"
127#include "MCalibrationBlindPix.h"
128#include "MCalibrationBlindCam.h"
129#include "MCalibrationBlindCamOneOldStyle.h"
130#include "MCalibrationBlindCamTwoNewStyle.h"
131#include "MCalibrationChargeCalc.h"
132#include "MCalibColorSet.h"
133
134#include "MHGausEvents.h"
135#include "MHCalibrationCam.h"
136#include "MHCalibrationChargeCam.h"
137#include "MHCalibrationChargeBlindCam.h"
138#include "MHCalibrationChargePINDiode.h"
139#include "MHCalibrationRelTimeCam.h"
140#include "MCalibrationRelTimeCam.h"
141#include "MCalibrationRelTimeCalc.h"
142
143#include "MReadMarsFile.h"
144#include "MRawFileRead.h"
145#include "MGeomApply.h"
146#include "MTaskEnv.h"
147#include "MBadPixelsMerge.h"
148#include "MBadPixelsCam.h"
149#include "MExtractTime.h"
150#include "MExtractor.h"
151#include "MExtractPINDiode.h"
152#include "MExtractBlindPixel.h"
153#include "MExtractSlidingWindow.h"
154#include "MExtractTimeFastSpline.h"
155#include "MFCosmics.h"
156#include "MContinue.h"
157#include "MFillH.h"
158
159#include "MArrivalTimeCam.h"
160
161#include "MStatusDisplay.h"
162
163ClassImp(MJCalibration);
164
165using namespace std;
166
167const Int_t MJCalibration::gkIFAEBoxInaugurationRun = 20113;
168const Int_t MJCalibration::gkSecondBlindPixelInstallation = 31693;
169const Int_t MJCalibration::gkSpecialPixelsContInstallation = 34057;
170const Int_t MJCalibration::gkThirdBlindPixelInstallation = 99999;
171
172const Double_t MJCalibration::fgConvFADC2PheMin = 0.;
173const Double_t MJCalibration::fgConvFADC2PheMax = 1.5;
174const Double_t MJCalibration::fgConvFADC2PhotMin = 0.;
175const Double_t MJCalibration::fgConvFADC2PhotMax = 10.;
176const Double_t MJCalibration::fgQEMin = 0.;
177const Double_t MJCalibration::fgQEMax = 0.3;
178const Double_t MJCalibration::fgArrivalTimeMin = 1.;
179const Double_t MJCalibration::fgArrivalTimeMax = 10.;
180
181const Float_t MJCalibration::fgRefConvFADC2PheInner = 0.14;
182const Float_t MJCalibration::fgRefConvFADC2PheOuter = 0.4;
183const Float_t MJCalibration::fgRefConvFADC2PhotInner = 0.8;
184const Float_t MJCalibration::fgRefConvFADC2PhotOuter = 3.8;
185const Float_t MJCalibration::fgRefQEInner = 0.18;
186const Float_t MJCalibration::fgRefQEOuter = 0.12;
187const Float_t MJCalibration::fgRefArrivalTimeInner = 4.5;
188const Float_t MJCalibration::fgRefArrivalTimeOuter = 5.0;
189const Float_t MJCalibration::fgRefArrivalTimeRmsInner = 0.5;
190const Float_t MJCalibration::fgRefArrivalTimeRmsOuter = 0.5;
191// --------------------------------------------------------------------------
192//
193// Default constructor.
194//
195// - Sets fRuns to 0, fExtractor to NULL, fTimeExtractor to NULL, fColor to kNONE,
196// fDisplay to kNormalDisplay, kRelTimes to kFALSE, kataCheck to kFALSE, kDebug to kFALSE,
197// kIntensity to kFALSE
198// - SetUseBlindPixel()
199// - SetUsePINDiode()
200//
201MJCalibration::MJCalibration(const char *name, const char *title)
202 : fRuns(0), fExtractor(NULL), fTimeExtractor(NULL),
203 fColor(MCalibrationCam::kNONE), fDisplayType(kDataCheckDisplay),
204 fGeometry("MGeomCamMagic")
205{
206
207 fName = name ? name : "MJCalibration";
208 fTitle = title ? title : "Tool to create the calibration constants for one calibration run";
209
210 SetUseBlindPixel();
211 SetUsePINDiode();
212
213 SetRelTimeCalibration( kFALSE );
214 SetDataCheck ( kFALSE );
215 SetDebug ( kFALSE );
216 SetIntensity ( kFALSE );
217
218 SetNoStorage ( kFALSE );
219 SetHistsStorage ( kFALSE );
220}
221
222void MJCalibration::DrawTab(MParList &plist, const char *cont, const char *name, Option_t *opt)
223{
224 TObject *obj = plist.FindObject(cont);
225 if (!obj)
226 return;
227
228 fDisplay->AddTab(name);
229 obj->DrawClone(opt);
230}
231
232// --------------------------------------------------------------------------
233//
234// Display the results in MStatusDisplay:
235//
236// - Add "Calibration" to the MStatusDisplay title
237// - Retrieve the MGeomCam from MParList
238// - Initialize the following MHCamera's:
239// 1) MCalibrationPix::GetMean()
240// 2) MCalibrationPix::Sigma()
241// 3) MCalibrationChargePix::GetRSigma()
242// 4) MCalibrationChargePix::GetRSigmaPerCharge()
243// 5) MCalibrationChargePix::GetPheFFactorMethod()
244// 6) MCalibrationChargePix::GetMeanConvFADC2Phe()
245// 7) MCalibrationChargePix::GetMeanFFactorFADC2Phot()
246// 8) MCalibrationQEPix::GetQECascadesFFactor()
247// 9) MCalibrationQEPix::GetQECascadesBlindPixel()
248// 10) MCalibrationQEPix::GetQECascadesPINDiode()
249// 11) MCalibrationQEPix::GetQECascadesCombined()
250// 12) MCalibrationQEPix::IsAverageQEFFactorAvailable()
251// 13) MCalibrationQEPix::IsAverageQEBlindPixelAvailable()
252// 14) MCalibrationQEPix::IsAverageQEPINDiodeAvailable()
253// 15) MCalibrationQEPix::IsAverageQECombinedAvailable()
254// 16) MCalibrationChargePix::IsHiGainSaturation()
255// 17) MCalibrationPix::GetHiLoMeansDivided()
256// 18) MCalibrationPix::GetHiLoSigmasDivided()
257// 19) MCalibrationChargePix::GetHiGainPickup()
258// 20) MCalibrationChargePix::GetLoGainPickup()
259// 21) MCalibrationChargePix::GetHiGainBlackout()
260// 22) MCalibrationChargePix::GetLoGainBlackout()
261// 23) MCalibrationPix::IsExcluded()
262// 24) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
263// 25) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
264// 26) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
265// 27) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
266// 28) MCalibrationChargePix::GetAbsTimeMean()
267// 29) MCalibrationChargePix::GetAbsTimeRms()
268//
269// If the flag SetFullDisplay() is set, all MHCameras will be displayed.
270// if the flag SetDataCheckDisplay() is set, only the most important ones are displayed
271// and otherwise, (default: SetNormalDisplay()), a good selection of plots is given
272//
273void MJCalibration::DisplayResult(MParList &plist)
274{
275 if (!fDisplay)
276 return;
277
278 TString drawoption = "nonew ";
279 if (fDisplayType == kDataCheckDisplay)
280 drawoption += "datacheck";
281 if (fDisplayType == kFullDisplay)
282 drawoption += "all";
283
284 if (IsUsePINDiode())
285 DrawTab(plist, "MHCalibrationChargePINDiode", "PINDiode", drawoption);
286 if (IsUseBlindPixel())
287 DrawTab(plist, "MHCalibrationChargeChargeBlindCam", "BlindPix", drawoption);
288 if (IsRelTimes())
289 DrawTab(plist, "MHCalibrationRelTimeCam", "RelTime", drawoption);
290 DrawTab(plist, "MHCalibrationChargeCam", "Charge", drawoption);
291
292 //
293 // Update display
294 //
295 TString title = fDisplay->GetTitle();
296 title += "-- Calibration ";
297 title += fSequence.IsValid() ? Form("calib%06d", fSequence.GetSequence()) : (const char*)fRuns->GetRunsAsString();
298 title += " --";
299 fDisplay->SetTitle(title);
300
301 //
302 // Get container from list
303 //
304 MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
305
306 // Create histograms to display
307 MHCamera disp1 (geomcam, "Charge", "Fitted Mean Signal (Charges)");
308 MHCamera disp2 (geomcam, "SigmaCharge", "Sigma of Fitted Signal");
309 MHCamera disp3 (geomcam, "RSigma", "Reduced Sigmas");
310 MHCamera disp4 (geomcam, "RSigmaPerCharge", "Reduced Sigma per Charge");
311 MHCamera disp5 (geomcam, "NumPhes", "Number Photo-electrons");
312 MHCamera disp6 (geomcam, "ConvFADC2Phes", "Conversion Factor to Phes");
313 MHCamera disp7 (geomcam, "TotalFFactor", "Total F-Factor(F-Factor Method)");
314 MHCamera disp8 (geomcam, "CascadesQEFFactor", "Cascades QE (F-Factor Method)");
315 MHCamera disp9 (geomcam, "CascadesQEBlindPix","Cascades QE (Blind Pixel Method)");
316 MHCamera disp10(geomcam, "CascadesQEPINDiode","Cascades QE (PIN Diode Method)");
317 MHCamera disp11(geomcam, "CascadesQECombined","Cascades QE (Combined Method)");
318 MHCamera disp12(geomcam, "FFactorValid", "Pixels with valid F-Factor calibration");
319 MHCamera disp13(geomcam, "BlindPixelValid", "Pixels with valid BlindPixel calibration");
320 MHCamera disp14(geomcam, "PINdiodeValid", "Pixels with valid PINDiode calibration");
321 MHCamera disp15(geomcam, "CombinedValid", "Pixels with valid Combined calibration");
322 MHCamera disp16(geomcam, "Saturation", "Pixels with saturated Hi Gain");
323 MHCamera disp17(geomcam, "ConversionMeans", "Conversion HiGain.vs.LoGain Means");
324 MHCamera disp18(geomcam, "ConversionSigmas", "Conversion HiGain.vs.LoGain Sigmas");
325 MHCamera disp19(geomcam, "HiGainPickup", "Number Pickup events Hi Gain");
326 MHCamera disp20(geomcam, "LoGainPickup", "Number Pickup events Lo Gain");
327 MHCamera disp21(geomcam, "HiGainBlackout", "Number Blackout events Hi Gain");
328 MHCamera disp22(geomcam, "LoGainBlackout", "Number Blackout events Lo Gain");
329 MHCamera disp23(geomcam, "Excluded", "Pixels previously excluded");
330 MHCamera disp24(geomcam, "UnSuitable", "Pixels not suited for further analysis");
331 MHCamera disp25(geomcam, "UnReliable", "Pixels suitable, but not reliable for further analysis");
332 MHCamera disp26(geomcam, "HiGainOscillating", "Oscillating Pixels High Gain");
333 MHCamera disp27(geomcam, "LoGainOscillating", "Oscillating Pixels Low Gain");
334 MHCamera disp28(geomcam, "AbsTimeMean", "Abs. Arrival Times");
335 MHCamera disp29(geomcam, "AbsTimeRms", "RMS of Arrival Times");
336 MHCamera disp30(geomcam, "MeanTime", "Mean Rel. Arrival Times");
337 MHCamera disp31(geomcam, "SigmaTime", "Sigma Rel. Arrival Times");
338 MHCamera disp32(geomcam, "TimeProb", "Probability of Time Fit");
339 MHCamera disp33(geomcam, "TimeNotFitValid", "Pixels with not valid fit results");
340 MHCamera disp34(geomcam, "TimeOscillating", "Oscillating Pixels");
341 MHCamera disp35(geomcam, "TotalConv", "Conversion Factor to photons");
342
343 MCalibrationChargeCam *cam = NULL;
344 MCalibrationQECam *qecam = NULL;
345 MCalibrationRelTimeCam *relcam = NULL;
346 MBadPixelsCam *badcam = NULL;
347
348 if (IsIntensity())
349 {
350 cam = (MCalibrationChargeCam*) fIntensCalibCam.GetCam();
351 qecam = (MCalibrationQECam*) fIntensQECam.GetCam();
352 relcam = (MCalibrationRelTimeCam*)fIntensRelTimeCam.GetCam();
353 badcam = (MBadPixelsCam*) fIntensBadCam.GetCam();
354 }
355 else
356 {
357 cam = &fCalibrationCam;
358 qecam = &fQECam;
359 relcam = &fRelTimeCam;
360 badcam = &fBadPixels;
361 }
362
363 // Fitted charge means and sigmas
364 disp1.SetCamContent(*cam, 0);
365 disp1.SetCamError( *cam, 1);
366 disp2.SetCamContent(*cam, 2);
367 disp2.SetCamError( *cam, 3);
368
369 // Reduced Sigmas and reduced sigmas per charge
370 disp3.SetCamContent(*cam, 5);
371 disp3.SetCamError( *cam, 6);
372 disp4.SetCamContent(*cam, 7);
373 disp4.SetCamError( *cam, 8);
374
375 // F-Factor Method
376 disp5.SetCamContent(*cam, 9);
377 disp5.SetCamError( *cam, 10);
378 disp6.SetCamContent(*cam, 11);
379 disp6.SetCamError( *cam, 12);
380 disp7.SetCamContent(*cam, 13);
381 disp7.SetCamError( *cam, 14);
382
383 // Quantum Efficiencies
384 disp8.SetCamContent (*qecam, 0 );
385 disp8.SetCamError (*qecam, 1 );
386 disp9.SetCamContent (*qecam, 2 );
387 disp9.SetCamError (*qecam, 3 );
388 disp10.SetCamContent(*qecam, 4 );
389 disp10.SetCamError (*qecam, 5 );
390 disp11.SetCamContent(*qecam, 6 );
391 disp11.SetCamError (*qecam, 7 );
392
393 // Valid flags
394 disp12.SetCamContent(*qecam, 8 );
395 disp13.SetCamContent(*qecam, 9 );
396 disp14.SetCamContent(*qecam, 10);
397 disp15.SetCamContent(*qecam, 11);
398
399 // Conversion Hi-Lo
400 disp16.SetCamContent(*cam, 25);
401 disp17.SetCamContent(*cam, 16);
402 disp17.SetCamError (*cam, 17);
403 disp18.SetCamContent(*cam, 18);
404 disp18.SetCamError (*cam, 19);
405
406 // Pickup and Blackout
407 disp19.SetCamContent(*cam, 21);
408 disp20.SetCamContent(*cam, 22);
409 disp21.SetCamContent(*cam, 23);
410 disp22.SetCamContent(*cam, 24);
411
412 // Pixels with defects
413 disp23.SetCamContent(*cam, 20);
414 disp24.SetCamContent(*badcam, 6);
415 disp25.SetCamContent(*badcam, 7);
416
417 // Oscillations
418 disp26.SetCamContent(*badcam, 10);
419 disp27.SetCamContent(*badcam, 11);
420
421 // Arrival Times
422 disp28.SetCamContent(*cam, 26);
423 disp28.SetCamError( *cam, 27);
424 disp29.SetCamContent(*cam, 27);
425
426 disp1.SetYTitle("Q [FADC counts]");
427 disp2.SetYTitle("\\sigma_{Q} [FADC counts]");
428
429 disp3.SetYTitle("\\sqrt{\\sigma^{2}_{Q} - RMS^{2}_{Ped}} [FADC Counts]");
430 disp4.SetYTitle("Red.Sigma/<Q> [1]");
431
432 disp5.SetYTitle("Photo-electons [1]");
433 disp6.SetYTitle("Conv.Factor [PhE/FADC counts]");
434 disp7.SetYTitle("Total F-Factor [1]");
435
436 disp8.SetYTitle("QE [1]");
437 disp9.SetYTitle("QE [1]");
438 disp10.SetYTitle("QE [1]");
439 disp11.SetYTitle("QE [1]");
440
441 disp12.SetYTitle("[1]");
442 disp13.SetYTitle("[1]");
443 disp14.SetYTitle("[1]");
444 disp15.SetYTitle("[1]");
445 disp16.SetYTitle("[1]");
446
447 disp17.SetYTitle("<Q>(High)/<Q>(Low) [1]");
448 disp18.SetYTitle("\\sigma_{Q}(High)/\\sigma_{Q}(Low) [1]");
449
450 disp19.SetYTitle("[1]");
451 disp20.SetYTitle("[1]");
452 disp21.SetYTitle("[1]");
453 disp22.SetYTitle("[1]");
454 // disp23.SetYTitle("[1]");
455 // disp24.SetYTitle("[1]");
456 // disp25.SetYTitle("[1]");
457 disp26.SetYTitle("[1]");
458 disp27.SetYTitle("[1]");
459
460 disp28.SetYTitle("Mean Abs. Time [FADC slice]");
461 disp29.SetYTitle("RMS Abs. Time [FADC slices]");
462
463 disp35.SetYTitle("Conv.Factor [Ph/FADC counts]");
464
465 for (UInt_t i=0;i<geomcam.GetNumPixels();i++)
466 {
467
468 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*cam) [i];
469 MCalibrationQEPix &qe = (MCalibrationQEPix&) (*qecam)[i];
470
471 if (!pix.IsFFactorMethodValid())
472 continue;
473
474 const Float_t convphe = pix.GetMeanConvFADC2Phe();
475 const Float_t quaeff = qe.GetQECascadesFFactor(0.);
476
477 disp35.Fill(i,convphe/quaeff);
478 disp35.SetUsed(i);
479 }
480
481
482 if (IsRelTimes())
483 {
484 disp30.SetCamContent(*relcam,0);
485 disp30.SetCamError( *relcam,1);
486 disp31.SetCamContent(*relcam,2);
487 disp31.SetCamError( *relcam,3);
488 disp32.SetCamContent(*relcam,4);
489 disp33.SetCamContent(fBadPixels,20);
490 disp34.SetCamContent(fBadPixels,21);
491
492 disp30.SetYTitle("Time Offset [FADC units]");
493 disp31.SetYTitle("Timing resolution [FADC units]");
494 disp32.SetYTitle("P_{Time} [1]");
495 disp33.SetYTitle("[1]");
496 disp34.SetYTitle("[1]");
497 }
498
499 if (fDisplayType == kDataCheckDisplay)
500 {
501
502 TCanvas &c1 = fDisplay->AddTab("FitCharge");
503 c1.Divide(3, 3);
504
505 //
506 // MEAN CHARGES
507 //
508
509 c1.cd(1);
510 gPad->SetBorderMode(0);
511 gPad->SetTicks();
512 MHCamera *obj1=(MHCamera*)disp1.DrawCopy("hist");
513 //
514 // for the datacheck, fix the ranges!!
515 //
516 // obj1->SetMinimum(fgChargeMin);
517 // obj1->SetMaximum(fgChargeMax);
518 //
519 // Set the datacheck sizes:
520 //
521 FixDataCheckHist((TH1D*)obj1);
522 obj1->SetStats(kFALSE);
523 //
524 // set reference lines
525 //
526 // DisplayReferenceLines(obj1,0);
527
528 c1.cd(4);
529 gPad->SetBorderMode(0);
530 obj1->SetPrettyPalette();
531 obj1->Draw();
532
533 c1.cd(7);
534 gPad->SetBorderMode(0);
535 gPad->SetTicks();
536 TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName());
537 obj2->Draw();
538 obj2->SetBit(kCanDelete);
539 obj2->Fit("gaus","Q");
540 TF1 *fun2 = obj2->GetFunction("gaus");
541 fun2->SetLineColor(kYellow);
542 gPad->Modified();
543 gPad->Update();
544 TPaveStats *st = (TPaveStats*)obj2->GetListOfFunctions()->FindObject("stats");
545 st->SetY1NDC(0.55);
546 st->SetY2NDC(0.89);
547 st->SetX1NDC(0.65);
548 st->SetX2NDC(0.99);
549 gPad->Modified();
550 gPad->Update();
551 //
552 // Set the datacheck sizes:
553 //
554 FixDataCheckHist(obj2);
555 obj2->SetStats(1);
556
557 //
558 // Display the outliers as dead and noisy pixels
559 //
560 DisplayOutliers(obj2,"low-ampl.","high-ampl.");
561 TLatex flattex;
562 flattex.SetTextSize(0.07);
563 const Double_t minl = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
564 const Double_t maxl = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
565 flattex.DrawLatex(minl+0.015*(maxl-minl),obj2->GetBinContent(obj2->GetMaximumBin())/1.35,
566 Form("Flatfield precision: %4.2f%%",
567 fun2->GetParameter(2)/fun2->GetParameter(1)*100.));
568
569 //
570 // REDUCED SIGMAS
571 //
572
573 c1.cd(2);
574 gPad->SetBorderMode(0);
575 gPad->SetTicks();
576 MHCamera *obj3=(MHCamera*)disp4.DrawCopy("hist");
577 //
578 // for the datacheck, fix the ranges!!
579 //
580 obj3->SetMinimum(0.);
581 // obj3->SetMaximum(fgChargeMax);
582 //
583 // Set the datacheck sizes:
584 //
585 FixDataCheckHist((TH1D*)obj3);
586 obj3->SetStats(kFALSE);
587 //
588 // set reference lines
589 //
590 // DisplayReferenceLines(obj3,0);
591
592 c1.cd(5);
593 gPad->SetBorderMode(0);
594 obj3->SetPrettyPalette();
595 obj3->Draw();
596
597 c1.cd(8);
598 gPad->SetBorderMode(0);
599 if (geomcam.InheritsFrom("MGeomCamMagic"))
600 DisplayDoubleProject(&disp4, "dead", "noisy");
601
602 //
603 // PHOTO ELECTRONS
604 //
605
606 c1.cd(3);
607 gPad->SetBorderMode(0);
608 gPad->SetTicks();
609 MHCamera *obj4=(MHCamera*)disp5.DrawCopy("hist");
610 //
611 // for the datacheck, fix the ranges!!
612 //
613 // obj3->SetMinimum(fgChargeMin);
614 // obj3->SetMaximum(fgChargeMax);
615 //
616 // Set the datacheck sizes:
617 //
618 FixDataCheckHist((TH1D*)obj4);
619 obj4->SetStats(kFALSE);
620 //
621 // set reference lines
622 //
623 // DisplayReferenceLines(obj3,0);
624
625 c1.cd(6);
626 gPad->SetBorderMode(0);
627 obj4->SetPrettyPalette();
628 obj4->Draw();
629
630 c1.cd(9);
631 gPad->SetBorderMode(0);
632 if (geomcam.InheritsFrom("MGeomCamMagic"))
633 DisplayDoubleProject(&disp5, "dead", "noisy");
634
635 //
636 // CONVERSION FACTORS
637 //
638 TCanvas &c2 = fDisplay->AddTab("Conversion");
639 c2.Divide(3,3);
640
641 c2.cd(1);
642 gPad->SetBorderMode(0);
643 gPad->SetTicks();
644 MHCamera *obj5=(MHCamera*)disp6.DrawCopy("hist");
645 //
646 // for the datacheck, fix the ranges!!
647 //
648 obj5->SetMinimum(fgConvFADC2PheMin);
649 obj5->SetMaximum(fgConvFADC2PheMax);
650 //
651 // Set the datacheck sizes:
652 //
653 FixDataCheckHist((TH1D*)obj5);
654 obj5->SetStats(kFALSE);
655 //
656 // set reference lines
657 //
658 DisplayReferenceLines(obj5,2);
659
660 c2.cd(4);
661 gPad->SetBorderMode(0);
662 obj5->SetPrettyPalette();
663 obj5->Draw();
664
665 c2.cd(7);
666 gPad->SetBorderMode(0);
667 if (geomcam.InheritsFrom("MGeomCamMagic"))
668 DisplayDoubleProject(&disp6, "noisy", "dead");
669
670 //
671 // QUANTUM EFFICIENCY
672 //
673 c2.cd(2);
674 gPad->SetBorderMode(0);
675 gPad->SetTicks();
676 MHCamera *obj6=(MHCamera*)disp8.DrawCopy("hist");
677 //
678 // for the datacheck, fix the ranges!!
679 //
680 obj6->SetMinimum(fgQEMin);
681 obj6->SetMaximum(fgQEMax);
682 //
683 // Set the datacheck sizes:
684 //
685 FixDataCheckHist((TH1D*)obj6);
686 obj6->SetStats(kFALSE);
687 //
688 // set reference lines
689 //
690 DisplayReferenceLines(obj6,0);
691
692 c2.cd(5);
693 gPad->SetBorderMode(0);
694 obj6->SetPrettyPalette();
695 obj6->Draw();
696
697 c2.cd(8);
698 gPad->SetBorderMode(0);
699 if (geomcam.InheritsFrom("MGeomCamMagic"))
700 DisplayDoubleProject(&disp8, "noisy", "dead");
701
702 //
703 // CONVERSION FADC TO PHOTONS
704 //
705
706 c2.cd(3);
707 gPad->SetBorderMode(0);
708 gPad->SetTicks();
709 MHCamera *obj7=(MHCamera*)disp35.DrawCopy("hist");
710 //
711 // for the datacheck, fix the ranges!!
712 //
713 obj7->SetMinimum(fgConvFADC2PhotMin);
714 obj7->SetMaximum(fgConvFADC2PhotMax);
715 //
716 // Set the datacheck sizes:
717 //
718 FixDataCheckHist((TH1D*)obj7);
719 obj7->SetStats(kFALSE);
720 //
721 // set reference lines
722 //
723 DisplayReferenceLines(obj7,1);
724
725 c2.cd(6);
726 gPad->SetBorderMode(0);
727 obj7->SetPrettyPalette();
728 obj7->Draw();
729 c2.cd(9);
730 gPad->SetBorderMode(0);
731 if (geomcam.InheritsFrom("MGeomCamMagic"))
732 DisplayDoubleProject(&disp35, "noisy", "dead");
733
734 //
735 // ARRIVAL TIMES
736 //
737 TCanvas &c3 = fDisplay->AddTab("AbsTimes");
738 c3.Divide(2,3);
739
740 c3.cd(1);
741 gPad->SetBorderMode(0);
742 gPad->SetTicks();
743 MHCamera *obj10=(MHCamera*)disp28.DrawCopy("hist");
744 //
745 // for the datacheck, fix the ranges!!
746 //
747 obj10->SetMinimum(fgArrivalTimeMin);
748 obj10->SetMaximum(fgArrivalTimeMax);
749 //
750 // Set the datacheck sizes:
751 //
752 FixDataCheckHist((TH1D*)obj10);
753 obj10->SetStats(kFALSE);
754 //
755 // set reference lines
756 //
757 DisplayReferenceLines(obj10,3);
758
759 c3.cd(3);
760 gPad->SetBorderMode(0);
761 obj10->SetPrettyPalette();
762 obj10->Draw();
763
764 c3.cd(5);
765 gPad->SetBorderMode(0);
766 if (geomcam.InheritsFrom("MGeomCamMagic"))
767 DisplayDoubleProject(&disp28, "early", "late");
768
769 //
770 // ARRIVAL TIMES JITTER
771 //
772 c3.cd(2);
773 gPad->SetBorderMode(0);
774 gPad->SetTicks();
775 MHCamera *obj11=(MHCamera*)disp29.DrawCopy("hist");
776 //
777 // for the datacheck, fix the ranges!!
778 //
779 // obj11->SetMinimum(fgArrivalTimeMin);
780 // obj11->SetMaximum(fgArrivalTimeMax);
781 //
782 // Set the datacheck sizes:
783 //
784 FixDataCheckHist((TH1D*)obj11);
785 obj11->SetStats(kFALSE);
786 //
787 // set reference lines
788 //
789 DisplayReferenceLines(obj11,4);
790
791 c3.cd(4);
792 gPad->SetBorderMode(0);
793 obj11->SetPrettyPalette();
794 obj11->Draw();
795
796 c3.cd(6);
797 gPad->SetBorderMode(0);
798 if (geomcam.InheritsFrom("MGeomCamMagic"))
799 DisplayDoubleProject(&disp29, "", "jittering");
800
801 //
802 // UNSUITABLE PIXELS
803 //
804 TCanvas &c4 = fDisplay->AddTab("Defect");
805 c4.Divide(2,2);
806
807 c4.cd(1);
808 gPad->SetBorderMode(0);
809 gPad->SetTicks();
810 MHCamera *obj8=(MHCamera*)disp24.DrawCopy("hist");
811 //
812 // for the datacheck, fix the ranges!!
813 //
814 const Double_t max = 11.;
815 obj8->SetMinimum(0.);
816 obj8->SetMaximum(11.);
817 //
818 // Set the datacheck sizes:
819 //
820 FixDataCheckHist((TH1D*)obj8);
821 obj8->SetStats(kFALSE);
822
823 gStyle->SetPalette(1);
824 const Int_t numcol = gStyle->GetNumberOfColors()-3;
825
826 TPaveText *pave = new TPaveText(0.0,0.0,0.99,0.99);
827 pave->SetBit(kCanDelete);
828 pave->ConvertNDCtoPad();
829 pave->SetTextSize(0.05);
830 pave->AddText(" ");
831 TText *t1 = pave->AddText(Form("Signal smaller 3 Pedestal RMS: %3i pixels",
832 CountBadPixels(&disp24,1)));
833 t1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol + 1.)));
834 t1->SetTextAlign(12);
835 TText *t2 = pave->AddText(Form("%s%3i%s","Signal Rel. error too large: ",
836 CountBadPixels(&disp24,2)," pixels"));
837 t2->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol + 1.)));
838 t2->SetTextAlign(12);
839 TText *t4 = pave->AddText(Form("Low Gain Saturation: %3i pixels",
840 CountBadPixels(&disp24,3)));
841 t4->SetTextColor(gStyle->GetColorPalette(Int_t(3./max*numcol + 1.)));
842 t4->SetTextAlign(12);
843 TText *t5 = pave->AddText(Form("Mean Arr. Time In First Extraction Bin: %3i pixels",
844 CountBadPixels(&disp24,4)));
845 t5->SetTextColor(gStyle->GetColorPalette(Int_t(4./max*numcol + 1.)));
846 t5->SetTextAlign(12);
847 TText *t6 = pave->AddText(Form("Mean Arr. Time In Last 2 Extraction Bins: %3i pixels",
848 CountBadPixels(&disp24,5)));
849 t6->SetTextColor(gStyle->GetColorPalette(Int_t(5./max*numcol + 1.)));
850 t6->SetTextAlign(12);
851 TText *t7 = pave->AddText(Form("Deviating Number of Photo-electrons: %3i pixels",
852 CountBadPixels(&disp24,6)));
853 t7->SetTextColor(gStyle->GetColorPalette(Int_t(6./max*numcol + 1.)));
854 t7->SetTextAlign(12);
855 TText *t8 = pave->AddText(Form("Deviating global F-Factor: %3i pixels",
856 CountBadPixels(&disp24,7)));
857 t8->SetTextColor(gStyle->GetColorPalette(Int_t(7./max*numcol + 1.)));
858 t8->SetTextAlign(12);
859 TText *t9 = pave->AddText(Form("Deviating Number of Photons: %3i pixels",
860 CountBadPixels(&disp24,8)));
861 t9->SetTextColor(gStyle->GetColorPalette(Int_t(8./max*numcol + 1.)));
862 t9->SetTextAlign(12);
863 TText *t10= pave->AddText(Form("High-Gain Histogram Overflow: %3i pixels",
864 CountBadPixels(&disp24,9 )));
865 t10->SetTextColor(gStyle->GetColorPalette(Int_t(9./max*numcol + 1.)));
866 t10->SetTextAlign(12);
867 TText *t11= pave->AddText(Form("Low-Gain Histogram Overflow: %3i pixels",
868 CountBadPixels(&disp24,10)));
869 t11->SetTextColor(gStyle->GetColorPalette(Int_t(10./max*numcol + 1.)));
870 t11->SetTextAlign(12);
871 TText *t12= pave->AddText(Form("Previously Excluded: %3i pixels",
872 CountBadPixels(&disp24,11)));
873 t12->SetTextColor(gStyle->GetColorPalette(Int_t(11./max*numcol + 1.)));
874 t12->SetTextAlign(12);
875 pave->Draw();
876
877 c4.cd(3);
878 gPad->SetBorderMode(0);
879 obj8->Draw();
880 obj8->SetPrettyPalette();
881
882 //
883 // UNRELIABLE PIXELS
884 //
885
886 c4.cd(2);
887 gPad->SetBorderMode(0);
888 gPad->SetTicks();
889 MHCamera *obj9=(MHCamera*)disp25.DrawCopy("hist");
890 //
891 // for the datacheck, fix the ranges!!
892 //
893 const Double_t max2 = 8.;
894 obj9->SetMinimum(0.);
895 obj9->SetMaximum(max2);
896 //
897 // Set the datacheck sizes:
898 //
899 FixDataCheckHist((TH1D*)obj9);
900 obj9->SetStats(kFALSE);
901
902 gStyle->SetPalette(1);
903
904 TPaveText *pave2 = new TPaveText(0.0,0.0,0.99,0.99);
905 pave2->SetBit(kCanDelete);
906 pave2->ConvertNDCtoPad();
907 pave2->SetTextSize(0.05);
908 pave2->AddText(" ");
909 TText *t3 = pave2->AddText(Form("Signal Sigma smaller Pedestal RMS: %3i pixels",
910 CountBadPixels(&disp25,1)));
911 t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol + 1.)));
912 t3->SetTextAlign(12);
913 TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted: %3i pixels",
914 CountBadPixels(&disp25,2)));
915 tt1->SetTextColor(gStyle->GetColorPalette(Int_t(2./max2*numcol + 1.)));
916 tt1->SetTextAlign(12);
917 TText *tt2 = pave2->AddText(Form("Low Gain Signals could not be fitted: %3i pixels",
918 CountBadPixels(&disp25,3)));
919 tt2->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol + 1.)));
920 tt2->SetTextAlign(12);
921 TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted: %3i pixels",
922 CountBadPixels(&disp25,4)));
923 tt3->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol + 1.)));
924 tt3->SetTextAlign(12);
925 TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation: %3i pixels",
926 CountBadPixels(&disp25,5)));
927 tt4->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol + 1.)));
928 tt4->SetTextAlign(12);
929 TText *tt5 = pave2->AddText(Form("Low Gain Signals Oscillation: %3i pixels",
930 CountBadPixels(&disp25,6)));
931 tt5->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol + 1.)));
932 tt5->SetTextAlign(12);
933 TText *tt6 = pave2->AddText(Form("Relative Arr. Times Oscillation: %3i pixels",
934 CountBadPixels(&disp25,7)));
935 tt6->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol + 1.)));
936 tt6->SetTextAlign(12);
937 pave2->Draw();
938
939 c4.cd(4);
940 gPad->SetBorderMode(0);
941 obj9->SetPrettyPalette();
942 obj9->Draw();
943
944 if (IsRelTimes())
945 {
946 TCanvas &c5 = fDisplay->AddTab("RelTimes");
947 c5.Divide(2,3);
948
949 //
950 // MEAN REL. ARR. TIMES
951 //
952 c5.cd(1);
953 gPad->SetBorderMode(0);
954 gPad->SetTicks();
955 MHCamera *obj10=(MHCamera*)disp30.DrawCopy("hist");
956 //
957 // for the datacheck, fix the ranges!!
958 //
959 // obj10->SetMinimum(fgConvFADC2PheMin);
960 // obj10->SetMaximum(fgConvFADC2PheMax);
961 //
962 // Set the datacheck sizes:
963 //
964 FixDataCheckHist((TH1D*)obj10);
965 obj10->SetStats(kFALSE);
966 //
967 // set reference lines
968 //
969 // DisplayReferenceLines(obj10,2);
970
971 c5.cd(3);
972 gPad->SetBorderMode(0);
973 obj10->SetPrettyPalette();
974 obj10->Draw();
975
976 c5.cd(5);
977 gPad->SetBorderMode(0);
978 if (geomcam.InheritsFrom("MGeomCamMagic"))
979 DisplayDoubleProject(&disp30, "early", "late");
980
981 //
982 // JITTER Rel. Arr. Times
983 //
984 c5.cd(2);
985 gPad->SetBorderMode(0);
986 gPad->SetTicks();
987 MHCamera *obj11=(MHCamera*)disp31.DrawCopy("hist");
988 //
989 // for the datacheck, fix the ranges!!
990 //
991 // obj11->SetMinimum(fgQEMin);
992 // obj11->SetMaximum(fgQEMax);
993 //
994 // Set the datacheck sizes:
995 //
996 FixDataCheckHist((TH1D*)obj11);
997 obj11->SetStats(kFALSE);
998 //
999 // set reference lines
1000 //
1001 // DisplayReferenceLines(obj11,0);
1002
1003 c5.cd(4);
1004 gPad->SetBorderMode(0);
1005 obj11->SetPrettyPalette();
1006 obj11->Draw();
1007
1008 c5.cd(6);
1009 gPad->SetBorderMode(0);
1010 if (geomcam.InheritsFrom("MGeomCamMagic"))
1011 DisplayDoubleProject(&disp31, "too stable", "jittering");
1012
1013 }
1014 return;
1015 }
1016
1017 if (fDisplayType == kNormalDisplay)
1018 {
1019
1020 // Charges
1021 TCanvas &c11 = fDisplay->AddTab("FitCharge");
1022 c11.Divide(2, 4);
1023
1024 disp1.CamDraw(c11, 1, 2, 5, 1);
1025 disp2.CamDraw(c11, 2, 2, 5, 1);
1026
1027 // Reduced Sigmas
1028 TCanvas &c12 = fDisplay->AddTab("RedSigma");
1029 c12.Divide(2,4);
1030
1031 disp3.CamDraw(c12, 1, 2, 5, 1);
1032 disp4.CamDraw(c12, 2, 2, 5, 1);
1033
1034 // F-Factor
1035 TCanvas &c13 = fDisplay->AddTab("Phe's");
1036 c13.Divide(3,4);
1037
1038 disp5.CamDraw(c13, 1, 3, 5, 1);
1039 disp6.CamDraw(c13, 2, 3, 5, 1);
1040 disp7.CamDraw(c13, 3, 3, 5, 1);
1041
1042 // QE's
1043 TCanvas &c14 = fDisplay->AddTab("QE's");
1044 c14.Divide(4,4);
1045
1046 disp8.CamDraw(c14, 1, 4, 5, 1);
1047 disp9.CamDraw(c14, 2, 4, 5, 1);
1048 disp10.CamDraw(c14, 3, 4, 5, 1);
1049 disp11.CamDraw(c14, 4, 4, 5, 1);
1050
1051 // Defects
1052 TCanvas &c15 = fDisplay->AddTab("Defect");
1053 // c15.Divide(5,2);
1054 c15.Divide(4,2);
1055
1056 /*
1057 disp23.CamDraw(c15, 1, 5, 0);
1058 disp24.CamDraw(c15, 2, 5, 0);
1059 disp25.CamDraw(c15, 3, 5, 0);
1060 disp26.CamDraw(c15, 4, 5, 0);
1061 disp27.CamDraw(c15, 5, 5, 0);
1062 */
1063 disp24.CamDraw(c15, 1, 4, 0);
1064 disp25.CamDraw(c15, 2, 4, 0);
1065 disp26.CamDraw(c15, 3, 4, 0);
1066 disp27.CamDraw(c15, 4, 4, 0);
1067
1068 // Abs. Times
1069 TCanvas &c16 = fDisplay->AddTab("AbsTimes");
1070 c16.Divide(2,3);
1071
1072 disp28.CamDraw(c16, 1, 2, 5);
1073 disp29.CamDraw(c16, 2, 2, 5);
1074
1075 if (IsRelTimes())
1076 {
1077 // Rel. Times
1078 TCanvas &c17 = fDisplay->AddTab("RelTimes");
1079 c17.Divide(2,4);
1080
1081 disp30.CamDraw(c17, 1, 2, 5, 1);
1082 disp31.CamDraw(c17, 2, 2, 5, 1);
1083 }
1084
1085 return;
1086 }
1087
1088 if (fDisplayType == kFullDisplay)
1089 {
1090 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationChargeCam");
1091
1092 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
1093 {
1094 cam->GetAverageHiGainSector(sector).DrawClone("all");
1095 cam->GetAverageLoGainSector(sector).DrawClone("all");
1096 }
1097
1098 // Charges
1099 TCanvas &c21 = fDisplay->AddTab("FitCharge");
1100 c21.Divide(2, 4);
1101
1102 disp1.CamDraw(c21, 1, 2, 2, 1);
1103 disp2.CamDraw(c21, 2, 2, 2, 1);
1104
1105 // Reduced Sigmas
1106 TCanvas &c23 = fDisplay->AddTab("RedSigma");
1107 c23.Divide(2,4);
1108
1109 disp3.CamDraw(c23, 1, 2, 2, 1);
1110 disp4.CamDraw(c23, 2, 2, 2, 1);
1111
1112 // F-Factor
1113 TCanvas &c24 = fDisplay->AddTab("Phe's");
1114 c24.Divide(3,5);
1115
1116 disp5.CamDraw(c24, 1, 3, 2, 1, 1);
1117 disp6.CamDraw(c24, 2, 3, 2, 1, 1);
1118 disp7.CamDraw(c24, 3, 3, 2, 1, 1);
1119
1120 // QE's
1121 TCanvas &c25 = fDisplay->AddTab("QE's");
1122 c25.Divide(4,5);
1123
1124 disp8.CamDraw(c25, 1, 4, 2, 1, 1);
1125 disp9.CamDraw(c25, 2, 4, 2, 1, 1);
1126 disp10.CamDraw(c25, 3, 4, 2, 1, 1);
1127 disp11.CamDraw(c25, 4, 4, 2, 1, 1);
1128
1129 // Validity
1130 TCanvas &c26 = fDisplay->AddTab("Valid");
1131 c26.Divide(4,2);
1132
1133 disp12.CamDraw(c26, 1, 4, 0);
1134 disp13.CamDraw(c26, 2, 4, 0);
1135 disp14.CamDraw(c26, 3, 4, 0);
1136 disp15.CamDraw(c26, 4, 4, 0);
1137
1138 // Other info
1139 TCanvas &c27 = fDisplay->AddTab("HiLoGain");
1140 c27.Divide(3,3);
1141
1142 disp16.CamDraw(c27, 1, 3, 0);
1143 disp17.CamDraw(c27, 2, 3, 1);
1144 disp18.CamDraw(c27, 3, 3, 1);
1145
1146 // Pickup
1147 TCanvas &c28 = fDisplay->AddTab("Pickup");
1148 c28.Divide(4,2);
1149
1150 disp19.CamDraw(c28, 1, 4, 0);
1151 disp20.CamDraw(c28, 2, 4, 0);
1152 disp21.CamDraw(c28, 3, 4, 0);
1153 disp22.CamDraw(c28, 4, 4, 0);
1154
1155 // Defects
1156 TCanvas &c29 = fDisplay->AddTab("Defect");
1157 // c29.Divide(5,2);
1158 c29.Divide(4,2);
1159
1160 disp24.CamDraw(c29, 1, 4, 0);
1161 disp25.CamDraw(c29, 2, 4, 0);
1162 disp26.CamDraw(c29, 3, 4, 0);
1163 disp27.CamDraw(c29, 4, 4, 0);
1164
1165 // Abs. Times
1166 TCanvas &c30 = fDisplay->AddTab("AbsTimes");
1167 c30.Divide(2,3);
1168
1169 disp28.CamDraw(c30, 1, 2, 2);
1170 disp29.CamDraw(c30, 2, 2, 1);
1171
1172 if (IsRelTimes())
1173 {
1174 // Rel. Times
1175 TCanvas &c31 = fDisplay->AddTab("RelTimes");
1176 c31.Divide(3,5);
1177
1178 disp30.CamDraw(c31, 1, 3, 2, 1, 1);
1179 disp31.CamDraw(c31, 2, 3, 2, 1, 1);
1180 disp32.CamDraw(c31, 3, 3, 4, 1, 1);
1181
1182 // Time Defects
1183 TCanvas &c32 = fDisplay->AddTab("DefTime");
1184 c32.Divide(2,2);
1185
1186 disp33.CamDraw(c32, 1, 2, 0);
1187 disp34.CamDraw(c32, 2, 2, 0);
1188
1189 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationRelTimeCam");
1190
1191 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
1192 {
1193 cam->GetAverageHiGainSector(sector).DrawClone("fourierevents");
1194 cam->GetAverageLoGainSector(sector).DrawClone("fourierevents");
1195 }
1196
1197 }
1198
1199 return;
1200 }
1201}
1202
1203
1204void MJCalibration::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
1205{
1206
1207 const MGeomCam *geom = cam->GetGeometry();
1208
1209 Double_t x = geom->InheritsFrom("MGeomCamMagic") ? 397 : cam->GetNbinsX() ;
1210
1211 TLine line;
1212 line.SetLineStyle(kDashed);
1213 line.SetLineWidth(3);
1214 line.SetLineColor(kBlue);
1215
1216 TLine *l1 = NULL;
1217
1218 if (what == 0)
1219 l1 = line.DrawLine(0, fgRefQEInner, x, fgRefQEInner);
1220 else if (what == 1)
1221 l1 = line.DrawLine(0, fgRefConvFADC2PhotInner, x, fgRefConvFADC2PhotInner);
1222 else if (what == 2)
1223 l1 = line.DrawLine(0, fgRefConvFADC2PheInner, x, fgRefConvFADC2PheInner );
1224 else if (what == 3)
1225 l1 = line.DrawLine(0, fgRefArrivalTimeInner, x, fgRefArrivalTimeInner );
1226 else if (what == 4)
1227 l1 = line.DrawLine(0, fgRefArrivalTimeRmsInner, x, fgRefArrivalTimeRmsInner );
1228
1229 if (geom->InheritsFrom("MGeomCamMagic"))
1230 {
1231 const Double_t x2 = cam->GetNbinsX();
1232
1233 switch (what)
1234 {
1235 case 0:
1236 line.DrawLine(x2, fgRefQEOuter, 398, fgRefQEOuter);
1237 break;
1238 case 1:
1239 line.DrawLine(x2, fgRefConvFADC2PhotOuter, 398, fgRefConvFADC2PhotOuter );
1240 break;
1241 case 2:
1242 line.DrawLine(x2, fgRefConvFADC2PheOuter, 398, fgRefConvFADC2PheOuter);
1243 break;
1244 case 3:
1245 line.DrawLine(x2, fgRefArrivalTimeOuter, 398, fgRefArrivalTimeOuter);
1246 break;
1247 case 4:
1248 line.DrawLine(x2, fgRefArrivalTimeRmsOuter, 398, fgRefArrivalTimeRmsOuter);
1249 break;
1250 }
1251 }
1252
1253 TLegend *leg = new TLegend(what ? 0.2 : 0.6,0.75,what ? 0.5 : 0.9 ,0.85);
1254 leg->SetBit(kCanDelete);
1255 leg->AddEntry(l1, "Reference","l");
1256 leg->Draw();
1257}
1258
1259void MJCalibration::DisplayOutliers(TH1D *hist, const char* whatsmall, const char* whatbig) const
1260{
1261
1262 const Int_t kNotDraw = 1<<9;
1263 TF1 *f = hist->GetFunction("gaus");
1264 f->ResetBit(kNotDraw);
1265
1266 const Float_t mean = f->GetParameter(1);
1267 const Float_t lolim = mean - 4.0*f->GetParameter(2);
1268 const Float_t uplim = mean + 4.0*f->GetParameter(2);
1269 const Stat_t dead = hist->Integral(0,hist->FindBin(lolim)-1);
1270 const Stat_t noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
1271
1272 const Double_t max = hist->GetBinContent(hist->GetMaximumBin());
1273
1274 const Double_t minl = hist->GetBinCenter(hist->GetXaxis()->GetFirst());
1275 const Double_t maxl = hist->GetBinCenter(hist->GetXaxis()->GetLast());
1276
1277 TLatex deadtex;
1278 deadtex.SetTextSize(0.07);
1279 deadtex.DrawLatex(minl+0.015*(maxl-minl),max/1.1,
1280 Form("%3i %s pixels",(Int_t)dead,whatsmall));
1281
1282 TLatex noisytex;
1283 noisytex.SetTextSize(0.07);
1284 noisytex.DrawLatex(minl+0.015*(maxl-minl),max/1.2,
1285 Form("%3i %s pixels",(Int_t)noisy,whatbig));
1286
1287}
1288
1289void MJCalibration::FixDataCheckHist(TH1D *hist) const
1290{
1291
1292 hist->SetDirectory(NULL);
1293
1294 //
1295 // set the labels bigger
1296 //
1297 TAxis *xaxe = hist->GetXaxis();
1298 TAxis *yaxe = hist->GetYaxis();
1299
1300 xaxe->CenterTitle();
1301 yaxe->CenterTitle();
1302 xaxe->SetTitleSize(0.06);
1303 yaxe->SetTitleSize(0.06);
1304 xaxe->SetTitleOffset(0.8);
1305 yaxe->SetTitleOffset(0.85);
1306 xaxe->SetLabelSize(0.05);
1307 yaxe->SetLabelSize(0.05);
1308
1309}
1310
1311const Int_t MJCalibration::CountBadPixels ( MHCamera *cam , const Int_t what ) const
1312{
1313
1314 Int_t cnt = 0;
1315
1316 for (UInt_t pix=0; pix<cam->GetNumPixels();pix++)
1317 if ((Int_t)cam->GetPixContent(pix) == what)
1318 cnt++;
1319
1320 return cnt;
1321}
1322
1323// --------------------------------------------------------------------------
1324//
1325// Retrieve the output file written by WriteResult()
1326//
1327const char* MJCalibration::GetOutputFile() const
1328{
1329 if (fSequence.IsValid())
1330 return Form("%s/calib%06d.root", (const char*)fPathOut, fSequence.GetSequence());
1331 if (!fRuns)
1332 return "";
1333
1334 return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
1335}
1336
1337// --------------------------------------------------------------------------
1338//
1339// MJCalibration allows to setup several option by a resource file:
1340// MJCalibration.Display: full, datacheck, normal
1341// MJCalibration.RelTimeCalibration: yes,no
1342// MJCalibration.DataCheck: yes,no
1343// MJCalibration.Debug: yes,no
1344// MJCalibration.Intensity: yes,no
1345// MJCalibration.UseBlindPixel: yes,no
1346// MJCalibration.UsePINDiode: yes,no
1347// MJCalibration.Geometry: MGeomCamMagic, MGeomCamECO1000
1348//
1349// For more details see the class description and the corresponding Getters
1350//
1351Bool_t MJCalibration::CheckEnvLocal()
1352{
1353 TString dis = GetEnv("Display", "");
1354 if (dis.BeginsWith("Full", TString::kIgnoreCase))
1355 SetFullDisplay();
1356 if (dis.BeginsWith("DataCheck", TString::kIgnoreCase))
1357 SetDataCheckDisplay();
1358 if (dis.BeginsWith("Normal", TString::kIgnoreCase))
1359 SetNormalDisplay();
1360
1361 SetRelTimeCalibration(GetEnv("RelTimeCalibration", IsRelTimes()));
1362 SetIntensity(GetEnv("IntensityCalibration", IsIntensity()));
1363 SetDataCheck(GetEnv("DataCheck", IsDataCheck()));
1364 SetDebug(GetEnv("Debug", IsDebug()));
1365
1366 SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel()));
1367 SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
1368 SetGeometry(GetEnv("Geometry", fGeometry));
1369
1370 return kTRUE;
1371}
1372
1373// --------------------------------------------------------------------------
1374//
1375// Call the ProcessFile(MPedestalCam)
1376//
1377Bool_t MJCalibration::Process(MPedestalCam &pedcam)
1378{
1379 if (!ReadCalibrationCam())
1380 return ProcessFile(pedcam);
1381
1382 return kTRUE;
1383}
1384
1385void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext,
1386 MHCalibrationChargeBlindCam &blindcam)
1387{
1388
1389 Int_t run = fSequence.IsValid() ? fSequence.GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
1390
1391 //
1392 // Initialize the blind pixel. Unfortunately, there is a hardware difference
1393 // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
1394 // later setup. The first needs to use a filter because of the length of
1395 // spurious NSB photon signals. The latter get better along extracting the amplitude
1396 // from a small window.
1397 //
1398 if (run < gkSecondBlindPixelInstallation)
1399 {
1400 MCalibrationBlindCamOneOldStyle blindresults;
1401 if (IsIntensity())
1402 blindresults.Copy(*fIntensBlindCam.GetCam());
1403 else
1404 blindresults.Copy(fCalibrationBlindCam);
1405
1406 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
1407 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1408 blindext.SetRange(10,19,0,6);
1409 blindext.SetNSBFilterLimit(70);
1410 }
1411 else if (run < gkThirdBlindPixelInstallation)
1412 {
1413
1414 MCalibrationBlindCamTwoNewStyle blindresults;
1415
1416 if (IsIntensity())
1417 blindresults.Copy(*fIntensBlindCam.GetCam());
1418 else
1419 blindresults.Copy(fCalibrationBlindCam);
1420
1421 blindext.SetNumBlindPixels(blindresults.GetSize());
1422 for (Int_t i=0;i<blindresults.GetSize();i++)
1423 blindext.SetBlindPixelIdx(blindresults[i].GetPixId(),i);
1424
1425 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
1426 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1427 blindext.SetRange(5,8,0,2);
1428 blindext.SetNSBFilterLimit(38);
1429
1430 }
1431 else
1432 {
1433 *fLog << err << "Third blind pixel installation not yet completed, check your run number!!! " << endl;
1434 }
1435
1436}
1437
1438// --------------------------------------------------------------------------
1439//
1440// Execute the task list and the eventloop:
1441//
1442// - Check if there are fRuns, otherwise return
1443// - Check the colour of the files in fRuns (FindColor()), otherwise return
1444// - Check for consistency between run numbers and number of files
1445// - Add fRuns to MReadMarsFile
1446// - Put into MParList:
1447// 1) MPedestalCam (pedcam)
1448// 2) MCalibrationQECam (fQECam)
1449// 3) MCalibrationChargeCam (fCalibrationCam)
1450// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag IsRelTimes() is chosen)
1451// 5) MBadPixelsCam (fBadPixels)
1452// 6) MCalibrationChargePINDiode
1453// 7) MCalibrationBlindPix
1454// - Put into the MTaskList:
1455// 1) MReadMarsFile
1456// 2) MBadPixelsMerge
1457// 3) MGeomApply
1458// 4) MExtractor
1459// 5) MExtractPINDiode
1460// 6) MExtractBlindPixel
1461// 7) MExtractTime (only if flag IsRelTimes() is chosen)
1462// 8) MContinue(MFCosmics)
1463// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode")
1464// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam")
1465// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam")
1466// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillRelTime")
1467// 13) MCalibrationChargeCalc
1468// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag IsRelTimes() is chosen)
1469// 15) MCalibrationRelTimeCalc
1470// - Execute MEvtLoop
1471// - DisplayResult()
1472// - WriteResult()
1473//
1474Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
1475{
1476 if (!fSequence.IsValid())
1477 {
1478 if (!fRuns)
1479 {
1480 *fLog << err << "No Runs choosen... abort." << endl;
1481 return kFALSE;
1482 }
1483
1484 if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
1485 {
1486 *fLog << err << "Number of files found doesn't match number of runs... abort."
1487 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
1488 return kFALSE;
1489 }
1490 }
1491
1492 //if (!CheckEnv())
1493 // return kFALSE;
1494
1495 CheckEnv();
1496
1497 // --------------------------------------------------------------------------------
1498
1499 *fLog << inf;
1500 fLog->Separator(GetDescriptor());
1501
1502 *fLog << "Calculate MCalibrationCam from ";
1503 if (fSequence.IsValid())
1504 *fLog << "Sequence #" << fSequence.GetSequence() << endl;
1505 else
1506 *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
1507 *fLog << endl;
1508
1509 // --------------------------------------------------------------------------------
1510
1511 // Setup Tasklist
1512 MParList plist;
1513 MTaskList tlist;
1514 plist.AddToList(&tlist);
1515 plist.AddToList(this); // take care of fDisplay!
1516
1517 MDirIter iter;
1518 if (fSequence.IsValid())
1519 {
1520 const Int_t n0 = fSequence.SetupCalRuns(iter, fPathData, "C", IsDataCheck());
1521 const Int_t n1 = fSequence.GetNumCalRuns();
1522 if (n0==0)
1523 {
1524 *fLog << err << "ERROR - No input files of sequence found!" << endl;
1525 return kFALSE;
1526 }
1527 if (n0!=n1)
1528 {
1529 *fLog << err << "ERROR - Number of files found ("
1530 << n0 << ") doesn't match number of files in sequence ("
1531 << n1 << ")" << endl;
1532 return kFALSE;
1533 }
1534 }
1535
1536 //
1537 // Input containers
1538 //
1539 plist.AddToList(&pedcam);
1540 plist.AddToList(&fBadPixels);
1541
1542 //
1543 // Calibration Results containers
1544 //
1545 if (IsIntensity())
1546 {
1547 plist.AddToList(&fIntensQECam);
1548 plist.AddToList(&fIntensCalibCam);
1549 plist.AddToList(&fIntensBlindCam);
1550 // plist.AddToList(&fIntensCalibrationPINDiode);
1551 plist.AddToList(&fIntensRelTimeCam);
1552 plist.AddToList(&fIntensBadCam);
1553 }
1554 else
1555 {
1556 plist.AddToList(&fQECam);
1557 plist.AddToList(&fCalibrationCam);
1558 plist.AddToList(&fCalibrationBlindCam);
1559 plist.AddToList(&fCalibrationPINDiode);
1560 plist.AddToList(&fRelTimeCam);
1561 }
1562
1563 //
1564 // Initialize two histogram containers which could be modified in this class
1565 //
1566 MHCalibrationRelTimeCam reltimecam;
1567 MHCalibrationChargeCam chargecam;
1568 MHCalibrationChargeBlindCam blindcam;
1569 plist.AddToList(&chargecam);
1570 plist.AddToList(&blindcam);
1571 if (IsRelTimes())
1572 plist.AddToList(&reltimecam);
1573 //
1574 // Data Reading tasks
1575 //
1576 MReadMarsFile read("Events");
1577 MRawFileRead rawread(NULL);
1578
1579 if (IsDataCheck())
1580 {
1581 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1582 tlist.AddToList(&rawread);
1583 }
1584 else
1585 {
1586 read.DisableAutoScheme();
1587 read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1588 tlist.AddToList(&read);
1589 }
1590
1591 //
1592 // Other Tasks
1593 //
1594 MGeomApply apply;
1595 apply.SetGeometry(fGeometry);
1596 MBadPixelsMerge merge(&fBadPixels);
1597 MExtractPINDiode pinext;
1598 MExtractBlindPixel blindext;
1599
1600 InitBlindPixel(blindext, blindcam);
1601
1602 MExtractSlidingWindow extract2;
1603 MExtractTimeFastSpline timespline;
1604 MCalibrationChargeCalc calcalc;
1605 MCalibrationRelTimeCalc timecalc;
1606
1607 if (!fSequence.IsValid())
1608 {
1609 calcalc.SetOutputPath(fPathOut);
1610 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1611 }
1612
1613 if (IsDebug())
1614 {
1615 chargecam.SetDebug();
1616 calcalc.SetDebug();
1617 }
1618
1619 //
1620 // Calibration histogramming
1621 //
1622 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
1623 MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
1624 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
1625 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
1626 fillpin.SetBit(MFillH::kDoNotDisplay);
1627 fillbnd.SetBit(MFillH::kDoNotDisplay);
1628 fillcam.SetBit(MFillH::kDoNotDisplay);
1629 filltme.SetBit(MFillH::kDoNotDisplay);
1630/*
1631
1632 fillpin.SetNameTab("PINDiode");
1633 fillbnd.SetNameTab("BlindPix");
1634 fillcam.SetNameTab("Charge");
1635 filltme.SetNameTab("RelTimes");
1636
1637 TString drawoption;
1638
1639 if (fDisplayType == kDataCheckDisplay)
1640 drawoption += "datacheck";
1641 if (fDisplayType == kFullDisplay)
1642 drawoption += "all";
1643
1644 fillcam.SetDrawOption(drawoption.Data());
1645 fillbnd.SetDrawOption(drawoption.Data());
1646 fillpin.SetDrawOption(drawoption.Data());
1647 filltme.SetDrawOption(drawoption.Data());
1648 */
1649 //
1650 // Apply a filter against cosmics
1651 // (will have to be needed in the future
1652 // when the calibration hardware-trigger is working)
1653 //
1654 MFCosmics cosmics;
1655 MContinue cont(&cosmics);
1656
1657 MTaskEnv taskenv("ExtractSignal");
1658 taskenv.SetDefault(fExtractor ? fExtractor : &extract2);
1659
1660 tlist.AddToList(&merge);
1661 tlist.AddToList(&apply);
1662 tlist.AddToList(&taskenv);
1663 tlist.AddToList(&pinext);
1664 tlist.AddToList(&blindext);
1665
1666 MTaskEnv taskenv2("ExtractTime");
1667 if (!IsTimeAndCharge())
1668 {
1669 taskenv2.SetDefault(fTimeExtractor ? fTimeExtractor : &timespline);
1670
1671 if (IsRelTimes())
1672 tlist.AddToList(&taskenv2);
1673 }
1674
1675 //
1676 // FIXME: This is not yet implemented in the classes!!!
1677 //
1678 if (fColor == MCalibrationCam::kCT1)
1679 tlist.AddToList(&cont);
1680
1681 MCalibColorSet colorset;
1682 tlist.AddToList(&colorset);
1683
1684 MCalibColorSteer steer;
1685 if (IsIntensity())
1686 tlist.AddToList(&steer);
1687
1688 tlist.AddToList(&fillcam);
1689
1690 if (IsRelTimes())
1691 {
1692 tlist.AddToList(&filltme);
1693 tlist.AddToList(&timecalc);
1694 }
1695
1696 if (IsUseBlindPixel())
1697 tlist.AddToList(&fillbnd);
1698 if (IsUsePINDiode())
1699 tlist.AddToList(&fillpin);
1700
1701 tlist.AddToList(&calcalc);
1702
1703 // Create and setup the eventloop
1704 MEvtLoop evtloop(fName);
1705 evtloop.SetParList(&plist);
1706 evtloop.SetDisplay(fDisplay);
1707 evtloop.SetLogStream(fLog);
1708 if (!SetupEnv(evtloop))
1709 return kFALSE;
1710
1711 if (!taskenv.GetTask() && !taskenv2.GetTask())
1712 {
1713 *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initialized or both '<dummy>'." << endl;
1714 return kFALSE;
1715 }
1716
1717 if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
1718 return kFALSE;
1719
1720 // Execute first analysis
1721 if (!evtloop.Eventloop())
1722 {
1723 *fLog << err << GetDescriptor() << ": Failed." << endl;
1724 return kFALSE;
1725 }
1726
1727 tlist.PrintStatistics();
1728
1729 if (!fCalibrationPINDiode.IsValid())
1730 SetUsePINDiode(kFALSE);
1731
1732 DisplayResult(plist);
1733
1734 if (!IsNoStorage())
1735 if (!WriteResult(plist.FindObject("MGeomCam")))
1736 return kFALSE;
1737
1738 if (IsHistsStorage())
1739 {
1740 if (!WriteHists(plist))
1741 return kFALSE;
1742 }
1743
1744 *fLog << all << GetDescriptor() << ": Done." << endl;
1745
1746 return kTRUE;
1747}
1748
1749// --------------------------------------------------------------------------
1750//
1751// Read the following containers from GetOutputFile()
1752// - MCalibrationChargeCam
1753// - MCalibrationQECam
1754// - MBadPixelsCam
1755//
1756Bool_t MJCalibration::ReadCalibrationCam()
1757{
1758
1759 if (IsNoStorage())
1760 return kFALSE;
1761
1762 const TString fname = GetOutputFile();
1763
1764 if (gSystem->AccessPathName(fname, kFileExists))
1765 {
1766 *fLog << err << "Input file " << fname << " doesn't exist." << endl;
1767 return kFALSE;
1768 }
1769
1770 *fLog << inf << "Reading from file: " << fname << endl;
1771
1772 TFile file(fname, "READ");
1773 if (fCalibrationCam.Read()<=0)
1774 {
1775 *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
1776 return kFALSE;
1777 }
1778
1779 if (fQECam.Read()<=0)
1780 {
1781 *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
1782 return kFALSE;
1783 }
1784
1785
1786 if (file.FindKey("MCalibrationRelTimeCam"))
1787 if (fRelTimeCam.Read()<=0)
1788 {
1789 *fLog << err << "Unable to read MCalibrationRelTimeCam from " << fname << endl;
1790 return kFALSE;
1791 }
1792
1793 if (file.FindKey("MBadPixelsCam"))
1794 {
1795 MBadPixelsCam bad;
1796 if (bad.Read()<=0)
1797 {
1798 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
1799 return kFALSE;
1800 }
1801 fBadPixels.Merge(bad);
1802 }
1803
1804 if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
1805 fDisplay->Read();
1806
1807 return kTRUE;
1808}
1809
1810
1811// --------------------------------------------------------------------------
1812//
1813// Set the useage of the Blind Pixel device
1814//
1815void MJCalibration::SetUseBlindPixel(const Bool_t b)
1816{
1817 b ? SETBIT(fDevices,kUseBlindPixel) : CLRBIT(fDevices,kUseBlindPixel);
1818}
1819
1820// --------------------------------------------------------------------------
1821//
1822// Set the useage of the PIN Diode device
1823//
1824void MJCalibration::SetUsePINDiode(const Bool_t b)
1825{
1826 b ? SETBIT(fDevices,kUsePINDiode) : CLRBIT(fDevices,kUsePINDiode);
1827}
1828
1829Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
1830{
1831
1832 if (IsNoStorage())
1833 return kTRUE;
1834
1835 if (fPathOut.IsNull())
1836 return kTRUE;
1837
1838 const TString oname(GetOutputFile());
1839
1840 *fLog << inf << "Writing to file: " << oname << endl;
1841
1842 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1843 if (!file.IsOpen())
1844 {
1845 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1846 return kFALSE;
1847 }
1848
1849 if (evtloop.Write(fName)<=0)
1850 {
1851 *fLog << err << "Unable to write MEvtloop to " << oname << endl;
1852 return kFALSE;
1853 }
1854
1855 return kTRUE;
1856}
1857
1858Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
1859{
1860
1861 if (IsNoStorage())
1862 return kTRUE;
1863
1864 if (fPathOut.IsNull())
1865 return kTRUE;
1866
1867 const TString oname(GetOutputFile());
1868
1869 *fLog << inf << "Writing to file: " << oname << endl;
1870
1871 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1872 if (!file.IsOpen())
1873 {
1874 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1875 return kFALSE;
1876 }
1877
1878 if (t1 && t1->Write()<=0)
1879 {
1880 *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
1881 return kFALSE;
1882 }
1883
1884 if (t2 && t2->Write()<=0)
1885 {
1886 *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
1887 return kFALSE;
1888 }
1889
1890 return kTRUE;
1891}
1892
1893// --------------------------------------------------------------------------
1894//
1895// Write the result into the output file GetOutputFile(), if fOutputPath exists.
1896//
1897// The following containers are written:
1898// - MStatusDisplay
1899// - MCalibrationChargeCam or MCalibrationIntensityChargeCam
1900// - MCalibrationBlindCam or MCalibrationIntensityBlindCam
1901// - MCalibrationQECam or MCalibrationIntensityQECam
1902// - MCalibrationChargePINDiode
1903// - MBadPixelsCam
1904// If the flag kRelTimes is set, then also:
1905// - MCalibrationRelTimeCam or MCalibrationIntensityRelTimeCam
1906//
1907Bool_t MJCalibration::WriteResult(TObject *geom)
1908{
1909
1910 if (fPathOut.IsNull())
1911 return kTRUE;
1912
1913 const TString oname(GetOutputFile());
1914
1915 *fLog << inf << "Writing to file: " << oname << endl;
1916
1917 TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
1918 if (!file.IsOpen())
1919 {
1920 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1921 return kFALSE;
1922 }
1923
1924 *fLog << inf << " - MStatusDisplay..." << flush;
1925 if (fDisplay && fDisplay->Write()<=0)
1926 {
1927 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
1928 return kFALSE;
1929 }
1930 *fLog << inf << "ok." << endl;
1931
1932 TObjArray cont;
1933 if (IsIntensity())
1934 {
1935 cont.Add(&fIntensBadCam);
1936 cont.Add(&fIntensCalibCam);
1937 cont.Add(&fIntensQECam);
1938 cont.Add(&fIntensBlindCam);
1939 }
1940 else
1941 {
1942 cont.Add(&fBadPixels);
1943 cont.Add(&fCalibrationCam);
1944 cont.Add(&fQECam);
1945 cont.Add(&fCalibrationBlindCam);
1946 }
1947 cont.Add(&fCalibrationPINDiode);
1948 if (IsRelTimes())
1949 cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
1950
1951 if (!geom)
1952 *fLog << warn << " - WARNING - MGeomCam... not found!" << endl;
1953 else
1954 cont.Add(geom);
1955
1956 return WriteContainer(cont);
1957}
1958
1959// --------------------------------------------------------------------------
1960//
1961// Write the calibration histograms into the output file GetOutputFile(),
1962// if fOutputPath exists.
1963//
1964// The following containers are written:
1965// - MHCalibrationChargeCam
1966// - MHCalibrationChargeBlindCam
1967// - MHCalibrationChargePINDiode
1968// If the flag kRelTimes is set, then also:
1969// - MHCalibrationRelTimeBlindCam
1970//
1971Bool_t MJCalibration::WriteHists(MParList &plist)
1972{
1973 if (fPathOut.IsNull())
1974 return kTRUE;
1975
1976 const TString oname(GetOutputFile());
1977
1978 *fLog << inf << "Writing to file: " << oname << endl;
1979
1980 TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
1981 if (!file.IsOpen())
1982 {
1983 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1984 return kFALSE;
1985 }
1986
1987 TObjArray cont;
1988 cont.Add(plist.FindObject("MHCalibrationChargeCam"));
1989 cont.Add(plist.FindObject("MHCalibrationChargeBlindCam"));
1990 cont.Add(plist.FindObject("MHCalibrationChargePINDiode"));
1991 if (IsRelTimes())
1992 cont.Add(plist.FindObject("MHCalibrationRelTimeCam"));
1993
1994 return WriteContainer(cont);
1995}
1996
1997void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
1998{
1999
2000 TArrayI inner(1);
2001 inner[0] = 0;
2002
2003 TArrayI outer(1);
2004 outer[0] = 1;
2005
2006 TArrayI s1(3);
2007 s1[0] = 6;
2008 s1[1] = 1;
2009 s1[2] = 2;
2010
2011 TArrayI s2(3);
2012 s2[0] = 3;
2013 s2[1] = 4;
2014 s2[2] = 5;
2015
2016 TVirtualPad *pad = gPad;
2017 pad->Divide(2,1);
2018
2019 TH1D *inout[2];
2020
2021 for (int i=0; i<2; i++)
2022 {
2023 pad->cd(i+1);
2024 gPad->SetBorderMode(0);
2025 gPad->SetTicks();
2026
2027 inout[i] = cam->ProjectionS(TArrayI(), TArrayI(1,&i), i==0 ? "Inner" : "Outer");
2028 FixDataCheckHist(inout[i]);
2029 inout[i]->SetTitle(Form("%s %s",cam->GetTitle(),i==0 ? "Inner" : "Outer"));
2030 inout[i]->SetDirectory(NULL);
2031 inout[i]->SetLineColor(kRed+i);
2032 inout[i]->SetBit(kCanDelete);
2033 inout[i]->Draw();
2034 //
2035 // Display the outliers as dead and noisy pixels
2036 //
2037 if (!inout[i]->Fit("gaus","0Q"))
2038 DisplayOutliers(inout[i],whatsmall,whatbig);
2039
2040 gPad->Modified();
2041 gPad->Update();
2042 TPaveStats *st = (TPaveStats*)inout[i]->GetListOfFunctions()->FindObject("stats");
2043 st->SetY1NDC(0.6);
2044 st->SetY2NDC(0.9);
2045 st->SetX1NDC(0.55);
2046 st->SetX2NDC(0.99);
2047 gPad->Modified();
2048 gPad->Update();
2049
2050 TLegend *leg2 = new TLegend(0.55,0.4,0.99,0.6);
2051
2052 //
2053 // Display the two half of the camera separately
2054 //
2055 TH1D *half[2];
2056 half[0] = cam->ProjectionS(s1, TArrayI(1,&i), "Sector 6-1-2");
2057 half[1] = cam->ProjectionS(s2, TArrayI(1,&i), "Sector 3-4-5");
2058
2059 for (int j=0; j<2; j++)
2060 {
2061 half[j]->SetLineColor(kRed+i+2*j+1);
2062 half[j]->SetDirectory(NULL);
2063 half[j]->SetBit(kCanDelete);
2064 half[j]->Draw("same");
2065 leg2->AddEntry(half[j], half[j]->GetName(), "l");
2066 }
2067 leg2->Draw();
2068 }
2069}
Note: See TracBrowser for help on using the repository browser.