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, Double_t cent=-1);
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 * Set to use the running average in Poisson
132 * @param use use or not
134 void SetUseRunningAverage(Bool_t use) { fUseRunningAverage = use; }
136 * Maximum particle weight to use
140 void SetMaxParticles(UShort_t m) { fMaxParticles = m; }
142 * Set whether to use poisson statistics to estimate the
143 * number of particles that has hit within a region. If this is true,
144 * then the average charge particle density is given by
146 * \lambda = -\log\left(\frac{N_e}{N_t}\right)
148 * where $N_e$ is the number of strips within the region that has no
149 * hits over threshold, and $N_t$ is the total number of strips in the
152 * @param u Whether to use poisson statistics to estimate the
153 * number of particles that has hit within a region.
155 void SetUsePoisson(Bool_t u) { fUsePoisson = u; }
157 * Set whether to use the phi acceptance correction.
159 * How the phi acceptance is used depends on the value passed.
160 * - 0: No phi acceptance
161 * - 1: Phi acceptance correction done to estimate of particles
162 * - 2: Phi acceptance correction done to energy deposited
164 * @param u If >0, use the phi acceptance (default is false)
166 void SetUsePhiAcceptance(UShort_t u=kPhiCorrectNch) { fUsePhiAcceptance = u; }
168 * Set the lower multiplicity cut. This overrides the setting in
169 * the energy loss fits.
171 * @param cut Cut to use
173 void SetMultCut(Double_t cut) { fCuts.SetMultCuts(cut,cut,cut,cut,cut); }
175 * Set the lower multiplicity cuts
177 * @param fmd1i Lower mulitplicyt cut for FMD1i
178 * @param fmd2i Lower mulitplicyt cut for FMD2i
179 * @param fmd2o Lower mulitplicyt cut for FMD2o
180 * @param fmd3i Lower mulitplicyt cut for FMD3i
181 * @param fmd3o Lower mulitplicyt cut for FMD3o
183 void SetMultCuts(Double_t fmd1i,
189 * Set the luming factors used in the Poisson method
191 * @param eta Must be 1 or larger
192 * @param phi Must be 1 or larger
194 void SetLumping(Int_t eta, Int_t phi) {
195 fEtaLumping = (eta < 1 ? 1 : eta);
196 fPhiLumping = (phi < 1 ? 1 : phi);
199 * Set the number of landau width to subtract from the most probably
200 * value to get the low cut.
202 * @param nXi Number of @f$ \xi@f$
204 void SetNXi(Double_t nXi) { fCuts.SetNXi(nXi); /* fNXi = nXi;*/ }
206 * Whether to include sigma in the number subtracted from the MPV to
209 * @param u If true, then low cut is @f$ \Delta_{mp} - n(\xi+\sigma)@f$
211 void SetIncludeSigma(Bool_t u) { fCuts.SetIncludeSigma(u); /*fIncludeSigma = u;*/ }
214 * Set the fraction of MPV
216 * @param cut if true cut at fraction of MPV
218 void SetFractionOfMPV(Double_t cut) { fCuts.SetMPVFraction(cut); /*fFractionOfMPV = cut;*/ }
220 * Get the multiplicity cut. If the user has set fMultCut (via
221 * SetMultCut) then that value is used. If not, then the lower
222 * value of the fit range for the enery loss fits is returned.
224 * @return Lower cut on multiplicity
226 Double_t GetMultCut(UShort_t d, Char_t r, Double_t eta,
227 Bool_t errors=true) const;
229 * Get the multiplicity cut. If the user has set fMultCut (via
230 * SetMultCut) then that value is used. If not, then the lower
231 * value of the fit range for the enery loss fits is returned.
233 * @return Lower cut on multiplicity
235 Double_t GetMultCut(UShort_t d, Char_t r, Int_t ieta,
236 Bool_t errors=true) const;
240 * @param option Print options
241 * - max Print max weights
243 void Print(Option_t* option="") const;
244 AliFMDMultCuts& GetCuts() { return fCuts; }
245 void SetCuts(const AliFMDMultCuts& c) { fCuts = c; }
248 * Find the max weight to use for FMD<i>dr</i> in eta bin @a iEta
250 * @param cor Correction
253 * @param iEta Eta bin
255 Int_t FindMaxWeight(const AliFMDCorrELossFit* cor,
256 UShort_t d, Char_t r, Int_t iEta) const;
259 * Find the max weights and cache them
262 void CacheMaxWeights();
264 * Find the (cached) maximum weight for FMD<i>dr</i> in
265 * @f$\eta@f$ bin @a iEta
269 * @param iEta Eta bin
271 * @return max weight or <= 0 in case of problems
273 Int_t GetMaxWeight(UShort_t d, Char_t r, Int_t iEta) const;
275 * Find the (cached) maximum weight for FMD<i>dr</i> iat
282 * @return max weight or <= 0 in case of problems
284 Int_t GetMaxWeight(UShort_t d, Char_t r, Float_t eta) const;
287 * Get the number of particles corresponding to the signal mult
293 * @param t Strip (not used)
294 * @param v Vertex bin
295 * @param eta Pseudo-rapidity
296 * @param lowFlux Low-flux flag
298 * @return The number of particles
300 virtual Float_t NParticles(Float_t mult,
301 UShort_t d, Char_t r, UShort_t s, UShort_t t,
302 UShort_t v, Float_t eta, Bool_t lowFlux) const;
304 * Get the inverse correction factor. This consist of
306 * - acceptance correction (corners of sensors)
307 * - double hit correction (for low-flux events)
308 * - dead strip correction
313 * @param t Strip (not used)
314 * @param v Vertex bin
315 * @param eta Pseudo-rapidity
316 * @param lowFlux Low-flux flag
320 virtual Float_t Correction(UShort_t d, Char_t r, UShort_t s, UShort_t t,
321 UShort_t v, Float_t eta, Bool_t lowFlux) const;
323 * Get the acceptance correction for strip @a t in an ring of type @a r
325 * @param r Ring type ('I' or 'O')
326 * @param t Strip number
328 * @return Inverse acceptance correction
330 virtual Float_t AcceptanceCorrection(Char_t r, UShort_t t) const;
332 * Generate the acceptance corrections
334 * @param r Ring to generate for
336 * @return Newly allocated histogram of acceptance corrections
338 virtual TH1D* GenerateAcceptanceCorrection(Char_t r) const;
340 * Internal data structure to keep track of the histograms
342 struct RingHistos : public AliForwardUtil::RingHistos
354 RingHistos(UShort_t d, Char_t r);
358 * @param o Object to copy from
360 RingHistos(const RingHistos& o);
362 * Assignment operator
364 * @param o Object to assign from
366 * @return Reference to this
368 RingHistos& operator=(const RingHistos& o);
374 * Initialize the object
378 void Init(const TAxis& eAxis);
382 * @param dir Where to put it
384 void Output(TList* dir);
386 * Scale the histograms to the total number of events
388 * @param dir Where the output is
389 * @param nEvents Number of events
391 void ScaleHistograms(TList* dir, Int_t nEvents);
394 * Create Poisson histograms
396 void ResetPoissonHistos(const TH2D* h, Int_t etaLumping, Int_t phiLumping);
398 TH2D* fEvsN; // Correlation of Eloss vs uncorrected Nch
399 TH2D* fEvsM; // Correlation of Eloss vs corrected Nch
400 TProfile* fEtaVsN; // Average uncorrected Nch vs eta
401 TProfile* fEtaVsM; // Average corrected Nch vs eta
402 TProfile* fCorr; // Average correction vs eta
403 TH2D* fDensity; // Distribution inclusive Nch
404 TH2D* fELossVsPoisson; // Correlation of energy loss vs Poisson N_ch
406 TH2D* fTotalStrips; // Total number of strips in a region
407 TH2D* fEmptyStrips; // Total number of strips in a region
408 TH2D* fBasicHits ; // Total number basic hits in a region
409 TH2D* fEmptyVsTotal; // # of empty strips vs total number of
412 AliPoissonCalculator fPoisson; // Calculate density using Poisson method
414 TH1D* fELoss; // Energy loss as seen by this
415 TH1D* fELossUsed; // Energy loss in strips with signal
416 Double_t fMultCut; // If set, use this
418 ClassDef(RingHistos,5);
421 * Get the ring histogram container
426 * @return Ring histogram container
428 RingHistos* GetRingHistos(UShort_t d, Char_t r) const;
429 TList fRingHistos; // List of histogram containers
430 TH1D* fSumOfWeights; // Histogram
431 TH1D* fWeightedSum; // Histogram
432 TH1D* fCorrections; // Histogram
433 UShort_t fMaxParticles; // Maximum particle weight to use
434 Bool_t fUsePoisson; // If true, then use poisson statistics
435 UShort_t fUsePhiAcceptance; // Whether to correct for corners
436 TH1D* fAccI; // Acceptance correction for inner rings
437 TH1D* fAccO; // Acceptance correction for outer rings
438 TArrayI fFMD1iMax; // Array of max weights
439 TArrayI fFMD2iMax; // Array of max weights
440 TArrayI fFMD2oMax; // Array of max weights
441 TArrayI fFMD3iMax; // Array of max weights
442 TArrayI fFMD3oMax; // Array of max weights
443 TH2D* fMaxWeights; // Histogram of max weights
444 TH2D* fLowCuts; // Histogram of low cuts
445 Int_t fEtaLumping; // How to lump eta bins for Poisson
446 Int_t fPhiLumping; // How to lump phi bins for Poisson
447 Int_t fDebug; // Debug level
448 AliFMDMultCuts fCuts; // Cuts
449 Bool_t fUseRunningAverage; //Use running average for Poisson
451 ClassDef(AliFMDDensityCalculator,6); // Calculate Nch density