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
13 * @defgroup pwg2_forward_corr Corrections
15 * @ingroup pwg2_forward
18 * Object holding the Energy loss fit 'correction'
20 * These are generated from Monte-Carlo or real ESDs.
22 * @ingroup pwg2_forward_corr
24 class AliFMDCorrELossFit : public TObject
28 * POD structure to hold data from fits
30 * @ingroup pwg2_forward_corr
32 struct ELossFit : public TObject
34 Int_t fN; // Number of peaks fitted
35 UShort_t fNu; // Number degrees of freedom
36 Double_t fChi2; // Chi square from fit
37 Double_t fC; // Scaling constant
38 Double_t fDelta; // Most probable value
39 Double_t fXi; // Width parameter of Landau
40 Double_t fSigma; // Sigma on folded gaussian
41 Double_t fSigmaN; // Sigma of detector noise
42 Double_t* fA; // [fN] Weights
43 Double_t fEC; // Error on C
44 Double_t fEDelta; // Error on Delta
45 Double_t fEXi; // Error on Xi
46 Double_t fESigma; // Error on sigma
47 Double_t fESigmaN;// Error on sigma (noise)
48 Double_t* fEA; // [fN] Error on weights
49 Int_t fQuality;// Assigned quality
50 UShort_t fDet; // Detector
52 UShort_t fBin; // Eta bin
54 static Double_t fgMaxRelError; // Global default max relative error
55 static Double_t fgLeastWeight; // Global default least weight
56 static Double_t fgMaxChi2nu; // Global default maximum reduced chi^2
63 * Construct from a function
65 * @param quality Quality flag
68 ELossFit(Int_t quality,const TF1& f);
70 * Constructor with full parameter set
72 * @param quality Quality flag
73 * @param n @f$ N@f$ - Number of fitted peaks
74 * @param chi2 @f$ \chi^2 @f$
75 * @param nu @f$ \nu @f$ - number degrees of freedom
76 * @param c @f$ C@f$ - scale constant
77 * @param ec @f$ \delta C@f$ - error on @f$ C@f$
78 * @param delta @f$ \Delta@f$ - Most probable value
79 * @param edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
80 * @param xi @f$ \xi@f$ - width
81 * @param exi @f$ \delta\xi@f$ - error on @f$\xi@f$
82 * @param sigma @f$ \sigma@f$ - Width of Gaussian
83 * @param esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
84 * @param sigman @f$ \sigma_n@f$ - Noise width
85 * @param esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
86 * @param a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
88 * @param ea Array of @f$ N-1@f$ error on the weights @f$ a_i@f$ for
91 ELossFit(Int_t quality,UShort_t n,
92 Double_t chi2, UShort_t nu,
93 Double_t c, Double_t ec,
94 Double_t delta, Double_t edelta,
95 Double_t xi, Double_t exi,
96 Double_t sigma, Double_t esigma,
97 Double_t sigman, Double_t esigman,
98 Double_t* a, Double_t* ea);
102 * @param o Object to copy from
104 ELossFit(const ELossFit& o);
106 * Assignment operator
108 * @param o Object to assign from
110 * @return Reference to this object
112 ELossFit& operator=(const ELossFit& o);
119 * @name Access to parameters
122 * @return Number of peaks fitted
124 Int_t GetN() const { return fN; }
126 * @return Number degrees of freedom
128 UShort_t GetNu() const { return fNu; }
130 * @return Chi square from fit
132 Double_t GetChi2() const { return fChi2; }
134 * @return Scaling constant
136 Double_t GetC() const { return fC; }
138 * @return Most probable value
140 Double_t GetDelta() const { return fDelta; }
142 * @return Width parameter of Landau
144 Double_t GetXi() const { return fXi; }
146 * @return Sigma on folded gaussian
148 Double_t GetSigma() const { return fSigma; }
150 * @return Sigma of detector noise
152 Double_t GetSigmaN() const { return fSigmaN; }
156 Double_t* GetAs() const { return fA; }
160 Double_t GetA(UShort_t i) const;
164 Double_t GetEC() const { return fEC; }
166 * @return Error on Delta
168 Double_t GetEDelta() const { return fEDelta; }
170 * @return Error on Xi
172 Double_t GetEXi() const { return fEXi; }
174 * @return Error on sigma
176 Double_t GetESigma() const { return fESigma; }
178 * @return Error on sigma (noise)
180 Double_t GetESigmaN() const { return fESigmaN; }
182 * @return Error on weights
184 Double_t* GetEAs() const { return fEA; }
186 * @return Error on weights
188 Double_t GetEA(UShort_t i) const;
190 * @return Assigned quality
192 Int_t GetQuality() const { return fQuality; }
196 UShort_t GetDet() const { return fDet; }
200 Char_t GetRing() const { return fRing; }
204 UShort_t GetBin() const { return fBin; }
214 * f_N(x;\Delta,\xi,\sigma') =
215 * \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')
218 * (see AliForwardUtil::NLandauGaus) for the maximum @f$ N @f$
219 * that fulfills the requirements
221 * @param x Where to evaluate
222 * @param maxN @f$ \max{N}@f$
224 * @return @f$ f_N(x;\Delta,\xi,\sigma')@f$
226 Double_t Evaluate(Double_t x,
227 UShort_t maxN=999) const;
231 * f_W(x;\Delta,\xi,\sigma') =
232 * \frac{\sum_{i=1}^{n} i a_i f_i(x;\Delta,\xi,\sigma')}{
233 * f_N(x;\Delta,\xi,\sigma')} =
234 * \frac{\sum_{i=1}^{n} i a_i f(x;\Delta_i,\xi_i,\sigma_i')}{
235 * \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')}
237 * where @f$ n@f$ fulfills the requirements (see FindMaxWeight).
239 * If the denominator is zero, then 1 is returned.
241 * See also AliForwardUtil::ILandauGaus and AliForwardUtil::NLandauGaus
242 * for more information on the evaluated functions.
244 * @param x Where to evaluate
245 * @param maxN @f$ \max{N}@f$
247 * @return @f$ f_W(x;\Delta,\xi,\sigma')@f$.
249 Double_t EvaluateWeighted(Double_t x,
250 UShort_t maxN=9999) const;
252 * Find the maximum weight to use. The maximum weight is the
253 * largest i for which
255 * - @f$ i \leq \max{N}@f$
256 * - @f$ a_i > \min{a}@f$
257 * - @f$ \delta a_i/a_i > \delta_{max}@f$
259 * @param maxRelError @f$ \min{a}@f$
260 * @param leastWeight @f$ \delta_{max}@f$
261 * @param maxN @f$ \max{N}@f$
263 * @return The largest index @f$ i@f$ for which the above
264 * conditions hold. Will never return less than 1.
266 Int_t FindMaxWeight(Double_t maxRelError=2*fgMaxRelError,
267 Double_t leastWeight=fgLeastWeight,
268 UShort_t maxN=999) const;
272 * @name TObject Sortable interface
275 * Declare this object as sortable
277 * @return Always true
279 Bool_t IsSortable() const { return kTRUE; }
281 * Compare to another ELossFit object.
283 * - +1, if this quality is better (larger) than other objects quality
284 * - -1, if this quality is worse (smaller) than other objects quality
285 * - +1, if this @f$|\chi^2/\nu-1|@f$ is smaller than the same for other
286 * - -1, if this @f$|\chi^2/\nu-1|@f$ is larger than the same for other
289 * @param o Other object to compare to
291 Int_t Compare(const TObject* o) const;
295 * name Auxiliary member functions
298 * Information to standard output
300 * @param option Not used
302 void Print(Option_t* option) const; // *MENU*
306 * @param option Options
307 * - COMP Draw components too
309 void Draw(Option_t* option="comp"); // *MENU*
315 void Browse(TBrowser* b);
317 * Get the name of this object
322 const Char_t* GetName() const;
324 * Calculate the quality
326 void CalculateQuality(Double_t maxChi2nu=fgMaxChi2nu,
327 Double_t maxRelError=fgMaxRelError,
328 Double_t leastWeight=fgLeastWeight);
330 ClassDef(ELossFit,1); // Result of fit
334 * Default constructor
336 AliFMDCorrELossFit();
340 * @param o Object to copy from
342 AliFMDCorrELossFit(const AliFMDCorrELossFit& o);
346 virtual ~AliFMDCorrELossFit();
348 * Assignment operator
350 * @param o Object to assign from
352 * @return Reference to this object
354 AliFMDCorrELossFit& operator=(const AliFMDCorrELossFit& o);
361 * Set the fit parameters from a function
366 * @param quality Quality flag
367 * @param f Function from fit
369 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta, Int_t quality,
372 * Set the fit parameters from a function
377 * @param f ELoss fit result - note, the object will take ownership
379 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta, ELossFit* f);
381 * Set the fit parameters from a function
385 * @param etaBin Eta (bin number, 1->nBins)
386 * @param f ELoss fit result - note, the object will take ownership
388 Bool_t SetFit(UShort_t d, Char_t r, Int_t etaBin, ELossFit* f);
390 * Set the fit parameters from a function
392 * @param d Detector number
393 * @param r Ring identifier
394 * @param eta Eta value
395 * @param quality Quality flag
396 * @param n @f$ N@f$ - Number of fitted peaks
397 * @param chi2 @f$ \chi^2 @f$
398 * @param nu @f$ \nu @f$ - number degrees of freedom
399 * @param c @f$ C@f$ - scale constant
400 * @param ec @f$ \delta C@f$ - error on @f$ C@f$
401 * @param delta @f$ \Delta@f$ - most probable value
402 * @param edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
403 * @param xi @f$ \xi@f$ - Landau width
404 * @param exi @f$ \delta\xi@f$ - error on @f$\xi@f$
405 * @param sigma @f$ \sigma@f$ - Gaussian width
406 * @param esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
407 * @param sigman @f$ \sigma_n@f$ - Noise width
408 * @param esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
409 * @param a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
411 * @param ea Array of @f$ N-1@f$ errors on weights @f$ a_i@f$ for
414 Bool_t SetFit(UShort_t d, Char_t r, Double_t eta,
415 Int_t quality,UShort_t n,
416 Double_t chi2, UShort_t nu,
417 Double_t c, Double_t ec,
418 Double_t delta, Double_t edelta,
419 Double_t xi, Double_t exi,
420 Double_t sigma, Double_t esigma,
421 Double_t sigman, Double_t esigman,
422 Double_t* a, Double_t* ea);
427 * @name Set and get eta axis
430 * Set the eta axis to use
432 * @param axis Eta axis
434 void SetEtaAxis(const TAxis& axis);
436 * Set the eta axis to use
438 * @param nBins Number of bins
439 * @param min Minimum @f$ \eta@f$
440 * @param max maximum @f$ \eta@f$
442 void SetEtaAxis(Int_t nBins, Double_t min, Double_t max);
444 * Get the eta axis used
448 const TAxis& GetEtaAxis() const { return fEtaAxis; }
450 * Set the low cut used when fitting
452 * @param cut Cut value
454 void SetLowCut(Double_t cut) { fLowCut = cut; }
456 * Get the low cut used when fitting
458 * @return Low cut used for fitting
460 Double_t GetLowCut() const { return fLowCut; }
462 * Find the eta bin corresponding to the given eta
464 * @param eta Eta value
466 * @return Bin (in @f$[1,N_{bins}]@f$) corresponding to the given
467 * eta, or 0 if out of range.
469 Int_t FindEtaBin(Double_t eta) const;
477 * Find the fit corresponding to the specified parameters
481 * @param eta Eta value
483 * @return Fit parameters or null in case of problems
485 ELossFit* FindFit(UShort_t d, Char_t r, Double_t eta) const;
487 * Find the fit corresponding to the specified parameters
491 * @param etabin Eta bin (1 based)
493 * @return Fit parameters or null in case of problems
495 ELossFit* FindFit(UShort_t d, Char_t r, Int_t etabin) const;
500 * @name Miscellaneous
503 * Get the ring array corresponding to the specified ring
508 * @return Pointer to ring array, or null in case of problems
510 TObjArray* GetRingArray(UShort_t d, Char_t r) const;
512 * Signal that this is a folder
514 * @return Always true
516 Bool_t IsFolder() const { return true; }
522 void Browse(TBrowser* b);
526 * @param option Options. Possible values are
527 * - err Plot error bars
529 void Draw(Option_t* option=""); //*MENU*
533 * @param option Options
534 * - R Print recursive
537 void Print(Option_t* option="R") const; //*MENU*
541 * Get the ring array corresponding to the specified ring
546 * @return Pointer to ring array, or newly created container
548 TObjArray* GetOrMakeRingArray(UShort_t d, Char_t r);
550 TObjArray fRings; // Array of rings
551 TAxis fEtaAxis; // Eta axis used
552 Double_t fLowCut; // Low cut used when fitting
554 ClassDef(AliFMDCorrELossFit,2);
557 //____________________________________________________________________
559 AliFMDCorrELossFit::SetEtaAxis(Int_t nBins, Double_t min, Double_t max)
561 fEtaAxis.Set(nBins, min, max);
563 //____________________________________________________________________
565 AliFMDCorrELossFit::SetEtaAxis(const TAxis& e)
567 fEtaAxis.Set(e.GetNbins(), e.GetXmin(), e.GetXmax());
569 //____________________________________________________________________
571 AliFMDCorrELossFit::ELossFit::GetA(UShort_t i) const
574 if (i > fN) return 0;
575 if (i == 1) return 1;
578 //____________________________________________________________________
580 AliFMDCorrELossFit::ELossFit::GetEA(UShort_t i) const
583 if (i > fN) return 0;
584 if (i == 1) return 1;