1 // Object holding the Energy loss fit 'correction'
3 // These are generated from Monte-Carlo or real ESDs.
5 #include "AliFMDCorrELossFit.h"
6 #include "AliForwardUtil.h"
9 #include <TVirtualPad.h>
18 Double_t AliFMDCorrELossFit::ELossFit::fgMaxRelError = .2;
19 Double_t AliFMDCorrELossFit::ELossFit::fgLeastWeight = 1e-5;
20 Double_t AliFMDCorrELossFit::ELossFit::fgMaxChi2nu = 20;
22 //____________________________________________________________________
23 AliFMDCorrELossFit::ELossFit::ELossFit()
45 // Default constructor
49 //____________________________________________________________________
50 AliFMDCorrELossFit::ELossFit::ELossFit(Int_t quality, const TF1& f)
51 : fN(f.GetNpar() > AliForwardUtil::ELossFitter::kN ?
52 f.GetParameter(AliForwardUtil::ELossFitter::kN) :
55 fChi2(f.GetChisquare()),
56 fC(f.GetParameter(AliForwardUtil::ELossFitter::kC)),
57 fDelta(f.GetParameter(AliForwardUtil::ELossFitter::kDelta)),
58 fXi(f.GetParameter(AliForwardUtil::ELossFitter::kXi)),
59 fSigma(f.GetParameter(AliForwardUtil::ELossFitter::kSigma)),
60 fSigmaN(f.GetParameter(AliForwardUtil::ELossFitter::kSigmaN)),
62 fEC(f.GetParError(AliForwardUtil::ELossFitter::kC)),
63 fEDelta(f.GetParError(AliForwardUtil::ELossFitter::kDelta)),
64 fEXi(f.GetParError(AliForwardUtil::ELossFitter::kXi)),
65 fESigma(f.GetParError(AliForwardUtil::ELossFitter::kSigma)),
66 fESigmaN(f.GetParError(AliForwardUtil::ELossFitter::kSigmaN)),
74 // Construct from a function
77 // quality Quality flag
81 fA = new Double_t[fN];
82 fEA = new Double_t[fN];
83 for (Int_t i = 0; i < fN-1; i++) {
84 fA[i] = f.GetParameter(AliForwardUtil::ELossFitter::kA+i);
85 fEA[i] = f.GetParError(AliForwardUtil::ELossFitter::kA+i);
91 //____________________________________________________________________
92 AliFMDCorrELossFit::ELossFit::ELossFit(Int_t quality,UShort_t n,
93 Double_t chi2, UShort_t nu,
94 Double_t c, Double_t ec,
95 Double_t delta, Double_t edelta,
96 Double_t xi, Double_t exi,
97 Double_t sigma, Double_t esigma,
98 Double_t sigman, Double_t esigman,
99 Double_t* a, Double_t* ea)
121 // Constructor with full parameter set
124 // quality Quality flag
125 // n @f$ N@f$ - Number of fitted peaks
126 // chi2 @f$ \chi^2 @f$
127 // nu @f$ \nu @f$ - number degrees of freedom
128 // c @f$ C@f$ - scale constant
129 // ec @f$ \delta C@f$ - error on @f$ C@f$
130 // delta @f$ \Delta@f$ - Most probable value
131 // edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
132 // xi @f$ \xi@f$ - width
133 // exi @f$ \delta\xi@f$ - error on @f$\xi@f$
134 // sigma @f$ \sigma@f$ - Width of Gaussian
135 // esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
136 // sigman @f$ \sigma_n@f$ - Noise width
137 // esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
138 // a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
140 // ea Array of @f$ N-1@f$ error on the weights @f$ a_i@f$ for
144 fA = new Double_t[fN];
145 fEA = new Double_t[fN];
146 for (Int_t i = 0; i < fN-1; i++) {
153 //____________________________________________________________________
154 AliFMDCorrELossFit::ELossFit::ELossFit(const ELossFit& o)
169 fESigmaN(o.fESigmaN),
171 fQuality(o.fQuality),
180 // o Object to copy from
183 fA = new Double_t[fN];
184 fEA = new Double_t[fN];
185 for (Int_t i = 0; i < fN-1; i++) {
193 //____________________________________________________________________
194 AliFMDCorrELossFit::ELossFit&
195 AliFMDCorrELossFit::ELossFit::operator=(const ELossFit& o)
198 // Assignment operator
201 // o Object to assign from
204 // Reference to this object
218 fESigmaN = o.fESigmaN;
219 fQuality = o.fQuality;
223 if (fA) delete [] fA;
224 if (fEA) delete [] fEA;
228 if (fN <= 0) return *this;
229 fA = new Double_t[fN];
230 fEA = new Double_t[fN];
231 for (Int_t i = 0; i < fN; i++) {
239 //____________________________________________________________________
240 AliFMDCorrELossFit::ELossFit::~ELossFit()
243 if (fEA) delete[] fEA;
247 //____________________________________________________________________
249 AliFMDCorrELossFit::ELossFit::FindMaxWeight(Double_t maxRelError,
250 Double_t leastWeight,
254 // Find the maximum weight to use. The maximum weight is the
255 // largest i for which
257 // - @f$ i \leq \max{N}@f$
258 // - @f$ a_i > \min{a}@f$
259 // - @f$ \delta a_i/a_i > \delta_{max}@f$
262 // maxRelError @f$ \min{a}@f$
263 // leastWeight @f$ \delta_{max}@f$
264 // maxN @f$ \max{N}@f$
267 // The largest index @f$ i@f$ for which the above
268 // conditions hold. Will never return less than 1.
270 Int_t n = TMath::Min(maxN, UShort_t(fN-1));
272 // fN is one larger than we have data
273 for (Int_t i = 0; i < n-1; i++, m++) {
274 if (fA[i] < leastWeight) break;
275 if (fEA[i] / fA[i] > maxRelError) break;
280 //____________________________________________________________________
282 AliFMDCorrELossFit::ELossFit::Evaluate(Double_t x,
288 // f_N(x;\Delta,\xi,\sigma') =
289 // \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')
292 // (see AliForwardUtil::NLandauGaus) for the maximum @f$ N @f$
293 // that fulfills the requirements
296 // x Where to evaluate
297 // maxN @f$ \max{N}@f$
300 // @f$ f_N(x;\Delta,\xi,\sigma')@f$
302 return AliForwardUtil::NLandauGaus(x, fDelta, fXi, fSigma, fSigmaN,
303 TMath::Min(maxN, UShort_t(fN)), fA);
306 //____________________________________________________________________
308 AliFMDCorrELossFit::ELossFit::EvaluateWeighted(Double_t x,
314 // f_W(x;\Delta,\xi,\sigma') =
315 // \frac{\sum_{i=1}^{n} i a_i f_i(x;\Delta,\xi,\sigma')}{
316 // f_N(x;\Delta,\xi,\sigma')} =
317 // \frac{\sum_{i=1}^{n} i a_i f(x;\Delta_i,\xi_i,\sigma_i')}{
318 // \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i')}
320 // where @f$ n@f$ fulfills the requirements (see FindMaxWeight).
322 // If the denominator is zero, then 1 is returned.
324 // See also AliForwardUtil::ILandauGaus and AliForwardUtil::NLandauGaus
325 // for more information on the evaluated functions.
328 // x Where to evaluate
329 // maxN @f$ \max{N}@f$
332 // @f$ f_W(x;\Delta,\xi,\sigma')@f$.
334 UShort_t n = TMath::Min(maxN, UShort_t(fN-1));
337 for (Int_t i = 1; i <= n; i++) {
338 Double_t a = (i == 1 ? 1 : fA[i-1]);
339 if (fA[i-1] < 0) break;
340 Double_t f = AliForwardUtil::ILandauGaus(x,fDelta,fXi,fSigma,fSigmaN,i);
344 if (den <= 0) return 1;
349 #define OUTPAR(N,V,E) \
350 std::setprecision(9) << \
351 std::setw(12) << N << ": " << \
352 std::setw(14) << V << " +/- " << \
353 std::setw(14) << E << " (" << \
354 std::setprecision(-1) << \
355 std::setw(5) << 100*(V>0?E/V:1) << "%)\n"
358 //____________________________________________________________________
360 AliFMDCorrELossFit::ELossFit::Compare(const TObject* o) const
363 // Compare to another ELossFit object.
365 // - +1, if this quality is better (larger) than other objects quality
366 // - -1, if this quality is worse (smaller) than other objects quality
367 // - +1, if this @f$|\chi^2/\nu-1|@f$ is smaller than the same for other
368 // - -1, if this @f$|\chi^2/\nu-1|@f$ is larger than the same for other
372 // o Other object to compare to
374 const ELossFit* other = static_cast<const ELossFit*>(o);
375 if (this->fQuality < other->fQuality) return -1;
376 if (this->fQuality > other->fQuality) return +1;
377 Double_t chi2nu = (fNu == 0 ? 1000 : fChi2 / fNu);
378 Double_t oChi2nu = (other->fNu == 0 ? 1000 : other->fChi2 / other->fNu);
379 if (TMath::Abs(chi2nu-1) < TMath::Abs(oChi2nu-1)) return +1;
380 if (TMath::Abs(chi2nu-1) > TMath::Abs(oChi2nu-1)) return -1;
384 //____________________________________________________________________
386 AliFMDCorrELossFit::ELossFit::Print(Option_t*) const
389 // Information to standard output
394 std::cout << GetName() << ":\n"
395 << " chi^2/nu = " << fChi2 << "/" << fNu << " = "
396 << (fNu == 0 ? 999 : fChi2 / fNu) << "\n"
397 << " Quality: " << fQuality << "\n"
398 << " NParticles: " << fN << " (" << FindMaxWeight() << ")\n"
399 << OUTPAR("Delta", fDelta, fEDelta)
400 << OUTPAR("xi", fXi, fEXi)
401 << OUTPAR("sigma", fSigma, fESigma)
402 << OUTPAR("sigma_n", fSigmaN, fESigmaN);
403 for (Int_t i = 0; i < fN-1; i++)
404 std::cout << OUTPAR(Form("a%d", i+2), fA[i], fEA[i]);
405 std::cout << std::flush;
408 //____________________________________________________________________
410 AliFMDCorrELossFit::ELossFit::GetName() const
413 // Get the name of this object
419 return Form("FMD%d%c_etabin%03d", fDet, fRing, fBin);
422 //____________________________________________________________________
424 AliFMDCorrELossFit::ELossFit::Browse(TBrowser* b)
427 // Browse this object
432 Draw(b ? b->GetDrawOption() : "comp");
437 //____________________________________________________________________
439 AliFMDCorrELossFit::ELossFit::Draw(Option_t* option)
446 // - COMP Draw components too
451 if (opt.Contains("COMP")) {
452 opt.ReplaceAll("COMP","");
455 if (!opt.Contains("SAME")) {
460 TF1* tot = AliForwardUtil::MakeNLandauGaus(1,
465 tot->SetLineColor(kBlack);
466 tot->SetLineWidth(2);
467 tot->SetLineStyle(1);
468 tot->SetTitle(GetName());
469 Double_t max = tot->GetMaximum();
471 if (!opt.Contains("SAME")) {
472 TH1* frame = new TH1F(GetName(),
473 Form("FMD%d%c, eta bin %d",fDet,fRing,fBin),
475 frame->SetMinimum(max/10000);
476 frame->SetMaximum(max*1.4);
477 frame->SetXTitle("#Delta / #Delta_{mip}");
481 tot->DrawCopy(opt.Data());
491 Int_t maxW = FindMaxWeight();
492 for (Int_t i=1; i <= fN; i++) {
493 TF1* f = AliForwardUtil::MakeILandauGaus((i == 1 ? 1 : fA[i-2]),
498 f->SetLineStyle(i > maxW ? 2 : 1);
499 min = TMath::Min(f->GetMaximum(), min);
500 f->DrawCopy(opt.Data());
504 tot->GetHistogram()->SetMaximum(max);
505 tot->GetHistogram()->SetMinimum(min);
506 tot->GetHistogram()->GetYaxis()->SetRangeUser(min, max);
512 //____________________________________________________________________
513 #define CHECKPAR(V,E,T) ((V > 0) && (E / V < T))
515 //____________________________________________________________________
517 AliFMDCorrELossFit::ELossFit::CalculateQuality(Double_t maxChi2nu,
518 Double_t maxRelError,
519 Double_t leastWeight)
522 // Calculate the quality
525 if (fNu > 0 && fChi2 / fNu < maxChi2nu) qual += 4;;
526 if (CHECKPAR(fDelta, fEDelta, maxRelError)) qual++;
527 if (CHECKPAR(fXi, fEXi, maxRelError)) qual++;
528 if (CHECKPAR(fSigma, fESigma, maxRelError)) qual++;
529 if (CHECKPAR(fSigmaN, fESigmaN, maxRelError)) qual++;
530 qual += FindMaxWeight(1.5*maxRelError, leastWeight, fN);
534 //____________________________________________________________________
535 AliFMDCorrELossFit::AliFMDCorrELossFit()
542 // Default constructor
544 fRings.SetOwner(kTRUE);
545 fEtaAxis.SetTitle("#eta");
546 fEtaAxis.SetName("etaAxis");
547 fRings.SetName("rings");
550 //____________________________________________________________________
551 AliFMDCorrELossFit::AliFMDCorrELossFit(const AliFMDCorrELossFit& o)
554 fEtaAxis(o.fEtaAxis.GetNbins(),o.fEtaAxis.GetXmin(),o.fEtaAxis.GetXmax()),
561 // o Object to copy from
563 fEtaAxis.SetTitle("#eta");
564 fEtaAxis.SetName("etaAxis");
567 //____________________________________________________________________
568 AliFMDCorrELossFit::~AliFMDCorrELossFit()
576 //____________________________________________________________________
578 AliFMDCorrELossFit::operator=(const AliFMDCorrELossFit& o)
581 // Assignment operator
584 // o Object to assign from
587 // Reference to this object
591 SetEtaAxis(o.fEtaAxis.GetNbins(), o.fEtaAxis.GetXmin(), o.fEtaAxis.GetXmax());
595 //____________________________________________________________________
597 AliFMDCorrELossFit::FindEtaBin(Double_t eta) const
600 // Find the eta bin corresponding to the given eta
606 // Bin (in @f$[1,N_{bins}]@f$) corresponding to the given
607 // eta, or 0 if out of range.
609 if (fEtaAxis.GetXmin() == fEtaAxis.GetXmax() || fEtaAxis.GetNbins() == 0) {
610 AliWarning("No eta axis defined");
613 Int_t bin = const_cast<TAxis&>(fEtaAxis).FindBin(eta);
614 if (bin <= 0 || bin > fEtaAxis.GetNbins()) return 0;
618 //____________________________________________________________________
620 AliFMDCorrELossFit::SetFit(UShort_t d, Char_t r, Int_t etaBin, ELossFit* fit)
623 // Set the fit parameters from a function
628 // etaBin Eta (bin number, 1->nBins)
629 // f ELoss fit result - note, the object will take ownership
631 TObjArray* ringArray = GetOrMakeRingArray(d, r);
633 AliError(Form("Failed to make ring array for FMD%d%c", d, r));
636 if (etaBin <= 0 || etaBin >= fEtaAxis.GetNbins()+1) {
637 AliError(Form("bin=%d is out of range [%d,%d]",
638 etaBin, 1, fEtaAxis.GetNbins()));
641 // AliInfo(Form("Adding fit %p at %3d", fit, etaBin));
642 ringArray->AddAtAndExpand(fit, etaBin);
646 //____________________________________________________________________
648 AliFMDCorrELossFit::SetFit(UShort_t d, Char_t r, Double_t eta, ELossFit* fit)
651 // Set the fit parameters from a function
657 // f ELoss fit result - note, the object will take ownership
659 Int_t bin = FindEtaBin(eta);
661 AliError(Form("eta=%f is out of range [%f,%f]",
662 eta, fEtaAxis.GetXmin(), fEtaAxis.GetXmax()));
666 return SetFit(d, r, bin, fit);
668 //____________________________________________________________________
670 AliFMDCorrELossFit::SetFit(UShort_t d, Char_t r,
672 Int_t quality,UShort_t n,
673 Double_t chi2, UShort_t nu,
674 Double_t c, Double_t ec,
675 Double_t delta, Double_t edelta,
676 Double_t xi, Double_t exi,
677 Double_t sigma, Double_t esigma,
678 Double_t sigman, Double_t esigman,
679 Double_t* a, Double_t* ea)
682 // Set the fit parameters from a function
688 // quality Quality flag
689 // n @f$ N@f$ - Number of fitted peaks
690 // chi2 @f$ \chi^2 @f$
691 // nu @f$ \nu @f$ - number degrees of freedom
692 // c @f$ C@f$ - scale constant
693 // ec @f$ \delta C@f$ - error on @f$ C@f$
694 // delta @f$ \Delta@f$ - most probable value
695 // edelta @f$ \delta\Delta@f$ - error on @f$\Delta@f$
696 // xi @f$ \xi@f$ - Landau width
697 // exi @f$ \delta\xi@f$ - error on @f$\xi@f$
698 // sigma @f$ \sigma@f$ - Gaussian width
699 // esigma @f$ \delta\sigma@f$ - error on @f$\sigma@f$
700 // sigman @f$ \sigma_n@f$ - Noise width
701 // esigman @f$ \delta\sigma_n@f$ - error on @f$\sigma_n@f$
702 // a Array of @f$ N-1@f$ weights @f$ a_i@f$ for
704 // ea Array of @f$ N-1@f$ errors on weights @f$ a_i@f$ for
707 ELossFit* e = new ELossFit(quality, n,
715 if (!SetFit(d, r, eta, e)) {
721 //____________________________________________________________________
723 AliFMDCorrELossFit::SetFit(UShort_t d, Char_t r, Double_t eta,
724 Int_t quality, const TF1& f)
727 // Set the fit parameters from a function
733 // quality Quality flag
734 // f Function from fit
736 ELossFit* e = new ELossFit(quality, f);
737 if (!SetFit(d, r, eta, e)) {
743 //____________________________________________________________________
744 AliFMDCorrELossFit::ELossFit*
745 AliFMDCorrELossFit::GetFit(UShort_t d, Char_t r, Int_t etabin) const
748 // Get the fit corresponding to the specified parameters
753 // etabin Eta bin (1 based)
756 // Fit parameters or null in case of problems
758 TObjArray* ringArray = GetRingArray(d, r);
759 if (!ringArray) return 0;
760 if (etabin <= 0 || etabin >= fEtaAxis.GetNbins()) return 0;
761 if (etabin > ringArray->GetEntriesFast()) return 0;
762 else if (etabin >= ringArray->GetEntriesFast()) etabin--;
763 else if (!ringArray->At(etabin)) etabin++;
764 return static_cast<ELossFit*>(ringArray->At(etabin));
766 //____________________________________________________________________
767 AliFMDCorrELossFit::ELossFit*
768 AliFMDCorrELossFit::GetFit(UShort_t d, Char_t r, Double_t eta) const
771 // Find the fit corresponding to the specified parameters
779 // Fit parameters or null in case of problems
781 Int_t etabin = FindEtaBin(eta);
782 return GetFit(d, r, etabin);
785 //____________________________________________________________________
786 AliFMDCorrELossFit::ELossFit*
787 AliFMDCorrELossFit::FindFit(UShort_t d, Char_t r, Int_t etabin) const
790 // Find the fit corresponding to the specified parameters
795 // etabin Eta bin (1 based)
798 // Fit parameters or null in case of problems
800 TObjArray* ringArray = GetRingArray(d, r);
802 AliError(Form("Failed to make ring array for FMD%d%c", d, r));
805 if (etabin <= 0 || etabin >= fEtaAxis.GetNbins()) {
806 AliError(Form("Eta bin=%3d out of bounds [%d,%d] for FMD%d%c",
807 etabin, 1, fEtaAxis.GetNbins(), d, r));
810 if (etabin > ringArray->GetEntriesFast()) {
811 AliError(Form("Eta bin=%3d out of bounds [%d,%d] for FMD%d%c",
812 etabin, 1, ringArray->GetEntriesFast(), d, r));
815 else if (etabin >= ringArray->GetEntriesFast()) {
816 AliWarning(Form("Eta bin=%3d out of bounds by +1 [%d,%d] for FMD%d%c, "
817 "trying %3d", etabin, 1, ringArray->GetEntriesFast(), d, r,
821 else if (!ringArray->At(etabin)) {
822 AliWarning(Form("Eta bin=%d has no fit for FMD%d%c, trying %03d",
823 etabin, d, r, etabin+1));
826 return static_cast<ELossFit*>(ringArray->At(etabin));
828 //____________________________________________________________________
829 AliFMDCorrELossFit::ELossFit*
830 AliFMDCorrELossFit::FindFit(UShort_t d, Char_t r, Double_t eta) const
833 // Find the fit corresponding to the specified parameters
841 // Fit parameters or null in case of problems
843 Int_t etabin = FindEtaBin(eta);
844 return FindFit(d, r, etabin);
846 //____________________________________________________________________
848 AliFMDCorrELossFit::GetRingArray(UShort_t d, Char_t r) const
851 // Get the ring array corresponding to the specified ring
858 // Pointer to ring array, or null in case of problems
862 case 1: idx = 0; break;
863 case 2: idx = (r == 'i' || r == 'I') ? 1 : 2; break;
864 case 3: idx = (r == 'o' || r == 'I') ? 3 : 4; break;
866 if (idx < 0 || idx >= fRings.GetEntriesFast()) return 0;
867 return static_cast<TObjArray*>(fRings.At(idx));
869 //____________________________________________________________________
871 AliFMDCorrELossFit::GetOrMakeRingArray(UShort_t d, Char_t r)
874 // Get the ring array corresponding to the specified ring
881 // Pointer to ring array, or newly created container
885 case 1: idx = 0; break;
886 case 2: idx = (r == 'i' || r == 'I') ? 1 : 2; break;
887 case 3: idx = (r == 'o' || r == 'I') ? 3 : 4; break;
889 if (idx < 0) return 0;
890 if (idx >= fRings.GetEntriesFast() || !fRings.At(idx)) {
891 TObjArray* a = new TObjArray(0);
892 // TOrdCollection* a = new TOrdCollection(fEtaAxis.GetNbins());
893 a->SetName(Form("FMD%d%c", d, r));
895 fRings.AddAtAndExpand(a, idx);
897 return static_cast<TObjArray*>(fRings.At(idx));
901 TH1D* MakeHist(const TAxis& axis, const char* name, const char* title,
904 TH1D* h = new TH1D(Form("%s_%s", name, title),
905 Form("%s %s", name, title),
906 axis.GetNbins(), axis.GetXmin(), axis.GetXmax());
908 h->SetMarkerStyle(20);
909 h->SetMarkerColor(color);
910 h->SetMarkerSize(0.5);
911 h->SetFillColor(color);
912 h->SetFillStyle(3001);
913 h->SetLineColor(color);
918 #define IDX2RING(I) (i == 0 || i == 1 || i == 3 ? 'I' : 'O')
919 #define IDX2DET(I) (i == 0 ? 1 : (i == 1 || i == 2 ? 2 : 3))
920 //____________________________________________________________________
922 AliFMDCorrELossFit::Draw(Option_t* option)
928 // option Options. Possible values are
929 // - err Plot error bars
931 TString opt(Form("nostack %s", option));
933 Bool_t rel = (opt.Contains("relative"));
934 Bool_t err = (opt.Contains("error"));
935 if (rel) opt.ReplaceAll("relative","");
936 if (err) opt.ReplaceAll("error","");
937 Int_t nRings = fRings.GetEntriesFast();
939 for (Int_t i = 0; i < nRings; i++) {
940 if (!fRings.At(i)) continue;
941 TObjArray* a = static_cast<TObjArray*>(fRings.At(i));
942 Int_t nFits = a->GetEntriesFast();
944 for (Int_t j = 0; j < nFits; j++) {
945 ELossFit* fit = static_cast<ELossFit*>(a->At(j));
947 maxN = TMath::Max(maxN, UShort_t(fit->fN));
950 // AliInfo(Form("Maximum N is %d", maxN));
951 Int_t nPad = 6+maxN-1; // 7 regular params, and maxN-1 weights
952 TVirtualPad* pad = gPad;
953 pad->Divide(2, (nPad+1)/2, 0.1, 0, 0);
972 stacks.AddAt(sChi2nu= new THStack("chi2", "#chi^{2}/#nu"), kChi2nu);
973 stacks.AddAt(sC = new THStack("c", "C"), kC);
974 stacks.AddAt(sDelta = new THStack("delta", "#Delta_{mp}"), kDelta);
975 stacks.AddAt(sXi = new THStack("xi", "#xi"), kXi);
976 stacks.AddAt(sSigma = new THStack("sigma", "#sigma"), kSigma);
977 //stacks.AddAt(sigman= new THStack("sigman", "#sigma_{n}"), 5);
978 stacks.AddAt(n = new THStack("n", "N"), kN);
979 for (Int_t i = 1; i <= maxN; i++) {
980 stacks.AddAt(new THStack(Form("a_%02d", i+1), Form("a_{%d}", i+1)), kN+i);
988 for (Int_t i = 0; i < nRings; i++) {
989 if (!fRings.At(i)) continue;
990 TObjArray* a = static_cast<TObjArray*>(fRings.At(i));
991 Int_t nFits = a->GetEntriesFast();
992 Int_t color = AliForwardUtil::RingColor(IDX2DET(i), IDX2RING(i));
994 TH1D* hChi = MakeHist(fEtaAxis,a->GetName(), "chi2", color);
995 TH1D* hC = MakeHist(fEtaAxis,a->GetName(), "c", color);
996 TH1D* hDelta = MakeHist(fEtaAxis,a->GetName(), "delta", color);
997 TH1D* hXi = MakeHist(fEtaAxis,a->GetName(), "xi", color);
998 TH1D* hSigma = MakeHist(fEtaAxis,a->GetName(), "sigma", color);
999 // TH1D* hSigmaN = MakeHist(fEtaAxis,a->GetName(), "sigman", color);
1000 TH1D* hN = MakeHist(fEtaAxis,a->GetName(), "n", color);
1002 const char* ho = (rel || !err ? "hist" : "e");
1003 sChi2nu->Add(hChi, "hist"); // 0
1004 sC ->Add(hC, ho); // 1
1005 sDelta ->Add(hDelta, ho); // 2
1006 sXi ->Add(hXi, ho); // 3
1007 sSigma ->Add(hSigma, ho); // 4
1008 // sigman->Add(hSigmaN,ho); // 5
1009 n ->Add(hN, "hist"); // 5
1010 hChi->SetFillColor(color);
1011 hChi->SetFillStyle(3001);
1012 hN->SetFillColor(color);
1013 hN->SetFillStyle(3001);
1015 for (Int_t k = 1; k <= maxN; k++) {
1016 hA[k-1] = MakeHist(fEtaAxis,a->GetName(), Form("a%02d",k+1), color);
1017 static_cast<THStack*>(stacks.At(kN+k))->Add(hA[k-1], ho);
1020 for (Int_t j = 0; j < nFits; j++) {
1021 ELossFit* f = static_cast<ELossFit*>(a->At(j));
1025 Int_t nW = f->FindMaxWeight();
1026 Double_t vChi2nu = (f->fNu <= 0 ? 0 : f->fChi2 / f->fNu);
1027 Double_t vC = (rel ? (f->fC >0 ?f->fEC /f->fC :0)
1029 Double_t vDelta = (rel ? (f->fDelta >0 ?f->fEDelta /f->fDelta :0)
1031 Double_t vXi = (rel ? (f->fXi >0 ?f->fEXi /f->fXi :0)
1033 Double_t vSigma = (rel ? (f->fSigma >0 ?f->fESigma /f->fSigma :0)
1035 // Double_t sigman = (rel ? (f->fSigmaN>0 ?f->fESigmaN/f->fSigmaN :0)
1037 hChi ->SetBinContent(b, vChi2nu);
1038 hN ->SetBinContent(b, nW);
1039 hC ->SetBinContent(b, vC);
1040 hDelta ->SetBinContent(b, vDelta);
1041 hXi ->SetBinContent(b, vXi);
1042 hSigma ->SetBinContent(b, vSigma);
1043 if (vChi2nu > 1e-12) {
1044 min[kChi2nu] = TMath::Min(min[kChi2nu], vChi2nu);
1045 max[kChi2nu] = TMath::Max(max[kChi2nu], vChi2nu);
1048 min[kC] = TMath::Min(min[kC], vC);
1049 max[kC] = TMath::Max(max[kC], vC);
1051 if (vDelta > 1e-12) {
1052 min[kDelta] = TMath::Min(min[kDelta], vDelta);
1053 max[kDelta] = TMath::Max(max[kDelta], vDelta);
1056 min[kXi] = TMath::Min(min[kXi], vXi);
1057 max[kXi] = TMath::Max(max[kXi], vXi);
1059 if (vSigma > 1e-12) {
1060 min[kSigma] = TMath::Min(min[kSigma], vSigma);
1061 max[kSigma] = TMath::Max(max[kSigma], vSigma);
1064 min[kN] = TMath::Min(min[kN], Double_t(nW));
1065 max[kN] = TMath::Max(max[kN], Double_t(nW));
1067 // hSigmaN->SetBinContent(b, sigman);
1069 hC ->SetBinError(b, f->fEC);
1070 hDelta ->SetBinError(b, f->fEDelta);
1071 hXi ->SetBinError(b, f->fEXi);
1072 hSigma ->SetBinError(b, f->fESigma);
1073 // hSigmaN->SetBinError(b, f->fESigmaN);
1075 for (Int_t k = 0; k < f->fN-1 && k < maxN; k++) {
1076 Double_t vA = (rel ? (f->fA[k] > 0 ? f->fEA[k] / f->fA[k] : 0)
1078 hA[k]->SetBinContent(b, vA);
1079 if (!rel) hA[k]->SetBinError(b, f->fEA[k]);
1081 min[kN+1+k] = TMath::Min(min[kN+1+k], vA);
1082 max[kN+1+k] = TMath::Max(max[kN+1+k], vA);
1087 Int_t nPad2 = (nPad+1) / 2;
1088 for (Int_t i = 0; i < nPad; i++) {
1089 Int_t iPad = 1 + i/nPad2 + 2 * (i % nPad2);
1090 TVirtualPad* p = pad->cd(iPad);
1091 p->SetLeftMargin(.15);
1096 if (rel && i != 0 && i != 6 && i != 5 && i != 4) p->SetLogy();
1098 Double_t powMax = TMath::Log10(max[i]);
1099 Double_t powMin = min[i] <= 0 ? powMax : TMath::Log10(min[i]);
1100 if (powMax-powMin > 2. && min[i] != 0) p->SetLogy();
1102 THStack* stack = static_cast<THStack*>(stacks.At(i));
1103 // stack->SetMinimum(min[i]);
1104 // stack->SetMaximum(max[i]);
1105 stack->Draw(opt.Data());
1107 TString tit(stack->GetTitle());
1108 if (rel && i != 0 && i != 6)
1109 tit = Form("#delta %s/%s", tit.Data(), tit.Data());
1110 TH1* hist = stack->GetHistogram();
1111 TAxis* yaxis = hist->GetYaxis();
1112 yaxis->SetTitle(tit.Data());
1113 yaxis->SetTitleSize(0.15);
1114 yaxis->SetLabelSize(0.08);
1115 yaxis->SetTitleOffset(0.35);
1116 yaxis->SetTitleFont(132);
1117 yaxis->SetLabelFont(132);
1118 yaxis->SetNdivisions(5);
1121 TAxis* xaxis = stack->GetHistogram()->GetXaxis();
1122 xaxis->SetTitle("#eta");
1123 xaxis->SetTitleSize(0.15);
1124 xaxis->SetLabelSize(0.08);
1125 xaxis->SetTitleOffset(0.35);
1126 xaxis->SetTitleFont(132);
1127 xaxis->SetLabelFont(132);
1128 xaxis->SetNdivisions(10);
1130 stack->Draw(opt.Data());
1135 //____________________________________________________________________
1137 AliFMDCorrELossFit::Print(Option_t* option) const
1139 TString opt(option);
1141 Int_t nRings = fRings.GetEntriesFast();
1142 bool recurse = opt.Contains("R");
1144 std::cout << "Low cut in fit range: " << fLowCut << "\n"
1145 << "Eta axis: " << fEtaAxis.GetNbins()
1146 << " bins, range [" << fEtaAxis.GetXmin() << ","
1147 << fEtaAxis.GetXmax() << "]" << std::endl;
1149 for (Int_t i = 0; i < nRings; i++) {
1150 if (!fRings.At(i)) continue;
1151 TObjArray* a = static_cast<TObjArray*>(fRings.At(i));
1152 Int_t nFits = a->GetEntriesFast();
1154 std::cout << a->GetName() << " [" << nFits << " entries]"
1155 << (recurse ? ":\n" : "\t");
1156 Int_t min = fEtaAxis.GetNbins()+1;
1158 for (Int_t j = 0; j < nFits; j++) {
1159 if (!a->At(j)) continue;
1161 min = TMath::Min(j, min);
1162 max = TMath::Max(j, max);
1165 std::cout << "Bin # " << j << "\t";
1166 ELossFit* fit = static_cast<ELossFit*>(a->At(j));
1171 std::cout << " bin range: " << std::setw(3) << min
1172 << "-" << std::setw(3) << max << " " << std::setw(3)
1173 << (max-min+1) << " bins" << std::endl;
1177 //____________________________________________________________________
1179 AliFMDCorrELossFit::Browse(TBrowser* b)
1182 // Browse this object
1193 //____________________________________________________________________