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

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