source: trunk/MagicSoft/Mars/mimage/MHHillasExt.cc@ 9340

Last change on this file since 9340 was 9340, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 8.1 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!
20! Copyright: MAGIC Software Development, 2000-2007
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MHHillasExt
28//
29// This class contains histograms for every Hillas parameter
30//
31// Class Version 2:
32// ----------------
33// - fHMaxDist
34// + fHSlopeL
35//
36/////////////////////////////////////////////////////////////////////////////
37#include "MHHillasExt.h"
38
39#include <math.h>
40
41#include <TPad.h>
42#include <TLegend.h>
43#include <TCanvas.h>
44
45#include "MLog.h"
46#include "MLogManip.h"
47
48#include "MGeomCam.h"
49
50#include "MParList.h"
51
52#include "MBinning.h"
53
54#include "MHillas.h"
55#include "MHillasExt.h"
56#include "MHillasSrc.h"
57
58ClassImp(MHHillasExt);
59
60using namespace std;
61
62// --------------------------------------------------------------------------
63//
64// Setup four histograms for Width, Length
65//
66MHHillasExt::MHHillasExt(const char *name, const char *title)
67 : fGeom(0), fHillas(0), fHillasExt(0), fHilName("MHillasExt")
68{
69 //
70 // set the name and title of this object
71 //
72 fName = name ? name : "MHHillasExt";
73 fTitle = title ? title : "Container for extended Hillas histograms";
74
75 //
76 // loop over all Pixels and create two histograms
77 // one for the Low and one for the High gain
78 // connect all the histogram with the container fHist
79 //
80 fHAsym.UseCurrentStyle();
81 fHM3Long.UseCurrentStyle();
82 fHM3Trans.UseCurrentStyle();
83 fHSlopeL.UseCurrentStyle();
84
85 fHAsym.SetName("Asymmetry");
86 fHM3Long.SetName("M3l");
87 fHM3Trans.SetName("M3t");
88 fHSlopeL.SetName("SlopeL");
89
90 fHAsym.SetTitle("Asymmetry");
91 fHM3Long.SetTitle("3^{rd} Moment Longitudinal");
92 fHM3Trans.SetTitle("3^{rd} Moment Transverse");
93 fHSlopeL.SetTitle("Longitudinal time-slope vs. Dist");
94
95 fHAsym.SetXTitle("Asym [\\circ]");
96 fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
97 fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
98 fHSlopeL.SetXTitle("D [\\circ]");
99
100 fHAsym.SetYTitle("Counts");
101 fHM3Long.SetYTitle("Counts");
102 fHM3Trans.SetYTitle("Counts");
103 fHSlopeL.SetYTitle("S_{l} [ns/\\circ]");
104
105 fHAsym.SetFillStyle(4000);
106 fHM3Long.SetFillStyle(4000);
107 fHM3Trans.SetFillStyle(4000);
108 //fHSlopeL.SetFillStyle(4000);
109
110 fHAsym.SetDirectory(NULL);
111 fHM3Long.SetDirectory(NULL);
112 fHM3Trans.SetDirectory(NULL);
113 fHSlopeL.SetDirectory(NULL);
114
115 fHM3Trans.SetLineColor(kBlue);
116
117 MBinning binsx, binsy;
118
119 binsx.SetEdges(51, -326, 326);
120 binsx.Apply(fHM3Long);
121 binsx.Apply(fHM3Trans);
122
123 binsx.SetEdges(51, -593, 593);
124 binsx.Apply(fHAsym);
125
126 binsx.SetEdges(100, 0, 445);
127 binsy.SetEdges(100, -0.04, 0.04);
128 MH::SetBinning(&fHSlopeL, &binsx, &binsy);
129}
130
131// --------------------------------------------------------------------------
132//
133// Setup the Binning for the histograms automatically if the correct
134// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
135// are found in the parameter list
136// Use this function if you want to set the conversion factor which
137// is used to convert the mm-scale in the camera plain into the deg-scale
138// used for histogram presentations. The conversion factor is part of
139// the camera geometry. Please create a corresponding MGeomCam container.
140//
141Bool_t MHHillasExt::SetupFill(const MParList *plist)
142{
143 fHillasExt = (MHillasExt*)plist->FindObject(fHilName, "MHillasExt");
144 if (!fHillasExt)
145 {
146 *fLog << err << fHilName << "[MHillasExt] not found in parameter list... aborting." << endl;
147 return kFALSE;
148 }
149
150 fHillas = (MHillas*)plist->FindObject("MHillas");
151 if (!fHillas)
152 {
153 *fLog << err << "MHillas not found in parameter list... aborting." << endl;
154 return kFALSE;
155 }
156
157 fGeom = (MGeomCam*)plist->FindObject("MGeomCam");
158 if (!fGeom)
159 {
160 *fLog << err << "MGeomCam not found... abort." << endl;
161 return kFALSE;
162 }
163
164 ApplyBinning(*plist, "Asym", &fHAsym);
165 ApplyBinning(*plist, "M3Long", &fHM3Long);
166 ApplyBinning(*plist, "M3Trans", &fHM3Trans);
167 ApplyBinning(*plist, "Dist", "Slope", &fHSlopeL);
168
169 return kTRUE;
170}
171
172// --------------------------------------------------------------------------
173//
174// Fill the four histograms with data from a MHillas-Container.
175// Be careful: Only call this with an object of type MHillas
176//
177Int_t MHHillasExt::Fill(const MParContainer *par, const Stat_t w)
178{
179 const MHillasSrc *src = (MHillasSrc*)par;
180
181 const Double_t scale = TMath::Sign(fGeom->GetConvMm2Deg(), (src ? src->GetCosDeltaAlpha() : 1));
182 const Double_t dist = src ? src->GetDist() : fHillas->GetDist0();
183
184 fHAsym.Fill(scale*fHillasExt->GetAsym(), w);
185 fHM3Long.Fill(scale*fHillasExt->GetM3Long(), w);
186 fHM3Trans.Fill(scale*fHillasExt->GetM3Trans(), w);
187 fHSlopeL.Fill(scale*dist, fHillasExt->GetSlopeLong()/scale, w);
188
189 return kTRUE;
190}
191
192// --------------------------------------------------------------------------
193//
194// Creates a new canvas and draws the four histograms into it.
195// Be careful: The histograms belongs to this object and won't get deleted
196// together with the canvas.
197//
198void MHHillasExt::Draw(Option_t *o)
199{
200 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
201 pad->SetBorderMode(0);
202
203 AppendPad("");
204
205 // FIXME: If same-option given make two independant y-axis!
206 const TString opt(o);
207 const Bool_t same = opt.Contains("same");
208
209 if (!same)
210 pad->Divide(2,2);
211 else
212 {
213 fHAsym.SetName("AsymmetrySame");
214 fHM3Long.SetName("M3lSame");
215 fHM3Trans.SetName("M3tSame");
216 fHSlopeL.SetName("SlopeLSame");
217
218 fHAsym.SetDirectory(0);
219 fHM3Long.SetDirectory(0);
220 fHM3Trans.SetDirectory(0);
221 fHSlopeL.SetDirectory(0);
222
223 fHM3Long.SetLineColor(kMagenta);
224 fHM3Trans.SetLineColor(kCyan);
225 fHAsym.SetLineColor(kBlue);
226 fHSlopeL.SetMarkerColor(kBlue);
227 }
228
229 pad->cd(1);
230 gPad->SetBorderMode(0);
231 gPad->SetGridx();
232 gPad->SetGridy();
233 RemoveFromPad("M3lSame");
234 RemoveFromPad("M3tSame");
235 MH::DrawSame(fHM3Long, fHM3Trans, "3^{rd} Moments", same);
236
237 pad->cd(3);
238 gPad->SetBorderMode(0);
239 gPad->SetGridx();
240 gPad->SetGridy();
241 RemoveFromPad("AsymmetrySame");
242 fHAsym.Draw(same?"same":"");
243
244 pad->cd(2);
245 gPad->SetBorderMode(0);
246 gPad->SetGridx();
247 gPad->SetGridy();
248 //RemoveFromPad("SlopeLSame");
249 //fHSlopeL.Draw(same?"same":"");
250 if (same)
251 {
252 TH2 *h=dynamic_cast<TH2*>(gPad->FindObject("SlopeL"));
253 if (h)
254 {
255 // This causes crashes in THistPainter::PaintTable
256 // if the z-axis is not kept. No idea why...
257 h->SetDrawOption("z");
258 h->SetMarkerColor(kBlack);
259 }
260
261 RemoveFromPad("SlopeLSame");
262 fHSlopeL.SetMarkerColor(kGreen);
263 fHSlopeL.Draw("same");
264 }
265 else
266 fHSlopeL.Draw("colz");
267
268 delete pad->GetPad(4);
269}
270
271TH1 *MHHillasExt::GetHistByName(const TString name) const
272{
273 if (name.Contains("Asym", TString::kIgnoreCase))
274 return const_cast<TH1F*>(&fHAsym);
275 if (name.Contains("M3L", TString::kIgnoreCase))
276 return const_cast<TH1F*>(&fHM3Long);
277 if (name.Contains("M3T", TString::kIgnoreCase))
278 return const_cast<TH1F*>(&fHM3Trans);
279 if (name.Contains("SlopeL", TString::kIgnoreCase))
280 return const_cast<TH2F*>(&fHSlopeL);
281
282 return NULL;
283}
Note: See TracBrowser for help on using the repository browser.