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

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