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

Last change on this file since 2313 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 6.2 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-2003
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.SetFillStyle(4000);
68
69 fHistLeakage2.SetName("Leakage2");
70 fHistLeakage2.SetTitle("Leakage_{2}");
71 fHistLeakage2.SetXTitle("Leakage");
72 fHistLeakage2.SetYTitle("Counts");
73 fHistLeakage2.SetDirectory(NULL);
74 fHistLeakage2.SetLineColor(kBlue);
75 fHistLeakage2.SetFillStyle(4000);
76
77 fHistUsedPix.SetName("UsedPix");
78 fHistUsedPix.SetTitle("Number of used pixels");
79 fHistUsedPix.SetXTitle("Number of Pixels");
80 fHistUsedPix.SetYTitle("Counts");
81 fHistUsedPix.SetDirectory(NULL);
82 fHistUsedPix.SetLineColor(kGreen);
83 fHistUsedPix.SetFillStyle(4000);
84
85 fHistCorePix.SetName("CorePix");
86 fHistCorePix.SetTitle("Number of core pixels");
87 fHistCorePix.SetXTitle("Number of Pixels");
88 fHistCorePix.SetYTitle("Counts");
89 fHistCorePix.SetDirectory(NULL);
90 fHistCorePix.SetLineColor(kRed);
91 fHistCorePix.SetFillStyle(4000);
92
93 fHistConc.SetDirectory(NULL);
94 fHistConc1.SetDirectory(NULL);
95 fHistConc.SetName("Conc2");
96 fHistConc1.SetName("Conc1");
97 fHistConc.SetTitle("Ratio: Conc");
98 fHistConc1.SetTitle("Ratio: Conc1");
99 fHistConc.SetXTitle("Ratio");
100 fHistConc1.SetXTitle("Ratio");
101 fHistConc.SetYTitle("Counts");
102 fHistConc1.SetYTitle("Counts");
103 fHistConc.SetFillStyle(4000);
104 fHistConc1.SetFillStyle(4000);
105 fHistConc1.SetLineColor(kBlue);
106 fHistConc.SetFillStyle(0);
107
108
109 MBinning bins;
110
111 bins.SetEdges(100, 0, 1);
112 bins.Apply(fHistLeakage1);
113 bins.Apply(fHistLeakage2);
114 bins.Apply(fHistConc);
115 bins.Apply(fHistConc1);
116
117 bins.SetEdges(150, 0, 150);
118 bins.Apply(fHistUsedPix);
119 bins.Apply(fHistCorePix);
120}
121
122// --------------------------------------------------------------------------
123//
124// Setup the Binning for the histograms automatically if the correct
125// instances of MBinning
126//
127Bool_t MHNewImagePar::SetupFill(const MParList *plist)
128{
129 ApplyBinning(*plist, "Leakage", &fHistLeakage1);
130 ApplyBinning(*plist, "Leakage", &fHistLeakage2);
131
132 ApplyBinning(*plist, "Pixels", &fHistUsedPix);
133 ApplyBinning(*plist, "Pixels", &fHistCorePix);
134
135 ApplyBinning(*plist, "Conc", &fHistConc);
136 ApplyBinning(*plist, "Conc1", &fHistConc1);
137
138 return kTRUE;
139}
140
141
142// --------------------------------------------------------------------------
143//
144// Fill the histograms with data from a MNewImagePar container.
145//
146Bool_t MHNewImagePar::Fill(const MParContainer *par, const Stat_t w)
147{
148 if (!par)
149 {
150 *fLog << err << "MHNewImagePar::Fill: Pointer (!=NULL) expected." << endl;
151 return kFALSE;
152 }
153
154 const MNewImagePar &h = *(MNewImagePar*)par;
155
156 fHistLeakage1.Fill(h.GetLeakage1(), w);
157 fHistLeakage2.Fill(h.GetLeakage2(), w);
158
159 fHistUsedPix.Fill(h.GetNumUsedPixels(), w);
160 fHistCorePix.Fill(h.GetNumCorePixels(), w);
161
162 fHistConc.Fill(h.GetConc(), w);
163 fHistConc1.Fill(h.GetConc1(), w);
164
165 return kTRUE;
166}
167
168// --------------------------------------------------------------------------
169//
170// Creates a new canvas and draws the two histograms into it.
171// Be careful: The histograms belongs to this object and won't get deleted
172// together with the canvas.
173//
174void MHNewImagePar::Draw(Option_t *)
175{
176 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
177 pad->SetBorderMode(0);
178
179 AppendPad("");
180
181 pad->Divide(2,2);
182
183 pad->cd(1);
184 gPad->SetBorderMode(0);
185 TAxis &x = *fHistLeakage1.GetXaxis();
186 x.SetRangeUser(0.0, x.GetXmax());
187 MH::Draw(fHistLeakage1, fHistLeakage2, "Leakage1 and Leakage2");
188
189 pad->cd(2);
190 gPad->SetBorderMode(0);
191 MH::Draw(fHistCorePix, fHistUsedPix, "Number of core/used Pixels");
192
193 pad->cd(3);
194 gPad->SetBorderMode(0);
195 MH::Draw(fHistConc1, fHistConc, "Concentrations");
196
197 pad->cd(4);
198 gPad->SetBorderMode(0);
199
200 pad->Modified();
201 pad->Update();
202}
203
204TH1 *MHNewImagePar::GetHistByName(const TString name)
205{
206 if (name.Contains("Leakage1", TString::kIgnoreCase))
207 return &fHistLeakage1;
208 if (name.Contains("Leakage2", TString::kIgnoreCase))
209 return &fHistLeakage2;
210 if (name.Contains("Conc", TString::kIgnoreCase))
211 return &fHistConc;
212 if (name.Contains("Conc1", TString::kIgnoreCase))
213 return &fHistConc1;
214 if (name.Contains("UsedPix", TString::kIgnoreCase))
215 return &fHistUsedPix;
216 if (name.Contains("CorePix", TString::kIgnoreCase))
217 return &fHistCorePix;
218
219 return NULL;
220}
Note: See TracBrowser for help on using the repository browser.