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

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