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

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