1 #ifndef ALIPOISSONCALCULATOR_H
2 #define ALIPOISSONCALCULATOR_H
9 * A class to calculate the multiplicity in @f$(\eta,\varphi)@f$ bins
10 * using Poisson statistics.
12 * The input is assumed to be binned in @f$(\eta,\varphi)@f$ as
13 * described by the 2D histogram passwd to the Reset member function.
15 * The data is grouped in to regions as defined by the parameters
16 * fXLumping and fYLumping. The total number of cells and number
17 * of empty cells is then calculate in each region. The mean
18 * multiplicity over the region is then determined as
21 * \langle m\rangle = -\log\left(\frac{e}{t}\right)
23 * where @f$ e@f$ is the number of empty cells and @f$t@f$ is the
24 * total number of cells in the region. A correction for counting
25 * statistics, is then applied
27 * c &=& \frac{1}{1 - \exp{-\langle m\rangle}}\\ &=&
28 * \frac{1}{1 - \frac{e}{t}}
30 * and the final number in each cell is then
31 * @f$h_i c \langle m\rangle@f$
32 * where @f$h_i@f$ is the number of hits in the cell @f$i@f$
35 class AliPoissonCalculator : public TNamed
41 AliPoissonCalculator();
46 AliPoissonCalculator(const char*/*, UShort_t d, Char_t r*/);
50 * @param o Object to copy from
52 AliPoissonCalculator(const AliPoissonCalculator& o);
57 virtual ~AliPoissonCalculator();
61 * @param o Object to assign from
63 * @return Reference to this object
65 AliPoissonCalculator& operator=(const AliPoissonCalculator& o);
67 * Set the number of eta bins to group into a region
69 * @param n Number of eta bins per region
71 void SetLumping(UShort_t nx, UShort_t ny);
73 * Set the number of X bins to group into a region
75 * @param n Number of eta bins per region
77 void SetXLumping(UShort_t nx) { SetLumping(nx, fYLumping); } //*MENU*
79 * Set the number of Y bins to group into a region
81 * @param n Number of eta bins per region
83 void SetYLumping(UShort_t ny) { SetLumping(fYLumping, ny); } //*MENU*
85 * Intialize this object
87 * @param xLumping If larger than 0, set the eta lumping to this
88 * @param yLumping If larger than 0, set the phi lumping to this
90 void Init(Int_t xLumping=-1, Int_t yLumping=-1);
92 * Make output stuff for the passed list
98 * Output stuff to the passed list
100 * @param d List to add output histograms to
102 void Output(TList* d);
104 * Reset the cache histogram
106 * @param xChannels number of channels in x
107 * @param yChannels number of channels in y
109 void Reset(UShort_t xChannels, UShort_t yChannels);
111 * Fill in an observation
113 * @param eta Eta value
114 * @param phi Phi value
115 * @param hit True if hit
116 * @param weight Weight if this
118 void Fill(UShort_t strip, UShort_t sec, Bool_t hit, Double_t weight=1);
120 * Calculate result and store in @a output
122 * @return The result histogram (fBase overwritten)
124 TH2D* Result(Bool_t correct=true);
126 * @return Always true
128 Bool_t IsFolder() const { return kTRUE; }
132 * @param option Not used
134 void Print(const Option_t* option="") const;
138 * @param b Object to browse
140 void Browse(TBrowser* b);
143 * Get the empty versus total histogram
145 * @return Empty versus total
147 TH2D* GetEmptyVsTotal() const { return fEmptyVsTotal; }
149 * Get the histogram of the means
153 TH1D* GetMean() const { return fMean; }
155 * Get the occupancy histogram
157 * @return Occupancy histogram
159 TH1D* GetOccupancy() const { return fOcc; }
161 * Get the correction histogram
163 * @return correction histogram
165 TH2D* GetCorrection() const { return fCorr; }
168 * Get the X bin in the reduced historgam
170 * @param ix X bin in full histogram
172 * @return X bin in reduced histogram
174 Int_t GetReducedXBin(Int_t ix) const;
176 * Get the X bin in the reduced historgam
180 * @return X bin in reduced histogram
182 Int_t GetReducedXBin(Double_t x) const;
184 * Get the Y bin in the reduced historgam
186 * @param iy Y bin in full histogram
188 * @return Y bin in reduced histogram
190 Int_t GetReducedYBin(Int_t iy) const;
192 * Get the Y bin in the reduced historgam
196 * @return Y bin in reduced histogram
198 Int_t GetReducedYBin(Double_t y) const;
202 * Clean up allocated space
209 * This is based on the fact that for a Poisson
211 * P(n;\lambda) = \frac{-\lambda^n e^{-\lambda}}{n!}
213 * we have the probability for 0 observation
215 * P(0;\lambda) = e^{-\lambda} = \frac{N_{empty}}{N_{total}}
217 * and so we get that the mean is the defined region is
219 * \lambda = -\log\left(\frac{N_{empty}}{N_{total}}\right)
222 * Note the boundary conditions
223 * - @f$N_{total}=0 \rightarrow\lambda=0@f$
224 * - @f$N_{empty}<\epsilon\rightarrow N_{empty} = \epsilon@f$
226 * @param empty Number of empty bins
227 * @param total Total number of bins
229 * @return The mean in the defined region
231 Double_t CalculateMean(Double_t empty, Double_t total) const;
233 * The mean @f$\lambda@f$ calculated above is not the full story.
234 * In addition it needs to be corrected using the expression
236 * \frac{1}{1-e^{\lambda}} =
237 * \frac{1}{1-\frac{N_{empty}}{N_{total}}}
240 * Note the boundary conditions
241 * - @f$N_{total}=0 \rightarrow\lambda=0@f$
242 * - @f$|N_{total}-N_{empty}|<\epsilon\rightarrow N_{empty} =
243 * N_{total}-\epsilon@f$
245 * @param empty Number of empty bins
246 * @param total Total number of bins
248 * @return The correction to the mean.
250 Double_t CalculateCorrection(Double_t empty, Double_t total) const;
251 UShort_t fXLumping; // Grouping of eta bins
252 UShort_t fYLumping; // Grouping of phi bins
253 TH2D* fTotal; // Total number of strips in a region
254 TH2D* fEmpty; // Total number of strips in a region
255 TH2D* fBasic; // Total number basic hits in a region
256 TH2D* fEmptyVsTotal; // Empty versus total cells
257 TH1D* fMean; // Mean calculated by poisson method
258 TH1D* fOcc; // Histogram of occupancies
259 TH2D* fCorr; // Correction as a function of mean
260 ClassDef(AliPoissonCalculator,2) // Calculate N_ch using Poisson