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

Last change on this file since 6173 was 6173, checked in by gaug, 20 years ago
*** empty log message ***
File size: 68.0 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 MExtractTimeSpline
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 "MExtractTimeFastSpline.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 : fRuns(0), 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 if (fSequence.IsValid())
1387 return Form("calib%08d.root", fSequence.GetSequence());
1388 if (!fRuns)
1389 return "";
1390
1391 return Form("%s-F1.root", (const char*)fRuns->GetRunsAsFileName());
1392}
1393
1394// --------------------------------------------------------------------------
1395//
1396// MJCalibration allows to setup several option by a resource file:
1397// MJCalibration.Display: full, datacheck, normal
1398// MJCalibration.RelTimeCalibration: yes,no
1399// MJCalibration.DataCheck: yes,no
1400// MJCalibration.Debug: yes,no
1401// MJCalibration.Intensity: yes,no
1402// MJCalibration.UseBlindPixel: yes,no
1403// MJCalibration.UsePINDiode: yes,no
1404// MJCalibration.Geometry: MGeomCamMagic, MGeomCamECO1000
1405//
1406// For more details see the class description and the corresponding Getters
1407//
1408Bool_t MJCalibration::CheckEnvLocal()
1409{
1410
1411 TString dis = GetEnv("Display", "");
1412 if (dis.BeginsWith("Full", TString::kIgnoreCase))
1413 SetFullDisplay();
1414 if (dis.BeginsWith("DataCheck", TString::kIgnoreCase))
1415 SetDataCheckDisplay();
1416 if (dis.BeginsWith("Normal", TString::kIgnoreCase))
1417 SetNormalDisplay();
1418
1419 SetUseRootData();
1420
1421 TString dat = GetEnv("DataType", "");
1422 if (dat.BeginsWith("raw", TString::kIgnoreCase))
1423 {
1424 fDataFlag = 0;
1425 SetUseRawData();
1426 }
1427 if (dat.BeginsWith("root", TString::kIgnoreCase))
1428 {
1429 fDataFlag = 0;
1430 SetUseRootData();
1431 }
1432 if (dat.BeginsWith("mc", TString::kIgnoreCase))
1433 {
1434 fDataFlag = 0;
1435 SetUseMC();
1436 }
1437
1438 SetRelTimeCalibration(GetEnv("RelTimeCalibration", IsRelTimes()));
1439 SetIntensity(GetEnv("IntensityCalibration", IsIntensity()));
1440 SetDebug(GetEnv("Debug", IsDebug()));
1441
1442 SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel()));
1443 SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
1444 SetGeometry(GetEnv("Geometry", fGeometry));
1445
1446 fReferenceFile = GetEnv("ReferenceFile",fReferenceFile.Data());
1447
1448 TEnv refenv(fReferenceFile);
1449
1450 fConvFADC2PheMin = refenv.GetValue("ConvFADC2PheMin",fConvFADC2PheMin);
1451 fConvFADC2PheMax = refenv.GetValue("ConvFADC2PheMax",fConvFADC2PheMax);
1452 fConvFADC2PhotMin = refenv.GetValue("ConvFADC2PhotMin",fConvFADC2PhotMin);
1453 fConvFADC2PhotMax = refenv.GetValue("ConvFADC2PhotMax",fConvFADC2PhotMax);
1454 fQEMin = refenv.GetValue("QEMin",fQEMin);
1455 fQEMax = refenv.GetValue("QEMax",fQEMax);
1456 fArrivalTimeMin = refenv.GetValue("ArrivalTimeMin",fArrivalTimeMin);
1457 fArrivalTimeMax = refenv.GetValue("ArrivalTimeMax",fArrivalTimeMax);
1458 fTimeOffsetMin = refenv.GetValue("TimeOffsetMin",fTimeOffsetMin);
1459 fTimeOffsetMax = refenv.GetValue("TimeOffsetMax",fTimeOffsetMax);
1460 fTimeResolutionMin = refenv.GetValue("TimeResolutionMin",fTimeResolutionMin);
1461 fTimeResolutionMax = refenv.GetValue("TimeResolutionMax",fTimeResolutionMax);
1462
1463 fRefConvFADC2PheInner = refenv.GetValue("RefConvFADC2PheInner",fRefConvFADC2PheInner);
1464 fRefConvFADC2PheOuter = refenv.GetValue("RefConvFADC2PheOuter",fRefConvFADC2PheOuter);
1465 fRefConvFADC2PhotInner = refenv.GetValue("RefConvFADC2PhotInner",fRefConvFADC2PhotInner);
1466 fRefConvFADC2PhotOuter = refenv.GetValue("RefConvFADC2PhotOuter",fRefConvFADC2PhotOuter);
1467 fRefQEInner = refenv.GetValue("RefQEInner",fRefQEInner);
1468 fRefQEOuter = refenv.GetValue("RefQEOuter",fRefQEOuter);
1469 fRefArrivalTimeInner = refenv.GetValue("RefArrivalTimeInner",fRefArrivalTimeInner);
1470 fRefArrivalTimeOuter = refenv.GetValue("RefArrivalTimeOuter",fRefArrivalTimeOuter);
1471 fRefArrivalTimeRmsInner = refenv.GetValue("RefArrivalTimeRmsInner",fRefArrivalTimeRmsInner);
1472 fRefArrivalTimeRmsOuter = refenv.GetValue("RefArrivalTimeRmsOuter",fRefArrivalTimeRmsOuter);
1473 fRefTimeOffsetInner = refenv.GetValue("RefTimeOffsetInner",fRefTimeOffsetInner);
1474 fRefTimeOffsetOuter = refenv.GetValue("RefTimeOffsetOuter",fRefTimeOffsetOuter);
1475 fRefTimeResolutionInner = refenv.GetValue("RefTimeResolutionInner",fRefTimeResolutionInner);
1476 fRefTimeResolutionOuter = refenv.GetValue("RefTimeResolutionOuter",fRefTimeResolutionOuter);
1477
1478 return kTRUE;
1479}
1480
1481// --------------------------------------------------------------------------
1482//
1483// Call the ProcessFile(MPedestalCam)
1484//
1485Bool_t MJCalibration::Process(MPedestalCam &pedcam)
1486{
1487 if (!ReadCalibrationCam())
1488 return ProcessFile(pedcam);
1489
1490 return kTRUE;
1491}
1492
1493void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext,
1494 MHCalibrationChargeBlindCam &blindcam)
1495{
1496
1497 Int_t run = fSequence.IsValid() ? fSequence.GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
1498
1499 //
1500 // Initialize the blind pixel. Unfortunately, there is a hardware difference
1501 // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
1502 // later setup. The first needs to use a filter because of the length of
1503 // spurious NSB photon signals. The latter get better along extracting the amplitude
1504 // from a small window.
1505 //
1506 if (run < gkSecondBlindPixelInstallation)
1507 {
1508 MCalibrationBlindCamOneOldStyle blindresults;
1509 if (IsIntensity())
1510 blindresults.Copy(*fIntensBlindCam.GetCam());
1511 else
1512 blindresults.Copy(fCalibrationBlindCam);
1513
1514 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
1515 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1516 blindext.SetRange(10,19,0,6);
1517 blindext.SetNSBFilterLimit(70);
1518 }
1519 else if (run < gkThirdBlindPixelInstallation)
1520 {
1521
1522 MCalibrationBlindCamTwoNewStyle blindresults;
1523
1524 if (IsIntensity())
1525 blindresults.Copy(*fIntensBlindCam.GetCam());
1526 else
1527 blindresults.Copy(fCalibrationBlindCam);
1528
1529 blindext.SetNumBlindPixels(blindresults.GetSize());
1530 for (Int_t i=0;i<blindresults.GetSize();i++)
1531 blindext.SetBlindPixelIdx(blindresults[i].GetPixId(),i);
1532
1533 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
1534 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1535 blindext.SetRange(5,8,0,2);
1536 blindext.SetNSBFilterLimit(38);
1537
1538 }
1539 else
1540 {
1541
1542 MCalibrationBlindCamThreeNewStyle blindresults;
1543
1544 if (IsIntensity())
1545 blindresults.Copy(*fIntensBlindCam.GetCam());
1546 else
1547 blindresults.Copy(fCalibrationBlindCam);
1548
1549 blindext.SetNumBlindPixels(blindresults.GetSize());
1550
1551 for (Int_t i=0;i<blindresults.GetSize();i++)
1552 blindext.SetBlindPixelIdx(blindresults[i].GetPixId(),i);
1553
1554 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
1555 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1556 blindext.SetDataType(MExtractBlindPixel::kRawEvt2);
1557 blindext.SetRange(5,8,0,2);
1558 blindext.SetNSBFilterLimit(38);
1559
1560 }
1561
1562}
1563
1564// --------------------------------------------------------------------------
1565//
1566// Execute the task list and the eventloop:
1567//
1568// - Check if there are fRuns, otherwise return
1569// - Check the colour of the files in fRuns (FindColor()), otherwise return
1570// - Check for consistency between run numbers and number of files
1571// - Add fRuns to MReadMarsFile
1572// - Put into MParList:
1573// 1) MPedestalCam (pedcam)
1574// 2) MCalibrationQECam (fQECam)
1575// 3) MCalibrationChargeCam (fCalibrationCam)
1576// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag IsRelTimes() is chosen)
1577// 5) MBadPixelsCam (fBadPixels)
1578// 6) MCalibrationChargePINDiode
1579// 7) MCalibrationBlindPix
1580// - Put into the MTaskList:
1581// 1) MReadMarsFile
1582// 2) MBadPixelsMerge
1583// 3) MGeomApply
1584// 4) MExtractor
1585// 5) MExtractPINDiode
1586// 6) MExtractBlindPixel
1587// 7) MExtractTime (only if flag IsRelTimes() is chosen)
1588// 8) MContinue(MFCosmics)
1589// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode")
1590// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam")
1591// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam")
1592// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam", "FillRelTime")
1593// 13) MCalibrationChargeCalc
1594// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag IsRelTimes() is chosen)
1595// 15) MCalibrationRelTimeCalc
1596// - Execute MEvtLoop
1597// - DisplayResult()
1598// - WriteResult()
1599//
1600Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
1601{
1602 if (!fSequence.IsValid())
1603 {
1604 if (!fRuns)
1605 {
1606 *fLog << err << "No Runs choosen... abort." << endl;
1607 return kFALSE;
1608 }
1609
1610 if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
1611 {
1612 *fLog << err << "Number of files found doesn't match number of runs... abort."
1613 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
1614 return kFALSE;
1615 }
1616 }
1617
1618 //if (!CheckEnv())
1619 // return kFALSE;
1620
1621 CheckEnv();
1622
1623 // --------------------------------------------------------------------------------
1624
1625 *fLog << inf;
1626 fLog->Separator(GetDescriptor());
1627
1628 *fLog << "Calculate MCalibrationCam from ";
1629 if (fSequence.IsValid())
1630 *fLog << "Sequence #" << fSequence.GetSequence() << endl;
1631 else
1632 *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
1633 *fLog << endl;
1634
1635 // --------------------------------------------------------------------------------
1636
1637 // Setup Tasklist
1638 MParList plist;
1639 MTaskList tlist;
1640 plist.AddToList(&tlist);
1641 plist.AddToList(this); // take care of fDisplay!
1642
1643 MDirIter iter;
1644 if (fSequence.IsValid())
1645 {
1646 const Int_t n0 = fSequence.SetupCalRuns(iter, fPathData, "C", IsUseRawData());
1647 const Int_t n1 = fSequence.GetNumCalRuns();
1648 if (n0==0)
1649 {
1650 *fLog << err << "ERROR - No input files of sequence found!" << endl;
1651 return kFALSE;
1652 }
1653 if (n0!=n1)
1654 {
1655 *fLog << err << "ERROR - Number of files found ("
1656 << n0 << ") doesn't match number of files in sequence ("
1657 << n1 << ")" << endl;
1658 return kFALSE;
1659 }
1660 }
1661
1662 //
1663 // Input containers
1664 //
1665 pedcam.SetName("MPedestalCam"); // MPedestalFundamental
1666 plist.AddToList(&pedcam);
1667 plist.AddToList(&fBadPixels);
1668
1669 //
1670 // Calibration Results containers
1671 //
1672 if (IsIntensity())
1673 {
1674 plist.AddToList(&fIntensQECam);
1675 plist.AddToList(&fIntensCalibCam);
1676 plist.AddToList(&fIntensBlindCam);
1677 // plist.AddToList(&fIntensCalibrationPINDiode);
1678 plist.AddToList(&fIntensRelTimeCam);
1679 plist.AddToList(&fIntensBadCam);
1680 }
1681 else
1682 {
1683 plist.AddToList(&fQECam);
1684 plist.AddToList(&fCalibrationCam);
1685 plist.AddToList(&fCalibrationBlindCam);
1686 plist.AddToList(&fCalibrationPINDiode);
1687 plist.AddToList(&fRelTimeCam);
1688 }
1689
1690 //
1691 // Initialize two histogram containers which could be modified in this class
1692 //
1693 MHCalibrationRelTimeCam reltimecam;
1694 MHCalibrationChargeCam chargecam;
1695 MHCalibrationChargeBlindCam blindcam;
1696 plist.AddToList(&chargecam);
1697 plist.AddToList(&blindcam);
1698 if (IsRelTimes())
1699 plist.AddToList(&reltimecam);
1700 //
1701 // Data Reading tasks
1702 //
1703 MReadMarsFile read("Events");
1704 MRawFileRead rawread(NULL);
1705
1706 if (IsUseRawData())
1707 {
1708 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1709 tlist.AddToList(&rawread);
1710 }
1711 else
1712 {
1713 read.DisableAutoScheme();
1714 read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
1715 tlist.AddToList(&read);
1716 }
1717
1718 //
1719 // Other Tasks
1720 //
1721 MCalibrationPatternDecode decode;
1722 MGeomApply apply;
1723 apply.SetGeometry(fGeometry);
1724
1725 MBadPixelsMerge merge(&fBadPixels);
1726 MExtractPINDiode pinext;
1727 MExtractBlindPixel blindext;
1728
1729 InitBlindPixel(blindext, blindcam);
1730
1731 MExtractSlidingWindow extract2;
1732 MExtractTimeFastSpline timespline;
1733 MCalibrationChargeCalc calcalc;
1734 MCalibrationRelTimeCalc timecalc;
1735 calcalc.SetOutputFile("");
1736 timecalc.SetOutputFile("");
1737
1738 if (!fSequence.IsValid())
1739 {
1740 calcalc.SetOutputPath(fPathOut);
1741 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1742 timecalc.SetOutputPath(fPathOut);
1743 timecalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1744 }
1745
1746 if (IsDebug())
1747 {
1748 chargecam.SetDebug();
1749 calcalc.SetDebug();
1750 }
1751
1752 //
1753 // Calibration histogramming
1754 //
1755 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
1756 MFillH fillbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
1757 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
1758 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
1759 fillpin.SetBit(MFillH::kDoNotDisplay);
1760 fillbnd.SetBit(MFillH::kDoNotDisplay);
1761 fillcam.SetBit(MFillH::kDoNotDisplay);
1762 filltme.SetBit(MFillH::kDoNotDisplay);
1763
1764 //
1765 // Set default extractors in case, none has been set...
1766 //
1767 if (!fExtractor)
1768 fExtractor = &extract2;
1769 if (!fTimeExtractor)
1770 fTimeExtractor = &timespline;
1771
1772 //
1773 // Look if the extractor is a pure charge or also a time extractor
1774 //
1775 if (fExtractor->InheritsFrom("MExtractTimeAndCharge"))
1776 {
1777 if (fExtractorCam.GetSize() == pedcam.GetSize())
1778 calcalc.SetPedestals(&fExtractorCam);
1779 else
1780 {
1781 *fLog << err << GetDescriptor() << "ERROR - ";
1782 *fLog << "Used Extractor derives from MExtractTimeAndCharge, " << endl;
1783 *fLog << "but MExtractorCam size " << fExtractorCam.GetSize() << " ";
1784 *fLog << "mismatch pedcam size " << pedcam.GetSize() << "! " << endl;
1785 return kFALSE;
1786 }
1787 }
1788
1789 //
1790 // Setup more tasks and tasklist
1791 //
1792 MTaskEnv taskenv("ExtractSignal");
1793 taskenv.SetDefault(fExtractor);
1794
1795 tlist.AddToList(&decode);
1796 tlist.AddToList(&merge);
1797 tlist.AddToList(&apply);
1798
1799 MPedCalcPedRun pedcalc;
1800 pedcalc.SetExtractWindow(fExtractor->GetHiGainFirst(),TMath::Nint(fExtractor->GetNumHiGainSamples()));
1801
1802 if (IsIntensity())
1803 tlist.AddToList(&pedcalc);
1804
1805 MCalibColorSet colorset;
1806 tlist.AddToList(&colorset);
1807
1808 tlist.AddToList(&taskenv);
1809 tlist.AddToList(&pinext);
1810 tlist.AddToList(&blindext);
1811
1812 MTaskEnv taskenv2("ExtractTime");
1813 if (!fExtractor->InheritsFrom("MExtractTimeAndCharge"))
1814 {
1815 taskenv2.SetDefault(fTimeExtractor);
1816
1817 if (IsRelTimes())
1818 tlist.AddToList(&taskenv2);
1819 }
1820
1821 //
1822 // Apply a filter against cosmics
1823 // (will have to be needed in the future
1824 // when the calibration hardware-trigger is working)
1825 //
1826 MFCosmics cosmics;
1827 MContinue cont(&cosmics);
1828
1829 if (fColor == MCalibrationCam::kCT1)
1830 tlist.AddToList(&cont);
1831
1832 MCalibColorSteer steer;
1833 if (IsIntensity())
1834 tlist.AddToList(&steer);
1835
1836 tlist.AddToList(&fillcam);
1837
1838 if (IsRelTimes())
1839 {
1840 tlist.AddToList(&filltme);
1841 tlist.AddToList(&timecalc);
1842 }
1843
1844 if (IsUseBlindPixel())
1845 tlist.AddToList(&fillbnd);
1846 if (IsUsePINDiode())
1847 tlist.AddToList(&fillpin);
1848
1849 tlist.AddToList(&calcalc);
1850
1851 // Create and setup the eventloop
1852 MEvtLoop evtloop(fName);
1853 evtloop.SetParList(&plist);
1854 evtloop.SetDisplay(fDisplay);
1855 evtloop.SetLogStream(fLog);
1856 if (!SetupEnv(evtloop))
1857 return kFALSE;
1858
1859 if (!taskenv.GetTask() && !taskenv2.GetTask())
1860 {
1861 *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initialized or both '<dummy>'." << endl;
1862 return kFALSE;
1863 }
1864
1865 if (!WriteTasks(taskenv.GetTask(), IsRelTimes() ? taskenv2.GetTask() : 0))
1866 return kFALSE;
1867
1868 // Execute first analysis
1869 if (!evtloop.Eventloop())
1870 {
1871 // DisplayResult(plist);
1872 // WriteResult(plist);
1873 *fLog << err << GetDescriptor() << ": Failed." << endl;
1874 return kFALSE;
1875 }
1876
1877 tlist.PrintStatistics();
1878
1879 /*
1880 MHCalibrationRelTimeCam *hcam = (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
1881 MHCalibrationPix &pix1 = (*hcam)(100);
1882 pix1.DrawClone("");
1883 gPad->SaveAs("test_time_100.ps");
1884
1885 MHCalibrationChargeCam *hccam = (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
1886 MHCalibrationPix &pix11 = (*hccam)(100);
1887 pix11.DrawClone("");
1888 gPad->SaveAs("test_charge_100.ps");
1889
1890 MHCalibrationPix &pix2 = (MHCalibrationPix&)(*hcam)(400);
1891 pix2.DrawClone("");
1892 gPad->SaveAs("test_time_400.ps");
1893
1894 MHCalibrationPix &pix22 = (*hccam)(400);
1895 pix22.DrawClone("");
1896 gPad->SaveAs("test_charge_400.ps");
1897
1898 *fLog << err << "Blackout 100: " << fRelTimeCam[100].GetNumBlackout() << endl;
1899 *fLog << err << "Picup 100: " << fRelTimeCam[100].GetNumPickup () << endl;
1900 *fLog << err << "Blackout 400: " << fRelTimeCam[400].GetNumBlackout() << endl;
1901 *fLog << err << "Picup 400: " << fRelTimeCam[400].GetNumPickup () << endl;
1902 */
1903
1904 if (!fCalibrationPINDiode.IsValid())
1905 SetUsePINDiode(kFALSE);
1906
1907 DisplayResult(plist);
1908
1909 if (!WriteResult(plist))
1910 return kFALSE;
1911
1912 *fLog << all << GetDescriptor() << ": Done." << endl;
1913
1914 return kTRUE;
1915}
1916
1917// --------------------------------------------------------------------------
1918//
1919// Read the following containers from GetOutputFile()
1920// - MCalibrationChargeCam
1921// - MCalibrationQECam
1922// - MBadPixelsCam
1923//
1924Bool_t MJCalibration::ReadCalibrationCam()
1925{
1926
1927 if (IsNoStorage())
1928 return kFALSE;
1929
1930 const TString fname = GetOutputFile();
1931
1932 if (gSystem->AccessPathName(fname, kFileExists))
1933 {
1934 *fLog << err << "Input file " << fname << " doesn't exist." << endl;
1935 return kFALSE;
1936 }
1937
1938 *fLog << inf << "Reading from file: " << fname << endl;
1939
1940 TFile file(fname, "READ");
1941 if (fCalibrationCam.Read()<=0)
1942 {
1943 *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
1944 return kFALSE;
1945 }
1946
1947 if (fQECam.Read()<=0)
1948 {
1949 *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
1950 return kFALSE;
1951 }
1952
1953
1954 if (file.FindKey("MCalibrationRelTimeCam"))
1955 if (fRelTimeCam.Read()<=0)
1956 {
1957 *fLog << err << "Unable to read MCalibrationRelTimeCam from " << fname << endl;
1958 return kFALSE;
1959 }
1960
1961 if (file.FindKey("MBadPixelsCam"))
1962 {
1963 MBadPixelsCam bad;
1964 if (bad.Read()<=0)
1965 {
1966 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
1967 return kFALSE;
1968 }
1969 fBadPixels.Merge(bad);
1970 }
1971
1972 if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
1973 fDisplay->Read();
1974
1975 return kTRUE;
1976}
1977
1978
1979// --------------------------------------------------------------------------
1980//
1981// Set the useage of the Blind Pixel device
1982//
1983void MJCalibration::SetUseBlindPixel(const Bool_t b)
1984{
1985 b ? SETBIT(fDevices,kUseBlindPixel) : CLRBIT(fDevices,kUseBlindPixel);
1986}
1987
1988// --------------------------------------------------------------------------
1989//
1990// Set the useage of the PIN Diode device
1991//
1992void MJCalibration::SetUsePINDiode(const Bool_t b)
1993{
1994 b ? SETBIT(fDevices,kUsePINDiode) : CLRBIT(fDevices,kUsePINDiode);
1995}
1996
1997/*
1998Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
1999{
2000 if (IsNoStorage())
2001 return kTRUE;
2002
2003 if (fPathOut.IsNull())
2004 return kTRUE;
2005
2006 const TString oname(GetOutputFile());
2007
2008 *fLog << inf << "Writing to file: " << oname << endl;
2009
2010 TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
2011 if (!file.IsOpen())
2012 {
2013 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
2014 return kFALSE;
2015 }
2016
2017 if (evtloop.Write(fName)<=0)
2018 {
2019 *fLog << err << "Unable to write MEvtloop to " << oname << endl;
2020 return kFALSE;
2021 }
2022
2023 return kTRUE;
2024}
2025*/
2026
2027Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
2028{
2029 if (IsNoStorage())
2030 return kTRUE;
2031
2032 TObjArray cont;
2033 if (t1)
2034 cont.Add(t1);
2035 if (t2)
2036 cont.Add(t2);
2037
2038 return WriteContainer(cont, GetOutputFileName(), fOverwrite?"RECREATE":"NEW");
2039}
2040
2041// --------------------------------------------------------------------------
2042//
2043// Write the result into the output file GetOutputFile(), if fOutputPath exists.
2044//
2045// The following containers are written:
2046// - MStatusDisplay
2047// - MCalibrationChargeCam or MCalibrationIntensityChargeCam
2048// - MCalibrationBlindCam or MCalibrationIntensityBlindCam
2049// - MCalibrationQECam or MCalibrationIntensityQECam
2050// - MCalibrationChargePINDiode
2051// - MBadPixelsCam
2052// If the flag kRelTimes is set, then also:
2053// - MCalibrationRelTimeCam or MCalibrationIntensityRelTimeCam
2054//
2055Bool_t MJCalibration::WriteResult(MParList &plist)
2056{
2057 TObjArray cont;
2058
2059 if (!IsNoStorage())
2060 {
2061 if (IsIntensity())
2062 {
2063 cont.Add(&fIntensBadCam);
2064 cont.Add(&fIntensCalibCam);
2065 cont.Add(&fIntensQECam);
2066 cont.Add(&fIntensBlindCam);
2067 }
2068 else
2069 {
2070 cont.Add(&fBadPixels);
2071 cont.Add(&fCalibrationCam);
2072 cont.Add(&fQECam);
2073 cont.Add(&fCalibrationBlindCam);
2074 }
2075 cont.Add(&fCalibrationPINDiode);
2076
2077 //if (IsRelTimes())
2078 cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
2079
2080 TObject *geom = plist.FindObject("MGeomCam");
2081 if (!geom)
2082 *fLog << warn << " - WARNING - MGeomCam... not found for writing!" << endl;
2083 else
2084 cont.Add(geom);
2085 }
2086
2087 if (IsHistsStorage())
2088 {
2089 cont.Add(plist.FindObject("MHCalibrationChargeCam"));
2090 cont.Add(plist.FindObject("MHCalibrationChargeBlindCam"));
2091 cont.Add(plist.FindObject("MHCalibrationChargePINDiode"));
2092 if (IsRelTimes())
2093 cont.Add(plist.FindObject("MHCalibrationRelTimeCam"));
2094 }
2095
2096 return WriteContainer(cont, GetOutputFileName(), "UPDATE");
2097}
2098
2099void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
2100{
2101
2102 TArrayI inner(1);
2103 inner[0] = 0;
2104
2105 TArrayI outer(1);
2106 outer[0] = 1;
2107
2108 TArrayI s1(3);
2109 s1[0] = 6;
2110 s1[1] = 1;
2111 s1[2] = 2;
2112
2113 TArrayI s2(3);
2114 s2[0] = 3;
2115 s2[1] = 4;
2116 s2[2] = 5;
2117
2118 TVirtualPad *pad = gPad;
2119 pad->Divide(2,1);
2120
2121 TH1D *inout[2];
2122
2123 for (int i=0; i<2; i++)
2124 {
2125 pad->cd(i+1);
2126 gPad->SetBorderMode(0);
2127 gPad->SetTicks();
2128
2129 inout[i] = cam->ProjectionS(TArrayI(), TArrayI(1,&i), i==0 ? "Inner" : "Outer");
2130 FixDataCheckHist(inout[i]);
2131 inout[i]->SetTitle(Form("%s %s",cam->GetTitle(),i==0 ? "Inner" : "Outer"));
2132 inout[i]->SetDirectory(NULL);
2133 inout[i]->SetLineColor(kRed+i);
2134 inout[i]->SetBit(kCanDelete);
2135 inout[i]->Draw();
2136 //
2137 // Display the outliers as dead and noisy pixels
2138 //
2139 if (!inout[i]->Fit("gaus","0Q"))
2140 DisplayOutliers(inout[i],whatsmall,whatbig);
2141
2142 gPad->Modified();
2143 gPad->Update();
2144 TPaveStats *st = (TPaveStats*)inout[i]->GetListOfFunctions()->FindObject("stats");
2145 st->SetY1NDC(0.6);
2146 st->SetY2NDC(0.9);
2147 st->SetX1NDC(0.55);
2148 st->SetX2NDC(0.99);
2149 gPad->Modified();
2150 gPad->Update();
2151
2152 TLegend *leg2 = new TLegend(0.55,0.4,0.99,0.6);
2153
2154 //
2155 // Display the two half of the camera separately
2156 //
2157 TH1D *half[2];
2158 half[0] = cam->ProjectionS(s1, TArrayI(1,&i), "Sector 6-1-2");
2159 half[1] = cam->ProjectionS(s2, TArrayI(1,&i), "Sector 3-4-5");
2160
2161 for (int j=0; j<2; j++)
2162 {
2163 half[j]->SetLineColor(kRed+i+2*j+1);
2164 half[j]->SetDirectory(NULL);
2165 half[j]->SetBit(kCanDelete);
2166 half[j]->Draw("same");
2167 leg2->AddEntry(half[j], half[j]->GetName(), "l");
2168 }
2169 leg2->Draw();
2170 }
2171}
Note: See TracBrowser for help on using the repository browser.