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

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