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 | // --------------------------------------------------------------------------
|
---|
68 | //
|
---|
69 | // Setup histograms
|
---|
70 | //
|
---|
71 | MHMuonPar::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 | //
|
---|
129 | Bool_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 | //
|
---|
165 | Bool_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 | //
|
---|
185 | void 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 | AppendPad("pad3");
|
---|
207 |
|
---|
208 | pad->cd(4);
|
---|
209 | gPad->SetBorderMode(0);
|
---|
210 | fHistBroad.Draw();
|
---|
211 |
|
---|
212 | TF1 ref("RefShape", "0.112*x*x - 0.413*x + 0.404", 0.7, 1.2);
|
---|
213 | ref.SetLineColor(kBlue);
|
---|
214 | ref.SetLineWidth(1);
|
---|
215 | ref.SetLineStyle(kDashed);
|
---|
216 | ref.DrawCopy("same");
|
---|
217 |
|
---|
218 | AppendPad("pad4");
|
---|
219 | }
|
---|
220 |
|
---|
221 | void MHMuonPar::Paint(Option_t *opt)
|
---|
222 | {
|
---|
223 | if (TString(opt)==TString("pad4"))
|
---|
224 | {
|
---|
225 | const Double_t lolim = 0.7;
|
---|
226 | const Double_t uplim = 1.2;
|
---|
227 |
|
---|
228 | const Int_t bin1 = fHistBroad.GetXaxis()->FindFixBin(lolim);
|
---|
229 | const Int_t bin2 = fHistBroad.GetXaxis()->FindFixBin(uplim);
|
---|
230 |
|
---|
231 | const TString txt = Form("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.3f", lolim,
|
---|
232 | uplim, fHistBroad.Integral(bin1, bin2));
|
---|
233 |
|
---|
234 | TLatex text(0.57, 0.93, txt);
|
---|
235 | text.SetBit(TLatex::kTextNDC);
|
---|
236 | text.SetTextSize(0.055);
|
---|
237 | text.Paint();
|
---|
238 | }
|
---|
239 |
|
---|
240 | if (TString(opt)==TString("pad3"))
|
---|
241 | {
|
---|
242 | const Double_t lolim = 0.7;
|
---|
243 | const Double_t uplim = 1.2;
|
---|
244 |
|
---|
245 | const Int_t bin1 = fHistSize.GetXaxis()->FindFixBin(lolim);
|
---|
246 | const Int_t bin2 = fHistSize.GetXaxis()->FindFixBin(uplim);
|
---|
247 |
|
---|
248 | const TString txt = Form("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.f", lolim,
|
---|
249 | uplim, fHistSize.Integral(bin1, bin2));
|
---|
250 |
|
---|
251 | TLatex text(0.47, 0.93, txt);
|
---|
252 | text.SetBit(TLatex::kTextNDC);
|
---|
253 | text.SetTextSize(0.055);
|
---|
254 | text.Paint();
|
---|
255 | }
|
---|
256 | }
|
---|