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): Thomas Bretz 2001 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | ! Author(s): Wolfgang Wittek 2002 <mailto:wittek@mppmu.mpg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MHVsSize
|
---|
29 | //
|
---|
30 | // This class contains histograms for the source independent image parameters
|
---|
31 | //
|
---|
32 | /////////////////////////////////////////////////////////////////////////////
|
---|
33 | #include "MHVsSize.h"
|
---|
34 |
|
---|
35 | #include <TH2.h>
|
---|
36 | #include <TPad.h>
|
---|
37 | #include <TStyle.h>
|
---|
38 | #include <TCanvas.h>
|
---|
39 |
|
---|
40 | #include "MLog.h"
|
---|
41 | #include "MLogManip.h"
|
---|
42 |
|
---|
43 | #include "MParList.h"
|
---|
44 |
|
---|
45 | #include "MHillas.h"
|
---|
46 | #include "MHillasSrc.h"
|
---|
47 | #include "MHillasExt.h"
|
---|
48 | #include "MNewImagePar.h"
|
---|
49 | #include "MGeomCam.h"
|
---|
50 | #include "MBinning.h"
|
---|
51 |
|
---|
52 | ClassImp(MHVsSize);
|
---|
53 |
|
---|
54 | using namespace std;
|
---|
55 |
|
---|
56 | // --------------------------------------------------------------------------
|
---|
57 | //
|
---|
58 | // Setup four histograms for Width, Length
|
---|
59 | //
|
---|
60 | MHVsSize::MHVsSize(const char *name, const char *title)
|
---|
61 | : fHillas(NULL), fHillasExt(NULL), fNewImagePar(NULL), fMm2Deg(1), fUseMmScale(kTRUE)
|
---|
62 | {
|
---|
63 | //
|
---|
64 | // set the name and title of this object
|
---|
65 | //
|
---|
66 | fName = name ? name : "MHVsSize";
|
---|
67 | fTitle = title ? title : "Source independent image parameters";
|
---|
68 |
|
---|
69 | fLength.SetNameTitle("Length", "Length vs. Size");
|
---|
70 | fWidth.SetNameTitle( "Width", "Width vs. Size");
|
---|
71 | fDist.SetNameTitle( "Dist", "Dist vs. Size");
|
---|
72 | fConc1.SetNameTitle( "Conc1", "Conc1 vs. Size");
|
---|
73 | fArea.SetNameTitle( "Area", "Area vs. Size");
|
---|
74 | fM3Long.SetNameTitle("M3Long", "M3Long vs. Size");
|
---|
75 |
|
---|
76 | fLength.SetDirectory(NULL);
|
---|
77 | fWidth.SetDirectory(NULL);
|
---|
78 | fDist.SetDirectory(NULL);
|
---|
79 | fConc1.SetDirectory(NULL);
|
---|
80 | fArea.SetDirectory(NULL);
|
---|
81 | fM3Long.SetDirectory(NULL);
|
---|
82 |
|
---|
83 | fLength.SetXTitle("Size [phe]");
|
---|
84 | fWidth.SetXTitle("Size [phe]");
|
---|
85 | fDist.SetXTitle("Size [phe]");
|
---|
86 | fConc1.SetXTitle("Size [phe]");
|
---|
87 | fArea.SetXTitle("Size [phe]");
|
---|
88 | fM3Long.SetXTitle("Size [phe]");
|
---|
89 |
|
---|
90 | fLength.SetYTitle("Length [mm]");
|
---|
91 | fWidth.SetYTitle("Width [mm]");
|
---|
92 | fDist.SetYTitle("Distance [mm]");
|
---|
93 | fConc1.SetYTitle("Conc1 [ratio]");
|
---|
94 | fArea.SetYTitle("Conc1 [mm^{2}]");
|
---|
95 | fM3Long.SetYTitle("M3Long [mm]");
|
---|
96 |
|
---|
97 | MBinning binse, binsl, binsd, binsc, binsa, binsm;
|
---|
98 | binse.SetEdgesLog( 50, 10, 1e5);
|
---|
99 | binsl.SetEdges( 100, 0, 296.7/2);
|
---|
100 | binsd.SetEdges( 100, 0, 600);
|
---|
101 | binsc.SetEdgesLog(100, 3e-3, 1);
|
---|
102 | binsa.SetEdges( 100, 0, 445*45);
|
---|
103 | binsm.SetEdges( 100, -445, 445);
|
---|
104 |
|
---|
105 | MH::SetBinning(&fLength, &binse, &binsl);
|
---|
106 | MH::SetBinning(&fWidth, &binse, &binsl);
|
---|
107 | MH::SetBinning(&fDist, &binse, &binsd);
|
---|
108 | MH::SetBinning(&fConc1, &binse, &binsc);
|
---|
109 | MH::SetBinning(&fArea, &binse, &binsa);
|
---|
110 | MH::SetBinning(&fM3Long, &binse, &binsm);
|
---|
111 |
|
---|
112 | fLength.UseCurrentStyle();
|
---|
113 | fWidth.UseCurrentStyle();
|
---|
114 | fDist.UseCurrentStyle();
|
---|
115 | fConc1.UseCurrentStyle();
|
---|
116 | fArea.UseCurrentStyle();
|
---|
117 | fM3Long.UseCurrentStyle();
|
---|
118 | }
|
---|
119 |
|
---|
120 | // --------------------------------------------------------------------------
|
---|
121 | //
|
---|
122 | // Setup the Binning for the histograms automatically if the correct
|
---|
123 | // instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
|
---|
124 | // are found in the parameter list
|
---|
125 | // Use this function if you want to set the conversion factor which
|
---|
126 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
---|
127 | // used for histogram presentations. The conversion factor is part of
|
---|
128 | // the camera geometry. Please create a corresponding MGeomCam container.
|
---|
129 | //
|
---|
130 | Bool_t MHVsSize::SetupFill(const MParList *plist)
|
---|
131 | {
|
---|
132 | MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
133 | if (!geom)
|
---|
134 | *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
|
---|
135 | else
|
---|
136 | {
|
---|
137 | fMm2Deg = geom->GetConvMm2Deg();
|
---|
138 | SetMmScale(kFALSE);
|
---|
139 | }
|
---|
140 |
|
---|
141 | fHillas = (MHillas*)plist->FindObject("MHillas");
|
---|
142 | if (!fHillas)
|
---|
143 | {
|
---|
144 | *fLog << err << "MHillas not found... abort." << endl;
|
---|
145 | return kFALSE;
|
---|
146 | }
|
---|
147 |
|
---|
148 | fHillasExt = (MHillasExt*)plist->FindObject("MHillasExt");
|
---|
149 | if (!fHillasExt)
|
---|
150 | {
|
---|
151 | *fLog << err << "MHillasExt not found... abort." << endl;
|
---|
152 | return kFALSE;
|
---|
153 | }
|
---|
154 |
|
---|
155 | fNewImagePar = (MNewImagePar*)plist->FindObject("MNewImagePar");
|
---|
156 | if (!fNewImagePar)
|
---|
157 | {
|
---|
158 | *fLog << err << "MNewImagePar not found... abort." << endl;
|
---|
159 | return kFALSE;
|
---|
160 | }
|
---|
161 |
|
---|
162 | /*
|
---|
163 | ApplyBinning(*plist, "Width", "Size", fWidth);
|
---|
164 | ApplyBinning(*plist, "Length", "Size", fLength);
|
---|
165 | ApplyBinning(*plist, "Area", "Size", fArea);
|
---|
166 | ApplyBinning(*plist, "M3Long", "Size", fM3Long);
|
---|
167 | ApplyBinning(*plist, "Conc1", "Size", fConc1);
|
---|
168 | */
|
---|
169 |
|
---|
170 | return kTRUE;
|
---|
171 | }
|
---|
172 |
|
---|
173 | // --------------------------------------------------------------------------
|
---|
174 | //
|
---|
175 | // Use this function to setup your own conversion factor between degrees
|
---|
176 | // and millimeters. The conversion factor should be the one calculated in
|
---|
177 | // MGeomCam. Use this function with Caution: You could create wrong values
|
---|
178 | // by setting up your own scale factor.
|
---|
179 | //
|
---|
180 | void MHVsSize::SetMm2Deg(Float_t mmdeg)
|
---|
181 | {
|
---|
182 | if (mmdeg<0)
|
---|
183 | {
|
---|
184 | *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
|
---|
185 | return;
|
---|
186 | }
|
---|
187 |
|
---|
188 | if (fMm2Deg>=0)
|
---|
189 | *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
|
---|
190 |
|
---|
191 | fMm2Deg = mmdeg;
|
---|
192 | }
|
---|
193 |
|
---|
194 | // --------------------------------------------------------------------------
|
---|
195 | //
|
---|
196 | // With this function you can convert the histogram ('on the fly') between
|
---|
197 | // degrees and millimeters.
|
---|
198 | //
|
---|
199 | void MHVsSize::SetMmScale(Bool_t mmscale)
|
---|
200 | {
|
---|
201 | if (fUseMmScale == mmscale)
|
---|
202 | return;
|
---|
203 |
|
---|
204 | if (fMm2Deg<0)
|
---|
205 | {
|
---|
206 | *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
|
---|
207 | return;
|
---|
208 | }
|
---|
209 |
|
---|
210 | const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
|
---|
211 | MH::ScaleAxis(&fLength, 1, scale);
|
---|
212 | MH::ScaleAxis(&fWidth, 1, scale);
|
---|
213 | MH::ScaleAxis(&fDist, 1, scale);
|
---|
214 | MH::ScaleAxis(&fM3Long, 1, scale);
|
---|
215 | MH::ScaleAxis(&fArea, 1, scale*scale);
|
---|
216 |
|
---|
217 | if (mmscale)
|
---|
218 | {
|
---|
219 | fLength.SetYTitle("Length [mm]");
|
---|
220 | fWidth.SetYTitle("Width [mm]");
|
---|
221 | fDist.SetYTitle("Distance [mm]");
|
---|
222 | fArea.SetYTitle("Area [mm^{2}]");
|
---|
223 | fM3Long.SetYTitle("M3Long [mm]");
|
---|
224 | }
|
---|
225 | else
|
---|
226 | {
|
---|
227 | fLength.SetYTitle("Length [\\circ]");
|
---|
228 | fWidth.SetYTitle("Width [\\circ]");
|
---|
229 | fDist.SetYTitle("Distance [\\circ]");
|
---|
230 | fArea.SetYTitle("Area [\\circ^{2}]");
|
---|
231 | fM3Long.SetYTitle("M3Long [\\circ]");
|
---|
232 | }
|
---|
233 |
|
---|
234 | fUseMmScale = mmscale;
|
---|
235 | }
|
---|
236 |
|
---|
237 | // --------------------------------------------------------------------------
|
---|
238 | //
|
---|
239 | // Fill the histograms with data from a MHillas-Container.
|
---|
240 | // Be careful: Only call this with an object of type MHillas
|
---|
241 | //
|
---|
242 | Bool_t MHVsSize::Fill(const MParContainer *par, const Stat_t w)
|
---|
243 | {
|
---|
244 | const MHillasSrc *src = dynamic_cast<const MHillasSrc*>(par);
|
---|
245 | if (!src)
|
---|
246 | {
|
---|
247 | *fLog << err << "MHVsSize::Fill: Wrong argument... abort." << endl;
|
---|
248 | return kFALSE;
|
---|
249 | }
|
---|
250 |
|
---|
251 | const Double_t scale = fUseMmScale ? 1 : fMm2Deg;
|
---|
252 |
|
---|
253 | fLength.Fill(fHillas->GetSize(), scale*fHillas->GetLength(), w);
|
---|
254 | fWidth.Fill( fHillas->GetSize(), scale*fHillas->GetWidth(), w);
|
---|
255 | fDist.Fill( fHillas->GetSize(), scale*src->GetDist(), w);
|
---|
256 | fConc1.Fill( fHillas->GetSize(), fNewImagePar->GetConc1(), w);
|
---|
257 | fArea.Fill( fHillas->GetSize(), scale*scale*fHillas->GetArea(), w);
|
---|
258 | fM3Long.Fill(fHillas->GetSize(), scale*fHillasExt->GetM3Long()*TMath::Sign(1.0f, src->GetCosDeltaAlpha()), w);
|
---|
259 |
|
---|
260 | return kTRUE;
|
---|
261 | }
|
---|
262 |
|
---|
263 | // --------------------------------------------------------------------------
|
---|
264 | //
|
---|
265 | // Creates a new canvas and draws the four histograms into it.
|
---|
266 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
267 | // together with the canvas.
|
---|
268 | //
|
---|
269 | void MHVsSize::Draw(Option_t *o)
|
---|
270 | {
|
---|
271 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
272 | pad->SetBorderMode(0);
|
---|
273 |
|
---|
274 | AppendPad("");
|
---|
275 |
|
---|
276 | TString opt(o);
|
---|
277 | opt.ToLower();
|
---|
278 |
|
---|
279 | // FIXME: If same-option given make two independant y-axis!
|
---|
280 | const Bool_t same = opt.Contains("same");
|
---|
281 |
|
---|
282 | if (!same)
|
---|
283 | pad->Divide(3,2);
|
---|
284 | else
|
---|
285 | {
|
---|
286 | fLength.SetName("LengthSame");
|
---|
287 | fWidth.SetName("WidthSame");
|
---|
288 | fDist.SetName("DistSame");
|
---|
289 | fConc1.SetName("Conc1Same");
|
---|
290 | fArea.SetName("AreaSame");
|
---|
291 | fM3Long.SetName("M3LongSame");
|
---|
292 |
|
---|
293 | fLength.SetDirectory(0);
|
---|
294 | fWidth.SetDirectory(0);
|
---|
295 | fDist.SetDirectory(0);
|
---|
296 | fConc1.SetDirectory(0);
|
---|
297 | fArea.SetDirectory(0);
|
---|
298 | fM3Long.SetDirectory(0);
|
---|
299 |
|
---|
300 | fDist.SetMarkerColor(kBlue);
|
---|
301 | fConc1.SetMarkerColor(kBlue);
|
---|
302 | fWidth.SetMarkerColor(kBlue);
|
---|
303 | fLength.SetMarkerColor(kBlue);
|
---|
304 | fArea.SetMarkerColor(kBlue);
|
---|
305 | fM3Long.SetMarkerColor(kBlue);
|
---|
306 | }
|
---|
307 |
|
---|
308 | pad->cd(1);
|
---|
309 | gPad->SetBorderMode(0);
|
---|
310 | gPad->SetLogx();
|
---|
311 | RemoveFromPad("LengthSame");
|
---|
312 | fLength.Draw(same?"same":"");
|
---|
313 |
|
---|
314 | pad->cd(2);
|
---|
315 | gPad->SetBorderMode(0);
|
---|
316 | gPad->SetLogx();
|
---|
317 | RemoveFromPad("WidthSame");
|
---|
318 | fWidth.Draw(same?"same":"");
|
---|
319 |
|
---|
320 | pad->cd(3);
|
---|
321 | gPad->SetBorderMode(0);
|
---|
322 | gPad->SetLogx();
|
---|
323 | RemoveFromPad("DistSame");
|
---|
324 | fDist.Draw(same?"same":"");
|
---|
325 |
|
---|
326 | pad->cd(4);
|
---|
327 | gPad->SetBorderMode(0);
|
---|
328 | gPad->SetLogx();
|
---|
329 | RemoveFromPad("AreaSame");
|
---|
330 | fArea.Draw(same?"same":"");
|
---|
331 |
|
---|
332 | pad->cd(5);
|
---|
333 | gPad->SetBorderMode(0);
|
---|
334 | gPad->SetLogx();
|
---|
335 | RemoveFromPad("M3LongSame");
|
---|
336 | fM3Long.Draw(same?"same":"");
|
---|
337 |
|
---|
338 | pad->cd(6);
|
---|
339 | gPad->SetBorderMode(0);
|
---|
340 | gPad->SetLogx();
|
---|
341 | gPad->SetLogy();
|
---|
342 | RemoveFromPad("Conc1Same");
|
---|
343 | fConc1.Draw(same?"same":"");
|
---|
344 | }
|
---|