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

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