1 #ifndef ALIROOT_PWG2_FORWARD_ALIFMDCORRELOSSFIT_H
2 #define ALIROOT_PWG2_FORWARD_ALIFMDCORRELOSSFIT_H
10 * @defgroup pwg2_forward_corr Corrections
12 * @ingroup pwg2_forward
15 * Object holding the Energy loss fit 'correction'
17 * These are generated from Monte-Carlo or real ESDs.
19 * @ingroup pwg2_forward_corr
21 class AliFMDCorrELossFit : public TObject
25 * POD structure to hold data from fits
27 * @ingroup pwg2_forward_corr
29 struct ELossFit : public TObject
31 Int_t fN; // Number of peaks fitted
32 UShort_t fNu; // Number degrees of freedom
33 Double_t fChi2; // Chi square from fit
34 Double_t fC; // Scaling constant
35 Double_t fDelta; // Most probable value
36 Double_t fXi; // Width parameter of Landau
37 Double_t fSigma; // Sigma on folded gaussian
38 Double_t fSigmaN; // Sigma of detector noise
39 Double_t* fA; // [fN] Weights
40 Double_t fEC; // Error on C
41 Double_t fEDelta; // Error on Delta
42 Double_t fEXi; // Error on Xi
43 Double_t fESigma; // Error on sigma
44 Double_t fESigmaN;// Error on sigma (noise)
45 Double_t* fEA; // [fN] Error on weights
46 Int_t fQuality;// Assigned quality
47 UShort_t fDet; // Detector
49 UShort_t fBin; // Eta bin
51 static Double_t fgMaxRelError; // Global default max relative error
52 static Double_t fgLeastWeight; // Global default least weight
53 static Double_t fgMaxChi2nu; // Global default maximum reduced chi^2
60 * Construct from a function
62 * @param quality Quality flag
65 ELossFit(Int_t quality,const TF1& f);
67 * Constructor with full parameter set
69 * @param quality Quality flag
70 * @param n @f$ N@f$ - Number of fitted peaks
71 * @param chi2 @f$ \chi^2 @f$
72 * @param nu @f$ \nu @f$ - number degrees of freedom
73 * @param c @f$ C@f$ - scale constant
74 * @param ec @f$ \delta C@f$ - error on @f$ C@f$
75 * @param delta @f$ \Delta@f$ - Most probable value
76 * @param edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
77 * @param xi @f$ \xi@f$ - width
78 * @param exi @f$ \delta\xi@f$ - error on @f$\xi@f$
79 * @param sigma @f$ \sigma@f$ - Width of Gaussian
80 * @param esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
81 * @param sigman @f$ \sigma_n@f$ - Noise width
82 * @param esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
83 * @param a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
85 * @param ea Array of @f$ N-1@f$ error on the weights @f$ a_i@f$ for
88 ELossFit(Int_t quality,UShort_t n,
89 Double_t chi2, UShort_t nu,
90 Double_t c, Double_t ec,
91 Double_t delta, Double_t edelta,
92 Double_t xi, Double_t exi,
93 Double_t sigma, Double_t esigma,
94 Double_t sigman, Double_t esigman,
95 Double_t* a, Double_t* ea);
99 * @param o Object to copy from
101 ELossFit(const ELossFit& o);
103 * Assignment operator
105 * @param o Object to assign from
107 * @return Reference to this object
109 ELossFit& operator=(const ELossFit& o);
116 * @name Access to parameters
119 * @return Number of peaks fitted
121 Int_t GetN() const { return fN; }
123 * @return Number degrees of freedom
125 UShort_t GetNu() const { return fNu; }
127 * @return Chi square from fit
129 Double_t GetChi2() const { return fChi2; }
131 * @return Scaling constant
133 Double_t GetC() const { return fC; }
135 * @return Most probable value
137 Double_t GetDelta() const { return fDelta; }
139 * @return Width parameter of Landau
141 Double_t GetXi() const { return fXi; }
143 * @return Sigma on folded gaussian
145 Double_t GetSigma() const { return fSigma; }
147 * @return Sigma of detector noise
149 Double_t GetSigmaN() const { return fSigmaN; }
153 Double_t* GetAs() const { return fA; }
157 Double_t GetA(UShort_t i) const;
161 Double_t GetEC() const { return fEC; }
163 * @return Error on Delta
165 Double_t GetEDelta() const { return fEDelta; }
167 * @return Error on Xi
169 Double_t GetEXi() const { return fEXi; }
171 * @return Error on sigma
173 Double_t GetESigma() const { return fESigma; }
175 * @return Error on sigma (noise)
177 Double_t GetESigmaN() const { return fESigmaN; }
179 * @return Error on weights
181 Double_t* GetEAs() const { return fEA; }
183 * @return Error on weights
185 Double_t GetEA(UShort_t i) const;
187 * @return Assigned quality
189 Int_t GetQuality() const { return fQuality; }
193 UShort_t GetDet() const { return fDet; }
197 Char_t GetRing() const { return fRing; }
201 UShort_t GetBin() const { return fBin; }
211 * f_N(x;\Delta,\xi,\sigma') =
212 * \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')
215 * (see AliForwardUtil::NLandauGaus) for the maximum @f$ N @f$
216 * that fulfills the requirements
218 * @param x Where to evaluate
219 * @param maxN @f$ \max{N}@f$
221 * @return @f$ f_N(x;\Delta,\xi,\sigma')@f$
223 Double_t Evaluate(Double_t x,
224 UShort_t maxN=999) const;
228 * f_W(x;\Delta,\xi,\sigma') =
229 * \frac{\sum_{i=1}^{n} i a_i f_i(x;\Delta,\xi,\sigma')}{
230 * f_N(x;\Delta,\xi,\sigma')} =
231 * \frac{\sum_{i=1}^{n} i a_i f(x;\Delta_i,\xi_i,\sigma_i')}{
232 * \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')}
234 * where @f$ n@f$ fulfills the requirements (see FindMaxWeight).
236 * If the denominator is zero, then 1 is returned.
238 * See also AliForwardUtil::ILandauGaus and AliForwardUtil::NLandauGaus
239 * for more information on the evaluated functions.
241 * @param x Where to evaluate
242 * @param maxN @f$ \max{N}@f$
244 * @return @f$ f_W(x;\Delta,\xi,\sigma')@f$.
246 Double_t EvaluateWeighted(Double_t x,
247 UShort_t maxN=9999) const;
249 * Find the maximum weight to use. The maximum weight is the
250 * largest i for which
252 * - @f$ i \leq \max{N}@f$
253 * - @f$ a_i > \min{a}@f$
254 * - @f$ \delta a_i/a_i > \delta_{max}@f$
256 * @param maxRelError @f$ \min{a}@f$
257 * @param leastWeight @f$ \delta_{max}@f$
258 * @param maxN @f$ \max{N}@f$
260 * @return The largest index @f$ i@f$ for which the above
261 * conditions hold. Will never return less than 1.
263 Int_t FindMaxWeight(Double_t maxRelError=2*fgMaxRelError,
264 Double_t leastWeight=fgLeastWeight,
265 UShort_t maxN=999) const;
269 * @name TObject Sortable interface
272 * Declare this object as sortable
274 * @return Always true
276 Bool_t IsSortable() const { return kTRUE; }
278 * Compare to another ELossFit object.
280 * - +1, if this quality is better (larger) than other objects quality
281 * - -1, if this quality is worse (smaller) than other objects quality
282 * - +1, if this @f$|\chi^2/\nu-1|@f$ is smaller than the same for other
283 * - -1, if this @f$|\chi^2/\nu-1|@f$ is larger than the same for other
286 * @param o Other object to compare to
288 Int_t Compare(const TObject* o) const;
292 * name Auxiliary member functions
295 * Information to standard output
297 * @param option Not used
299 void Print(Option_t* option) const; // *MENU*
303 * @param option Options
304 * - COMP Draw components too
306 void Draw(Option_t* option="comp"); // *MENU*
312 void Browse(TBrowser* b);
314 * Get the name of this object
319 const Char_t* GetName() const;
321 * Calculate the quality
323 void CalculateQuality(Double_t maxChi2nu=fgMaxChi2nu,
324 Double_t maxRelError=fgMaxRelError,
325 Double_t leastWeight=fgLeastWeight);
327 ClassDef(ELossFit,1); // Result of fit
331 * Default constructor
333 AliFMDCorrELossFit();
337 * @param o Object to copy from
339 AliFMDCorrELossFit(const AliFMDCorrELossFit& o);
343 virtual ~AliFMDCorrELossFit();
345 * Assignment operator
347 * @param o Object to assign from
349 * @return Reference to this object
351 AliFMDCorrELossFit& operator=(const AliFMDCorrELossFit& o);
358 * Set the fit parameters from a function
363 * @param quality Quality flag
364 * @param f Function from fit
366 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta, Int_t quality,
369 * Set the fit parameters from a function
374 * @param f ELoss fit result - note, the object will take ownership
376 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta, ELossFit* f);
378 * Set the fit parameters from a function
382 * @param etaBin Eta (bin number, 1->nBins)
383 * @param f ELoss fit result - note, the object will take ownership
385 Bool_t SetFit(UShort_t d, Char_t r, Int_t etaBin, ELossFit* f);
387 * Set the fit parameters from a function
389 * @param d Detector number
390 * @param r Ring identifier
391 * @param eta Eta value
392 * @param quality Quality flag
393 * @param n @f$ N@f$ - Number of fitted peaks
394 * @param chi2 @f$ \chi^2 @f$
395 * @param nu @f$ \nu @f$ - number degrees of freedom
396 * @param c @f$ C@f$ - scale constant
397 * @param ec @f$ \delta C@f$ - error on @f$ C@f$
398 * @param delta @f$ \Delta@f$ - most probable value
399 * @param edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
400 * @param xi @f$ \xi@f$ - Landau width
401 * @param exi @f$ \delta\xi@f$ - error on @f$\xi@f$
402 * @param sigma @f$ \sigma@f$ - Gaussian width
403 * @param esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
404 * @param sigman @f$ \sigma_n@f$ - Noise width
405 * @param esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
406 * @param a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
408 * @param ea Array of @f$ N-1@f$ errors on weights @f$ a_i@f$ for
411 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta,
412 Int_t quality,UShort_t n,
413 Double_t chi2, UShort_t nu,
414 Double_t c, Double_t ec,
415 Double_t delta, Double_t edelta,
416 Double_t xi, Double_t exi,
417 Double_t sigma, Double_t esigma,
418 Double_t sigman, Double_t esigman,
419 Double_t* a, Double_t* ea);
424 * @name Set and get eta axis
427 * Set the eta axis to use
429 * @param axis Eta axis
431 void SetEtaAxis(const TAxis& axis);
433 * Set the eta axis to use
435 * @param nBins Number of bins
436 * @param min Minimum @f$ \eta@f$
437 * @param max maximum @f$ \eta@f$
439 void SetEtaAxis(Int_t nBins, Double_t min, Double_t max);
441 * Get the eta axis used
445 const TAxis& GetEtaAxis() const { return fEtaAxis; }
447 * Set the low cut used when fitting
449 * @param cut Cut value
451 void SetLowCut(Double_t cut) { fLowCut = cut; }
453 * Get the low cut used when fitting
455 * @return Low cut used for fitting
457 Double_t GetLowCut() const { return fLowCut; }
459 * Find the eta bin corresponding to the given eta
461 * @param eta Eta value
463 * @return Bin (in @f$[1,N_{bins}]@f$) corresponding to the given
464 * eta, or 0 if out of range.
466 Int_t FindEtaBin(Double_t eta) const;
474 * Find the fit corresponding to the specified parameters
478 * @param eta Eta value
480 * @return Fit parameters or null in case of problems
482 ELossFit* FindFit(UShort_t d, Char_t r, Double_t eta) const;
484 * Find the fit corresponding to the specified parameters
488 * @param etabin Eta bin (1 based)
490 * @return Fit parameters or null in case of problems
492 ELossFit* FindFit(UShort_t d, Char_t r, Int_t etabin) const;
497 * @name Miscellaneous
500 * Get the ring array corresponding to the specified ring
505 * @return Pointer to ring array, or null in case of problems
507 TObjArray* GetRingArray(UShort_t d, Char_t r) const;
509 * Signal that this is a folder
511 * @return Always true
513 Bool_t IsFolder() const { return true; }
519 void Browse(TBrowser* b);
523 * @param option Options. Possible values are
524 * - err Plot error bars
526 void Draw(Option_t* option=""); //*MENU*
530 * @param option Options
531 * - R Print recursive
534 void Print(Option_t* option="R") const; //*MENU*
538 * Get the ring array corresponding to the specified ring
543 * @return Pointer to ring array, or newly created container
545 TObjArray* GetOrMakeRingArray(UShort_t d, Char_t r);
547 TObjArray fRings; // Array of rings
548 TAxis fEtaAxis; // Eta axis used
549 Double_t fLowCut; // Low cut used when fitting
551 ClassDef(AliFMDCorrELossFit,2);
554 //____________________________________________________________________
556 AliFMDCorrELossFit::SetEtaAxis(Int_t nBins, Double_t min, Double_t max)
558 fEtaAxis.Set(nBins, min, max);
560 //____________________________________________________________________
562 AliFMDCorrELossFit::SetEtaAxis(const TAxis& e)
564 fEtaAxis.Set(e.GetNbins(), e.GetXmin(), e.GetXmax());
566 //____________________________________________________________________
568 AliFMDCorrELossFit::ELossFit::GetA(UShort_t i) const
571 if (i > fN) return 0;
572 if (i == 1) return 1;
575 //____________________________________________________________________
577 AliFMDCorrELossFit::ELossFit::GetEA(UShort_t i) const
580 if (i > fN) return 0;
581 if (i == 1) return 1;