source: branches/AddingGoogleTestEnvironment/macros/tutorials/sumpedestalrms.C@ 20042

Last change on this file since 20042 was 7158, checked in by tbretz, 19 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 // First Task: Read file with image parameters
42 // (created with the star.C macro)
43
44 MReadMarsFile read("Events", fname);
45 read.DisableAutoScheme();
46
47 MGeomApply geomapl;
48 MCerPhotAnal2 ncalc;
49
50 tlist.AddToList(&read);
51 tlist.AddToList(&geomapl);
52 tlist.AddToList(&ncalc);
53
54 MHCamEvent hist;
55 hist.SetType(1);
56 plist.AddToList(&hist);
57
58 MFillH fill("MHCamEvent", "MPedestalCam");
59 tlist.AddToList(&fill);
60
61 //
62 // Create and setup the eventloop
63 //
64 MEvtLoop evtloop;
65 evtloop.SetParList(&plist);
66
67 //
68 // Execute your analysis
69 //
70 if (!evtloop.Eventloop())
71 return;
72
73 tlist.PrintStatistics();
74
75 TCanvas *c = MH::MakeDefCanvas();
76 c->Divide(3, 2);
77
78 MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
79 MHCamera *disp0 = h.GetHistByName();
80 MHCamera *disp1 = new MHCamera(geom, "MPedestalCam;avg", "Pedestal-RMS Avarage");
81 MHCamera *disp2 = new MHCamera(geom, "MPedestalCam;err", "Pedestal-RMS Avarage Error");
82 MHCamera *disp3 = new MHCamera(geom, "MPedestalCam;rel", "Pedestal-RMS Avarage ERR/VAL");
83 disp1->SetBit(kCanDelete);
84 disp2->SetBit(kCanDelete);
85 disp3->SetBit(kCanDelete);
86
87 disp1->SetCamContent(*disp0, 0);
88 disp2->SetCamContent(*disp0, 1);
89 disp3->SetCamContent(*disp0, 2);
90
91 disp1->SetYTitle("P_{rms} [au]");
92 disp2->SetYTitle("\\sigma_{P_{rms}} [au]");
93 disp3->SetYTitle("\\sigma_{P_{rms}} [%]");
94
95 TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
96 text.SetTextSize(0.015);
97 text.DrawClone();
98
99 c->cd(1);
100 gStyle->SetOptStat(1111);
101 disp1->Draw("hist");
102 gPad->Update();
103
104 c->cd(2);
105 gStyle->SetOptStat(1101);
106 disp2->Draw("hist");
107 gPad->Update();
108
109 c->cd(3);
110 gStyle->SetOptStat(1101);
111 disp3->Draw("hist");
112 gPad->Update();
113
114 c->cd(4);
115 gPad->SetBorderMode(0);
116 gPad->Divide(1,1);
117 gPad->cd(1);
118 disp1->Draw();
119
120 c->cd(5);
121 gPad->SetBorderMode(0);
122 gPad->Divide(1,1);
123 gPad->cd(1);
124 disp2->Draw();
125
126 c->cd(6);
127 gPad->SetBorderMode(0);
128 gPad->Divide(1,1);
129 gPad->cd(1);
130 disp3->Draw();
131
132 c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
133 //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
134}
135
136// -------------------------------------------------------------------------
137//
138// plot.C
139//
140// This macro shows how to fill and display a histogram using Mars
141//
142void sumpedestalrms(const char *dirname=".")
143{
144 MDirIter Next;
145 Next.AddDirectory(dirname, "*1947*.root", -1);
146
147 TString fname;
148 while (1)
149 {
150 fname = Next();
151 if (fname.IsNull())
152 break;
153
154 ProcessFile(fname);
155 return;
156 }
157}
Note: See TracBrowser for help on using the repository browser.