source: trunk/MagicSoft/Mars/macros/sumcurrents.C@ 2179

Last change on this file since 2179 was 2178, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25// -------------------------------------------------------------------------
26//
27// plot.C
28//
29// This macro shows how to fill and display a histogram using Mars
30//
31void sumcurrents(const char *fname="../currents/spica_center.txt")
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 MTaskList tlist;
40 plist.AddToList(&tlist);
41
42 //
43 // Now setup the tasks and tasklist:
44 // ---------------------------------
45 //
46
47 MGeomCamMagic geom;
48 plist.AddToList(&geom);
49
50 // First Task: Read file with image parameters
51 // (created with the star.C macro)
52 MReadCurrents read(fname);
53 /*
54 read.AddFile("../currents/dcs_arcturus2.dat");
55 read.AddFile("../currents/dcs_arcturus3.dat");
56 read.AddFile("../currents/dcs_arcturus4.dat");
57 read.AddFile("../currents/dcs_arcturus5.dat");
58 read.AddFile("../currents/dcs_arcturus6.dat");
59 read.AddFile("../currents/dcs_arcturus7.dat");
60 read.AddFile("../currents/dcs_arcturus8.dat");
61 read.AddFile("../currents/dcs_arcturus9.dat");
62 read.AddFile("../currents/dcs_arcturus10.dat");
63 */
64 tlist.AddToList(&read);
65
66 MFillH fill("MHCurrents");
67 tlist.AddToList(&fill);
68
69 //
70 // Create and setup the eventloop
71 //
72 MEvtLoop evtloop;
73 evtloop.SetParList(&plist);
74
75 //
76 // Execute your analysis
77 //
78 if (!evtloop.Eventloop())
79 return;
80
81 tlist.PrintStatistics();
82
83 MHCurrents &h = *(MHCurrents*)plist->FindObject("MHCurrents");
84
85 TCanvas *c = MH::MakeDefCanvas();
86 c->Divide(3, 2);
87
88 MCamDisplay *disp1=new MCamDisplay(&geom);
89 MCamDisplay *disp2=new MCamDisplay(&geom);
90 MCamDisplay *disp3=new MCamDisplay(&geom);
91 disp1->Fill(h.GetSum());
92 disp2->Fill(h.GetRms());
93
94 TArrayF arr(577);
95 for (int i=0;i<577;i++)
96 {
97 TArrayF &r = h.GetRms();
98 TArrayF &v = h.GetSum();
99 arr[i] = (r[i]==0 ? 0 : v[i]/r[i]);
100 }
101 disp3->Fill(arr);
102
103 c->cd(1);
104 gPad->SetBorderMode(0);
105 gPad->Divide(1,1);
106 gPad->cd(1);
107 gPad->SetLogz();
108 disp1->Draw();
109 disp1->SetBit(kCanDelete);
110 c->cd(2);
111 gPad->SetBorderMode(0);
112 gPad->Divide(1,1);
113 gPad->cd(1);
114 gPad->SetLogz();
115 disp2->Draw();
116 disp2->SetBit(kCanDelete);
117 c->cd(3);
118 gPad->SetBorderMode(0);
119 gPad->Divide(1,1);
120 gPad->cd(1);
121 gPad->SetLogz();
122 disp3->Draw();
123 disp3->SetBit(kCanDelete);
124 c->cd(4);
125 gPad->SetBorderMode(0);
126 h.GetHist().DrawClone();
127 c->cd(5);
128 gPad->SetBorderMode(0);
129 TH1F h1("currents;rms", "Currents Rms", 577, -0.5, 576.5);
130 for (int i=1;i<=577; i++)
131 h1.SetBinContent(i, h.GetHist().GetBinError(i));
132 h1.DrawCopy();
133 c->cd(6);
134 gPad->SetBorderMode(0);
135 TH1F h2("currents;relerr", "Currents rel. Error [%]", 577, -0.5, 576.5);
136 for (int i=1;i<=577; i++)
137 {
138 Float_t val = h.GetHist().GetBinContent(i);
139 Float_t rms = h.GetHist().GetBinError(i);
140 h2.SetBinContent(i, rms==0?0:val/rms);
141 }
142 h2.DrawCopy();
143
144 c->SaveAs("spica_center-avg.ps");
145}
Note: See TracBrowser for help on using the repository browser.