source: trunk/FACT++/spectrum/display.C@ 19932

Last change on this file since 19932 was 19909, checked in by tbretz, 5 years ago
Minor convenience updates
File size: 9.2 KB
Line 
1void display(const char *filename="spectrum.hist.root")
2{
3 gEnv->SetValue("Canvas.ShowEventStatus", 1);
4 gEnv->SetValue("TFile.Recover", 0);
5
6 // --------------------------------
7
8 TFile file(filename);
9 if (file.IsZombie())
10 return;
11
12 // --------------------------------
13
14 cout << endl;
15
16 file.ReadAll();
17 file.ls();
18
19 cout << endl;
20
21 // --------------------------------
22
23 TH1D *h1 = 0;
24 TH2D *h2 = 0;
25
26 TCanvas *c = 0;
27
28 gStyle->SetErrorX(0.5);
29
30 TF1 fx("fx", "x", 0, 90);
31 fx.SetLineStyle(kDashed);
32 fx.SetLineColor(kBlack);
33
34 TF1 f0("f0", "[0]", 0, 90);
35 f0.SetParameter(0, 0);
36 f0.SetLineStyle(kDashed);
37 f0.SetLineColor(kBlack);
38
39 TF1 f("spectrum", "[0]*pow(pow(10, x)/1000, -[1])", 2.8, 4.5);
40 f.SetLineColor(kBlue);
41
42 // --------------------------------
43
44 c = new TCanvas("Zd Weights", "Zd Weights");
45 c->Divide(2,2);
46 c->cd(1);
47 file.GetObject("Zd/OnTime", h1);
48 h1->SetTitle("OnTime (hist), Scaled excess (markers)");
49 double time = h1->Integral();
50 h1->DrawCopy();
51 file.GetObject("Data/Theta/Excess", h1);
52 h1->Scale(time/h1->Integral());
53 h1->DrawCopy("same");
54 c->cd(2);
55 file.GetObject("Zd/CountN", h1);
56 h1->DrawCopy("P");
57 c->cd(3);
58 file.GetObject("Zd/ZdWeight", h1);
59 h1->DrawCopy("P");
60
61 // --------------------------------
62
63 c = new TCanvas("Zenith Angle", "Zenith Angle");
64 c->Divide(2,2);
65
66 c->cd(1);
67 gPad->SetGridy();
68 file.GetObject("MC/theta/BiasW", h1);
69 h1->DrawCopy("P");
70 f0.DrawCopy("same");
71 c->cd(2);
72 gPad->SetGridy();
73 file.GetObject("MC/theta/ResolutionW", h1);
74 h1->DrawCopy("][ P");
75 f0.DrawCopy("same");
76
77 c->cd(3);
78 gPad->SetGridy();
79 file.GetObject("MC/theta/TriggerEfficiencyW", h1);
80 h1->SetTitle("Trigger (black) and Cut Efficiency (blue)");
81 h1->DrawCopy("P");
82 file.GetObject("MC/theta/CutEfficiencyW", h1);
83 h1->SetMarkerColor(kBlue);
84 h1->DrawCopy("P same");
85
86 c->cd(4);
87 gPad->SetLogy();
88 file.GetObject("Data/Theta/Spectrum", h1);
89 h1->DrawCopy("P");
90 file.GetObject("Data/Theta/RolkeUL", h1);
91 h1->SetMarkerStyle(23);
92 h1->DrawCopy("P same");
93
94 // --------------------------------
95
96 c = new TCanvas("Migration", "Migration");
97 c->Divide(2,1);
98 c->cd(1);
99 file.GetObject("MC/dense/Migration", h2);
100 h2->DrawCopy("colz");
101 fx.DrawCopy("same");
102 c->cd(2);
103 file.GetObject("MC/sparse/Migration", h2);
104 h2->DrawCopy("colz");
105 fx.DrawCopy("same");
106
107 // --------------------------------
108 c = new TCanvas("Resolution", "Resolution");
109 c->Divide(2,2);
110 c->cd(1);
111 gPad->SetGridy();
112 file.GetObject("MC/dense/TrueEnergy/BiasW", h1);
113 h1->DrawCopy("P");
114 f0.DrawCopy("same");
115 c->cd(2);
116 gPad->SetGridy();
117 file.GetObject("MC/dense/EstimatedEnergy/BiasW", h1);
118 h1->DrawCopy("P");
119 f0.DrawCopy("same");
120 c->cd(3);
121 file.GetObject("MC/dense/TrueEnergy/ResolutionW", h1);
122 h1->DrawCopy("][ P");
123 c->cd(4);
124 file.GetObject("MC/dense/EstimatedEnergy/ResolutionW", h1);
125 h1->DrawCopy("][ P");
126
127 // --------------------------------
128
129 c = new TCanvas("Efficiency", "Efficiency");
130 c->Divide(2,2);
131 c->cd(1);
132 file.GetObject("MC/dense/TrueEnergy/TriggerEfficiencyW", h1);
133 h1->SetTitle("Trigger (black) and Cut (blue) efficiency");
134 h1->DrawCopy("P X0");
135 h1->DrawCopy("C hist same");
136 file.GetObject("MC/dense/TrueEnergy/CutEfficiencyW", h1);
137 h1->SetLineColor(kBlue);
138 h1->DrawCopy("P X0 same");
139 h1->DrawCopy("C hist same");
140
141 c->cd(2);
142 gPad->SetLogy();
143 file.GetObject("MC/dense/TrueEnergy/EffectiveAreaW", h1);
144 h1->SetTitle("Effective Collection Area");
145 h1->DrawCopy("P X0");
146 h1->DrawCopy("C hist same");
147
148 c->cd(3);
149
150 gPad->SetLogy();
151 file.GetObject("MC/dense/TrueEnergy/SimFluxW", h1);
152 h1->SetTitle("Simulated (blk), Triggered (blk), Cut (blu), Bg (blu), Reconstructed (red) spectrum");
153 h1->DrawCopy("P X0");
154 h1->DrawCopy("C hist same");
155
156 gPad->SetLogy();
157 file.GetObject("MC/dense/TrueEnergy/TrigFluxW", h1);
158 h1->DrawCopy("P X0 same");
159 h1->DrawCopy("C hist same");
160
161 gPad->SetLogy();
162 file.GetObject("MC/dense/TrueEnergy/ExcessFluxW", h1);
163 h1->DrawCopy("P X0 same");
164 h1->DrawCopy("C hist same");
165
166 TSpline3 spline(h1);
167 spline.SetLineColor(kBlue);
168 spline.DrawClone("same");
169
170 float max = 0;
171 float xmax = 0;
172 for (float x=2.5; x<5; x+=0.01)
173 {
174 if (spline.Eval(x)>max)
175 {
176 xmax = x;
177 max = spline.Eval(x);
178 }
179 }
180
181 TMarker m;
182 m.SetMarkerColor(kBlue);
183 m.SetMarkerStyle(kStar);
184 m.DrawMarker(xmax, max);
185
186 cout << endl;
187 cout << "Threshold Max: " << pow(10, xmax) << endl;
188 cout << endl;
189
190 file.GetObject("MC/dense/EstimatedEnergy/ExcessFluxW", h1);
191 h1->SetLineColor(kRed);
192 h1->DrawCopy("X0 P same");
193 h1->DrawCopy("C hist same");
194
195 file.GetObject("MC/dense/TrueEnergy/BackgroundFluxW", h1);
196 h1->SetLineColor(kBlue);
197 h1->DrawCopy("X0 P same");
198 h1->DrawCopy("C hist same");
199
200 c->cd(4);
201 gPad->SetLogy();
202 file.GetObject("Data/Energy/Differential/Excess", h1);
203 h1->SetTitle("Measured Signal (blue) / Simulated Excess (black)");
204 h1->SetLineColor(kBlue);
205 h1->DrawCopy("P X0");
206 h1->DrawCopy("C hist same");
207 double scale = h1->Integral();
208 file.GetObject("MC/sparse/EstimatedEnergy/ExcessFluxW", h1);
209 h1->Scale(scale/h1->Integral());
210 h1->DrawCopy("X0 P same");
211 h1->DrawCopy("C hist same");
212
213 // --------------------------------
214 f0.SetLineColor(kRed);
215 // --------------------------------
216
217 c = new TCanvas("Integral Spectrum", "Integral Spectrum");
218 c->Divide(2,2);
219 c->cd(4);
220 gPad->SetLogy();
221 file.GetObject("Data/Energy/Differential/IntegratedSpectrum", h1);
222 h1->SetLineColor(kGray);
223 h1->SetMarkerColor(kGray);
224 if (h1->GetMinimum()<=0)
225 {
226 h1->SetMinimum(h1->GetMinimum(0)*0.1);
227 cout << "WARNING: Integral Spectrum contains negative flux points!\n" << endl;
228 }
229 h1->DrawCopy("P");
230 file.GetObject("Data/Energy/Integral/Spectrum", h1);
231 h1->DrawCopy("P same");
232
233 f.SetParameters(h1->GetMaximum(), 1.4);
234 h1->Fit(&f, "N0EM", "");
235 f.DrawCopy("same");
236
237 cout << endl;
238 cout << "ChiSq " << f.GetChisquare() << " / " << f.GetNDF() << endl;
239 cout << "Prob. " << f.GetProb() << endl;
240 cout << endl;
241
242 file.GetObject("Data/Energy/Integral/RolkeUL", h1);
243 h1->SetMarkerStyle(23);
244 h1->DrawCopy("P same");
245
246 //file.GetObject("Data/Energy/Integral/RolkeLL", h1);
247 //h1->SetMarkerStyle(22);
248 //h1->DrawCopy("P same");
249
250 c->cd(1);
251 gPad->SetGridx();
252 file.GetObject("Data/Energy/Integral/SigmaFlux", h1);
253 h1->SetMaximum(5);
254 h1->SetMarkerStyle(kFullDotLarge);
255 h1->DrawCopy("P");
256 f0.SetParameter(0, 1);
257 f0.DrawCopy("same");
258
259 c->cd(3);
260 gPad->SetGridx();
261 file.GetObject("Data/Energy/Integral/BackgroundI", h1);
262 h1->SetTitle("Integral Signal (black), Background (red) and Excess (blue)");
263 h1->Scale(5);
264 h1->SetMaximum(30);
265 h1->SetMarkerColor(kRed);
266 h1->SetLineColor(kRed);
267 h1->DrawCopy("P");
268 file.GetObject("Data/Energy/Integral/SignalI", h1);
269 h1->DrawCopy("P same");
270 file.GetObject("Data/Energy/Integral/ExcessI", h1);
271 h1->SetMarkerColor(kBlue);
272 h1->SetLineColor(kBlue);
273 h1->DrawCopy("P same");
274
275 f0.SetParameter(0, 10);
276 f0.DrawCopy("same");
277
278 // --------------------------------
279
280 c = new TCanvas("Differential Spectrum", "Differential Spectrum");
281 c->Divide(2,2);
282 c->cd(4);
283 gPad->SetLogy();
284 file.GetObject("Data/Energy/Differential/Spectrum", h1);
285 if (h1->GetMinimum()<=0)
286 {
287 h1->SetMinimum(h1->GetMinimum(0)*0.1);
288 cout << "WARNING: Differential Spectrum contains negative flux points!\n" << endl;
289 }
290 h1->DrawCopy("P");
291
292 f.SetParameters(h1->GetMaximum(), 2.4);
293 h1->Fit(&f, "N0EM", "");
294 f.DrawCopy("same");
295
296 cout << endl;
297 cout << "ChiSq " << f.GetChisquare() << " / " << f.GetNDF() << endl;
298 cout << "Prob. " << f.GetProb() << endl;
299 cout << endl;
300
301 file.GetObject("Data/Energy/Differential/RolkeUL", h1);
302 h1->SetMarkerStyle(23);
303 h1->DrawCopy("P same");
304
305 //file.GetObject("Data/Energy/Differential/RolkeLL", h1);
306 //h1->SetMarkerStyle(22);
307 //h1->DrawCopy("P same");
308
309 //file.GetObject("Data/Energy/Differential/FeldmanCousins", h1);
310 //h1->SetMarkerColor(kBlue);
311 //h1->SetMarkerStyle(23);
312 //h1->DrawCopy("P same");
313
314 c->cd(1);
315 gPad->SetGridx();
316 file.GetObject("Data/Energy/Differential/SigmaFlux", h1);
317 h1->SetMaximum(5);
318 h1->SetMarkerStyle(kFullDotLarge);
319 h1->DrawCopy("P");
320 f0.SetParameter(0, 1);
321 f0.DrawCopy("same");
322
323 c->cd(3);
324 gPad->SetGridx();
325 file.GetObject("Data/Energy/Differential/Background", h1);
326 h1->SetTitle("Differential Signal (black), Background (red) and Excess (blue)");
327 h1->Scale(5);
328 h1->SetMaximum(30);
329 h1->SetMarkerColor(kRed);
330 h1->SetLineColor(kRed);
331 h1->DrawCopy("P");
332 file.GetObject("Data/Energy/Differential/Signal", h1);
333 h1->DrawCopy("P same");
334 file.GetObject("Data/Energy/Differential/Excess", h1);
335 h1->SetMarkerColor(kBlue);
336 h1->SetLineColor(kBlue);
337 h1->DrawCopy("P same");
338
339 f0.SetParameter(0, 10);
340 f0.DrawCopy("same");
341}
Note: See TracBrowser for help on using the repository browser.