1 #ifndef ALIPOISSONCALCULATOR_H
2 #define 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 * fXLumping and fYLumping. 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 * \langle 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{-\langle m\rangle}}\\ &=&
29 * \frac{1}{1 - \frac{e}{t}}
31 * and the final number in each cell is then
32 * @f$h_i c \langle m\rangle@f$
33 * where @f$h_i@f$ is the number of hits in the cell @f$i@f$
36 class AliPoissonCalculator : public TNamed
42 AliPoissonCalculator();
47 AliPoissonCalculator(const char*/*, UShort_t d, Char_t r*/);
51 * @param o Object to copy from
53 AliPoissonCalculator(const AliPoissonCalculator& o);
58 virtual ~AliPoissonCalculator();
62 * @param o Object to assign from
64 * @return Reference to this object
66 AliPoissonCalculator& operator=(const AliPoissonCalculator& o);
68 * Set the number of eta bins to group into a region
70 * @param n Number of eta bins per region
72 void SetLumping(UShort_t nx, UShort_t ny);
74 * Set the number of X bins to group into a region
76 * @param n Number of eta bins per region
78 void SetXLumping(UShort_t nx) { SetLumping(nx, fYLumping); } //*MENU*
80 * Set the number of Y bins to group into a region
82 * @param n Number of eta bins per region
84 void SetYLumping(UShort_t ny) { SetLumping(fYLumping, ny); } //*MENU*
86 * Intialize this object
88 * @param xLumping If larger than 0, set the eta lumping to this
89 * @param yLumping If larger than 0, set the phi lumping to this
91 void Init(Int_t xLumping=-1, Int_t yLumping=-1);
94 * Initialize this object.
96 * Also book the cache histograms
98 void Define(const TAxis& xaxis, const TAxis& yaxis);
100 * Make output stuff for the passed list
106 * Output stuff to the passed list
108 * @param d List to add output histograms to
110 void Output(TList* d);
112 * Reset the cache histogram
114 * @param base Base histogram
116 void Reset(const TH2D* base);
118 * Fill in an observation
120 * @param eta Eta value
121 * @param phi Phi value
122 * @param hit True if hit
123 * @param weight Weight if this
125 void Fill(UShort_t strip, UShort_t sec, Bool_t hit, Double_t weight=1);
127 * Calculate result and store in @a output
129 * @return The result histogram (fBase overwritten)
131 TH2D* Result(Bool_t correct=true);
133 * @return Always true
135 Bool_t IsFolder() const { return kTRUE; }
139 * @param option Not used
141 void Print(const Option_t* option="") const;
145 * @param b Object to browse
147 void Browse(TBrowser* b);
150 * Get the empty versus total histogram
152 * @return Empty versus total
154 TH2D* GetEmptyVsTotal() const { return fEmptyVsTotal; }
156 * Get the histogram of the means
160 TH1D* GetMean() const { return fMean; }
162 * Get the occupancy histogram
164 * @return Occupancy histogram
166 TH1D* GetOccupancy() const { return fOcc; }
168 * Get the correction histogram
170 * @return correction histogram
172 TH2D* GetCorrection() const { return fCorr; }
175 * Get the X bin in the reduced historgam
177 * @param ix X bin in full histogram
179 * @return X bin in reduced histogram
181 Int_t GetReducedXBin(Int_t ix) const;
183 * Get the X bin in the reduced historgam
187 * @return X bin in reduced histogram
189 Int_t GetReducedXBin(Double_t x) const;
191 * Get the Y bin in the reduced historgam
193 * @param iy Y bin in full histogram
195 * @return Y bin in reduced histogram
197 Int_t GetReducedYBin(Int_t iy) const;
199 * Get the Y bin in the reduced historgam
203 * @return Y bin in reduced histogram
205 Int_t GetReducedYBin(Double_t y) const;
209 * check that the lumping parameter makes sense
211 * @param which Which axis
212 * @param nBins Number of bins
213 * @param lumping Lumping
215 * @return The new value of the lumping
217 Int_t CheckLumping(char which, Int_t nBins, Int_t lumping) const;
219 * Clean up allocated space
226 * This is based on the fact that for a Poisson
228 * P(n;\lambda) = \frac{-\lambda^n e^{-\lambda}}{n!}
230 * we have the probability for 0 observation
232 * P(0;\lambda) = e^{-\lambda} = \frac{N_{empty}}{N_{total}}
234 * and so we get that the mean is the defined region is
236 * \lambda = -\log\left(\frac{N_{empty}}{N_{total}}\right)
239 * Note the boundary conditions
240 * - @f$N_{total}=0 \rightarrow\lambda=0@f$
241 * - @f$N_{empty}<\epsilon\rightarrow N_{empty} = \epsilon@f$
243 * @param empty Number of empty bins
244 * @param total Total number of bins
246 * @return The mean in the defined region
248 Double_t CalculateMean(Double_t empty, Double_t total) const;
250 * The mean @f$\lambda@f$ calculated above is not the full story.
251 * In addition it needs to be corrected using the expression
253 * \frac{1}{1-e^{\lambda}} =
254 * \frac{1}{1-\frac{N_{empty}}{N_{total}}}
257 * Note the boundary conditions
258 * - @f$N_{total}=0 \rightarrow\lambda=0@f$
259 * - @f$|N_{total}-N_{empty}|<\epsilon\rightarrow N_{empty} =
260 * N_{total}-\epsilon@f$
262 * @param empty Number of empty bins
263 * @param total Total number of bins
265 * @return The correction to the mean.
267 Double_t CalculateCorrection(Double_t empty, Double_t total) const;
268 UShort_t fXLumping; // Grouping of eta bins
269 UShort_t fYLumping; // Grouping of phi bins
270 TH2D* fTotal; // Total number of strips in a region
271 TH2D* fEmpty; // Total number of strips in a region
272 TH2D* fBasic; // Total number basic hits in a region
273 TH2D* fEmptyVsTotal; // Empty versus total cells
274 TH1D* fMean; // Mean calculated by poisson method
275 TH1D* fOcc; // Histogram of occupancies
276 TH2D* fCorr; // Correction as a function of mean
277 ClassDef(AliPoissonCalculator,2) // Calculate N_ch using Poisson