1 // Object holding the Energy loss fit 'correction'
3 // These are generated from Monte-Carlo or real ESDs.
4 #ifndef ALIFMDCORRELOSSFIT_H
5 #define ALIFMDCORRELOSSFIT_H
7 * @file AliFMDCorrELossFit.h
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 14:01:15 2011
13 * @ingroup pwg2_forward_eloss
18 #include <TObjArray.h>
23 * @defgroup pwg2_forward_corr Corrections
25 * @ingroup pwg2_forward
28 * Object holding the Energy loss fit 'correction'
30 * These are generated from Monte-Carlo or real ESDs.
32 * @ingroup pwg2_forward_corr
33 * @ingroup pwg2_forward_eloss
35 class AliFMDCorrELossFit : public TObject
39 * POD structure to hold data from fits
41 * @ingroup pwg2_forward_corr
43 struct ELossFit : public TObject
45 Int_t fN; // Number of peaks fitted
46 UShort_t fNu; // Number degrees of freedom
47 Double_t fChi2; // Chi square from fit
48 Double_t fC; // Scaling constant
49 Double_t fDelta; // Most probable value
50 Double_t fXi; // Width parameter of Landau
51 Double_t fSigma; // Sigma on folded gaussian
52 Double_t fSigmaN; // Sigma of detector noise
53 Double_t* fA; // [fN] Weights
54 Double_t fEC; // Error on C
55 Double_t fEDelta; // Error on Delta
56 Double_t fEXi; // Error on Xi
57 Double_t fESigma; // Error on sigma
58 Double_t fESigmaN;// Error on sigma (noise)
59 Double_t* fEA; // [fN] Error on weights
60 Int_t fQuality;// Assigned quality
61 UShort_t fDet; // Detector
63 UShort_t fBin; // Eta bin
65 static Double_t fgMaxRelError; // Global default max relative error
66 static Double_t fgLeastWeight; // Global default least weight
67 static Double_t fgMaxChi2nu; // Global default maximum reduced chi^2
74 * Construct from a function
76 * @param quality Quality flag
79 ELossFit(Int_t quality,const TF1& f);
81 * Constructor with full parameter set
83 * @param quality Quality flag
84 * @param n @f$ N@f$ - Number of fitted peaks
85 * @param chi2 @f$ \chi^2 @f$
86 * @param nu @f$ \nu @f$ - number degrees of freedom
87 * @param c @f$ C@f$ - scale constant
88 * @param ec @f$ \delta C@f$ - error on @f$ C@f$
89 * @param delta @f$ \Delta@f$ - Most probable value
90 * @param edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
91 * @param xi @f$ \xi@f$ - width
92 * @param exi @f$ \delta\xi@f$ - error on @f$\xi@f$
93 * @param sigma @f$ \sigma@f$ - Width of Gaussian
94 * @param esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
95 * @param sigman @f$ \sigma_n@f$ - Noise width
96 * @param esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
97 * @param a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
99 * @param ea Array of @f$ N-1@f$ error on the weights @f$ a_i@f$ for
102 ELossFit(Int_t quality,UShort_t n,
103 Double_t chi2, UShort_t nu,
104 Double_t c, Double_t ec,
105 Double_t delta, Double_t edelta,
106 Double_t xi, Double_t exi,
107 Double_t sigma, Double_t esigma,
108 Double_t sigman, Double_t esigman,
109 const Double_t* a,const Double_t* ea);
113 * @param o Object to copy from
115 ELossFit(const ELossFit& o);
117 * Assignment operator
119 * @param o Object to assign from
121 * @return Reference to this object
123 ELossFit& operator=(const ELossFit& o);
130 * @name Access to parameters
133 * @return Number of peaks fitted
135 Int_t GetN() const { return fN; }
137 * @return Number degrees of freedom
139 UShort_t GetNu() const { return fNu; }
141 * @return Chi square from fit
143 Double_t GetChi2() const { return fChi2; }
145 * @return Scaling constant
147 Double_t GetC() const { return fC; }
149 * @return Most probable value
151 Double_t GetDelta() const { return fDelta; }
153 * @return Width parameter of Landau
155 Double_t GetXi() const { return fXi; }
157 * @return Sigma on folded gaussian
159 Double_t GetSigma() const { return fSigma; }
161 * @return Sigma of detector noise
163 Double_t GetSigmaN() const { return fSigmaN; }
167 Double_t* GetAs() const { return fA; }
171 Double_t GetA(UShort_t i) const;
175 Double_t GetEC() const { return fEC; }
177 * @return Error on Delta
179 Double_t GetEDelta() const { return fEDelta; }
181 * @return Error on Xi
183 Double_t GetEXi() const { return fEXi; }
185 * @return Error on sigma
187 Double_t GetESigma() const { return fESigma; }
189 * @return Error on sigma (noise)
191 Double_t GetESigmaN() const { return fESigmaN; }
193 * @return Error on weights
195 Double_t* GetEAs() const { return fEA; }
197 * @return Error on weights
199 Double_t GetEA(UShort_t i) const;
201 * @return Assigned quality
203 Int_t GetQuality() const { return fQuality; }
207 UShort_t GetDet() const { return fDet; }
211 Char_t GetRing() const { return fRing; }
215 UShort_t GetBin() const { return fBin; }
225 * f_N(x;\Delta,\xi,\sigma') =
226 * \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')
229 * (see AliForwardUtil::NLandauGaus) for the maximum @f$ N @f$
230 * that fulfills the requirements
232 * @param x Where to evaluate
233 * @param maxN @f$ \max{N}@f$
235 * @return @f$ f_N(x;\Delta,\xi,\sigma')@f$
237 Double_t Evaluate(Double_t x,
238 UShort_t maxN=999) const;
242 * f_W(x;\Delta,\xi,\sigma') =
243 * \frac{\sum_{i=1}^{n} i a_i f_i(x;\Delta,\xi,\sigma')}{
244 * f_N(x;\Delta,\xi,\sigma')} =
245 * \frac{\sum_{i=1}^{n} i a_i f(x;\Delta_i,\xi_i,\sigma_i')}{
246 * \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')}
248 * where @f$ n@f$ fulfills the requirements (see FindMaxWeight).
250 * If the denominator is zero, then 1 is returned.
252 * See also AliForwardUtil::ILandauGaus and AliForwardUtil::NLandauGaus
253 * for more information on the evaluated functions.
255 * @param x Where to evaluate
256 * @param maxN @f$ \max{N}@f$
258 * @return @f$ f_W(x;\Delta,\xi,\sigma')@f$.
260 Double_t EvaluateWeighted(Double_t x,
261 UShort_t maxN=9999) const;
263 * Find the maximum weight to use. The maximum weight is the
264 * largest i for which
266 * - @f$ i \leq \max{N}@f$
267 * - @f$ a_i > \min{a}@f$
268 * - @f$ \delta a_i/a_i > \delta_{max}@f$
270 * @param maxRelError @f$ \min{a}@f$
271 * @param leastWeight @f$ \delta_{max}@f$
272 * @param maxN @f$ \max{N}@f$
274 * @return The largest index @f$ i@f$ for which the above
275 * conditions hold. Will never return less than 1.
277 Int_t FindMaxWeight(Double_t maxRelError=2*fgMaxRelError,
278 Double_t leastWeight=fgLeastWeight,
279 UShort_t maxN=999) const;
283 * @name TObject Sortable interface
286 * Declare this object as sortable
288 * @return Always true
290 Bool_t IsSortable() const { return kTRUE; }
292 * Compare to another ELossFit object.
294 * - +1, if this quality is better (larger) than other objects quality
295 * - -1, if this quality is worse (smaller) than other objects quality
296 * - +1, if this @f$|\chi^2/\nu-1|@f$ is smaller than the same for other
297 * - -1, if this @f$|\chi^2/\nu-1|@f$ is larger than the same for other
300 * @param o Other object to compare to
302 Int_t Compare(const TObject* o) const;
306 * name Auxiliary member functions
309 * Information to standard output
311 * @param option Not used
313 void Print(Option_t* option) const; // *MENU*
317 * @param option Options
318 * - COMP Draw components too
320 void Draw(Option_t* option="comp"); // *MENU*
326 void Browse(TBrowser* b);
328 * Get the name of this object
333 const Char_t* GetName() const;
335 * Calculate the lower bound
337 * @param f Width factor
338 * @param includeSigma Whether to include sigma
340 * @return @f$ \Delta - f (\xi + \sigma)@f$
342 Double_t GetLowerBound(Double_t f, Bool_t includeSigma) const;
344 * Calculate the quality
346 void CalculateQuality(Double_t maxChi2nu=fgMaxChi2nu,
347 Double_t maxRelError=fgMaxRelError,
348 Double_t leastWeight=fgLeastWeight);
350 ClassDef(ELossFit,1); // Result of fit
354 * Default constructor
356 AliFMDCorrELossFit();
360 * @param o Object to copy from
362 AliFMDCorrELossFit(const AliFMDCorrELossFit& o);
366 virtual ~AliFMDCorrELossFit();
368 * Assignment operator
370 * @param o Object to assign from
372 * @return Reference to this object
374 AliFMDCorrELossFit& operator=(const AliFMDCorrELossFit& o);
381 * Set the fit parameters from a function
386 * @param quality Quality flag
387 * @param f Function from fit
389 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta, Int_t quality,
392 * Set the fit parameters from a function
397 * @param f ELoss fit result - note, the object will take ownership
399 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta, ELossFit* f);
401 * Set the fit parameters from a function
405 * @param etaBin Eta (bin number, 1->nBins)
406 * @param f ELoss fit result - note, the object will take ownership
408 Bool_t SetFit(UShort_t d, Char_t r, Int_t etaBin, ELossFit* f);
410 * Set the fit parameters from a function
412 * @param d Detector number
413 * @param r Ring identifier
414 * @param eta Eta value
415 * @param quality Quality flag
416 * @param n @f$ N@f$ - Number of fitted peaks
417 * @param chi2 @f$ \chi^2 @f$
418 * @param nu @f$ \nu @f$ - number degrees of freedom
419 * @param c @f$ C@f$ - scale constant
420 * @param ec @f$ \delta C@f$ - error on @f$ C@f$
421 * @param delta @f$ \Delta@f$ - most probable value
422 * @param edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
423 * @param xi @f$ \xi@f$ - Landau width
424 * @param exi @f$ \delta\xi@f$ - error on @f$\xi@f$
425 * @param sigma @f$ \sigma@f$ - Gaussian width
426 * @param esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
427 * @param sigman @f$ \sigma_n@f$ - Noise width
428 * @param esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
429 * @param a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
431 * @param ea Array of @f$ N-1@f$ errors on weights @f$ a_i@f$ for
434 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta,
435 Int_t quality,UShort_t n,
436 Double_t chi2, UShort_t nu,
437 Double_t c, Double_t ec,
438 Double_t delta, Double_t edelta,
439 Double_t xi, Double_t exi,
440 Double_t sigma, Double_t esigma,
441 Double_t sigman, Double_t esigman,
442 Double_t* a, Double_t* ea);
447 * @name Set and get eta axis
450 * Set the eta axis to use
452 * @param axis Eta axis
454 void SetEtaAxis(const TAxis& axis);
456 * Set the eta axis to use
458 * @param nBins Number of bins
459 * @param min Minimum @f$ \eta@f$
460 * @param max maximum @f$ \eta@f$
462 void SetEtaAxis(Int_t nBins, Double_t min, Double_t max);
464 * Get the eta axis used
468 const TAxis& GetEtaAxis() const { return fEtaAxis; }
470 * Set the low cut used when fitting
472 * @param cut Cut value
474 void SetLowCut(Double_t cut) { fLowCut = cut; }
476 * Get the low cut used when fitting
478 * @return Low cut used for fitting
480 Double_t GetLowCut() const { return fLowCut; }
482 * Find the eta bin corresponding to the given eta
484 * @param eta Eta value
486 * @return Bin (in @f$[1,N_{bins}]@f$) corresponding to the given
487 * eta, or 0 if out of range.
489 Int_t FindEtaBin(Double_t eta) const;
497 * Find the fit corresponding to the specified parameters
501 * @param eta Eta value
503 * @return Fit parameters or null in case of problems
505 ELossFit* FindFit(UShort_t d, Char_t r, Double_t eta) const;
507 * Find the fit corresponding to the specified parameters
511 * @param etabin Eta bin (1 based)
513 * @return Fit parameters or null in case of problems
515 ELossFit* FindFit(UShort_t d, Char_t r, Int_t etabin) const;
517 * Find the fit corresponding to the specified parameters
521 * @param eta Eta value
523 * @return Fit parameters or null in case of problems
525 ELossFit* GetFit(UShort_t d, Char_t r, Double_t eta) const;
527 * Find the fit corresponding to the specified parameters
531 * @param etabin Eta bin (1 based)
533 * @return Fit parameters or null in case of problems
535 ELossFit* GetFit(UShort_t d, Char_t r, Int_t etabin) const;
540 * @name Lower bounds on fits
543 * Get the lower validity bound of the fit
547 * @param etaBin Eta bin (1-based)
548 * @param f Factor on xi (and sigma)
549 * @param showErrors Show errors
550 * @param includeSigma Whether to include sigma
552 * @return @f$ \Delta_{mp} - f(\xi+\sigma)@f$
554 Double_t GetLowerBound(UShort_t d, Char_t r, Int_t etaBin,
555 Double_t f, Bool_t showErrors=true,
556 Bool_t includeSigma=true) const;
558 * Get the lower validity bound of the fit
562 * @param eta Eta value
563 * @param f Factor on xi (and sigma)
564 * @param showErrors Show errors
565 * @param includeSigma Whether to include sigma
567 * @return @f$ \Delta_{mp} - f(\xi+\sigma)@f$
569 Double_t GetLowerBound(UShort_t d, Char_t r, Double_t eta,
570 Double_t f, Bool_t showErrors=true,
571 Bool_t includeSigma=true) const;
576 * @name Miscellaneous
579 * Get the ring array corresponding to the specified ring
584 * @return Pointer to ring array, or null in case of problems
586 TObjArray* GetRingArray(UShort_t d, Char_t r) const;
588 * Signal that this is a folder
590 * @return Always true
592 Bool_t IsFolder() const { return true; }
598 void Browse(TBrowser* b);
602 * @param option Options. Possible values are
603 * - error Plot error bars
604 * - relative Plot relative errors
606 void Draw(Option_t* option=""); //*MENU*
610 * @param option Options
611 * - R Print recursive
614 void Print(Option_t* option="R") const; //*MENU*
618 * Get the ring array corresponding to the specified ring
623 * @return Pointer to ring array, or newly created container
625 TObjArray* GetOrMakeRingArray(UShort_t d, Char_t r);
627 TObjArray fRings; // Array of rings
628 TAxis fEtaAxis; // Eta axis used
629 Double_t fLowCut; // Low cut used when fitting
631 ClassDef(AliFMDCorrELossFit,2);
634 //____________________________________________________________________
636 AliFMDCorrELossFit::SetEtaAxis(Int_t nBins, Double_t min, Double_t max)
638 fEtaAxis.Set(nBins, min, max);
640 //____________________________________________________________________
642 AliFMDCorrELossFit::SetEtaAxis(const TAxis& e)
644 fEtaAxis.Set(e.GetNbins(), e.GetXmin(), e.GetXmax());
646 //____________________________________________________________________
648 AliFMDCorrELossFit::ELossFit::GetA(UShort_t i) const
651 if (i > fN) return 0;
652 if (i == 1) return 1;
655 //____________________________________________________________________
657 AliFMDCorrELossFit::ELossFit::GetEA(UShort_t i) const
660 if (i > fN) return 0;
661 if (i == 1) return 1;