source: branches/MarsWobble/macros/tutorials/sumeventserr.C@ 18162

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