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

Last change on this file since 7022 was 7022, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 6.7 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
67// --------------------------------------------------------------------------
68//
69// Setup histograms
70//
71MHMuonPar::MHMuonPar(const char *name, const char *title) :
72 fMuonSearchPar(NULL), fMuonCalibPar(NULL)
73{
74 fName = name ? name : "MHMuonPar";
75 fTitle = title ? title : "Histograms of muon parameters";
76
77 fHistRadius.SetName("Radius");
78 fHistRadius.SetTitle("Distribution of Radius'");
79 fHistRadius.SetXTitle("R [\\circ]");
80 fHistRadius.SetYTitle("Counts");
81 fHistRadius.SetDirectory(NULL);
82 fHistRadius.UseCurrentStyle();
83 fHistRadius.SetFillStyle(4000);
84
85 fHistArcWidth.SetName("ArcWidth");
86 fHistArcWidth.SetTitle("Distribution of ArcWidth");
87 fHistArcWidth.SetXTitle("W [\\circ]");
88 fHistArcWidth.SetYTitle("Counts");
89 fHistArcWidth.SetDirectory(NULL);
90 fHistArcWidth.UseCurrentStyle();
91 fHistArcWidth.SetFillStyle(4000);
92
93 fHistBroad.SetName("RingBroadening");
94 fHistBroad.SetTitle("Profile ArcWidth/Radius vs Radius");
95 fHistBroad.SetXTitle("R [\\circ]");
96 fHistBroad.SetYTitle("W/R [1]");
97 fHistBroad.SetDirectory(NULL);
98 fHistBroad.UseCurrentStyle();
99 fHistBroad.SetFillStyle(4000);
100
101 fHistSize.SetName("SizeVsRadius");
102 fHistSize.SetTitle("Profile MuonSize vs Radius");
103 fHistSize.SetXTitle("R [\\circ]");
104 fHistSize.SetYTitle("S [phe]");
105 fHistSize.SetDirectory(NULL);
106 fHistSize.UseCurrentStyle();
107 fHistSize.SetFillStyle(4000);
108
109 MBinning bins;
110
111 bins.SetEdges(20, 0.5, 1.5);
112 bins.Apply(fHistRadius);
113
114 bins.SetEdges(60, 0., 0.3);
115 bins.Apply(fHistArcWidth);
116
117 bins.SetEdges(20, 0.5, 1.5);
118 bins.Apply(fHistBroad);
119
120 bins.SetEdges(20, 0.5, 1.5);
121 bins.Apply(fHistSize);
122}
123
124// --------------------------------------------------------------------------
125//
126// Setup the Binning for the histograms automatically if the correct
127// instances of MBinning
128//
129Bool_t MHMuonPar::SetupFill(const MParList *plist)
130{
131 MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
132 if (!geom)
133 {
134 *fLog << warn << "MGeomCam not found... abort." << endl;
135 return kFALSE;
136 }
137 fMm2Deg = geom->GetConvMm2Deg();
138
139 fMuonSearchPar = (MMuonSearchPar*)plist->FindObject("MMuonSearchPar");
140 if (!fMuonSearchPar)
141 {
142 *fLog << warn << "MMuonSearchPar not found... abort." << endl;
143 return kFALSE;
144 }
145 fMuonCalibPar = (MMuonCalibPar*)plist->FindObject("MMuonCalibPar");
146 if (!fMuonCalibPar)
147 {
148 *fLog << warn << "MMuonCalibPar not found... abort." << endl;
149 return kFALSE;
150 }
151
152 ApplyBinning(*plist, "Radius", &fHistRadius);
153 ApplyBinning(*plist, "ArcWidth", &fHistArcWidth);
154 ApplyBinning(*plist, "RingBroadening", &fHistBroad);
155 ApplyBinning(*plist, "SizeVsRadius", &fHistSize);
156
157 return kTRUE;
158}
159
160// --------------------------------------------------------------------------
161//
162// Fill the histograms with data from a MMuonCalibPar and
163// MMuonSearchPar container.
164//
165Bool_t MHMuonPar::Fill(const MParContainer *par, const Stat_t w)
166{
167 fHistRadius.Fill(fMm2Deg*fMuonSearchPar->GetRadius(), w);
168
169 fHistArcWidth.Fill(fMuonCalibPar->GetArcWidth(), w);
170
171 fHistBroad.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
172 fMuonCalibPar->GetArcWidth()/(fMm2Deg*fMuonSearchPar->GetRadius()), w);
173
174 fHistSize.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
175 fMuonCalibPar->GetMuonSize(), w);
176
177 return kTRUE;
178}
179// --------------------------------------------------------------------------
180//
181// Creates a new canvas and draws the two histograms into it.
182// Be careful: The histograms belongs to this object and won't get deleted
183// together with the canvas.
184//
185void MHMuonPar::Draw(Option_t *)
186{
187 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
188 pad->SetBorderMode(0);
189
190 AppendPad("");
191
192 pad->Divide(2,2);
193
194 pad->cd(1);
195 gPad->SetBorderMode(0);
196 fHistRadius.Draw();
197
198 pad->cd(2);
199 gPad->SetBorderMode(0);
200 fHistArcWidth.Draw();
201
202 pad->cd(3);
203 gPad->SetBorderMode(0);
204 fHistSize.Draw();
205
206 pad->cd(4);
207 gPad->SetBorderMode(0);
208 fHistBroad.Draw();
209
210 TF1 ref("RefShape", "0.112*x*x - 0.413*x + 0.404", 0.7, 1.2);
211 ref.SetLineColor(kBlue);
212 ref.SetLineWidth(1);
213 ref.SetLineStyle(kDashed);
214 ref.DrawCopy("same");
215
216 AppendPad("pad4");
217}
218
219void MHMuonPar::Paint(Option_t *opt)
220{
221 if (TString(opt)!=TString("pad4"))
222 return;
223
224 const Double_t lolim = 0.7;
225 const Double_t uplim = 1.2;
226
227 const Int_t bin1 = fHistBroad.GetXaxis()->FindFixBin(lolim);
228 const Int_t bin2 = fHistBroad.GetXaxis()->FindFixBin(uplim);
229
230 const TString txt = Form("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.3f", lolim,
231 uplim, fHistBroad.Integral(bin1, bin2));
232
233 TLatex text(0.57, 0.93, txt);
234 text.SetBit(TLatex::kTextNDC);
235 text.SetTextSize(0.055);
236 text.Paint();
237}
Note: See TracBrowser for help on using the repository browser.