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

Last change on this file since 4855 was 4855, checked in by gaug, 20 years ago
*** empty log message ***
File size: 63.4 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)
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//
1340// For more details see the class description and the corresponding Getters
1341//
1342Bool_t MJCalibration::CheckEnvLocal()
1343{
1344 TString col = GetEnv("Color", "");
1345 if (!col.IsNull())
1346 {
1347 }
1348
1349 TString dis = GetEnv("Display", "");
1350 if (dis.BeginsWith("Full", TString::kIgnoreCase))
1351 SetFullDisplay();
1352 if (dis.BeginsWith("DataCheck", TString::kIgnoreCase))
1353 SetDataCheckDisplay();
1354 if (dis.BeginsWith("Normal", TString::kIgnoreCase))
1355 SetNormalDisplay();
1356
1357 SetRelTimeCalibration(GetEnv("RelTimeCalibration", fRelTimes));
1358 SetDataCheck(GetEnv("Datacheck", fDataCheck));
1359 SetDebug(GetEnv("Debug", fDebug));
1360 SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel()));
1361 SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
1362
1363 return kTRUE;
1364}
1365
1366// --------------------------------------------------------------------------
1367//
1368// Call the ProcessFile(MPedestalCam)
1369//
1370Bool_t MJCalibration::Process(MPedestalCam &pedcam)
1371{
1372 if (!ReadCalibrationCam())
1373 return ProcessFile(pedcam);
1374
1375 return kTRUE;
1376}
1377
1378void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext,
1379 MHCalibrationChargeBlindCam &blindcam)
1380{
1381
1382 Int_t run = fSequence.IsValid() ? fSequence.GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
1383
1384 //
1385 // Initialize the blind pixel. Unfortunately, there is a hardware difference
1386 // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
1387 // later setup. The first needs to use a filter because of the length of
1388 // spurious NSB photon signals. The latter get better along extracting the amplitude
1389 // from a small window.
1390 //
1391 if (run < gkSecondBlindPixelInstallation)
1392 {
1393
1394 MCalibrationChargeBlindCamOneOldStyle blindresults;
1395 blindresults.Copy(fCalibrationBlindCam);
1396
1397 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
1398 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1399 blindext.SetRange(10,19,0,6);
1400 blindext.SetNSBFilterLimit(70);
1401 blindcam.SetFitFunc( MHCalibrationChargeBlindPix::kEPoisson5 );
1402 }
1403 else if (run < gkThirdBlindPixelInstallation)
1404 {
1405
1406 MCalibrationChargeBlindCamTwoNewStyle blindresults;
1407 blindresults.Copy(fCalibrationBlindCam);
1408
1409 blindext.SetNumBlindPixels(blindresults.GetNumBlindPixels());
1410 for (UInt_t i=0;i<blindresults.GetNumBlindPixels();i++)
1411 blindext.SetBlindPixelIdx(blindresults[i].GetPixId(),i);
1412
1413 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
1414 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1415 blindext.SetRange(5,8,0,2);
1416 blindext.SetNSBFilterLimit(38);
1417
1418 }
1419 else
1420 {
1421 *fLog << err << "Third blind pixel installation not yet completed, check your run number!!! " << endl;
1422 }
1423
1424}
1425
1426// --------------------------------------------------------------------------
1427//
1428// Execute the task list and the eventloop:
1429//
1430// - Check if there are fRuns, otherwise return
1431// - Check the colour of the files in fRuns (FindColor()), otherwise return
1432// - Check for consistency between run numbers and number of files
1433// - Add fRuns to MReadMarsFile
1434// - Put into MParList:
1435// 1) MPedestalCam (pedcam)
1436// 2) MCalibrationQECam (fQECam)
1437// 3) MCalibrationChargeCam (fCalibrationCam)
1438// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag fRelTimes is chosen)
1439// 5) MBadPixelsCam (fBadPixels)
1440// 6) MCalibrationChargePINDiode
1441// 7) MCalibrationChargeBlindPix
1442// - Put into the MTaskList:
1443// 1) MReadMarsFile
1444// 2) MBadPixelsMerge
1445// 3) MGeomApply
1446// 4) MExtractor
1447// 5) MExtractPINDiode
1448// 6) MExtractBlindPixel
1449// 7) MExtractTime (only if flag fRelTimes is chosen)
1450// 8) MContinue(MFCosmics)
1451// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode")
1452// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel")
1453// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam")
1454// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam")
1455// 13) MCalibrationChargeCalc
1456// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag fRelTimes is chosen)
1457// 15) MCalibrationRelTimeCalc
1458// - Execute MEvtLoop
1459// - DisplayResult()
1460// - WriteResult()
1461//
1462Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
1463{
1464 if (!fSequence.IsValid())
1465 {
1466 if (!fRuns)
1467 {
1468 *fLog << err << "No Runs choosen... abort." << endl;
1469 return kFALSE;
1470 }
1471
1472 if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
1473 {
1474 *fLog << err << "Number of files found doesn't match number of runs... abort."
1475 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
1476 return kFALSE;
1477 }
1478 }
1479
1480 //if (!CheckEnv())
1481 // return kFALSE;
1482
1483 CheckEnv();
1484
1485 // --------------------------------------------------------------------------------
1486
1487 *fLog << inf;
1488 fLog->Separator(GetDescriptor());
1489
1490 if (!FindColor())
1491 return kFALSE;
1492
1493 *fLog << "Calculate MCalibrationCam from ";
1494 if (fSequence.IsValid())
1495 *fLog << "Sequence #" << fSequence.GetSequence() << endl;
1496 else
1497 *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
1498 *fLog << endl;
1499
1500 // --------------------------------------------------------------------------------
1501
1502 // Setup Tasklist
1503 MParList plist;
1504 MTaskList tlist;
1505 plist.AddToList(&tlist);
1506 plist.AddToList(this); // take care of fDisplay!
1507
1508 MReadMarsFile read("Events");
1509 MRawFileRead rawread(NULL);
1510
1511 MDirIter iter;
1512 if (fSequence.IsValid())
1513 {
1514 const Int_t n0 = fSequence.SetupCalRuns(iter, fPathData);
1515 const Int_t n1 = fSequence.GetNumCalRuns();
1516 if (n0==0)
1517 {
1518 *fLog << err << "ERROR - No input files of sequence found!" << endl;
1519 return kFALSE;
1520 }
1521 if (n0!=n1)
1522 {
1523 *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
1524 return kFALSE;
1525 }
1526 }
1527
1528 if (fDataCheck)
1529 {
1530 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1531 tlist.AddToList(&rawread);
1532 }
1533 else
1534 {
1535 read.DisableAutoScheme();
1536 read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1537 tlist.AddToList(&read);
1538 }
1539
1540 MHCalibrationChargeCam chargecam;
1541 MHCalibrationChargeBlindCam blindcam;
1542
1543 plist.AddToList(&pedcam);
1544 plist.AddToList(&chargecam);
1545 plist.AddToList(&blindcam);
1546 plist.AddToList(&fBadPixels);
1547 plist.AddToList(&fQECam);
1548 plist.AddToList(&fCalibrationCam);
1549 plist.AddToList(&fCalibrationBlindCam);
1550 plist.AddToList(&fCalibrationPINDiode);
1551 plist.AddToList(&fRelTimeCam);
1552
1553 MGeomApply apply;
1554 MBadPixelsMerge merge(&fBadPixels);
1555 MExtractPINDiode pinext;
1556 MExtractBlindPixel blindext;
1557
1558 InitBlindPixel(blindext, blindcam);
1559
1560 MExtractSlidingWindow extract2;
1561 MExtractTimeFastSpline timespline;
1562 MCalibrationChargeCalc calcalc;
1563 MCalibrationRelTimeCalc timecalc;
1564
1565 if (!fSequence.IsValid())
1566 {
1567 calcalc.SetOutputPath(fPathOut);
1568 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1569 }
1570
1571 if (fDebug)
1572 {
1573 chargecam.SetDebug();
1574 calcalc.SetDebug();
1575 }
1576
1577 //
1578 // As long as there are no DM's, have to colour by hand
1579 //
1580 chargecam.SetColor (fColor);
1581 calcalc.SetPulserColor(fColor);
1582
1583 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
1584 MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
1585 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
1586 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
1587 fillpin.SetNameTab("PINDiode");
1588 fillbnd.SetNameTab("BlindPix");
1589 fillcam.SetNameTab("Charge");
1590 filltme.SetNameTab("RelTimes");
1591
1592 TString drawoption;
1593
1594 if (fDisplayType == kDataCheckDisplay)
1595 drawoption += "datacheck";
1596 if (fDisplayType == kFullDisplay)
1597 drawoption += " all";
1598
1599 fillcam.SetDrawOption(drawoption.Data());
1600 fillbnd.SetDrawOption(drawoption.Data());
1601 fillpin.SetDrawOption(drawoption.Data());
1602 filltme.SetDrawOption(drawoption.Data());
1603
1604 //
1605 // Apply a filter against cosmics
1606 // (will have to be needed in the future
1607 // when the calibration hardware-trigger is working)
1608 //
1609 MFCosmics cosmics;
1610 MContinue cont(&cosmics);
1611
1612 tlist.AddToList(&merge);
1613 tlist.AddToList(&apply);
1614
1615 MTaskEnv taskenv("ExtractSignal");
1616 taskenv.SetDefault(fExtractor ? fExtractor : &extract2);
1617
1618 tlist.AddToList(&taskenv);
1619 tlist.AddToList(&pinext);
1620 tlist.AddToList(&blindext);
1621
1622 MTaskEnv taskenv2("ExtractTime");
1623 taskenv2.SetDefault(fTimeExtractor ? fTimeExtractor : &timespline);
1624
1625 if (fRelTimes)
1626 tlist.AddToList(&taskenv2);
1627
1628 if (fColor == MCalibrationCam::kCT1)
1629 tlist.AddToList(&cont);
1630
1631 tlist.AddToList(&fillcam);
1632
1633 if (fRelTimes)
1634 {
1635 tlist.AddToList(&filltme);
1636 tlist.AddToList(&timecalc);
1637 }
1638
1639 if (IsUseBlindPixel())
1640 tlist.AddToList(&fillbnd);
1641 if (IsUsePINDiode())
1642 tlist.AddToList(&fillpin);
1643
1644 tlist.AddToList(&calcalc);
1645
1646 // Create and setup the eventloop
1647 MEvtLoop evtloop(fName);
1648 evtloop.SetParList(&plist);
1649 evtloop.SetDisplay(fDisplay);
1650 evtloop.SetLogStream(fLog);
1651 if (!SetupEnv(evtloop))
1652 return kFALSE;
1653
1654 if (!taskenv.GetTask() && !taskenv2.GetTask())
1655 {
1656 *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initialized or both '<dummy>'." << endl;
1657 return kFALSE;
1658 }
1659
1660 if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
1661 return kFALSE;
1662
1663 // Execute first analysis
1664 if (!evtloop.Eventloop())
1665 {
1666 *fLog << err << GetDescriptor() << ": Failed." << endl;
1667 return kFALSE;
1668 }
1669
1670 tlist.PrintStatistics();
1671
1672 //
1673 // The next lines are necessary in order to avoid that
1674 // the last entry drawn by MFillH gets deleted again from
1675 // the display. No idea where this comes from...
1676 //
1677 // FIND THE REASON! THE NEXT CHANGE SOMEBODY DOES MIGHT RESULT
1678 // IN __YOUR__ WORKAROUN NOT WORKING IF IT IS NOT CLEANLY DONE!
1679 //
1680 // THE AUTHOR OF MFILLH SHOULD FIND THE REASON INSTEAD OF DELETING
1681 // CODE WITHOUT INFORMING THE DATACHECK PEOPLE - SORRY, I SPENT
1682 // TOO MANY DAYS TRYING TO FIND THIS REASON!
1683 //
1684 if (fDisplay)
1685 {
1686 if (IsUsePINDiode())
1687 {
1688 MHCalibrationChargePINDiode *pin =
1689 (MHCalibrationChargePINDiode*)plist.FindObject("MHCalibrationChargePINDiode");
1690 pin->DrawClone(Form("nonew %s",drawoption.Data()));
1691 }
1692 else if (IsUseBlindPixel())
1693 {
1694 MHCalibrationChargeBlindCam *cam =
1695 (MHCalibrationChargeBlindCam*)plist.FindObject("MHCalibrationChargeBlindCam");
1696 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1697 }
1698 else if (fRelTimes)
1699 {
1700 MHCalibrationRelTimeCam *cam =
1701 (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
1702 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1703 }
1704 else
1705 {
1706 MHCalibrationChargeCam *cam =
1707 (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
1708 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1709 }
1710 }
1711
1712 DisplayResult(plist);
1713
1714 if (!WriteResult())
1715 return kFALSE;
1716
1717 *fLog << all << GetDescriptor() << ": Done." << endl;
1718
1719 return kTRUE;
1720}
1721
1722// --------------------------------------------------------------------------
1723//
1724// Read the following containers from GetOutputFile()
1725// - MCalibrationChargeCam
1726// - MCalibrationQECam
1727// - MBadPixelsCam
1728//
1729Bool_t MJCalibration::ReadCalibrationCam()
1730{
1731 const TString fname = GetOutputFile();
1732
1733 if (gSystem->AccessPathName(fname, kFileExists))
1734 {
1735 *fLog << err << "Input file " << fname << " doesn't exist." << endl;
1736 return kFALSE;
1737 }
1738
1739 *fLog << inf << "Reading from file: " << fname << endl;
1740
1741 TFile file(fname, "READ");
1742 if (fCalibrationCam.Read()<=0)
1743 {
1744 *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
1745 return kFALSE;
1746 }
1747
1748 if (fQECam.Read()<=0)
1749 {
1750 *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
1751 return kFALSE;
1752 }
1753
1754
1755 if (file.FindKey("MCalibrationRelTimeCam"))
1756 if (fRelTimeCam.Read()<=0)
1757 {
1758 *fLog << err << "Unable to read MCalibrationRelTimeCam from " << fname << endl;
1759 return kFALSE;
1760 }
1761
1762 if (file.FindKey("MBadPixelsCam"))
1763 {
1764 MBadPixelsCam bad;
1765 if (bad.Read()<=0)
1766 {
1767 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
1768 return kFALSE;
1769 }
1770 fBadPixels.Merge(bad);
1771 }
1772
1773 if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
1774 fDisplay->Read();
1775
1776 return kTRUE;
1777}
1778
1779
1780// --------------------------------------------------------------------------
1781//
1782// Set the useage of the Blind Pixel device
1783//
1784void MJCalibration::SetUseBlindPixel(const Bool_t b)
1785{
1786 b ? SETBIT(fDevices,kUseBlindPixel) : CLRBIT(fDevices,kUseBlindPixel);
1787}
1788
1789// --------------------------------------------------------------------------
1790//
1791// Set the useage of the PIN Diode device
1792//
1793void MJCalibration::SetUsePINDiode(const Bool_t b)
1794{
1795 b ? SETBIT(fDevices,kUsePINDiode) : CLRBIT(fDevices,kUsePINDiode);
1796}
1797
1798Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
1799{
1800 if (fPathOut.IsNull())
1801 return kTRUE;
1802
1803 const TString oname(GetOutputFile());
1804
1805 *fLog << inf << "Writing to file: " << oname << endl;
1806
1807 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1808 if (!file.IsOpen())
1809 {
1810 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1811 return kFALSE;
1812 }
1813
1814 if (evtloop.Write(fName)<=0)
1815 {
1816 *fLog << err << "Unable to write MEvtloop to " << oname << endl;
1817 return kFALSE;
1818 }
1819
1820 return kTRUE;
1821}
1822
1823Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
1824{
1825 if (fPathOut.IsNull())
1826 return kTRUE;
1827
1828 const TString oname(GetOutputFile());
1829
1830 *fLog << inf << "Writing to file: " << oname << endl;
1831
1832 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
1833 if (!file.IsOpen())
1834 {
1835 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1836 return kFALSE;
1837 }
1838
1839 if (t1 && t1->Write()<=0)
1840 {
1841 *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
1842 return kFALSE;
1843 }
1844 if (t2 && t2->Write()<=0)
1845 {
1846 *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
1847 return kFALSE;
1848 }
1849
1850 return kTRUE;
1851}
1852
1853// --------------------------------------------------------------------------
1854//
1855// Write the result into the output file GetOutputFile(), if fOutputPath exists.
1856//
1857// The following containers are written:
1858// - MStatusDisplay
1859// - MCalibrationChargeCam
1860// - MCalibrationChargeBlindPix
1861// - MCalibrationQECam
1862// - MBadPixelsCam
1863//
1864Bool_t MJCalibration::WriteResult()
1865{
1866 if (fPathOut.IsNull())
1867 return kTRUE;
1868
1869 const TString oname(GetOutputFile());
1870
1871 *fLog << inf << "Writing to file: " << oname << endl;
1872
1873 TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
1874 if (!file.IsOpen())
1875 {
1876 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
1877 return kFALSE;
1878 }
1879
1880 *fLog << inf << " - MStatusDisplay..." << flush;
1881 if (fDisplay && fDisplay->Write()<=0)
1882 {
1883 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
1884 return kFALSE;
1885 }
1886 *fLog << inf << "ok." << endl;
1887
1888 *fLog << inf << " - MCalibrationChargeCam..." << flush;
1889 if (fCalibrationCam.Write()<=0)
1890 {
1891 *fLog << err << "Unable to write MCalibrationChargeCam to " << oname << endl;
1892 return kFALSE;
1893 }
1894 *fLog << inf << "ok." << endl;
1895
1896 *fLog << inf << " - MCalibrationChargeBlindCam..." << flush;
1897 if (fCalibrationBlindCam.Write()<=0)
1898 {
1899 *fLog << err << "Unable to write MCalibrationChargeBlindCam to " << oname << endl;
1900 return kFALSE;
1901 }
1902 *fLog << inf << "ok." << endl;
1903
1904 *fLog << inf << " - MCalibrationChargePINDiode..." << flush;
1905 if (fCalibrationPINDiode.Write()<=0)
1906 {
1907 *fLog << err << "Unable to write MCalibrationChargePINDiode to " << oname << endl;
1908 return kFALSE;
1909 }
1910 *fLog << inf << "ok." << endl;
1911
1912 *fLog << inf << " - MCalibrationQECam..." << flush;
1913 if (fQECam.Write()<=0)
1914 {
1915 *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
1916 return kFALSE;
1917 }
1918 *fLog << inf << "ok." << endl;
1919
1920 *fLog << inf << " - MBadPixelsCam..." << flush;
1921 if (fBadPixels.Write()<=0)
1922 {
1923 *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
1924 return kFALSE;
1925 }
1926 *fLog << inf << "ok." << endl;
1927
1928 if (fRelTimes)
1929 {
1930 *fLog << inf << " - MCalibrationRelTimeCam..." << flush;
1931 if (fRelTimeCam.Write()<=0)
1932 {
1933 *fLog << err << "Unable to write MCalibrationRelTimeCam to " << oname << endl;
1934 return kFALSE;
1935 }
1936 *fLog << inf << "ok." << endl;
1937 }
1938
1939 return kTRUE;
1940
1941}
1942
1943void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
1944{
1945
1946 TArrayI inner(1);
1947 inner[0] = 0;
1948
1949 TArrayI outer(1);
1950 outer[0] = 1;
1951
1952 TArrayI s0(6);
1953 s0[0] = 6;
1954 s0[1] = 1;
1955 s0[2] = 2;
1956 s0[3] = 3;
1957 s0[4] = 4;
1958 s0[5] = 5;
1959
1960 TArrayI s1(3);
1961 s1[0] = 6;
1962 s1[1] = 1;
1963 s1[2] = 2;
1964
1965 TArrayI s2(3);
1966 s2[0] = 3;
1967 s2[1] = 4;
1968 s2[2] = 5;
1969
1970 TVirtualPad *pad = gPad;
1971 pad->Divide(2,1);
1972
1973 TH1D *inout[2];
1974 inout[0] = cam->ProjectionS(s0, inner, "Inner");
1975 inout[1] = cam->ProjectionS(s0, outer, "Outer");
1976 FixDataCheckHist(inout[0]);
1977 FixDataCheckHist(inout[1]);
1978
1979 inout[0]->SetTitle(Form("%s %s",cam->GetTitle(),"Inner"));
1980 inout[1]->SetTitle(Form("%s %s",cam->GetTitle(),"Outer"));
1981
1982 for (int i=0; i<2; i++)
1983 {
1984 pad->cd(i+1);
1985 gPad->SetBorderMode(0);
1986 gPad->SetTicks();
1987
1988 inout[i]->SetDirectory(NULL);
1989 inout[i]->SetLineColor(kRed+i);
1990 inout[i]->SetBit(kCanDelete);
1991 inout[i]->Draw();
1992 inout[i]->Fit("gaus", "Q");
1993 gPad->Modified();
1994 gPad->Update();
1995 TPaveStats *st = (TPaveStats*)inout[i]->GetListOfFunctions()->FindObject("stats");
1996 st->SetY1NDC(0.6);
1997 st->SetY2NDC(0.9);
1998 st->SetX1NDC(0.55);
1999 st->SetX2NDC(0.99);
2000 gPad->Modified();
2001 gPad->Update();
2002
2003 TLegend *leg2 = new TLegend(0.55,0.4,0.99,0.6);
2004 //
2005 // Display the outliers as dead and noisy pixels
2006 //
2007 DisplayOutliers(inout[i],whatsmall,whatbig);
2008
2009 //
2010 // Display the two half of the camera separately
2011 //
2012 TH1D *half[2];
2013 half[0] = cam->ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
2014 half[1] = cam->ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
2015
2016 for (int j=0; j<2; j++)
2017 {
2018 half[j]->SetLineColor(kRed+i+2*j+1);
2019 half[j]->SetDirectory(NULL);
2020 half[j]->SetBit(kCanDelete);
2021 half[j]->Draw("same");
2022 leg2->AddEntry(half[j], half[j]->GetName(), "l");
2023 }
2024 leg2->Draw();
2025 }
2026}
Note: See TracBrowser for help on using the repository browser.