source: trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc@ 3682

Last change on this file since 3682 was 3682, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 7.6 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): Wolfgang Wittek, 03/2003 <mailto:wittek@mppmu.mpg.de>
19! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHNewImagePar
29//
30////////////////////////////////////////////////////////////////////////////
31#include "MHNewImagePar.h"
32
33#include <math.h>
34
35#include <TH1.h>
36#include <TPad.h>
37#include <TCanvas.h>
38
39#include "MLog.h"
40#include "MLogManip.h"
41
42#include "MGeomCam.h"
43#include "MBinning.h"
44#include "MParList.h"
45
46#include "MHillas.h"
47#include "MNewImagePar.h"
48
49ClassImp(MHNewImagePar);
50
51using namespace std;
52
53// --------------------------------------------------------------------------
54//
55// Setup histograms
56//
57MHNewImagePar::MHNewImagePar(const char *name, const char *title)
58{
59 fName = name ? name : "MHNewImagePar";
60 fTitle = title ? title : "Histograms of new image parameters";
61
62 fHistLeakage1.SetName("Leakage1");
63 fHistLeakage1.SetTitle("Leakage_{1}");
64 fHistLeakage1.SetXTitle("Leakage");
65 fHistLeakage1.SetYTitle("Counts");
66 fHistLeakage1.SetDirectory(NULL);
67 fHistLeakage1.UseCurrentStyle();
68 fHistLeakage1.SetFillStyle(4000);
69
70 fHistLeakage2.SetName("Leakage2");
71 fHistLeakage2.SetTitle("Leakage_{2}");
72 fHistLeakage2.SetXTitle("Leakage");
73 fHistLeakage2.SetYTitle("Counts");
74 fHistLeakage2.SetDirectory(NULL);
75 fHistLeakage2.UseCurrentStyle();
76 fHistLeakage2.SetLineColor(kBlue);
77 fHistLeakage2.SetFillStyle(4000);
78
79 fHistUsedPix.SetName("UsedPix");
80 fHistUsedPix.SetTitle("Number of used pixels");
81 fHistUsedPix.SetXTitle("Number of Pixels");
82 fHistUsedPix.SetYTitle("Counts");
83 fHistUsedPix.SetDirectory(NULL);
84 fHistUsedPix.UseCurrentStyle();
85 fHistUsedPix.SetLineColor(kBlue);
86 fHistUsedPix.SetFillStyle(4000);
87
88 fHistCorePix.SetName("CorePix");
89 fHistCorePix.SetTitle("Number of core pixels");
90 fHistCorePix.SetXTitle("Number of Pixels");
91 fHistCorePix.SetYTitle("Counts");
92 fHistCorePix.SetDirectory(NULL);
93 fHistCorePix.UseCurrentStyle();
94 fHistCorePix.SetLineColor(kBlack);
95 fHistCorePix.SetFillStyle(4000);
96
97 fHistUsedArea.SetName("UsedArea");
98 fHistUsedArea.SetTitle("Area of used pixels");
99 fHistUsedArea.SetXTitle("Area [m^2]");
100 fHistUsedArea.SetYTitle("Counts");
101 fHistUsedArea.SetDirectory(NULL);
102 fHistUsedArea.UseCurrentStyle();
103 fHistUsedArea.SetLineColor(kBlue);
104 fHistUsedArea.SetFillStyle(4000);
105
106 fHistCoreArea.SetName("CoreArea");
107 fHistCoreArea.SetTitle("Area of core pixels");
108 fHistCoreArea.SetXTitle("Area [m^2]");
109 fHistCoreArea.SetYTitle("Counts");
110 fHistCoreArea.SetDirectory(NULL);
111 fHistCoreArea.UseCurrentStyle();
112 fHistCoreArea.SetLineColor(kBlack);
113 fHistCoreArea.SetFillStyle(4000);
114
115 fHistConc.SetDirectory(NULL);
116 fHistConc1.SetDirectory(NULL);
117 fHistConc.SetName("Conc2");
118 fHistConc1.SetName("Conc1");
119 fHistConc.SetTitle("Ratio: Conc");
120 fHistConc1.SetTitle("Ratio: Conc1");
121 fHistConc.SetXTitle("Ratio");
122 fHistConc1.SetXTitle("Ratio");
123 fHistConc.SetYTitle("Counts");
124 fHistConc1.SetYTitle("Counts");
125 fHistConc1.UseCurrentStyle();
126 fHistConc.UseCurrentStyle();
127 fHistConc.SetFillStyle(4000);
128 fHistConc1.SetFillStyle(4000);
129 fHistConc1.SetLineColor(kBlue);
130 fHistConc.SetFillStyle(0);
131
132
133 MBinning bins;
134
135 bins.SetEdges(100, 0, 1);
136 bins.Apply(fHistLeakage1);
137 bins.Apply(fHistLeakage2);
138 bins.Apply(fHistConc);
139 bins.Apply(fHistConc1);
140
141 bins.SetEdges(75, 0, 150);
142 bins.Apply(fHistUsedPix);
143 bins.Apply(fHistCorePix);
144
145 bins.SetEdges(75, 0, 0.249);
146 bins.Apply(fHistUsedArea);
147 bins.Apply(fHistCoreArea);
148}
149
150// --------------------------------------------------------------------------
151//
152// Setup the Binning for the histograms automatically if the correct
153// instances of MBinning
154//
155Bool_t MHNewImagePar::SetupFill(const MParList *plist)
156{
157 ApplyBinning(*plist, "Leakage", &fHistLeakage1);
158 ApplyBinning(*plist, "Leakage", &fHistLeakage2);
159
160 ApplyBinning(*plist, "Pixels", &fHistUsedPix);
161 ApplyBinning(*plist, "Pixels", &fHistCorePix);
162
163 ApplyBinning(*plist, "Area", &fHistUsedArea);
164 ApplyBinning(*plist, "Area", &fHistCoreArea);
165
166 ApplyBinning(*plist, "Conc", &fHistConc);
167 ApplyBinning(*plist, "Conc1", &fHistConc1);
168
169 return kTRUE;
170}
171
172
173// --------------------------------------------------------------------------
174//
175// Fill the histograms with data from a MNewImagePar container.
176//
177Bool_t MHNewImagePar::Fill(const MParContainer *par, const Stat_t w)
178{
179 if (!par)
180 {
181 *fLog << err << "MHNewImagePar::Fill: Pointer (!=NULL) expected." << endl;
182 return kFALSE;
183 }
184
185 const MNewImagePar &h = *(MNewImagePar*)par;
186
187 fHistLeakage1.Fill(h.GetLeakage1(), w);
188 fHistLeakage2.Fill(h.GetLeakage2(), w);
189
190 fHistUsedPix.Fill(h.GetNumUsedPixels(), w);
191 fHistCorePix.Fill(h.GetNumCorePixels(), w);
192
193 fHistUsedArea.Fill(h.GetUsedArea()/1000000, w);
194 fHistCoreArea.Fill(h.GetCoreArea()/1000000, w);
195
196 fHistConc.Fill(h.GetConc(), w);
197 fHistConc1.Fill(h.GetConc1(), w);
198
199 return kTRUE;
200}
201
202// --------------------------------------------------------------------------
203//
204// Creates a new canvas and draws the two histograms into it.
205// Be careful: The histograms belongs to this object and won't get deleted
206// together with the canvas.
207//
208void MHNewImagePar::Draw(Option_t *)
209{
210 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
211 pad->SetBorderMode(0);
212
213 AppendPad("");
214
215 pad->Divide(2,2);
216
217 pad->cd(1);
218 gPad->SetBorderMode(0);
219 TAxis &x = *fHistLeakage1.GetXaxis();
220 x.SetRangeUser(0.0, x.GetXmax());
221 MH::DrawSame(fHistLeakage1, fHistLeakage2, "Leakage1 and Leakage2");
222
223 pad->cd(2);
224 gPad->SetBorderMode(0);
225 MH::DrawSame(fHistCorePix, fHistUsedPix, "Number of core/used Pixels");
226
227 pad->cd(3);
228 gPad->SetBorderMode(0);
229 MH::DrawSame(fHistConc1, fHistConc, "Concentrations");
230
231 pad->cd(4);
232 gPad->SetBorderMode(0);
233 MH::DrawSame(fHistCoreArea, fHistUsedArea, "Area of core/used Pixels");
234
235 pad->Modified();
236 pad->Update();
237}
238
239TH1 *MHNewImagePar::GetHistByName(const TString name)
240{
241 if (name.Contains("Leakage1", TString::kIgnoreCase))
242 return &fHistLeakage1;
243 if (name.Contains("Leakage2", TString::kIgnoreCase))
244 return &fHistLeakage2;
245 if (name.Contains("Conc", TString::kIgnoreCase))
246 return &fHistConc;
247 if (name.Contains("Conc1", TString::kIgnoreCase))
248 return &fHistConc1;
249 if (name.Contains("UsedPix", TString::kIgnoreCase))
250 return &fHistUsedPix;
251 if (name.Contains("CorePix", TString::kIgnoreCase))
252 return &fHistCorePix;
253 if (name.Contains("UsedArea", TString::kIgnoreCase))
254 return &fHistUsedArea;
255 if (name.Contains("CoreArea", TString::kIgnoreCase))
256 return &fHistCoreArea;
257
258 return NULL;
259}
Note: See TracBrowser for help on using the repository browser.