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

Last change on this file since 4609 was 4609, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 42.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! 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// MCalibrationChargeBlindPix, 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 SetTimeExtractor(MExtractor *)
81//
82// See also: MHCalibrationRelTimePix, MHCalibrationRelTimeCam, MHGausEvents
83// MCalibrationRelTimePix, MCalibrationRelTimeCam
84// MBadPixelsPix, MBadPixelsCam
85//
86/////////////////////////////////////////////////////////////////////////////
87#include "MJCalibration.h"
88
89#include <TEnv.h>
90#include <TFile.h>
91#include <TStyle.h>
92#include <TCanvas.h>
93#include <TSystem.h>
94
95#include "MLog.h"
96#include "MLogManip.h"
97
98#include "MRunIter.h"
99#include "MSequence.h"
100#include "MParList.h"
101#include "MTaskList.h"
102#include "MEvtLoop.h"
103
104#include "MHCamera.h"
105#include "MGeomCam.h"
106
107#include "MPedestalCam.h"
108#include "MCalibrationCam.h"
109#include "MCalibrationQECam.h"
110#include "MCalibrationChargeCam.h"
111#include "MCalibrationChargePINDiode.h"
112#include "MCalibrationChargeBlindPix.h"
113#include "MCalibrationChargeBlindCam.h"
114#include "MCalibrationChargeBlindPix.h"
115#include "MCalibrationChargeCalc.h"
116
117#include "MHGausEvents.h"
118#include "MHCalibrationCam.h"
119#include "MHCalibrationChargeCam.h"
120#include "MHCalibrationChargeBlindCam.h"
121#include "MHCalibrationChargePINDiode.h"
122#include "MHCalibrationRelTimeCam.h"
123#include "MCalibrationRelTimeCam.h"
124#include "MCalibrationRelTimeCalc.h"
125
126#include "MReadMarsFile.h"
127#include "MRawFileRead.h"
128#include "MGeomApply.h"
129#include "MTaskEnv.h"
130#include "MBadPixelsMerge.h"
131#include "MBadPixelsCam.h"
132#include "MExtractTime.h"
133#include "MExtractor.h"
134#include "MExtractPINDiode.h"
135#include "MExtractBlindPixel.h"
136#include "MExtractSlidingWindow.h"
137#include "MExtractTimeFastSpline.h"
138#include "MFCosmics.h"
139#include "MContinue.h"
140#include "MFillH.h"
141
142#include "MArrivalTimeCam.h"
143
144#include "MStatusDisplay.h"
145
146ClassImp(MJCalibration);
147
148using namespace std;
149
150const Int_t MJCalibration::gkIFAEBoxInaugurationRun = 20113;
151const Int_t MJCalibration::gkSecondBlindPixelInstallation = 31693;
152const Int_t MJCalibration::gkThirdBlindPixelInstallation = 99999;
153// --------------------------------------------------------------------------
154//
155// Default constructor.
156//
157// - Sets fRuns to 0, fExtractor to NULL, fTimeExtractor to NULL, fColor to kNONE,
158// fDisplay to kNormalDisplay, fRelTime to kFALSE, fDataCheck to kFALSE,
159// - SetUseBlindPixel()
160// - SetUsePINDiode()
161//
162MJCalibration::MJCalibration(const char *name, const char *title)
163 : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fTimeExtractor(NULL),
164 fColor(MCalibrationCam::kNONE), fDisplayType(kNormalDisplay),
165 fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE)
166{
167
168 fName = name ? name : "MJCalibration";
169 fTitle = title ? title : "Tool to create the calibration constants for one calibration run";
170
171 SetUseBlindPixel();
172 SetUsePINDiode();
173
174}
175
176MJCalibration::~MJCalibration()
177{
178 if (fEnv)
179 delete fEnv;
180}
181
182// --------------------------------------------------------------------------
183//
184// Display the results in MStatusDisplay:
185//
186// - Add "Calibration" to the MStatusDisplay title
187// - Retrieve the MGeomCam from MParList
188// - Initialize the following MHCamera's:
189// 1) MCalibrationPix::GetMean()
190// 2) MCalibrationPix::Sigma()
191// 3) MCalibrationChargePix::GetRSigma()
192// 4) MCalibrationChargePix::GetRSigmaPerCharge()
193// 5) MCalibrationChargePix::GetPheFFactorMethod()
194// 6) MCalibrationChargePix::GetMeanConvFADC2Phe()
195// 7) MCalibrationChargePix::GetMeanFFactorFADC2Phot()
196// 8) MCalibrationQEPix::GetQECascadesFFactor()
197// 9) MCalibrationQEPix::GetQECascadesBlindPixel()
198// 10) MCalibrationQEPix::GetQECascadesPINDiode()
199// 11) MCalibrationQEPix::GetQECascadesCombined()
200// 12) MCalibrationQEPix::IsAverageQEFFactorAvailable()
201// 13) MCalibrationQEPix::IsAverageQEBlindPixelAvailable()
202// 14) MCalibrationQEPix::IsAverageQEPINDiodeAvailable()
203// 15) MCalibrationQEPix::IsAverageQECombinedAvailable()
204// 16) MCalibrationChargePix::IsHiGainSaturation()
205// 17) MCalibrationPix::GetHiLoMeansDivided()
206// 18) MCalibrationPix::GetHiLoSigmasDivided()
207// 19) MCalibrationChargePix::GetHiGainPickup()
208// 20) MCalibrationChargePix::GetLoGainPickup()
209// 21) MCalibrationChargePix::GetHiGainBlackout()
210// 22) MCalibrationChargePix::GetLoGainBlackout()
211// 23) MCalibrationPix::IsExcluded()
212// 24) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
213// 25) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
214// 26) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
215// 27) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
216// 28) MCalibrationChargePix::GetAbsTimeMean()
217// 29) MCalibrationChargePix::GetAbsTimeRms()
218//
219// If the flag SetFullDisplay() is set, all MHCameras will be displayed.
220// if the flag SetDataCheckDisplay() is set, only the most important ones are displayed
221// and otherwise, (default: SetNormalDisplay()), a good selection of plots is given
222//
223void MJCalibration::DisplayResult(MParList &plist)
224{
225
226 if (!fDisplay)
227 return;
228
229 //
230 // Update display
231 //
232 TString title = fDisplay->GetTitle();
233 title += "-- Calibration ";
234 title += fSequence ? Form("calib%06d", fSequence->GetSequence()) : fRuns->GetRunsAsString();
235 title += " --";
236 fDisplay->SetTitle(title);
237
238 //
239 // Get container from list
240 //
241 MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
242
243 // Create histograms to display
244 MHCamera disp1 (geomcam, "Charge", "Fitted Mean Charges");
245 MHCamera disp2 (geomcam, "SigmaCharge", "Sigma of Fitted Charges");
246 MHCamera disp3 (geomcam, "RSigma", "Reduced Sigmas");
247 MHCamera disp4 (geomcam, "RSigmaPerCharge", "Reduced Sigma per Charge");
248 MHCamera disp5 (geomcam, "NumPhes", "Nr. of Phe's (F-Factor Method)");
249 MHCamera disp6 (geomcam, "ConvFADC2Phes", "Conversion Factor (F-Factor Method)");
250 MHCamera disp7 (geomcam, "TotalFFactor", "Total F-Factor (F-Factor Method)");
251 MHCamera disp8 (geomcam, "CascadesQEFFactor", "Cascades QE (F-Factor Method)");
252 MHCamera disp9 (geomcam, "CascadesQEBlindPix","Cascades QE (Blind Pixel Method)");
253 MHCamera disp10(geomcam, "CascadesQEPINDiode","Cascades QE (PIN Diode Method)");
254 MHCamera disp11(geomcam, "CascadesQECombined","Cascades QE (Combined Method)");
255 MHCamera disp12(geomcam, "FFactorValid", "Pixels with valid F-Factor calibration");
256 MHCamera disp13(geomcam, "BlindPixelValid", "Pixels with valid BlindPixel calibration");
257 MHCamera disp14(geomcam, "PINdiodeValid", "Pixels with valid PINDiode calibration");
258 MHCamera disp15(geomcam, "CombinedValid", "Pixels with valid Combined calibration");
259 MHCamera disp16(geomcam, "Saturation", "Pixels with saturated Hi Gain");
260 MHCamera disp17(geomcam, "ConversionMeans", "Conversion HiGain.vs.LoGain Means");
261 MHCamera disp18(geomcam, "ConversionSigmas", "Conversion HiGain.vs.LoGain Sigmas");
262 MHCamera disp19(geomcam, "HiGainPickup", "Number Pickup events Hi Gain");
263 MHCamera disp20(geomcam, "LoGainPickup", "Number Pickup events Lo Gain");
264 MHCamera disp21(geomcam, "HiGainBlackout", "Number Blackout events Hi Gain");
265 MHCamera disp22(geomcam, "LoGainBlackout", "Number Blackout events Lo Gain");
266 MHCamera disp23(geomcam, "Excluded", "Pixels previously excluded");
267 MHCamera disp24(geomcam, "UnSuitable", "Pixels not suited for further analysis");
268 MHCamera disp25(geomcam, "UnReliable", "Pixels not reliable for further analysis");
269 MHCamera disp26(geomcam, "HiGainOscillating", "Oscillating Pixels High Gain");
270 MHCamera disp27(geomcam, "LoGainOscillating", "Oscillating Pixels Low Gain");
271 MHCamera disp28(geomcam, "AbsTimeMean", "Abs. Arrival Times");
272 MHCamera disp29(geomcam, "AbsTimeRms", "RMS of Arrival Times");
273 MHCamera disp30(geomcam, "MeanTime", "Mean Rel. Arrival Times");
274 MHCamera disp31(geomcam, "SigmaTime", "Sigma Rel. Arrival Times");
275 MHCamera disp32(geomcam, "TimeProb", "Probability of Time Fit");
276 MHCamera disp33(geomcam, "TimeNotFitValid", "Pixels with not valid fit results");
277 MHCamera disp34(geomcam, "TimeOscillating", "Oscillating Pixels");
278
279 // Fitted charge means and sigmas
280 disp1.SetCamContent(fCalibrationCam, 0);
281 disp1.SetCamError( fCalibrationCam, 1);
282 disp2.SetCamContent(fCalibrationCam, 2);
283 disp2.SetCamError( fCalibrationCam, 3);
284
285 // Reduced Sigmas and reduced sigmas per charge
286 disp3.SetCamContent(fCalibrationCam, 5);
287 disp3.SetCamError( fCalibrationCam, 6);
288 disp4.SetCamContent(fCalibrationCam, 7);
289 disp4.SetCamError( fCalibrationCam, 8);
290
291 // F-Factor Method
292 disp5.SetCamContent(fCalibrationCam, 9);
293 disp5.SetCamError( fCalibrationCam, 10);
294 disp6.SetCamContent(fCalibrationCam, 11);
295 disp6.SetCamError( fCalibrationCam, 12);
296 disp7.SetCamContent(fCalibrationCam, 13);
297 disp7.SetCamError( fCalibrationCam, 14);
298
299 // Quantum Efficiencies
300 disp8.SetCamContent (fQECam, 0 );
301 disp8.SetCamError (fQECam, 1 );
302 disp9.SetCamContent (fQECam, 2 );
303 disp9.SetCamError (fQECam, 3 );
304 disp10.SetCamContent(fQECam, 4 );
305 disp10.SetCamError (fQECam, 5 );
306 disp11.SetCamContent(fQECam, 6 );
307 disp11.SetCamError (fQECam, 7 );
308
309 // Valid flags
310 disp12.SetCamContent(fQECam, 8 );
311 disp13.SetCamContent(fQECam, 9 );
312 disp14.SetCamContent(fQECam, 10);
313 disp15.SetCamContent(fQECam, 11);
314
315 // Conversion Hi-Lo
316 disp16.SetCamContent(fCalibrationCam, 25);
317 disp17.SetCamContent(fCalibrationCam, 16);
318 disp17.SetCamError (fCalibrationCam, 17);
319 disp18.SetCamContent(fCalibrationCam, 18);
320 disp18.SetCamError (fCalibrationCam, 19);
321
322 // Pickup and Blackout
323 disp19.SetCamContent(fCalibrationCam, 21);
324 disp20.SetCamContent(fCalibrationCam, 22);
325 disp21.SetCamContent(fCalibrationCam, 23);
326 disp22.SetCamContent(fCalibrationCam, 24);
327
328 // Pixels with defects
329 disp23.SetCamContent(fCalibrationCam, 20);
330 disp24.SetCamContent(fBadPixels, 1);
331 disp25.SetCamContent(fBadPixels, 3);
332
333 // Oscillations
334 disp26.SetCamContent(fBadPixels, 10);
335 disp27.SetCamContent(fBadPixels, 11);
336
337 // Arrival Times
338 disp28.SetCamContent(fCalibrationCam, 26);
339 disp28.SetCamError( fCalibrationCam, 27);
340 disp29.SetCamContent(fCalibrationCam, 27);
341
342 disp1.SetYTitle("Q [FADC counts]");
343 disp2.SetYTitle("\\sigma_{Q} [FADC counts]");
344
345 disp3.SetYTitle("\\sqrt{\\sigma^{2}_{Q} - RMS^{2}_{Ped}} [FADC Counts]");
346 disp4.SetYTitle("Red.Sigma/<Q> [1]");
347
348 disp5.SetYTitle("Nr. Phe's [1]");
349 disp6.SetYTitle("Conv.Factor [PhE/FADC counts]");
350 disp7.SetYTitle("Total F-Factor [1]");
351
352 disp8.SetYTitle("QE [1]");
353 disp9.SetYTitle("QE [1]");
354 disp10.SetYTitle("QE [1]");
355 disp11.SetYTitle("QE [1]");
356
357 disp12.SetYTitle("[1]");
358 disp13.SetYTitle("[1]");
359 disp14.SetYTitle("[1]");
360 disp15.SetYTitle("[1]");
361 disp16.SetYTitle("[1]");
362
363 disp17.SetYTitle("<Q>(High)/<Q>(Low) [1]");
364 disp18.SetYTitle("\\sigma_{Q}(High)/\\sigma_{Q}(Low) [1]");
365
366 disp19.SetYTitle("[1]");
367 disp20.SetYTitle("[1]");
368 disp21.SetYTitle("[1]");
369 disp22.SetYTitle("[1]");
370 disp23.SetYTitle("[1]");
371 disp24.SetYTitle("[1]");
372 disp25.SetYTitle("[1]");
373 disp26.SetYTitle("[1]");
374 disp27.SetYTitle("[1]");
375
376 disp28.SetYTitle("Mean Abs. Time [FADC slice]");
377 disp29.SetYTitle("RMS Abs. Time [FADC slices]");
378
379 if (fRelTimes)
380 {
381
382 disp30.SetCamContent(fRelTimeCam,0);
383 disp30.SetCamError( fRelTimeCam,1);
384 disp31.SetCamContent(fRelTimeCam,2);
385 disp31.SetCamError( fRelTimeCam,3);
386 disp32.SetCamContent(fRelTimeCam,4);
387 disp33.SetCamContent(fBadPixels,20);
388 disp34.SetCamContent(fBadPixels,21);
389
390 disp30.SetYTitle("Time Offset [FADC units]");
391 disp31.SetYTitle("Timing resolution [FADC units]");
392 disp32.SetYTitle("P_{Time} [1]");
393 disp33.SetYTitle("[1]");
394 disp34.SetYTitle("[1]");
395 }
396
397 if (fDisplayType == kDataCheckDisplay)
398 {
399
400 TCanvas &c1 = fDisplay->AddTab("Fit.Charge");
401 c1.Divide(3, 3);
402
403 disp1.CamDraw( c1, 1, 3, 5);
404 disp4.CamDraw( c1, 2, 3, 5);
405 disp28.CamDraw(c1, 3, 3, 5);
406
407 // F-Factor
408 TCanvas &c2 = fDisplay->AddTab("Phe's");
409 c2.Divide(3,4);
410
411 disp6.CamDraw(c2, 1, 3, 5, 1);
412 disp7.CamDraw(c2, 2, 3, 5, 1);
413 disp8.CamDraw(c2, 3, 3, 5, 1);
414
415 // QE's
416 TCanvas &c3 = fDisplay->AddTab("QE's");
417 c3.Divide(3,4);
418
419 disp8.CamDraw(c3, 1, 3, 5, 1);
420 disp9.CamDraw(c3, 2, 3, 5, 1);
421 disp10.CamDraw(c3, 3, 3, 5, 1);
422
423 // Defects
424 TCanvas &c4 = fDisplay->AddTab("Defect");
425 c4.Divide(2,2);
426
427 disp24.CamDraw(c4, 1, 2, 0);
428 disp25.CamDraw(c4, 2, 2, 0);
429
430 if (fRelTimes)
431 {
432 // Rel. Times
433 TCanvas &c5 = fDisplay->AddTab("Rel. Times");
434 c5.Divide(2,4);
435
436 disp30.CamDraw(c5, 1, 2, 2);
437 disp31.CamDraw(c5, 2, 2, 2);
438 }
439
440 return;
441 }
442
443 if (fDisplayType == kNormalDisplay)
444 {
445
446 // Charges
447 TCanvas &c11 = fDisplay->AddTab("Fit.Charge");
448 c11.Divide(2, 4);
449
450 disp1.CamDraw(c11, 1, 2, 5, 1);
451 disp2.CamDraw(c11, 2, 2, 5, 1);
452
453 // Reduced Sigmas
454 TCanvas &c12 = fDisplay->AddTab("Red.Sigma");
455 c12.Divide(2,4);
456
457 disp3.CamDraw(c12, 1, 2, 5, 1);
458 disp4.CamDraw(c12, 2, 2, 5, 1);
459
460 // F-Factor
461 TCanvas &c13 = fDisplay->AddTab("Phe's");
462 c13.Divide(3,4);
463
464 disp5.CamDraw(c13, 1, 3, 5, 1);
465 disp6.CamDraw(c13, 2, 3, 5, 1);
466 disp7.CamDraw(c13, 3, 3, 5, 1);
467
468 // QE's
469 TCanvas &c14 = fDisplay->AddTab("QE's");
470 c14.Divide(4,4);
471
472 disp8.CamDraw(c14, 1, 4, 5, 1);
473 disp9.CamDraw(c14, 2, 4, 5, 1);
474 disp10.CamDraw(c14, 3, 4, 5, 1);
475 disp11.CamDraw(c14, 4, 4, 5, 1);
476
477 // Defects
478 TCanvas &c15 = fDisplay->AddTab("Defect");
479 // c15.Divide(5,2);
480 c15.Divide(4,2);
481
482 /*
483 disp23.CamDraw(c15, 1, 5, 0);
484 disp24.CamDraw(c15, 2, 5, 0);
485 disp25.CamDraw(c15, 3, 5, 0);
486 disp26.CamDraw(c15, 4, 5, 0);
487 disp27.CamDraw(c15, 5, 5, 0);
488 */
489 disp24.CamDraw(c15, 1, 4, 0);
490 disp25.CamDraw(c15, 2, 4, 0);
491 disp26.CamDraw(c15, 3, 4, 0);
492 disp27.CamDraw(c15, 4, 4, 0);
493
494 // Abs. Times
495 TCanvas &c16 = fDisplay->AddTab("Abs. Times");
496 c16.Divide(2,3);
497
498 disp28.CamDraw(c16, 1, 2, 5);
499 disp29.CamDraw(c16, 2, 2, 5);
500
501 if (fRelTimes)
502 {
503 // Rel. Times
504 TCanvas &c17 = fDisplay->AddTab("Rel. Times");
505 c17.Divide(2,4);
506
507 disp30.CamDraw(c17, 1, 2, 5, 1);
508 disp31.CamDraw(c17, 2, 2, 5, 1);
509 }
510
511 return;
512 }
513
514 if (fDisplayType == kFullDisplay)
515 {
516
517 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationChargeCam");
518
519 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
520 {
521 cam->GetAverageHiGainSector(sector).DrawClone("all");
522 cam->GetAverageLoGainSector(sector).DrawClone("all");
523 }
524
525 // Charges
526 TCanvas &c21 = fDisplay->AddTab("Fit.Charge");
527 c21.Divide(2, 4);
528
529 disp1.CamDraw(c21, 1, 2, 2, 1);
530 disp2.CamDraw(c21, 2, 2, 2, 1);
531
532 // Reduced Sigmas
533 TCanvas &c23 = fDisplay->AddTab("Red.Sigma");
534 c23.Divide(2,4);
535
536 disp3.CamDraw(c23, 1, 2, 2, 1);
537 disp4.CamDraw(c23, 2, 2, 2, 1);
538
539 // F-Factor
540 TCanvas &c24 = fDisplay->AddTab("Phe's");
541 c24.Divide(3,5);
542
543 disp5.CamDraw(c24, 1, 3, 2, 1, 1);
544 disp6.CamDraw(c24, 2, 3, 2, 1, 1);
545 disp7.CamDraw(c24, 3, 3, 2, 1, 1);
546
547 // QE's
548 TCanvas &c25 = fDisplay->AddTab("QE's");
549 c25.Divide(4,5);
550
551 disp8.CamDraw(c25, 1, 4, 2, 1, 1);
552 disp9.CamDraw(c25, 2, 4, 2, 1, 1);
553 disp10.CamDraw(c25, 3, 4, 2, 1, 1);
554 disp11.CamDraw(c25, 4, 4, 2, 1, 1);
555
556 // Validity
557 TCanvas &c26 = fDisplay->AddTab("Valid");
558 c26.Divide(4,2);
559
560 disp12.CamDraw(c26, 1, 4, 0);
561 disp13.CamDraw(c26, 2, 4, 0);
562 disp14.CamDraw(c26, 3, 4, 0);
563 disp15.CamDraw(c26, 4, 4, 0);
564
565 // Other info
566 TCanvas &c27 = fDisplay->AddTab("HiLoGain");
567 c27.Divide(3,3);
568
569 disp16.CamDraw(c27, 1, 3, 0);
570 disp17.CamDraw(c27, 2, 3, 1);
571 disp18.CamDraw(c27, 3, 3, 1);
572
573 // Pickup
574 TCanvas &c28 = fDisplay->AddTab("Pickup");
575 c28.Divide(4,2);
576
577 disp19.CamDraw(c28, 1, 4, 0);
578 disp20.CamDraw(c28, 2, 4, 0);
579 disp21.CamDraw(c28, 3, 4, 0);
580 disp22.CamDraw(c28, 4, 4, 0);
581
582 // Defects
583 TCanvas &c29 = fDisplay->AddTab("Defect");
584 // c29.Divide(5,2);
585 c29.Divide(4,2);
586
587 disp24.CamDraw(c29, 1, 4, 0);
588 disp25.CamDraw(c29, 2, 4, 0);
589 disp26.CamDraw(c29, 3, 4, 0);
590 disp27.CamDraw(c29, 4, 4, 0);
591
592 // Abs. Times
593 TCanvas &c30 = fDisplay->AddTab("Abs. Times");
594 c30.Divide(2,3);
595
596 disp28.CamDraw(c30, 1, 2, 2);
597 disp29.CamDraw(c30, 2, 2, 1);
598
599 if (fRelTimes)
600 {
601 // Rel. Times
602 TCanvas &c31 = fDisplay->AddTab("Rel. Times");
603 c31.Divide(3,5);
604
605 disp30.CamDraw(c31, 1, 3, 2, 1, 1);
606 disp31.CamDraw(c31, 2, 3, 2, 1, 1);
607 disp32.CamDraw(c31, 3, 3, 4, 1, 1);
608
609 // Time Defects
610 TCanvas &c32 = fDisplay->AddTab("Time Def.");
611 c32.Divide(2,2);
612
613 disp33.CamDraw(c32, 1, 2, 0);
614 disp34.CamDraw(c32, 2, 2, 0);
615
616 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationRelTimeCam");
617
618 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
619 {
620 cam->GetAverageHiGainSector(sector).DrawClone("fourierevents");
621 cam->GetAverageLoGainSector(sector).DrawClone("fourierevents");
622 }
623
624 }
625
626 return;
627 }
628}
629
630
631
632// --------------------------------------------------------------------------
633//
634// Find the colour of the pulsing LED:
635// - If the run number is smaller than gkIFAEBoxInaugurationRun, take MCalibrationCam::kCT1
636// - Otherwise find the colour out of the run name
637// - If no colour is found, return kFALSE
638//
639Bool_t MJCalibration::FindColor()
640{
641 if (fSequence)
642 {
643 fColor = MCalibrationCam::kCT1;
644 return kTRUE;
645 }
646
647const UInt_t nruns = fRuns->GetNumRuns();
648
649 if (nruns == 0)
650 return kFALSE;
651
652 TArrayI arr = fRuns->GetRuns();
653
654 if (arr[nruns-1] < gkIFAEBoxInaugurationRun)
655 {
656 *fLog << "Found colour kCT1 in runs: " << fRuns->GetRunsAsString() << endl;
657 fColor = MCalibrationCam::kCT1;
658 return kTRUE;
659 }
660
661 TString filenames;
662 ((MDirIter*)fRuns)->Reset();
663
664 while (!(filenames=((MDirIter*)fRuns)->Next()).IsNull())
665 {
666
667 filenames.ToLower();
668
669 //
670 // Here starts the list of runs where the shifters did not put
671 // a colour, but which have been found out by other means.
672 // FIXME: This list has is only preliminary and has to move into the
673 // database!!
674 //
675 if (filenames.Contains("_30090_"))
676 if (fColor == MCalibrationCam::kNONE)
677 {
678 *fLog << "Found colour: kGREEN in " << filenames << endl;
679 fColor = MCalibrationCam::kGREEN;
680 }
681 else if (fColor != MCalibrationCam::kNONE)
682 {
683 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
684 return kFALSE;
685 }
686
687 if (filenames.Contains("_27474_"))
688 if (fColor == MCalibrationCam::kNONE)
689 {
690 *fLog << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! "
691 << "Selected runs were: " << filenames << endl;
692 fColor = MCalibrationCam::kNONE;
693 return kFALSE;
694 }
695 else if (fColor != MCalibrationCam::kNONE)
696 {
697 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
698 return kFALSE;
699 }
700
701 if (filenames.Contains("_26924_"))
702 if (fColor == MCalibrationCam::kNONE)
703 {
704 *fLog << "Found colour: kGREEN in " << filenames << endl;
705 fColor = MCalibrationCam::kGREEN;
706 }
707 else if (fColor != MCalibrationCam::kGREEN)
708 {
709 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
710 return kFALSE;
711 }
712
713
714 if (filenames.Contains("_26568_"))
715 if (fColor == MCalibrationCam::kNONE)
716 {
717 *fLog << "Found colour: kGREEN in " << filenames << endl;
718 fColor = MCalibrationCam::kGREEN;
719 }
720 else if (fColor != MCalibrationCam::kGREEN)
721 {
722 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
723 return kFALSE;
724 }
725
726 if (filenames.Contains("_26412_"))
727 if (fColor == MCalibrationCam::kNONE)
728 {
729 *fLog << "Found colour: kGREEN in " << filenames << endl;
730 fColor = MCalibrationCam::kGREEN;
731 }
732 else if (fColor != MCalibrationCam::kGREEN)
733 {
734 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
735 return kFALSE;
736 }
737
738
739 if (filenames.Contains("_26409_"))
740 if (fColor == MCalibrationCam::kNONE)
741 {
742 *fLog << "Found colour: kGREEN in " << filenames << endl;
743 fColor = MCalibrationCam::kGREEN;
744 }
745 else if (fColor != MCalibrationCam::kGREEN)
746 {
747 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
748 return kFALSE;
749 }
750
751 if (filenames.Contains("_26408_"))
752 if (fColor == MCalibrationCam::kNONE)
753 {
754 *fLog << "Found colour: kGREEN in " << filenames << endl;
755 fColor = MCalibrationCam::kGREEN;
756 }
757 else if (fColor != MCalibrationCam::kGREEN)
758 {
759 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
760 return kFALSE;
761 }
762
763
764 if (filenames.Contains("_26402_"))
765 if (fColor == MCalibrationCam::kNONE)
766 {
767 *fLog << "Found colour: kBLUE in " << filenames << endl;
768 fColor = MCalibrationCam::kBLUE;
769 }
770 else if (fColor != MCalibrationCam::kBLUE)
771 {
772 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
773 return kFALSE;
774 }
775
776 if (filenames.Contains("_20661_"))
777 if (fColor == MCalibrationCam::kNONE)
778 {
779 *fLog << "Found colour: kGREEN in " << filenames << endl;
780 fColor = MCalibrationCam::kGREEN;
781 }
782 else if (fColor != MCalibrationCam::kGREEN)
783 {
784 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
785 return kFALSE;
786 }
787
788 if (filenames.Contains("_20660_"))
789 if (fColor == MCalibrationCam::kNONE)
790 {
791 *fLog << "Found colour: kGREEN in " << filenames << endl;
792 fColor = MCalibrationCam::kGREEN;
793 }
794 else if (fColor != MCalibrationCam::kGREEN)
795 {
796 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
797 return kFALSE;
798 }
799
800 //
801 // Here start the runs where the shifter put
802 // the colour.
803 //
804 if (filenames.Contains("green"))
805 if (fColor == MCalibrationCam::kNONE)
806 {
807 *fLog << "Found colour: kGREEN in " << filenames << endl;
808 fColor = MCalibrationCam::kGREEN;
809 }
810 else if (fColor != MCalibrationCam::kGREEN)
811 {
812 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
813 return kFALSE;
814 }
815
816 if (filenames.Contains("blue"))
817 if (fColor == MCalibrationCam::kNONE)
818 {
819 *fLog << "Found colour: kBLUE in " << filenames << endl;
820 fColor = MCalibrationCam::kBLUE;
821 }
822 else if (fColor != MCalibrationCam::kBLUE)
823 {
824 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
825 return kFALSE;
826 }
827
828 if (filenames.Contains("uv"))
829 if (fColor == MCalibrationCam::kNONE)
830 {
831 *fLog << "Found colour: kUV in " << filenames << endl;
832 fColor = MCalibrationCam::kUV;
833 }
834 else if (fColor != MCalibrationCam::kUV)
835 {
836 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
837 return kFALSE;
838 }
839
840 if (filenames.Contains("ct1"))
841 if (fColor == MCalibrationCam::kNONE)
842 {
843 *fLog << "Found colour: kCT1 in " << filenames << endl;
844 fColor = MCalibrationCam::kCT1;
845 }
846 else if (fColor != MCalibrationCam::kCT1)
847 {
848 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
849 return kFALSE;
850 }
851
852 }
853
854 if (fColor == MCalibrationCam::kNONE)
855 {
856 *fLog << "No colour found in filenames of runs: " << fRuns->GetRunsAsString()
857 << "... abort" << endl;
858 return kFALSE;
859 }
860
861
862 return kTRUE;
863}
864
865// --------------------------------------------------------------------------
866//
867// Retrieve the output file written by WriteResult()
868//
869const char* MJCalibration::GetOutputFile() const
870{
871 if (fSequence)
872 return Form("%s/calib%06d.root", (const char*)fOutputPath, fSequence->GetSequence());
873 if (!fRuns)
874 return "";
875
876 return Form("%s/%s-F1.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
877}
878
879Bool_t MJCalibration::IsUseBlindPixel() const
880{
881 return TESTBIT(fDevices,kUseBlindPixel);
882}
883
884Bool_t MJCalibration::IsUsePINDiode() const
885{
886 return TESTBIT(fDevices,kUsePINDiode);
887}
888
889void MJCalibration::SetEnv(const char *env)
890{
891 if (fEnv)
892 delete fEnv;
893 fEnv = new TEnv(env);
894}
895
896void MJCalibration::CheckEnv()
897{
898 if (!fEnv)
899 return;
900
901 TString e1 = fEnv->GetValue("MJCalibration.OutputPath", "");
902 if (!e1.IsNull())
903 {
904 e1.ReplaceAll("\015", "");
905 SetOutputPath(e1);
906 }
907}
908
909// --------------------------------------------------------------------------
910//
911// Call the ProcessFile(MPedestalCam)
912//
913Bool_t MJCalibration::Process(MPedestalCam &pedcam)
914{
915 if (!ReadCalibrationCam())
916 return ProcessFile(pedcam);
917
918 return kTRUE;
919}
920
921void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext,
922 MHCalibrationChargeBlindCam &blindcam)
923{
924 Int_t run = fSequence ? fSequence->GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
925
926 //
927 // Initialize the blind pixel. Unfortunately, there is a hardware difference
928 // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
929 // later setup. The first needs to use a filter because of the length of
930 // spurious NSB photon signals. The latter get better along extracting the amplitude
931 // from a small window.
932 //
933 if (run < gkSecondBlindPixelInstallation)
934 {
935 blindext.SetModified(kFALSE);
936 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
937 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
938 blindext.SetRange(10,19,0,6);
939 blindext.SetNSBFilterLimit(70);
940 blindcam.SetFitFunc( MHCalibrationChargeBlindPix::kEPoisson5 );
941 }
942 else
943 {
944 blindext.SetModified(kTRUE);
945 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
946 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
947 blindext.SetRange(5,8,0,2);
948 blindext.SetNSBFilterLimit(38);
949
950 if (run < gkThirdBlindPixelInstallation)
951 blindext.SetNumBlindPixels(2);
952 else
953 blindext.SetNumBlindPixels(3);
954 }
955}
956
957// --------------------------------------------------------------------------
958//
959// Execute the task list and the eventloop:
960//
961// - Check if there are fRuns, otherwise return
962// - Check the colour of the files in fRuns (FindColor()), otherwise return
963// - Check for consistency between run numbers and number of files
964// - Add fRuns to MReadMarsFile
965// - Put into MParList:
966// 1) MPedestalCam (pedcam)
967// 2) MCalibrationQECam (fQECam)
968// 3) MCalibrationChargeCam (fCalibrationCam)
969// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag fRelTimes is chosen)
970// 5) MBadPixelsCam (fBadPixels)
971// 6) MCalibrationChargePINDiode
972// 7) MCalibrationChargeBlindPix
973// - Put into the MTaskList:
974// 1) MReadMarsFile
975// 2) MBadPixelsMerge
976// 3) MGeomApply
977// 4) MExtractor
978// 5) MExtractPINDiode
979// 6) MExtractBlindPixel
980// 7) MExtractTime (only if flag fRelTimes is chosen)
981// 8) MContinue(MFCosmics)
982// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode")
983// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel")
984// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam")
985// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam")
986// 13) MCalibrationChargeCalc
987// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag fRelTimes is chosen)
988// 15) MCalibrationRelTimeCalc
989// - Execute MEvtLoop
990// - DisplayResult()
991// - WriteResult()
992//
993Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
994{
995 if (!fRuns && !fSequence)
996 {
997 *fLog << err << "No Runs choosen... abort." << endl;
998 return kFALSE;
999 }
1000
1001 if (!fSequence && fRuns->GetNumRuns() != fRuns->GetNumEntries())
1002 {
1003 *fLog << err << "Number of files found doesn't match number of runs... abort."
1004 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
1005 return kFALSE;
1006 }
1007
1008 *fLog << inf;
1009 fLog->Separator(GetDescriptor());
1010
1011 if (!FindColor())
1012 return kFALSE;
1013
1014 *fLog << "Calculate MCalibrationCam from ";
1015 if (fSequence)
1016 *fLog << "Sequence #" << fSequence->GetSequence() << endl;
1017 else
1018 *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
1019 *fLog << endl;
1020
1021 // Setup Tasklist
1022 MParList plist;
1023 MTaskList tlist;
1024 plist.AddToList(&tlist);
1025
1026 MReadMarsFile read("Events");
1027 MRawFileRead rawread(NULL);
1028
1029 MDirIter iter;
1030 if (fSequence)
1031 fSequence->SetupCalRuns(iter);
1032
1033 if (fDataCheck)
1034 {
1035 rawread.AddFiles(fSequence ? iter : *fRuns);
1036 tlist.AddToList(&rawread);
1037 }
1038 else
1039 {
1040 read.DisableAutoScheme();
1041 static_cast<MRead&>(read).AddFiles(fSequence ? iter : *fRuns);
1042 tlist.AddToList(&read);
1043 }
1044
1045 MHCalibrationChargeCam chargecam;
1046 MHCalibrationChargeBlindCam blindcam;
1047
1048 plist.AddToList(&pedcam);
1049 plist.AddToList(&chargecam);
1050 plist.AddToList(&blindcam);
1051 plist.AddToList(&fBadPixels);
1052 plist.AddToList(&fQECam);
1053 plist.AddToList(&fCalibrationCam);
1054 plist.AddToList(&fCalibrationBlindCam);
1055 plist.AddToList(&fCalibrationPINDiode);
1056 plist.AddToList(&fRelTimeCam);
1057
1058 MGeomApply apply;
1059 MBadPixelsMerge merge(&fBadPixels);
1060 MExtractPINDiode pinext;
1061 MExtractBlindPixel blindext;
1062 InitBlindPixel(blindext, blindcam);
1063 MExtractSlidingWindow extract2;
1064 MExtractTimeFastSpline timespline;
1065 MCalibrationChargeCalc calcalc;
1066 if (!fSequence)
1067 {
1068 calcalc.SetOutputPath(fOutputPath);
1069 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1070 }
1071
1072 if (fDebug)
1073 {
1074 chargecam.SetDebug();
1075 calcalc.SetDebug();
1076 }
1077
1078 //
1079 // As long as there are no DM's, have to colour by hand
1080 //
1081 calcalc.SetPulserColor(fColor);
1082
1083 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
1084 MFillH fillbnd("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
1085 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam");
1086 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam");
1087 fillpin.SetNameTab("PINDiode");
1088 fillbnd.SetNameTab("BlindPix");
1089 fillcam.SetNameTab("Charge");
1090 filltme.SetNameTab("RelTimes");
1091
1092 TString drawoption;
1093
1094 if (fDisplayType == kDataCheckDisplay)
1095 drawoption += "datacheck";
1096 if (fDisplayType == kFullDisplay)
1097 drawoption += " all";
1098
1099 fillcam.SetDrawOption(drawoption.Data());
1100 fillbnd.SetDrawOption(drawoption.Data());
1101 fillpin.SetDrawOption(drawoption.Data());
1102 filltme.SetDrawOption(drawoption.Data());
1103
1104 //
1105 // Apply a filter against cosmics
1106 // (will have to be needed in the future
1107 // when the calibration hardware-trigger is working)
1108 //
1109 MFCosmics cosmics;
1110 MContinue cont(&cosmics);
1111
1112 tlist.AddToList(&merge);
1113 tlist.AddToList(&apply);
1114
1115 MTaskEnv taskenv("ExtractSignal");
1116 taskenv.SetDefault(fExtractor ? fExtractor : &extract2);
1117
1118 tlist.AddToList(&taskenv);
1119 tlist.AddToList(&pinext);
1120 tlist.AddToList(&blindext);
1121
1122 MTaskEnv taskenv2("ExtractTime");
1123 taskenv2.SetDefault(fTimeExtractor ? fTimeExtractor : &timespline);
1124
1125 if (fRelTimes)
1126 tlist.AddToList(&taskenv2);
1127
1128 if (fColor == MCalibrationCam::kCT1)
1129 tlist.AddToList(&cont);
1130
1131 tlist.AddToList(&fillcam);
1132 tlist.AddToList(&calcalc);
1133
1134 MCalibrationRelTimeCalc timecalc;
1135 if (fRelTimes)
1136 {
1137 tlist.AddToList(&filltme);
1138 tlist.AddToList(&timecalc);
1139 }
1140
1141
1142 // Create and setup the eventloop
1143 MEvtLoop evtloop(fName);
1144 evtloop.SetParList(&plist);
1145 evtloop.SetDisplay(fDisplay);
1146 evtloop.SetLogStream(fLog);
1147 if (fEnv)
1148 evtloop.ReadEnv(*fEnv);
1149
1150 // Execute first analysis
1151 if (!evtloop.Eventloop())
1152 {
1153 *fLog << err << GetDescriptor() << ": Failed." << endl;
1154 return kFALSE;
1155 }
1156
1157 tlist.PrintStatistics();
1158
1159 //
1160 // The next lines are necessary in order to avoid that
1161 // the last entry drawn by MFillH gets deleted again from
1162 // the display. No idea where this comes from...
1163 //
1164 /*
1165 if (fDisplay)
1166 {
1167 if (IsUsePINDiode())
1168 {
1169 MHCalibrationChargePINDiode *pin =
1170 (MHCalibrationChargePINDiode*)plist.FindObject("MHCalibrationChargePINDiode");
1171 pin->DrawClone(Form("nonew %s",drawoption.Data()));
1172 }
1173 else if (IsUseBlindPixel())
1174 {
1175 MHCalibrationChargeBlindCam *cam =
1176 (MHCalibrationChargeBlindCam*)plist.FindObject("MHCalibrationChargeBlindCam");
1177 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1178 }
1179 else if (fRelTimes)
1180 {
1181 MHCalibrationRelTimeCam *cam =
1182 (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
1183 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1184 }
1185 else
1186 {
1187 MHCalibrationChargeCam *cam =
1188 (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
1189 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1190 }
1191 }
1192 */
1193
1194 DisplayResult(plist);
1195
1196 if (!WriteResult())
1197 return kFALSE;
1198
1199 *fLog << inf << GetDescriptor() << ": Done." << endl;
1200
1201 return kTRUE;
1202}
1203
1204// --------------------------------------------------------------------------
1205//
1206// Read the following containers from GetOutputFile()
1207// - MCalibrationChargeCam
1208// - MCalibrationQECam
1209// - MBadPixelsCam
1210//
1211Bool_t MJCalibration::ReadCalibrationCam()
1212{
1213
1214 const TString fname = GetOutputFile();
1215
1216 if (gSystem->AccessPathName(fname, kFileExists))
1217 {
1218 *fLog << err << "Input file " << fname << " doesn't exist." << endl;
1219 return kFALSE;
1220 }
1221
1222 *fLog << inf << "Reading from file: " << fname << endl;
1223
1224 TFile file(fname, "READ");
1225 if (fCalibrationCam.Read()<=0)
1226 {
1227 *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
1228 return kFALSE;
1229 }
1230
1231 if (fQECam.Read()<=0)
1232 {
1233 *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
1234 return kFALSE;
1235 }
1236
1237
1238 if (fRelTimes)
1239 if (fRelTimeCam.Read()<=0)
1240 {
1241 *fLog << err << "Unable to read MCalibrationRelTimeCam from " << fname << endl;
1242 return kFALSE;
1243 }
1244
1245 if (file.FindKey("MBadPixelsCam"))
1246 {
1247 MBadPixelsCam bad;
1248 if (bad.Read()<=0)
1249 {
1250 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
1251 return kFALSE;
1252 }
1253 fBadPixels.Merge(bad);
1254 }
1255
1256 if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
1257 fDisplay->Read();
1258
1259 return kTRUE;
1260}
1261
1262
1263// --------------------------------------------------------------------------
1264//
1265// Set the path for output files, written by WriteResult()
1266//
1267void MJCalibration::SetOutputPath(const char *path)
1268{
1269 fOutputPath = path;
1270 if (fOutputPath.EndsWith("/"))
1271 fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
1272}
1273
1274// --------------------------------------------------------------------------
1275//
1276// Set the useage of the Blind Pixel device
1277//
1278void MJCalibration::SetUseBlindPixel(const Bool_t b)
1279{
1280 b ? SETBIT(fDevices,kUseBlindPixel) : CLRBIT(fDevices,kUseBlindPixel);
1281}
1282
1283// --------------------------------------------------------------------------
1284//
1285// Set the useage of the PIN Diode device
1286//
1287void MJCalibration::SetUsePINDiode(const Bool_t b)
1288{
1289 b ? SETBIT(fDevices,kUsePINDiode) : CLRBIT(fDevices,kUsePINDiode);
1290}
1291
1292// --------------------------------------------------------------------------
1293//
1294// Write the result into the output file GetOutputFile(), if fOutputPath exists.
1295//
1296// The following containers are written:
1297// - MStatusDisplay
1298// - MCalibrationChargeCam
1299// - MCalibrationChargeBlindPix
1300// - MCalibrationQECam
1301// - MBadPixelsCam
1302//
1303Bool_t MJCalibration::WriteResult()
1304{
1305 if (fOutputPath.IsNull())
1306 return kTRUE;
1307
1308 const TString oname(GetOutputFile());
1309
1310 *fLog << inf << "Writing to file: " << oname << endl;
1311
1312 TFile file(oname, "UPDATE");
1313
1314 if (fDisplay && fDisplay->Write()<=0)
1315 {
1316 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
1317 return kFALSE;
1318 }
1319
1320 if (fCalibrationCam.Write()<=0)
1321 {
1322 *fLog << err << "Unable to write MCalibrationChargeCam to " << oname << endl;
1323 return kFALSE;
1324 }
1325
1326 if (fCalibrationBlindCam.Write()<=0)
1327 {
1328 *fLog << err << "Unable to write MCalibrationChargeBlindCam to " << oname << endl;
1329 return kFALSE;
1330 }
1331
1332 if (fCalibrationPINDiode.Write()<=0)
1333 {
1334 *fLog << err << "Unable to write MCalibrationChargePINDiode to " << oname << endl;
1335 return kFALSE;
1336 }
1337
1338 if (fQECam.Write()<=0)
1339 {
1340 *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
1341 return kFALSE;
1342 }
1343
1344 if (fRelTimes)
1345 if (fRelTimeCam.Write()<=0)
1346 {
1347 *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
1348 return kFALSE;
1349 }
1350
1351 if (fBadPixels.Write()<=0)
1352 {
1353 *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
1354 return kFALSE;
1355 }
1356
1357 return kTRUE;
1358
1359}
1360
Note: See TracBrowser for help on using the repository browser.