source: trunk/MagicSoft/Mars/macros/sumeventsrms.C@ 6491

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