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): Thomas Bretz, 07/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2005
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHPhi
|
---|
28 | //
|
---|
29 | // Plot delta phi the angle between the reconstructed shower origin and
|
---|
30 | // the source position.
|
---|
31 | //
|
---|
32 | // More detail can be found at:
|
---|
33 | // http://www.astro.uni-wuerzburg.de/results/ringmethod/
|
---|
34 | //
|
---|
35 | ////////////////////////////////////////////////////////////////////////////
|
---|
36 | #include "MHPhi.h"
|
---|
37 |
|
---|
38 | #include <TCanvas.h>
|
---|
39 | #include <TVector2.h>
|
---|
40 | #include <TLatex.h>
|
---|
41 | #include <TLine.h>
|
---|
42 | #include <TMarker.h>
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MParList.h"
|
---|
48 |
|
---|
49 | #include "MHillas.h"
|
---|
50 | #include "MSrcPosCam.h"
|
---|
51 | #include "MParameters.h"
|
---|
52 | #include "MGeomCam.h"
|
---|
53 | #include "MBinning.h"
|
---|
54 | #include "MMath.h"
|
---|
55 |
|
---|
56 | ClassImp(MHPhi);
|
---|
57 |
|
---|
58 | using namespace std;
|
---|
59 |
|
---|
60 | // --------------------------------------------------------------------------
|
---|
61 | //
|
---|
62 | // Setup histograms
|
---|
63 | //
|
---|
64 | MHPhi::MHPhi(const char *name, const char *title)
|
---|
65 | : fHillas(0), fSrcPos(0), fDisp(0)//, fOnOffMode(kTRUE), fIsOffLoop(kFALSE)
|
---|
66 | {
|
---|
67 | fName = name ? name : "MHPhi";
|
---|
68 | fTitle = title ? title : "Graphs for rate data";
|
---|
69 |
|
---|
70 | // Init Graphs
|
---|
71 | fHPhi.SetNameTitle("Phi", "\\Delta\\Phi-Distribution");
|
---|
72 |
|
---|
73 | fHPhi.SetXTitle("\\Delta\\Phi [\\circ]");
|
---|
74 | fHPhi.SetYTitle("Counts");
|
---|
75 |
|
---|
76 | fHPhi.SetMinimum(0);
|
---|
77 | fHPhi.SetDirectory(0);
|
---|
78 | fHPhi.Sumw2();
|
---|
79 | fHPhi.SetBit(TH1::kNoStats);
|
---|
80 | fHPhi.SetMarkerStyle(kFullDotMedium);
|
---|
81 |
|
---|
82 | fHPhi.GetYaxis()->SetTitleOffset(1.2);
|
---|
83 |
|
---|
84 | /*
|
---|
85 | fNameParameter = "Disp";
|
---|
86 |
|
---|
87 | fHist.SetNameTitle("Phi", "\\Delta\\Phi-Distribution");
|
---|
88 | fHist.SetZTitle("\\Delta\\Phi [\\circ]");
|
---|
89 | fHist.SetDirectory(NULL);
|
---|
90 |
|
---|
91 | // Main histogram
|
---|
92 | fHistTime.SetName("Phi");
|
---|
93 | fHistTime.SetXTitle("\\Delta\\Phi [\\circ]");
|
---|
94 | fHistTime.SetDirectory(NULL);
|
---|
95 |
|
---|
96 | MBinning binsa, binse, binst;
|
---|
97 | //binsa.SetEdges(75, 0, 1.5);
|
---|
98 | //binsa.SetEdges(arr);
|
---|
99 | binse.SetEdgesLog(15, 10, 100000);
|
---|
100 | binst.SetEdgesASin(67, -0.005, 0.665);
|
---|
101 | //binsa.Apply(fHistTime);
|
---|
102 |
|
---|
103 | MH::SetBinning(&fHist, &binst, &binse, &binsa);
|
---|
104 | */
|
---|
105 | }
|
---|
106 |
|
---|
107 | /*
|
---|
108 | Double_t MHPhi::GetVal() const
|
---|
109 | {
|
---|
110 | const Dopuble_t disp = static_cast<const MParameterD*>(fParameter)->GetVal();
|
---|
111 |
|
---|
112 | const TVector2 pos = fHillas->GetMean()*fConvMm2Deg + fHillas->GetNormAxis()*disp;
|
---|
113 | const TVector2 src = fSrcPos->GetXY()*fConvMm2Deg;
|
---|
114 |
|
---|
115 | // Calculate radial distance.
|
---|
116 | const Double_t d = pos.Mod() - src.Mod();
|
---|
117 |
|
---|
118 | if (d<-fThetaCut*0.913 || d>fThetaCut)
|
---|
119 | return kTRUE;
|
---|
120 |
|
---|
121 | const Double_t delta = src.DeltaPhi(pos)*TMath::RadToDeg();
|
---|
122 | const Double_t absd = TMath::Abs(delta)
|
---|
123 |
|
---|
124 | return fHistOff ? absd : 180-absd;
|
---|
125 | }
|
---|
126 | */
|
---|
127 |
|
---|
128 | // --------------------------------------------------------------------------
|
---|
129 | //
|
---|
130 | // Setup the Binning for the histograms automatically if the correct
|
---|
131 | // instances of MBinning
|
---|
132 | //
|
---|
133 | Bool_t MHPhi::SetupFill(const MParList *plist)
|
---|
134 | {
|
---|
135 | fHillas = (MHillas*)plist->FindObject("MHillas");
|
---|
136 | if (!fHillas)
|
---|
137 | {
|
---|
138 | *fLog << err << "MHillas not found... abort." << endl;
|
---|
139 | return kFALSE;
|
---|
140 | }
|
---|
141 | fSrcPos = (MSrcPosCam*)plist->FindObject("MSrcPosCam");
|
---|
142 | if (!fSrcPos)
|
---|
143 | {
|
---|
144 | *fLog << err << "MSrcPosCam not found... abort." << endl;
|
---|
145 | return kFALSE;
|
---|
146 | }
|
---|
147 | fDisp = (MParameterD*)plist->FindObject("Disp", "MParameterD");
|
---|
148 | if (!fDisp)
|
---|
149 | {
|
---|
150 | *fLog << err << "Disp [MParameterD] not found... abort." << endl;
|
---|
151 | return kFALSE;
|
---|
152 | }
|
---|
153 |
|
---|
154 | MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
155 | if (!geom)
|
---|
156 | {
|
---|
157 | *fLog << err << "MGeomCam not found... abort." << endl;
|
---|
158 | return kFALSE;
|
---|
159 | }
|
---|
160 |
|
---|
161 | fConvMm2Deg = geom->GetConvMm2Deg();
|
---|
162 |
|
---|
163 | fNumBinsSignal = 2;
|
---|
164 | fThetaCut = 0.21/1.2;
|
---|
165 | fDistSrc = 0.4;
|
---|
166 | //fIsOffLoop = !fIsOffLoop;
|
---|
167 |
|
---|
168 | const Double_t w = TMath::ATan(fThetaCut/fDistSrc);
|
---|
169 | const Float_t sz = TMath::RadToDeg()*w/fNumBinsSignal;
|
---|
170 | const Int_t n = TMath::Nint(TMath::Ceil(180/sz));
|
---|
171 |
|
---|
172 | MBinning(n, 0, n*sz).Apply(fHPhi);
|
---|
173 | /*
|
---|
174 |
|
---|
175 | // Get Histogram binnings
|
---|
176 | MBinning binst, binse;
|
---|
177 | binst.SetEdges(fHist, 'x');
|
---|
178 | binse.SetEdges(fHist, 'y');
|
---|
179 |
|
---|
180 | MBinning binsa(n, 0, n*sz);
|
---|
181 |
|
---|
182 | // Apply binning
|
---|
183 | binsa.Apply(fHistTime);
|
---|
184 | MH::SetBinning(&fHist, &binst, &binse, &binsa);
|
---|
185 |
|
---|
186 | // Remark: Binnings might be overwritten in MHAlpha::SetupFill
|
---|
187 | return MHAlpha::SetupFill(pl);
|
---|
188 | */
|
---|
189 | return kTRUE;
|
---|
190 | }
|
---|
191 |
|
---|
192 | // --------------------------------------------------------------------------
|
---|
193 | //
|
---|
194 | // Fill the histograms with data from a MMuonCalibPar and
|
---|
195 | // MMuonSearchPar container.
|
---|
196 | //
|
---|
197 | Bool_t MHPhi::Fill(const MParContainer *par, const Stat_t weight)
|
---|
198 | {
|
---|
199 | const TVector2 pos = fHillas->GetMean()*fConvMm2Deg + fHillas->GetNormAxis()*fDisp->GetVal();
|
---|
200 | const TVector2 src = fSrcPos->GetXY()*fConvMm2Deg;
|
---|
201 |
|
---|
202 | // Calculate radial distance.
|
---|
203 | const Double_t d = pos.Mod() - src.Mod();
|
---|
204 |
|
---|
205 | if (d<-fThetaCut*0.913 || d>fThetaCut)
|
---|
206 | return kTRUE;
|
---|
207 |
|
---|
208 | const Double_t delta = src.DeltaPhi(pos)*TMath::RadToDeg();
|
---|
209 |
|
---|
210 | fHPhi.Fill(TMath::Abs(delta), weight);
|
---|
211 |
|
---|
212 | // const Double_t absd = TMath::Abs(delta)
|
---|
213 | // fHPhi.Fill(fHistOff ? absd : 180-absd, weight);
|
---|
214 |
|
---|
215 | return kTRUE;
|
---|
216 | }
|
---|
217 |
|
---|
218 | // --------------------------------------------------------------------------
|
---|
219 | //
|
---|
220 | // This displays the TGraph like you expect it to be (eg. time on the axis)
|
---|
221 | // It should also make sure, that the displayed time always is UTC and
|
---|
222 | // not local time...
|
---|
223 | //
|
---|
224 | void MHPhi::Draw(Option_t *opt)
|
---|
225 | {
|
---|
226 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
227 | pad->SetBorderMode(0);
|
---|
228 |
|
---|
229 | AppendPad("combine");
|
---|
230 |
|
---|
231 | fHPhi.Draw();
|
---|
232 |
|
---|
233 | AppendPad(opt);
|
---|
234 | }
|
---|
235 |
|
---|
236 | void MHPhi::Paint(Option_t *o)
|
---|
237 | {
|
---|
238 | //TString opt(o);
|
---|
239 | //opt.ToLower();
|
---|
240 |
|
---|
241 | // if (opt=="combine" && fHistOff)
|
---|
242 | // {
|
---|
243 | // fHPhi.Add(fHist, fHistOff);
|
---|
244 | // return;
|
---|
245 | // }
|
---|
246 |
|
---|
247 | const Bool_t wobble = TString(o).Contains("anticut", TString::kIgnoreCase);
|
---|
248 |
|
---|
249 | const Double_t cut = fHPhi.GetBinLowEdge(fNumBinsSignal+1);
|
---|
250 |
|
---|
251 | const Int_t maxbin = wobble ? fHPhi.GetXaxis()->FindFixBin(180-cut)-1 : fHPhi.GetNbinsX();
|
---|
252 | const Double_t cut2 = wobble ? fHPhi.GetBinLowEdge(maxbin+1) : 180;
|
---|
253 |
|
---|
254 | const Double_t sig = fHPhi.Integral(1, fNumBinsSignal);
|
---|
255 | const Double_t bg = fHPhi.Integral(1+fNumBinsSignal, maxbin);
|
---|
256 |
|
---|
257 | const Double_t f = cut/(cut2-cut);
|
---|
258 |
|
---|
259 | const Double_t S0 = MMath::SignificanceLiMaSigned(sig, bg*f);
|
---|
260 | const Double_t S = MMath::SignificanceLiMaSigned(sig, bg, f);
|
---|
261 |
|
---|
262 | const TString fmt = Form("\\sigma_{L/M}=%.1f (\\sigma_{0}=%.1f) \\Delta\\Phi_{on}<%.1f\\circ \\Delta\\Phi_{off}<%.1f\\circ E=%.0f B=%.0f f=%.2f",
|
---|
263 | S, S0, cut, cut2, sig-bg*f, bg*f, f);
|
---|
264 |
|
---|
265 | const Double_t b = bg *f/fNumBinsSignal;
|
---|
266 | const Double_t e = TMath::Sqrt(bg)*f/fNumBinsSignal;
|
---|
267 |
|
---|
268 | TLatex text(0.27, 0.94, fmt);
|
---|
269 | text.SetBit(TLatex::kTextNDC);
|
---|
270 | text.SetTextSize(0.035);
|
---|
271 | text.Paint();
|
---|
272 |
|
---|
273 | TLine line;
|
---|
274 | line.SetLineColor(14);
|
---|
275 | line.PaintLine(cut, gPad->GetUymin(), cut, gPad->GetUymax());
|
---|
276 | if (maxbin<fHPhi.GetNbinsX())
|
---|
277 | line.PaintLine(cut2, gPad->GetUymin(), cut2, gPad->GetUymax());
|
---|
278 | line.SetLineColor(kBlue);
|
---|
279 | line.PaintLine(0, b, cut, b);
|
---|
280 | line.PaintLine(cut/2, b-e, cut/2, b+e);
|
---|
281 | line.SetLineStyle(kDashed);
|
---|
282 | line.PaintLine(cut, b, fHPhi.GetXaxis()->GetXmax(), b);
|
---|
283 |
|
---|
284 | TMarker m;
|
---|
285 | m.SetMarkerColor(kBlue);
|
---|
286 | m.SetMarkerStyle(kFullDotMedium);
|
---|
287 | m.PaintMarker(cut/2, b);
|
---|
288 | }
|
---|