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

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