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

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