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

Last change on this file since 8280 was 8245, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 68.8 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19! 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 "MRunIter.h"
107#include "MSequence.h"
108#include "MParList.h"
109#include "MTaskList.h"
110#include "MEvtLoop.h"
111
112#include "MHCamera.h"
113#include "MGeomCam.h"
114
115#include "MPedestalCam.h"
116#include "MPedestalSubtract.h"
117#include "MCalibColorSteer.h"
118
119#include "MCalibrationIntensityChargeCam.h"
120#include "MCalibrationIntensityBlindCam.h"
121#include "MCalibrationIntensityRelTimeCam.h"
122#include "MCalibrationIntensityQECam.h"
123
124#include "MCalibrationPatternDecode.h"
125#include "MCalibrationCam.h"
126#include "MCalibrationHiLoCam.h"
127#include "MCalibrationHiLoPix.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 = "mjobs/hilocalib_df46.root";
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//
1471// MCalibrationHiLoCam
1472//
1473Bool_t MJCalibration::ReadHiLoCalibFile()
1474{
1475
1476 if (!fIsHiLoCalibration)
1477 return kTRUE;
1478
1479 TFile file(fHiLoCalibFile,"READ");
1480 if (!file.IsOpen())
1481 {
1482 *fLog << err << "ERROR - Couldn't open file " << fHiLoCalibFile << " for reading... abort." << endl;
1483 return kFALSE;
1484 }
1485
1486 MCalibrationHiLoCam hilocam;
1487 if (hilocam.Read()<=0)
1488 {
1489 *fLog << err << "Unable to read MCalibrationHiLoCam from " << fHiLoCalibFile << "... abort." << endl;
1490 return kFALSE;
1491 }
1492 if (hilocam.GetSize() < 1)
1493 {
1494 *fLog << err << "MCalibationHiLoCam is un-initialized in file " << fHiLoCalibFile << "... abort." << endl;
1495 return kFALSE;
1496 }
1497
1498 *fLog << all << "Hi-/Lo-Gain intercalibration constants read from " << fHiLoCalibFile << endl << endl;
1499
1500 if (fCalibrationCam.GetSize() < 1)
1501 fCalibrationCam.InitSize(hilocam.GetSize());
1502
1503 if (fBadPixels.GetSize() < 1)
1504 fBadPixels.InitSize(hilocam.GetSize());
1505
1506 if (fCalibrationCam.GetSize() != hilocam.GetSize())
1507 {
1508 *fLog << err << "Size mismatch MCalibationHiLoCam and MCalibrationChargeCam.. abort." << endl;
1509 return kFALSE;
1510 }
1511
1512 for (Int_t i=0;i<hilocam.GetSize();i++)
1513 {
1514 const MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)hilocam[i];
1515
1516 const Float_t ratio = pix.GetHiLoChargeRatio();
1517 const Float_t raterr = pix.GetHiLoChargeRatioErr();
1518 const Float_t sigma = pix.GetHiLoChargeRatioSigma();
1519
1520 if (ratio < 0.)
1521 {
1522 fBadPixels[i].SetUncalibrated(MBadPixelsPix::kConversionHiLoNotValid);
1523 continue;
1524 }
1525
1526 MCalibrationChargePix &cpix = (MCalibrationChargePix&)fCalibrationCam[i];
1527
1528 cpix.SetConversionHiLo(ratio);
1529 cpix.SetConversionHiLoErr(raterr);
1530 cpix.SetConversionHiLoSigma(sigma);
1531 }
1532
1533 return kTRUE;
1534}
1535
1536// --------------------------------------------------------------------------
1537//
1538// MJCalibration allows to setup several option by a resource file:
1539// MJCalibration.Display: full, datacheck, normal
1540// MJCalibration.RelTimeCalibration: yes,no
1541// MJCalibration.DataCheck: yes,no
1542// MJCalibration.Debug: yes,no
1543// MJCalibration.Intensity: yes,no
1544// MJCalibration.UseBlindPixel: yes,no
1545// MJCalibration.UsePINDiode: yes,no
1546// MJCalibration.Geometry: MGeomCamMagic, MGeomCamECO1000
1547//
1548// Name of a file containing reference values (see ReadReferenceFile)
1549// Prefix.ReferenceFile: filename
1550// (see ReadReferenceFile)
1551//
1552// For more details see the class description and the corresponding Getters
1553//
1554Bool_t MJCalibration::CheckEnvLocal()
1555{
1556 TString dis = GetEnv("Display", "");
1557 if (dis.BeginsWith("Full", TString::kIgnoreCase))
1558 SetFullDisplay();
1559 if (dis.BeginsWith("DataCheck", TString::kIgnoreCase))
1560 SetDataCheckDisplay();
1561 if (dis.BeginsWith("Normal", TString::kIgnoreCase))
1562 SetNormalDisplay();
1563
1564 if (!MJCalib::CheckEnvLocal())
1565 return kFALSE;
1566
1567 SetRelTimeCalibration(GetEnv("RelTimeCalibration", IsRelTimes()));
1568 SetIntensity(GetEnv("IntensityCalibration", IsIntensity()));
1569 SetDebug(GetEnv("Debug", IsDebug()));
1570
1571 SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel()));
1572 SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
1573 SetGeometry(GetEnv("Geometry", fGeometry));
1574
1575 fReferenceFile = GetEnv("ReferenceFile",fReferenceFile.Data());
1576 ReadReferenceFile();
1577
1578 fHiLoCalibFile = GetEnv("HiLoCalibFile",fHiLoCalibFile.Data());
1579
1580 if (IsUseMC() && !fHiLoCalibFile.EndsWith("_mc.root"))
1581 {
1582 if (!fHiLoCalibFile.EndsWith(".root"))
1583 {
1584 *fLog << warn << "WARNING - Hi-/Lo-Gain intercalibration file ";
1585 *fLog << fHiLoCalibFile << " has not .root as extension..." << endl;
1586 }
1587 else
1588 fHiLoCalibFile.Insert(fHiLoCalibFile.Length()-5, "_mc");
1589 }
1590
1591 return ReadHiLoCalibFile();
1592}
1593
1594void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext,
1595 MHCalibrationChargeBlindCam &blindcam)
1596{
1597 const Int_t run = fSequence.GetLastRun();
1598
1599 //
1600 // Initialize the blind pixel. Unfortunately, there is a hardware
1601 // difference in the first blind pixel until run
1602 // gkSecondBlindPixelInstallation and the later setup. The first
1603 // needs to use a filter because of the length of spurious NSB photon
1604 // signals. The latter get better along extracting the amplitude
1605 // from a small window.
1606 //
1607 const MCalibrationBlindCamOneOldStyle one;
1608 const MCalibrationBlindCamTwoNewStyle two;
1609 const MCalibrationBlindCamThreeNewStyle three;
1610
1611 const MCalibrationBlindCam &blindresults =
1612 run<gkSecondBlindPixelInstallation ? static_cast<MCalibrationBlindCam>(one) :
1613 (run<gkThirdBlindPixelInstallation ? static_cast<MCalibrationBlindCam>(two) : static_cast<MCalibrationBlindCam>(three));
1614
1615 if (IsIntensity())
1616 blindresults.Copy(*fIntensBlindCam.GetCam());
1617 else
1618 blindresults.Copy(fCalibrationBlindCam);
1619
1620 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
1621 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1622
1623 if (run<gkSecondBlindPixelInstallation)
1624 {
1625 blindext.SetRange(10,19,0,6);
1626 blindext.SetNSBFilterLimit(70);
1627 }
1628 else
1629 {
1630 blindext.SetRange(5,8,0,2);
1631 blindext.SetNSBFilterLimit(38);
1632 }
1633
1634 if (run>=gkThirdBlindPixelInstallation)
1635 blindext.SetDataType(MExtractBlindPixel::kRawEvt2);
1636}
1637
1638// --------------------------------------------------------------------------
1639//
1640// Execute the task list and the eventloop:
1641//
1642// - Check the colour of the files in fRuns (FindColor()), otherwise return
1643// - Check for consistency between run numbers and number of files
1644// - Add fRuns to MReadMarsFile
1645// - Put into MParList:
1646// 1) MPedestalCam (pedcam)
1647// 2) MCalibrationQECam (fQECam)
1648// 3) MCalibrationChargeCam (fCalibrationCam)
1649// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag IsRelTimes() is chosen)
1650// 5) MBadPixelsCam (fBadPixels)
1651// 6) MCalibrationChargePINDiode
1652// 7) MCalibrationBlindPix
1653// - Put into the MTaskList:
1654// 1) MReadMarsFile
1655// 2) MBadPixelsMerge
1656// 3) MGeomApply
1657// 4) MExtractor
1658// 5) MExtractPINDiode
1659// 6) MExtractBlindPixel
1660// 7) MExtractTime (only if flag IsRelTimes() is chosen)
1661// 8) MContinue(MFCosmics)
1662// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode")
1663// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam")
1664// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam")
1665// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillRelTime")
1666// 13) MCalibrationChargeCalc
1667// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag IsRelTimes() is chosen)
1668// 15) MCalibrationRelTimeCalc
1669// - Execute MEvtLoop
1670// - DisplayResult()
1671// - WriteResult()
1672//
1673Bool_t MJCalibration::Process(MPedestalCam &pedcam)
1674{
1675 if (!fSequence.IsValid())
1676 {
1677 *fLog << err << "ERROR - Sequence invalid..." << endl;
1678 return kFALSE;
1679 }
1680
1681 *fLog << inf;
1682 fLog->Separator(GetDescriptor());
1683 *fLog << "Calculate calibration constants from Sequence #";
1684 *fLog << fSequence.GetSequence() << endl << endl;
1685
1686 // --------------------------------------------------------------------------------
1687
1688 if (!CheckEnv())
1689 return kFALSE;
1690
1691 // --------------------------------------------------------------------------------
1692
1693 // Setup Tasklist
1694 MParList plist;
1695 MTaskList tlist;
1696 plist.AddToList(&tlist);
1697 plist.AddToList(this); // take care of fDisplay!
1698
1699 MDirIter iter;
1700 if (fSequence.SetupCalRuns(iter, 0, IsUseRawData())<=0)
1701 return kFALSE;
1702
1703 //
1704 // Input containers
1705 //
1706 pedcam.SetName("MPedestalCam"); // MPedestalFundamental
1707 plist.AddToList(&pedcam);
1708 plist.AddToList(&fBadPixels);
1709
1710 //
1711 // Calibration Results containers
1712 //
1713 if (IsIntensity())
1714 {
1715
1716 MCalibrationChargeCam *cam = (MCalibrationChargeCam*)fIntensCalibCam.GetCam();
1717 cam->InitSize(fCalibrationCam.GetSize());
1718 cam->MergeHiLoConversionFactors(fCalibrationCam);
1719
1720 plist.AddToList(&fIntensQECam);
1721 plist.AddToList(&fIntensCalibCam);
1722 // plist.AddToList(&fIntensCalibrationPINDiode);
1723 plist.AddToList(&fIntensRelTimeCam);
1724 plist.AddToList(&fIntensBadCam);
1725 if (IsUseBlindPixel())
1726 plist.AddToList(&fIntensBlindCam);
1727 }
1728 else
1729 {
1730 plist.AddToList(&fQECam);
1731 plist.AddToList(&fCalibrationCam);
1732 plist.AddToList(&fRelTimeCam);
1733 if (IsUseBlindPixel())
1734 plist.AddToList(&fCalibrationBlindCam);
1735 if (IsUsePINDiode())
1736 plist.AddToList(&fCalibrationPINDiode);
1737 }
1738
1739 //
1740 // Initialize two histogram containers which could be modified in this class
1741 //
1742 MHCalibrationRelTimeCam reltimecam;
1743 MHCalibrationChargeCam chargecam;
1744 MHCalibrationChargeBlindCam blindcam;
1745 plist.AddToList(&chargecam);
1746
1747 if (IsUseBlindPixel())
1748 plist.AddToList(&blindcam);
1749 if (IsRelTimes())
1750 plist.AddToList(&reltimecam);
1751 //
1752 // Data Reading tasks
1753 //
1754 MReadMarsFile read("Events");
1755 MRawFileRead rawread(NULL);
1756
1757 if (IsUseRawData())
1758 {
1759 rawread.AddFiles(iter);
1760 tlist.AddToList(&rawread);
1761 }
1762 else
1763 {
1764 read.DisableAutoScheme();
1765 read.AddFiles(iter);
1766 tlist.AddToList(&read);
1767 }
1768
1769 //
1770 // Other Tasks
1771 //
1772
1773 // Set the default for data version earlier than 5, where no valid
1774 // trigger pattern exists. There should not be pin diode or other
1775 // types of events inside the calibration files which should be skipped,
1776 // anyway. So we set the default such that the MContinue ccalib
1777 // will never be executed.
1778 MTriggerPatternDecode trgpat;
1779 MFTriggerPattern fcalib("CalibFilter");
1780 fcalib.SetDefault(kFALSE);
1781 fcalib.DenyCalibration(MFTriggerPattern::kPrescaled);
1782
1783 MContinue ccalib(&fcalib,"ContTrigPattern");
1784
1785 MCalibrationPatternDecode decode;
1786 MGeomApply apply;
1787 apply.SetGeometry(fGeometry);
1788
1789 MBadPixelsMerge merge(&fBadPixels);
1790 MExtractPINDiode pinext;
1791 MExtractBlindPixel blindext;
1792
1793 if (IsUseBlindPixel())
1794 InitBlindPixel(blindext, blindcam);
1795
1796// MExtractSlidingWindow extract2;
1797// MExtractTimeHighestIntegral timehigh;
1798 MCalibrationChargeCalc calcalc;
1799 MCalibrationRelTimeCalc timecalc;
1800 calcalc.SetExtractor(fExtractor);
1801
1802 if (IsDebug())
1803 {
1804 chargecam.SetDebug();
1805 calcalc.SetDebug();
1806 }
1807
1808 //
1809 // Calibration histogramming
1810 //
1811 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
1812 MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
1813 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
1814 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
1815 fillpin.SetBit(MFillH::kDoNotDisplay);
1816 fillbnd.SetBit(MFillH::kDoNotDisplay);
1817 fillcam.SetBit(MFillH::kDoNotDisplay);
1818 filltme.SetBit(MFillH::kDoNotDisplay);
1819
1820 //
1821 // Set default extractors in case, none has been set...
1822 //
1823 /*
1824 if (!fExtractor)
1825 fExtractor = &extract2;
1826 if (!fTimeExtractor)
1827 fTimeExtractor = &timehigh;
1828 */
1829 MExtractTimeAndChargeSpline spline;
1830 if (!fExtractor)
1831 fExtractor = &spline;
1832// if (!fTimeExtractor)
1833// fTimeExtractor = &timehigh;
1834
1835 const Bool_t istimecharge = fExtractor->InheritsFrom("MExtractTimeAndCharge");
1836
1837 //
1838 // Look if the extractor is a pure charge or also a time extractor
1839 //
1840 if (istimecharge)
1841 {
1842 if (fExtractorCam.GetSize() == pedcam.GetSize())
1843 calcalc.SetPedestals(&fExtractorCam);
1844 else
1845 {
1846 *fLog << err << GetDescriptor() << "ERROR - ";
1847 *fLog << "Used Extractor derives from MExtractTimeAndCharge, " << endl;
1848 *fLog << "but MExtractorCam size " << fExtractorCam.GetSize() << " ";
1849 *fLog << "mismatch pedcam size " << pedcam.GetSize() << "! " << endl;
1850 return kFALSE;
1851 }
1852 }
1853
1854 //
1855 // Setup more tasks and tasklist
1856 //
1857 MTaskEnv taskenv("ExtractSignal");
1858 taskenv.SetDefault(fExtractor);
1859
1860 tlist.AddToList(&trgpat);
1861 if (fColor != MCalibrationCam::kCT1)
1862 tlist.AddToList(&ccalib);
1863 tlist.AddToList(&decode);
1864 tlist.AddToList(&merge);
1865 tlist.AddToList(&apply);
1866
1867 // Produce pedestal subtracted raw-data
1868 MPedestalSubtract pedsub;
1869 pedsub.SetPedestalCam(fExtractor->GetPedestals());
1870 tlist.AddToList(&pedsub);
1871
1872 // Setup to use the hi-gain extraction window in the lo-gain
1873 // range (the start of the lo-gain range is added automatically
1874 // by MPedCalcFromLoGain)
1875 //
1876 // The window size of the extractor is not yet initialized,
1877 // so we have to stick to the extraction range
1878 const Int_t f = fExtractor->GetHiGainFirst();
1879 const Int_t l = fExtractor->GetHiGainLast();
1880 const Int_t w = (l-f+1)&~1;
1881
1882 MPedCalcPedRun pedcalc;
1883 pedcalc.SetExtractWindow(f, w);
1884
1885 if (IsIntensity())
1886 tlist.AddToList(&pedcalc);
1887
1888 MCalibColorSet colorset;
1889 if (fColor != MCalibrationCam::kNONE)
1890 colorset.SetExplicitColor(fColor);
1891 tlist.AddToList(&colorset);
1892
1893 tlist.AddToList(&taskenv);
1894
1895 if (IsUsePINDiode())
1896 tlist.AddToList(&pinext);
1897 if (IsUseBlindPixel())
1898 tlist.AddToList(&blindext);
1899
1900 MTaskEnv taskenv2("ExtractTime");
1901 if (!istimecharge)
1902 {
1903 taskenv2.SetDefault(fTimeExtractor);
1904
1905 if (IsRelTimes())
1906 tlist.AddToList(&taskenv2);
1907 }
1908
1909 //
1910 // Apply a filter against cosmics
1911 // (will have to be needed in the future
1912 // when the calibration hardware-trigger is working)
1913 //
1914 MFCosmics cosmics;
1915 cosmics.SetMaxEmptyPixels(0.05);
1916 cosmics.SetMaxAcceptedFraction(0.5); // max=0.5 cosmics
1917
1918 MContinue cont(&cosmics, "ContCosmics");
1919 tlist.AddToList(&cont);
1920
1921 MCalibColorSteer steer;
1922 if (IsIntensity())
1923 tlist.AddToList(&steer);
1924
1925 if (IsRelTimes())
1926 {
1927 tlist.AddToList(&filltme);
1928 tlist.AddToList(&timecalc);
1929 }
1930
1931 tlist.AddToList(&fillcam);
1932
1933 if (IsUseBlindPixel())
1934 tlist.AddToList(&fillbnd);
1935 if (IsUsePINDiode())
1936 tlist.AddToList(&fillpin);
1937
1938 tlist.AddToList(&calcalc);
1939
1940
1941 MHCamEvent evt2(0, "Extra'd", "Extracted Calibration Signal;;S [cnts/sl]");
1942 MHCamEvent evt9(4, "ArrTm", "Extracted ArrivalTime;;T");
1943
1944 MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtractedSignal");
1945 MFillH fill9(&evt9, "MArrivalTimeCam", "FillArrivalTime");
1946
1947 tlist.AddToList(&fill2);
1948 tlist.AddToList(&fill9);
1949
1950
1951 // Create and setup the eventloop
1952 MEvtLoop evtloop(fName);
1953 evtloop.SetParList(&plist);
1954 evtloop.SetDisplay(fDisplay);
1955 evtloop.SetLogStream(fLog);
1956 if (!SetupEnv(evtloop))
1957 return kFALSE;
1958
1959 if (!taskenv.GetTask() && !taskenv2.GetTask())
1960 {
1961 *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initialized or both '<dummy>'." << endl;
1962 return kFALSE;
1963 }
1964
1965 if (!WriteTasks(taskenv.GetTask(), istimecharge ? 0 : taskenv2.GetTask()))
1966 return kFALSE;
1967
1968 // Execute first analysis
1969 const Bool_t rc = evtloop.Eventloop();
1970
1971 if (!fCalibrationPINDiode.IsValid())
1972 SetUsePINDiode(kFALSE);
1973
1974 const Int_t numexec = IsUseRawData() ? rawread.GetNumExecutions() : read.GetNumExecutions();
1975 if (numexec>0)
1976 {
1977 DisplayResult(plist);
1978 if (!WriteResult(plist))
1979 return kFALSE;
1980 }
1981
1982 if (!rc)
1983 {
1984 *fLog << err << GetDescriptor() << ": Failed." << endl;
1985 return kFALSE;
1986 }
1987
1988 // --------------------------------------------------------------------------------
1989
1990 if (fIsPixelCheck)
1991 {
1992 chargecam[fCheckedPixId].DrawClone("datacheck");
1993 chargecam(fCheckedPixId).DrawClone("datacheck");
1994
1995 if (IsRelTimes())
1996 {
1997 reltimecam[fCheckedPixId].DrawClone("");
1998 reltimecam(fCheckedPixId).DrawClone("");
1999 }
2000 }
2001
2002 *fLog << all << GetDescriptor() << ": Done." << endl;
2003
2004 return kTRUE;
2005}
2006
2007/*
2008Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
2009{
2010 if (IsNoStorage())
2011 return kTRUE;
2012
2013 if (fPathOut.IsNull())
2014 return kTRUE;
2015
2016 const TString oname(GetOutputFile());
2017
2018 *fLog << inf << "Writing to file: " << oname << endl;
2019
2020 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
2021 if (!file.IsOpen())
2022 {
2023 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
2024 return kFALSE;
2025 }
2026
2027 if (evtloop.Write(fName)<=0)
2028 {
2029 *fLog << err << "Unable to write MEvtloop to " << oname << endl;
2030 return kFALSE;
2031 }
2032
2033 return kTRUE;
2034}
2035*/
2036
2037Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
2038{
2039 if (IsNoStorage())
2040 return kTRUE;
2041
2042 TObjArray cont;
2043 if (t1)
2044 cont.Add(t1);
2045 if (t2)
2046 cont.Add(t2);
2047
2048 return WriteContainer(cont, GetOutputFileName(), fOverwrite?"RECREATE":"NEW");
2049}
2050
2051// --------------------------------------------------------------------------
2052//
2053// Write the result into the output file GetOutputFile(), if fOutputPath exists.
2054//
2055// The following containers are written:
2056// - MStatusDisplay
2057// - MCalibrationChargeCam or MCalibrationIntensityChargeCam
2058// - MCalibrationBlindCam or MCalibrationIntensityBlindCam
2059// - MCalibrationQECam or MCalibrationIntensityQECam
2060// - MCalibrationChargePINDiode
2061// - MBadPixelsCam
2062// If the flag kRelTimes is set, then also:
2063// - MCalibrationRelTimeCam or MCalibrationIntensityRelTimeCam
2064//
2065Bool_t MJCalibration::WriteResult(MParList &plist)
2066{
2067 if (IsNoStorage())
2068 return kTRUE;
2069
2070 TObjArray cont;
2071
2072 if (IsIntensity())
2073 {
2074 cont.Add(&fIntensBadCam);
2075 cont.Add(&fIntensCalibCam);
2076 cont.Add(&fIntensQECam);
2077 cont.Add(&fIntensBlindCam);
2078 }
2079 else
2080 {
2081 cont.Add(&fBadPixels);
2082 cont.Add(&fCalibrationCam);
2083 cont.Add(&fQECam);
2084 cont.Add(&fCalibrationBlindCam);
2085 }
2086 cont.Add(&fCalibrationPINDiode);
2087
2088 //if (IsRelTimes())
2089 cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
2090
2091 if (fExtractorCam.GetSize() != 0)
2092 cont.Add(&fExtractorCam);
2093
2094 TObject *pedcam = plist.FindObject("MPedestalCam");
2095 if (!pedcam)
2096 *fLog << warn << " - WARNING - MPedestalCam (fundamental)... not found for writing!" << endl;
2097 else
2098 cont.Add(pedcam);
2099
2100 TObject *geom = plist.FindObject("MGeomCam");
2101 if (!geom)
2102 *fLog << warn << " - WARNING - MGeomCam... not found for writing!" << endl;
2103 else
2104 cont.Add(geom);
2105
2106 if (IsHistsStorage())
2107 {
2108 cont.Add(plist.FindObject("MHCalibrationChargeCam"));
2109 cont.Add(plist.FindObject("MHCalibrationChargeBlindCam"));
2110 cont.Add(plist.FindObject("MHCalibrationChargePINDiode"));
2111 if (IsRelTimes())
2112 cont.Add(plist.FindObject("MHCalibrationRelTimeCam"));
2113 }
2114
2115 return WriteContainer(cont, GetOutputFileName(), "UPDATE");
2116}
2117
2118void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
2119{
2120
2121 TArrayI inner(1);
2122 inner[0] = 0;
2123
2124 TArrayI outer(1);
2125 outer[0] = 1;
2126
2127 TArrayI s1(3);
2128 s1[0] = 6;
2129 s1[1] = 1;
2130 s1[2] = 2;
2131
2132 TArrayI s2(3);
2133 s2[0] = 3;
2134 s2[1] = 4;
2135 s2[2] = 5;
2136
2137 TVirtualPad *pad = gPad;
2138 pad->Divide(2,1);
2139
2140 TH1D *inout[2];
2141
2142 for (int i=0; i<2; i++)
2143 {
2144 pad->cd(i+1);
2145 gPad->SetBorderMode(0);
2146 gPad->SetTicks();
2147
2148 inout[i] = cam->ProjectionS(TArrayI(), TArrayI(1,&i), i==0 ? "Inner" : "Outer");
2149 FixDataCheckHist(inout[i]);
2150 inout[i]->SetTitle(Form("%s %s",cam->GetTitle(),i==0 ? "Inner" : "Outer"));
2151 inout[i]->SetDirectory(NULL);
2152 inout[i]->SetLineColor(kRed+i);
2153 inout[i]->SetBit(kCanDelete);
2154 inout[i]->Draw();
2155 //
2156 // Display the outliers as dead and noisy pixels
2157 //
2158 if (!inout[i]->Fit("gaus","0Q"))
2159 DisplayOutliers(inout[i],whatsmall,whatbig);
2160
2161 gPad->Modified();
2162 gPad->Update();
2163 TPaveStats *st = (TPaveStats*)inout[i]->GetListOfFunctions()->FindObject("stats");
2164 st->SetY1NDC(0.6);
2165 st->SetY2NDC(0.9);
2166 st->SetX1NDC(0.55);
2167 st->SetX2NDC(0.99);
2168 gPad->Modified();
2169 gPad->Update();
2170
2171 TLegend *leg2 = new TLegend(0.55,0.4,0.99,0.6);
2172
2173 //
2174 // Display the two half of the camera separately
2175 //
2176 TH1D *half[2];
2177 half[0] = cam->ProjectionS(s1, TArrayI(1,&i), "Sector 6-1-2");
2178 half[1] = cam->ProjectionS(s2, TArrayI(1,&i), "Sector 3-4-5");
2179
2180 for (int j=0; j<2; j++)
2181 {
2182 half[j]->SetLineColor(kRed+i+2*j+1);
2183 half[j]->SetDirectory(NULL);
2184 half[j]->SetBit(kCanDelete);
2185 half[j]->Draw("same");
2186 leg2->AddEntry(half[j], half[j]->GetName(), "l");
2187 }
2188 leg2->Draw();
2189 }
2190}
Note: See TracBrowser for help on using the repository browser.