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

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