8 * @ingroup pwglf_forward_scripts_tests
11 MakeIntegerAxis(Int_t& nBins, Double_t& min, Double_t& max)
13 if (nBins <= 0) return;
14 if (max <= 0) max = nBins;
16 Double_t dBin = max / nBins;
28 * @ingroup pwglf_forward_scripts_tests
31 TestPoisson(Double_t o=.3, bool useWeights=false, bool correct=true)
33 const char* load = "$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C";
35 gROOT->GetInterpreter()->UnloadFile(gSystem->ExpandPathName(load));
37 // --- Parameters of this script -----------------------------------
38 Int_t nBin = 5; // Our detector matrix size
39 Int_t nMax = TMath::Max(Int_t(nBin * nBin * o + .5)+nBin/2,nBin);
40 Int_t nEv = 10000; // Number of events
41 Double_t mp = o; // The 'hit' probability
44 TH2D* base = new TH2D("base", "Basic histogram",
45 nBin,-.5, nBin-.5, nBin, -.5, nBin-.5);
46 base->SetXTitle("#eta");
47 base->SetYTitle("#varphi");
48 base->SetDirectory(0);
49 base->SetOption("colz");
51 Int_t tN1=nMax; Double_t tMin1; Double_t tMax1;
52 Int_t tN2=nMax*10; Double_t tMin2; Double_t tMax2=nMax;
53 MakeIntegerAxis(tN1, tMin1, tMax1);
54 MakeIntegerAxis(tN2, tMin2, tMax2);
55 TH2D* corr = new TH2D("comp", "Comparison",
56 tN1, tMin1, tMax1, tN2, tMin2, tMax2);
57 corr->SetXTitle("Input");
58 corr->SetYTitle("Poisson");
59 corr->SetDirectory(0);
60 corr->SetOption("colz");
62 TLine* lcorr = new TLine(0, 0, tMax2, tMax2);
64 Int_t mm = TMath::Max(Int_t(nBin * o + .5),nBin/2);
65 tN2=mm*10; tMax2 = mm;
66 MakeIntegerAxis(tN2, tMin2, tMax2);
67 Info("", "Making mean w/nbins=%d,range=[%f,%f]", tN2, tMin2, tMax2);
68 TH2D* mean = new TH2D("mean", "Mean comparison",
69 tN2, tMin2, tMax2, tN2, tMin2, tMax2);
70 mean->SetXTitle("Input");
71 mean->SetYTitle("Poisson");
72 mean->SetDirectory(0);
73 mean->SetOption("colz");
75 TLine* lmean = new TLine(tMin2, tMin2, tMax2, tMax2);
77 TH1D* dist = new TH1D("dist", "Distribution of hits", tN1, tMin1, tMax1);
79 dist->SetYTitle("P(s)");
80 dist->SetFillColor(kRed+1);
81 dist->SetFillStyle(3001);
82 dist->SetDirectory(0);
84 TH1D* diff = new TH1D("diff", "P-T", 100, -25, 25);
85 diff->SetXTitle("Difference");
86 diff->SetFillColor(kRed+1);
87 diff->SetFillStyle(3001);
88 diff->SetYTitle("Prob");
90 AliPoissonCalculator* c = new AliPoissonCalculator("ignored");
93 for (Int_t i = 0; i < nEv; i++) {
97 for (Int_t iEta = 0; iEta < nBin; iEta++) {
98 for (Int_t iPhi = 0; iPhi < nBin; iPhi++) {
100 Int_t m = gRandom->Poisson(mp);
103 // Fill into our base histogram
104 base->Fill(iEta, iPhi, m);
106 // Fill into poisson calculator
107 c->Fill(iEta, iPhi, m > 0, (useWeights ? m : 1));
110 // Calculate the result
111 TH2D* res = c->Result(correct);
113 // Now loop and compare
116 for (Int_t iEta = 0; iEta < nBin; iEta++) {
117 for (Int_t iPhi = 0; iPhi < nBin; iPhi++) {
118 Double_t p = res->GetBinContent(iEta, iPhi);
119 Double_t t = base->GetBinContent(iEta, iPhi);
127 Int_t nn = nBin * nBin;
128 mean->Fill(mBase / nn, mPois / nn);
131 TCanvas* cc = new TCanvas("c", "c", 900, 900);
134 cc->SetBorderMode(0);
135 cc->SetRightMargin(0.02);
136 cc->SetTopMargin(0.02);
139 TVirtualPad* pp = cc->cd(1);
142 pp->SetBorderMode(0);
143 pp->SetRightMargin(0.15);
144 pp->SetTopMargin(0.02);
154 pp->SetBorderMode(0);
155 pp->SetRightMargin(0.02);
156 pp->SetTopMargin(0.02);
158 c->GetMean()->Draw();
163 c->GetOccupancy()->Draw();
167 dist->Scale(1. / dist->Integral());
169 TH1D* m1 = c->GetMean();
170 m1->Scale(1. / m1->Integral());
173 Double_t ii = 100 * dist->Integral(2, 0);
174 TLatex* ll = new TLatex(.97, .85,
175 Form("Input #bar{m}: %5.3f", mp));
177 ll->SetTextFont(132);
178 ll->SetTextAlign(31);
180 ll->DrawLatex(.97, .75, Form("Result #bar{m}: %5.3f", dist->GetMean()));
181 ll->DrawLatex(.97, .65, Form("Occupancy: #int_{1}^{#infty}P(s)ds = %6.2f%%",
189 pp->SetBorderMode(0);
190 pp->SetRightMargin(0.15);
191 pp->SetTopMargin(0.02);
194 c->GetCorrection()->Draw();
199 pp->SetBorderMode(0);
200 pp->SetRightMargin(0.15);
201 pp->SetTopMargin(0.02);