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

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