source: trunk/MagicSoft/Mars/macros/sumcurrents.C@ 2525

Last change on this file since 2525 was 2221, 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 MReadCurrents read(fname);
47 tlist.AddToList(&read);
48
49 MFillH fill("MHCamEvent", "MCurrents");
50 tlist.AddToList(&fill);
51
52 //
53 // Create and setup the eventloop
54 //
55 MEvtLoop evtloop;
56 evtloop.SetParList(&plist);
57
58 //
59 // Execute your analysis
60 //
61 if (!evtloop.Eventloop())
62 return;
63
64 tlist.PrintStatistics();
65
66 MHCamEvent &h2 = *(MHCamEvent*)plist->FindObject("MHCamEvent");
67 MHCamera &h = *(MHCamera*)h2.GetHistByName();
68;
69
70 TCanvas *c = MH::MakeDefCanvas();
71 c->Divide(3, 2);
72
73 MHCamera *disp1=h.Clone();
74 MHCamera *disp2=h.Clone();
75 MHCamera *disp3=h.Clone();
76 disp2->SetCamContent(h, 1);
77 disp3->SetCamContent(h, 2);
78
79 disp1->SetYTitle("I [nA]");
80 disp2->SetYTitle("\\sigma_{I} [nA]");
81 disp3->SetYTitle("\\sigma_{I} [%]");
82 disp1->SetName("Currents;avg");
83 disp2->SetName("Currents;err");
84 disp3->SetName("Currents;rel");
85 disp1->SetTitle("Currents Average");
86 disp2->SetTitle("Currents error");
87 disp3->SetTitle("Currents relative error");
88
89 c->cd(1);
90 TText text(0.1, 0.95, &fname[fname.Last('/')+1]);
91 text.SetTextSize(0.03);
92 text.DrawClone();
93 gPad->SetBorderMode(0);
94 gPad->Divide(1,1);
95 gPad->cd(1);
96 gPad->SetLogy();
97 disp1->Draw();
98 disp1->SetBit(kCanDelete);
99 c->cd(2);
100 gPad->SetBorderMode(0);
101 gPad->Divide(1,1);
102 gPad->cd(1);
103 gPad->SetLogy();
104 disp2->Draw();
105 disp2->SetBit(kCanDelete);
106 c->cd(3);
107 gPad->SetBorderMode(0);
108 gPad->Divide(1,1);
109 gPad->cd(1);
110 gPad->SetLogy();
111 disp3->Draw();
112 disp3->SetBit(kCanDelete);
113 c->cd(4);
114 gPad->SetBorderMode(0);
115 disp1->Draw("EPhist");
116 c->cd(5);
117 gPad->SetBorderMode(0);
118 gPad->SetLogy();
119 disp2->Draw("Phist");
120 c->cd(6);
121 gPad->SetBorderMode(0);
122 gPad->SetLogy();
123 disp3->Draw("Phist");
124
125 c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
126 c->SaveAs(fname(0, fname.Last('.')+1) + "root");
127}
128
129// -------------------------------------------------------------------------
130//
131// plot.C
132//
133// This macro shows how to fill and display a histogram using Mars
134//
135void sumcurrents(const char *dirname="/home/MAGIC/online_data/ccdata/")
136{
137 MDirIter Next;
138 Next.AddDirectory(dirname, "dc_*.txt", -1);
139
140 TString fname;
141 while (1)
142 {
143 fname = Next();
144 if (fname.IsNull())
145 break;
146
147 ProcessFile(fname);
148 }
149}
Note: See TracBrowser for help on using the repository browser.