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

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