source: tags/Mars-V0.10.3/mjobs/MJCalibration.cc

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