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

Last change on this file since 2811 was 2797, checked in by gaug, 21 years ago
*** empty log message ***
File size: 12.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
25void calibration(TString pedname="/mnt/Data/rootdata/Miscellaneous/2003_12_19/20031218_03522_P_Park_E.root",
26 TString calname="/mnt/Data/rootdata/Miscellaneous/2003_12_19/20031218_03527_C_Park_E.root")
27{
28
29 //
30 // Create a empty Parameter List and an empty Task List
31 // The tasklist is identified in the eventloop by its name
32 //
33 MParList plist;
34
35 MTaskList tlist;
36 plist.AddToList(&tlist);
37
38 //
39 // Now setup the tasks and tasklist for the pedestals:
40 // ---------------------------------------------------
41 //
42
43 MReadMarsFile read("Events", pedname);
44 read.DisableAutoScheme();
45
46 MGeomApply geomapl;
47 MPedCalcPedRun pedcalc;
48 MGeomCamMagic geomcam;
49 MPedestalCam pedcam;
50
51 tlist.AddToList(&read);
52 tlist.AddToList(&geomapl);
53 tlist.AddToList(&pedcalc);
54
55 plist.AddToList(&pedcam);
56
57 MHCamEvent hist("Pedestal");
58 hist.SetType(0);
59 plist.AddToList(&hist);
60 MFillH fill(&hist, "MPedestalCam");
61
62 tlist.AddToList(&fill);
63
64 MStatusDisplay *d1 = new MStatusDisplay;
65
66 //Set update time to 3s
67 d1->SetUpdateTime(3000);
68
69 //
70 // Create and setup the eventloop
71 //
72 MEvtLoop evtloop;
73 evtloop.SetParList(&plist);
74 evtloop.SetDisplay(d1);
75
76 //
77 // Execute first analysis
78 //
79 if (!evtloop.Eventloop())
80 return;
81
82 tlist.PrintStatistics();
83
84
85 //
86 // Create a empty Parameter List and an empty Task List
87 //
88 MParList plist2;
89
90 MTaskList tlist2;
91 plist2.AddToList(&tlist2);
92
93
94 plist2.AddToList((MPedestalCam*)plist.FindObject("MPedestalCam"));
95
96 tlist2.AddToList(&geomapl);
97
98 //
99 // Now setup the new tasks and tasklist for the calibration
100 // ---------------------------------------------------
101 //
102
103 MReadMarsFile read2("Events", calname);
104 read2.DisableAutoScheme();
105
106 MExtractSignal sigsig;
107 MCalibrationCalc calcalc;
108 MExtractedSignalCam sigcam;
109
110 plist2.AddToList(&geomcam);
111 plist2.AddToList(&sigcam);
112
113 //
114 // As long, as we don't have digital modules,
115 // we have to set the color of the pulser LED by hand
116 //
117 calcalc.SetPulserColor(MCalibrationCalc::kECT1);
118
119 tlist2.AddToList(&read2);
120 tlist2.AddToList(&sigsig);
121 tlist2.AddToList(&calcalc);
122
123 //
124 // Create and setup the eventloop
125 //
126 MEvtLoop evtloop2;
127 evtloop2.SetParList(&plist2);
128
129 //
130 // Execute second analysis
131 //
132 if (!evtloop2.Eventloop())
133 return;
134
135 tlist2.PrintStatistics();
136
137 //
138 // just one example how to get the plots of individual pixels
139 //
140 MCalibrationCam *cam = plist2.FindObject("MCalibrationCam");
141 cam.Print();
142
143 MHCamEvent camevt;
144 MHCamera disp1 (geomcam, "MCalibrationPix;Charge", "Fitted Mean Charges");
145 MHCamera disp3 (geomcam, "MCalibrationPix;SigmaCharge", "Sigma of Fitted Charges");
146 MHCamera disp5 (geomcam, "MCalibrationPix;ChargeProb", "Probability of Fit");
147 MHCamera disp6 (geomcam, "MCalibrationPix;Time", "Arrival Times");
148 MHCamera disp7 (geomcam, "MCalibrationPix;SigmaTime", "Sigma of Arrival Times");
149 MHCamera disp8 (geomcam, "MCalibrationPix;TimeChiSquare", "Chi Square of Time Fit");
150 MHCamera disp9 (geomcam, "MCalibrationPix;Ped", "Pedestals");
151 MHCamera disp10 (geomcam, "MCalibrationPix;PedRms", "Pedestal RMS");
152 MHCamera disp11 (geomcam, "MCalibrationPix;RSigma", "Reduced Sigmas");
153 MHCamera disp12 (geomcam, "MCalibrationPix;PheFFactorMethod", "Nr. of Phe's (F-Factor Method)");
154 MHCamera disp13 (geomcam, "MCalibrationPix;MeanConversionFFactorMethod", "Conversion Factor (F-Factor Method)");
155 MHCamera disp14 (geomcam, "MCalibrationPix;MeanPhotInsidePlexiglass", "Nr. of Photons (Blind Pixel Method)");
156 MHCamera disp15 (geomcam, "MCalibrationPix;MeanConversionBlindPixelMethod", "Conversion Factor (Blind Pixel Method)");
157 MHCamera disp16 (geomcam, "MCalibrationPix;RSigma/Charge", "Reduced Sigma per Charge");
158
159 disp1.SetCamContent(*cam, 0);
160 disp1.SetCamError(*cam,1);
161
162 disp3.SetCamContent(*cam, 2);
163 disp3.SetCamError(*cam,3);
164
165 disp5.SetCamContent(*cam, 4);
166
167 disp6.SetCamContent(*cam, 5);
168 disp6.SetCamError(*cam, 6);
169 disp7.SetCamContent(*cam, 6);
170 disp8.SetCamContent(*cam, 7);
171
172 disp9.SetCamContent(*cam, 8);
173 disp9.SetCamError(*cam, 9);
174 disp10.SetCamContent(*cam, 9);
175
176 disp11.SetCamContent(*cam, 10);
177
178 disp12.SetCamContent(*cam, 11);
179 disp12.SetCamError(*cam, 12);
180
181 disp13.SetCamContent(*cam, 13);
182 disp13.SetCamError(*cam, 14);
183
184 disp14.SetCamContent(*cam, 15);
185 disp15.SetCamContent(*cam, 16);
186 disp16.SetCamContent(*cam, 17);
187
188
189 disp1.SetYTitle("Charge [FADC counts]");
190 // disp2.SetYTitle("\\Delta Q [FADC counts]");
191 disp3.SetYTitle("\\sigma_{Charge} [FADC counts]");
192 // disp4.SetYTitle("\\Delta {\\sigma_{Q}} [FADC counts]");
193 disp5.SetYTitle("P_{Charge} [1]");
194 disp6.SetYTitle("Arr. Time [Time Slice Nr.]");
195 disp7.SetYTitle("\\sigma_{Time} [Time Slices]");
196 disp8.SetYTitle("\\chi^{2}_{Time} [1]");
197 disp9.SetYTitle("Ped [FADC Counts ]");
198 disp10.SetYTitle("RMS_{Ped} [FADC Counts ]");
199 disp11.SetYTitle("\\sqrt{\\sigma^{2}_{Charge} - RMS^{2}_{Ped}} [FADC Counts]");
200 disp12.SetYTitle("Nr. Photo-Electrons [1]");
201 disp13.SetYTitle("Conversion Factor [PhE/FADC Count]");
202 disp14.SetYTitle("Nr. Photons [1]");
203 disp15.SetYTitle("Conversion Factor [Phot/FADC Count]");
204 disp16.SetYTitle("Reduced Sigma / Charge [1]");
205
206 MStatusDisplay *d3 = new MStatusDisplay;
207 d3->SetUpdateTime(3000);
208 d3->Resize(1180,900);
209
210 gStyle->SetOptStat(1111);
211 gStyle->SetOptFit();
212
213 // Charges
214 TCanvas *c1 = &d3->AddTab("Fitted Charges");
215 c1->Divide(2,3);
216
217 TObject *obj1;
218 TObject *obj2;
219
220 c1->cd(1);
221 obj1=disp1.DrawCopy("hist");
222 ((MHCamera*)obj1)->AddNotify(*cam);
223
224 c1->cd(3);
225 gPad->SetBorderMode(0);
226 obj1->Draw();
227 ((MHCamera*)obj1)->SetPrettyPalette();
228
229 c1->cd(5);
230 gPad->SetBorderMode(0);
231 obj2 = obj1->DrawClone("proj");
232 gPad->Update();
233 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
234 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
235
236 c1->cd(2);
237 obj1=disp3.DrawCopy("hist");
238 ((MHCamera*)obj1)->AddNotify(*cam);
239
240 c1->cd(4);
241 gPad->SetBorderMode(0);
242 obj1->Draw();
243 ((MHCamera*)obj1)->SetPrettyPalette();
244
245 c1->cd(6);
246 gPad->SetBorderMode(0);
247 obj2 = obj1->DrawClone("proj");
248 gPad->Update();
249 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
250 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
251
252 // Fit Probability
253 TCanvas *c12 = &d3->AddTab("Fit Prob.");
254 c12->Divide(1, 3);
255
256 c12->cd(1);
257 obj1=disp5.DrawCopy("hist");
258 ((MHCamera*)obj1)->AddNotify(*cam);
259
260 c12->cd(2);
261 gPad->SetBorderMode(0);
262 obj1->Draw();
263 ((MHCamera*)obj1)->SetPrettyPalette();
264
265 c12->cd(3);
266 gPad->SetBorderMode(0);
267 obj2 = obj1->DrawClone("proj");
268 gPad->Update();
269 ((MHCamera*)obj2)->GetYProj()->Fit("pol0","Q");
270 ((MHCamera*)obj2)->GetYProj()->GetFunction("pol0")->SetLineColor(kYellow);
271
272 // Times
273 TCanvas *c2 = &d3->AddTab("Fitted Times");
274 c2->Divide(3, 3);
275
276 c2->cd(1);
277 obj1=disp6.DrawCopy("hist");
278 ((MHCamera*)obj1)->AddNotify(*cam);
279
280 c2->cd(4);
281 obj1->Draw();
282 ((MHCamera*)obj1)->SetPrettyPalette();
283
284 c2->cd(7);
285 gPad->SetBorderMode(0);
286 obj2 = obj1->DrawClone("proj");
287 gPad->Update();
288 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
289 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
290
291 c2->cd(2);
292 obj1=disp7.DrawCopy("hist");
293 ((MHCamera*)obj1)->AddNotify(*cam);
294
295 c2->cd(5);
296 obj1->Draw();
297 ((MHCamera*)obj1)->SetPrettyPalette();
298
299 c2->cd(8);
300 gPad->SetBorderMode(0);
301 obj2 = obj1->DrawClone("proj");
302 gPad->Update();
303 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
304 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
305
306 c2->cd(3);
307 obj1=disp8.DrawCopy("hist");
308 ((MHCamera*)obj1)->AddNotify(*cam);
309
310 c2->cd(6);
311 obj1->Draw();
312 ((MHCamera*)obj1)->SetPrettyPalette();
313
314 c2->cd(9);
315 gPad->SetBorderMode(0);
316 obj2 = obj1->DrawClone("proj");
317 gPad->Update();
318 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
319 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
320
321 // Pedestals
322 TCanvas *c3 = &d3->AddTab("Pedestals");
323 c3->Divide(2, 3);
324
325 c3->cd(1);
326 obj1=disp9.DrawCopy("hist");
327 ((MHCamera*)obj1)->AddNotify(*cam);
328
329 c3->cd(3);
330 obj1->Draw();
331 ((MHCamera*)obj1)->SetPrettyPalette();
332
333 c3->cd(5);
334 gPad->SetBorderMode(0);
335 obj2 = obj1->DrawClone("proj");
336 gPad->Update();
337 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
338 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
339
340 c3->cd(2);
341 obj1=disp10.DrawCopy("hist");
342 ((MHCamera*)obj1)->AddNotify(*cam);
343
344 c3->cd(4);
345 obj1->Draw();
346 ((MHCamera*)obj1)->SetPrettyPalette();
347
348 c3->cd(6);
349 gPad->SetBorderMode(0);
350 obj2 = obj1->DrawClone("proj");
351 gPad->Update();
352 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
353 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
354
355 // Reduced Sigmas
356 TCanvas *c4 = &d3->AddTab("Reduced Sigmas");
357 c4->Divide(2,3);
358
359 c4->cd(1);
360 obj1=disp11.DrawCopy("hist");
361 ((MHCamera*)obj1)->AddNotify(*cam);
362
363 c4->cd(3);
364 obj1->Draw();
365 ((MHCamera*)obj1)->SetPrettyPalette();
366
367 c4->cd(5);
368 gPad->SetBorderMode(0);
369 obj2 = obj1->DrawClone("proj");
370 gPad->Update();
371 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
372 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
373
374 c4->cd(2);
375 obj1=disp16.DrawCopy("hist");
376 ((MHCamera*)obj1)->AddNotify(*cam);
377
378 c4->cd(4);
379 obj1->Draw();
380 ((MHCamera*)obj1)->SetPrettyPalette();
381
382 c4->cd(6);
383 gPad->SetBorderMode(0);
384 obj2 = obj1->DrawClone("proj");
385 gPad->Update();
386 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
387 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
388
389 // F-Factor Method
390 TCanvas *c5 = &d3->AddTab("F-Factor Method");
391 c5->Divide(2, 3);
392
393 c5->cd(1);
394 obj1=disp12.DrawCopy("hist");
395 ((MHCamera*)obj1)->AddNotify(*cam);
396
397 c5->cd(3);
398 obj1->Draw();
399 ((MHCamera*)obj1)->SetPrettyPalette();
400
401 c5->cd(5);
402 gPad->SetBorderMode(0);
403 obj2 = obj1->DrawClone("proj");
404 gPad->Update();
405 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
406 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
407
408 c5->cd(2);
409 obj1=disp13.DrawCopy("hist");
410 ((MHCamera*)obj1)->AddNotify(*cam);
411
412 c5->cd(4);
413 obj1->Draw();
414 ((MHCamera*)obj1)->SetPrettyPalette();
415
416 c5->cd(6);
417 gPad->SetBorderMode(0);
418 obj2 = obj1->DrawClone("proj");
419 gPad->Update();
420 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
421 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
422
423 // Blind Pixel Method
424 TCanvas *c6 = &d3->AddTab("Blind Pixel Method");
425 c6->Divide(2, 3);
426
427 c6->cd(1);
428 obj1=disp14.DrawCopy("hist");
429 ((MHCamera*)obj1)->AddNotify(*cam);
430
431 c6->cd(3);
432 obj1->Draw();
433 ((MHCamera*)obj1)->SetPrettyPalette();
434
435
436 c6->cd(2);
437 obj1=disp15.DrawCopy("hist");
438 ((MHCamera*)obj1)->AddNotify(*cam);
439
440 c6->cd(4);
441 obj1->Draw();
442 ((MHCamera*)obj1)->SetPrettyPalette();
443
444 c6->cd(6);
445 gPad->SetBorderMode(0);
446 obj2 = obj1->DrawClone("proj");
447 gPad->Update();
448 ((MHCamera*)obj2)->GetYProj()->Fit("gaus","Q");
449 ((MHCamera*)obj2)->GetYProj()->GetFunction("gaus")->SetLineColor(kYellow);
450}
451
Note: See TracBrowser for help on using the repository browser.