14 #include <TDatabasePDG.h>
21 #include <THashList.h>
22 #include <TMCProcess.h>
24 #include <TObjArray.h>
25 #include <TObjString.h>
27 #include <TParticlePDG.h>
47 if (xmin < 1e-20 || xmax < 1e-20) {
48 Error(
"PairAnalysisHelper::MakeLogBinning",
49 "For Log binning xmin and xmax must be > 1e-20. Using linear binning "
58 TVectorD* binLim =
new TVectorD(nbinsX + 1);
59 Double_t
first = xmin;
61 Double_t expMax = TMath::Log(last /
first);
62 for (Int_t
i = 0;
i < nbinsX + 1; ++
i) {
63 (*binLim)[
i] =
first * TMath::Exp(expMax / nbinsX * (Double_t)
i);
80 TVectorD* binLim =
new TVectorD(nbinsX + 1);
81 Double_t
first = xmin;
83 Double_t binWidth = (last -
first) / nbinsX;
84 for (Int_t
i = 0;
i < nbinsX + 1; ++
i) {
85 (*binLim)[
i] =
first + binWidth * (Double_t)
i;
96 if (limits.IsNull()) {
97 Error(
"PairAnalysisHelper::MakeArbitraryBinning",
98 "Bin Limit string is empty, cannot add the variable");
102 TObjArray* arr = limits.Tokenize(
",");
103 Int_t nLimits = arr->GetEntries();
105 Error(
"PairAnalysisHelper::MakeArbitraryBinning",
106 "Need at leas 2 bin limits, cannot add the variable");
111 TVectorD* binLimits =
new TVectorD(nLimits);
112 for (Int_t iLim = 0; iLim < nLimits; ++iLim) {
114 (
static_cast<TObjString*
>(arr->At(iLim)))->GetString().Atof();
130 TVectorD* binLim =
new TVectorD(nbinsX + 1);
132 TF1 g(
"g",
"gaus", mean - 5 * sigma, mean + 5 * sigma);
133 g.SetParameters(1, mean, sigma);
134 Double_t sum = g.Integral(mean - 5 * sigma, mean + 5 * sigma);
137 TF1 g2(
"g2",
"gaus(0)/[3]", mean - 5 * sigma, mean + 5 * sigma);
138 g2.SetParameters(1, mean, sigma, sum);
142 Double_t epsilon = sigma / 10000;
143 Double_t xt = mean - 5 * sigma;
147 Double_t lim = epsilon;
150 while ((xt += epsilon) <= mean + 5 * sigma) {
155 g2.Integral(mean - 5 * sigma, xt);
159 if (cint >= lim && pint < lim) {
166 lim = bin * (1. / nbinsX);
168 if (bin == nbinsX) lim = 1. - epsilon;
187 Int_t lastEqualsFirst =
188 (Int_t)(TMath::Abs((*low)[low->GetNrows() - 1] - (*high)[0]) < 1.e-15);
190 new TVectorD(low->GetNrows() + high->GetNrows() - lastEqualsFirst);
191 for (Int_t
i = 0;
i < low->GetNrows();
i++)
192 (*binLim)[
i] = (*low)[
i];
193 for (Int_t
i = 0;
i < high->GetNrows() - lastEqualsFirst;
i++)
194 (*binLim)[low->GetNrows() +
i] = (*high)[
i + lastEqualsFirst];
207 if (!
h || stat > 1.)
return 0x0;
211 Double_t from =
h->GetBinLowEdge(1);
214 TArrayD* vBins =
new TArrayD(1 + 1);
215 vBins->AddAt(from, 0);
218 for (Int_t
i = 1;
i <=
h->GetNbinsX();
i++) {
220 if (
h->GetBinContent(
i) == 0.0 &&
h->GetBinError(
i) == 0.)
continue;
222 to =
h->GetBinLowEdge(
i + 1);
223 cont +=
h->GetBinContent(
i);
224 err += (
h->GetBinError(
i) *
h->GetBinError(
i));
225 vBins->AddAt(to, vEle);
232 TMath::Sqrt(err) / cont <= stat
241 vBins->Set(vEle + 1);
245 vBins->AddAt(
h->GetXaxis()->GetXmax(), vBins->GetSize() - 1);
258 TDatabasePDG* pdg =
new TDatabasePDG();
260 TIter next(pdg->ParticleList());
264 while ((p = (TParticlePDG*) next())) {
265 if (TMath::Abs(p->PdgCode()) < 1e+6) {
267 gr.SetPoint(
i++, p->PdgCode(), 1.);
271 TVectorD* vec =
new TVectorD(
gr.GetN(),
gr.GetX());
279 const Double_t* values) {
283 Double_t params[10] = {0.};
285 for (Int_t ip = 0; ip < form->GetNpar(); ip++)
286 params[ip] = values[(UInt_t) form->GetParameter(ip)];
287 return (form->EvalPar(0x0, params));
296 TString tform(form->GetExpFormula());
301 tform.ReplaceAll(
"*",
"#upoint");
303 tform.ReplaceAll(
"TMath::",
"");
304 tform.ReplaceAll(
"()",
"");
307 for (Int_t j = 0; j < form->GetNpar(); j++)
320 for (Int_t j = 0; j < form->GetNpar(); j++) {
323 if (j != form->GetNpar() - 1) tform +=
",";
331 const char* formula) {
335 TString check(formula);
336 if (check.IsNull())
return 0x0;
337 TFormula* form =
new TFormula(name, formula);
339 if (form->Compile())
return 0x0;
341 for (Int_t
i = 0;
i < form->GetNpar();
i++) {
356 if (!hLbl) hLbl = hist;
358 TDatabasePDG* pdg = TDatabasePDG::Instance();
359 TAxis* xaxis = hLbl->GetXaxis();
360 for (Int_t
i = 1;
i < hist->GetNbinsX() + 1;
i++) {
362 if (clean && !hist->GetBinContent(
i))
continue;
363 Int_t pdgCode = (Int_t) xaxis->GetBinLowEdge(
i);
364 TParticlePDG* p = pdg->GetParticle(pdgCode);
369 if (hLbl->GetDimension() == 1)
return;
371 TAxis* yaxis = hLbl->GetYaxis();
372 TString keyY = yaxis->GetName();
373 if (keyY.Contains(
"pdg", TString::kIgnoreCase)) {
374 for (Int_t
i = 1;
i < hist->GetNbinsY() + 1;
i++) {
376 if (clean && !hist->GetBinContent(
i))
continue;
377 Int_t pdgCode = (Int_t) yaxis->GetBinLowEdge(
i);
378 TParticlePDG* p = pdg->GetParticle(pdgCode);
391 TString name = TDatabasePDG::Instance()->GetParticle(pdg)->GetName();
392 name.ReplaceAll(
"dd_1_bar",
"primary");
393 name.ReplaceAll(
"proton",
"p");
411 name.ReplaceAll(
"delta",
"#delta");
412 name.ReplaceAll(
"gamma",
"#gamma");
413 name.ReplaceAll(
"psi",
"#psi");
414 name.ReplaceAll(
"sigma",
"#sigma");
415 name.ReplaceAll(
"xi",
"#xi");
416 name.ReplaceAll(
"lambda",
"#lambda");
417 name.ReplaceAll(
"omega",
"#omega");
418 name.ReplaceAll(
"eta",
"#eta");
419 name.ReplaceAll(
"tau",
"#tau");
420 name.ReplaceAll(
"phi",
"#phi");
421 name.ReplaceAll(
"upsilon",
"#upsilon");
422 name.ReplaceAll(
"nu",
"#nu");
423 name.ReplaceAll(
"mu",
"#mu");
424 name.ReplaceAll(
"pi",
"#pi");
425 name.ReplaceAll(
"rho",
"#rho");
428 if (name.Contains(
"anti")) {
429 name.ReplaceAll(
"anti",
"#bar{");
431 }
else if (name.Contains(
"_bar")) {
432 name.ReplaceAll(
"_bar",
"}");
433 name.Prepend(
"#bar{");
436 name.ReplaceAll(
"+",
"^{+}");
437 name.ReplaceAll(
"-",
"^{-}");
438 name.ReplaceAll(
"0",
"^{0}");
439 name.ReplaceAll(
"_s",
"_{s}");
440 name.ReplaceAll(
"_c",
"_{c}");
441 name.ReplaceAll(
"_b",
"_{b}");
442 name.ReplaceAll(
"_1",
"_{1}");
444 name.ReplaceAll(
"/psi",
"/#psi");
454 TAxis* xaxis = hist->GetXaxis();
455 for (Int_t
i = 1;
i < hist->GetNbinsX() + 1;
i++) {
456 xaxis->SetBinLabel(
i, TMCProcessName[
i - 1]);
458 xaxis->LabelsOption(
"v");
460 xaxis->SetTitleOffset(3.6);
461 gPad->SetTopMargin(0.01);
462 gPad->SetBottomMargin(0.4);
484 Int_t bin, binx, biny, binz;
485 Int_t xfirst =
h->GetXaxis()->GetFirst();
486 Int_t xlast =
h->GetXaxis()->GetLast();
487 Int_t yfirst =
h->GetYaxis()->GetFirst();
488 Int_t ylast =
h->GetYaxis()->GetLast();
489 Int_t zfirst =
h->GetZaxis()->GetFirst();
490 Int_t zlast =
h->GetZaxis()->GetLast();
491 Double_t minimum = FLT_MAX, value = 0., error = 0.;
492 for (binz = zfirst; binz <= zlast; binz++) {
493 for (biny = yfirst; biny <= ylast; biny++) {
494 for (binx = xfirst; binx <= xlast; binx++) {
495 bin =
h->GetBin(binx, biny, binz);
496 value =
h->GetBinContent(bin);
497 error =
h->GetBinError(bin);
499 if (gPad->GetLogy() && (value - error) <= 0.)
continue;
500 if (error > value * 0.9)
continue;
501 if (inclErr) value -=
h->GetBinError(bin);
503 && TMath::Abs(
h->GetBinError(bin) - 1.e-15) > 1.e-15) {
517 Int_t bin, binx, biny, binz;
518 Int_t xfirst =
h->GetXaxis()->GetFirst();
519 Int_t xlast =
h->GetXaxis()->GetLast();
520 Int_t yfirst =
h->GetYaxis()->GetFirst();
521 Int_t ylast =
h->GetYaxis()->GetLast();
522 Int_t zfirst =
h->GetZaxis()->GetFirst();
523 Int_t zlast =
h->GetZaxis()->GetLast();
524 Double_t maximum = -1. * FLT_MAX, value = 0., error = 0.;
525 for (binz = zfirst; binz <= zlast; binz++) {
526 for (biny = yfirst; biny <= ylast; biny++) {
527 for (binx = xfirst; binx <= xlast; binx++) {
528 bin =
h->GetBin(binx, biny, binz);
529 value =
h->GetBinContent(bin);
530 error =
h->GetBinError(bin);
531 if (inclErr) value +=
h->GetBinError(bin);
532 if (value > maximum && TMath::Abs(error - 1.e-15) > 1.e-15) {
546 if (p < 0.0 || p > 1.)
return -1.;
547 Int_t nbinsX = h1->GetNbinsX();
548 Int_t nbinsY = h1->GetNbinsY();
549 Int_t nbinsZ = h1->GetNbinsZ();
550 Int_t nbins = (nbinsX * (nbinsY ? nbinsY : 1) * (nbinsZ ? nbinsZ : 1));
557 for (Int_t
i = 1;
i <= nbins;
i++) {
558 h1->GetBinXYZ(
i, xbin, ybin, zbin);
559 if (xbin < h1->GetXaxis()->GetFirst() || xbin > h1->GetXaxis()->GetLast())
561 if (ybin < h1->GetYaxis()->GetFirst() || ybin > h1->GetYaxis()->GetLast())
563 Double_t con = h1->GetBinContent(
i);
564 Double_t err = h1->GetBinError(
i);
568 con + (h1->GetDimension() < 2 ? err : 0.0);
572 if (nfilled == 0)
return -1.;
573 TMath::Sort(nfilled, val, idx, kFALSE);
574 Int_t
pos = (Int_t)((Double_t) nfilled * p);
577 return val[idx[
pos]];
584 TH2* hsum = (TH2*)
h->Clone(
"SliceInts");
586 for (Int_t ix = 0; ix <= hsum->GetNbinsX() + 1; ix++) {
587 Double_t ysum =
h->Integral(ix, ix);
588 for (Int_t iy = 0; iy <= hsum->GetNbinsY() + 1; iy++) {
589 hsum->SetBinContent(ix, iy, ysum);
603 Int_t xstart = (reverse ?
h->GetNbinsX() + 1 : 0 - 1);
604 Int_t xend = (reverse ? 0 :
h->GetNbinsX() + 1 + 1);
605 Int_t xincr = (reverse ? -1 : +1);
607 Double_t integral = 1.;
608 for (Int_t iy = 0; iy <=
h->GetNbinsY() + 1; iy++) {
609 if (norm) integral =
h->Integral(0,
h->GetNbinsX() + 1, iy, iy);
612 for (Int_t ix = xstart; ix != xend; ix += xincr) {
613 cumInt +=
h->GetBinContent(ix, iy);
614 h->SetBinContent(ix, iy, cumInt / integral);
624 Int_t xstart = (reverse ?
h->GetNbinsX() + 1 : 0 - 1);
625 Int_t xend = (reverse ? 0 :
h->GetNbinsX() + 1 + 1);
626 Int_t xincr = (reverse ? -1 : +1);
628 Double_t integral = 1.;
629 if (norm) integral =
h->Integral(0,
h->GetNbinsX() + 1);
632 for (Int_t ix = xstart; ix != xend; ix += xincr) {
633 cumInt +=
h->GetBinContent(ix);
634 h->SetBinContent(ix, cumInt / integral);
644 for (Int_t
i = 0;
i < arrhist->GetEntriesFast();
i++) {
645 if (!ref.CompareTo(arrhist->UncheckedAt(
i)->GetTitle())) {
646 return arrhist->UncheckedAt(
i);
662 Bool_t bfnd = kFALSE;
668 ((TMath::Abs(value * TMath::Power(10, precision)) / 1e6
669 - TMath::Floor(TMath::Abs(value * TMath::Power(10, precision)) / 1e6))
673 if (!bfnd) precision++;