source: trunk/MagicSoft/Mars/mmuon/MHMuonPar.cc@ 9335

Last change on this file since 9335 was 9303, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 8.4 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): Markus Meyer, 02/2005 <mailto:meyer@astro.uni-wuerzburg.de>
19! Author(s): Thomas Bretz, 04/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2005
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHMuonPar
29//
30// This class is a histogram class for displaying muonparameters.
31// The folowing histgrams will be plotted:
32// - Radius (TH1F)
33// - ArcWidth (TH1F)
34// - ArcWidth/Radius vs Radius (TProfile) (it is the energy dependent
35// relative broadening of the muon ring)
36// - Size Vs Radius
37//
38// Inputcontainer:
39// - MGeomCam
40// - MMuonSearchPar
41// - MMuonCalibPar
42//
43////////////////////////////////////////////////////////////////////////////
44#include "MHMuonPar.h"
45
46#include <TH1.h>
47#include <TF1.h>
48#include <TPad.h>
49#include <TLatex.h>
50#include <TCanvas.h>
51#include <TProfile.h>
52
53#include "MLog.h"
54#include "MLogManip.h"
55
56#include "MString.h"
57
58#include "MGeomCam.h"
59#include "MBinning.h"
60#include "MParList.h"
61
62#include "MMuonSearchPar.h"
63#include "MMuonCalibPar.h"
64
65ClassImp(MHMuonPar);
66
67using namespace std;
68
69const Float_t MHMuonPar::fgIntegralLoLim = 0.751;
70const Float_t MHMuonPar::fgIntegralUpLim = 1.199;
71
72// --------------------------------------------------------------------------
73//
74// Setup histograms
75//
76MHMuonPar::MHMuonPar(const char *name, const char *title) :
77 fMuonSearchPar(NULL), fMuonCalibPar(NULL)
78{
79 fName = name ? name : "MHMuonPar";
80 fTitle = title ? title : "Histograms of muon parameters";
81
82 fHistRadius.SetName("Radius");
83 fHistRadius.SetTitle("Distribution of Radius'");
84 fHistRadius.SetXTitle("R [\\circ]");
85 fHistRadius.SetYTitle("Counts");
86 fHistRadius.GetXaxis()->SetTitleOffset(1.2);
87 fHistRadius.SetDirectory(NULL);
88 fHistRadius.UseCurrentStyle();
89 fHistRadius.SetFillStyle(4000);
90
91 fHistArcWidth.SetName("ArcWidth");
92 fHistArcWidth.SetTitle("Distribution of ArcWidth");
93 fHistArcWidth.SetXTitle("W [\\circ]");
94 fHistArcWidth.GetXaxis()->SetTitleOffset(1.2);
95 fHistArcWidth.SetYTitle("Counts");
96 fHistArcWidth.SetDirectory(NULL);
97 fHistArcWidth.UseCurrentStyle();
98 fHistArcWidth.SetFillStyle(4000);
99
100 fHistBroad.SetName("RingBroadening");
101 fHistBroad.SetTitle("Profile ArcWidth vs Radius");
102 fHistBroad.SetXTitle("R [\\circ]");
103 fHistBroad.SetYTitle("W/R [1]");
104 fHistBroad.GetXaxis()->SetTitleOffset(1.2);
105 fHistBroad.SetDirectory(NULL);
106 fHistBroad.UseCurrentStyle();
107 fHistBroad.SetFillStyle(4000);
108
109 fHistSize.SetName("SizeVsRadius");
110 fHistSize.SetTitle("Profile MuonSize vs Radius");
111 fHistSize.SetXTitle("R [\\circ]");
112 fHistSize.SetYTitle("S [phe]");
113 fHistSize.GetXaxis()->SetTitleOffset(1.2);
114 fHistSize.SetDirectory(NULL);
115 fHistSize.UseCurrentStyle();
116 fHistSize.SetFillStyle(4000);
117
118 MBinning bins;
119
120 bins.SetEdges(20, 0.5, 1.5);
121 bins.Apply(fHistRadius);
122
123 bins.SetEdges(60, 0., 0.3);
124 bins.Apply(fHistArcWidth);
125
126 bins.SetEdges(20, 0.5, 1.5);
127 bins.Apply(fHistBroad);
128
129 bins.SetEdges(20, 0.5, 1.5);
130 bins.Apply(fHistSize);
131}
132
133// --------------------------------------------------------------------------
134//
135// Setup the Binning for the histograms automatically if the correct
136// instances of MBinning
137//
138Bool_t MHMuonPar::SetupFill(const MParList *plist)
139{
140 MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
141 if (!geom)
142 {
143 *fLog << warn << "MGeomCam not found... abort." << endl;
144 return kFALSE;
145 }
146 fMm2Deg = geom->GetConvMm2Deg();
147
148 fMuonSearchPar = (MMuonSearchPar*)plist->FindObject("MMuonSearchPar");
149 if (!fMuonSearchPar)
150 {
151 *fLog << warn << "MMuonSearchPar not found... abort." << endl;
152 return kFALSE;
153 }
154 fMuonCalibPar = (MMuonCalibPar*)plist->FindObject("MMuonCalibPar");
155 if (!fMuonCalibPar)
156 {
157 *fLog << warn << "MMuonCalibPar not found... abort." << endl;
158 return kFALSE;
159 }
160
161 ApplyBinning(*plist, "Radius", &fHistRadius);
162 ApplyBinning(*plist, "ArcWidth", &fHistArcWidth);
163 ApplyBinning(*plist, "RingBroadening", &fHistBroad);
164 ApplyBinning(*plist, "SizeVsRadius", &fHistSize);
165
166 return kTRUE;
167}
168
169// --------------------------------------------------------------------------
170//
171// Fill the histograms with data from a MMuonCalibPar and
172// MMuonSearchPar container.
173//
174Int_t MHMuonPar::Fill(const MParContainer *par, const Stat_t w)
175{
176 fHistRadius.Fill(fMm2Deg*fMuonSearchPar->GetRadius(), w);
177
178 fHistArcWidth.Fill(fMuonCalibPar->GetArcWidth(), w);
179
180 fHistBroad.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
181 fMuonCalibPar->GetArcWidth(), w);
182
183 fHistSize.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
184 fMuonCalibPar->GetMuonSize(), w);
185
186 return kTRUE;
187}
188// --------------------------------------------------------------------------
189//
190// Creates a new canvas and draws the two histograms into it.
191// Be careful: The histograms belongs to this object and won't get deleted
192// together with the canvas.
193//
194void MHMuonPar::Draw(Option_t *)
195{
196 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
197 pad->SetBorderMode(0);
198
199 AppendPad("");
200
201 pad->Divide(2,2);
202
203 pad->cd(1);
204 gPad->SetBorderMode(0);
205 gPad->SetGridx();
206 gPad->SetGridy();
207 fHistRadius.Draw();
208
209 pad->cd(2);
210 gPad->SetBorderMode(0);
211 gPad->SetGridx();
212 gPad->SetGridy();
213 fHistArcWidth.Draw();
214
215 pad->cd(3);
216 gPad->SetBorderMode(0);
217 gPad->SetGridx();
218 gPad->SetGridy();
219 fHistSize.Draw();
220
221 TText txt;
222 txt.SetTextColor(kBlue);
223
224 TF1 ref("RefShape100%", "-77.07+1249.3*x-351.2*x*x", fgIntegralLoLim, fgIntegralUpLim);
225 // old: 573*x + 430
226 ref.SetLineColor(kBlue);
227 ref.SetLineWidth(1);
228 ref.SetLineStyle(kDashed);
229 gROOT->GetListOfFunctions()->Remove(ref.DrawCopy("same"));
230
231 txt.SetTextAlign(31);
232 txt.DrawText(fgIntegralLoLim, ref.Eval(fgIntegralLoLim+0.05), "100%");
233
234 AppendPad("pad3");
235
236 pad->cd(4);
237 gPad->SetBorderMode(0);
238 gPad->SetGridx();
239 gPad->SetGridy();
240 fHistBroad.Draw();
241
242 ref.SetName("RefShape12mm");
243 ref.Compile("- 0.02711*x + 0.09359");
244 gROOT->GetListOfFunctions()->Remove(ref.DrawCopy("same"));
245
246 txt.SetTextAlign(11);
247 txt.DrawText(fgIntegralLoLim, ref.Eval(fgIntegralLoLim-0.05), "12mm");
248
249 AppendPad("pad4");
250}
251/*
252Double_t MHMuonPar::Integral(const TProfile &p, Int_t a, Int_t b) const
253{
254 Float_t numerator = 0;
255 Float_t denominator = 0;
256
257 for (Int_t i=a; i<b; i++)
258 {
259 numerator += p.GetBinContent(i)*p.GetBinEntries(i);
260 denominator += p.GetBinEntries(i);
261 }
262
263 return denominator==0 ? 0 : numerator/denominator;
264}
265*/
266Double_t MHMuonPar::Integral(const TProfile &p, Float_t a, Float_t b) const
267{
268 const Int_t bin1 = p.GetXaxis()->FindFixBin(a);
269 const Int_t bin2 = p.GetXaxis()->FindFixBin(b);
270
271 return p.Integral(bin1, bin2);
272}
273
274void MHMuonPar::Paint(Option_t *opt)
275{
276 if (TString(opt)==TString("pad4"))
277 {
278 const TString txt = MString::Format("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.3f",
279 fgIntegralLoLim, fgIntegralUpLim, Integral(fHistBroad));
280
281 TLatex text(0.55, 0.93, txt);
282 text.SetBit(TLatex::kTextNDC);
283 text.SetTextSize(0.055);
284 text.Paint();
285 }
286
287 if (TString(opt)==TString("pad3"))
288 {
289 const TString txt = MString::Format("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.f",
290 fgIntegralLoLim, fgIntegralUpLim, Integral(fHistSize));
291
292 TLatex text(0.47, 0.93, txt);
293 text.SetBit(TLatex::kTextNDC);
294 text.SetTextSize(0.055);
295 text.Paint();
296 }
297}
Note: See TracBrowser for help on using the repository browser.