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

Last change on this file since 5017 was 5017, checked in by gaug, 20 years ago
*** empty log message ***
File size: 67.3 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(kNormalDisplay),
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
645 c2.cd(2);
646 gPad->SetBorderMode(0);
647 gPad->SetTicks();
648 MHCamera *obj6=(MHCamera*)disp8.DrawCopy("hist");
649 //
650 // for the datacheck, fix the ranges!!
651 //
652 obj6->SetMinimum(fgQEMin);
653 obj6->SetMaximum(fgQEMax);
654 //
655 // Set the datacheck sizes:
656 //
657 FixDataCheckHist((TH1D*)obj6);
658 obj6->SetStats(kFALSE);
659 //
660 // set reference lines
661 //
662 DisplayReferenceLines(obj6,0);
663
664 c2.cd(5);
665 gPad->SetBorderMode(0);
666 obj6->SetPrettyPalette();
667 obj6->Draw();
668
669 c2.cd(8);
670 gPad->SetBorderMode(0);
671 if (geomcam.InheritsFrom("MGeomCamMagic"))
672 DisplayDoubleProject(&disp8, "noisy", "dead");
673
674 //
675 // CONVERSION FADC TO PHOTONS
676 //
677
678 c2.cd(3);
679 gPad->SetBorderMode(0);
680 gPad->SetTicks();
681 MHCamera *obj7=(MHCamera*)disp35.DrawCopy("hist");
682 //
683 // for the datacheck, fix the ranges!!
684 //
685 obj7->SetMinimum(fgConvFADC2PhotMin);
686 obj7->SetMaximum(fgConvFADC2PhotMax);
687 //
688 // Set the datacheck sizes:
689 //
690 FixDataCheckHist((TH1D*)obj7);
691 obj7->SetStats(kFALSE);
692 //
693 // set reference lines
694 //
695 DisplayReferenceLines(obj7,1);
696
697 c2.cd(6);
698 gPad->SetBorderMode(0);
699 obj7->SetPrettyPalette();
700 obj7->Draw();
701 c2.cd(9);
702 gPad->SetBorderMode(0);
703 if (geomcam.InheritsFrom("MGeomCamMagic"))
704 DisplayDoubleProject(&disp35, "noisy", "dead");
705
706 //
707 // ARRIVAL TIMES
708 //
709 TCanvas &c3 = fDisplay->AddTab("ArrivalTimes");
710 c3.Divide(2,3);
711
712 c3.cd(1);
713 gPad->SetBorderMode(0);
714 gPad->SetTicks();
715 MHCamera *obj10=(MHCamera*)disp28.DrawCopy("hist");
716 //
717 // for the datacheck, fix the ranges!!
718 //
719 obj10->SetMinimum(fgArrivalTimeMin);
720 obj10->SetMaximum(fgArrivalTimeMax);
721 //
722 // Set the datacheck sizes:
723 //
724 FixDataCheckHist((TH1D*)obj10);
725 obj10->SetStats(kFALSE);
726 //
727 // set reference lines
728 //
729 DisplayReferenceLines(obj10,3);
730
731 c3.cd(3);
732 gPad->SetBorderMode(0);
733 obj10->SetPrettyPalette();
734 obj10->Draw();
735
736 c3.cd(5);
737 gPad->SetBorderMode(0);
738 if (geomcam.InheritsFrom("MGeomCamMagic"))
739 DisplayDoubleProject(&disp28, "early", "late");
740
741 //
742 // ARRIVAL TIMES JITTER
743 //
744 c3.cd(2);
745 gPad->SetBorderMode(0);
746 gPad->SetTicks();
747 MHCamera *obj11=(MHCamera*)disp29.DrawCopy("hist");
748 //
749 // for the datacheck, fix the ranges!!
750 //
751 // obj11->SetMinimum(fgArrivalTimeMin);
752 // obj11->SetMaximum(fgArrivalTimeMax);
753 //
754 // Set the datacheck sizes:
755 //
756 FixDataCheckHist((TH1D*)obj11);
757 obj11->SetStats(kFALSE);
758 //
759 // set reference lines
760 //
761 DisplayReferenceLines(obj11,4);
762
763 c3.cd(4);
764 gPad->SetBorderMode(0);
765 obj11->SetPrettyPalette();
766 obj11->Draw();
767
768 c3.cd(6);
769 gPad->SetBorderMode(0);
770 if (geomcam.InheritsFrom("MGeomCamMagic"))
771 DisplayDoubleProject(&disp29, "", "jittering");
772
773 //
774 // UNSUITABLE PIXELS
775 //
776 TCanvas &c4 = fDisplay->AddTab("Defect");
777 c4.Divide(2,2);
778
779 c4.cd(1);
780 gPad->SetBorderMode(0);
781 gPad->SetTicks();
782 MHCamera *obj8=(MHCamera*)disp24.DrawCopy("hist");
783 //
784 // for the datacheck, fix the ranges!!
785 //
786 const Double_t max = 11.;
787 obj8->SetMinimum(0.);
788 obj8->SetMaximum(11.);
789 //
790 // Set the datacheck sizes:
791 //
792 FixDataCheckHist((TH1D*)obj8);
793 obj8->SetStats(kFALSE);
794
795 gStyle->SetPalette(1);
796 const Int_t numcol = gStyle->GetNumberOfColors()-3;
797
798 TPaveText *pave = new TPaveText(0.0,0.0,0.99,0.99);
799 pave->SetBit(kCanDelete);
800 pave->ConvertNDCtoPad();
801 pave->SetTextSize(0.05);
802 pave->AddText(" ");
803 TText *t1 = pave->AddText(Form("Signal smaller 3 Pedestal RMS: %3i pixels",
804 CountBadPixels(&disp24,1)));
805 t1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol + 1.)));
806 t1->SetTextAlign(12);
807 TText *t2 = pave->AddText(Form("%s%3i%s","Signal Rel. error too large: ",
808 CountBadPixels(&disp24,2)," pixels"));
809 t2->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol + 1.)));
810 t2->SetTextAlign(12);
811 TText *t4 = pave->AddText(Form("Low Gain Saturation: %3i pixels",
812 CountBadPixels(&disp24,3)));
813 t4->SetTextColor(gStyle->GetColorPalette(Int_t(3./max*numcol + 1.)));
814 t4->SetTextAlign(12);
815 TText *t5 = pave->AddText(Form("Mean Arr. Time In First Extraction Bin: %3i pixels",
816 CountBadPixels(&disp24,4)));
817 t5->SetTextColor(gStyle->GetColorPalette(Int_t(4./max*numcol + 1.)));
818 t5->SetTextAlign(12);
819 TText *t6 = pave->AddText(Form("Mean Arr. Time In Last 2 Extraction Bins: %3i pixels",
820 CountBadPixels(&disp24,5)));
821 t6->SetTextColor(gStyle->GetColorPalette(Int_t(5./max*numcol + 1.)));
822 t6->SetTextAlign(12);
823 TText *t7 = pave->AddText(Form("Deviating Number of Photo-electrons: %3i pixels",
824 CountBadPixels(&disp24,6)));
825 t7->SetTextColor(gStyle->GetColorPalette(Int_t(6./max*numcol + 1.)));
826 t7->SetTextAlign(12);
827 TText *t8 = pave->AddText(Form("Deviating global F-Factor: %3i pixels",
828 CountBadPixels(&disp24,7)));
829 t8->SetTextColor(gStyle->GetColorPalette(Int_t(7./max*numcol + 1.)));
830 t8->SetTextAlign(12);
831 TText *t9 = pave->AddText(Form("Deviating Number of Photons: %3i pixels",
832 CountBadPixels(&disp24,8)));
833 t9->SetTextColor(gStyle->GetColorPalette(Int_t(8./max*numcol + 1.)));
834 t9->SetTextAlign(12);
835 TText *t10= pave->AddText(Form("High-Gain Histogram Overflow: %3i pixels",
836 CountBadPixels(&disp24,9 )));
837 t10->SetTextColor(gStyle->GetColorPalette(Int_t(9./max*numcol + 1.)));
838 t10->SetTextAlign(12);
839 TText *t11= pave->AddText(Form("Low-Gain Histogram Overflow: %3i pixels",
840 CountBadPixels(&disp24,10)));
841 t11->SetTextColor(gStyle->GetColorPalette(Int_t(10./max*numcol + 1.)));
842 t11->SetTextAlign(12);
843 TText *t12= pave->AddText(Form("Previously Excluded: %3i pixels",
844 CountBadPixels(&disp24,11)));
845 t12->SetTextColor(gStyle->GetColorPalette(Int_t(11./max*numcol + 1.)));
846 t12->SetTextAlign(12);
847 pave->Draw();
848
849 c4.cd(3);
850 gPad->SetBorderMode(0);
851 obj8->Draw();
852 obj8->SetPrettyPalette();
853
854 //
855 // UNRELIABLE PIXELS
856 //
857
858 c4.cd(2);
859 gPad->SetBorderMode(0);
860 gPad->SetTicks();
861 MHCamera *obj9=(MHCamera*)disp25.DrawCopy("hist");
862 //
863 // for the datacheck, fix the ranges!!
864 //
865 const Double_t max2 = 8.;
866 obj9->SetMinimum(0.);
867 obj9->SetMaximum(max2);
868 //
869 // Set the datacheck sizes:
870 //
871 FixDataCheckHist((TH1D*)obj9);
872 obj9->SetStats(kFALSE);
873
874 gStyle->SetPalette(1);
875
876 TPaveText *pave2 = new TPaveText(0.0,0.0,0.99,0.99);
877 pave2->SetBit(kCanDelete);
878 pave2->ConvertNDCtoPad();
879 pave2->SetTextSize(0.05);
880 pave2->AddText(" ");
881 TText *t3 = pave2->AddText(Form("Signal Sigma smaller Pedestal RMS: %3i pixels",
882 CountBadPixels(&disp25,1)));
883 t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol + 1.)));
884 t3->SetTextAlign(12);
885 TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted: %3i pixels",
886 CountBadPixels(&disp25,2)));
887 tt1->SetTextColor(gStyle->GetColorPalette(Int_t(2./max2*numcol + 1.)));
888 tt1->SetTextAlign(12);
889 TText *tt2 = pave2->AddText(Form("Low Gain Signals could not be fitted: %3i pixels",
890 CountBadPixels(&disp25,3)));
891 tt2->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol + 1.)));
892 tt2->SetTextAlign(12);
893 TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted: %3i pixels",
894 CountBadPixels(&disp25,4)));
895 tt3->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol + 1.)));
896 tt3->SetTextAlign(12);
897 TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation: %3i pixels",
898 CountBadPixels(&disp25,5)));
899 tt4->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol + 1.)));
900 tt4->SetTextAlign(12);
901 TText *tt5 = pave2->AddText(Form("Low Gain Signals Oscillation: %3i pixels",
902 CountBadPixels(&disp25,6)));
903 tt5->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol + 1.)));
904 tt5->SetTextAlign(12);
905 TText *tt6 = pave2->AddText(Form("Relative Arr. Times Oscillation: %3i pixels",
906 CountBadPixels(&disp25,7)));
907 tt6->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol + 1.)));
908 tt6->SetTextAlign(12);
909 pave2->Draw();
910
911 c4.cd(4);
912 gPad->SetBorderMode(0);
913 obj9->SetPrettyPalette();
914 obj9->Draw();
915
916 if (IsRelTimes())
917 {
918 // Rel. Times
919 TCanvas &c5 = fDisplay->AddTab("Rel. Times");
920 c5.Divide(2,4);
921
922 disp30.CamDraw(c5, 1, 2, 2);
923 disp31.CamDraw(c5, 2, 2, 2);
924 }
925
926 return;
927 }
928
929 if (fDisplayType == kNormalDisplay)
930 {
931
932 // Charges
933 TCanvas &c11 = fDisplay->AddTab("Fit.Charge");
934 c11.Divide(2, 4);
935
936 disp1.CamDraw(c11, 1, 2, 5, 1);
937 disp2.CamDraw(c11, 2, 2, 5, 1);
938
939 // Reduced Sigmas
940 TCanvas &c12 = fDisplay->AddTab("Red.Sigma");
941 c12.Divide(2,4);
942
943 disp3.CamDraw(c12, 1, 2, 5, 1);
944 disp4.CamDraw(c12, 2, 2, 5, 1);
945
946 // F-Factor
947 TCanvas &c13 = fDisplay->AddTab("Phe's");
948 c13.Divide(3,4);
949
950 disp5.CamDraw(c13, 1, 3, 5, 1);
951 disp6.CamDraw(c13, 2, 3, 5, 1);
952 disp7.CamDraw(c13, 3, 3, 5, 1);
953
954 // QE's
955 TCanvas &c14 = fDisplay->AddTab("QE's");
956 c14.Divide(4,4);
957
958 disp8.CamDraw(c14, 1, 4, 5, 1);
959 disp9.CamDraw(c14, 2, 4, 5, 1);
960 disp10.CamDraw(c14, 3, 4, 5, 1);
961 disp11.CamDraw(c14, 4, 4, 5, 1);
962
963 // Defects
964 TCanvas &c15 = fDisplay->AddTab("Defect");
965 // c15.Divide(5,2);
966 c15.Divide(4,2);
967
968 /*
969 disp23.CamDraw(c15, 1, 5, 0);
970 disp24.CamDraw(c15, 2, 5, 0);
971 disp25.CamDraw(c15, 3, 5, 0);
972 disp26.CamDraw(c15, 4, 5, 0);
973 disp27.CamDraw(c15, 5, 5, 0);
974 */
975 disp24.CamDraw(c15, 1, 4, 0);
976 disp25.CamDraw(c15, 2, 4, 0);
977 disp26.CamDraw(c15, 3, 4, 0);
978 disp27.CamDraw(c15, 4, 4, 0);
979
980 // Abs. Times
981 TCanvas &c16 = fDisplay->AddTab("Abs. Times");
982 c16.Divide(2,3);
983
984 disp28.CamDraw(c16, 1, 2, 5);
985 disp29.CamDraw(c16, 2, 2, 5);
986
987 if (IsRelTimes())
988 {
989 // Rel. Times
990 TCanvas &c17 = fDisplay->AddTab("Rel. Times");
991 c17.Divide(2,4);
992
993 disp30.CamDraw(c17, 1, 2, 5, 1);
994 disp31.CamDraw(c17, 2, 2, 5, 1);
995 }
996
997 return;
998 }
999
1000 if (fDisplayType == kFullDisplay)
1001 {
1002 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationChargeCam");
1003
1004 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
1005 {
1006 cam->GetAverageHiGainSector(sector).DrawClone("all");
1007 cam->GetAverageLoGainSector(sector).DrawClone("all");
1008 }
1009
1010 // Charges
1011 TCanvas &c21 = fDisplay->AddTab("Fit.Charge");
1012 c21.Divide(2, 4);
1013
1014 disp1.CamDraw(c21, 1, 2, 2, 1);
1015 disp2.CamDraw(c21, 2, 2, 2, 1);
1016
1017 // Reduced Sigmas
1018 TCanvas &c23 = fDisplay->AddTab("Red.Sigma");
1019 c23.Divide(2,4);
1020
1021 disp3.CamDraw(c23, 1, 2, 2, 1);
1022 disp4.CamDraw(c23, 2, 2, 2, 1);
1023
1024 // F-Factor
1025 TCanvas &c24 = fDisplay->AddTab("Phe's");
1026 c24.Divide(3,5);
1027
1028 disp5.CamDraw(c24, 1, 3, 2, 1, 1);
1029 disp6.CamDraw(c24, 2, 3, 2, 1, 1);
1030 disp7.CamDraw(c24, 3, 3, 2, 1, 1);
1031
1032 // QE's
1033 TCanvas &c25 = fDisplay->AddTab("QE's");
1034 c25.Divide(4,5);
1035
1036 disp8.CamDraw(c25, 1, 4, 2, 1, 1);
1037 disp9.CamDraw(c25, 2, 4, 2, 1, 1);
1038 disp10.CamDraw(c25, 3, 4, 2, 1, 1);
1039 disp11.CamDraw(c25, 4, 4, 2, 1, 1);
1040
1041 // Validity
1042 TCanvas &c26 = fDisplay->AddTab("Valid");
1043 c26.Divide(4,2);
1044
1045 disp12.CamDraw(c26, 1, 4, 0);
1046 disp13.CamDraw(c26, 2, 4, 0);
1047 disp14.CamDraw(c26, 3, 4, 0);
1048 disp15.CamDraw(c26, 4, 4, 0);
1049
1050 // Other info
1051 TCanvas &c27 = fDisplay->AddTab("HiLoGain");
1052 c27.Divide(3,3);
1053
1054 disp16.CamDraw(c27, 1, 3, 0);
1055 disp17.CamDraw(c27, 2, 3, 1);
1056 disp18.CamDraw(c27, 3, 3, 1);
1057
1058 // Pickup
1059 TCanvas &c28 = fDisplay->AddTab("Pickup");
1060 c28.Divide(4,2);
1061
1062 disp19.CamDraw(c28, 1, 4, 0);
1063 disp20.CamDraw(c28, 2, 4, 0);
1064 disp21.CamDraw(c28, 3, 4, 0);
1065 disp22.CamDraw(c28, 4, 4, 0);
1066
1067 // Defects
1068 TCanvas &c29 = fDisplay->AddTab("Defect");
1069 // c29.Divide(5,2);
1070 c29.Divide(4,2);
1071
1072 disp24.CamDraw(c29, 1, 4, 0);
1073 disp25.CamDraw(c29, 2, 4, 0);
1074 disp26.CamDraw(c29, 3, 4, 0);
1075 disp27.CamDraw(c29, 4, 4, 0);
1076
1077 // Abs. Times
1078 TCanvas &c30 = fDisplay->AddTab("Abs. Times");
1079 c30.Divide(2,3);
1080
1081 disp28.CamDraw(c30, 1, 2, 2);
1082 disp29.CamDraw(c30, 2, 2, 1);
1083
1084 if (IsRelTimes())
1085 {
1086 // Rel. Times
1087 TCanvas &c31 = fDisplay->AddTab("Rel. Times");
1088 c31.Divide(3,5);
1089
1090 disp30.CamDraw(c31, 1, 3, 2, 1, 1);
1091 disp31.CamDraw(c31, 2, 3, 2, 1, 1);
1092 disp32.CamDraw(c31, 3, 3, 4, 1, 1);
1093
1094 // Time Defects
1095 TCanvas &c32 = fDisplay->AddTab("Time Def.");
1096 c32.Divide(2,2);
1097
1098 disp33.CamDraw(c32, 1, 2, 0);
1099 disp34.CamDraw(c32, 2, 2, 0);
1100
1101 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationRelTimeCam");
1102
1103 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
1104 {
1105 cam->GetAverageHiGainSector(sector).DrawClone("fourierevents");
1106 cam->GetAverageLoGainSector(sector).DrawClone("fourierevents");
1107 }
1108
1109 }
1110
1111 return;
1112 }
1113}
1114
1115
1116void MJCalibration::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
1117{
1118
1119 const MGeomCam *geom = cam->GetGeometry();
1120
1121 Double_t x = geom->InheritsFrom("MGeomCamMagic") ? 397 : cam->GetNbinsX() ;
1122
1123 TLine line;
1124 line.SetLineStyle(kDashed);
1125 line.SetLineWidth(3);
1126 line.SetLineColor(kBlue);
1127
1128 TLine *l1 = NULL;
1129
1130 if (what == 0)
1131 l1 = line.DrawLine(0, fgRefQEInner, x, fgRefQEInner);
1132 else if (what == 1)
1133 l1 = line.DrawLine(0, fgRefConvFADC2PhotInner, x, fgRefConvFADC2PhotInner);
1134 else if (what == 2)
1135 l1 = line.DrawLine(0, fgRefConvFADC2PheInner, x, fgRefConvFADC2PheInner );
1136 else if (what == 3)
1137 l1 = line.DrawLine(0, fgRefArrivalTimeInner, x, fgRefArrivalTimeInner );
1138 else if (what == 4)
1139 l1 = line.DrawLine(0, fgRefArrivalTimeRmsInner, x, fgRefArrivalTimeRmsInner );
1140
1141 if (geom->InheritsFrom("MGeomCamMagic"))
1142 {
1143 const Double_t x2 = cam->GetNbinsX();
1144
1145 switch (what)
1146 {
1147 case 0:
1148 line.DrawLine(x2, fgRefQEOuter, 398, fgRefQEOuter);
1149 break;
1150 case 1:
1151 line.DrawLine(x2, fgRefConvFADC2PhotOuter, 398, fgRefConvFADC2PhotOuter );
1152 break;
1153 case 2:
1154 line.DrawLine(x2, fgRefConvFADC2PheOuter, 398, fgRefConvFADC2PheOuter);
1155 break;
1156 case 3:
1157 line.DrawLine(x2, fgRefArrivalTimeOuter, 398, fgRefArrivalTimeOuter);
1158 break;
1159 case 4:
1160 line.DrawLine(x2, fgRefArrivalTimeRmsOuter, 398, fgRefArrivalTimeRmsOuter);
1161 break;
1162 }
1163 }
1164
1165 TLegend *leg = new TLegend(what ? 0.2 : 0.6,0.75,what ? 0.5 : 0.9 ,0.85);
1166 leg->SetBit(kCanDelete);
1167 leg->AddEntry(l1, "Reference","l");
1168 leg->Draw();
1169}
1170
1171void MJCalibration::DisplayOutliers(TH1D *hist, const char* whatsmall, const char* whatbig) const
1172{
1173
1174 const Int_t kNotDraw = 1<<9;
1175 TF1 *f = hist->GetFunction("gaus");
1176 f->ResetBit(kNotDraw);
1177
1178 const Float_t mean = f->GetParameter(1);
1179 const Float_t lolim = mean - 4.0*f->GetParameter(2);
1180 const Float_t uplim = mean + 4.0*f->GetParameter(2);
1181 const Stat_t dead = hist->Integral(0,hist->FindBin(lolim)-1);
1182 const Stat_t noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
1183
1184 const Double_t max = hist->GetBinContent(hist->GetMaximumBin());
1185
1186 const Double_t minl = hist->GetBinCenter(hist->GetXaxis()->GetFirst());
1187 const Double_t maxl = hist->GetBinCenter(hist->GetXaxis()->GetLast());
1188
1189 TLatex deadtex;
1190 deadtex.SetTextSize(0.07);
1191 deadtex.DrawLatex(minl+0.015*(maxl-minl),max/1.1,
1192 Form("%3i %s pixels",(Int_t)dead,whatsmall));
1193
1194 TLatex noisytex;
1195 noisytex.SetTextSize(0.07);
1196 noisytex.DrawLatex(minl+0.015*(maxl-minl),max/1.2,
1197 Form("%3i %s pixels",(Int_t)noisy,whatbig));
1198
1199}
1200
1201void MJCalibration::FixDataCheckHist(TH1D *hist) const
1202{
1203
1204 hist->SetDirectory(NULL);
1205
1206 //
1207 // set the labels bigger
1208 //
1209 TAxis *xaxe = hist->GetXaxis();
1210 TAxis *yaxe = hist->GetYaxis();
1211
1212 xaxe->CenterTitle();
1213 yaxe->CenterTitle();
1214 xaxe->SetTitleSize(0.06);
1215 yaxe->SetTitleSize(0.06);
1216 xaxe->SetTitleOffset(0.8);
1217 yaxe->SetTitleOffset(0.85);
1218 xaxe->SetLabelSize(0.05);
1219 yaxe->SetLabelSize(0.05);
1220
1221}
1222
1223const Int_t MJCalibration::CountBadPixels ( MHCamera *cam , const Int_t what ) const
1224{
1225
1226 Int_t cnt = 0;
1227
1228 for (UInt_t pix=0; pix<cam->GetNumPixels();pix++)
1229 if ((Int_t)cam->GetPixContent(pix) == what)
1230 cnt++;
1231
1232 return cnt;
1233}
1234
1235
1236// --------------------------------------------------------------------------
1237//
1238// Find the colour of the pulsing LED:
1239// - If the run number is smaller than gkIFAEBoxInaugurationRun, take MCalibrationCam::kCT1
1240// - Otherwise find the colour out of the run name
1241// - If no colour is found, return kFALSE
1242//
1243Bool_t MJCalibration::FindColor()
1244{
1245 if (fColor != MCalibrationCam::kNONE)
1246 return kTRUE;
1247
1248 if (fSequence.IsValid())
1249 {
1250 fColor = MCalibrationCam::kCT1;
1251 return kTRUE;
1252 }
1253
1254 const UInt_t nruns = fRuns->GetNumRuns();
1255 if (nruns == 0)
1256 return kFALSE;
1257
1258 fRuns->Reset();
1259
1260 TString filenames;
1261 while (!(filenames=((MDirIter*)fRuns)->Next()).IsNull())
1262 {
1263 MCalibrationCam::PulserColor_t newcolor = MCalibrationCam::kNONE;
1264
1265 TString number = filenames(TRegexp("[0-9]+_._.+[.]root$"));
1266 Int_t num = atoi(number.Data());
1267
1268 if (num<gkIFAEBoxInaugurationRun)
1269 newcolor = MCalibrationCam::kCT1;
1270
1271 switch (num)
1272 {
1273 case 26402:
1274 case 22246:
1275 case 22253:
1276 newcolor = MCalibrationCam::kBLUE;
1277 break;
1278
1279 case 30090:
1280 case 20660:
1281 case 20661:
1282 case 26408:
1283 case 26409:
1284 case 26412:
1285 case 26568:
1286 case 26924:
1287 newcolor = MCalibrationCam::kGREEN;
1288 break;
1289
1290 case 27474:
1291 newcolor = MCalibrationCam::kNONE;
1292 *fLog << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
1293 return kFALSE;
1294
1295 default:
1296 if (filenames.Contains("green",TString::kIgnoreCase))
1297 newcolor = MCalibrationCam::kGREEN;
1298 if (filenames.Contains("blue",TString::kIgnoreCase))
1299 newcolor = MCalibrationCam::kBLUE;
1300 if (filenames.Contains("uv",TString::kIgnoreCase))
1301 newcolor = MCalibrationCam::kUV;
1302 if (filenames.Contains("ct1",TString::kIgnoreCase))
1303 newcolor = MCalibrationCam::kCT1;
1304 }
1305
1306 if (newcolor==MCalibrationCam::kNONE)
1307 {
1308 *fLog << err << "No color found for " << filenames << "... abort." << endl;
1309 return kFALSE;
1310 }
1311
1312 if (fColor == MCalibrationCam::kNONE)
1313 fColor = newcolor;
1314
1315 if (fColor != newcolor)
1316 {
1317 *fLog << err << "Color mismatch found in " << filenames << "... abort." << endl;
1318 return kFALSE;
1319 }
1320 }
1321
1322 *fLog << inf << "Found color: ";
1323 switch (fColor)
1324 {
1325 case MCalibrationCam::kBLUE: *fLog << "kBLUE"; break;
1326 case MCalibrationCam::kGREEN: *fLog << "kGREEN"; break;
1327 case MCalibrationCam::kUV: *fLog << "kUV"; break;
1328 case MCalibrationCam::kCT1: *fLog << "kCT1"; break;
1329 default: *fLog << "<none>"; break;
1330 }
1331 *fLog << endl;
1332
1333 if (fColor!=MCalibrationCam::kNONE)
1334 return kTRUE;
1335
1336 *fLog << "No colour found in: " << fRuns->GetRunsAsString() << "... abort." << endl;
1337 return kFALSE;
1338}
1339
1340// --------------------------------------------------------------------------
1341//
1342// Retrieve the output file written by WriteResult()
1343//
1344const char* MJCalibration::GetOutputFile() const
1345{
1346 if (fSequence.IsValid())
1347 return Form("%s/calib%06d.root", (const char*)fPathOut, fSequence.GetSequence());
1348 if (!fRuns)
1349 return "";
1350
1351 return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
1352}
1353
1354Bool_t MJCalibration::IsUseBlindPixel() const
1355{
1356 return TESTBIT(fDevices,kUseBlindPixel);
1357}
1358
1359Bool_t MJCalibration::IsUsePINDiode() const
1360{
1361 return TESTBIT(fDevices,kUsePINDiode);
1362}
1363
1364// --------------------------------------------------------------------------
1365//
1366// MJCalibration allows to setup several option by a resource file:
1367// MJCalibration.Display: full, datacheck, normal
1368// MJCalibration.RelTimeCalibration: yes,no
1369// MJCalibration.Datacheck: yes,no
1370// MJCalibration.Debug: yes,no
1371// MJCalibration.Intensity: yes,no
1372// MJCalibration.UseBlindPixel: yes,no
1373// MJCalibration.UsePINDiode: yes,no
1374// MJCalibration.Geometry: MGeomCamMagic, MGeomCamECO1000
1375//
1376// For more details see the class description and the corresponding Getters
1377//
1378Bool_t MJCalibration::CheckEnvLocal()
1379{
1380 TString col = GetEnv("Color", "");
1381 if (!col.IsNull())
1382 {
1383 }
1384
1385 TString dis = GetEnv("Display", "");
1386 if (dis.BeginsWith("Full", TString::kIgnoreCase))
1387 SetFullDisplay();
1388 if (dis.BeginsWith("DataCheck", TString::kIgnoreCase))
1389 SetDataCheckDisplay();
1390 if (dis.BeginsWith("Normal", TString::kIgnoreCase))
1391 SetNormalDisplay();
1392
1393 SetRelTimeCalibration(GetEnv("RelTimeCalibration", IsRelTimes()));
1394 SetDataCheck(GetEnv("Datacheck", IsDataCheck()));
1395 SetDebug(GetEnv("Debug", IsDebug()));
1396 SetIntensity(GetEnv("Intensity", IsIntensity()));
1397
1398 SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel()));
1399 SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
1400 SetGeometry(GetEnv("Geometry", fGeometry));
1401
1402 return kTRUE;
1403}
1404
1405// --------------------------------------------------------------------------
1406//
1407// Call the ProcessFile(MPedestalCam)
1408//
1409Bool_t MJCalibration::Process(MPedestalCam &pedcam)
1410{
1411 if (!ReadCalibrationCam())
1412 return ProcessFile(pedcam);
1413
1414 return kTRUE;
1415}
1416
1417void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext,
1418 MHCalibrationChargeBlindCam &blindcam)
1419{
1420
1421 Int_t run = fSequence.IsValid() ? fSequence.GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
1422
1423 //
1424 // Initialize the blind pixel. Unfortunately, there is a hardware difference
1425 // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
1426 // later setup. The first needs to use a filter because of the length of
1427 // spurious NSB photon signals. The latter get better along extracting the amplitude
1428 // from a small window.
1429 //
1430 if (run < gkSecondBlindPixelInstallation)
1431 {
1432
1433 MCalibrationBlindCamOneOldStyle blindresults;
1434 if (IsIntensity())
1435 blindresults.Copy(*fIntensBlindCam.GetCam());
1436 else
1437 blindresults.Copy(fCalibrationBlindCam);
1438
1439 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
1440 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1441 blindext.SetRange(10,19,0,6);
1442 blindext.SetNSBFilterLimit(70);
1443 }
1444 else if (run < gkThirdBlindPixelInstallation)
1445 {
1446
1447 MCalibrationBlindCamTwoNewStyle blindresults;
1448
1449 if (IsIntensity())
1450 blindresults.Copy(*fIntensBlindCam.GetCam());
1451 else
1452 blindresults.Copy(fCalibrationBlindCam);
1453
1454 blindext.SetNumBlindPixels(blindresults.GetSize());
1455 for (Int_t i=0;i<blindresults.GetSize();i++)
1456 blindext.SetBlindPixelIdx(blindresults[i].GetPixId(),i);
1457
1458 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
1459 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1460 blindext.SetRange(5,8,0,2);
1461 blindext.SetNSBFilterLimit(38);
1462
1463 }
1464 else
1465 {
1466 *fLog << err << "Third blind pixel installation not yet completed, check your run number!!! " << endl;
1467 }
1468
1469}
1470
1471// --------------------------------------------------------------------------
1472//
1473// Execute the task list and the eventloop:
1474//
1475// - Check if there are fRuns, otherwise return
1476// - Check the colour of the files in fRuns (FindColor()), otherwise return
1477// - Check for consistency between run numbers and number of files
1478// - Add fRuns to MReadMarsFile
1479// - Put into MParList:
1480// 1) MPedestalCam (pedcam)
1481// 2) MCalibrationQECam (fQECam)
1482// 3) MCalibrationChargeCam (fCalibrationCam)
1483// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag IsRelTimes() is chosen)
1484// 5) MBadPixelsCam (fBadPixels)
1485// 6) MCalibrationChargePINDiode
1486// 7) MCalibrationBlindPix
1487// - Put into the MTaskList:
1488// 1) MReadMarsFile
1489// 2) MBadPixelsMerge
1490// 3) MGeomApply
1491// 4) MExtractor
1492// 5) MExtractPINDiode
1493// 6) MExtractBlindPixel
1494// 7) MExtractTime (only if flag IsRelTimes() is chosen)
1495// 8) MContinue(MFCosmics)
1496// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode")
1497// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam")
1498// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam")
1499// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillRelTime")
1500// 13) MCalibrationChargeCalc
1501// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag IsRelTimes() is chosen)
1502// 15) MCalibrationRelTimeCalc
1503// - Execute MEvtLoop
1504// - DisplayResult()
1505// - WriteResult()
1506//
1507Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
1508{
1509 if (!fSequence.IsValid())
1510 {
1511 if (!fRuns)
1512 {
1513 *fLog << err << "No Runs choosen... abort." << endl;
1514 return kFALSE;
1515 }
1516
1517 if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
1518 {
1519 *fLog << err << "Number of files found doesn't match number of runs... abort."
1520 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
1521 return kFALSE;
1522 }
1523 }
1524
1525 //if (!CheckEnv())
1526 // return kFALSE;
1527
1528 CheckEnv();
1529
1530 // --------------------------------------------------------------------------------
1531
1532 *fLog << inf;
1533 fLog->Separator(GetDescriptor());
1534
1535 // if (!FindColor())
1536 // return kFALSE;
1537
1538 *fLog << "Calculate MCalibrationCam from ";
1539 if (fSequence.IsValid())
1540 *fLog << "Sequence #" << fSequence.GetSequence() << endl;
1541 else
1542 *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
1543 *fLog << endl;
1544
1545 // --------------------------------------------------------------------------------
1546
1547 // Setup Tasklist
1548 MParList plist;
1549 MTaskList tlist;
1550 plist.AddToList(&tlist);
1551 plist.AddToList(this); // take care of fDisplay!
1552
1553 MDirIter iter;
1554 if (fSequence.IsValid())
1555 {
1556 const Int_t n0 = fSequence.SetupCalRuns(iter, fPathData);
1557 const Int_t n1 = fSequence.GetNumCalRuns();
1558 if (n0==0)
1559 {
1560 *fLog << err << "ERROR - No input files of sequence found!" << endl;
1561 return kFALSE;
1562 }
1563 if (n0!=n1)
1564 {
1565 *fLog << err << "ERROR - Number of files found ("
1566 << n0 << ") doesn't match number of files in sequence ("
1567 << n1 << ")" << endl;
1568 return kFALSE;
1569 }
1570 }
1571
1572 //
1573 // Input containers
1574 //
1575 plist.AddToList(&pedcam);
1576 plist.AddToList(&fBadPixels);
1577
1578 //
1579 // Calibration Results containers
1580 //
1581 if (IsIntensity())
1582 {
1583 plist.AddToList(&fIntensQECam);
1584 plist.AddToList(&fIntensCalibCam);
1585 plist.AddToList(&fIntensBlindCam);
1586 // plist.AddToList(&fIntensCalibrationPINDiode);
1587 plist.AddToList(&fIntensRelTimeCam);
1588 plist.AddToList(&fIntensBadCam);
1589 }
1590 else
1591 {
1592 plist.AddToList(&fQECam);
1593 plist.AddToList(&fCalibrationCam);
1594 plist.AddToList(&fCalibrationBlindCam);
1595 plist.AddToList(&fCalibrationPINDiode);
1596 plist.AddToList(&fRelTimeCam);
1597 }
1598
1599 //
1600 // Initialize two histogram containers which could be modified in this class
1601 //
1602 MHCalibrationChargeCam chargecam;
1603 MHCalibrationChargeBlindCam blindcam;
1604 plist.AddToList(&chargecam);
1605 plist.AddToList(&blindcam);
1606
1607 //
1608 // Data Reading tasks
1609 //
1610 MReadMarsFile read("Events");
1611 MRawFileRead rawread(NULL);
1612
1613 if (IsDataCheck())
1614 {
1615 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1616 tlist.AddToList(&rawread);
1617 }
1618 else
1619 {
1620 read.DisableAutoScheme();
1621 read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1622 tlist.AddToList(&read);
1623 }
1624
1625 //
1626 // Other Tasks
1627 //
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
1641 if (!fSequence.IsValid())
1642 {
1643 calcalc.SetOutputPath(fPathOut);
1644 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1645 }
1646
1647 if (IsDebug())
1648 {
1649 chargecam.SetDebug();
1650 calcalc.SetDebug();
1651 }
1652
1653 //
1654 // Calibration histogramming
1655 //
1656 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
1657 MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
1658 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
1659 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
1660 fillpin.SetNameTab("PINDiode");
1661 fillbnd.SetNameTab("BlindPix");
1662 fillcam.SetNameTab("Charge");
1663 filltme.SetNameTab("RelTimes");
1664
1665 TString drawoption;
1666
1667 if (fDisplayType == kDataCheckDisplay)
1668 drawoption += "datacheck";
1669 if (fDisplayType == kFullDisplay)
1670 drawoption += " all";
1671
1672 fillcam.SetDrawOption(drawoption.Data());
1673 fillbnd.SetDrawOption(drawoption.Data());
1674 fillpin.SetDrawOption(drawoption.Data());
1675 filltme.SetDrawOption(drawoption.Data());
1676
1677 //
1678 // Apply a filter against cosmics
1679 // (will have to be needed in the future
1680 // when the calibration hardware-trigger is working)
1681 //
1682 MFCosmics cosmics;
1683 MContinue cont(&cosmics);
1684
1685 MTaskEnv taskenv("ExtractSignal");
1686 taskenv.SetDefault(fExtractor ? fExtractor : &extract2);
1687
1688 tlist.AddToList(&merge);
1689 tlist.AddToList(&apply);
1690 tlist.AddToList(&taskenv);
1691 tlist.AddToList(&pinext);
1692 tlist.AddToList(&blindext);
1693
1694 MTaskEnv taskenv2("ExtractTime");
1695 taskenv2.SetDefault(fTimeExtractor ? fTimeExtractor : &timespline);
1696
1697 if (IsRelTimes())
1698 tlist.AddToList(&taskenv2);
1699
1700 //
1701 // FIXME: This is not yet implemented in the classes!!!
1702 //
1703 if (fColor == MCalibrationCam::kCT1)
1704 tlist.AddToList(&cont);
1705
1706 MCalibColorSet colorset;
1707 tlist.AddToList(&colorset);
1708
1709 MCalibColorSteer steer;
1710 if (IsIntensity())
1711 tlist.AddToList(&steer);
1712
1713 tlist.AddToList(&fillcam);
1714
1715 if (IsRelTimes())
1716 {
1717 tlist.AddToList(&filltme);
1718 tlist.AddToList(&timecalc);
1719 }
1720
1721 if (IsUseBlindPixel())
1722 tlist.AddToList(&fillbnd);
1723 if (IsUsePINDiode())
1724 tlist.AddToList(&fillpin);
1725
1726 tlist.AddToList(&calcalc);
1727
1728 // Create and setup the eventloop
1729 MEvtLoop evtloop(fName);
1730 evtloop.SetParList(&plist);
1731 evtloop.SetDisplay(fDisplay);
1732 evtloop.SetLogStream(fLog);
1733 if (!SetupEnv(evtloop))
1734 return kFALSE;
1735
1736 if (!taskenv.GetTask() && !taskenv2.GetTask())
1737 {
1738 *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initialized or both '<dummy>'." << endl;
1739 return kFALSE;
1740 }
1741
1742 if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
1743 return kFALSE;
1744
1745 // Execute first analysis
1746 if (!evtloop.Eventloop())
1747 {
1748 *fLog << err << GetDescriptor() << ": Failed." << endl;
1749 return kFALSE;
1750 }
1751
1752 tlist.PrintStatistics();
1753
1754 //
1755 // The next lines are necessary in order to avoid that
1756 // the last entry drawn by MFillH gets deleted again from
1757 // the display. No idea where this comes from...
1758 //
1759 // FIND THE REASON! THE NEXT CHANGE SOMEBODY DOES MIGHT RESULT
1760 // IN __YOUR__ WORKAROUN NOT WORKING IF IT IS NOT CLEANLY DONE!
1761 //
1762 // THE AUTHOR OF MFILLH SHOULD FIND THE REASON INSTEAD OF DELETING
1763 // CODE WITHOUT INFORMING THE DATACHECK PEOPLE - SORRY, I SPENT
1764 // TOO MANY DAYS TRYING TO FIND THIS REASON!
1765 //
1766 // There is NO BUG-REPORT! And no code has been deleted! And
1767 // there is NO hint who wrote this work around and should
1768 // be informed! Maybe the author of a WORKAROUND should contact
1769 // the author of a class which he/she identified not working
1770 // correctly instead of vice versa!
1771 //
1772 if (fDisplay)
1773 {
1774 if (IsUsePINDiode())
1775 {
1776 MHCalibrationChargePINDiode *pin =
1777 (MHCalibrationChargePINDiode*)plist.FindObject("MHCalibrationChargePINDiode");
1778 pin->DrawClone(Form("nonew %s",drawoption.Data()));
1779 }
1780 else if (IsUseBlindPixel())
1781 {
1782 MHCalibrationChargeBlindCam *cam =
1783 (MHCalibrationChargeBlindCam*)plist.FindObject("MHCalibrationChargeBlindCam");
1784 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1785 }
1786 else if (IsRelTimes())
1787 {
1788 MHCalibrationRelTimeCam *cam =
1789 (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
1790 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1791 }
1792 else
1793 chargecam.DrawClone(Form("nonew %s",drawoption.Data()));
1794 }
1795
1796 DisplayResult(plist);
1797
1798 if (!WriteResult(plist.FindObject("MGeomCam")))
1799 return kFALSE;
1800
1801 *fLog << all << GetDescriptor() << ": Done." << endl;
1802
1803 return kTRUE;
1804}
1805
1806// --------------------------------------------------------------------------
1807//
1808// Read the following containers from GetOutputFile()
1809// - MCalibrationChargeCam
1810// - MCalibrationQECam
1811// - MBadPixelsCam
1812//
1813Bool_t MJCalibration::ReadCalibrationCam()
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 if (fPathOut.IsNull())
1885 return kTRUE;
1886
1887 const TString oname(GetOutputFile());
1888
1889 *fLog << inf << "Writing to file: " << oname << endl;
1890
1891 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1892 if (!file.IsOpen())
1893 {
1894 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1895 return kFALSE;
1896 }
1897
1898 if (evtloop.Write(fName)<=0)
1899 {
1900 *fLog << err << "Unable to write MEvtloop to " << oname << endl;
1901 return kFALSE;
1902 }
1903
1904 return kTRUE;
1905}
1906
1907Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
1908{
1909 if (fPathOut.IsNull())
1910 return kTRUE;
1911
1912 const TString oname(GetOutputFile());
1913
1914 *fLog << inf << "Writing to file: " << oname << endl;
1915
1916 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1917 if (!file.IsOpen())
1918 {
1919 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1920 return kFALSE;
1921 }
1922
1923 if (t1 && t1->Write()<=0)
1924 {
1925 *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
1926 return kFALSE;
1927 }
1928 if (t2 && t2->Write()<=0)
1929 {
1930 *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
1931 return kFALSE;
1932 }
1933
1934 return kTRUE;
1935}
1936
1937// --------------------------------------------------------------------------
1938//
1939// Write the result into the output file GetOutputFile(), if fOutputPath exists.
1940//
1941// The following containers are written:
1942// - MStatusDisplay
1943// - MCalibrationChargeCam or MCalibrationIntensityChargeCam
1944// - MCalibrationBlindCam or MCalibrationIntensityBlindCam
1945// - MCalibrationQECam or MCalibrationIntensityQECam
1946// - MBadPixelsCam
1947//
1948Bool_t MJCalibration::WriteResult(TObject *geom)
1949{
1950 if (fPathOut.IsNull())
1951 return kTRUE;
1952
1953 const TString oname(GetOutputFile());
1954
1955 *fLog << inf << "Writing to file: " << oname << endl;
1956
1957 TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
1958 if (!file.IsOpen())
1959 {
1960 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1961 return kFALSE;
1962 }
1963
1964 *fLog << inf << " - MStatusDisplay..." << flush;
1965 if (fDisplay && fDisplay->Write()<=0)
1966 {
1967 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
1968 return kFALSE;
1969 }
1970 *fLog << inf << "ok." << endl;
1971
1972 if (IsIntensity())
1973 {
1974 *fLog << inf << " - MBadPixelsIntensityCam..." << flush;
1975 if (fIntensBadCam.Write()<=0)
1976 {
1977 *fLog << err << "Unable to write MBadPixelsIntensityCam to " << oname << endl;
1978 return kFALSE;
1979 }
1980 *fLog << inf << "ok." << endl;
1981
1982 *fLog << inf << " - MCalibrationIntensityChargeCam..." << flush;
1983 if (fIntensCalibCam.Write()<=0)
1984 {
1985 *fLog << err << "Unable to write MCalibrationIntensityChargeCam to " << oname << endl;
1986 return kFALSE;
1987 }
1988 *fLog << inf << "ok." << endl;
1989
1990 *fLog << inf << " - MCalibrationIntensityQECam..." << flush;
1991 if (fIntensQECam.Write()<=0)
1992 {
1993 *fLog << err << "Unable to write MCalibrationIntensityQECam to " << oname << endl;
1994 return kFALSE;
1995 }
1996 *fLog << inf << "ok." << endl;
1997 *fLog << inf << " - MCalibrationIntensityBlindCam..." << flush;
1998 if (fIntensBlindCam.Write()<=0)
1999 {
2000 *fLog << err << "Unable to write MCalibrationIntensityBlindCam to " << oname << endl;
2001 return kFALSE;
2002 }
2003 *fLog << inf << "ok." << endl;
2004 }
2005 else
2006 {
2007 *fLog << inf << " - MCalibrationChargeCam..." << flush;
2008 if (fCalibrationCam.Write()<=0)
2009 {
2010 *fLog << err << "Unable to write MCalibrationChargeCam to " << oname << endl;
2011 return kFALSE;
2012 }
2013 *fLog << inf << "ok." << endl;
2014
2015 *fLog << inf << " - MCalibrationQECam..." << flush;
2016 if (fQECam.Write()<=0)
2017 {
2018 *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
2019 return kFALSE;
2020 }
2021 *fLog << inf << "ok." << endl;
2022
2023 *fLog << inf << " - MCalibrationBlindCam..." << flush;
2024 if (fCalibrationBlindCam.Write()<=0)
2025 {
2026 *fLog << err << "Unable to write MCalibrationBlindCam to " << oname << endl;
2027 return kFALSE;
2028 }
2029 *fLog << inf << "ok." << endl;
2030 }
2031
2032 *fLog << inf << " - MCalibrationChargePINDiode..." << flush;
2033 if (fCalibrationPINDiode.Write()<=0)
2034 {
2035 *fLog << err << "Unable to write MCalibrationChargePINDiode to " << oname << endl;
2036 return kFALSE;
2037 }
2038 *fLog << inf << "ok." << endl;
2039
2040 *fLog << inf << " - MBadPixelsCam..." << flush;
2041 if (fBadPixels.Write()<=0)
2042 {
2043 *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
2044 return kFALSE;
2045 }
2046 *fLog << inf << "ok." << endl;
2047
2048 if (!geom)
2049 *fLog << warn << " - WARNING: MGeomCam... not found!" << endl;
2050 {
2051 *fLog << inf << " - MGeomCam..." << flush;
2052 if (geom->Write()<=0)
2053 {
2054 *fLog << err << "Unable to write MGeomCam to " << oname << endl;
2055 return kFALSE;
2056 }
2057 *fLog << inf << "ok." << endl;
2058 }
2059
2060 if (IsRelTimes())
2061 {
2062 if (IsIntensity())
2063 {
2064 *fLog << inf << " - MCalibrationIntensityRelTimeCam..." << flush;
2065 if (fIntensRelTimeCam.Write()<=0)
2066 {
2067 *fLog << err << "Unable to write MCalibrationIntensityRelTimeCam to " << oname << endl;
2068 return kFALSE;
2069 }
2070 *fLog << inf << "ok." << endl;
2071 }
2072 else
2073 {
2074 *fLog << inf << " - MCalibrationRelTimeCam..." << flush;
2075 if (fRelTimeCam.Write()<=0)
2076 {
2077 *fLog << err << "Unable to write MCalibrationRelTimeCam to " << oname << endl;
2078 return kFALSE;
2079 }
2080 *fLog << inf << "ok." << endl;
2081 }
2082
2083 }
2084
2085 return kTRUE;
2086
2087}
2088
2089void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
2090{
2091
2092 TArrayI inner(1);
2093 inner[0] = 0;
2094
2095 TArrayI outer(1);
2096 outer[0] = 1;
2097
2098 TArrayI s1(3);
2099 s1[0] = 6;
2100 s1[1] = 1;
2101 s1[2] = 2;
2102
2103 TArrayI s2(3);
2104 s2[0] = 3;
2105 s2[1] = 4;
2106 s2[2] = 5;
2107
2108 TVirtualPad *pad = gPad;
2109 pad->Divide(2,1);
2110
2111 TH1D *inout[2];
2112
2113 for (int i=0; i<2; i++)
2114 {
2115 pad->cd(i+1);
2116 gPad->SetBorderMode(0);
2117 gPad->SetTicks();
2118
2119 inout[i] = cam->ProjectionS(TArrayI(), TArrayI(1,&i), i==0 ? "Inner" : "Outer");
2120 FixDataCheckHist(inout[i]);
2121 inout[i]->SetTitle(Form("%s %s",cam->GetTitle(),i==0 ? "Inner" : "Outer"));
2122 inout[i]->SetDirectory(NULL);
2123 inout[i]->SetLineColor(kRed+i);
2124 inout[i]->SetBit(kCanDelete);
2125 inout[i]->Draw();
2126 //
2127 // Display the outliers as dead and noisy pixels
2128 //
2129 if (!inout[i]->Fit("gaus","0Q"))
2130 DisplayOutliers(inout[i],whatsmall,whatbig);
2131
2132 gPad->Modified();
2133 gPad->Update();
2134 TPaveStats *st = (TPaveStats*)inout[i]->GetListOfFunctions()->FindObject("stats");
2135 st->SetY1NDC(0.6);
2136 st->SetY2NDC(0.9);
2137 st->SetX1NDC(0.55);
2138 st->SetX2NDC(0.99);
2139 gPad->Modified();
2140 gPad->Update();
2141
2142 TLegend *leg2 = new TLegend(0.55,0.4,0.99,0.6);
2143
2144 //
2145 // Display the two half of the camera separately
2146 //
2147 TH1D *half[2];
2148 half[0] = cam->ProjectionS(s1, TArrayI(1,&i), "Sector 6-1-2");
2149 half[1] = cam->ProjectionS(s2, TArrayI(1,&i), "Sector 3-4-5");
2150
2151 for (int j=0; j<2; j++)
2152 {
2153 half[j]->SetLineColor(kRed+i+2*j+1);
2154 half[j]->SetDirectory(NULL);
2155 half[j]->SetBit(kCanDelete);
2156 half[j]->Draw("same");
2157 leg2->AddEntry(half[j], half[j]->GetName(), "l");
2158 }
2159 leg2->Draw();
2160 }
2161}
Note: See TracBrowser for help on using the repository browser.