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

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