source: tags/Mars-V0.8.5/macros/estimate.C

Last change on this file was 1634, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 7.0 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 estimate()
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 MReadMarsFile read("Events");
48 read.DisableAutoScheme();
49 /*
50 read.AddFile("star.root");
51 read.AddFile("star2.root");
52 */
53 read.AddFile("gammas.root");
54
55 // Create a filter for the gamma events
56 MFParticleId fgamma("MMcEvt", '=', kGAMMA);
57
58 MTaskList tlist2;
59 tlist2.SetFilter(&fgamma);
60
61 MEnergyEstParam eest;
62 eest.Add("MHillasSrc");
63
64 //
65 // Use this to change the binnign of the histograms to CT1-style
66 //
67 Bool_t usect1 = kTRUE;
68
69 //
70 // Here you set up the coefficients of the parametrization
71 // (MEnergyEstParam)
72 //
73 TArrayD fA(5);
74 fA[0] = -2539; // [cm]
75 fA[1] = 900; // [cm]
76 fA[2] = 17.5; // [cm]
77 fA[3] = 4;
78 fA[4] = 58.3;
79
80 TArrayD fB(7);
81 fB[0] = -8.64; // [GeV]
82 fB[1] = -0.069; // [GeV]
83 fB[2] = 0.00066; // [GeV]
84 fB[3] = 0.033; // [GeV]
85 fB[4] = 0.000226; // [GeV]
86 fB[5] = 4.14e-8; // [GeV]
87 fB[6] = -0.06;
88
89 eest.SetCoeffA(fA);
90 eest.SetCoeffB(fB);
91
92 MH3 mh3e("MMcEvt.fEnergy", "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
93 MH3 mh3i("MMcEvt.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
94 MH3 mh3eo("MMcEvt.fEnergy", "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
95 MH3 mh3io("MMcEvt.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
96
97 MH3 mh3e2("MEnergyEst.fEnergy", "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
98 MH3 mh3i2("MEnergyEst.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
99 MH3 mh3eo2("MEnergyEst.fEnergy", "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
100 MH3 mh3io2("MEnergyEst.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
101
102 MH3 mhe("MMcEvt.fEnergy", "MEnergyEst.fEnergy");
103 MH3 mhi("MMcEvt.fImpact/100", "MEnergyEst.fImpact/100");
104
105 mh3e.SetName("HistEnergy");
106 mh3i.SetName("HistImpact");
107 mh3eo.SetName("HistEnergyOffset");
108 mh3io.SetName("HistImpactOffset");
109
110 mh3e2.SetName("HistEnergy");
111 mh3i2.SetName("HistImpact");
112 mh3eo2.SetName("HistEnergyOffset");
113 mh3io2.SetName("HistImpactOffset");
114
115 mhe.SetName("HistEE");
116 mhi.SetName("HistII");
117
118 MFillH hfille(&mh3e);
119 MFillH hfilli(&mh3i);
120 MFillH hfilleo(&mh3eo);
121 MFillH hfillio(&mh3io);
122
123 MFillH hfille2(&mh3e2);
124 MFillH hfilli2(&mh3i2);
125 MFillH hfilleo2(&mh3eo2);
126 MFillH hfillio2(&mh3io2);
127
128 MFillH hfillee(&mhe);
129 MFillH hfillii(&mhi);
130
131 MBinning binsex("BinningHistEnergyX");
132 MBinning binsey("BinningHistEnergyY");
133 MBinning binsix("BinningHistImpactX");
134 MBinning binsiy("BinningHistImpactY");
135 MBinning binseox("BinningHistEnergyOffsetX");
136 MBinning binseoy("BinningHistEnergyOffsetY");
137 MBinning binsiox("BinningHistImpactOffsetX");
138 MBinning binsioy("BinningHistImpactOffsetY");
139 MBinning binseex("BinningHistEEX");
140 MBinning binsiix("BinningHistIIX");
141 MBinning binseey("BinningHistEEY");
142 MBinning binsiiy("BinningHistIIY");
143
144 binsex.SetEdgesLog(50, usect1 ? 300: 10, usect1 ? 50000 : 1e4);
145 binsey.SetEdges(50, 0, 1.75);
146 binseox.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 1e4);
147 binseoy.SetEdges(50, -1.75, 1.75);
148
149 binsix.SetEdges(50, 0, usect1 ? 450 : 300);
150 binsiy.SetEdges(50, 0, 1.75);
151 binsiox.SetEdges(50, 0, usect1 ? 450 : 300);
152 binsioy.SetEdges(50, -1.75, 1.75);
153
154 binseex.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 15e3);
155 binseey.SetEdgesLog(50, usect1 ? 300 : 1, usect1 ? 50000 : 2e3);
156 binsiix.SetEdges(50, 0, usect1 ? 450 : 300);
157 binsiiy.SetEdges(50, 0, usect1 ? 450 : 150);
158
159 plist.AddToList(&binsex);
160 plist.AddToList(&binsey);
161 plist.AddToList(&binsix);
162 plist.AddToList(&binsiy);
163 plist.AddToList(&binseox);
164 plist.AddToList(&binseoy);
165 plist.AddToList(&binsiox);
166 plist.AddToList(&binsioy);
167 plist.AddToList(&binseex);
168 plist.AddToList(&binseey);
169 plist.AddToList(&binsiix);
170 plist.AddToList(&binsiiy);
171
172 //
173 // Setup tasklists
174 //
175 tlist.AddToList(&read);
176 tlist.AddToList(&fgamma);
177 tlist.AddToList(&tlist2);
178
179 tlist2.AddToList(&eest);
180 tlist2.AddToList(&hfille);
181 tlist2.AddToList(&hfilli);
182 tlist2.AddToList(&hfilleo);
183 tlist2.AddToList(&hfillio);
184
185 tlist2.AddToList(&hfille2);
186 tlist2.AddToList(&hfilli2);
187 tlist2.AddToList(&hfilleo2);
188 tlist2.AddToList(&hfillio2);
189
190 tlist2.AddToList(&hfillee);
191 tlist2.AddToList(&hfillii);
192
193 /*
194 MPrint p("MEnergyEst");
195 tlist2.AddToList(&p);
196 */
197
198 //
199 // Create and setup the eventloop
200 //
201 MProgressBar bar;
202
203 MEvtLoop evtloop;
204 evtloop.SetProgressBar(&bar);
205 evtloop.SetParList(&plist);
206
207 //
208 // Execute your analysis
209 //
210 if (!evtloop.Eventloop())
211 return;
212
213 tlist.PrintStatistics();
214
215 const TString text = "\\sqrt{<y>}=%.0f%%";
216
217 TCanvas *c=new TCanvas("Est1", "Estimates vs. E_{true}");
218 c->Divide(2,2);
219 c->cd(1);
220 mh3i.DrawClone("PROFXnonew");
221 TLatex *t = new TLatex(180, 1.6, Form(text, sqrt(mh3i.GetHist().GetMean(2))*100));
222 t->Draw();
223 c->cd(2);
224 mh3e.DrawClone("PROFXnonew");
225 t = new TLatex(2.7, 1.6, Form(text, sqrt(mh3e.GetHist().GetMean(2))*100));
226 t->Draw();
227 c->cd(3);
228 mh3io.DrawClone("PROFXnonew");
229 c->cd(4);
230 mh3eo.DrawClone("PROFXnonew");
231
232 c=new TCanvas("Est2", "Estimates vs. E_{est}");
233 c->Divide(2,2);
234 c->cd(1);
235 mh3i2.DrawClone("PROFXnonew");
236 c->cd(2);
237 mh3e2.DrawClone("PROFXnonew");
238 c->cd(3);
239 mh3io2.DrawClone("PROFXnonew");
240 c->cd(4);
241 mh3eo2.DrawClone("PROFXnonew");
242
243 mhe.DrawClone("PROFX");
244 mhi.DrawClone("PROFX");
245}
Note: See TracBrowser for help on using the repository browser.