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

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