source: trunk/MagicSoft/Mars/macros/sumpedestalrms.C@ 2258

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