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

Last change on this file since 6157 was 4058, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.2 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-2004
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////////
26//
27// sumcurrents.C
28// =============
29//
30// This is a demonstration macro to display mean DC currents for all pixels.
31// The input is cc report file. The output are histograms and plots.
32// Using the MDirIter functionality you can process more than one file
33// in one or more directories. For more information see MDirIter.
34//
35///////////////////////////////////////////////////////////////////////////
36
37void ProcessFile(TString fname)
38{
39 //
40 // Create a empty Parameter List and an empty Task List
41 // The tasklist is identified in the eventloop by its name
42 //
43 MParList plist;
44
45 MTaskList tlist;
46 plist.AddToList(&tlist);
47
48 //
49 // Now setup the tasks and tasklist:
50 // ---------------------------------
51 //
52
53 // Create the magic geometry
54 MGeomCamMagic geom;
55 plist.AddToList(&geom);
56
57 // First Task: Read file with image parameters
58 // (created with the star.C macro)
59 MReportFileRead read(fname);
60 read.SetHasNoHeader();
61 read.AddToList("MReportCurrents");
62 tlist.AddToList(&read);
63
64 // create a task to fill a histogram
65 MFillH fill("MHCamEvent", "MCameraDC");
66 tlist.AddToList(&fill);
67
68 //
69 // Create and setup the eventloop
70 //
71 MEvtLoop evtloop;
72 evtloop.SetParList(&plist);
73
74 //
75 // Execute your analysis
76 //
77 if (!evtloop.Eventloop())
78 return;
79
80 tlist.PrintStatistics();
81
82 //
83 // Now display the result of the loop
84 //
85 MHCamEvent &h2 = *(MHCamEvent*)plist->FindObject("MHCamEvent");
86 MHCamera &h = *(MHCamera*)h2.GetHistByName("sum");
87;
88
89 TCanvas *c = MH::MakeDefCanvas();
90 c->Divide(3, 2);
91
92 MHCamera *disp1=h.Clone();
93 MHCamera *disp2=h.Clone();
94 MHCamera *disp3=h.Clone();
95 disp2->SetCamContent(h, 1);
96 disp3->SetCamContent(h, 2);
97
98 disp1->SetYTitle("I [nA]");
99 disp2->SetYTitle("\\sigma_{I} [\\mu A]");
100 disp3->SetYTitle("\\sigma_{I} [%]");
101 disp1->SetName("Currents;avg");
102 disp2->SetName("Currents;err");
103 disp3->SetName("Currents;rel");
104 disp1->SetTitle("Currents Average");
105 disp2->SetTitle("Currents error");
106 disp3->SetTitle("Currents relative error");
107
108 c->cd(1);
109 TText text(0.1, 0.95, &fname[fname.Last('/')+1]);
110 text.SetTextSize(0.03);
111 text.DrawClone();
112 gPad->SetBorderMode(0);
113 gPad->Divide(1,1);
114 gPad->cd(1);
115 gPad->SetLogy();
116 disp1->Draw();
117 disp1->SetBit(kCanDelete);
118 c->cd(2);
119 gPad->SetBorderMode(0);
120 gPad->Divide(1,1);
121 gPad->cd(1);
122 gPad->SetLogy();
123 disp2->Draw();
124 disp2->SetBit(kCanDelete);
125 c->cd(3);
126 gPad->SetBorderMode(0);
127 gPad->Divide(1,1);
128 gPad->cd(1);
129 gPad->SetLogy();
130 disp3->Draw();
131 disp3->SetBit(kCanDelete);
132 c->cd(4);
133 gPad->SetBorderMode(0);
134 disp1->Draw("EPhist");
135 c->cd(5);
136 gPad->SetBorderMode(0);
137 gPad->SetLogy();
138 disp2->Draw("Phist");
139 c->cd(6);
140 gPad->SetBorderMode(0);
141 gPad->SetLogy();
142 disp3->Draw("Phist");
143
144 c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
145 c->SaveAs(fname(0, fname.Last('.')+1) + "root");
146}
147
148void sumcurrents(const char *dirname=".")
149{
150 MDirIter Next;
151 Next.AddDirectory(dirname, "dc_*.txt", -1);
152
153 TString fname;
154 while (1)
155 {
156 fname = Next();
157 if (fname.IsNull())
158 break;
159
160 ProcessFile(fname);
161 }
162}
Note: See TracBrowser for help on using the repository browser.