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

Last change on this file since 2627 was 2627, checked in by gaug, 21 years ago
*** empty log message ***
File size: 9.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
25void calibration(TString pedname="/data/MAGIC/rootdata/2003_12_01/20031130_03340_P_CrabNebula_E.root",
26 TString calname="/data/MAGIC/rootdata/2003_12_01/20031130_03341_C_CrabNebula_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// MGeomApply geomapl2;
97 tlist2.AddToList(&geomapl);
98
99 //
100 // Now setup the new tasks and tasklist for the calibration
101 // ---------------------------------------------------
102 //
103
104 MReadMarsFile read2("Events", calname);
105 read2.DisableAutoScheme();
106
107 MCalibrationCalc calcalc;
108// calcalc.SetSkipTFits();
109
110 plist2.AddToList(&geomcam);
111
112 //
113 // As long, as we don't have digital modules,
114 // we have to set the color of the pulser LED by hand
115 //
116 calcalc.SetPulserColor(MCalibrationCalc::kECT1);
117
118 tlist2.AddToList(&read2);
119 tlist2.AddToList(&calcalc);
120
121 MHCamEvent hist2;
122 hist2.SetType(8);
123 plist2.AddToList(&hist2);
124 MFillH fill2("MHCamEvent", "MCalibrationCam");
125 tlist2.AddToList(&fill2);
126
127 //
128 // Create and setup the eventloop
129 //
130 MEvtLoop evtloop2;
131 evtloop2.SetParList(&plist2);
132
133 //
134 // Execute second analysis
135 //
136 if (!evtloop2.Eventloop())
137 return;
138
139 tlist2.PrintStatistics();
140
141 //
142 // just one example how to get the plots of individual pixels
143 //
144 MCalibrationCam *cam = plist2.FindObject("MCalibrationCam");
145 cam.Print();
146
147 //
148 // Here we are confronted to a serious bug in ROOT:
149 // If we do not apply the next command, gPad will get
150 // screwed up completely: (Thanks to tbretz for finding out
151 // the reason during several hours!!!)
152 //
153 gROOT->GetListOfCanvases()->Delete();
154
155 MHCamEvent &h = *(MHCamEvent*)plist2->FindObject("MHCamEvent");
156 MHCamera &disp0 = *h.GetHistByName();
157 MHCamera disp1 (geomcam, "MCalibrationCam;q", "Fitted Mean Charges");
158 // MHCamera disp2 (geomcam, "MCalibrationCam;errq", "Error of Fitted Mean Charges");
159 MHCamera disp3 (geomcam, "MCalibrationCam;sigmaq", "Sigma of Fitted Mean Charges");
160 // MHCamera disp4 (geomcam, "MCalibrationCam;errsigmaq", "Error of Sigma of Fitted Mean Charges");
161 MHCamera disp5 (geomcam, "MCalibrationCam;probq", "Probability of Fit");
162 MHCamera disp6 (geomcam, "MCalibrationCam;t", "Arrival Times");
163 MHCamera disp7 (geomcam, "MCalibrationCam;sigmat", "Sigma of Arrival Times");
164 MHCamera disp8 (geomcam, "MCalibrationCam;probt", "Probability of Time Fit");
165 MHCamera disp9 (geomcam, "MCalibrationCam;ped", "Pedestals");
166 MHCamera disp10 (geomcam, "MCalibrationCam;pedrms", "Pedestal RMS");
167 MHCamera disp11 (geomcam, "MCalibrationCam;rsigma", "Reduced Sigmas");
168 MHCamera disp12 (geomcam, "MCalibrationCam;phe", "Nr. of Phe's (F-Factor Method)");
169 MHCamera disp13 (geomcam, "MCalibrationCam;convphe", "Conversion Factor (F-Factor Method)");
170 MHCamera disp14 (geomcam, "MCalibrationCam;photons", "Nr. of Photons (Blind Pixel Method)");
171 MHCamera disp15 (geomcam, "MCalibrationCam;convphot", "Conversion Factor (Blind Pixel Method)");
172
173 disp1.SetCamContent(*cam, 0);
174 disp1.SetCamError(*cam,1);
175 // disp2.SetCamContent(*cam, 1);
176
177 disp3.SetCamContent(*cam, 2);
178 disp3.SetCamError(*cam,3);
179 // disp4.SetCamContent(*cam, 3);
180 disp5.SetCamContent(*cam, 4);
181
182 disp6.SetCamContent(*cam, 5);
183 disp6.SetCamError(*cam,6);
184 disp7.SetCamContent(*cam, 6);
185 disp8.SetCamContent(*cam, 7);
186
187 disp9.SetCamContent(*cam, 8);
188 disp9.SetCamError(*cam,9);
189 disp10.SetCamContent(*cam, 9);
190
191 disp11.SetCamContent(*cam, 10);
192
193 disp12.SetCamContent(*cam, 11);
194 disp13.SetCamContent(*cam, 12);
195 disp14.SetCamContent(*cam, 13);
196 disp15.SetCamContent(*cam, 14);
197 // disp16.SetCamError(*cam, 16);
198
199
200 disp1.SetYTitle("Q [FADC counts]");
201 // disp2.SetYTitle("\\Delta Q [FADC counts]");
202 disp3.SetYTitle("\\sigma_{Q} [FADC counts]");
203 // disp4.SetYTitle("\\Delta {\\sigma_{Q}} [FADC counts]");
204 disp5.SetYTitle("P [au]");
205 disp6.SetYTitle("T [FADC slices]");
206 disp7.SetYTitle("\\Delta T [FADC slices]");
207 disp8.SetYTitle("P [au]");
208 disp9.SetYTitle("P [FADC counts/ slice ]");
209 disp10.SetYTitle("RMS_{P} [FADC counts / slice ]");
210 disp11.SetYTitle("\\sigma^2_{Q} - RMS^2_{P} [FADC counts^2]");
211 disp12.SetYTitle("Nr Phe's");
212 disp13.SetYTitle("Conversion Factor [Phe/FADC count]");
213 disp14.SetYTitle("Nr Photons");
214 disp15.SetYTitle("Conversion Factor [Ph/FADC count]");
215
216 MStatusDisplay *d2 = new MStatusDisplay;
217
218 // Set update time to 1s
219 d2->SetUpdateTime(1000);
220
221 TCanvas *c1 = &d2->AddTab("Fitted Charges");
222 c1->Divide(2, 2);
223
224 TObject *obj;
225
226 c1->cd(1);
227 gStyle->SetOptStat(1111);
228 obj=disp1.DrawCopy("hist");
229 ((MHCamera*)obj)->AddNotify(*cam);
230
231 c1->cd(3);
232 gPad->SetBorderMode(0);
233 obj->Draw();
234
235 c1->cd(2);
236 gStyle->SetOptStat(1101);
237 obj=disp3.DrawCopy("hist");
238 ((MHCamera*)obj)->AddNotify(*cam);
239
240 c1->cd(4);
241 gPad->SetBorderMode(0);
242 obj->Draw();
243
244
245 TCanvas *c12 = &d2->AddTab("Fit Prob.");
246 c12->Divide(1, 2);
247
248 c12->cd(1);
249 gStyle->SetOptStat(1101);
250 obj=disp5.DrawCopy("hist");
251 ((MHCamera*)obj)->AddNotify(*cam);
252
253 c12->cd(2);
254 gPad->SetBorderMode(0);
255 obj->Draw();
256
257 TCanvas *c2 = &d2->AddTab("Fitted Times");
258 c2->Divide(3, 2);
259
260 c2->cd(1);
261 gStyle->SetOptStat(1111);
262 obj=disp6.DrawCopy("hist");
263 ((MHCamera*)obj)->AddNotify(*cam);
264
265 c2->cd(4);
266 obj->Draw();
267
268 c2->cd(2);
269 gStyle->SetOptStat(1101);
270 obj=disp7.DrawCopy("hist");
271 ((MHCamera*)obj)->AddNotify(*cam);
272
273 c2->cd(5);
274 obj->Draw();
275
276 c2->cd(3);
277 gStyle->SetOptStat(1101);
278 obj=disp8.DrawCopy("hist");
279 ((MHCamera*)obj)->AddNotify(*cam);
280
281 c2->cd(6);
282 obj->Draw();
283
284 TCanvas *c3 = &d2->AddTab("Pedestals");
285 c3->Divide(2, 2);
286
287 c3->cd(1);
288 gStyle->SetOptStat(1111);
289 obj=disp9.DrawCopy("hist");
290 ((MHCamera*)obj)->AddNotify(*cam);
291
292 c3->cd(3);
293 obj->Draw();
294
295 c3->cd(2);
296 gStyle->SetOptStat(1111);
297 obj=disp10.DrawCopy("hist");
298 ((MHCamera*)obj)->AddNotify(*cam);
299
300 c3->cd(4);
301 obj->Draw();
302
303 TCanvas *c4 = &d2->AddTab("Reduced Charges");
304 c4->Divide(2,1);
305
306 c4->cd(1);
307 gStyle->SetOptStat(1111);
308 obj=disp11.DrawCopy("hist");
309 ((MHCamera*)obj)->AddNotify(*cam);
310
311 c4->cd(3);
312 obj->Draw();
313
314 TCanvas *c5 = &d2->AddTab("F-Factor Method");
315 c5->Divide(2, 2);
316
317 c5->cd(1);
318 gStyle->SetOptStat(1111);
319 obj=disp12.DrawCopy("hist");
320 ((MHCamera*)obj)->AddNotify(*cam);
321
322 c5->cd(3);
323 obj->Draw();
324
325 c5->cd(2);
326 gStyle->SetOptStat(1101);
327 obj=disp13.DrawCopy("hist");
328 ((MHCamera*)obj)->AddNotify(*cam);
329
330 c5->cd(4);
331 obj->Draw();
332
333 TCanvas *c6 = &d2->AddTab("Blind Pixel Method");
334 c6->Divide(2, 2);
335
336 c6->cd(1);
337 gStyle->SetOptStat(1111);
338 obj=disp14.DrawCopy("hist");
339 ((MHCamera*)obj)->AddNotify(*cam);
340
341 c6->cd(3);
342 obj->Draw();
343
344 c6->cd(2);
345 gStyle->SetOptStat(1101);
346 obj=disp15.DrawCopy("hist");
347 ((MHCamera*)obj)->AddNotify(*cam);
348
349 c6->cd(4);
350 obj->Draw();
351
352}
353
Note: See TracBrowser for help on using the repository browser.