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 |
|
---|
63 | ClassImp(MHMuonPar);
|
---|
64 |
|
---|
65 | using namespace std;
|
---|
66 |
|
---|
67 | const Float_t MHMuonPar::fgIntegralLoLim = 0.751;
|
---|
68 | const Float_t MHMuonPar::fgIntegralUpLim = 1.199;
|
---|
69 |
|
---|
70 | // --------------------------------------------------------------------------
|
---|
71 | //
|
---|
72 | // Setup histograms
|
---|
73 | //
|
---|
74 | MHMuonPar::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 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 | //
|
---|
136 | Bool_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 | //
|
---|
172 | Bool_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(), 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 | //
|
---|
192 | void 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 | gPad->SetGridx();
|
---|
204 | gPad->SetGridy();
|
---|
205 | fHistRadius.Draw();
|
---|
206 |
|
---|
207 | pad->cd(2);
|
---|
208 | gPad->SetBorderMode(0);
|
---|
209 | gPad->SetGridx();
|
---|
210 | gPad->SetGridy();
|
---|
211 | fHistArcWidth.Draw();
|
---|
212 |
|
---|
213 | pad->cd(3);
|
---|
214 | gPad->SetBorderMode(0);
|
---|
215 | gPad->SetGridx();
|
---|
216 | gPad->SetGridy();
|
---|
217 | fHistSize.Draw();
|
---|
218 |
|
---|
219 | TText txt;
|
---|
220 | txt.SetTextColor(kBlue);
|
---|
221 |
|
---|
222 | TF1 ref("RefShape100%", "-77.07+1249.3*x-351.2*x*x", fgIntegralLoLim, fgIntegralUpLim);
|
---|
223 | // old: 573*x + 430
|
---|
224 | ref.SetLineColor(kBlue);
|
---|
225 | ref.SetLineWidth(1);
|
---|
226 | ref.SetLineStyle(kDashed);
|
---|
227 | gROOT->GetListOfFunctions()->Remove(ref.DrawCopy("same"));
|
---|
228 |
|
---|
229 | txt.SetTextAlign(31);
|
---|
230 | txt.DrawText(fgIntegralLoLim, ref.Eval(fgIntegralLoLim+0.05), "100%");
|
---|
231 |
|
---|
232 | AppendPad("pad3");
|
---|
233 |
|
---|
234 | pad->cd(4);
|
---|
235 | gPad->SetBorderMode(0);
|
---|
236 | gPad->SetGridx();
|
---|
237 | gPad->SetGridy();
|
---|
238 | fHistBroad.Draw();
|
---|
239 |
|
---|
240 | ref.SetName("RefShape12mm");
|
---|
241 | ref.Compile("- 0.02711*x + 0.09359");
|
---|
242 | gROOT->GetListOfFunctions()->Remove(ref.DrawCopy("same"));
|
---|
243 |
|
---|
244 | txt.SetTextAlign(11);
|
---|
245 | txt.DrawText(fgIntegralLoLim, ref.Eval(fgIntegralLoLim-0.05), "12mm");
|
---|
246 |
|
---|
247 | AppendPad("pad4");
|
---|
248 | }
|
---|
249 | /*
|
---|
250 | Double_t MHMuonPar::Integral(const TProfile &p, Int_t a, Int_t b) const
|
---|
251 | {
|
---|
252 | Float_t numerator = 0;
|
---|
253 | Float_t denominator = 0;
|
---|
254 |
|
---|
255 | for (Int_t i=a; i<b; i++)
|
---|
256 | {
|
---|
257 | numerator += p.GetBinContent(i)*p.GetBinEntries(i);
|
---|
258 | denominator += p.GetBinEntries(i);
|
---|
259 | }
|
---|
260 |
|
---|
261 | return denominator==0 ? 0 : numerator/denominator;
|
---|
262 | }
|
---|
263 | */
|
---|
264 | Double_t MHMuonPar::Integral(const TProfile &p, Float_t a, Float_t b) const
|
---|
265 | {
|
---|
266 | const Int_t bin1 = p.GetXaxis()->FindFixBin(a);
|
---|
267 | const Int_t bin2 = p.GetXaxis()->FindFixBin(b);
|
---|
268 |
|
---|
269 | return p.Integral(bin1, bin2);
|
---|
270 | }
|
---|
271 |
|
---|
272 | void MHMuonPar::Paint(Option_t *opt)
|
---|
273 | {
|
---|
274 | if (TString(opt)==TString("pad4"))
|
---|
275 | {
|
---|
276 | const TString txt = Form("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.3f",
|
---|
277 | fgIntegralLoLim, fgIntegralUpLim, Integral(fHistBroad));
|
---|
278 |
|
---|
279 | TLatex text(0.55, 0.93, txt);
|
---|
280 | text.SetBit(TLatex::kTextNDC);
|
---|
281 | text.SetTextSize(0.055);
|
---|
282 | text.Paint();
|
---|
283 | }
|
---|
284 |
|
---|
285 | if (TString(opt)==TString("pad3"))
|
---|
286 | {
|
---|
287 | const TString txt = Form("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.f",
|
---|
288 | fgIntegralLoLim, fgIntegralUpLim, Integral(fHistSize));
|
---|
289 |
|
---|
290 | TLatex text(0.47, 0.93, txt);
|
---|
291 | text.SetBit(TLatex::kTextNDC);
|
---|
292 | text.SetTextSize(0.055);
|
---|
293 | text.Paint();
|
---|
294 | }
|
---|
295 | }
|
---|