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

Last change on this file since 2203 was 2192, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.9 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
25void 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 MReadCurrents read(fname);
47 tlist.AddToList(&read);
48
49 MFillH fill("MHCurrents");
50 tlist.AddToList(&fill);
51
52 //
53 // Create and setup the eventloop
54 //
55 MEvtLoop evtloop;
56 evtloop.SetParList(&plist);
57
58 //
59 // Execute your analysis
60 //
61 if (!evtloop.Eventloop())
62 return;
63
64 tlist.PrintStatistics();
65
66 MHCurrents &h = *(MHCurrents*)plist->FindObject("MHCurrents");
67
68 TCanvas *c = MH::MakeDefCanvas();
69 c->Divide(3, 2);
70
71 MCamDisplay *disp1=new MCamDisplay(&geom);
72 MCamDisplay *disp2=new MCamDisplay(&geom);
73 MCamDisplay *disp3=new MCamDisplay(&geom);
74 disp1->Fill(h.GetSum());
75 disp2->Fill(h.GetRms());
76
77 TArrayF arr(577);
78 for (int i=0;i<577;i++)
79 {
80 TArrayF &r = h.GetRms();
81 TArrayF &v = h.GetSum();
82 arr[i] = (v[i]==0 ? 0 : r[i]/v[i]);
83 }
84 disp3->Fill(arr);
85
86 c->cd(1);
87 gPad->SetBorderMode(0);
88 gPad->Divide(1,1);
89 gPad->cd(1);
90 gPad->SetLogz();
91 disp1->Draw();
92 disp1->SetBit(kCanDelete);
93 c->cd(2);
94 gPad->SetBorderMode(0);
95 gPad->Divide(1,1);
96 gPad->cd(1);
97 gPad->SetLogz();
98 disp2->Draw();
99 disp2->SetBit(kCanDelete);
100 c->cd(3);
101 gPad->SetBorderMode(0);
102 gPad->Divide(1,1);
103 gPad->cd(1);
104 gPad->SetLogz();
105 disp3->Draw();
106 disp3->SetBit(kCanDelete);
107 c->cd(4);
108 gPad->SetBorderMode(0);
109 h.GetHist().SetStats(kFALSE);
110 h.GetHist().DrawCopy();
111 c->cd(5);
112 gPad->SetBorderMode(0);
113 gPad->SetLogy();
114 TH1F h1("currents;rms", "Currents Rms", 577, -0.5, 576.5);
115 h1.SetXTitle("Pixel Index");
116 h1.SetStats(kFALSE);
117 for (int i=1;i<=577; i++)
118 h1.SetBinContent(i, h.GetHist().GetBinError(i));
119 h1.DrawCopy();
120 c->cd(6);
121 gPad->SetBorderMode(0);
122 gPad->SetLogy();
123 TH1F h2("currents;relerr", "Currents rel. Error [%]", 577, -0.5, 576.5);
124 h2.SetXTitle("Pixel Index");
125 h2.SetStats(kFALSE);
126 for (int i=1;i<=577; i++)
127 h2.SetBinContent(i, arr[i-1]*100);
128 h2.DrawCopy();
129
130 c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
131 c->SaveAs(fname(0, fname.Last('.')+1) + "root");
132}
133
134// -------------------------------------------------------------------------
135//
136// plot.C
137//
138// This macro shows how to fill and display a histogram using Mars
139//
140void sumcurrents(const char *dirname="/home/MAGIC/online_data/ccdata/")
141{
142 MDirIter Next;
143 Next.AddDirectory(dirname, "dc_*.txt", -1);
144
145 TString fname;
146 while (1)
147 {
148 fname = Next();
149 if (fname.IsNull())
150 break;
151
152 ProcessFile(fname);
153 }
154}
Note: See TracBrowser for help on using the repository browser.