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

Last change on this file since 5817 was 5142, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.9 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
131
132 MBinning bins;
133
134 bins.SetEdges(100, 0, 1);
135 bins.Apply(fHistLeakage1);
136 bins.Apply(fHistLeakage2);
137 bins.Apply(fHistConc);
138 bins.Apply(fHistConc1);
139
140 bins.SetEdges(75, 0.5, 150.5);
141 bins.Apply(fHistUsedPix);
142 bins.Apply(fHistCorePix);
143
144 bins.SetEdges(75, 0, 0.249);
145 bins.Apply(fHistUsedArea);
146 bins.Apply(fHistCoreArea);
147}
148
149// --------------------------------------------------------------------------
150//
151// Setup the Binning for the histograms automatically if the correct
152// instances of MBinning
153//
154Bool_t MHNewImagePar::SetupFill(const MParList *plist)
155{
156 ApplyBinning(*plist, "Leakage", &fHistLeakage1);
157 ApplyBinning(*plist, "Leakage", &fHistLeakage2);
158
159 ApplyBinning(*plist, "Pixels", &fHistUsedPix);
160 ApplyBinning(*plist, "Pixels", &fHistCorePix);
161
162 ApplyBinning(*plist, "Area", &fHistUsedArea);
163 ApplyBinning(*plist, "Area", &fHistCoreArea);
164
165 ApplyBinning(*plist, "Conc", &fHistConc);
166 ApplyBinning(*plist, "Conc1", &fHistConc1);
167
168 return kTRUE;
169}
170
171
172// --------------------------------------------------------------------------
173//
174// Fill the histograms with data from a MNewImagePar container.
175//
176Bool_t MHNewImagePar::Fill(const MParContainer *par, const Stat_t w)
177{
178 if (!par)
179 {
180 *fLog << err << "MHNewImagePar::Fill: Pointer (!=NULL) expected." << endl;
181 return kFALSE;
182 }
183
184 const MNewImagePar &h = *(MNewImagePar*)par;
185
186 fHistLeakage1.Fill(h.GetLeakage1(), w);
187 fHistLeakage2.Fill(h.GetLeakage2(), w);
188
189 fHistUsedPix.Fill(h.GetNumUsedPixels(), w);
190 fHistCorePix.Fill(h.GetNumCorePixels(), w);
191
192 fHistUsedArea.Fill(h.GetUsedArea()/1000000, w);
193 fHistCoreArea.Fill(h.GetCoreArea()/1000000, w);
194
195 fHistConc.Fill(h.GetConc(), w);
196 fHistConc1.Fill(h.GetConc1(), w);
197
198 return kTRUE;
199}
200
201void MHNewImagePar::Paint(Option_t *o)
202{
203 if (TString(o)==(TString)"log" && fHistLeakage1.GetMaximum()>0)
204 gPad->SetLogy();
205}
206
207// --------------------------------------------------------------------------
208//
209// Creates a new canvas and draws the two histograms into it.
210// Be careful: The histograms belongs to this object and won't get deleted
211// together with the canvas.
212//
213void MHNewImagePar::Draw(Option_t *)
214{
215 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
216 pad->SetBorderMode(0);
217
218 AppendPad("");
219
220 pad->Divide(2,2);
221
222 pad->cd(1);
223 gPad->SetBorderMode(0);
224 TAxis &x = *fHistLeakage1.GetXaxis();
225 x.SetRangeUser(0.0, x.GetXmax());
226 MH::DrawSame(fHistLeakage1, fHistLeakage2, "Leakage1 and Leakage2");
227 fHistLeakage1.SetMinimum();
228 fHistLeakage2.SetMinimum();
229 fHistLeakage2.SetMaximum(0.1); // dummy value to allow log-scale
230 AppendPad("log");
231
232 pad->cd(2);
233 gPad->SetBorderMode(0);
234 MH::DrawSame(fHistCorePix, fHistUsedPix, "Number of core/used Pixels");
235
236 pad->cd(3);
237 gPad->SetBorderMode(0);
238 MH::DrawSame(fHistConc1, fHistConc, "Concentrations");
239
240 pad->cd(4);
241 gPad->SetBorderMode(0);
242 MH::DrawSame(fHistCoreArea, fHistUsedArea, "Area of core/used Pixels");
243}
244
245TH1 *MHNewImagePar::GetHistByName(const TString name)
246{
247 if (name.Contains("Leakage1", TString::kIgnoreCase))
248 return &fHistLeakage1;
249 if (name.Contains("Leakage2", TString::kIgnoreCase))
250 return &fHistLeakage2;
251 if (name.Contains("Conc", TString::kIgnoreCase))
252 return &fHistConc;
253 if (name.Contains("Conc1", TString::kIgnoreCase))
254 return &fHistConc1;
255 if (name.Contains("UsedPix", TString::kIgnoreCase))
256 return &fHistUsedPix;
257 if (name.Contains("CorePix", TString::kIgnoreCase))
258 return &fHistCorePix;
259 if (name.Contains("UsedArea", TString::kIgnoreCase))
260 return &fHistUsedArea;
261 if (name.Contains("CoreArea", TString::kIgnoreCase))
262 return &fHistCoreArea;
263
264 return NULL;
265}
Note: See TracBrowser for help on using the repository browser.