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

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