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

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