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

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