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

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