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

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