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 |
|
---|
65 | ClassImp(MHMuonPar);
|
---|
66 |
|
---|
67 | using namespace std;
|
---|
68 |
|
---|
69 | const Float_t MHMuonPar::fgIntegralLoLim = 0.751;
|
---|
70 | const Float_t MHMuonPar::fgIntegralUpLim = 1.199;
|
---|
71 |
|
---|
72 | // --------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | // Setup histograms
|
---|
75 | //
|
---|
76 | MHMuonPar::MHMuonPar(const char *name, const char *title) :
|
---|
77 | fMuonSearchPar(NULL), fMuonCalibPar(NULL), fGeom(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 | //
|
---|
138 | Bool_t MHMuonPar::SetupFill(const MParList *plist)
|
---|
139 | {
|
---|
140 | fGeom = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
141 | if (!fGeom)
|
---|
142 | {
|
---|
143 | *fLog << warn << "MGeomCam not found... abort." << endl;
|
---|
144 | return kFALSE;
|
---|
145 | }
|
---|
146 |
|
---|
147 | fMuonSearchPar = (MMuonSearchPar*)plist->FindObject("MMuonSearchPar");
|
---|
148 | if (!fMuonSearchPar)
|
---|
149 | {
|
---|
150 | *fLog << warn << "MMuonSearchPar not found... abort." << endl;
|
---|
151 | return kFALSE;
|
---|
152 | }
|
---|
153 | fMuonCalibPar = (MMuonCalibPar*)plist->FindObject("MMuonCalibPar");
|
---|
154 | if (!fMuonCalibPar)
|
---|
155 | {
|
---|
156 | *fLog << warn << "MMuonCalibPar not found... abort." << endl;
|
---|
157 | return kFALSE;
|
---|
158 | }
|
---|
159 |
|
---|
160 | ApplyBinning(*plist, "Radius", &fHistRadius);
|
---|
161 | ApplyBinning(*plist, "ArcWidth", &fHistArcWidth);
|
---|
162 | ApplyBinning(*plist, "RingBroadening", &fHistBroad);
|
---|
163 | ApplyBinning(*plist, "SizeVsRadius", &fHistSize);
|
---|
164 |
|
---|
165 | return kTRUE;
|
---|
166 | }
|
---|
167 |
|
---|
168 | // --------------------------------------------------------------------------
|
---|
169 | //
|
---|
170 | // Fill the histograms with data from a MMuonCalibPar and
|
---|
171 | // MMuonSearchPar container.
|
---|
172 | //
|
---|
173 | Int_t MHMuonPar::Fill(const MParContainer *par, const Stat_t w)
|
---|
174 | {
|
---|
175 | const Double_t fMm2Deg = fGeom->GetConvMm2Deg();
|
---|
176 |
|
---|
177 | fHistRadius.Fill(fMm2Deg*fMuonSearchPar->GetRadius(), w);
|
---|
178 |
|
---|
179 | fHistArcWidth.Fill(fMuonCalibPar->GetArcWidth(), w);
|
---|
180 |
|
---|
181 | fHistBroad.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
|
---|
182 | fMuonCalibPar->GetArcWidth(), w);
|
---|
183 |
|
---|
184 | fHistSize.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
|
---|
185 | fMuonCalibPar->GetMuonSize(), w);
|
---|
186 |
|
---|
187 | return kTRUE;
|
---|
188 | }
|
---|
189 | // --------------------------------------------------------------------------
|
---|
190 | //
|
---|
191 | // Creates a new canvas and draws the two histograms into it.
|
---|
192 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
193 | // together with the canvas.
|
---|
194 | //
|
---|
195 | void MHMuonPar::Draw(Option_t *)
|
---|
196 | {
|
---|
197 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
198 | pad->SetBorderMode(0);
|
---|
199 |
|
---|
200 | AppendPad("");
|
---|
201 |
|
---|
202 | pad->Divide(2,2);
|
---|
203 |
|
---|
204 | pad->cd(1);
|
---|
205 | gPad->SetBorderMode(0);
|
---|
206 | gPad->SetGridx();
|
---|
207 | gPad->SetGridy();
|
---|
208 | fHistRadius.Draw();
|
---|
209 |
|
---|
210 | pad->cd(2);
|
---|
211 | gPad->SetBorderMode(0);
|
---|
212 | gPad->SetGridx();
|
---|
213 | gPad->SetGridy();
|
---|
214 | fHistArcWidth.Draw();
|
---|
215 |
|
---|
216 | pad->cd(3);
|
---|
217 | gPad->SetBorderMode(0);
|
---|
218 | gPad->SetGridx();
|
---|
219 | gPad->SetGridy();
|
---|
220 | fHistSize.Draw();
|
---|
221 |
|
---|
222 | TText txt;
|
---|
223 | txt.SetTextColor(kBlue);
|
---|
224 |
|
---|
225 | TF1 ref("RefShape100%", "-77.07+1249.3*x-351.2*x*x", fgIntegralLoLim, fgIntegralUpLim);
|
---|
226 | // old: 573*x + 430
|
---|
227 | ref.SetLineColor(kBlue);
|
---|
228 | ref.SetLineWidth(1);
|
---|
229 | ref.SetLineStyle(kDashed);
|
---|
230 | gROOT->GetListOfFunctions()->Remove(ref.DrawCopy("same"));
|
---|
231 |
|
---|
232 | txt.SetTextAlign(31);
|
---|
233 | txt.DrawText(fgIntegralLoLim, ref.Eval(fgIntegralLoLim+0.05), "100%");
|
---|
234 |
|
---|
235 | AppendPad("pad3");
|
---|
236 |
|
---|
237 | pad->cd(4);
|
---|
238 | gPad->SetBorderMode(0);
|
---|
239 | gPad->SetGridx();
|
---|
240 | gPad->SetGridy();
|
---|
241 | fHistBroad.Draw();
|
---|
242 |
|
---|
243 | ref.SetName("RefShape12mm");
|
---|
244 | ref.Compile("- 0.02711*x + 0.09359");
|
---|
245 | gROOT->GetListOfFunctions()->Remove(ref.DrawCopy("same"));
|
---|
246 |
|
---|
247 | txt.SetTextAlign(11);
|
---|
248 | txt.DrawText(fgIntegralLoLim, ref.Eval(fgIntegralLoLim-0.05), "12mm");
|
---|
249 |
|
---|
250 | AppendPad("pad4");
|
---|
251 | }
|
---|
252 | /*
|
---|
253 | Double_t MHMuonPar::Integral(const TProfile &p, Int_t a, Int_t b) const
|
---|
254 | {
|
---|
255 | Float_t numerator = 0;
|
---|
256 | Float_t denominator = 0;
|
---|
257 |
|
---|
258 | for (Int_t i=a; i<b; i++)
|
---|
259 | {
|
---|
260 | numerator += p.GetBinContent(i)*p.GetBinEntries(i);
|
---|
261 | denominator += p.GetBinEntries(i);
|
---|
262 | }
|
---|
263 |
|
---|
264 | return denominator==0 ? 0 : numerator/denominator;
|
---|
265 | }
|
---|
266 | */
|
---|
267 | Double_t MHMuonPar::Integral(const TProfile &p, Float_t a, Float_t b) const
|
---|
268 | {
|
---|
269 | const Int_t bin1 = p.GetXaxis()->FindFixBin(a);
|
---|
270 | const Int_t bin2 = p.GetXaxis()->FindFixBin(b);
|
---|
271 |
|
---|
272 | return p.Integral(bin1, bin2);
|
---|
273 | }
|
---|
274 |
|
---|
275 | void MHMuonPar::Paint(Option_t *opt)
|
---|
276 | {
|
---|
277 | if (TString(opt)==TString("pad4"))
|
---|
278 | {
|
---|
279 | const TString txt = MString::Format("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.3f",
|
---|
280 | fgIntegralLoLim, fgIntegralUpLim, Integral(fHistBroad));
|
---|
281 |
|
---|
282 | TLatex text(0.55, 0.93, txt);
|
---|
283 | text.SetBit(TLatex::kTextNDC);
|
---|
284 | text.SetTextSize(0.055);
|
---|
285 | text.Paint();
|
---|
286 | }
|
---|
287 |
|
---|
288 | if (TString(opt)==TString("pad3"))
|
---|
289 | {
|
---|
290 | const TString txt = MString::Format("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.f",
|
---|
291 | fgIntegralLoLim, fgIntegralUpLim, Integral(fHistSize));
|
---|
292 |
|
---|
293 | TLatex text(0.47, 0.93, txt);
|
---|
294 | text.SetBit(TLatex::kTextNDC);
|
---|
295 | text.SetTextSize(0.055);
|
---|
296 | text.Paint();
|
---|
297 | }
|
---|
298 | }
|
---|