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