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

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