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

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