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, 5/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2005
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MHDisp
|
---|
28 | //
|
---|
29 | // Create a false source plot using disp.
|
---|
30 | //
|
---|
31 | // Currently the use of this class requires to be after MFMagicCuts
|
---|
32 | // in the tasklist. Switching of the M3L cut in MFMagicCuts is recommended.
|
---|
33 | //
|
---|
34 | //////////////////////////////////////////////////////////////////////////////
|
---|
35 | #include "MHDisp.h"
|
---|
36 |
|
---|
37 | #include <TStyle.h>
|
---|
38 | #include <TCanvas.h>
|
---|
39 |
|
---|
40 | #include <TF1.h>
|
---|
41 | #include <TF2.h>
|
---|
42 | #include <TProfile.h>
|
---|
43 |
|
---|
44 | #include "MLog.h"
|
---|
45 | #include "MLogManip.h"
|
---|
46 |
|
---|
47 | #include "MMath.h"
|
---|
48 | #include "MBinning.h"
|
---|
49 |
|
---|
50 | #include "MParList.h"
|
---|
51 | #include "MParameters.h"
|
---|
52 |
|
---|
53 | #include "MHillas.h"
|
---|
54 | #include "MSrcPosCam.h"
|
---|
55 | #include "MPointingPos.h"
|
---|
56 | #include "MPointingDev.h"
|
---|
57 |
|
---|
58 | ClassImp(MHDisp);
|
---|
59 |
|
---|
60 | using namespace std;
|
---|
61 |
|
---|
62 | // --------------------------------------------------------------------------
|
---|
63 | //
|
---|
64 | // Default Constructor
|
---|
65 | //
|
---|
66 | MHDisp::MHDisp(const char *name, const char *title)
|
---|
67 | : fDisp(0), fDeviation(0), fSmearing(-1), fWobble(kFALSE)
|
---|
68 | {
|
---|
69 | //
|
---|
70 | // set the name and title of this object
|
---|
71 | //
|
---|
72 | fName = name ? name : "MHDisp";
|
---|
73 | fTitle = title ? title : "3D-plot using Disp vs x, y";
|
---|
74 |
|
---|
75 | fHist.SetName("Alpha");
|
---|
76 | fHist.SetTitle("3D-plot of ThetaSq vs x, y");
|
---|
77 | fHist.SetXTitle("x [\\circ]");
|
---|
78 | fHist.SetYTitle("y [\\circ]");
|
---|
79 | fHist.SetZTitle("Eq.cts");
|
---|
80 |
|
---|
81 | fHist.SetDirectory(NULL);
|
---|
82 | fHistBg.SetDirectory(NULL);
|
---|
83 | fHistBg1.SetDirectory(NULL);
|
---|
84 | fHistBg2.SetDirectory(NULL);
|
---|
85 |
|
---|
86 | fHist.SetBit(TH1::kNoStats);
|
---|
87 | }
|
---|
88 |
|
---|
89 | // --------------------------------------------------------------------------
|
---|
90 | //
|
---|
91 | // Set binnings (takes BinningFalseSource) and prepare filling of the
|
---|
92 | // histogram.
|
---|
93 | //
|
---|
94 | // Also search for MTime, MObservatory and MPointingPos
|
---|
95 | //
|
---|
96 | Bool_t MHDisp::SetupFill(const MParList *plist)
|
---|
97 | {
|
---|
98 | if (!MHFalseSource::SetupFill(plist))
|
---|
99 | return kFALSE;
|
---|
100 |
|
---|
101 | fDisp = (MParameterD*)plist->FindObject("Disp", "MParameterD");
|
---|
102 | if (!fDisp)
|
---|
103 | {
|
---|
104 | *fLog << err << "Disp [MParameterD] not found... abort." << endl;
|
---|
105 | return kFALSE;
|
---|
106 | }
|
---|
107 |
|
---|
108 | fDeviation = (MPointingDev*)plist->FindObject("MPointingDev");
|
---|
109 | if (!fDeviation)
|
---|
110 | *fLog << warn << "MPointingDev not found... ignored." << endl;
|
---|
111 |
|
---|
112 | MBinning binsx, binsy;
|
---|
113 | binsx.SetEdges(fHist, 'x');
|
---|
114 | binsy.SetEdges(fHist, 'y');
|
---|
115 | MH::SetBinning(&fHistBg, &binsx, &binsy);
|
---|
116 |
|
---|
117 | if (!fHistOff)
|
---|
118 | {
|
---|
119 | MH::SetBinning(&fHistBg1, &binsx, &binsy);
|
---|
120 | MH::SetBinning(&fHistBg2, &binsx, &binsy);
|
---|
121 | }
|
---|
122 |
|
---|
123 | return kTRUE;
|
---|
124 | }
|
---|
125 |
|
---|
126 | // --------------------------------------------------------------------------
|
---|
127 | //
|
---|
128 | // Calculate the delta angle between fSrcPos->GetXY() and v.
|
---|
129 | // Return result in deg.
|
---|
130 | //
|
---|
131 | Double_t MHDisp::DeltaPhiSrc(const TVector2 &v) const
|
---|
132 | {
|
---|
133 | return TMath::Abs(fSrcPos->GetXY().DeltaPhi(v))*TMath::RadToDeg();
|
---|
134 | }
|
---|
135 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // Fill the histogram. For details see the code or the class description
|
---|
139 | //
|
---|
140 | Bool_t MHDisp::Fill(const MParContainer *par, const Stat_t w)
|
---|
141 | {
|
---|
142 | const MHillas *hil = dynamic_cast<const MHillas*>(par);
|
---|
143 | if (!hil)
|
---|
144 | {
|
---|
145 | *fLog << err << "MHDisp::Fill: No container specified!" << endl;
|
---|
146 | return kFALSE;
|
---|
147 | }
|
---|
148 |
|
---|
149 | // Get camera rotation angle
|
---|
150 | Double_t rho = 0;
|
---|
151 | if (fTime && fObservatory && fPointPos)
|
---|
152 | rho = fPointPos->RotationAngle(*fObservatory, *fTime, fDeviation);
|
---|
153 |
|
---|
154 | // Vector of length disp in direction of shower
|
---|
155 | const TVector2 p(hil->GetCosDelta(), hil->GetSinDelta());
|
---|
156 |
|
---|
157 | // Move origin of vector to center-of-gravity of shower and derotate
|
---|
158 | TVector2 pos1 = hil->GetMean()*fMm2Deg + p*fDisp->GetVal();
|
---|
159 |
|
---|
160 | Double_t w0 = 1;
|
---|
161 | if (fWobble)
|
---|
162 | {
|
---|
163 | const Double_t delta = DeltaPhiSrc(pos1);
|
---|
164 |
|
---|
165 | // Skip off-data not in the same half than the source (here: anti-source)
|
---|
166 | // Could be replaced by some kind of theta cut...
|
---|
167 | if (!fHistOff)
|
---|
168 | {
|
---|
169 | if (delta>165)
|
---|
170 | return kTRUE;
|
---|
171 |
|
---|
172 | // Because afterwards the plots are normalized with the number
|
---|
173 | // of entries the non-overlap region corresponds to half the
|
---|
174 | // contents, the overlap region to full contents. By taking
|
---|
175 | // the mean of both distributions we get the same result than
|
---|
176 | // we would have gotten using full off-events with a slightly
|
---|
177 | // increased uncertainty
|
---|
178 | // FIXME: The delta stuff could be replaced by a 2*antitheta cut...
|
---|
179 | w0 = delta>15 ? 1 : 2;
|
---|
180 | }
|
---|
181 |
|
---|
182 | // Define by the source position which histogram to fill
|
---|
183 | if (DeltaPhiSrc(fFormerSrc)>90)
|
---|
184 | fHalf = !fHalf;
|
---|
185 | fFormerSrc = fSrcPos->GetXY();
|
---|
186 | }
|
---|
187 |
|
---|
188 | // If on-data: Derotate source and P. Translate P to center.
|
---|
189 | TVector2 m;
|
---|
190 | if (fHistOff)
|
---|
191 | {
|
---|
192 | // Derotate all position around camera center by -rho
|
---|
193 | // Move origin of vector to center-of-gravity of shower and derotate
|
---|
194 | pos1=pos1.Rotate(-rho);
|
---|
195 |
|
---|
196 | // Shift the source position to 0/0
|
---|
197 | if (fSrcPos)
|
---|
198 | {
|
---|
199 | // m: Position of the camera center in the FS plot
|
---|
200 | m = fSrcPos->GetXY().Rotate(-rho)*fMm2Deg;
|
---|
201 | pos1 -= m;
|
---|
202 | }
|
---|
203 | }
|
---|
204 |
|
---|
205 | // -------------------------------------------------
|
---|
206 | // The following algorithm may look complicated...
|
---|
207 | // It is optimized for speed
|
---|
208 | // -------------------------------------------------
|
---|
209 |
|
---|
210 | // Define a vector used to calculate rotated x and y component
|
---|
211 | const TVector2 rot(TMath::Sin(rho), TMath::Cos(rho));
|
---|
212 |
|
---|
213 | // Fold event position with the PSF and fill it into histogram
|
---|
214 | const TAxis &axex = *fHist.GetXaxis();
|
---|
215 | const TAxis &axey = *fHist.GetYaxis();
|
---|
216 |
|
---|
217 | const Int_t nx = axex.GetNbins();
|
---|
218 | const Int_t ny = axey.GetNbins();
|
---|
219 |
|
---|
220 | // normg: Normalization for Gauss [sqrt(2*pi)*sigma]^2
|
---|
221 | const Double_t weight = axex.GetBinWidth(1)*axey.GetBinWidth(1)*w*w0;
|
---|
222 | const Double_t psf = 2*fSmearing*fSmearing;
|
---|
223 | const Double_t pi2 = fSmearing * TMath::Pi()/2;
|
---|
224 | const Double_t normg = pi2*pi2 * TMath::Sqrt(TMath::TwoPi()) / weight;
|
---|
225 | const Int_t bz = fHist.GetZaxis()->FindFixBin(0);
|
---|
226 |
|
---|
227 | TH2 &bg = fHalf ? fHistBg1 : fHistBg2;
|
---|
228 |
|
---|
229 | const Bool_t smear = fSmearing>0;
|
---|
230 | if (!smear)
|
---|
231 | {
|
---|
232 | if (!fHistOff)
|
---|
233 | bg.Fill(pos1.X(), pos1.Y(), w*w0);
|
---|
234 | else
|
---|
235 | fHist.Fill(pos1.X(), pos1.Y(), 0.0, w*w0);
|
---|
236 | }
|
---|
237 |
|
---|
238 | // To calculate significance map smear with 2*theta-cut and
|
---|
239 | // do not normalize gauss, for event map use theta-cut/2 instead
|
---|
240 | if (smear || fHistOff)
|
---|
241 | {
|
---|
242 | for (int x=1; x<=nx; x++)
|
---|
243 | {
|
---|
244 | const Double_t cx = axex.GetBinCenter(x);
|
---|
245 | const Double_t px = cx-pos1.X();
|
---|
246 |
|
---|
247 | for (int y=1; y<=ny; y++)
|
---|
248 | {
|
---|
249 | const Double_t cy = axey.GetBinCenter(y);
|
---|
250 | const Double_t sp = Sq(px, cy-pos1.Y());
|
---|
251 | if (smear)
|
---|
252 | {
|
---|
253 | const Double_t dp = sp/psf;
|
---|
254 |
|
---|
255 | // Values below 1e-3 (>3.5sigma) are not filled into the histogram
|
---|
256 | if (dp<4)
|
---|
257 | {
|
---|
258 | const Double_t rc = TMath::Exp(-dp)/normg;
|
---|
259 | if (!fHistOff)
|
---|
260 | bg.AddBinContent(bg.GetBin(x, y), rc);
|
---|
261 | else
|
---|
262 | fHist.AddBinContent(fHist.GetBin(x, y, bz), rc);
|
---|
263 | }
|
---|
264 | }
|
---|
265 |
|
---|
266 | if (!fHistOff)
|
---|
267 | continue;
|
---|
268 |
|
---|
269 | // If we are filling the signal already (fHistOff!=NULL)
|
---|
270 | // we also fill the background by projecting the
|
---|
271 | // background in the camera into the sky plot.
|
---|
272 | const TVector2 v = TVector2(cx+m.X(), cy+m.Y());
|
---|
273 |
|
---|
274 | // Speed up further: Xmax-fWobble
|
---|
275 | if (v.Mod()>axex.GetXmax()) // Gains 10% speed
|
---|
276 | continue;
|
---|
277 |
|
---|
278 | const Int_t bx = axex.FindFixBin(v^rot);
|
---|
279 | const Int_t by = axey.FindFixBin(v*rot);
|
---|
280 | const Double_t bg = fHistOff->GetBinContent(bx, by, bz);
|
---|
281 |
|
---|
282 | fHistBg.AddBinContent(fHistBg.GetBin(x, y), bg);
|
---|
283 | }
|
---|
284 | }
|
---|
285 | }
|
---|
286 |
|
---|
287 | if (fHistOff)
|
---|
288 | fHistBg.SetEntries(fHistBg.GetEntries()+1);
|
---|
289 |
|
---|
290 | if (!smear)
|
---|
291 | return kTRUE;
|
---|
292 |
|
---|
293 | if (!fHistOff)
|
---|
294 | bg.SetEntries(bg.GetEntries()+1);
|
---|
295 | else
|
---|
296 | fHist.SetEntries(fHist.GetEntries()+1);
|
---|
297 |
|
---|
298 | return kTRUE;
|
---|
299 | }
|
---|
300 |
|
---|
301 | // --------------------------------------------------------------------------
|
---|
302 | //
|
---|
303 | // Compile the background in camera coordinates from the two background
|
---|
304 | // histograms
|
---|
305 | //
|
---|
306 | Bool_t MHDisp::Finalize()
|
---|
307 | {
|
---|
308 | if (fHistOff)
|
---|
309 | return kTRUE;
|
---|
310 |
|
---|
311 | const Int_t bz = fHist.GetZaxis()->FindFixBin(0);
|
---|
312 |
|
---|
313 | const Double_t n1 = fHistBg1.GetEntries();
|
---|
314 | const Double_t n2 = fHistBg2.GetEntries();
|
---|
315 |
|
---|
316 | for (int x=1; x<=fHist.GetNbinsX(); x++)
|
---|
317 | for (int y=1; y<=fHist.GetNbinsY(); y++)
|
---|
318 | {
|
---|
319 | const Int_t bin1 = fHistBg1.GetBin(x, y);
|
---|
320 |
|
---|
321 | const Double_t rc =
|
---|
322 | (n1==0?0:fHistBg1.GetBinContent(bin1)/n1)+
|
---|
323 | (n2==0?0:fHistBg2.GetBinContent(bin1)/n2);
|
---|
324 |
|
---|
325 | fHist.SetBinContent(x, y, bz, rc/2);
|
---|
326 | }
|
---|
327 |
|
---|
328 | fHist.SetEntries(n1+n2);
|
---|
329 |
|
---|
330 | // Result corresponds to one smeared background event
|
---|
331 |
|
---|
332 | return kTRUE;
|
---|
333 | }
|
---|
334 |
|
---|
335 |
|
---|
336 | // --------------------------------------------------------------------------
|
---|
337 | //
|
---|
338 | // Return the mean signal in h around (0,0) in a distance between
|
---|
339 | // 0.325 and 0.475deg
|
---|
340 | //
|
---|
341 | Double_t MHDisp::GetOffSignal(TH1 &h) const
|
---|
342 | {
|
---|
343 | const TAxis &axex = *h.GetXaxis();
|
---|
344 | const TAxis &axey = *h.GetYaxis();
|
---|
345 |
|
---|
346 | Int_t cnt = 0;
|
---|
347 | Double_t sum = 0;
|
---|
348 | for (int x=0; x<h.GetNbinsX(); x++)
|
---|
349 | for (int y=0; y<h.GetNbinsY(); y++)
|
---|
350 | {
|
---|
351 | const Double_t d = TMath::Hypot(axex.GetBinCenter(x+1), axey.GetBinCenter(y+1));
|
---|
352 | if (d>0.325 && d<0.475)
|
---|
353 | {
|
---|
354 | sum += h.GetBinContent(x+1,y+1);
|
---|
355 | cnt++;
|
---|
356 | }
|
---|
357 | }
|
---|
358 | return sum/cnt;
|
---|
359 | }
|
---|
360 |
|
---|
361 | // --------------------------------------------------------------------------
|
---|
362 | //
|
---|
363 | // Fill h2 with the radial profile of h1 around (x0, y0)
|
---|
364 | //
|
---|
365 | void MHDisp::Profile(TH1 &h2, const TH2 &h1, Axis_t x0, Axis_t y0) const
|
---|
366 | {
|
---|
367 | const TAxis &axex = *h1.GetXaxis();
|
---|
368 | const TAxis &axey = *h1.GetYaxis();
|
---|
369 |
|
---|
370 | h2.Reset();
|
---|
371 |
|
---|
372 | for (int x=1; x<=axex.GetNbins(); x++)
|
---|
373 | for (int y=1; y<=axey.GetNbins(); y++)
|
---|
374 | {
|
---|
375 | const Double_t dx = axex.GetBinCenter(x)-x0;
|
---|
376 | const Double_t dy = axey.GetBinCenter(y)-y0;
|
---|
377 |
|
---|
378 | const Double_t r = TMath::Hypot(dx, dy);
|
---|
379 |
|
---|
380 | h2.Fill(r, h1.GetBinContent(x, y));
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | // --------------------------------------------------------------------------
|
---|
385 | //
|
---|
386 | // Remove contents of histogram around a circle.
|
---|
387 | //
|
---|
388 | void MHDisp::MakeDot(TH2 &h2) const
|
---|
389 | {
|
---|
390 | const TAxis &axex = *h2.GetXaxis();
|
---|
391 | const TAxis &axey = *h2.GetYaxis();
|
---|
392 |
|
---|
393 | const Double_t rmax = fWobble ? axex.GetXmax()-0.4 : axex.GetXmax();
|
---|
394 |
|
---|
395 | for (int x=1; x<=axex.GetNbins(); x++)
|
---|
396 | for (int y=1; y<=axey.GetNbins(); y++)
|
---|
397 | {
|
---|
398 | const Int_t bin = h2.GetBin(x,y);
|
---|
399 |
|
---|
400 | const Double_t px = h2.GetBinCenter(x);
|
---|
401 | const Double_t py = h2.GetBinCenter(y);
|
---|
402 |
|
---|
403 | if (rmax<TMath::Hypot(px, py))
|
---|
404 | h2.SetBinContent(bin, 0);
|
---|
405 | else
|
---|
406 | if (h2.GetBinContent(bin)==0)
|
---|
407 | h2.SetBinContent(bin, 1e-10);
|
---|
408 | }
|
---|
409 | }
|
---|
410 |
|
---|
411 | // --------------------------------------------------------------------------
|
---|
412 | //
|
---|
413 | // Calculate from signal and background the significance map
|
---|
414 | //
|
---|
415 | void MHDisp::MakeSignificance(TH2 &s, const TH2 &h1, const TH2 &h2, const Double_t scale) const
|
---|
416 | {
|
---|
417 | const TAxis &axex = *s.GetXaxis();
|
---|
418 | const TAxis &axey = *s.GetYaxis();
|
---|
419 |
|
---|
420 | const Int_t n = TMath::Nint(0.2/axex.GetBinWidth(1));
|
---|
421 |
|
---|
422 | for (int x=1+n; x<=axex.GetNbins()-n; x++)
|
---|
423 | for (int y=1+n; y<=axey.GetNbins()-n; y++)
|
---|
424 | {
|
---|
425 | Double_t sig=0;
|
---|
426 | Double_t bg =0;
|
---|
427 |
|
---|
428 | for (int dx=-n; dx<=n; dx++)
|
---|
429 | for (int dy=-n; dy<=n; dy++)
|
---|
430 | {
|
---|
431 | if (TMath::Hypot((float)dx, (float)dy)>n)
|
---|
432 | continue;
|
---|
433 |
|
---|
434 | const Int_t bin = s.GetBin(x+dx,y+dy);
|
---|
435 |
|
---|
436 | sig += h1.GetBinContent(bin);
|
---|
437 | bg += h2.GetBinContent(bin);
|
---|
438 | }
|
---|
439 |
|
---|
440 | const Double_t S = sig>0 ? MMath::SignificanceLiMaSigned(sig, bg, TMath::Abs(scale)) : 0;
|
---|
441 |
|
---|
442 | const Int_t bin = s.GetBin(x,y);
|
---|
443 | s.SetBinContent(bin, S);
|
---|
444 | }
|
---|
445 | }
|
---|
446 |
|
---|
447 | void MHDisp::Profile1D(const char *name, const TH2 &h) const
|
---|
448 | {
|
---|
449 | if (!gPad)
|
---|
450 | return;
|
---|
451 |
|
---|
452 | TH1D *hrc = dynamic_cast<TH1D*>(gPad->FindObject(name));
|
---|
453 | if (!hrc)
|
---|
454 | return;
|
---|
455 |
|
---|
456 | hrc->Reset();
|
---|
457 |
|
---|
458 | const Double_t max = h.GetMaximum();
|
---|
459 |
|
---|
460 | MBinning(50, -max*1.1, max*1.1).Apply(*hrc);
|
---|
461 |
|
---|
462 | for (int x=1; x<=h.GetXaxis()->GetNbins(); x++)
|
---|
463 | for (int y=1; y<=h.GetXaxis()->GetNbins(); y++)
|
---|
464 | {
|
---|
465 | const Int_t bin = h.GetBin(x,y);
|
---|
466 | const Double_t sig = h.GetBinContent(bin);
|
---|
467 | if (sig!=0)
|
---|
468 | hrc->Fill(sig);
|
---|
469 | }
|
---|
470 |
|
---|
471 | gPad->SetLogy(hrc->GetMaximum()>0);
|
---|
472 |
|
---|
473 | if (!fHistOff || hrc->GetRMS()<0.1)
|
---|
474 | return;
|
---|
475 |
|
---|
476 | // ---------- Fix mean ----------
|
---|
477 | // TF1 *g = (TF1*)gROOT->GetFunction("gaus");
|
---|
478 | // g->FixParameter(1, 0);
|
---|
479 | // hrc->Fit("gaus", "BQI");
|
---|
480 |
|
---|
481 | hrc->Fit("gaus", "QI");
|
---|
482 |
|
---|
483 | TF1 *f = hrc->GetFunction("gaus");
|
---|
484 | if (f)
|
---|
485 | {
|
---|
486 | f->SetLineWidth(1);
|
---|
487 | f->SetLineColor(kBlue);
|
---|
488 | }
|
---|
489 | }
|
---|
490 |
|
---|
491 | void MHDisp::Paint(Option_t *o)
|
---|
492 | {
|
---|
493 | // Compile Background if necessary
|
---|
494 | Finalize();
|
---|
495 |
|
---|
496 | // Paint result
|
---|
497 | TVirtualPad *pad = gPad;
|
---|
498 |
|
---|
499 | pad->cd(1);
|
---|
500 |
|
---|
501 | // Project on data onto yx-plane
|
---|
502 | fHist.GetZaxis()->SetRange(0,9999);
|
---|
503 | TH2 *h1=(TH2*)fHist.Project3D("yx_on");
|
---|
504 |
|
---|
505 | // Set Glow-palette (PaintSurface doesn't allow more than 99 colors)
|
---|
506 | MH::SetPalette(fHistOff?"glowsym":"glow1", 99);
|
---|
507 | h1->SetContour(99);
|
---|
508 |
|
---|
509 | TH2 *hx=0;
|
---|
510 |
|
---|
511 | Double_t scale = 1;
|
---|
512 | if (fHistOff)
|
---|
513 | {
|
---|
514 | // Project off data onto yx-plane and subtract it from on-data
|
---|
515 | fHistOff->GetZaxis()->SetRange(0,9999);
|
---|
516 | TH2 *h=(TH2*)fHistOff->Project3D("yx_off");
|
---|
517 |
|
---|
518 | const Double_t h1off = GetOffSignal(*h1);
|
---|
519 | const Double_t hoff = GetOffSignal(fHistBg);
|
---|
520 |
|
---|
521 | scale = hoff==0 ? -1 : -h1off/hoff;
|
---|
522 |
|
---|
523 | hx = (TH2*)pad->GetPad(4)->FindObject("Alpha_yx_sig");
|
---|
524 | if (hx)
|
---|
525 | {
|
---|
526 | hx->SetContour(99);
|
---|
527 | MakeSignificance(*hx, *h1, fHistBg, scale);
|
---|
528 | MakeDot(*hx);
|
---|
529 | MakeSymmetric(hx);
|
---|
530 | }
|
---|
531 |
|
---|
532 | h1->Add(&fHistBg, scale);
|
---|
533 |
|
---|
534 | MakeDot(*h1);
|
---|
535 | MakeSymmetric(h1);
|
---|
536 |
|
---|
537 | delete h;
|
---|
538 | }
|
---|
539 |
|
---|
540 | pad->cd(3);
|
---|
541 | TH1 *h2 = (TH1*)gPad->FindObject("RadProf");
|
---|
542 |
|
---|
543 | TString opt(o);
|
---|
544 | opt.ToLower();
|
---|
545 |
|
---|
546 | if (h1 && h2)
|
---|
547 | {
|
---|
548 | Int_t ix, iy, iz;
|
---|
549 | h1->GetMaximumBin(ix, iy, iz);
|
---|
550 |
|
---|
551 | const Double_t x0 = h1->GetXaxis()->GetBinCenter(ix);
|
---|
552 | const Double_t y0 = h1->GetYaxis()->GetBinCenter(iy);
|
---|
553 | //const Double_t w0 = h1->GetXaxis()->GetBinWidth(1);
|
---|
554 |
|
---|
555 | Profile(*h2, *h1, 0, 0);
|
---|
556 | //Profile(*h2, *h1, x0, y0);
|
---|
557 |
|
---|
558 | // Replace with MAlphaFitter?
|
---|
559 | TF1 func("fcn", "gaus + [3]*x*x + [4]");
|
---|
560 | func.SetLineWidth(1);
|
---|
561 | func.SetLineColor(kBlue);
|
---|
562 |
|
---|
563 | func.SetParLimits(2, h2->GetBinWidth(1), 1.0);
|
---|
564 |
|
---|
565 | func.SetParameter(0, h2->GetBinContent(1));
|
---|
566 | func.FixParameter(1, 0);
|
---|
567 | func.SetParameter(2, 0.12);
|
---|
568 | if (fHistOff)
|
---|
569 | func.FixParameter(3, 0);
|
---|
570 | func.SetParameter(4, 0);//h2->GetBinContent(20));
|
---|
571 | h2->Fit(&func, "IQ", "", 0, 1.0);
|
---|
572 |
|
---|
573 | h2->SetTitle(Form("P=(%.2f\\circ/%.2f\\circ) \\omega=%.2f\\circ f=%.2f", x0, y0, func.GetParameter(2), TMath::Abs(scale)));
|
---|
574 | }
|
---|
575 |
|
---|
576 | pad->cd(5);
|
---|
577 | if (h1)
|
---|
578 | Profile1D("Exc", *h1);
|
---|
579 |
|
---|
580 | pad->cd(6);
|
---|
581 | if (hx)
|
---|
582 | Profile1D("Sig", *hx);
|
---|
583 | }
|
---|
584 |
|
---|
585 | void MHDisp::Draw(Option_t *o)
|
---|
586 | {
|
---|
587 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
588 | const Int_t col = pad->GetFillColor();
|
---|
589 | pad->SetBorderMode(0);
|
---|
590 |
|
---|
591 | AppendPad(o);
|
---|
592 |
|
---|
593 | // ----- Pad number 4 -----
|
---|
594 | TString name = Form("%s_4", pad->GetName());
|
---|
595 | TPad *p = new TPad(name,name, 0.5025, 0.3355, 0.995, 0.995, col, 0, 0);
|
---|
596 | p->SetNumber(4);
|
---|
597 | p->Draw();
|
---|
598 | p->cd();
|
---|
599 |
|
---|
600 | TH1 *h3 = fHist.Project3D("yx_sig");
|
---|
601 | h3->SetTitle("Significance Map");
|
---|
602 | h3->SetDirectory(NULL);
|
---|
603 | h3->SetXTitle(fHist.GetXaxis()->GetTitle());
|
---|
604 | h3->SetYTitle(fHist.GetYaxis()->GetTitle());
|
---|
605 | h3->SetMinimum(0);
|
---|
606 | h3->Draw("colz");
|
---|
607 | h3->SetBit(kCanDelete);
|
---|
608 |
|
---|
609 | if (fHistOff)
|
---|
610 | GetCatalog()->Draw("white mirror same *");
|
---|
611 |
|
---|
612 | // ----- Pad number 1 -----
|
---|
613 | pad->cd();
|
---|
614 | name = Form("%s_1", pad->GetName());
|
---|
615 | p = new TPad(name,name, 0.005, 0.3355, 0.4975, 0.995, col, 0, 0);
|
---|
616 | p->SetNumber(1);
|
---|
617 | p->Draw();
|
---|
618 | p->cd();
|
---|
619 |
|
---|
620 | h3 = fHist.Project3D("yx_on");
|
---|
621 | h3->SetTitle("Distribution of equivalent events");
|
---|
622 | h3->SetDirectory(NULL);
|
---|
623 | h3->SetXTitle(fHist.GetXaxis()->GetTitle());
|
---|
624 | h3->SetYTitle(fHist.GetYaxis()->GetTitle());
|
---|
625 | h3->SetMinimum(0);
|
---|
626 | h3->Draw("colz");
|
---|
627 | h3->SetBit(kCanDelete);
|
---|
628 |
|
---|
629 | if (fHistOff)
|
---|
630 | GetCatalog()->Draw("white mirror same *");
|
---|
631 |
|
---|
632 | // ----- Pad number 2 -----
|
---|
633 | pad->cd();
|
---|
634 | name = Form("%s_2", pad->GetName());
|
---|
635 | p = new TPad(name,name, 0.005, 0.005, 0.2485, 0.3315, col, 0, 0);
|
---|
636 | p->SetNumber(2);
|
---|
637 | p->Draw();
|
---|
638 | p->cd();
|
---|
639 | h3->Draw("surf3");
|
---|
640 |
|
---|
641 | // ----- Pad number 3 -----
|
---|
642 | pad->cd();
|
---|
643 | name = Form("%s_3", pad->GetName());
|
---|
644 | p = new TPad(name,name, 0.2525, 0.005, 0.4985, 0.3315, col, 0, 0);
|
---|
645 | p->SetNumber(3);
|
---|
646 | p->SetGrid();
|
---|
647 | p->Draw();
|
---|
648 | p->cd();
|
---|
649 |
|
---|
650 | const Double_t maxr = TMath::Hypot(h3->GetXaxis()->GetXmax(), h3->GetYaxis()->GetXmax());
|
---|
651 | const Int_t nbin = (h3->GetNbinsX()+h3->GetNbinsY())/2;
|
---|
652 | TProfile *h = new TProfile("RadProf", "Radial Profile", nbin, 0, maxr);
|
---|
653 | h->SetDirectory(0);
|
---|
654 | //TH1F *h = new TH1F("RadProf", "Radial Profile", nbin, 0, maxr);
|
---|
655 | //h->Sumw2();
|
---|
656 | h->SetXTitle("\\vartheta [\\circ]");
|
---|
657 | h->SetYTitle("<cts>/\\Delta R");
|
---|
658 | h->SetBit(kCanDelete);
|
---|
659 | h->Draw();
|
---|
660 |
|
---|
661 | // ----- Pad number 5 -----
|
---|
662 | pad->cd();
|
---|
663 | name = Form("%s_5", pad->GetName());
|
---|
664 | p = new TPad(name,name, 0.5025, 0.005, 0.7485, 0.3315, col, 0, 0);
|
---|
665 | p->SetNumber(5);
|
---|
666 | p->SetGrid();
|
---|
667 | p->Draw();
|
---|
668 | p->cd();
|
---|
669 |
|
---|
670 | h3 = new TH1D("Exc", "Distribution of excess events", 10, -1, 1);
|
---|
671 | h3->SetDirectory(NULL);
|
---|
672 | h3->SetXTitle("N");
|
---|
673 | h3->SetYTitle("Counts");
|
---|
674 | h3->Draw();
|
---|
675 | h3->SetBit(kCanDelete);
|
---|
676 |
|
---|
677 | // ----- Pad number 6 -----
|
---|
678 | pad->cd();
|
---|
679 | name = Form("%s_6", pad->GetName());
|
---|
680 | p = new TPad(name,name, 0.7525, 0.005, 0.9995, 0.3315, col, 0, 0);
|
---|
681 | p->SetNumber(6);
|
---|
682 | p->SetGrid();
|
---|
683 | p->Draw();
|
---|
684 | p->cd();
|
---|
685 |
|
---|
686 | h3 = new TH1D("Sig", "Distribution of significances", 10, -1, 1);
|
---|
687 | h3->SetDirectory(NULL);
|
---|
688 | h3->SetXTitle("N");
|
---|
689 | h3->SetYTitle("Counts");
|
---|
690 | h3->Draw();
|
---|
691 | h3->SetBit(kCanDelete);
|
---|
692 | }
|
---|
693 |
|
---|
694 | // --------------------------------------------------------------------------
|
---|
695 | //
|
---|
696 | // The following resources are available:
|
---|
697 | //
|
---|
698 | // MHDisp.Smearing: 0.1
|
---|
699 | // MHDisp.Wobble: on/off
|
---|
700 | //
|
---|
701 | Int_t MHDisp::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
702 | {
|
---|
703 | Int_t rc = MHFalseSource::ReadEnv(env, prefix, print);
|
---|
704 | if (rc==kERROR)
|
---|
705 | return kERROR;
|
---|
706 |
|
---|
707 | if (IsEnvDefined(env, prefix, "Smearing", print))
|
---|
708 | {
|
---|
709 | rc = kTRUE;
|
---|
710 | SetSmearing(GetEnvValue(env, prefix, "Smearing", fSmearing));
|
---|
711 | }
|
---|
712 | if (IsEnvDefined(env, prefix, "Wobble", print))
|
---|
713 | {
|
---|
714 | rc = kTRUE;
|
---|
715 | SetWobble(GetEnvValue(env, prefix, "Wobble", fWobble));
|
---|
716 | }
|
---|
717 |
|
---|
718 | return rc;
|
---|
719 | }
|
---|
720 |
|
---|