source: trunk/MagicSoft/Mars/macros/sumevents.C@ 3581

Last change on this file since 3581 was 2377, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.8 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 MFillH fill("MHCamEvent", "MCerPhotEvt");
55 tlist.AddToList(&fill);
56
57 //
58 // Create and setup the eventloop
59 //
60 MEvtLoop evtloop;
61 evtloop.SetParList(&plist);
62
63 //
64 // Execute your analysis
65 //
66 if (!evtloop.Eventloop())
67 return;
68
69 tlist.PrintStatistics();
70
71 TCanvas *c = MH::MakeDefCanvas();
72 c->Divide(3, 2);
73
74 MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
75 MHCamera *disp0 = h.GetHistByName();
76 MHCamera *disp1 = new MHCamera(geom, "MCerPhotEvt;avg", "Cerenkov Photons Avarage");
77 MHCamera *disp2 = new MHCamera(geom, "MCerPhotEvt;err", "Cerenkov Photons Error");
78 MHCamera *disp3 = new MHCamera(geom, "MCerPhotEvt;rel", "Cerenkov Photons ERR/VAL");
79 disp1->SetBit(kCanDelete);
80 disp2->SetBit(kCanDelete);
81 disp3->SetBit(kCanDelete);
82
83 disp1->SetCamContent(*disp0, 0);
84 disp2->SetCamContent(*disp0, 1);
85 disp3->SetCamContent(*disp0, 2);
86
87 disp1->SetYTitle("S [au]");
88 disp2->SetYTitle("\\sigma_{S} [au]");
89 disp3->SetYTitle("\\sigma_{S} [%]");
90
91 TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
92 text.SetTextSize(0.015);
93 text.DrawClone();
94
95 c->cd(1);
96 gStyle->SetOptStat(1111);
97 disp1->Draw("hist");
98 gPad->Update();
99
100 c->cd(2);
101 gPad->SetLogy();
102 gStyle->SetOptStat(1101);
103 disp2->Draw("hist");
104 gPad->Update();
105
106 c->cd(3);
107 gPad->SetLogy();
108 gStyle->SetOptStat(1101);
109 disp3->Draw("hist");
110 gPad->Update();
111
112 c->cd(4);
113 gPad->SetBorderMode(0);
114 gPad->Divide(1,1);
115 gPad->cd(1);
116 disp1->Draw();
117
118 c->cd(5);
119 gPad->SetBorderMode(0);
120 gPad->Divide(1,1);
121 gPad->cd(1);
122 disp2->Draw();
123
124 c->cd(6);
125 gPad->SetBorderMode(0);
126 gPad->Divide(1,1);
127 gPad->cd(1);
128 disp3->Draw();
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 sumevents(const char *dirname=".")
141{
142 MDirIter Next;
143 Next.AddDirectory(dirname, "*1947*.root", -1);
144
145 TString fname;
146 while (1)
147 {
148 fname = Next();
149 if (fname.IsNull())
150 break;
151
152 ProcessFile(fname);
153 return;
154 }
155}
Note: See TracBrowser for help on using the repository browser.