1 // This class calculates the inclusive charged particle density
2 // in each for the 5 FMD rings.
4 #ifndef ALIFMDDENSITYCALCULATOR_H
5 #define ALIFMDDENSITYCALCULATOR_H
7 * @file AliFMDDensityCalculator.h
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 14:02:09 2011
14 * @ingroup pwg2_forward_aod
19 #include "AliForwardUtil.h"
20 #include "AliFMDMultCuts.h"
21 #include "AliPoissonCalculator.h"
26 class AliFMDCorrELossFit;
29 * This class calculates the inclusive charged particle density
30 * in each for the 5 FMD rings.
33 * - AliESDFMD object possibly corrected for sharing
36 * - 5 RingHistos objects - each with a number of vertex dependent
37 * 2D histograms of the inclusive charge particle density
39 * @par Corrections used:
40 * - AliFMDAnaCalibEnergyDistribution
41 * - AliFMDDoubleHitCorrection
42 * - AliFMDDeadCorrection
44 * @ingroup pwg2_forward_algo
45 * @ingroup pwg2_forward_aod
47 class AliFMDDensityCalculator : public TNamed
51 * How to correct for the missing phi coverage at the corners of the
58 /** Correct the calculated number charged particles */
60 /** Correct the energy loss */
66 AliFMDDensityCalculator();
70 * @param name Name of object
72 AliFMDDensityCalculator(const char* name);
76 * @param o Object to copy from
78 AliFMDDensityCalculator(const AliFMDDensityCalculator& o);
82 virtual ~AliFMDDensityCalculator();
84 * Assignement operator
86 * @param o Object to assign from
88 * @return Reference to this object
90 AliFMDDensityCalculator& operator=(const AliFMDDensityCalculator& o);
92 * Initialize this sub-algorithm
94 * @param etaAxis Not used
96 virtual void Init(const TAxis& etaAxis);
100 * @param fmd AliESDFMD object (possibly) corrected for sharing
101 * @param hists Histogram cache
102 * @param vtxBin Vertex bin
103 * @param lowFlux Low flux flag.
105 * @return true on successs
107 virtual Bool_t Calculate(const AliESDFMD& fmd,
108 AliForwardUtil::Histos& hists,
109 UShort_t vtxBin, Bool_t lowFlux);
111 * Scale the histograms to the total number of events
113 * @param dir where to put the output
114 * @param nEvents Number of events
116 virtual void ScaleHistograms(const TList* dir, Int_t nEvents);
118 * Output diagnostic histograms to directory
120 * @param dir List to write in
122 virtual void DefineOutput(TList* dir);
124 * Set the debug level. The higher the value the more output
126 * @param dbg Debug level
128 void SetDebug(Int_t dbg=1) { fDebug = dbg; }
130 * Maximum particle weight to use
134 void SetMaxParticles(UShort_t m) { fMaxParticles = m; }
136 * Set whether to use poisson statistics to estimate the
137 * number of particles that has hit within a region. If this is true,
138 * then the average charge particle density is given by
140 * \lambda = -\log\left(\frac{N_e}{N_t}\right)
142 * where $N_e$ is the number of strips within the region that has no
143 * hits over threshold, and $N_t$ is the total number of strips in the
146 * @param u Whether to use poisson statistics to estimate the
147 * number of particles that has hit within a region.
149 void SetUsePoisson(Bool_t u) { fUsePoisson = u; }
151 * Set whether to use the phi acceptance correction.
153 * How the phi acceptance is used depends on the value passed.
154 * - 0: No phi acceptance
155 * - 1: Phi acceptance correction done to estimate of particles
156 * - 2: Phi acceptance correction done to energy deposited
158 * @param u If >0, use the phi acceptance (default is false)
160 void SetUsePhiAcceptance(UShort_t u=kPhiCorrectNch) { fUsePhiAcceptance = u; }
162 * Set the lower multiplicity cut. This overrides the setting in
163 * the energy loss fits.
165 * @param cut Cut to use
167 void SetMultCut(Double_t cut) { fCuts.SetMultCuts(cut,cut,cut,cut,cut); }
169 * Set the lower multiplicity cuts
171 * @param fmd1i Lower mulitplicyt cut for FMD1i
172 * @param fmd2i Lower mulitplicyt cut for FMD2i
173 * @param fmd2o Lower mulitplicyt cut for FMD2o
174 * @param fmd3i Lower mulitplicyt cut for FMD3i
175 * @param fmd3o Lower mulitplicyt cut for FMD3o
177 void SetMultCuts(Double_t fmd1i,
183 * Set the luming factors used in the Poisson method
185 * @param eta Must be 1 or larger
186 * @param phi Must be 1 or larger
188 void SetLumping(Int_t eta, Int_t phi) {
189 fEtaLumping = (eta < 1 ? 1 : eta);
190 fPhiLumping = (phi < 1 ? 1 : phi);
193 * Set the number of landau width to subtract from the most probably
194 * value to get the low cut.
196 * @param nXi Number of @f$ \xi@f$
198 void SetNXi(Double_t nXi) { fCuts.SetNXi(nXi); /* fNXi = nXi;*/ }
200 * Whether to include sigma in the number subtracted from the MPV to
203 * @param u If true, then low cut is @f$ \Delta_{mp} - n(\xi+\sigma)@f$
205 void SetIncludeSigma(Bool_t u) { fCuts.SetIncludeSigma(u); /*fIncludeSigma = u;*/ }
208 * Set the fraction of MPV
210 * @param cut if true cut at fraction of MPV
212 void SetFractionOfMPV(Double_t cut) { fCuts.SetMPVFraction(cut); /*fFractionOfMPV = cut;*/ }
214 * Get the multiplicity cut. If the user has set fMultCut (via
215 * SetMultCut) then that value is used. If not, then the lower
216 * value of the fit range for the enery loss fits is returned.
218 * @return Lower cut on multiplicity
220 Double_t GetMultCut(UShort_t d, Char_t r, Double_t eta,
221 Bool_t errors=true) const;
223 * Get the multiplicity cut. If the user has set fMultCut (via
224 * SetMultCut) then that value is used. If not, then the lower
225 * value of the fit range for the enery loss fits is returned.
227 * @return Lower cut on multiplicity
229 Double_t GetMultCut(UShort_t d, Char_t r, Int_t ieta,
230 Bool_t errors=true) const;
234 * @param option Print options
235 * - max Print max weights
237 void Print(Option_t* option="") const;
238 AliFMDMultCuts& GetCuts() { return fCuts; }
239 void SetCuts(const AliFMDMultCuts& c) { fCuts = c; }
242 * Find the max weight to use for FMD<i>dr</i> in eta bin @a iEta
244 * @param cor Correction
247 * @param iEta Eta bin
249 Int_t FindMaxWeight(const AliFMDCorrELossFit* cor,
250 UShort_t d, Char_t r, Int_t iEta) const;
253 * Find the max weights and cache them
256 void CacheMaxWeights();
258 * Find the (cached) maximum weight for FMD<i>dr</i> in
259 * @f$\eta@f$ bin @a iEta
263 * @param iEta Eta bin
265 * @return max weight or <= 0 in case of problems
267 Int_t GetMaxWeight(UShort_t d, Char_t r, Int_t iEta) const;
269 * Find the (cached) maximum weight for FMD<i>dr</i> iat
276 * @return max weight or <= 0 in case of problems
278 Int_t GetMaxWeight(UShort_t d, Char_t r, Float_t eta) const;
281 * Get the number of particles corresponding to the signal mult
287 * @param t Strip (not used)
288 * @param v Vertex bin
289 * @param eta Pseudo-rapidity
290 * @param lowFlux Low-flux flag
292 * @return The number of particles
294 virtual Float_t NParticles(Float_t mult,
295 UShort_t d, Char_t r, UShort_t s, UShort_t t,
296 UShort_t v, Float_t eta, Bool_t lowFlux) const;
298 * Get the inverse correction factor. This consist of
300 * - acceptance correction (corners of sensors)
301 * - double hit correction (for low-flux events)
302 * - dead strip correction
307 * @param t Strip (not used)
308 * @param v Vertex bin
309 * @param eta Pseudo-rapidity
310 * @param lowFlux Low-flux flag
314 virtual Float_t Correction(UShort_t d, Char_t r, UShort_t s, UShort_t t,
315 UShort_t v, Float_t eta, Bool_t lowFlux) const;
317 * Get the acceptance correction for strip @a t in an ring of type @a r
319 * @param r Ring type ('I' or 'O')
320 * @param t Strip number
322 * @return Inverse acceptance correction
324 virtual Float_t AcceptanceCorrection(Char_t r, UShort_t t) const;
326 * Generate the acceptance corrections
328 * @param r Ring to generate for
330 * @return Newly allocated histogram of acceptance corrections
332 virtual TH1D* GenerateAcceptanceCorrection(Char_t r) const;
334 * Internal data structure to keep track of the histograms
336 struct RingHistos : public AliForwardUtil::RingHistos
348 RingHistos(UShort_t d, Char_t r);
352 * @param o Object to copy from
354 RingHistos(const RingHistos& o);
356 * Assignment operator
358 * @param o Object to assign from
360 * @return Reference to this
362 RingHistos& operator=(const RingHistos& o);
368 * Initialize the object
372 void Init(const TAxis& eAxis);
376 * @param dir Where to put it
378 void Output(TList* dir);
380 * Scale the histograms to the total number of events
382 * @param dir Where the output is
383 * @param nEvents Number of events
385 void ScaleHistograms(TList* dir, Int_t nEvents);
388 * Create Poisson histograms
390 void ResetPoissonHistos(const TH2D* h, Int_t etaLumping, Int_t phiLumping);
392 TH2D* fEvsN; // Correlation of Eloss vs uncorrected Nch
393 TH2D* fEvsM; // Correlation of Eloss vs corrected Nch
394 TProfile* fEtaVsN; // Average uncorrected Nch vs eta
395 TProfile* fEtaVsM; // Average corrected Nch vs eta
396 TProfile* fCorr; // Average correction vs eta
397 TH2D* fDensity; // Distribution inclusive Nch
398 TH2D* fELossVsPoisson; // Correlation of energy loss vs Poisson N_ch
400 TH2D* fTotalStrips; // Total number of strips in a region
401 TH2D* fEmptyStrips; // Total number of strips in a region
402 TH2D* fBasicHits ; // Total number basic hits in a region
403 TH2D* fEmptyVsTotal; // # of empty strips vs total number of
406 AliPoissonCalculator fPoisson; // Calculate density using Poisson method
408 TH1D* fELoss; // Energy loss as seen by this
409 TH1D* fELossUsed; // Energy loss in strips with signal
410 Double_t fMultCut; // If set, use this
412 ClassDef(RingHistos,5);
415 * Get the ring histogram container
420 * @return Ring histogram container
422 RingHistos* GetRingHistos(UShort_t d, Char_t r) const;
423 TList fRingHistos; // List of histogram containers
424 TH1D* fSumOfWeights; // Histogram
425 TH1D* fWeightedSum; // Histogram
426 TH1D* fCorrections; // Histogram
427 UShort_t fMaxParticles; // Maximum particle weight to use
428 Bool_t fUsePoisson; // If true, then use poisson statistics
429 UShort_t fUsePhiAcceptance; // Whether to correct for corners
430 TH1D* fAccI; // Acceptance correction for inner rings
431 TH1D* fAccO; // Acceptance correction for outer rings
432 TArrayI fFMD1iMax; // Array of max weights
433 TArrayI fFMD2iMax; // Array of max weights
434 TArrayI fFMD2oMax; // Array of max weights
435 TArrayI fFMD3iMax; // Array of max weights
436 TArrayI fFMD3oMax; // Array of max weights
437 TH2D* fMaxWeights; // Histogram of max weights
438 TH2D* fLowCuts; // Histogram of low cuts
439 Int_t fEtaLumping; // How to lump eta bins for Poisson
440 Int_t fPhiLumping; // How to lump phi bins for Poisson
441 Int_t fDebug; // Debug level
442 AliFMDMultCuts fCuts; // Cuts
444 ClassDef(AliFMDDensityCalculator,6); // Calculate Nch density