1 #include "AliPoissonCalculator.h"
10 // A class to calculate the multiplicity in @f$(\eta,\varphi)@f$ bins
11 // using Poisson statistics.
13 // The input is assumed to be binned in @f$(\eta,\varphi)@f$ as
14 // described by the 2D histogram passwd to the Reset member function.
16 // The data is grouped in to regions as defined by the parameters
17 // fEtaLumping and fPhiLumping. The total number of cells and number
18 // of empty cells is then calculate in each region. The mean
19 // multiplicity over the region is then determined as
22 // \lange m\rangle = -\log\left(\frac{e}{t}\right)
24 // where @f$ e@f$ is the number of empty cells and @f$t@f$ is the
25 // total number of cells in the region. A correction for counting
26 // statistics, is then applied
28 // c &=& \frac{1}{1 - \exp{-\lange m\rangle}}
29 // &=& \frac{1}{1 - \frac{e}{t}}
31 // and the final number in each cell is then
33 // h_i c \lange m\rangle
35 // where @f$h_i@f$ is the number of hits in the cell @f$i@f$
39 //____________________________________________________________________
40 AliPoissonCalculator::AliPoissonCalculator()
57 //____________________________________________________________________
58 AliPoissonCalculator::AliPoissonCalculator(const char*)
59 : TNamed("poissonCalculator", "Calculate N_ch using Poisson stat"),
74 //____________________________________________________________________
75 AliPoissonCalculator::AliPoissonCalculator(const AliPoissonCalculator& o)
77 fEtaLumping(o.fEtaLumping),
78 fPhiLumping(o.fPhiLumping),
91 //____________________________________________________________________
92 AliPoissonCalculator::~AliPoissonCalculator()
97 //____________________________________________________________________
99 AliPoissonCalculator::CleanUp()
101 if (fTotal) delete fTotal; fTotal = 0;
102 if (fEmpty) delete fEmpty; fEmpty = 0;
103 if (fBasic) delete fBasic; fBasic = 0;
104 if (fEmptyVsTotal) delete fEmptyVsTotal; fEmptyVsTotal = 0;
105 if (fMean) delete fMean; fMean = 0;
106 if (fOcc) delete fOcc; fOcc = 0;
107 if (fCorr) delete fCorr; fCorr = 0;
109 //____________________________________________________________________
110 AliPoissonCalculator&
111 AliPoissonCalculator::operator=(const AliPoissonCalculator& o)
113 TNamed::operator=(o);
114 fEtaLumping = o.fEtaLumping;
115 fPhiLumping = o.fPhiLumping;
122 //____________________________________________________________________
124 AliPoissonCalculator::Init(Int_t etaLumping, Int_t phiLumping)
129 if (etaLumping > 0) SetEtaLumping(etaLumping);
130 if (phiLumping > 0) SetPhiLumping(phiLumping);
131 if (fEmptyVsTotal) return;
133 Int_t n = fEtaLumping * fPhiLumping + 1;
134 fEmptyVsTotal = new TH2D("emptyVsTotal",
135 "# of empty # bins vs total # bins",
136 n, -.5, n-.5, n, -.5, n-.5);
137 fEmptyVsTotal->SetXTitle("Total # bins");
138 fEmptyVsTotal->SetYTitle("# empty bins");
139 fEmptyVsTotal->SetZTitle("Correlation");
140 fEmptyVsTotal->SetOption("colz");
141 fEmptyVsTotal->SetDirectory(0);
143 n = (fEtaLumping + fPhiLumping);
144 fMean = new TH1D("poissonMean", "Mean N_{ch} as calculated by Poisson",
146 fMean->SetXTitle("#bar{N_{ch}}=#log(empty/total)");
147 fMean->SetYTitle("Events");
148 fMean->SetFillColor(kRed+1);
149 fMean->SetFillStyle(3001);
150 fMean->SetLineColor(kBlack);
151 fMean->SetDirectory(0);
153 fOcc = new TH1D("occupancy", "Occupancy = #int_{1}^{#infty}dN P(N)",
155 fOcc->SetXTitle("#int_{1}^{#infty}dN P(N) [%]");
156 fOcc->SetYTitle("Events");
157 fOcc->SetFillColor(kBlue+1);
158 fOcc->SetFillStyle(3001);
159 fOcc->SetLineColor(kBlack);
160 fOcc->SetDirectory(0);
162 fCorr = new TH2D("correction", "Correction as function of mean N_{ch}",
163 10*n+1, -.1, n+.1, 100, 0, 10);
164 fCorr->SetXTitle("#bar{N_{ch}}");
165 fCorr->SetYTitle("Correction 1/(1-e^{#bar{N_{c}}})");
166 fCorr->SetZTitle("Events");
167 fCorr->SetOption("colz");
168 fCorr->SetDirectory(0);
171 //____________________________________________________________________
173 AliPoissonCalculator::Output(TList* d)
176 if (!fEmptyVsTotal) Init();
177 d->Add(fEmptyVsTotal);
183 //____________________________________________________________________
185 AliPoissonCalculator::Reset(const TH2D* base)
191 if (fBasic && fTotal && fEmpty) {
198 Int_t nEtaF = base->GetNbinsX();
199 Int_t nEta = nEtaF / fEtaLumping;
200 Double_t etaMin = base->GetXaxis()->GetXmin();
201 Double_t etaMax = base->GetXaxis()->GetXmax();
202 Int_t nPhiF = base->GetNbinsY();
203 Int_t nPhi = nPhiF / fPhiLumping;
204 Double_t phiMin = base->GetYaxis()->GetXmin();
205 Double_t phiMax = base->GetYaxis()->GetXmax();
207 fTotal = new TH2D("total", "Total number of bins/region",
208 nEta, etaMin, etaMax, nPhi, phiMin, phiMax);
209 fEmpty = new TH2D("empty", "Empty number of bins/region",
210 nEta, etaMin, etaMax, nPhi, phiMin, phiMax);
211 fBasic = new TH2D("basic", "Basic number of hits",
212 nEtaF, etaMin, etaMax, nPhiF, phiMin, phiMax);
214 fTotal->SetDirectory(0);
215 fEmpty->SetDirectory(0);
216 fBasic->SetDirectory(0);
217 fTotal->SetXTitle("#eta");
218 fEmpty->SetXTitle("#eta");
219 fBasic->SetXTitle("#eta");
220 fTotal->SetYTitle("#varphi [radians]");
221 fEmpty->SetYTitle("#varphi [radians]");
222 fBasic->SetYTitle("#varphi [radians]");
228 //____________________________________________________________________
230 AliPoissonCalculator::Fill(Double_t eta, Double_t phi, Bool_t hit,
234 // Fill in an observation
240 // weight Weight if this
242 fTotal->Fill(eta, phi);
243 if (hit) fBasic->Fill(eta, phi, weight);
244 else fEmpty->Fill(eta, phi);
247 //____________________________________________________________________
249 AliPoissonCalculator::CalculateMean(Double_t empty, Double_t total) const
251 if (total <= 0) return 0;
252 if (empty < .001) empty = .001;
253 return -TMath::Log(empty/total);
255 //____________________________________________________________________
257 AliPoissonCalculator::CalculateCorrection(Double_t empty, Double_t total) const
259 if (total <= 0) return 0;
260 if (TMath::Abs(empty-total) < .001) empty = total - .001;
261 return 1 / (1 - empty / total);
264 //____________________________________________________________________
266 AliPoissonCalculator::Result()
269 // Calculate result and store in @a output
272 // The result histogram (fBase overwritten)
274 for (Int_t ieta = 1; ieta <= fBasic->GetNbinsX(); ieta++) {
275 for (Int_t iphi = 1; iphi <= fBasic->GetNbinsY(); iphi++) {
276 Double_t eta = fBasic->GetXaxis()->GetBinCenter(ieta);
277 Double_t phi = fBasic->GetYaxis()->GetBinCenter(iphi);
278 Int_t jeta = fEmpty->GetXaxis()->FindBin(eta);
279 Int_t jphi = fEmpty->GetYaxis()->FindBin(phi);
280 Double_t empty = fEmpty->GetBinContent(jeta, jphi);
281 Double_t total = fTotal->GetBinContent(jeta, jphi);
282 Double_t hits = fBasic->GetBinContent(ieta,iphi);
284 // Mean in region of interest
285 Double_t poissonM = CalculateMean(empty, total);
286 Double_t poissonC = CalculateCorrection(empty, total);
287 Double_t poissonV = hits * poissonM * poissonC;
288 Double_t poissonE = TMath::Sqrt(poissonV);
289 if(poissonV > 0) poissonE = TMath::Sqrt(poissonV);
291 fBasic->SetBinContent(ieta,iphi,poissonV);
292 fBasic->SetBinError(ieta,iphi,poissonE);
295 for (Int_t ieta = 1; ieta <= fEmpty->GetNbinsX(); ieta++) {
296 for (Int_t iphi = 1; iphi <= fEmpty->GetNbinsY(); iphi++) {
297 Double_t empty = fEmpty->GetBinContent(ieta, iphi);
298 Double_t total = fTotal->GetBinContent(ieta, iphi);
299 Double_t mean = CalculateMean(empty, total);
300 Double_t corr = CalculateCorrection(empty, total);
301 fEmptyVsTotal->Fill(total, empty);
303 fOcc->Fill(100 * (1 - TMath::PoissonI(0,mean)));
304 fCorr->Fill(mean, corr);
310 //____________________________________________________________________
312 AliPoissonCalculator::Print(const Option_t*) const
320 char ind[gROOT->GetDirLevel()+3];
321 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
322 ind[gROOT->GetDirLevel()] = '\0';
323 std::cout << ind << ClassName() << ": " << GetName() << '\n'
325 << ind << " Eta lumping: " << fEtaLumping << '\n'
326 << ind << " Phi lumping: " << fPhiLumping << '\n'
327 << std::noboolalpha << std::endl;
329 //____________________________________________________________________
331 AliPoissonCalculator::Browse(TBrowser* b)
334 // Browse this object
337 // b Object to browse
339 if (fTotal) b->Add(fTotal);
340 if (fEmpty) b->Add(fEmpty);
341 if (fBasic) b->Add(fBasic);
342 if (fEmptyVsTotal) b->Add(fEmptyVsTotal);
343 if (fMean) b->Add(fMean);
344 if (fOcc) b->Add(fOcc);
345 if (fCorr) b->Add(fCorr);