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

Last change on this file since 4651 was 4645, checked in by gaug, 20 years ago
*** empty log message ***
File size: 60.7 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#include <TLine.h>
95#include <TLatex.h>
96#include <TLegend.h>
97#include <TPaveText.h>
98
99#include "MLog.h"
100#include "MLogManip.h"
101
102#include "MRunIter.h"
103#include "MSequence.h"
104#include "MParList.h"
105#include "MTaskList.h"
106#include "MEvtLoop.h"
107
108#include "MHCamera.h"
109#include "MGeomCam.h"
110
111#include "MPedestalCam.h"
112#include "MCalibrationCam.h"
113#include "MCalibrationQECam.h"
114#include "MCalibrationQEPix.h"
115#include "MCalibrationChargeCam.h"
116#include "MCalibrationChargePix.h"
117#include "MCalibrationChargePINDiode.h"
118#include "MCalibrationChargeBlindPix.h"
119#include "MCalibrationChargeBlindCam.h"
120#include "MCalibrationChargeBlindPix.h"
121#include "MCalibrationChargeCalc.h"
122
123#include "MHGausEvents.h"
124#include "MHCalibrationCam.h"
125#include "MHCalibrationChargeCam.h"
126#include "MHCalibrationChargeBlindCam.h"
127#include "MHCalibrationChargePINDiode.h"
128#include "MHCalibrationRelTimeCam.h"
129#include "MCalibrationRelTimeCam.h"
130#include "MCalibrationRelTimeCalc.h"
131
132#include "MReadMarsFile.h"
133#include "MRawFileRead.h"
134#include "MGeomApply.h"
135#include "MTaskEnv.h"
136#include "MBadPixelsMerge.h"
137#include "MBadPixelsCam.h"
138#include "MExtractTime.h"
139#include "MExtractor.h"
140#include "MExtractPINDiode.h"
141#include "MExtractBlindPixel.h"
142#include "MExtractSlidingWindow.h"
143#include "MExtractTimeFastSpline.h"
144#include "MFCosmics.h"
145#include "MContinue.h"
146#include "MFillH.h"
147
148#include "MArrivalTimeCam.h"
149
150#include "MStatusDisplay.h"
151
152ClassImp(MJCalibration);
153
154using namespace std;
155
156const Int_t MJCalibration::gkIFAEBoxInaugurationRun = 20113;
157const Int_t MJCalibration::gkSecondBlindPixelInstallation = 31693;
158const Int_t MJCalibration::gkThirdBlindPixelInstallation = 99999;
159
160const Double_t MJCalibration::fgConvFADC2PheMin = 0.;
161const Double_t MJCalibration::fgConvFADC2PheMax = 1.5;
162const Double_t MJCalibration::fgConvFADC2PhotMin = 0.;
163const Double_t MJCalibration::fgConvFADC2PhotMax = 10.;
164const Double_t MJCalibration::fgQEMin = 0.;
165const Double_t MJCalibration::fgQEMax = 0.3;
166
167const Float_t MJCalibration::fgRefConvFADC2PheInner = 0.14;
168const Float_t MJCalibration::fgRefConvFADC2PheOuter = 0.45;
169const Float_t MJCalibration::fgRefConvFADC2PhotInner = 0.8;
170const Float_t MJCalibration::fgRefConvFADC2PhotOuter = 3.8;
171const Float_t MJCalibration::fgRefQEInner = 0.18;
172const Float_t MJCalibration::fgRefQEOuter = 0.12;
173// --------------------------------------------------------------------------
174//
175// Default constructor.
176//
177// - Sets fRuns to 0, fExtractor to NULL, fTimeExtractor to NULL, fColor to kNONE,
178// fDisplay to kNormalDisplay, fRelTime to kFALSE, fDataCheck to kFALSE,
179// - SetUseBlindPixel()
180// - SetUsePINDiode()
181//
182MJCalibration::MJCalibration(const char *name, const char *title)
183 : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fTimeExtractor(NULL),
184 fColor(MCalibrationCam::kNONE), fDisplayType(kNormalDisplay),
185 fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE)
186{
187
188 fName = name ? name : "MJCalibration";
189 fTitle = title ? title : "Tool to create the calibration constants for one calibration run";
190
191 SetUseBlindPixel();
192 SetUsePINDiode();
193
194}
195
196MJCalibration::~MJCalibration()
197{
198 if (fEnv)
199 delete fEnv;
200}
201
202// --------------------------------------------------------------------------
203//
204// Display the results in MStatusDisplay:
205//
206// - Add "Calibration" to the MStatusDisplay title
207// - Retrieve the MGeomCam from MParList
208// - Initialize the following MHCamera's:
209// 1) MCalibrationPix::GetMean()
210// 2) MCalibrationPix::Sigma()
211// 3) MCalibrationChargePix::GetRSigma()
212// 4) MCalibrationChargePix::GetRSigmaPerCharge()
213// 5) MCalibrationChargePix::GetPheFFactorMethod()
214// 6) MCalibrationChargePix::GetMeanConvFADC2Phe()
215// 7) MCalibrationChargePix::GetMeanFFactorFADC2Phot()
216// 8) MCalibrationQEPix::GetQECascadesFFactor()
217// 9) MCalibrationQEPix::GetQECascadesBlindPixel()
218// 10) MCalibrationQEPix::GetQECascadesPINDiode()
219// 11) MCalibrationQEPix::GetQECascadesCombined()
220// 12) MCalibrationQEPix::IsAverageQEFFactorAvailable()
221// 13) MCalibrationQEPix::IsAverageQEBlindPixelAvailable()
222// 14) MCalibrationQEPix::IsAverageQEPINDiodeAvailable()
223// 15) MCalibrationQEPix::IsAverageQECombinedAvailable()
224// 16) MCalibrationChargePix::IsHiGainSaturation()
225// 17) MCalibrationPix::GetHiLoMeansDivided()
226// 18) MCalibrationPix::GetHiLoSigmasDivided()
227// 19) MCalibrationChargePix::GetHiGainPickup()
228// 20) MCalibrationChargePix::GetLoGainPickup()
229// 21) MCalibrationChargePix::GetHiGainBlackout()
230// 22) MCalibrationChargePix::GetLoGainBlackout()
231// 23) MCalibrationPix::IsExcluded()
232// 24) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
233// 25) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
234// 26) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
235// 27) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
236// 28) MCalibrationChargePix::GetAbsTimeMean()
237// 29) MCalibrationChargePix::GetAbsTimeRms()
238//
239// If the flag SetFullDisplay() is set, all MHCameras will be displayed.
240// if the flag SetDataCheckDisplay() is set, only the most important ones are displayed
241// and otherwise, (default: SetNormalDisplay()), a good selection of plots is given
242//
243void MJCalibration::DisplayResult(MParList &plist)
244{
245
246 if (!fDisplay)
247 return;
248
249 //
250 // Update display
251 //
252 TString title = fDisplay->GetTitle();
253 title += "-- Calibration ";
254 title += fSequence ? Form("calib%06d", fSequence->GetSequence()) : fRuns->GetRunsAsString();
255 title += " --";
256 fDisplay->SetTitle(title);
257
258 //
259 // Get container from list
260 //
261 MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
262
263 // Create histograms to display
264 MHCamera disp1 (geomcam, "Charge", "Fitted Mean Charges");
265 MHCamera disp2 (geomcam, "SigmaCharge", "Sigma of Fitted Charges");
266 MHCamera disp3 (geomcam, "RSigma", "Reduced Sigmas");
267 MHCamera disp4 (geomcam, "RSigmaPerCharge", "Reduced Sigma per Charge");
268 MHCamera disp5 (geomcam, "NumPhes", "Number of Phes");
269 MHCamera disp6 (geomcam, "ConvFADC2Phes", "Conversion Factor to Phes");
270 MHCamera disp7 (geomcam, "TotalFFactor", "Total F-Factor (F-Factor Method)");
271 MHCamera disp8 (geomcam, "CascadesQEFFactor", "Cascades QE (F-Factor Method)");
272 MHCamera disp9 (geomcam, "CascadesQEBlindPix","Cascades QE (Blind Pixel Method)");
273 MHCamera disp10(geomcam, "CascadesQEPINDiode","Cascades QE (PIN Diode Method)");
274 MHCamera disp11(geomcam, "CascadesQECombined","Cascades QE (Combined Method)");
275 MHCamera disp12(geomcam, "FFactorValid", "Pixels with valid F-Factor calibration");
276 MHCamera disp13(geomcam, "BlindPixelValid", "Pixels with valid BlindPixel calibration");
277 MHCamera disp14(geomcam, "PINdiodeValid", "Pixels with valid PINDiode calibration");
278 MHCamera disp15(geomcam, "CombinedValid", "Pixels with valid Combined calibration");
279 MHCamera disp16(geomcam, "Saturation", "Pixels with saturated Hi Gain");
280 MHCamera disp17(geomcam, "ConversionMeans", "Conversion HiGain.vs.LoGain Means");
281 MHCamera disp18(geomcam, "ConversionSigmas", "Conversion HiGain.vs.LoGain Sigmas");
282 MHCamera disp19(geomcam, "HiGainPickup", "Number Pickup events Hi Gain");
283 MHCamera disp20(geomcam, "LoGainPickup", "Number Pickup events Lo Gain");
284 MHCamera disp21(geomcam, "HiGainBlackout", "Number Blackout events Hi Gain");
285 MHCamera disp22(geomcam, "LoGainBlackout", "Number Blackout events Lo Gain");
286 MHCamera disp23(geomcam, "Excluded", "Pixels previously excluded");
287 MHCamera disp24(geomcam, "UnSuitable", "Pixels not suited for further analysis");
288 MHCamera disp25(geomcam, "UnReliable", "Pixels not reliable for further analysis");
289 MHCamera disp26(geomcam, "HiGainOscillating", "Oscillating Pixels High Gain");
290 MHCamera disp27(geomcam, "LoGainOscillating", "Oscillating Pixels Low Gain");
291 MHCamera disp28(geomcam, "AbsTimeMean", "Abs. Arrival Times");
292 MHCamera disp29(geomcam, "AbsTimeRms", "RMS of Arrival Times");
293 MHCamera disp30(geomcam, "MeanTime", "Mean Rel. Arrival Times");
294 MHCamera disp31(geomcam, "SigmaTime", "Sigma Rel. Arrival Times");
295 MHCamera disp32(geomcam, "TimeProb", "Probability of Time Fit");
296 MHCamera disp33(geomcam, "TimeNotFitValid", "Pixels with not valid fit results");
297 MHCamera disp34(geomcam, "TimeOscillating", "Oscillating Pixels");
298 MHCamera disp35(geomcam, "TotalConv", "Conversion Factor to photons");
299
300 // Fitted charge means and sigmas
301 disp1.SetCamContent(fCalibrationCam, 0);
302 disp1.SetCamError( fCalibrationCam, 1);
303 disp2.SetCamContent(fCalibrationCam, 2);
304 disp2.SetCamError( fCalibrationCam, 3);
305
306 // Reduced Sigmas and reduced sigmas per charge
307 disp3.SetCamContent(fCalibrationCam, 5);
308 disp3.SetCamError( fCalibrationCam, 6);
309 disp4.SetCamContent(fCalibrationCam, 7);
310 disp4.SetCamError( fCalibrationCam, 8);
311
312 // F-Factor Method
313 disp5.SetCamContent(fCalibrationCam, 9);
314 disp5.SetCamError( fCalibrationCam, 10);
315 disp6.SetCamContent(fCalibrationCam, 11);
316 disp6.SetCamError( fCalibrationCam, 12);
317 disp7.SetCamContent(fCalibrationCam, 13);
318 disp7.SetCamError( fCalibrationCam, 14);
319
320 // Quantum Efficiencies
321 disp8.SetCamContent (fQECam, 0 );
322 disp8.SetCamError (fQECam, 1 );
323 disp9.SetCamContent (fQECam, 2 );
324 disp9.SetCamError (fQECam, 3 );
325 disp10.SetCamContent(fQECam, 4 );
326 disp10.SetCamError (fQECam, 5 );
327 disp11.SetCamContent(fQECam, 6 );
328 disp11.SetCamError (fQECam, 7 );
329
330 // Valid flags
331 disp12.SetCamContent(fQECam, 8 );
332 disp13.SetCamContent(fQECam, 9 );
333 disp14.SetCamContent(fQECam, 10);
334 disp15.SetCamContent(fQECam, 11);
335
336 // Conversion Hi-Lo
337 disp16.SetCamContent(fCalibrationCam, 25);
338 disp17.SetCamContent(fCalibrationCam, 16);
339 disp17.SetCamError (fCalibrationCam, 17);
340 disp18.SetCamContent(fCalibrationCam, 18);
341 disp18.SetCamError (fCalibrationCam, 19);
342
343 // Pickup and Blackout
344 disp19.SetCamContent(fCalibrationCam, 21);
345 disp20.SetCamContent(fCalibrationCam, 22);
346 disp21.SetCamContent(fCalibrationCam, 23);
347 disp22.SetCamContent(fCalibrationCam, 24);
348
349 // Pixels with defects
350 disp23.SetCamContent(fCalibrationCam, 20);
351 disp24.SetCamContent(fBadPixels, 6);
352 disp25.SetCamContent(fBadPixels, 7);
353
354 // Oscillations
355 disp26.SetCamContent(fBadPixels, 10);
356 disp27.SetCamContent(fBadPixels, 11);
357
358 // Arrival Times
359 disp28.SetCamContent(fCalibrationCam, 26);
360 disp28.SetCamError( fCalibrationCam, 27);
361 disp29.SetCamContent(fCalibrationCam, 27);
362
363 disp1.SetYTitle("Q [FADC counts]");
364 disp2.SetYTitle("\\sigma_{Q} [FADC counts]");
365
366 disp3.SetYTitle("\\sqrt{\\sigma^{2}_{Q} - RMS^{2}_{Ped}} [FADC Counts]");
367 disp4.SetYTitle("Red.Sigma/<Q> [1]");
368
369 disp5.SetYTitle("Phes [1]");
370 disp6.SetYTitle("Conv.Factor [PhE/FADC counts]");
371 disp7.SetYTitle("Total F-Factor [1]");
372
373 disp8.SetYTitle("QE [1]");
374 disp9.SetYTitle("QE [1]");
375 disp10.SetYTitle("QE [1]");
376 disp11.SetYTitle("QE [1]");
377
378 disp12.SetYTitle("[1]");
379 disp13.SetYTitle("[1]");
380 disp14.SetYTitle("[1]");
381 disp15.SetYTitle("[1]");
382 disp16.SetYTitle("[1]");
383
384 disp17.SetYTitle("<Q>(High)/<Q>(Low) [1]");
385 disp18.SetYTitle("\\sigma_{Q}(High)/\\sigma_{Q}(Low) [1]");
386
387 disp19.SetYTitle("[1]");
388 disp20.SetYTitle("[1]");
389 disp21.SetYTitle("[1]");
390 disp22.SetYTitle("[1]");
391 // disp23.SetYTitle("[1]");
392 // disp24.SetYTitle("[1]");
393 // disp25.SetYTitle("[1]");
394 disp26.SetYTitle("[1]");
395 disp27.SetYTitle("[1]");
396
397 disp28.SetYTitle("Mean Abs. Time [FADC slice]");
398 disp29.SetYTitle("RMS Abs. Time [FADC slices]");
399
400 disp35.SetYTitle("Conv.Factor [Ph/FADC counts]");
401
402 for (UInt_t i=0;i<geomcam.GetNumPixels();i++)
403 {
404
405 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCalibrationCam[i];
406 MCalibrationQEPix &qe = (MCalibrationQEPix&) fQECam [i];
407
408 if (!pix.IsFFactorMethodValid())
409 continue;
410
411 const Float_t convphe = pix.GetMeanConvFADC2Phe();
412 const Float_t quaeff = qe.GetQECascadesFFactor(0.);
413
414 disp35.Fill(i,convphe/quaeff);
415 disp35.SetUsed(i);
416 }
417
418
419 if (fRelTimes)
420 {
421 disp30.SetCamContent(fRelTimeCam,0);
422 disp30.SetCamError( fRelTimeCam,1);
423 disp31.SetCamContent(fRelTimeCam,2);
424 disp31.SetCamError( fRelTimeCam,3);
425 disp32.SetCamContent(fRelTimeCam,4);
426 disp33.SetCamContent(fBadPixels,20);
427 disp34.SetCamContent(fBadPixels,21);
428
429 disp30.SetYTitle("Time Offset [FADC units]");
430 disp31.SetYTitle("Timing resolution [FADC units]");
431 disp32.SetYTitle("P_{Time} [1]");
432 disp33.SetYTitle("[1]");
433 disp34.SetYTitle("[1]");
434 }
435
436
437
438 if (fDisplayType == kDataCheckDisplay)
439 {
440
441 TCanvas &c1 = fDisplay->AddTab("Fit.Charge");
442 c1.Divide(3, 3);
443
444 //
445 // MEAN CHARGES
446 //
447
448 c1.cd(1);
449 gPad->SetBorderMode(0);
450 gPad->SetTicks();
451 MHCamera *obj1=(MHCamera*)disp1.DrawCopy("hist");
452 //
453 // for the datacheck, fix the ranges!!
454 //
455 // obj1->SetMinimum(fgChargeMin);
456 // obj1->SetMaximum(fgChargeMax);
457 //
458 // Set the datacheck sizes:
459 //
460 FixDataCheckHist((TH1D*)obj1);
461 //
462 // set reference lines
463 //
464 // DisplayReferenceLines(obj1,0);
465
466 c1.cd(4);
467 gPad->SetBorderMode(0);
468 obj1->SetPrettyPalette();
469 obj1->Draw();
470
471 c1.cd(7);
472 gPad->SetBorderMode(0);
473 gPad->SetTicks();
474 TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName());
475 obj2->Draw();
476 obj2->SetBit(kCanDelete);
477 obj2->Fit("gaus","Q");
478 TF1 *fun2 = obj2->GetFunction("gaus");
479 fun2->SetLineColor(kYellow);
480 //
481 // Set the datacheck sizes:
482 //
483 FixDataCheckHist(obj2);
484 obj2->SetStats(1);
485
486 //
487 // Display the outliers as dead and noisy pixels
488 //
489 DisplayOutliers(obj2,"dead","noisy");
490 TLatex flattex;
491 flattex.SetTextSize(0.06);
492 const Double_t minl = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
493 const Double_t maxl = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
494 flattex.DrawLatex(minl+0.1*(maxl-minl),obj2->GetBinContent(obj2->GetMaximumBin())/1.3,
495 Form("Flatfielding precision: %4.2f%%",
496 fun2->GetParameter(2)/fun2->GetParameter(1)*100.));
497
498 //
499 // REDUCED SIGMAS
500 //
501
502 c1.cd(2);
503 gPad->SetBorderMode(0);
504 gPad->SetTicks();
505 MHCamera *obj3=(MHCamera*)disp4.DrawCopy("hist");
506 //
507 // for the datacheck, fix the ranges!!
508 //
509 // obj3->SetMinimum(fgChargeMin);
510 // obj3->SetMaximum(fgChargeMax);
511 //
512 // Set the datacheck sizes:
513 //
514 FixDataCheckHist((TH1D*)obj3);
515 //
516 // set reference lines
517 //
518 // DisplayReferenceLines(obj3,0);
519
520 c1.cd(5);
521 gPad->SetBorderMode(0);
522 obj3->SetPrettyPalette();
523 obj3->Draw();
524
525 c1.cd(8);
526 gPad->SetBorderMode(0);
527 if (geomcam.InheritsFrom("MGeomCamMagic"))
528 DisplayDoubleProject(&disp4, "dead", "noisy");
529
530 //
531 // PHOTO ELECTRONS
532 //
533
534 c1.cd(3);
535 gPad->SetBorderMode(0);
536 gPad->SetTicks();
537 MHCamera *obj4=(MHCamera*)disp5.DrawCopy("hist");
538 //
539 // for the datacheck, fix the ranges!!
540 //
541 // obj3->SetMinimum(fgChargeMin);
542 // obj3->SetMaximum(fgChargeMax);
543 //
544 // Set the datacheck sizes:
545 //
546 FixDataCheckHist((TH1D*)obj4);
547 //
548 // set reference lines
549 //
550 // DisplayReferenceLines(obj3,0);
551
552 c1.cd(6);
553 gPad->SetBorderMode(0);
554 obj4->SetPrettyPalette();
555 obj4->Draw();
556
557 c1.cd(9);
558 gPad->SetBorderMode(0);
559 if (geomcam.InheritsFrom("MGeomCamMagic"))
560 DisplayDoubleProject(&disp5, "dead", "noisy");
561
562 //
563 // CONVERSION FACTORS
564 //
565
566 TCanvas &c2 = fDisplay->AddTab("Conversion");
567 c2.Divide(3,3);
568
569 c2.cd(1);
570 gPad->SetBorderMode(0);
571 gPad->SetTicks();
572 MHCamera *obj5=(MHCamera*)disp6.DrawCopy("hist");
573 //
574 // for the datacheck, fix the ranges!!
575 //
576 obj5->SetMinimum(fgConvFADC2PheMin);
577 obj5->SetMaximum(fgConvFADC2PheMax);
578 //
579 // Set the datacheck sizes:
580 //
581 FixDataCheckHist((TH1D*)obj5);
582 //
583 // set reference lines
584 //
585 DisplayReferenceLines(obj5,2);
586
587 c2.cd(4);
588 gPad->SetBorderMode(0);
589 obj5->SetPrettyPalette();
590 obj5->Draw();
591
592 c2.cd(7);
593 gPad->SetBorderMode(0);
594 if (geomcam.InheritsFrom("MGeomCamMagic"))
595 DisplayDoubleProject(&disp6, "noisy", "dead");
596
597 //
598 // QUANTUM EFFICIENCY
599 //
600
601 c2.cd(2);
602 gPad->SetBorderMode(0);
603 gPad->SetTicks();
604 MHCamera *obj6=(MHCamera*)disp8.DrawCopy("hist");
605 //
606 // for the datacheck, fix the ranges!!
607 //
608 obj6->SetMinimum(fgQEMin);
609 obj6->SetMaximum(fgQEMax);
610 //
611 // Set the datacheck sizes:
612 //
613 FixDataCheckHist((TH1D*)obj6);
614 //
615 // set reference lines
616 //
617 DisplayReferenceLines(obj6,0);
618
619 c2.cd(5);
620 gPad->SetBorderMode(0);
621 obj6->SetPrettyPalette();
622 obj6->Draw();
623
624 c2.cd(8);
625 gPad->SetBorderMode(0);
626 if (geomcam.InheritsFrom("MGeomCamMagic"))
627 DisplayDoubleProject(&disp8, "noisy", "dead");
628
629 //
630 // CONVERSION FADC TO PHOTONS
631 //
632
633 c2.cd(3);
634 gPad->SetBorderMode(0);
635 gPad->SetTicks();
636 MHCamera *obj7=(MHCamera*)disp35.DrawCopy("hist");
637 //
638 // for the datacheck, fix the ranges!!
639 //
640 obj7->SetMinimum(fgConvFADC2PhotMin);
641 obj7->SetMaximum(fgConvFADC2PhotMax);
642 //
643 // Set the datacheck sizes:
644 //
645 FixDataCheckHist((TH1D*)obj7);
646 //
647 // set reference lines
648 //
649 DisplayReferenceLines(obj7,1);
650
651 c2.cd(6);
652 gPad->SetBorderMode(0);
653 obj7->SetPrettyPalette();
654 obj7->Draw();
655 c2.cd(9);
656 gPad->SetBorderMode(0);
657 if (geomcam.InheritsFrom("MGeomCamMagic"))
658 DisplayDoubleProject(&disp35, "noisy", "dead");
659
660 //
661 // UNSUITABLE PIXELS
662 //
663 TCanvas &c4 = fDisplay->AddTab("Defect");
664 c4.Divide(2,2);
665
666 c4.cd(1);
667 gPad->SetBorderMode(0);
668 gPad->SetTicks();
669 MHCamera *obj8=(MHCamera*)disp24.DrawCopy("hist");
670 //
671 // for the datacheck, fix the ranges!!
672 //
673 const Double_t max = 11.;
674 obj8->SetMinimum(0.);
675 obj8->SetMaximum(11.);
676 //
677 // Set the datacheck sizes:
678 //
679 FixDataCheckHist((TH1D*)obj8);
680
681 gStyle->SetPalette(1);
682 const Int_t numcol = gStyle->GetNumberOfColors()-3;
683
684 TPaveText *pave = new TPaveText(0.0,0.0,0.99,0.99);
685 pave->SetBit(kCanDelete);
686 pave->ConvertNDCtoPad();
687 pave->SetTextSize(0.05);
688 pave->AddText(" ");
689 TText *t1 = pave->AddText(Form("Signal smaller 3 Pedestal RMS: %3i pixels",
690 CountBadPixels(&disp24,1)));
691 t1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max*numcol + 1.)));
692 t1->SetTextAlign(12);
693 TText *t2 = pave->AddText(Form("%s%3i%s","Signal Rel. error too large: ",
694 CountBadPixels(&disp24,2)," pixels"));
695 t2->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol + 1.)));
696 t2->SetTextAlign(12);
697 TText *t3 = pave->AddText(Form("Signal Sigma smaller than Pedestal RMS: %3i pixels",
698 CountBadPixels(&disp24,3)));
699 t3->SetTextColor(gStyle->GetColorPalette(Int_t(3./max*numcol + 1.)));
700 t3->SetTextAlign(12);
701 TText *t4 = pave->AddText(Form("Low Gain Saturation: %3i pixels",
702 CountBadPixels(&disp24,4)));
703 t4->SetTextColor(gStyle->GetColorPalette(Int_t(4./max*numcol + 1.)));
704 t4->SetTextAlign(12);
705 TText *t5 = pave->AddText(Form("Mean Arr. Time In First Extraction Bin: %3i pixels",
706 CountBadPixels(&disp24,5)));
707 t5->SetTextColor(gStyle->GetColorPalette(Int_t(5./max*numcol + 1.)));
708 t5->SetTextAlign(12);
709 TText *t6 = pave->AddText(Form("Mean Arr. Time In Last 2 Extraction Bins: %3i pixels",
710 CountBadPixels(&disp24,6)));
711 t6->SetTextColor(gStyle->GetColorPalette(Int_t(6./max*numcol + 1.)));
712 t6->SetTextAlign(12);
713 TText *t7 = pave->AddText(Form("Deviating Number of Photo-electrons: %3i pixels",
714 CountBadPixels(&disp24,7)));
715 t7->SetTextColor(gStyle->GetColorPalette(Int_t(7./max*numcol + 1.)));
716 t7->SetTextAlign(12);
717 TText *t8 = pave->AddText(Form("Deviating global F-Factor: %3i pixels",
718 CountBadPixels(&disp24,8)));
719 t8->SetTextColor(gStyle->GetColorPalette(Int_t(8./max*numcol + 1.)));
720 t8->SetTextAlign(12);
721 TText *t9 = pave->AddText(Form("Deviating Number of Photons: %3i pixels",
722 CountBadPixels(&disp24,9)));
723 t9->SetTextColor(gStyle->GetColorPalette(Int_t(9./max*numcol + 1.)));
724 t9->SetTextAlign(12);
725 TText *t10= pave->AddText(Form("Previously Excluded: %3i pixels",
726 CountBadPixels(&disp24,10)));
727 t10->SetTextColor(gStyle->GetColorPalette(Int_t(10./max*numcol + 1.)));
728 t10->SetTextAlign(12);
729 pave->Draw();
730
731 c4.cd(3);
732 gPad->SetBorderMode(0);
733 obj8->Draw();
734 obj8->SetPrettyPalette();
735
736 //
737 // UNRELIABLE PIXELS
738 //
739
740 c4.cd(2);
741 gPad->SetBorderMode(0);
742 gPad->SetTicks();
743 MHCamera *obj9=(MHCamera*)disp25.DrawCopy("hist");
744 //
745 // for the datacheck, fix the ranges!!
746 //
747 const Double_t max2 = 8.;
748 obj9->SetMinimum(0.);
749 obj9->SetMaximum(max2);
750 //
751 // Set the datacheck sizes:
752 //
753 FixDataCheckHist((TH1D*)obj9);
754
755 gStyle->SetPalette(1);
756
757 TPaveText *pave2 = new TPaveText(0.0,0.0,0.99,0.99);
758 pave2->SetBit(kCanDelete);
759 pave2->ConvertNDCtoPad();
760 pave2->SetTextSize(0.05);
761 pave2->AddText(" ");
762 TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted: %3i pixels",
763 CountBadPixels(&disp25,1)));
764 tt1->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol + 1.)));
765 tt1->SetTextAlign(12);
766 TText *tt2 = pave2->AddText(Form("Low Gain Signals could not be fitted: %3i pixels",
767 CountBadPixels(&disp25,2)));
768 tt2->SetTextColor(gStyle->GetColorPalette(Int_t(2./max2*numcol + 1.)));
769 tt2->SetTextAlign(12);
770 TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted: %3i pixels",
771 CountBadPixels(&disp25,3)));
772 tt3->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol + 1.)));
773 tt3->SetTextAlign(12);
774 TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation: %3i pixels",
775 CountBadPixels(&disp25,4)));
776 tt4->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol + 1.)));
777 tt4->SetTextAlign(12);
778 TText *tt5 = pave2->AddText(Form("Low Gain Signals Oscillation: %3i pixels",
779 CountBadPixels(&disp25,5)));
780 tt5->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol + 1.)));
781 tt5->SetTextAlign(12);
782 TText *tt6 = pave2->AddText(Form("Relative Arr. Times Oscillation: %3i pixels",
783 CountBadPixels(&disp25,6)));
784 tt6->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol + 1.)));
785 tt6->SetTextAlign(12);
786 pave2->Draw();
787
788 c4.cd(4);
789 gPad->SetBorderMode(0);
790 obj9->SetPrettyPalette();
791 obj9->Draw();
792
793 if (fRelTimes)
794 {
795 // Rel. Times
796 TCanvas &c5 = fDisplay->AddTab("Rel. Times");
797 c5.Divide(2,4);
798
799 disp30.CamDraw(c5, 1, 2, 2);
800 disp31.CamDraw(c5, 2, 2, 2);
801 }
802
803 return;
804 }
805
806 if (fDisplayType == kNormalDisplay)
807 {
808
809 // Charges
810 TCanvas &c11 = fDisplay->AddTab("Fit.Charge");
811 c11.Divide(2, 4);
812
813 disp1.CamDraw(c11, 1, 2, 5, 1);
814 disp2.CamDraw(c11, 2, 2, 5, 1);
815
816 // Reduced Sigmas
817 TCanvas &c12 = fDisplay->AddTab("Red.Sigma");
818 c12.Divide(2,4);
819
820 disp3.CamDraw(c12, 1, 2, 5, 1);
821 disp4.CamDraw(c12, 2, 2, 5, 1);
822
823 // F-Factor
824 TCanvas &c13 = fDisplay->AddTab("Phe's");
825 c13.Divide(3,4);
826
827 disp5.CamDraw(c13, 1, 3, 5, 1);
828 disp6.CamDraw(c13, 2, 3, 5, 1);
829 disp7.CamDraw(c13, 3, 3, 5, 1);
830
831 // QE's
832 TCanvas &c14 = fDisplay->AddTab("QE's");
833 c14.Divide(4,4);
834
835 disp8.CamDraw(c14, 1, 4, 5, 1);
836 disp9.CamDraw(c14, 2, 4, 5, 1);
837 disp10.CamDraw(c14, 3, 4, 5, 1);
838 disp11.CamDraw(c14, 4, 4, 5, 1);
839
840 // Defects
841 TCanvas &c15 = fDisplay->AddTab("Defect");
842 // c15.Divide(5,2);
843 c15.Divide(4,2);
844
845 /*
846 disp23.CamDraw(c15, 1, 5, 0);
847 disp24.CamDraw(c15, 2, 5, 0);
848 disp25.CamDraw(c15, 3, 5, 0);
849 disp26.CamDraw(c15, 4, 5, 0);
850 disp27.CamDraw(c15, 5, 5, 0);
851 */
852 disp24.CamDraw(c15, 1, 4, 0);
853 disp25.CamDraw(c15, 2, 4, 0);
854 disp26.CamDraw(c15, 3, 4, 0);
855 disp27.CamDraw(c15, 4, 4, 0);
856
857 // Abs. Times
858 TCanvas &c16 = fDisplay->AddTab("Abs. Times");
859 c16.Divide(2,3);
860
861 disp28.CamDraw(c16, 1, 2, 5);
862 disp29.CamDraw(c16, 2, 2, 5);
863
864 if (fRelTimes)
865 {
866 // Rel. Times
867 TCanvas &c17 = fDisplay->AddTab("Rel. Times");
868 c17.Divide(2,4);
869
870 disp30.CamDraw(c17, 1, 2, 5, 1);
871 disp31.CamDraw(c17, 2, 2, 5, 1);
872 }
873
874 return;
875 }
876
877 if (fDisplayType == kFullDisplay)
878 {
879 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationChargeCam");
880
881 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
882 {
883 cam->GetAverageHiGainSector(sector).DrawClone("all");
884 cam->GetAverageLoGainSector(sector).DrawClone("all");
885 }
886
887 // Charges
888 TCanvas &c21 = fDisplay->AddTab("Fit.Charge");
889 c21.Divide(2, 4);
890
891 disp1.CamDraw(c21, 1, 2, 2, 1);
892 disp2.CamDraw(c21, 2, 2, 2, 1);
893
894 // Reduced Sigmas
895 TCanvas &c23 = fDisplay->AddTab("Red.Sigma");
896 c23.Divide(2,4);
897
898 disp3.CamDraw(c23, 1, 2, 2, 1);
899 disp4.CamDraw(c23, 2, 2, 2, 1);
900
901 // F-Factor
902 TCanvas &c24 = fDisplay->AddTab("Phe's");
903 c24.Divide(3,5);
904
905 disp5.CamDraw(c24, 1, 3, 2, 1, 1);
906 disp6.CamDraw(c24, 2, 3, 2, 1, 1);
907 disp7.CamDraw(c24, 3, 3, 2, 1, 1);
908
909 // QE's
910 TCanvas &c25 = fDisplay->AddTab("QE's");
911 c25.Divide(4,5);
912
913 disp8.CamDraw(c25, 1, 4, 2, 1, 1);
914 disp9.CamDraw(c25, 2, 4, 2, 1, 1);
915 disp10.CamDraw(c25, 3, 4, 2, 1, 1);
916 disp11.CamDraw(c25, 4, 4, 2, 1, 1);
917
918 // Validity
919 TCanvas &c26 = fDisplay->AddTab("Valid");
920 c26.Divide(4,2);
921
922 disp12.CamDraw(c26, 1, 4, 0);
923 disp13.CamDraw(c26, 2, 4, 0);
924 disp14.CamDraw(c26, 3, 4, 0);
925 disp15.CamDraw(c26, 4, 4, 0);
926
927 // Other info
928 TCanvas &c27 = fDisplay->AddTab("HiLoGain");
929 c27.Divide(3,3);
930
931 disp16.CamDraw(c27, 1, 3, 0);
932 disp17.CamDraw(c27, 2, 3, 1);
933 disp18.CamDraw(c27, 3, 3, 1);
934
935 // Pickup
936 TCanvas &c28 = fDisplay->AddTab("Pickup");
937 c28.Divide(4,2);
938
939 disp19.CamDraw(c28, 1, 4, 0);
940 disp20.CamDraw(c28, 2, 4, 0);
941 disp21.CamDraw(c28, 3, 4, 0);
942 disp22.CamDraw(c28, 4, 4, 0);
943
944 // Defects
945 TCanvas &c29 = fDisplay->AddTab("Defect");
946 // c29.Divide(5,2);
947 c29.Divide(4,2);
948
949 disp24.CamDraw(c29, 1, 4, 0);
950 disp25.CamDraw(c29, 2, 4, 0);
951 disp26.CamDraw(c29, 3, 4, 0);
952 disp27.CamDraw(c29, 4, 4, 0);
953
954 // Abs. Times
955 TCanvas &c30 = fDisplay->AddTab("Abs. Times");
956 c30.Divide(2,3);
957
958 disp28.CamDraw(c30, 1, 2, 2);
959 disp29.CamDraw(c30, 2, 2, 1);
960
961 if (fRelTimes)
962 {
963 // Rel. Times
964 TCanvas &c31 = fDisplay->AddTab("Rel. Times");
965 c31.Divide(3,5);
966
967 disp30.CamDraw(c31, 1, 3, 2, 1, 1);
968 disp31.CamDraw(c31, 2, 3, 2, 1, 1);
969 disp32.CamDraw(c31, 3, 3, 4, 1, 1);
970
971 // Time Defects
972 TCanvas &c32 = fDisplay->AddTab("Time Def.");
973 c32.Divide(2,2);
974
975 disp33.CamDraw(c32, 1, 2, 0);
976 disp34.CamDraw(c32, 2, 2, 0);
977
978 MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationRelTimeCam");
979
980 for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
981 {
982 cam->GetAverageHiGainSector(sector).DrawClone("fourierevents");
983 cam->GetAverageLoGainSector(sector).DrawClone("fourierevents");
984 }
985
986 }
987
988 return;
989 }
990}
991
992
993void MJCalibration::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
994{
995
996 const MGeomCam *geom = cam->GetGeometry();
997
998 Double_t x = geom->InheritsFrom("MGeomCamMagic") ? 397 : cam->GetNbinsX() ;
999
1000 TLine line;
1001 line.SetLineStyle(kDashed);
1002 line.SetLineWidth(3);
1003 line.SetLineColor(kBlue);
1004
1005 TLine *l1 = NULL;
1006
1007 if (what == 0)
1008 l1 = line.DrawLine(0, fgRefQEInner, x, fgRefQEInner);
1009 else if (what == 1)
1010 l1 = line.DrawLine(0, fgRefConvFADC2PhotInner, x, fgRefConvFADC2PhotInner);
1011 else if (what == 2)
1012 l1 = line.DrawLine(0, fgRefConvFADC2PheInner, x, fgRefConvFADC2PheInner );
1013
1014 if (geom->InheritsFrom("MGeomCamMagic"))
1015 {
1016 const Double_t x2 = cam->GetNbinsX();
1017
1018 switch (what)
1019 {
1020 case 0:
1021 line.DrawLine(x2, fgRefQEOuter, 398, fgRefQEOuter);
1022 break;
1023 case 1:
1024 line.DrawLine(x2, fgRefConvFADC2PhotOuter, 398, fgRefConvFADC2PhotOuter );
1025 break;
1026 case 2:
1027 line.DrawLine(x2, fgRefConvFADC2PheOuter, 398, fgRefConvFADC2PheOuter);
1028 break;
1029 }
1030 }
1031
1032 TLegend *leg = new TLegend(what ? 0.2 : 0.6,0.75,what ? 0.5 : 0.9 ,0.85);
1033 leg->SetBit(kCanDelete);
1034 leg->AddEntry(l1, "Reference","l");
1035 leg->Draw();
1036}
1037
1038void MJCalibration::DisplayOutliers(TH1D *hist, const char* whatsmall, const char* whatbig) const
1039{
1040
1041 const Float_t mean = hist->GetFunction("gaus")->GetParameter(1);
1042 const Float_t lolim = mean - 4.0*hist->GetFunction("gaus")->GetParameter(2);
1043 const Float_t uplim = mean + 4.0*hist->GetFunction("gaus")->GetParameter(2);
1044 const Stat_t dead = hist->Integral(0,hist->FindBin(lolim)-1);
1045 const Stat_t noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
1046
1047 const Double_t max = hist->GetBinContent(hist->GetMaximumBin());
1048
1049 const Double_t minl = hist->GetBinCenter(hist->GetXaxis()->GetFirst());
1050 const Double_t maxl = hist->GetBinCenter(hist->GetXaxis()->GetLast());
1051
1052 TLatex deadtex;
1053 deadtex.SetTextSize(0.06);
1054 deadtex.DrawLatex(minl+0.1*(maxl-minl),max/1.1,
1055 Form("%3i %s pixels",(Int_t)dead,whatsmall));
1056
1057 TLatex noisytex;
1058 noisytex.SetTextSize(0.06);
1059 noisytex.DrawLatex(minl+0.1*(maxl-minl),max/1.2,
1060 Form("%3i %s pixels",(Int_t)noisy,whatbig));
1061
1062}
1063
1064void MJCalibration::FixDataCheckHist(TH1D *hist) const
1065{
1066
1067 hist->SetDirectory(NULL);
1068
1069 //
1070 // set the labels bigger
1071 //
1072 TAxis *xaxe = hist->GetXaxis();
1073 TAxis *yaxe = hist->GetYaxis();
1074
1075 xaxe->CenterTitle();
1076 yaxe->CenterTitle();
1077 xaxe->SetTitleSize(0.06);
1078 yaxe->SetTitleSize(0.06);
1079 xaxe->SetTitleOffset(0.8);
1080 yaxe->SetTitleOffset(0.85);
1081 xaxe->SetLabelSize(0.05);
1082 yaxe->SetLabelSize(0.05);
1083
1084}
1085
1086const Int_t MJCalibration::CountBadPixels ( MHCamera *cam , const Int_t what ) const
1087{
1088
1089 Int_t cnt = 0;
1090
1091 for (UInt_t pix=0; pix<cam->GetNumPixels();pix++)
1092 if ((Int_t)cam->GetPixContent(pix) == what)
1093 cnt++;
1094
1095 return cnt;
1096}
1097
1098
1099// --------------------------------------------------------------------------
1100//
1101// Find the colour of the pulsing LED:
1102// - If the run number is smaller than gkIFAEBoxInaugurationRun, take MCalibrationCam::kCT1
1103// - Otherwise find the colour out of the run name
1104// - If no colour is found, return kFALSE
1105//
1106Bool_t MJCalibration::FindColor()
1107{
1108
1109 if (fSequence)
1110 {
1111 fColor = MCalibrationCam::kCT1;
1112 return kTRUE;
1113 }
1114
1115 const UInt_t nruns = fRuns->GetNumRuns();
1116
1117 if (nruns == 0)
1118 return kFALSE;
1119
1120 TArrayI arr = fRuns->GetRuns();
1121
1122 if (arr[nruns-1] < gkIFAEBoxInaugurationRun)
1123 {
1124 *fLog << "Found colour kCT1 in runs: " << fRuns->GetRunsAsString() << endl;
1125 fColor = MCalibrationCam::kCT1;
1126 return kTRUE;
1127 }
1128
1129 TString filenames;
1130 ((MDirIter*)fRuns)->Reset();
1131
1132 while (!(filenames=((MDirIter*)fRuns)->Next()).IsNull())
1133 {
1134
1135 filenames.ToLower();
1136
1137 //
1138 // Here starts the list of runs where the shifters did not put
1139 // a colour, but which have been found out by other means.
1140 // FIXME: This list has is only preliminary and has to move into the
1141 // database!!
1142 //
1143 if (filenames.Contains("_30090_"))
1144 if (fColor == MCalibrationCam::kNONE)
1145 {
1146 *fLog << "Found colour: kGREEN in " << filenames << endl;
1147 fColor = MCalibrationCam::kGREEN;
1148 }
1149 else if (fColor != MCalibrationCam::kNONE)
1150 {
1151 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1152 return kFALSE;
1153 }
1154
1155 if (filenames.Contains("_27474_"))
1156 if (fColor == MCalibrationCam::kNONE)
1157 {
1158 *fLog << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! "
1159 << "Selected runs were: " << filenames << endl;
1160 fColor = MCalibrationCam::kNONE;
1161 return kFALSE;
1162 }
1163 else if (fColor != MCalibrationCam::kNONE)
1164 {
1165 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1166 return kFALSE;
1167 }
1168
1169 if (filenames.Contains("_26924_"))
1170 if (fColor == MCalibrationCam::kNONE)
1171 {
1172 *fLog << "Found colour: kGREEN in " << filenames << endl;
1173 fColor = MCalibrationCam::kGREEN;
1174 }
1175 else if (fColor != MCalibrationCam::kGREEN)
1176 {
1177 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1178 return kFALSE;
1179 }
1180
1181
1182 if (filenames.Contains("_26568_"))
1183 if (fColor == MCalibrationCam::kNONE)
1184 {
1185 *fLog << "Found colour: kGREEN in " << filenames << endl;
1186 fColor = MCalibrationCam::kGREEN;
1187 }
1188 else if (fColor != MCalibrationCam::kGREEN)
1189 {
1190 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1191 return kFALSE;
1192 }
1193
1194 if (filenames.Contains("_26412_"))
1195 if (fColor == MCalibrationCam::kNONE)
1196 {
1197 *fLog << "Found colour: kGREEN in " << filenames << endl;
1198 fColor = MCalibrationCam::kGREEN;
1199 }
1200 else if (fColor != MCalibrationCam::kGREEN)
1201 {
1202 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1203 return kFALSE;
1204 }
1205
1206
1207 if (filenames.Contains("_26409_"))
1208 if (fColor == MCalibrationCam::kNONE)
1209 {
1210 *fLog << "Found colour: kGREEN in " << filenames << endl;
1211 fColor = MCalibrationCam::kGREEN;
1212 }
1213 else if (fColor != MCalibrationCam::kGREEN)
1214 {
1215 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1216 return kFALSE;
1217 }
1218
1219 if (filenames.Contains("_26408_"))
1220 if (fColor == MCalibrationCam::kNONE)
1221 {
1222 *fLog << "Found colour: kGREEN in " << filenames << endl;
1223 fColor = MCalibrationCam::kGREEN;
1224 }
1225 else if (fColor != MCalibrationCam::kGREEN)
1226 {
1227 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1228 return kFALSE;
1229 }
1230
1231
1232 if (filenames.Contains("_26402_"))
1233 if (fColor == MCalibrationCam::kNONE)
1234 {
1235 *fLog << "Found colour: kBLUE in " << filenames << endl;
1236 fColor = MCalibrationCam::kBLUE;
1237 }
1238 else if (fColor != MCalibrationCam::kBLUE)
1239 {
1240 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1241 return kFALSE;
1242 }
1243
1244 if (filenames.Contains("_20661_"))
1245 if (fColor == MCalibrationCam::kNONE)
1246 {
1247 *fLog << "Found colour: kGREEN in " << filenames << endl;
1248 fColor = MCalibrationCam::kGREEN;
1249 }
1250 else if (fColor != MCalibrationCam::kGREEN)
1251 {
1252 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1253 return kFALSE;
1254 }
1255
1256 if (filenames.Contains("_20660_"))
1257 if (fColor == MCalibrationCam::kNONE)
1258 {
1259 *fLog << "Found colour: kGREEN in " << filenames << endl;
1260 fColor = MCalibrationCam::kGREEN;
1261 }
1262 else if (fColor != MCalibrationCam::kGREEN)
1263 {
1264 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1265 return kFALSE;
1266 }
1267
1268 //
1269 // Here start the runs where the shifter put
1270 // the colour.
1271 //
1272 if (filenames.Contains("green"))
1273 if (fColor == MCalibrationCam::kNONE)
1274 {
1275 *fLog << "Found colour: kGREEN in " << filenames << endl;
1276 fColor = MCalibrationCam::kGREEN;
1277 }
1278 else if (fColor != MCalibrationCam::kGREEN)
1279 {
1280 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1281 return kFALSE;
1282 }
1283
1284 if (filenames.Contains("blue"))
1285 if (fColor == MCalibrationCam::kNONE)
1286 {
1287 *fLog << "Found colour: kBLUE in " << filenames << endl;
1288 fColor = MCalibrationCam::kBLUE;
1289 }
1290 else if (fColor != MCalibrationCam::kBLUE)
1291 {
1292 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1293 return kFALSE;
1294 }
1295
1296 if (filenames.Contains("uv"))
1297 if (fColor == MCalibrationCam::kNONE)
1298 {
1299 *fLog << "Found colour: kUV in " << filenames << endl;
1300 fColor = MCalibrationCam::kUV;
1301 }
1302 else if (fColor != MCalibrationCam::kUV)
1303 {
1304 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1305 return kFALSE;
1306 }
1307
1308 if (filenames.Contains("ct1"))
1309 if (fColor == MCalibrationCam::kNONE)
1310 {
1311 *fLog << "Found colour: kCT1 in " << filenames << endl;
1312 fColor = MCalibrationCam::kCT1;
1313 }
1314 else if (fColor != MCalibrationCam::kCT1)
1315 {
1316 *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
1317 return kFALSE;
1318 }
1319
1320 }
1321
1322 if (fColor == MCalibrationCam::kNONE)
1323 {
1324 *fLog << "No colour found in filenames of runs: " << fRuns->GetRunsAsString()
1325 << "... abort" << endl;
1326 return kFALSE;
1327 }
1328
1329
1330 return kTRUE;
1331}
1332
1333// --------------------------------------------------------------------------
1334//
1335// Retrieve the output file written by WriteResult()
1336//
1337const char* MJCalibration::GetOutputFile() const
1338{
1339 if (fSequence)
1340 return Form("%s/calib%06d.root", (const char*)fOutputPath, fSequence->GetSequence());
1341 if (!fRuns)
1342 return "";
1343
1344 return Form("%s/%s-F1.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
1345}
1346
1347Bool_t MJCalibration::IsUseBlindPixel() const
1348{
1349 return TESTBIT(fDevices,kUseBlindPixel);
1350}
1351
1352Bool_t MJCalibration::IsUsePINDiode() const
1353{
1354 return TESTBIT(fDevices,kUsePINDiode);
1355}
1356
1357void MJCalibration::SetEnv(const char *env)
1358{
1359 if (fEnv)
1360 delete fEnv;
1361 fEnv = new TEnv(env);
1362}
1363
1364void MJCalibration::CheckEnv()
1365{
1366 if (!fEnv)
1367 return;
1368
1369 TString e1 = fEnv->GetValue("MJCalibration.OutputPath", "");
1370 if (!e1.IsNull())
1371 {
1372 e1.ReplaceAll("\015", "");
1373 SetOutputPath(e1);
1374 }
1375
1376 TString col = fEnv->GetValue("MJCalibration.Color", "");
1377 if (!col.IsNull())
1378 {
1379 }
1380
1381 TString dis = fEnv->GetValue("MJCalibration.Display", "");
1382 if (dis.BeginsWith("Full", TString::kIgnoreCase))
1383 SetFullDisplay();
1384 if (dis.BeginsWith("DataCheck", TString::kIgnoreCase))
1385 SetDataCheckDisplay();
1386 if (dis.BeginsWith("Normal", TString::kIgnoreCase))
1387 SetNormalDisplay();
1388
1389 SetRelTimeCalibration(fEnv->GetValue("MJCalibration.RelTimeCalibration", fRelTimes));
1390 SetDataCheck(fEnv->GetValue("MJCalibration.Datacheck", fDataCheck));
1391 SetDebug(fEnv->GetValue("MJCalibration.Debug", fDebug));
1392 SetUseBlindPixel(fEnv->GetValue("MJCalibration.UseBlindPixel", IsUseBlindPixel()));
1393 SetUsePINDiode(fEnv->GetValue("MJCalibration.UsePINDiode", IsUsePINDiode()));
1394}
1395
1396// --------------------------------------------------------------------------
1397//
1398// Call the ProcessFile(MPedestalCam)
1399//
1400Bool_t MJCalibration::Process(MPedestalCam &pedcam)
1401{
1402 if (!ReadCalibrationCam())
1403 return ProcessFile(pedcam);
1404
1405 return kTRUE;
1406}
1407
1408void MJCalibration::InitBlindPixel(MExtractBlindPixel &blindext,
1409 MHCalibrationChargeBlindCam &blindcam)
1410{
1411
1412 Int_t run = fSequence ? fSequence->GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
1413
1414 //
1415 // Initialize the blind pixel. Unfortunately, there is a hardware difference
1416 // in the first blind pixel until run "gkSecondBlindPixelInstallation" and the
1417 // later setup. The first needs to use a filter because of the length of
1418 // spurious NSB photon signals. The latter get better along extracting the amplitude
1419 // from a small window.
1420 //
1421 if (run < gkSecondBlindPixelInstallation)
1422 {
1423 blindext.SetModified(kFALSE);
1424 blindext.SetExtractionType(MExtractBlindPixel::kIntegral);
1425 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1426 blindext.SetRange(10,19,0,6);
1427 blindext.SetNSBFilterLimit(70);
1428 blindcam.SetFitFunc( MHCalibrationChargeBlindPix::kEPoisson5 );
1429 }
1430 else
1431 {
1432 blindext.SetModified(kTRUE);
1433 blindext.SetExtractionType(MExtractBlindPixel::kAmplitude);
1434 blindext.SetExtractionType(MExtractBlindPixel::kFilter);
1435 blindext.SetRange(5,8,0,2);
1436 blindext.SetNSBFilterLimit(38);
1437
1438 if (run < gkThirdBlindPixelInstallation)
1439 blindext.SetNumBlindPixels(2);
1440 else
1441 blindext.SetNumBlindPixels(3);
1442 }
1443}
1444
1445// --------------------------------------------------------------------------
1446//
1447// Execute the task list and the eventloop:
1448//
1449// - Check if there are fRuns, otherwise return
1450// - Check the colour of the files in fRuns (FindColor()), otherwise return
1451// - Check for consistency between run numbers and number of files
1452// - Add fRuns to MReadMarsFile
1453// - Put into MParList:
1454// 1) MPedestalCam (pedcam)
1455// 2) MCalibrationQECam (fQECam)
1456// 3) MCalibrationChargeCam (fCalibrationCam)
1457// 4) MCalibrationRelTimeCam (fRelTimeCam) (only if flag fRelTimes is chosen)
1458// 5) MBadPixelsCam (fBadPixels)
1459// 6) MCalibrationChargePINDiode
1460// 7) MCalibrationChargeBlindPix
1461// - Put into the MTaskList:
1462// 1) MReadMarsFile
1463// 2) MBadPixelsMerge
1464// 3) MGeomApply
1465// 4) MExtractor
1466// 5) MExtractPINDiode
1467// 6) MExtractBlindPixel
1468// 7) MExtractTime (only if flag fRelTimes is chosen)
1469// 8) MContinue(MFCosmics)
1470// 9) MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode")
1471// 10) MFillH("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel")
1472// 11) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam")
1473// 12) MFillH("MHCalibrationChargeCam", "MExtractedSignalCam")
1474// 13) MCalibrationChargeCalc
1475// 14) MFillH("MHCalibrationRelTimeCam", "MArrivalTimeCam") (only if flag fRelTimes is chosen)
1476// 15) MCalibrationRelTimeCalc
1477// - Execute MEvtLoop
1478// - DisplayResult()
1479// - WriteResult()
1480//
1481Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
1482{
1483 if (!fRuns && !fSequence)
1484 {
1485 *fLog << err << "No Runs choosen... abort." << endl;
1486 return kFALSE;
1487 }
1488
1489 if (!fSequence && fRuns->GetNumRuns() != fRuns->GetNumEntries())
1490 {
1491 *fLog << err << "Number of files found doesn't match number of runs... abort."
1492 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
1493 return kFALSE;
1494 }
1495
1496 *fLog << inf;
1497 fLog->Separator(GetDescriptor());
1498
1499 if (!FindColor())
1500 return kFALSE;
1501
1502 *fLog << "Calculate MCalibrationCam from ";
1503 if (fSequence)
1504 *fLog << "Sequence #" << fSequence->GetSequence() << endl;
1505 else
1506 *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
1507 *fLog << endl;
1508
1509 CheckEnv();
1510
1511 // Setup Tasklist
1512 MParList plist;
1513 MTaskList tlist;
1514 plist.AddToList(&tlist);
1515
1516 MReadMarsFile read("Events");
1517 MRawFileRead rawread(NULL);
1518
1519 MDirIter iter;
1520 if (fSequence)
1521 fSequence->SetupCalRuns(iter);
1522
1523 if (fDataCheck)
1524 {
1525 rawread.AddFiles(fSequence ? iter : *fRuns);
1526 tlist.AddToList(&rawread);
1527 }
1528 else
1529 {
1530 read.DisableAutoScheme();
1531 static_cast<MRead&>(read).AddFiles(fSequence ? iter : *fRuns);
1532 tlist.AddToList(&read);
1533 }
1534
1535 MHCalibrationChargeCam chargecam;
1536 MHCalibrationChargeBlindCam blindcam;
1537
1538 plist.AddToList(&pedcam);
1539 plist.AddToList(&chargecam);
1540 plist.AddToList(&blindcam);
1541 plist.AddToList(&fBadPixels);
1542 plist.AddToList(&fQECam);
1543 plist.AddToList(&fCalibrationCam);
1544 plist.AddToList(&fCalibrationBlindCam);
1545 plist.AddToList(&fCalibrationPINDiode);
1546 plist.AddToList(&fRelTimeCam);
1547
1548 MGeomApply apply;
1549 MBadPixelsMerge merge(&fBadPixels);
1550 MExtractPINDiode pinext;
1551 MExtractBlindPixel blindext;
1552 InitBlindPixel(blindext, blindcam);
1553 MExtractSlidingWindow extract2;
1554 MExtractTimeFastSpline timespline;
1555 MCalibrationChargeCalc calcalc;
1556 MCalibrationRelTimeCalc timecalc;
1557
1558 if (!fSequence)
1559 {
1560 calcalc.SetOutputPath(fOutputPath);
1561 calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
1562 }
1563
1564 if (fDebug)
1565 {
1566 chargecam.SetDebug();
1567 calcalc.SetDebug();
1568 }
1569
1570 //
1571 // As long as there are no DM's, have to colour by hand
1572 //
1573 chargecam.SetColor (fColor);
1574 calcalc.SetPulserColor(fColor);
1575
1576 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
1577 MFillH fillbnd("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
1578 MFillH fillcam("MHCalibrationChargeCam", "MExtractedSignalCam");
1579 MFillH filltme("MHCalibrationRelTimeCam", "MArrivalTimeCam");
1580 fillpin.SetNameTab("PINDiode");
1581 fillbnd.SetNameTab("BlindPix");
1582 fillcam.SetNameTab("Charge");
1583 filltme.SetNameTab("RelTimes");
1584
1585 TString drawoption;
1586
1587 if (fDisplayType == kDataCheckDisplay)
1588 drawoption += "datacheck";
1589 if (fDisplayType == kFullDisplay)
1590 drawoption += " all";
1591
1592 fillcam.SetDrawOption(drawoption.Data());
1593 fillbnd.SetDrawOption(drawoption.Data());
1594 fillpin.SetDrawOption(drawoption.Data());
1595 filltme.SetDrawOption(drawoption.Data());
1596
1597 //
1598 // Apply a filter against cosmics
1599 // (will have to be needed in the future
1600 // when the calibration hardware-trigger is working)
1601 //
1602 MFCosmics cosmics;
1603 MContinue cont(&cosmics);
1604
1605 tlist.AddToList(&merge);
1606 tlist.AddToList(&apply);
1607
1608 MTaskEnv taskenv("ExtractSignal");
1609 taskenv.SetDefault(fExtractor ? fExtractor : &extract2);
1610
1611 tlist.AddToList(&taskenv);
1612 tlist.AddToList(&pinext);
1613 tlist.AddToList(&blindext);
1614
1615 MTaskEnv taskenv2("ExtractTime");
1616 taskenv2.SetDefault(fTimeExtractor ? fTimeExtractor : &timespline);
1617
1618 if (fRelTimes)
1619 tlist.AddToList(&taskenv2);
1620
1621 if (fColor == MCalibrationCam::kCT1)
1622 tlist.AddToList(&cont);
1623
1624 tlist.AddToList(&fillcam);
1625
1626 if (fRelTimes)
1627 {
1628 tlist.AddToList(&filltme);
1629 tlist.AddToList(&timecalc);
1630 }
1631
1632 if (IsUseBlindPixel())
1633 tlist.AddToList(&fillbnd);
1634 if (IsUsePINDiode())
1635 tlist.AddToList(&fillpin);
1636
1637 tlist.AddToList(&calcalc);
1638
1639 // Create and setup the eventloop
1640 MEvtLoop evtloop(fName);
1641 evtloop.SetParList(&plist);
1642 evtloop.SetDisplay(fDisplay);
1643 evtloop.SetLogStream(fLog);
1644 if (fEnv)
1645 evtloop.ReadEnv(*fEnv);
1646
1647 // Execute first analysis
1648 if (!evtloop.Eventloop())
1649 {
1650 *fLog << err << GetDescriptor() << ": Failed." << endl;
1651 return kFALSE;
1652 }
1653
1654 tlist.PrintStatistics();
1655
1656 //
1657 // The next lines are necessary in order to avoid that
1658 // the last entry drawn by MFillH gets deleted again from
1659 // the display. No idea where this comes from...
1660 //
1661 if (fDisplay)
1662 {
1663 if (IsUsePINDiode())
1664 {
1665 MHCalibrationChargePINDiode *pin =
1666 (MHCalibrationChargePINDiode*)plist.FindObject("MHCalibrationChargePINDiode");
1667 pin->DrawClone(Form("nonew %s",drawoption.Data()));
1668 }
1669 else if (IsUseBlindPixel())
1670 {
1671 MHCalibrationChargeBlindCam *cam =
1672 (MHCalibrationChargeBlindCam*)plist.FindObject("MHCalibrationChargeBlindCam");
1673 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1674 }
1675 else if (fRelTimes)
1676 {
1677 MHCalibrationRelTimeCam *cam =
1678 (MHCalibrationRelTimeCam*)plist.FindObject("MHCalibrationRelTimeCam");
1679 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1680 }
1681 else
1682 {
1683 MHCalibrationChargeCam *cam =
1684 (MHCalibrationChargeCam*)plist.FindObject("MHCalibrationChargeCam");
1685 cam->DrawClone(Form("nonew %s",drawoption.Data()));
1686 }
1687 }
1688
1689 DisplayResult(plist);
1690
1691 if (!WriteResult())
1692 return kFALSE;
1693
1694 *fLog << inf << GetDescriptor() << ": Done." << endl;
1695
1696 return kTRUE;
1697}
1698
1699// --------------------------------------------------------------------------
1700//
1701// Read the following containers from GetOutputFile()
1702// - MCalibrationChargeCam
1703// - MCalibrationQECam
1704// - MBadPixelsCam
1705//
1706Bool_t MJCalibration::ReadCalibrationCam()
1707{
1708 const TString fname = GetOutputFile();
1709
1710 if (gSystem->AccessPathName(fname, kFileExists))
1711 {
1712 *fLog << err << "Input file " << fname << " doesn't exist." << endl;
1713 return kFALSE;
1714 }
1715
1716 *fLog << inf << "Reading from file: " << fname << endl;
1717
1718 TFile file(fname, "READ");
1719 if (fCalibrationCam.Read()<=0)
1720 {
1721 *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
1722 return kFALSE;
1723 }
1724
1725 if (fQECam.Read()<=0)
1726 {
1727 *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
1728 return kFALSE;
1729 }
1730
1731
1732 if (file.FindKey("MCalibrationRelTimeCam"))
1733 if (fRelTimeCam.Read()<=0)
1734 {
1735 *fLog << err << "Unable to read MCalibrationRelTimeCam from " << fname << endl;
1736 return kFALSE;
1737 }
1738
1739 if (file.FindKey("MBadPixelsCam"))
1740 {
1741 MBadPixelsCam bad;
1742 if (bad.Read()<=0)
1743 {
1744 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
1745 return kFALSE;
1746 }
1747 fBadPixels.Merge(bad);
1748 }
1749
1750 if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
1751 fDisplay->Read();
1752
1753 return kTRUE;
1754}
1755
1756
1757// --------------------------------------------------------------------------
1758//
1759// Set the path for output files, written by WriteResult()
1760//
1761void MJCalibration::SetOutputPath(const char *path)
1762{
1763 fOutputPath = path;
1764 if (fOutputPath.EndsWith("/"))
1765 fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
1766}
1767
1768// --------------------------------------------------------------------------
1769//
1770// Set the useage of the Blind Pixel device
1771//
1772void MJCalibration::SetUseBlindPixel(const Bool_t b)
1773{
1774 b ? SETBIT(fDevices,kUseBlindPixel) : CLRBIT(fDevices,kUseBlindPixel);
1775}
1776
1777// --------------------------------------------------------------------------
1778//
1779// Set the useage of the PIN Diode device
1780//
1781void MJCalibration::SetUsePINDiode(const Bool_t b)
1782{
1783 b ? SETBIT(fDevices,kUsePINDiode) : CLRBIT(fDevices,kUsePINDiode);
1784}
1785
1786// --------------------------------------------------------------------------
1787//
1788// Write the result into the output file GetOutputFile(), if fOutputPath exists.
1789//
1790// The following containers are written:
1791// - MStatusDisplay
1792// - MCalibrationChargeCam
1793// - MCalibrationChargeBlindPix
1794// - MCalibrationQECam
1795// - MBadPixelsCam
1796//
1797Bool_t MJCalibration::WriteResult()
1798{
1799 if (fOutputPath.IsNull())
1800 return kTRUE;
1801
1802 const TString oname(GetOutputFile());
1803
1804 *fLog << inf << "Writing to file: " << oname << endl;
1805
1806 TFile file(oname, "UPDATE");
1807
1808 *fLog << inf << " - MStatusDisplay..." << flush;
1809 if (fDisplay && fDisplay->Write()<=0)
1810 {
1811 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
1812 return kFALSE;
1813 }
1814 *fLog << inf << "ok." << endl;
1815
1816 *fLog << inf << " - MCalibrationChargeCam..." << flush;
1817 if (fCalibrationCam.Write()<=0)
1818 {
1819 *fLog << err << "Unable to write MCalibrationChargeCam to " << oname << endl;
1820 return kFALSE;
1821 }
1822 *fLog << inf << "ok." << endl;
1823
1824 *fLog << inf << " - MCalibrationChargeBlindCam..." << flush;
1825 if (fCalibrationBlindCam.Write()<=0)
1826 {
1827 *fLog << err << "Unable to write MCalibrationChargeBlindCam to " << oname << endl;
1828 return kFALSE;
1829 }
1830 *fLog << inf << "ok." << endl;
1831
1832 *fLog << inf << " - MCalibrationChargePINDiode..." << flush;
1833 if (fCalibrationPINDiode.Write()<=0)
1834 {
1835 *fLog << err << "Unable to write MCalibrationChargePINDiode to " << oname << endl;
1836 return kFALSE;
1837 }
1838 *fLog << inf << "ok." << endl;
1839
1840 *fLog << inf << " - MCalibrationQECam..." << flush;
1841 if (fQECam.Write()<=0)
1842 {
1843 *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
1844 return kFALSE;
1845 }
1846 *fLog << inf << "ok." << endl;
1847
1848 *fLog << inf << " - MBadPixelsCam..." << flush;
1849 if (fBadPixels.Write()<=0)
1850 {
1851 *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
1852 return kFALSE;
1853 }
1854 *fLog << inf << "ok." << endl;
1855
1856 if (fRelTimes)
1857 {
1858 *fLog << inf << " - MCalibrationRelTimeCam..." << flush;
1859 if (fRelTimeCam.Write()<=0)
1860 {
1861 *fLog << err << "Unable to write MCalibrationRelTimeCam to " << oname << endl;
1862 return kFALSE;
1863 }
1864 *fLog << inf << "ok." << endl;
1865 }
1866
1867 return kTRUE;
1868
1869}
1870
1871void MJCalibration::DisplayDoubleProject(MHCamera *cam, const char* whatsmall, const char* whatbig) const
1872{
1873
1874 TArrayI inner(1);
1875 inner[0] = 0;
1876
1877 TArrayI outer(1);
1878 outer[0] = 1;
1879
1880 TArrayI s0(6);
1881 s0[0] = 6;
1882 s0[1] = 1;
1883 s0[2] = 2;
1884 s0[3] = 3;
1885 s0[4] = 4;
1886 s0[5] = 5;
1887
1888 TArrayI s1(3);
1889 s1[0] = 6;
1890 s1[1] = 1;
1891 s1[2] = 2;
1892
1893 TArrayI s2(3);
1894 s2[0] = 3;
1895 s2[1] = 4;
1896 s2[2] = 5;
1897
1898 TVirtualPad *pad = gPad;
1899 pad->Divide(2,1);
1900
1901 TH1D *inout[2];
1902 inout[0] = cam->ProjectionS(s0, inner, "Inner");
1903 inout[1] = cam->ProjectionS(s0, outer, "Outer");
1904 FixDataCheckHist(inout[0]);
1905 FixDataCheckHist(inout[1]);
1906
1907 inout[0]->SetTitle(Form("%s %s",cam->GetTitle(),"Inner"));
1908 inout[1]->SetTitle(Form("%s %s",cam->GetTitle(),"Outer"));
1909
1910 for (int i=0; i<2; i++)
1911 {
1912 pad->cd(i+1);
1913 gPad->SetBorderMode(0);
1914 gPad->SetTicks();
1915
1916 inout[i]->SetDirectory(NULL);
1917 inout[i]->SetLineColor(kRed+i);
1918 inout[i]->SetBit(kCanDelete);
1919 inout[i]->Draw();
1920 inout[i]->Fit("gaus", "Q");
1921
1922 TLegend *leg2 = new TLegend(0.6,0.5,0.9,0.7);
1923 //
1924 // Display the outliers as dead and noisy pixels
1925 //
1926 DisplayOutliers(inout[i],whatsmall,whatbig);
1927
1928 //
1929 // Display the two half of the camera separately
1930 //
1931 TH1D *half[2];
1932 half[0] = cam->ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
1933 half[1] = cam->ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
1934
1935 for (int j=0; j<2; j++)
1936 {
1937 half[j]->SetLineColor(kRed+i+2*j+1);
1938 half[j]->SetDirectory(NULL);
1939 half[j]->SetBit(kCanDelete);
1940 half[j]->Draw("same");
1941 leg2->AddEntry(half[j], half[j]->GetName(), "l");
1942 }
1943 leg2->Draw();
1944 }
1945}
Note: See TracBrowser for help on using the repository browser.