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

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