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 | void ProcessFile(TString fname)
|
---|
26 | {
|
---|
27 | //
|
---|
28 | // Create a empty Parameter List and an empty Task List
|
---|
29 | // The tasklist is identified in the eventloop by its name
|
---|
30 | //
|
---|
31 | MParList plist;
|
---|
32 |
|
---|
33 | MTaskList tlist;
|
---|
34 | plist.AddToList(&tlist);
|
---|
35 |
|
---|
36 | //
|
---|
37 | // Now setup the tasks and tasklist:
|
---|
38 | // ---------------------------------
|
---|
39 | //
|
---|
40 |
|
---|
41 | MGeomCamMagic geom;
|
---|
42 | plist.AddToList(&geom);
|
---|
43 |
|
---|
44 | // First Task: Read file with image parameters
|
---|
45 | // (created with the star.C macro)
|
---|
46 | MReportFileRead read(fname);
|
---|
47 | read.SetHasNoHeader();
|
---|
48 | read.AddToList("MReportCurrents");
|
---|
49 | tlist.AddToList(&read);
|
---|
50 |
|
---|
51 | MFillH fill("MHCamEvent", "MCameraDC");
|
---|
52 | tlist.AddToList(&fill);
|
---|
53 |
|
---|
54 | //
|
---|
55 | // Create and setup the eventloop
|
---|
56 | //
|
---|
57 | MEvtLoop evtloop;
|
---|
58 | evtloop.SetParList(&plist);
|
---|
59 |
|
---|
60 | //
|
---|
61 | // Execute your analysis
|
---|
62 | //
|
---|
63 | if (!evtloop.Eventloop())
|
---|
64 | return;
|
---|
65 |
|
---|
66 | tlist.PrintStatistics();
|
---|
67 |
|
---|
68 | MHCamEvent &h2 = *(MHCamEvent*)plist->FindObject("MHCamEvent");
|
---|
69 | MHCamera &h = *(MHCamera*)h2.GetHistByName("sum");
|
---|
70 | ;
|
---|
71 |
|
---|
72 | TCanvas *c = MH::MakeDefCanvas();
|
---|
73 | c->Divide(3, 2);
|
---|
74 |
|
---|
75 | MHCamera *disp1=h.Clone();
|
---|
76 | MHCamera *disp2=h.Clone();
|
---|
77 | MHCamera *disp3=h.Clone();
|
---|
78 | disp2->SetCamContent(h, 1);
|
---|
79 | disp3->SetCamContent(h, 2);
|
---|
80 |
|
---|
81 | disp1->SetYTitle("I [nA]");
|
---|
82 | disp2->SetYTitle("\\sigma_{I} [nA]");
|
---|
83 | disp3->SetYTitle("\\sigma_{I} [%]");
|
---|
84 | disp1->SetName("Currents;avg");
|
---|
85 | disp2->SetName("Currents;err");
|
---|
86 | disp3->SetName("Currents;rel");
|
---|
87 | disp1->SetTitle("Currents Average");
|
---|
88 | disp2->SetTitle("Currents error");
|
---|
89 | disp3->SetTitle("Currents relative error");
|
---|
90 |
|
---|
91 | c->cd(1);
|
---|
92 | TText text(0.1, 0.95, &fname[fname.Last('/')+1]);
|
---|
93 | text.SetTextSize(0.03);
|
---|
94 | text.DrawClone();
|
---|
95 | gPad->SetBorderMode(0);
|
---|
96 | gPad->Divide(1,1);
|
---|
97 | gPad->cd(1);
|
---|
98 | gPad->SetLogy();
|
---|
99 | disp1->Draw();
|
---|
100 | disp1->SetBit(kCanDelete);
|
---|
101 | c->cd(2);
|
---|
102 | gPad->SetBorderMode(0);
|
---|
103 | gPad->Divide(1,1);
|
---|
104 | gPad->cd(1);
|
---|
105 | gPad->SetLogy();
|
---|
106 | disp2->Draw();
|
---|
107 | disp2->SetBit(kCanDelete);
|
---|
108 | c->cd(3);
|
---|
109 | gPad->SetBorderMode(0);
|
---|
110 | gPad->Divide(1,1);
|
---|
111 | gPad->cd(1);
|
---|
112 | gPad->SetLogy();
|
---|
113 | disp3->Draw();
|
---|
114 | disp3->SetBit(kCanDelete);
|
---|
115 | c->cd(4);
|
---|
116 | gPad->SetBorderMode(0);
|
---|
117 | disp1->Draw("EPhist");
|
---|
118 | c->cd(5);
|
---|
119 | gPad->SetBorderMode(0);
|
---|
120 | gPad->SetLogy();
|
---|
121 | disp2->Draw("Phist");
|
---|
122 | c->cd(6);
|
---|
123 | gPad->SetBorderMode(0);
|
---|
124 | gPad->SetLogy();
|
---|
125 | disp3->Draw("Phist");
|
---|
126 |
|
---|
127 | c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
|
---|
128 | c->SaveAs(fname(0, fname.Last('.')+1) + "root");
|
---|
129 | }
|
---|
130 |
|
---|
131 | // -------------------------------------------------------------------------
|
---|
132 | //
|
---|
133 | // plot.C
|
---|
134 | //
|
---|
135 | // This macro shows how to fill and display a histogram using Mars
|
---|
136 | //
|
---|
137 | void sumcurrents(const char *dirname=".")
|
---|
138 | {
|
---|
139 | MDirIter Next;
|
---|
140 | Next.AddDirectory(dirname, "dc_*.txt", -1);
|
---|
141 |
|
---|
142 | TString fname;
|
---|
143 | while (1)
|
---|
144 | {
|
---|
145 | fname = Next();
|
---|
146 | if (fname.IsNull())
|
---|
147 | break;
|
---|
148 |
|
---|
149 | ProcessFile(fname);
|
---|
150 | }
|
---|
151 | }
|
---|