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

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