source: trunk/MagicSoft/Mars/macros/estct1.C@ 6162

Last change on this file since 6162 was 1843, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 7.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): Thomas Bretz et al, 09/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2002
21!
22!
23\* ======================================================================== */
24
25
26void estct1()
27{
28 //
29 // This is a demonstration program which calculates the Hillas
30 // parameter out of a Magic root file (raw data file).
31 //
32
33 //
34 // Create a empty Parameter List and an empty Task List
35 // The tasklist is identified in the eventloop by its name
36 //
37 MParList plist;
38
39
40 MTaskList tlist;
41 plist.AddToList(&tlist);
42
43 //
44 // Now setup the tasks and tasklist:
45 // ---------------------------------
46 //
47 MReadTree read("Events", "~/ct1/MC_ON2.root");
48
49 //MReadMarsFile read("Events");
50 read.DisableAutoScheme();
51 /*
52 read.AddFile("star.root");
53 read.AddFile("star2.root");
54 */
55 //read.AddFile("~/ct1/MC_ON2.root");
56
57 MEnergyEstParam eest("Hillas");
58 eest.Add("HillasSrc");
59
60 //
61 // Use this to change the binnign of the histograms to CT1-style
62 //
63 Bool_t usect1 = kTRUE;
64
65 //
66 // Here you set up the coefficients of the parametrization
67 // (MEnergyEstParam)
68 //
69 TArrayD fA(5);
70 fA[0] = -3907.74; //4916.4; //-2414.75;
71 fA[1] = 1162.3; //149.549; // 1134.28;
72 fA[2] = 199.351;//-558.209; // 132.932;
73 fA[3] = 0.403192;//0.270725; //0.292845;
74 fA[4] = 121.921;//107.001; // 107.001;
75
76 TArrayD fB(7);
77 fB[0] = 677.821;//-8234.12; //-4282.25;
78 fB[1] = 11.3302;//23.2153; // 18.892;
79 fB[2] = -0.0211177;//0.416372; //0.193373;
80 fB[3] = -23.0217;//332.42; //203.803;
81 fB[4] = -0.785242;//-0.701764; //-0.534876;
82 fB[5] = 5.6413e-5;//-0.0131774; //-0.00789539;
83 fB[6] = -0.146595;//-0.162687; // 0.111913;
84
85 eest.SetCoeffA(fA);
86 eest.SetCoeffB(fB);
87
88 MH3 mh3e("MMcEvt.fEnergy", "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
89 MH3 mh3i("MMcEvt.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
90 MH3 mh3eo("MMcEvt.fEnergy", "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
91 MH3 mh3io("MMcEvt.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
92
93 MH3 mh3e2("MEnergyEst.fEnergy", "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
94 MH3 mh3i2("MEnergyEst.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
95 MH3 mh3eo2("MEnergyEst.fEnergy", "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
96 MH3 mh3io2("MEnergyEst.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
97
98 MH3 mhe("MMcEvt.fEnergy", "MEnergyEst.fEnergy");
99 MH3 mhi("MMcEvt.fImpact/100", "MEnergyEst.fImpact/100");
100
101 mh3e.SetName("HistEnergy");
102 mh3i.SetName("HistImpact");
103 mh3eo.SetName("HistEnergyOffset");
104 mh3io.SetName("HistImpactOffset");
105
106 mh3e2.SetName("HistEnergy");
107 mh3i2.SetName("HistImpact");
108 mh3eo2.SetName("HistEnergyOffset");
109 mh3io2.SetName("HistImpactOffset");
110
111 mhe.SetName("HistEE");
112 mhi.SetName("HistII");
113
114 MFillH hfille(&mh3e);
115 MFillH hfilli(&mh3i);
116 MFillH hfilleo(&mh3eo);
117 MFillH hfillio(&mh3io);
118
119 MFillH hfille2(&mh3e2);
120 MFillH hfilli2(&mh3i2);
121 MFillH hfilleo2(&mh3eo2);
122 MFillH hfillio2(&mh3io2);
123
124 MFillH hfillee(&mhe);
125 MFillH hfillii(&mhi);
126
127 MBinning binsex("BinningHistEnergyX");
128 MBinning binsey("BinningHistEnergyY");
129 MBinning binsix("BinningHistImpactX");
130 MBinning binsiy("BinningHistImpactY");
131 MBinning binseox("BinningHistEnergyOffsetX");
132 MBinning binseoy("BinningHistEnergyOffsetY");
133 MBinning binsiox("BinningHistImpactOffsetX");
134 MBinning binsioy("BinningHistImpactOffsetY");
135 MBinning binseex("BinningHistEEX");
136 MBinning binsiix("BinningHistIIX");
137 MBinning binseey("BinningHistEEY");
138 MBinning binsiiy("BinningHistIIY");
139
140 binsex.SetEdgesLog(50, usect1 ? 300: 10, usect1 ? 50000 : 1e4);
141 binsey.SetEdges(50, 0, usect1 ? 0.8 : 1.75);
142 binseox.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 1e4);
143 binseoy.SetEdges(50, usect1 ? -0.75 : -1.75, usect1 ? 0.75 : 1.75);
144
145 binsix.SetEdges(50, 0, usect1 ? 275 : 300);
146 binsiy.SetEdges(50, 0, usect1 ? 0.2 : 1.75);
147 binsiox.SetEdges(50, 0, usect1 ? 275 : 300);
148 binsioy.SetEdges(50, usect1 ? -0.75 : -1.75, usect1 ? 0.75 : 1.75);
149
150 binseex.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 15e3);
151 binseey.SetEdgesLog(50, usect1 ? 300 : 1, usect1 ? 50000 : 2e3);
152 binsiix.SetEdges(50, 0, usect1 ? 275 : 300);
153 binsiiy.SetEdges(50, 0, usect1 ? 275 : 150);
154
155 plist.AddToList(&binsex);
156 plist.AddToList(&binsey);
157 plist.AddToList(&binsix);
158 plist.AddToList(&binsiy);
159 plist.AddToList(&binseox);
160 plist.AddToList(&binseoy);
161 plist.AddToList(&binsiox);
162 plist.AddToList(&binsioy);
163 plist.AddToList(&binseex);
164 plist.AddToList(&binseey);
165 plist.AddToList(&binsiix);
166 plist.AddToList(&binsiiy);
167
168 //
169 // Setup tasklists
170 //
171 tlist.AddToList(&read);
172
173 tlist.AddToList(&eest);
174 tlist.AddToList(&hfille);
175 tlist.AddToList(&hfilli);
176 tlist.AddToList(&hfilleo);
177 tlist.AddToList(&hfillio);
178
179 tlist.AddToList(&hfille2);
180 tlist.AddToList(&hfilli2);
181 tlist.AddToList(&hfilleo2);
182 tlist.AddToList(&hfillio2);
183
184 tlist.AddToList(&hfillee);
185 tlist.AddToList(&hfillii);
186
187 /*
188 MPrint p("MEnergyEst");
189 tlist2.AddToList(&p);
190 */
191
192 //
193 // Create and setup the eventloop
194 //
195 MProgressBar bar;
196
197 MEvtLoop evtloop;
198 evtloop.SetProgressBar(&bar);
199 evtloop.SetParList(&plist);
200
201 //
202 // Execute your analysis
203 //
204 if (!evtloop.Eventloop())
205 return;
206
207 tlist.PrintStatistics();
208
209 const TString text = "\\sqrt{<y>}=%.0f%%";
210
211 char txt[1000];
212
213 TCanvas *c=new TCanvas("Est1", "Estimates vs. E_{true}");
214 c->Divide(2,2);
215 c->cd(1);
216 mh3i.DrawClone("PROFXnonew");
217 sprintf(txt, text.Data(), sqrt(mh3i.GetHist().GetMean(2))*100);
218 TLatex *t = new TLatex(180, 0.15, txt);
219 t->Draw();
220 c->cd(2);
221 mh3e.DrawClone("PROFXnonew");
222 sprintf(txt, text.Data(), sqrt(mh3e.GetHist().GetMean(2))*100);
223 t = new TLatex(3.5, 0.6, txt);
224 t->Draw();
225 c->cd(3);
226 mh3io.DrawClone("PROFXnonew");
227 c->cd(4);
228 mh3eo.DrawClone("PROFXnonew");
229
230 c=new TCanvas("Est2", "Estimates vs. E_{est}");
231 c->Divide(2,2);
232 c->cd(1);
233 mh3i2.DrawClone("PROFXnonew");
234 c->cd(2);
235 mh3e2.DrawClone("PROFXnonew");
236 c->cd(3);
237 mh3io2.DrawClone("PROFXnonew");
238 c->cd(4);
239 mh3eo2.DrawClone("PROFXnonew");
240
241 mhe.DrawClone("PROFX");
242 mhi.DrawClone("PROFX");
243}
Note: See TracBrowser for help on using the repository browser.