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

Last change on this file since 4991 was 4991, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 66.8 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 blindresults.Copy(fCalibrationBlindCam);
1435
1436 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
1437 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1438 blindext.SetRange(10,19,0,6);
1439 blindext.SetNSBFilterLimit(70);
1440 }
1441 else if (run < gkThirdBlindPixelInstallation)
1442 {
1443
1444 MCalibrationBlindCamTwoNewStyle blindresults;
1445 blindresults.Copy(fCalibrationBlindCam);
1446
1447 blindext.SetNumBlindPixels(blindresults.GetSize());
1448 for (Int_t i=0;i<blindresults.GetSize();i++)
1449 blindext.SetBlindPixelIdx(blindresults[i].GetPixId(),i);
1450
1451 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
1452 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1453 blindext.SetRange(5,8,0,2);
1454 blindext.SetNSBFilterLimit(38);
1455
1456 }
1457 else
1458 {
1459 *fLog << err << "Third blind pixel installation not yet completed, check your run number!!! " << endl;
1460 }
1461
1462}
1463
1464// --------------------------------------------------------------------------
1465//
1466// Execute the task list and the eventloop:
1467//
1468// - Check if there are fRuns, otherwise return
1469// - Check the colour of the files in fRuns (FindColor()), otherwise return
1470// - Check for consistency between run numbers and number of files
1471// - Add fRuns to MReadMarsFile
1472// - Put into MParList:
1473// 1) MPedestalCam (pedcam)
1474// 2) MCalibrationQECam (fQECam)
1475// 3) MCalibrationChargeCam (fCalibrationCam)
1476// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag IsRelTimes() is chosen)
1477// 5) MBadPixelsCam (fBadPixels)
1478// 6) MCalibrationChargePINDiode
1479// 7) MCalibrationBlindPix
1480// - Put into the MTaskList:
1481// 1) MReadMarsFile
1482// 2) MBadPixelsMerge
1483// 3) MGeomApply
1484// 4) MExtractor
1485// 5) MExtractPINDiode
1486// 6) MExtractBlindPixel
1487// 7) MExtractTime (only if flag IsRelTimes() is chosen)
1488// 8) MContinue(MFCosmics)
1489// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode")
1490// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam")
1491// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam")
1492// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillRelTime")
1493// 13) MCalibrationChargeCalc
1494// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag IsRelTimes() is chosen)
1495// 15) MCalibrationRelTimeCalc
1496// - Execute MEvtLoop
1497// - DisplayResult()
1498// - WriteResult()
1499//
1500Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
1501{
1502 if (!fSequence.IsValid())
1503 {
1504 if (!fRuns)
1505 {
1506 *fLog << err << "No Runs choosen... abort." << endl;
1507 return kFALSE;
1508 }
1509
1510 if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
1511 {
1512 *fLog << err << "Number of files found doesn't match number of runs... abort."
1513 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
1514 return kFALSE;
1515 }
1516 }
1517
1518 //if (!CheckEnv())
1519 // return kFALSE;
1520
1521 CheckEnv();
1522
1523 // --------------------------------------------------------------------------------
1524
1525 *fLog << inf;
1526 fLog->Separator(GetDescriptor());
1527
1528 if (!FindColor())
1529 return kFALSE;
1530
1531 *fLog << "Calculate MCalibrationCam from ";
1532 if (fSequence.IsValid())
1533 *fLog << "Sequence #" << fSequence.GetSequence() << endl;
1534 else
1535 *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
1536 *fLog << endl;
1537
1538 // --------------------------------------------------------------------------------
1539
1540 // Setup Tasklist
1541 MParList plist;
1542 MTaskList tlist;
1543 plist.AddToList(&tlist);
1544 plist.AddToList(this); // take care of fDisplay!
1545
1546 MDirIter iter;
1547 if (fSequence.IsValid())
1548 {
1549 const Int_t n0 = fSequence.SetupCalRuns(iter, fPathData);
1550 const Int_t n1 = fSequence.GetNumCalRuns();
1551 if (n0==0)
1552 {
1553 *fLog << err << "ERROR - No input files of sequence found!" << endl;
1554 return kFALSE;
1555 }
1556 if (n0!=n1)
1557 {
1558 *fLog << err << "ERROR - Number of files found ("
1559 << n0 << ") doesn't match number of files in sequence ("
1560 << n1 << ")" << endl;
1561 return kFALSE;
1562 }
1563 }
1564
1565 //
1566 // Input containers
1567 //
1568 plist.AddToList(&pedcam);
1569 plist.AddToList(&fBadPixels);
1570
1571 //
1572 // Calibration Results containers
1573 //
1574 if (IsIntensity())
1575 {
1576 plist.AddToList(&fIntensQECam);
1577 plist.AddToList(&fIntensCalibCam);
1578 plist.AddToList(&fIntensBlindCam);
1579 // plist.AddToList(&fIntensCalibrationPINDiode);
1580 plist.AddToList(&fIntensRelTimeCam);
1581 }
1582 else
1583 {
1584 plist.AddToList(&fQECam);
1585 plist.AddToList(&fCalibrationCam);
1586 plist.AddToList(&fCalibrationBlindCam);
1587 plist.AddToList(&fCalibrationPINDiode);
1588 plist.AddToList(&fRelTimeCam);
1589 }
1590
1591 //
1592 // Initialize two histogram containers which could be modified in this class
1593 //
1594 MHCalibrationChargeCam chargecam;
1595 MHCalibrationChargeBlindCam blindcam;
1596 plist.AddToList(&chargecam);
1597 plist.AddToList(&blindcam);
1598
1599 //
1600 // Data Reading tasks
1601 //
1602 MReadMarsFile read("Events");
1603 MRawFileRead rawread(NULL);
1604
1605 if (IsDataCheck())
1606 {
1607 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1608 tlist.AddToList(&rawread);
1609 }
1610 else
1611 {
1612 read.DisableAutoScheme();
1613 read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1614 tlist.AddToList(&read);
1615 }
1616
1617 //
1618 // Other Tasks
1619 //
1620 MGeomApply apply;
1621 apply.SetGeometry(fGeometry);
1622 MBadPixelsMerge merge(&fBadPixels);
1623 MExtractPINDiode pinext;
1624 MExtractBlindPixel blindext;
1625
1626 InitBlindPixel(blindext, blindcam);
1627
1628 MExtractSlidingWindow extract2;
1629 MExtractTimeFastSpline timespline;
1630 MCalibrationChargeCalc calcalc;
1631 MCalibrationRelTimeCalc timecalc;
1632
1633 if (!fSequence.IsValid())
1634 {
1635 calcalc.SetOutputPath(fPathOut);
1636 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1637 }
1638
1639 if (IsDebug())
1640 {
1641 chargecam.SetDebug();
1642 calcalc.SetDebug();
1643 }
1644
1645 //
1646 // Calibration histogramming
1647 //
1648 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
1649 MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
1650 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
1651 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
1652 fillpin.SetNameTab("PINDiode");
1653 fillbnd.SetNameTab("BlindPix");
1654 fillcam.SetNameTab("Charge");
1655 filltme.SetNameTab("RelTimes");
1656
1657 TString drawoption;
1658
1659 if (fDisplayType == kDataCheckDisplay)
1660 drawoption += "datacheck";
1661 if (fDisplayType == kFullDisplay)
1662 drawoption += " all";
1663
1664 fillcam.SetDrawOption(drawoption.Data());
1665 fillbnd.SetDrawOption(drawoption.Data());
1666 fillpin.SetDrawOption(drawoption.Data());
1667 filltme.SetDrawOption(drawoption.Data());
1668
1669 //
1670 // Apply a filter against cosmics
1671 // (will have to be needed in the future
1672 // when the calibration hardware-trigger is working)
1673 //
1674 MFCosmics cosmics;
1675 MContinue cont(&cosmics);
1676
1677 MTaskEnv taskenv("ExtractSignal");
1678 taskenv.SetDefault(fExtractor ? fExtractor : &extract2);
1679
1680 tlist.AddToList(&merge);
1681 tlist.AddToList(&apply);
1682 tlist.AddToList(&taskenv);
1683 tlist.AddToList(&pinext);
1684 tlist.AddToList(&blindext);
1685
1686 MTaskEnv taskenv2("ExtractTime");
1687 taskenv2.SetDefault(fTimeExtractor ? fTimeExtractor : &timespline);
1688
1689 if (IsRelTimes())
1690 tlist.AddToList(&taskenv2);
1691
1692 //
1693 // FIXME: This is not yet implemented in the classes!!!
1694 //
1695 if (fColor == MCalibrationCam::kCT1)
1696 tlist.AddToList(&cont);
1697
1698 MCalibColorSet colorset;
1699 tlist.AddToList(&colorset);
1700
1701 MCalibColorSteer steer;
1702 if (IsIntensity())
1703 tlist.AddToList(&steer);
1704
1705 tlist.AddToList(&fillcam);
1706
1707 if (IsRelTimes())
1708 {
1709 tlist.AddToList(&filltme);
1710 tlist.AddToList(&timecalc);
1711 }
1712
1713 if (IsUseBlindPixel())
1714 tlist.AddToList(&fillbnd);
1715 if (IsUsePINDiode())
1716 tlist.AddToList(&fillpin);
1717
1718 tlist.AddToList(&calcalc);
1719
1720 // Create and setup the eventloop
1721 MEvtLoop evtloop(fName);
1722 evtloop.SetParList(&plist);
1723 evtloop.SetDisplay(fDisplay);
1724 evtloop.SetLogStream(fLog);
1725 if (!SetupEnv(evtloop))
1726 return kFALSE;
1727
1728 if (!taskenv.GetTask() && !taskenv2.GetTask())
1729 {
1730 *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initialized or both '<dummy>'." << endl;
1731 return kFALSE;
1732 }
1733
1734 if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
1735 return kFALSE;
1736
1737 // Execute first analysis
1738 if (!evtloop.Eventloop())
1739 {
1740 *fLog << err << GetDescriptor() << ": Failed." << endl;
1741 return kFALSE;
1742 }
1743
1744 tlist.PrintStatistics();
1745
1746 //
1747 // The next lines are necessary in order to avoid that
1748 // the last entry drawn by MFillH gets deleted again from
1749 // the display. No idea where this comes from...
1750 //
1751 // FIND THE REASON! THE NEXT CHANGE SOMEBODY DOES MIGHT RESULT
1752 // IN __YOUR__ WORKAROUN NOT WORKING IF IT IS NOT CLEANLY DONE!
1753 //
1754 // THE AUTHOR OF MFILLH SHOULD FIND THE REASON INSTEAD OF DELETING
1755 // CODE WITHOUT INFORMING THE DATACHECK PEOPLE - SORRY, I SPENT
1756 // TOO MANY DAYS TRYING TO FIND THIS REASON!
1757 //
1758 // There is NO BUG-REPORT! And no code has been deleted! And
1759 // there is NO hint who wrote this work around and should
1760 // be informed! Maybe the author of a WORKAROUND should contact
1761 // the author of a class which he/she identified not working
1762 // correctly instead of vice versa!
1763 //
1764 if (fDisplay)
1765 {
1766 if (IsUsePINDiode())
1767 {
1768 MHCalibrationChargePINDiode *pin =
1769 (MHCalibrationChargePINDiode*)plist.FindObject("MHCalibrationChargePINDiode");
1770 pin->DrawClone(Form("nonew %s",drawoption.Data()));
1771 }
1772 else if (IsUseBlindPixel())
1773 {
1774 MHCalibrationChargeBlindCam *cam =
1775 (MHCalibrationChargeBlindCam*)plist.FindObject("MHCalibrationChargeBlindCam");
1776 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1777 }
1778 else if (IsRelTimes())
1779 {
1780 MHCalibrationRelTimeCam *cam =
1781 (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
1782 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1783 }
1784 else
1785 chargecam.DrawClone(Form("nonew %s",drawoption.Data()));
1786 }
1787
1788 DisplayResult(plist);
1789
1790 if (!WriteResult(plist.FindObject("MGeomCam")))
1791 return kFALSE;
1792
1793 *fLog << all << GetDescriptor() << ": Done." << endl;
1794
1795 return kTRUE;
1796}
1797
1798// --------------------------------------------------------------------------
1799//
1800// Read the following containers from GetOutputFile()
1801// - MCalibrationChargeCam
1802// - MCalibrationQECam
1803// - MBadPixelsCam
1804//
1805Bool_t MJCalibration::ReadCalibrationCam()
1806{
1807 const TString fname = GetOutputFile();
1808
1809 if (gSystem->AccessPathName(fname, kFileExists))
1810 {
1811 *fLog << err << "Input file " << fname << " doesn't exist." << endl;
1812 return kFALSE;
1813 }
1814
1815 *fLog << inf << "Reading from file: " << fname << endl;
1816
1817 TFile file(fname, "READ");
1818 if (fCalibrationCam.Read()<=0)
1819 {
1820 *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
1821 return kFALSE;
1822 }
1823
1824 if (fQECam.Read()<=0)
1825 {
1826 *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
1827 return kFALSE;
1828 }
1829
1830
1831 if (file.FindKey("MCalibrationRelTimeCam"))
1832 if (fRelTimeCam.Read()<=0)
1833 {
1834 *fLog << err << "Unable to read MCalibrationRelTimeCam from " << fname << endl;
1835 return kFALSE;
1836 }
1837
1838 if (file.FindKey("MBadPixelsCam"))
1839 {
1840 MBadPixelsCam bad;
1841 if (bad.Read()<=0)
1842 {
1843 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
1844 return kFALSE;
1845 }
1846 fBadPixels.Merge(bad);
1847 }
1848
1849 if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
1850 fDisplay->Read();
1851
1852 return kTRUE;
1853}
1854
1855
1856// --------------------------------------------------------------------------
1857//
1858// Set the useage of the Blind Pixel device
1859//
1860void MJCalibration::SetUseBlindPixel(const Bool_t b)
1861{
1862 b ? SETBIT(fDevices,kUseBlindPixel) : CLRBIT(fDevices,kUseBlindPixel);
1863}
1864
1865// --------------------------------------------------------------------------
1866//
1867// Set the useage of the PIN Diode device
1868//
1869void MJCalibration::SetUsePINDiode(const Bool_t b)
1870{
1871 b ? SETBIT(fDevices,kUsePINDiode) : CLRBIT(fDevices,kUsePINDiode);
1872}
1873
1874Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
1875{
1876 if (fPathOut.IsNull())
1877 return kTRUE;
1878
1879 const TString oname(GetOutputFile());
1880
1881 *fLog << inf << "Writing to file: " << oname << endl;
1882
1883 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1884 if (!file.IsOpen())
1885 {
1886 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1887 return kFALSE;
1888 }
1889
1890 if (evtloop.Write(fName)<=0)
1891 {
1892 *fLog << err << "Unable to write MEvtloop to " << oname << endl;
1893 return kFALSE;
1894 }
1895
1896 return kTRUE;
1897}
1898
1899Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
1900{
1901 if (fPathOut.IsNull())
1902 return kTRUE;
1903
1904 const TString oname(GetOutputFile());
1905
1906 *fLog << inf << "Writing to file: " << oname << endl;
1907
1908 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1909 if (!file.IsOpen())
1910 {
1911 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1912 return kFALSE;
1913 }
1914
1915 if (t1 && t1->Write()<=0)
1916 {
1917 *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
1918 return kFALSE;
1919 }
1920 if (t2 && t2->Write()<=0)
1921 {
1922 *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
1923 return kFALSE;
1924 }
1925
1926 return kTRUE;
1927}
1928
1929// --------------------------------------------------------------------------
1930//
1931// Write the result into the output file GetOutputFile(), if fOutputPath exists.
1932//
1933// The following containers are written:
1934// - MStatusDisplay
1935// - MCalibrationChargeCam or MCalibrationIntensityChargeCam
1936// - MCalibrationBlindCam or MCalibrationIntensityBlindCam
1937// - MCalibrationQECam or MCalibrationIntensityQECam
1938// - MBadPixelsCam
1939//
1940Bool_t MJCalibration::WriteResult(TObject *geom)
1941{
1942 if (fPathOut.IsNull())
1943 return kTRUE;
1944
1945 const TString oname(GetOutputFile());
1946
1947 *fLog << inf << "Writing to file: " << oname << endl;
1948
1949 TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
1950 if (!file.IsOpen())
1951 {
1952 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1953 return kFALSE;
1954 }
1955
1956 *fLog << inf << " - MStatusDisplay..." << flush;
1957 if (fDisplay && fDisplay->Write()<=0)
1958 {
1959 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
1960 return kFALSE;
1961 }
1962 *fLog << inf << "ok." << endl;
1963
1964 if (IsIntensity())
1965 {
1966 *fLog << inf << " - MCalibrationIntensityChargeCam..." << flush;
1967 if (fIntensCalibCam.Write()<=0)
1968 {
1969 *fLog << err << "Unable to write MCalibrationIntensityChargeCam to " << oname << endl;
1970 return kFALSE;
1971 }
1972 *fLog << inf << "ok." << endl;
1973
1974 *fLog << inf << " - MCalibrationIntensityQECam..." << flush;
1975 if (fIntensQECam.Write()<=0)
1976 {
1977 *fLog << err << "Unable to write MCalibrationIntensityQECam to " << oname << endl;
1978 return kFALSE;
1979 }
1980 *fLog << inf << "ok." << endl;
1981 *fLog << inf << " - MCalibrationIntensityBlindCam..." << flush;
1982 if (fIntensBlindCam.Write()<=0)
1983 {
1984 *fLog << err << "Unable to write MCalibrationIntensityBlindCam to " << oname << endl;
1985 return kFALSE;
1986 }
1987 *fLog << inf << "ok." << endl;
1988 }
1989 else
1990 {
1991 *fLog << inf << " - MCalibrationChargeCam..." << flush;
1992 if (fCalibrationCam.Write()<=0)
1993 {
1994 *fLog << err << "Unable to write MCalibrationChargeCam to " << oname << endl;
1995 return kFALSE;
1996 }
1997 *fLog << inf << "ok." << endl;
1998
1999 *fLog << inf << " - MCalibrationQECam..." << flush;
2000 if (fQECam.Write()<=0)
2001 {
2002 *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
2003 return kFALSE;
2004 }
2005 *fLog << inf << "ok." << endl;
2006
2007 *fLog << inf << " - MCalibrationBlindCam..." << flush;
2008 if (fCalibrationBlindCam.Write()<=0)
2009 {
2010 *fLog << err << "Unable to write MCalibrationBlindCam to " << oname << endl;
2011 return kFALSE;
2012 }
2013 *fLog << inf << "ok." << endl;
2014 }
2015
2016 *fLog << inf << " - MCalibrationChargePINDiode..." << flush;
2017 if (fCalibrationPINDiode.Write()<=0)
2018 {
2019 *fLog << err << "Unable to write MCalibrationChargePINDiode to " << oname << endl;
2020 return kFALSE;
2021 }
2022 *fLog << inf << "ok." << endl;
2023
2024 *fLog << inf << " - MBadPixelsCam..." << flush;
2025 if (fBadPixels.Write()<=0)
2026 {
2027 *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
2028 return kFALSE;
2029 }
2030 *fLog << inf << "ok." << endl;
2031
2032 if (!geom)
2033 *fLog << warn << " - WARNING: MGeomCam... not found!" << endl;
2034 {
2035 *fLog << inf << " - MGeomCam..." << flush;
2036 if (geom->Write()<=0)
2037 {
2038 *fLog << err << "Unable to write MGeomCam to " << oname << endl;
2039 return kFALSE;
2040 }
2041 *fLog << inf << "ok." << endl;
2042 }
2043
2044 if (IsRelTimes())
2045 {
2046 if (IsIntensity())
2047 {
2048 *fLog << inf << " - MCalibrationIntensityRelTimeCam..." << flush;
2049 if (fIntensRelTimeCam.Write()<=0)
2050 {
2051 *fLog << err << "Unable to write MCalibrationIntensityRelTimeCam to " << oname << endl;
2052 return kFALSE;
2053 }
2054 *fLog << inf << "ok." << endl;
2055 }
2056 else
2057 {
2058 *fLog << inf << " - MCalibrationRelTimeCam..." << flush;
2059 if (fRelTimeCam.Write()<=0)
2060 {
2061 *fLog << err << "Unable to write MCalibrationRelTimeCam to " << oname << endl;
2062 return kFALSE;
2063 }
2064 *fLog << inf << "ok." << endl;
2065 }
2066
2067 }
2068
2069 return kTRUE;
2070
2071}
2072
2073void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
2074{
2075
2076 TArrayI inner(1);
2077 inner[0] = 0;
2078
2079 TArrayI outer(1);
2080 outer[0] = 1;
2081
2082 TArrayI s1(3);
2083 s1[0] = 6;
2084 s1[1] = 1;
2085 s1[2] = 2;
2086
2087 TArrayI s2(3);
2088 s2[0] = 3;
2089 s2[1] = 4;
2090 s2[2] = 5;
2091
2092 TVirtualPad *pad = gPad;
2093 pad->Divide(2,1);
2094
2095 TH1D *inout[2];
2096
2097 for (int i=0; i<2; i++)
2098 {
2099 pad->cd(i+1);
2100 gPad->SetBorderMode(0);
2101 gPad->SetTicks();
2102
2103 inout[i] = cam->ProjectionS(TArrayI(), TArrayI(1,&i), i==0 ? "Inner" : "Outer");
2104 FixDataCheckHist(inout[i]);
2105 inout[i]->SetTitle(Form("%s %s",cam->GetTitle(),i==0 ? "Inner" : "Outer"));
2106 inout[i]->SetDirectory(NULL);
2107 inout[i]->SetLineColor(kRed+i);
2108 inout[i]->SetBit(kCanDelete);
2109 inout[i]->Draw();
2110 //
2111 // Display the outliers as dead and noisy pixels
2112 //
2113 if (!inout[i]->Fit("gaus","0Q"))
2114 DisplayOutliers(inout[i],whatsmall,whatbig);
2115
2116 gPad->Modified();
2117 gPad->Update();
2118 TPaveStats *st = (TPaveStats*)inout[i]->GetListOfFunctions()->FindObject("stats");
2119 st->SetY1NDC(0.6);
2120 st->SetY2NDC(0.9);
2121 st->SetX1NDC(0.55);
2122 st->SetX2NDC(0.99);
2123 gPad->Modified();
2124 gPad->Update();
2125
2126 TLegend *leg2 = new TLegend(0.55,0.4,0.99,0.6);
2127
2128 //
2129 // Display the two half of the camera separately
2130 //
2131 TH1D *half[2];
2132 half[0] = cam->ProjectionS(s1, TArrayI(1,&i), "Sector 6-1-2");
2133 half[1] = cam->ProjectionS(s2, TArrayI(1,&i), "Sector 3-4-5");
2134
2135 for (int j=0; j<2; j++)
2136 {
2137 half[j]->SetLineColor(kRed+i+2*j+1);
2138 half[j]->SetDirectory(NULL);
2139 half[j]->SetBit(kCanDelete);
2140 half[j]->Draw("same");
2141 leg2->AddEntry(half[j], half[j]->GetName(), "l");
2142 }
2143 leg2->Draw();
2144 }
2145}
Note: See TracBrowser for help on using the repository browser.