8 * @ingroup pwg2_forward_analysis_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 pwg2_forward_analysis_scripts_tests
31 TestPoisson(Double_t o=.3, bool useWeights=false)
33 const char* load = "$ALICE_ROOT/PWG2/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 AliPoissonCalculator* c = new AliPoissonCalculator("ignored");
87 for (Int_t i = 0; i < nEv; i++) {
91 for (Int_t iEta = 0; iEta < nBin; iEta++) {
92 for (Int_t iPhi = 0; iPhi < nBin; iPhi++) {
94 Int_t m = gRandom->Poisson(mp);
97 // Fill into our base histogram
98 base->Fill(iEta, iPhi, m);
100 // Fill into poisson calculator
101 c->Fill(iEta, iPhi, m > 0, (useWeights ? m : 1));
104 // Calculate the result
105 TH2D* res = c->Result();
107 // Now loop and compare
110 for (Int_t iEta = 0; iEta < nBin; iEta++) {
111 for (Int_t iPhi = 0; iPhi < nBin; iPhi++) {
112 Double_t p = res->GetBinContent(iEta, iPhi);
113 Double_t t = base->GetBinContent(iEta, iPhi);
120 Int_t nn = nBin * nBin;
121 mean->Fill(mBase / nn, mPois / nn);
124 TCanvas* cc = new TCanvas("c", "c", 900, 900);
127 cc->SetBorderMode(0);
128 cc->SetRightMargin(0.02);
129 cc->SetTopMargin(0.02);
132 TVirtualPad* pp = cc->cd(1);
135 pp->SetBorderMode(0);
136 pp->SetRightMargin(0.15);
137 pp->SetTopMargin(0.02);
147 pp->SetBorderMode(0);
148 pp->SetRightMargin(0.02);
149 pp->SetTopMargin(0.02);
151 c->GetMean()->Draw();
153 c->GetOccupancy()->Draw();
157 dist->Scale(1. / dist->Integral());
159 TH1D* m1 = c->GetMean();
160 m1->Scale(1. / m1->Integral());
163 Double_t ii = 100 * dist->Integral(2, 0);
164 TLatex* ll = new TLatex(.97, .85,
165 Form("Input #bar{m}: %5.3f", mp));
167 ll->SetTextFont(132);
168 ll->SetTextAlign(31);
170 ll->DrawLatex(.97, .75, Form("Result #bar{m}: %5.3f", dist->GetMean()));
171 ll->DrawLatex(.97, .65, Form("Occupancy: #int_{1}^{#infty}P(s)ds = %6.2f%%",
179 pp->SetBorderMode(0);
180 pp->SetRightMargin(0.15);
181 pp->SetTopMargin(0.02);
184 c->GetCorrection()->Draw();
189 pp->SetBorderMode(0);
190 pp->SetRightMargin(0.15);
191 pp->SetTopMargin(0.02);