source: trunk/MagicSoft/Mars/macros/calibration.C@ 3273

Last change on this file since 3273 was 3265, checked in by gaug, 21 years ago
*** empty log message ***
File size: 24.5 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25//const TString pedfile = "../20040215_16770_P_OffCrab4_E.root";
26//const TString calfile = "../20040215_16771_C_OffCrab4_E.root";
27
28//const TString pedfile = "/mnt/users/mdoro/Mars/Data/20040201_14418_P_OffMrk421-1_E.root";
29//const TString calfile = "/mnt/users/mdoro/Mars/Data/20040201_1441*_C_OffMrk421-1_E.root";
30
31//const TString pedfile = "/mnt/Data/rootdata/CrabNebula/2004_02_10/20040210_14607_P_CrabNebula_E.root";
32//const TString calfile = "/mnt/Data/rootdata/CrabNebula/2004_02_10/20040210_14608_C_CrabNebula_E.root";
33
34//const TString pedfile = "/mnt/Data/rootdata/CrabNebula/2004_01_26/20040125_10412_P_Crab-On_E.root";
35//const TString calfile = "/mnt/Data/rootdata/CrabNebula/2004_01_26/20040125_1041*_C_Crab-On_E.root";
36
37//const TString pedfile = "/mnt/Data/rootdata/Miscellaneous/2003_12_19/20031218_03522_P_Park_E.root";
38//const TString calfile = "/mnt/Data/rootdata/Miscellaneous/2003_12_19/20031218_03527_C_Park_E.root";
39
40void calibration(TString pedname=pedfile,
41 TString calname=calfile)
42{
43
44 gStyle->SetOptStat(1111);
45 gStyle->SetOptFit();
46
47 MStatusDisplay *display = new MStatusDisplay;
48 display->SetUpdateTime(500);
49 display->Resize(850,700);
50
51 //
52 // Create a empty Parameter List and an empty Task List
53 // The tasklist is identified in the eventloop by its name
54 //
55 MParList plist;
56
57 MTaskList tlist;
58 plist.AddToList(&tlist);
59
60 //
61 // Now setup the tasks and tasklist for the pedestals:
62 // ---------------------------------------------------
63 //
64
65 MReadMarsFile read("Events", pedname);
66 read.DisableAutoScheme();
67
68 MGeomApply geomapl;
69 MExtractSignal sigcalc;
70
71 //
72 // Set the extraction range higher:
73 //
74 //sigcalc.SetRange(1,14,1,14);
75
76 MPedCalcPedRun pedcalc;
77
78 //
79 // Additionally to calculating the pedestals,
80 // you can fill histograms and look at them
81 //
82 MFillH fill("MHPedestalCam", "MExtractedSignalCam");
83
84 tlist.AddToList(&read);
85 tlist.AddToList(&geomapl);
86 tlist.AddToList(&sigcalc);
87 tlist.AddToList(&pedcalc);
88 tlist.AddToList(&fill);
89
90 MGeomCamMagic geomcam;
91 MPedestalCam pedcam;
92 MHPedestalCam hpedcam;
93 plist.AddToList(&geomcam);
94 plist.AddToList(&pedcam);
95 plist.AddToList(&hpedcam);
96
97 //
98 // Create and setup the eventloop
99 //
100 MEvtLoop evtloop;
101 evtloop.SetParList(&plist);
102 evtloop.SetDisplay(display);
103
104 //
105 // Execute first analysis
106 //
107 if (!evtloop.Eventloop())
108 return;
109
110 tlist.PrintStatistics();
111
112 //
113 // Look at one specific pixel, after all the histogram manipulations:
114 //
115// hpedcam[9].DrawClone("fourierevents");
116
117
118 MHCamera dispped0 (geomcam, "Ped;Pedestal", "Mean per Slice");
119 MHCamera dispped1 (geomcam, "Ped;PedestalErr", "Mean Error per Slice");
120 MHCamera dispped2 (geomcam, "Ped;PedestalRms", "RMS per Slice");
121 MHCamera dispped3 (geomcam, "Ped;PedestalRmsErr", "RMS Error per Slice");
122
123 MHCamera dispped4 (geomcam, "Ped;Mean", "Fitted Mean per Slice");
124 MHCamera dispped5 (geomcam, "Ped;MeanErr", "Fitted Error of Mean per Slice");
125 MHCamera dispped6 (geomcam, "Ped;Sigma", "Fitted Sigma per Slice");
126 MHCamera dispped7 (geomcam, "Ped;SigmaErr", "Fitted Error of Sigma per Slice");
127 MHCamera dispped8 (geomcam, "Ped;Prob", "Probability of Fit");
128 MHCamera dispped9 (geomcam, "Ped;DeltaPedestalMean", "Rel. Diff. Mean per Slice (Calc.-Fitte)");
129 MHCamera dispped10 (geomcam, "Ped;DeltaPedestalMeanError", "Rel. Diff. Mean Error per Slice (Calc.-Fitted)");
130 MHCamera dispped11 (geomcam, "Ped;DeltaRmsSigma", "Rel. Diff. RMS per Slice (Calc.-Fitted)");
131 MHCamera dispped12 (geomcam, "Ped;DeltaRmsSigmaError", "Rel. Diff. RMS Error per Slice (Calc.-Fitted)");
132 MHCamera dispped13 (geomcam, "Ped;FitOK", "Gaus Fit not OK");
133 MHCamera dispped14 (geomcam, "Ped;FourierOK", "Fourier Analysis not OK");
134
135 dispped0.SetCamContent( pedcam, 0);
136 dispped0.SetCamError( pedcam, 1);
137 dispped1.SetCamContent( pedcam, 1);
138 dispped2.SetCamContent( pedcam, 2);
139 dispped2.SetCamError( pedcam, 3);
140 dispped3.SetCamContent( pedcam, 3);
141
142 dispped4.SetCamContent( hpedcam, 0);
143 dispped4.SetCamError( hpedcam, 1);
144 dispped5.SetCamContent( hpedcam, 1);
145 dispped6.SetCamContent( hpedcam, 2);
146 dispped6.SetCamError( hpedcam, 3);
147 dispped7.SetCamContent( hpedcam, 3);
148 dispped8.SetCamContent( hpedcam, 4);
149 dispped9.SetCamContent( hpedcam, 5);
150 dispped9.SetCamError( hpedcam, 6);
151 dispped10.SetCamContent(hpedcam, 7);
152 dispped11.SetCamContent(hpedcam, 8);
153 dispped11.SetCamError( hpedcam, 9);
154 dispped12.SetCamContent(hpedcam, 10);
155 dispped13.SetCamContent(hpedcam, 11);
156 dispped14.SetCamContent(hpedcam, 12);
157
158 dispped0.SetYTitle("Calc. Pedestal per slice [FADC counts]");
159 dispped1.SetYTitle("Calc. Pedestal Error per slice [FADC counts]");
160 dispped2.SetYTitle("Calc. Pedestal RMS per slice [FADC counts]");
161 dispped3.SetYTitle("Calc. Pedestal RMS Error per slice [FADC counts]");
162 dispped4.SetYTitle("Fitted Mean per slice [FADC counts]");
163 dispped5.SetYTitle("Error of Fitted Mean per slice [FADC counts]");
164 dispped6.SetYTitle("Fitted Sigma per slice [FADC counts]");
165 dispped7.SetYTitle("Error of Fitted Sigma per slice [FADC counts]");
166 dispped8.SetYTitle("Fit Probability [1]");
167 dispped9.SetYTitle("Rel. Diff. Pedestal Calc.-Fitted per slice [1]");
168 dispped10.SetYTitle("Rel. Diff. Pedestal Error Calc.-Fitted per slice [1]");
169 dispped11.SetYTitle("Rel. Diff. Pedestal RMS Calc.-Fitted per slice [1]");
170 dispped12.SetYTitle("Rel. Diff. Pedestal RMS Error Calc.-Fitted per slice [1]");
171 dispped13.SetYTitle("[1]");
172 dispped14.SetYTitle("[1]");
173
174 // Histogram values
175 TCanvas &b1 = display->AddTab("Ped.Calc.");
176 b1.Divide(4,3);
177
178 CamDraw(b1,dispped0,pedcam,1,4,1);
179 CamDraw(b1,dispped1,pedcam,2,4,2);
180 CamDraw(b1,dispped2,pedcam,3,4,2);
181 CamDraw(b1,dispped3,pedcam,4,4,2);
182
183 // Fitted values
184 TCanvas &b2 = display->AddTab("Ped.Fit");
185 b2.Divide(4,3);
186
187 CamDraw(b2,dispped4,hpedcam,1,4,1);
188 CamDraw(b2,dispped5,hpedcam,2,4,2);
189 CamDraw(b2,dispped6,hpedcam,3,4,2);
190 CamDraw(b2,dispped7,hpedcam,4,4,2);
191
192
193 // Fits Probability
194 TCanvas &b3 = display->AddTab("Ped.Fit Prob.");
195 b3.Divide(1,3);
196
197 CamDraw(b3,dispped8,hpedcam,1,1,3);
198
199 // Differences
200 TCanvas &c4 = display->AddTab("Rel.Diff.Calc.-Fit");
201 c4.Divide(4,3);
202
203 CamDraw(c4,dispped9,hpedcam,1,4,1);
204 CamDraw(c4,dispped10,hpedcam,2,4,1);
205 CamDraw(c4,dispped11,hpedcam,3,4,1);
206 CamDraw(c4,dispped12,hpedcam,4,4,1);
207
208 // Defects
209 TCanvas &c5 = display->AddTab("Defects");
210 c5.Divide(2,2);
211
212 CamDraw(c5,dispped13,hpedcam,1,2,0);
213 CamDraw(c5,dispped14,hpedcam,2,2,0);
214
215 //
216 // Create a empty Parameter List and an empty Task List
217 //
218 MParList plist2;
219 MTaskList tlist2;
220 plist2.AddToList(&tlist2);
221
222 MExtractedSignalCam sigcam;
223 MCalibrationChargeCam calcam;
224 MHCalibrationRelTimeCam timecam;
225 MHCalibrationChargeCam chargecam;
226 MHCalibrationChargePINDiode chargepin;
227
228 //
229 // Get the previously created MPedestalCam into the new Parameter List
230 //
231 plist2.AddToList(&geomcam);
232 plist2.AddToList(&pedcam);
233 plist2.AddToList(&sigcam);
234 plist2.AddToList(&calcam);
235 plist2.AddToList(&timecam);
236 plist2.AddToList(&chargecam);
237 plist2.AddToList(&chargepin);
238 //
239 // Get the MAGIC geometry
240 //
241 tlist2.AddToList(&geomapl);
242 //
243 // Now setup the new tasks and tasklist for the calibration
244 // ---------------------------------------------------
245 //
246
247 MReadMarsFile read2("Events", calname);
248 read2.DisableAutoScheme();
249
250 //
251 // We saw that the signal jumps between slices,
252 // thus take the sliding window
253 //
254 MExtractPINDiode pincalc;
255 MExtractBlindPixel blindcalc;
256 MExtractSignal2 sigcalc2;
257 MArrivalTimeCalc2 timecalc;
258 MCalibrationChargeCalc calcalc;
259
260 MFillH filltime("MHCalibrationRelTimeCam", "MArrivalTime");
261 MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
262 MFillH fillcam("MHCalibrationChargeCam" , "MExtractedSignalCam");
263
264 //
265 // Set the range (other than default)
266 // of FADC slices for the blind pixel
267 //
268 // calcalc.SetBlindPixelRange(10,25);
269
270 //
271 // Set the cut upon which a superposition of the blind pixel
272 // FADC slices will be filled into the SinglePHE histogram
273 //
274 // calcalc.SetBlindPixelSinglePheCut(500);
275
276 //
277 // Skip the HiGain vs. LoGain calibration
278 //
279 calcalc.SkipHiLoGainCalibration();
280
281 //
282 // As long, as we don't have digital modules,
283 // we have to set the color of the pulser LED by hand
284 //
285// calcalc.SetPulserColor(MCalibrationCalc::kECT1);
286
287 //
288 // In case, we want to exclude a pre-defined list of bad pixels:
289 // (This is a preliminary feature)
290 //
291 // calcalc.ExcludePixelsFromAsciiFile("badpixels.dat");
292
293 //
294 // In case, we want to apply another fit function to the
295 // blind pixel
296 //
297 // MCalibrationBlindPix *bp = calcam.GetBlindPixel();
298 // bp->ChangeFitFunc(MHCalibrationBlindPixel::kEPoisson5);
299
300 //
301 // Apply a filter against cosmics
302 // (was directly in MCalibrationCalc in earlier versions)
303 //
304 MFCosmics cosmics;
305 MContinue cont(&cosmics);
306
307 tlist2.AddToList(&read2);
308 tlist2.AddToList(&blindcalc);
309 tlist2.AddToList(&pincalc);
310 tlist2.AddToList(&sigcalc2);
311 //
312 // In case, you want to skip the cosmics rejection,
313 // uncomment the next line
314 //
315 tlist2.AddToList(&cont);
316 //
317 // In case, you want to skip the somewhat lengthy calculation
318 // of the arrival times using a spline, uncomment the next two lines
319 //
320 tlist2.AddToList(&timecalc);
321 tlist2.AddToList(&filltime);
322 tlist2.AddToList(&fillpin);
323 tlist2.AddToList(&fillcam);
324 //
325 tlist2.AddToList(&calcalc);
326 //
327 // Create and setup the eventloop
328 //
329 MEvtLoop evtloop2;
330 evtloop2.SetParList(&plist2);
331 evtloop2.SetDisplay(display);
332
333 //
334 // Execute second analysis
335 //
336 if (!evtloop2.Eventloop())
337 return;
338
339 tlist2.PrintStatistics();
340
341 //
342 // print the most important results of all pixels
343 //
344 calcam.Print();
345
346 //
347 // just one example how to get the plots of individual pixels
348 //
349 chargecam[5].DrawClone("fourierevents");
350
351 // Create histograms to display
352 MHCamera disp1 (geomcam, "Cal;Charge", "Fitted Mean Charges");
353 MHCamera disp2 (geomcam, "Cal;SigmaCharge", "Sigma of Fitted Charges");
354 MHCamera disp3 (geomcam, "Cal;FitProb", "Probability of Fit");
355 MHCamera disp4 (geomcam, "Cal;RSigma", "Reduced Sigmas");
356 MHCamera disp5 (geomcam, "Cal;RSigma/Charge", "Reduced Sigma per Charge");
357 MHCamera disp6 (geomcam, "Cal;FFactorPh", "Nr. of Photons (F-Factor Method)");
358 MHCamera disp7 (geomcam, "Cal;FFactorConv", "Conversion Factor (F-Factor Method)");
359 MHCamera disp8 (geomcam, "Cal;FFactorFFactor", "Total F-Factor (F-Factor Method)");
360 MHCamera disp9 (geomcam, "Cal;BlindPixPh", "Photon flux inside plexiglass (Blind Pixel Method)");
361 MHCamera disp10 (geomcam, "Cal;BlindPixConv", "Conversion Factor (Blind Pixel Method)");
362 MHCamera disp11 (geomcam, "Cal;BlindPixFFactor","Total F-Factor (Blind Pixel Method)");
363 MHCamera disp12 (geomcam, "Cal;PINDiodePh", "Photon flux outside plexiglass (PIN Diode Method)");
364 MHCamera disp13 (geomcam, "Cal;PINDiodeConv", "Conversion Factor (PIN Diode Method)");
365 MHCamera disp14 (geomcam, "Cal;PINDiodeFFactor","Total F-Factor (PIN Diode Method)");
366 MHCamera disp15 (geomcam, "Cal;Excluded", "Pixels previously excluded");
367 MHCamera disp16 (geomcam, "Cal;NotFitted", "Pixels that could not be fitted");
368 MHCamera disp17 (geomcam, "Cal;NotFitValid", "Pixels with not valid fit results");
369 MHCamera disp18 (geomcam, "Cal;HiGainOscillating", "Oscillating Pixels HI Gain");
370 MHCamera disp19 (geomcam, "Cal;LoGainOscillating", "Oscillating Pixels LO Gain");
371 MHCamera disp20 (geomcam, "Cal;HiGainPickup", "Number Pickup events Hi Gain");
372 MHCamera disp21 (geomcam, "Cal;LoGainPickup", "Number Pickup events Lo Gain");
373 MHCamera disp22 (geomcam, "Cal;Saturation", "Pixels with saturated Hi Gain");
374 MHCamera disp23 (geomcam, "Cal;FFactorValid", "Pixels with valid F-Factor calibration");
375 MHCamera disp24 (geomcam, "Cal;BlindPixelValid", "Pixels with valid BlindPixel calibration");
376 MHCamera disp25 (geomcam, "Cal;PINdiodeFFactorValid", "Pixels with valid PINDiode calibration");
377
378 MHCamera disp26 (geomcam, "Cal;Ped", "Pedestals");
379 MHCamera disp27 (geomcam, "Cal;PedRms", "Pedestal RMS");
380
381 MHCamera disp28 (geomcam, "time;Time", "Rel. Arrival Times");
382 MHCamera disp29 (geomcam, "time;SigmaTime", "Sigma of Rel. Arrival Times");
383 MHCamera disp30 (geomcam, "time;TimeProb", "Probability of Time Fit");
384 MHCamera disp31 (geomcam, "time;NotFitValid", "Pixels with not valid fit results");
385 MHCamera disp32 (geomcam, "time;Oscillating", "Oscillating Pixels");
386
387 MHCamera disp33 (geomcam, "Cal;AbsTimeMean", "Abs. Arrival Times");
388 MHCamera disp34 (geomcam, "Cal;AbsTimeRms", "RMS of Arrival Times");
389
390 // Fitted charge means and sigmas
391 disp1.SetCamContent(calcam, 0);
392 disp1.SetCamError( calcam, 1);
393 disp2.SetCamContent(calcam, 2);
394 disp2.SetCamError( calcam, 3);
395
396 // Fit probabilities
397 disp3.SetCamContent(calcam, 4);
398
399 // Reduced Sigmas and reduced sigmas per charge
400 disp4.SetCamContent(calcam, 5);
401 disp4.SetCamError( calcam, 6);
402 disp5.SetCamContent(calcam, 7);
403 disp5.SetCamError( calcam, 8);
404
405 // F-Factor Method
406 disp6.SetCamContent(calcam, 9);
407 disp6.SetCamError( calcam, 10);
408 disp7.SetCamContent(calcam, 11);
409 disp7.SetCamError( calcam, 12);
410 disp8.SetCamContent(calcam, 13);
411 disp8.SetCamError( calcam, 14);
412
413 /// Blind Pixel Method
414 disp9.SetCamContent(calcam, 15);
415 disp9.SetCamError( calcam, 16);
416 disp10.SetCamContent(calcam,17);
417 disp10.SetCamError( calcam,18);
418 disp11.SetCamContent(calcam,19);
419 disp11.SetCamError( calcam,20);
420
421 // PIN Diode Method
422 disp12.SetCamContent(calcam,21);
423 disp12.SetCamError( calcam,22);
424 disp13.SetCamContent(calcam,23);
425 disp13.SetCamError( calcam,24);
426 disp14.SetCamContent(calcam,25);
427 disp14.SetCamError( calcam,26);
428
429 // Pixels with defects
430 disp15.SetCamContent(calcam,27);
431 disp16.SetCamContent(calcam,28);
432 disp17.SetCamContent(calcam,29);
433 disp18.SetCamContent(calcam,30);
434 disp19.SetCamContent(calcam,31);
435 disp20.SetCamContent(calcam,32);
436 disp21.SetCamContent(calcam,33);
437
438 // Lo Gain calibration
439 disp22.SetCamContent(calcam,34);
440
441 // Valid flags
442 disp23.SetCamContent(calcam,35);
443 disp24.SetCamContent(calcam,36);
444 disp25.SetCamContent(calcam,37);
445
446 // Pedestals
447 disp26.SetCamContent(calcam,38);
448 disp26.SetCamError( calcam,39);
449 disp27.SetCamContent(calcam,40);
450 disp27.SetCamError( calcam,41);
451
452/*
453 // Relative Times
454 disp28.SetCamContent(timecam,0);
455 disp28.SetCamError( timecam,1);
456 disp29.SetCamContent(timecam,2);
457 disp29.SetCamError( timecam,3);
458 disp30.SetCamContent(timecam,4);
459 disp31.SetCamContent(timecam,5);
460 disp32.SetCamContent(timecam,6);
461*/
462 // Absolute Times
463 disp33.SetCamContent(calcam,42);
464 disp33.SetCamError( calcam,43);
465 disp34.SetCamContent(calcam,43);
466
467 disp1.SetYTitle("Charge [FADC units]");
468 disp2.SetYTitle("\\sigma_{Charge} [FADC units]");
469 disp3.SetYTitle("P_{Charge} [1]");
470
471 disp4.SetYTitle("\\sqrt{\\sigma^{2}_{Charge} - RMS^{2}_{Ped}} [FADC Counts]");
472 disp5.SetYTitle("Reduced Sigma / Mean Charge [1]");
473
474 disp6.SetYTitle("Nr. Photons [1]");
475 disp7.SetYTitle("Conversion Factor [Ph/FADC Count]");
476 disp8.SetYTitle("\\sqrt{N_{PhE}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
477
478 disp9.SetYTitle("Photon flux [ph/mm^2]");
479 disp10.SetYTitle("Conversion Factor [Phot/FADC Count]");
480 disp11.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
481
482 disp12.SetYTitle("Photon flux [ph/mm^2]");
483 disp13.SetYTitle("Conversion Factor [Phot/FADC Count]");
484 disp14.SetYTitle("\\sqrt{N_{Ph}}*\\sigma_{Charge}/\\mu_{Charge} [1]");
485
486 disp15.SetYTitle("[1]");
487 disp16.SetYTitle("[1]");
488 disp17.SetYTitle("[1]");
489 disp18.SetYTitle("[1]");
490 disp19.SetYTitle("[1]");
491 disp20.SetYTitle("[1]");
492 disp21.SetYTitle("[1]");
493 disp22.SetYTitle("[1]");
494 disp23.SetYTitle("[1]");
495 disp24.SetYTitle("[1]");
496 disp25.SetYTitle("[1]");
497
498 disp26.SetYTitle("Ped [FADC Counts ]");
499 disp27.SetYTitle("RMS_{Ped} [FADC Counts ]");
500
501 disp28.SetYTitle("Time Offset [ns]");
502 disp29.SetYTitle("Timing resolution [ns]");
503 disp30.SetYTitle("P_{Time} [1]");
504
505 disp31.SetYTitle("[1]");
506 disp32.SetYTitle("[1]");
507
508 disp33.SetYTitle("Mean Abs. Time [FADC slice]");
509 disp34.SetYTitle("RMS Abs. Time [FADC slices]");
510
511 gStyle->SetOptStat(1111);
512 gStyle->SetOptFit();
513
514 // Charges
515 TCanvas &c1 = display->AddTab("Fit.Charge");
516 c1.Divide(2, 3);
517
518 CamDraw(c1, disp1,calcam,1, 2 , 2);
519 CamDraw(c1, disp2,calcam,2, 2 , 2);
520
521 // Fit Probability
522 TCanvas &c2 = display->AddTab("Fit.Prob");
523 c2.Divide(1,3);
524
525 CamDraw(c2, disp3,calcam,1, 1 , 4);
526
527 // Reduced Sigmas
528 TCanvas &c3 = display->AddTab("Red.Sigma");
529 c3.Divide(2,3);
530
531 CamDraw(c3, disp4,calcam,1, 2 , 2);
532 CamDraw(c3, disp5,calcam,2, 2 , 2);
533
534 // F-Factor Method
535 TCanvas &c4 = display->AddTab("F-Factor");
536 c4.Divide(3,3);
537
538 CamDraw(c4, disp6,calcam,1, 3 , 2);
539 CamDraw(c4, disp7,calcam,2, 3 , 2);
540 CamDraw(c4, disp8,calcam,3, 3 , 2);
541
542 // Blind Pixel Method
543 TCanvas &c5 = display->AddTab("BlindPix");
544 c5.Divide(3, 3);
545
546 CamDraw(c5, disp9,calcam,1, 3 , 9);
547 CamDraw(c5, disp10,calcam,2, 3 , 2);
548 CamDraw(c5, disp11,calcam,3, 3 , 2);
549
550 // PIN Diode Method
551 TCanvas &c6 = display->AddTab("PINDiode");
552 c6.Divide(3,3);
553
554 CamDraw(c6, disp12,calcam,1, 3 , 9);
555 CamDraw(c6, disp13,calcam,2, 3 , 2);
556 CamDraw(c6, disp14,calcam,3, 3 , 2);
557
558 // Defects
559 TCanvas &c7 = display->AddTab("Defects");
560 c7.Divide(7,2);
561
562 CamDraw(c7, disp15,calcam,1,7, 0);
563 CamDraw(c7, disp16,calcam,2,7, 0);
564 CamDraw(c7, disp17,calcam,3,7, 0);
565 CamDraw(c7, disp18,calcam,4,7, 0);
566 CamDraw(c7, disp19,calcam,5,7, 0);
567 CamDraw(c7, disp20,calcam,6,7, 0);
568 CamDraw(c7, disp21,calcam,7,7, 0);
569
570 // Valid flags
571 TCanvas &c8 = display->AddTab("Validity");
572 c8.Divide(4,2);
573
574 CamDraw(c8, disp22,calcam,1,4,0);
575 CamDraw(c8, disp23,calcam,2,4,0);
576 CamDraw(c8, disp24,calcam,3,4,0);
577 CamDraw(c8, disp25,calcam,4,4,0);
578
579
580 // Pedestals
581 TCanvas &c9 = display->AddTab("Pedestals");
582 c9.Divide(2,3);
583
584 CamDraw(c9,disp26,calcam,1,2,1);
585 CamDraw(c9,disp27,calcam,2,2,2);
586
587/*
588 // Rel. Times
589 TCanvas &c10 = display->AddTab("Fitted Rel. Times");
590 c10.Divide(3,3);
591
592 CamDraw(c10,disp28,calcam,1,3,2);
593 CamDraw(c10,disp29,calcam,2,3,2);
594 CamDraw(c10,disp30,calcam,3,3,4);
595
596 // Time Defects
597 TCanvas &c11 = display->AddTab("Time Def.");
598 c11.Divide(2,2);
599
600 CamDraw(c11, disp31,calcam,1,2, 0);
601 CamDraw(c11, disp32,calcam,2,2, 0);
602*/
603 // Abs. Times
604 TCanvas &c12 = display->AddTab("Abs. Times");
605 c12.Divide(2,3);
606
607 CamDraw(c12,disp33,calcam,1,2,2);
608 CamDraw(c12,disp34,calcam,2,2,2);
609
610}
611
612void CamDraw(TCanvas &c, MHCamera &cam, MCamEvent &evt, Int_t i, Int_t j, Int_t fit)
613{
614
615 c.cd(i);
616 gPad->SetBorderMode(0);
617 MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
618 // obj1->AddNotify(evt);
619
620 c.cd(i+j);
621 gPad->SetBorderMode(0);
622 obj1->Draw();
623 ((MHCamera*)obj1)->SetPrettyPalette();
624
625 if (fit != 0)
626 {
627 c.cd(i+2*j);
628 gPad->SetBorderMode(0);
629 TH1D *obj2 = (TH1D*)obj1->Projection();
630
631 obj2->Sumw2();
632 obj2->Draw();
633 obj2->SetBit(kCanDelete);
634
635 const Double_t min = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
636 const Double_t max = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
637 const Double_t integ = obj2->Integral("width")/2.5066283;
638 const Double_t mean = obj2->GetMean();
639 const Double_t rms = obj2->GetRMS();
640 const Double_t width = max-min;
641
642 if (rms == 0. || width == 0. )
643 return;
644
645 switch (fit)
646 {
647 case 1:
648 TF1 *sgaus = new TF1("sgaus","gaus(0)",min,max);
649 sgaus->SetBit(kCanDelete);
650 sgaus->SetParNames("Area","#mu","#sigma");
651 sgaus->SetParameters(integ/rms,mean,rms);
652 sgaus->SetParLimits(0,0.,integ);
653 sgaus->SetParLimits(1,min,max);
654 sgaus->SetParLimits(2,0,width/1.5);
655 obj2->Fit("sgaus","QLR");
656 obj2->GetFunction("sgaus")->SetLineColor(kYellow);
657 break;
658
659 case 2:
660 TString dgausform = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
661 dgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
662 TF1 *dgaus = new TF1("dgaus",dgausform.Data(),min,max);
663 dgaus->SetBit(kCanDelete);
664 dgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}","A_{2}","#mu_{2}","#sigma_{2}");
665 dgaus->SetParameters(integ,(min+mean)/2.,width/4.,
666 integ/width/2.,(max+mean)/2.,width/4.);
667 // The left-sided Gauss
668 dgaus->SetParLimits(0,integ-1.5,integ+1.5);
669 dgaus->SetParLimits(1,min+(width/10.),mean);
670 dgaus->SetParLimits(2,0,width/2.);
671 // The right-sided Gauss
672 dgaus->SetParLimits(3,0,integ);
673 dgaus->SetParLimits(4,mean,max-(width/10.));
674 dgaus->SetParLimits(5,0,width/2.);
675 obj2->Fit("dgaus","QLRM");
676 obj2->GetFunction("dgaus")->SetLineColor(kYellow);
677 break;
678
679 case 3:
680 TString tgausform = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
681 tgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
682 tgausform += "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
683 TF1 *tgaus = new TF1("tgaus",tgausform.Data(),min,max);
684 tgaus->SetBit(kCanDelete);
685 tgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
686 "A_{2}","#mu_{2}","#sigma_{2}",
687 "A_{3}","#mu_{3}","#sigma_{3}");
688 tgaus->SetParameters(integ,(min+mean)/2,width/4.,
689 integ/width/3.,(max+mean)/2.,width/4.,
690 integ/width/3.,mean,width/2.);
691 // The left-sided Gauss
692 tgaus->SetParLimits(0,integ-1.5,integ+1.5);
693 tgaus->SetParLimits(1,min+(width/10.),mean);
694 tgaus->SetParLimits(2,width/15.,width/2.);
695 // The right-sided Gauss
696 tgaus->SetParLimits(3,0.,integ);
697 tgaus->SetParLimits(4,mean,max-(width/10.));
698 tgaus->SetParLimits(5,width/15.,width/2.);
699 // The Gauss describing the outliers
700 tgaus->SetParLimits(6,0.,integ);
701 tgaus->SetParLimits(7,min,max);
702 tgaus->SetParLimits(8,width/4.,width/1.5);
703 obj2->Fit("tgaus","QLRM");
704 obj2->GetFunction("tgaus")->SetLineColor(kYellow);
705 break;
706 case 4:
707 obj2->Fit("pol0","Q");
708 obj2->GetFunction("pol0")->SetLineColor(kYellow);
709 break;
710 case 9:
711 break;
712 default:
713 obj2->Fit("gaus","Q");
714 obj2->GetFunction("gaus")->SetLineColor(kYellow);
715 break;
716 }
717
718 gPad->Modified();
719 gPad->Update();
720
721 }
722}
Note: See TracBrowser for help on using the repository browser.