source: trunk/MagicSoft/Mars/mimage/MHVsSize.cc@ 9620

Last change on this file since 9620 was 9343, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 8.3 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): 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-2009
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHVsSize
29//
30// This class contains histograms for the source independent image parameters
31//
32// ClassVersion 2:
33// ---------------
34// - fMm2Deg
35// - fUseMmScale
36//
37/////////////////////////////////////////////////////////////////////////////
38#include "MHVsSize.h"
39
40#include <TH2.h>
41#include <TPad.h>
42#include <TStyle.h>
43#include <TCanvas.h>
44
45#include "MLog.h"
46#include "MLogManip.h"
47
48#include "MParList.h"
49
50#include "MHillas.h"
51#include "MHillasSrc.h"
52#include "MHillasExt.h"
53#include "MNewImagePar.h"
54#include "MGeomCam.h"
55#include "MBinning.h"
56
57ClassImp(MHVsSize);
58
59using namespace std;
60
61// --------------------------------------------------------------------------
62//
63// Setup four histograms for Width, Length
64//
65MHVsSize::MHVsSize(const char *name, const char *title)
66 : fGeom(0), fHillas(0), fHillasExt(0), fNewImagePar(0)
67{
68 //
69 // set the name and title of this object
70 //
71 fName = name ? name : "MHVsSize";
72 fTitle = title ? title : "Source independent image parameters";
73
74 fLength.SetNameTitle("Length", "Length vs. Size");
75 fWidth.SetNameTitle( "Width", "Width vs. Size");
76 fDist.SetNameTitle( "Dist", "Dist vs. Size");
77 fConc1.SetNameTitle( "Conc1", "Conc1 vs. Size");
78 fArea.SetNameTitle( "Area", "Area vs. Size");
79 fM3Long.SetNameTitle("M3Long", "M3Long vs. Size");
80
81 fLength.SetDirectory(NULL);
82 fWidth.SetDirectory(NULL);
83 fDist.SetDirectory(NULL);
84 fConc1.SetDirectory(NULL);
85 fArea.SetDirectory(NULL);
86 fM3Long.SetDirectory(NULL);
87
88 fLength.SetXTitle("Size [phe]");
89 fWidth.SetXTitle("Size [phe]");
90 fDist.SetXTitle("Size [phe]");
91 fConc1.SetXTitle("Size [phe]");
92 fArea.SetXTitle("Size [phe]");
93 fM3Long.SetXTitle("Size [phe]");
94
95 fLength.SetYTitle("Length [\\circ]");
96 fWidth.SetYTitle("Width [\\circ]");
97 fDist.SetYTitle("Distance [\\circ]");
98 fConc1.SetYTitle("Conc1 [ratio]");
99 fArea.SetYTitle("Area [\\circ^{2}]");
100 fM3Long.SetYTitle("M3Long [\\circ]");
101
102 MBinning binse, binsl, binsd, binsc, binsa, binsm;
103 binse.SetEdgesLog( 50, 10, 1e5);
104 binsl.SetEdges( 100, 0, 0.5);
105 binsd.SetEdges( 100, 0, 2.0);
106 binsc.SetEdgesLog(100, 3e-3, 1);
107 binsa.SetEdges( 100, 0, 0.25);
108 binsm.SetEdges( 100, -1.5, 1.5);
109
110 MH::SetBinning(&fLength, &binse, &binsl);
111 MH::SetBinning(&fWidth, &binse, &binsl);
112 MH::SetBinning(&fDist, &binse, &binsd);
113 MH::SetBinning(&fConc1, &binse, &binsc);
114 MH::SetBinning(&fArea, &binse, &binsa);
115 MH::SetBinning(&fM3Long, &binse, &binsm);
116
117 fLength.UseCurrentStyle();
118 fWidth.UseCurrentStyle();
119 fDist.UseCurrentStyle();
120 fConc1.UseCurrentStyle();
121 fArea.UseCurrentStyle();
122 fM3Long.UseCurrentStyle();
123}
124
125// --------------------------------------------------------------------------
126//
127// Setup the Binning for the histograms automatically if the correct
128// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
129// are found in the parameter list
130// Use this function if you want to set the conversion factor which
131// is used to convert the mm-scale in the camera plain into the deg-scale
132// used for histogram presentations. The conversion factor is part of
133// the camera geometry. Please create a corresponding MGeomCam container.
134//
135Bool_t MHVsSize::SetupFill(const MParList *plist)
136{
137 fGeom = (MGeomCam*)plist->FindObject("MGeomCam");
138 if (!fGeom)
139 {
140 *fLog << err << "MGeomCam not found... abort." << endl;
141 return kFALSE;
142 }
143
144 fHillas = (MHillas*)plist->FindObject("MHillas");
145 if (!fHillas)
146 {
147 *fLog << err << "MHillas not found... abort." << endl;
148 return kFALSE;
149 }
150
151 fHillasExt = (MHillasExt*)plist->FindObject("MHillasExt");
152 if (!fHillasExt)
153 {
154 *fLog << err << "MHillasExt not found... abort." << endl;
155 return kFALSE;
156 }
157
158 fNewImagePar = (MNewImagePar*)plist->FindObject("MNewImagePar");
159 if (!fNewImagePar)
160 {
161 *fLog << err << "MNewImagePar not found... abort." << endl;
162 return kFALSE;
163 }
164
165 /*
166 ApplyBinning(*plist, "Width", "Size", fWidth);
167 ApplyBinning(*plist, "Length", "Size", fLength);
168 ApplyBinning(*plist, "Area", "Size", fArea);
169 ApplyBinning(*plist, "M3Long", "Size", fM3Long);
170 ApplyBinning(*plist, "Conc1", "Size", fConc1);
171 */
172
173 return kTRUE;
174}
175
176// --------------------------------------------------------------------------
177//
178// Fill the histograms with data from a MHillas-Container.
179// Be careful: Only call this with an object of type MHillas
180//
181Int_t MHVsSize::Fill(const MParContainer *par, const Stat_t w)
182{
183 const MHillasSrc *src = dynamic_cast<const MHillasSrc*>(par);
184 if (!src)
185 {
186 *fLog << err << "MHVsSize::Fill: Wrong argument... abort." << endl;
187 return kERROR;
188 }
189
190 const Double_t scale = fGeom->GetConvMm2Deg();
191
192 fLength.Fill(fHillas->GetSize(), scale*fHillas->GetLength(), w);
193 fWidth.Fill( fHillas->GetSize(), scale*fHillas->GetWidth(), w);
194 fDist.Fill( fHillas->GetSize(), scale*src->GetDist(), w);
195 fConc1.Fill( fHillas->GetSize(), fNewImagePar->GetConc1(), w);
196 fArea.Fill( fHillas->GetSize(), scale*scale*fHillas->GetArea(), w);
197 fM3Long.Fill(fHillas->GetSize(), scale*fHillasExt->GetM3Long()*TMath::Sign(1.0f, src->GetCosDeltaAlpha()), w);
198
199 return kTRUE;
200}
201
202// --------------------------------------------------------------------------
203//
204// Creates a new canvas and draws the four histograms into it.
205// Be careful: The histograms belongs to this object and won't get deleted
206// together with the canvas.
207//
208void MHVsSize::Draw(Option_t *o)
209{
210 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
211 pad->SetBorderMode(0);
212
213 AppendPad("");
214
215 TString opt(o);
216 opt.ToLower();
217
218 // FIXME: If same-option given make two independant y-axis!
219 const Bool_t same = opt.Contains("same");
220
221 if (!same)
222 pad->Divide(3,2);
223 else
224 {
225 fLength.SetName("LengthSame");
226 fWidth.SetName("WidthSame");
227 fDist.SetName("DistSame");
228 fConc1.SetName("Conc1Same");
229 fArea.SetName("AreaSame");
230 fM3Long.SetName("M3LongSame");
231
232 fLength.SetDirectory(0);
233 fWidth.SetDirectory(0);
234 fDist.SetDirectory(0);
235 fConc1.SetDirectory(0);
236 fArea.SetDirectory(0);
237 fM3Long.SetDirectory(0);
238
239 fDist.SetMarkerColor(kBlue);
240 fConc1.SetMarkerColor(kBlue);
241 fWidth.SetMarkerColor(kBlue);
242 fLength.SetMarkerColor(kBlue);
243 fArea.SetMarkerColor(kBlue);
244 fM3Long.SetMarkerColor(kBlue);
245 }
246
247 pad->cd(1);
248 gPad->SetBorderMode(0);
249 gPad->SetLogx();
250 RemoveFromPad("LengthSame");
251 fLength.Draw(same?"same":"");
252
253 pad->cd(2);
254 gPad->SetBorderMode(0);
255 gPad->SetLogx();
256 RemoveFromPad("WidthSame");
257 fWidth.Draw(same?"same":"");
258
259 pad->cd(3);
260 gPad->SetBorderMode(0);
261 gPad->SetLogx();
262 RemoveFromPad("DistSame");
263 fDist.Draw(same?"same":"");
264
265 pad->cd(4);
266 gPad->SetBorderMode(0);
267 gPad->SetLogx();
268 RemoveFromPad("AreaSame");
269 fArea.Draw(same?"same":"");
270
271 pad->cd(5);
272 gPad->SetBorderMode(0);
273 gPad->SetLogx();
274 RemoveFromPad("M3LongSame");
275 fM3Long.Draw(same?"same":"");
276
277 pad->cd(6);
278 gPad->SetBorderMode(0);
279 gPad->SetLogx();
280 gPad->SetLogy();
281 RemoveFromPad("Conc1Same");
282 fConc1.Draw(same?"same":"");
283}
Note: See TracBrowser for help on using the repository browser.